diff options
author | Joseph Hunkeler <jhunkeler@gmail.com> | 2015-07-08 20:46:52 -0400 |
---|---|---|
committer | Joseph Hunkeler <jhunkeler@gmail.com> | 2015-07-08 20:46:52 -0400 |
commit | fa080de7afc95aa1c19a6e6fc0e0708ced2eadc4 (patch) | |
tree | bdda434976bc09c864f2e4fa6f16ba1952b1e555 /sys/fio/write.x | |
download | iraf-linux-fa080de7afc95aa1c19a6e6fc0e0708ced2eadc4.tar.gz |
Initial commit
Diffstat (limited to 'sys/fio/write.x')
-rw-r--r-- | sys/fio/write.x | 40 |
1 files changed, 40 insertions, 0 deletions
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 <config.h> +include <syserr.h> +include <fio.h> + +# 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 <fio.com> + +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 |