From 40e5a5811c6ffce9b0974e93cdd927cbcf60c157 Mon Sep 17 00:00:00 2001 From: Joe Hunkeler Date: Tue, 11 Aug 2015 16:51:37 -0400 Subject: Repatch (from linux) of OSX IRAF --- sys/fio/write.x | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100644 sys/fio/write.x (limited to 'sys/fio/write.x') diff --git a/sys/fio/write.x b/sys/fio/write.x new file mode 100644 index 00000000..66241ff5 --- /dev/null +++ b/sys/fio/write.x @@ -0,0 +1,40 @@ +# Copyright(c) 1986 Association of Universities for Research in Astronomy Inc. + +include +include +include + +# WRITE -- Write binary chars to a file. The specified number of chars will +# always be written (with the file buffer being flushed as many times as +# necessary) unless an error occurs. + +procedure write (fd, buffer, maxchars) + +int fd +char buffer[ARB] +int maxchars +int nchars, chunk_size +errchk flsbuf +include + +begin + if (fd <= 0 || fiodes[fd] == NULL) + call syserr (SYS_FILENOTOPEN) + + nchars = 0 + + while (nchars < maxchars) { + if (iop[fd] < bufptr[fd] || iop[fd] >= otop[fd]) + call flsbuf (fd, maxchars - nchars) + chunk_size = min (maxchars - nchars, otop[fd] - iop[fd]) + if (chunk_size <= 0) + break + else { + call amovc (buffer[nchars+1], Memc[iop[fd]], chunk_size) + iop[fd] = iop[fd] + chunk_size + nchars = nchars + chunk_size + } + } + + FNCHARS(fiodes[fd]) = nchars +end -- cgit