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/fwatio.x | |
download | iraf-linux-fa080de7afc95aa1c19a6e6fc0e0708ced2eadc4.tar.gz |
Initial commit
Diffstat (limited to 'sys/fio/fwatio.x')
-rw-r--r-- | sys/fio/fwatio.x | 50 |
1 files changed, 50 insertions, 0 deletions
diff --git a/sys/fio/fwatio.x b/sys/fio/fwatio.x new file mode 100644 index 00000000..15e9c249 --- /dev/null +++ b/sys/fio/fwatio.x @@ -0,0 +1,50 @@ +# Copyright(c) 1986 Association of Universities for Research in Astronomy Inc. + +include <config.h> +include <syserr.h> +include <fio.h> + +# FWATIO -- Wait for i/o to complete on the file buffer, update file +# buffer pointers. + +procedure fwatio (fd) + +int fd +int nchars, bufmode +int await() +errchk filerr +include <fio.com> + +begin + fp = fiodes[fd] + + if (FBUFMODE(fp) == INACTIVE) + return + + else { + nchars = await (fd) + + # Set the buffer mode flag to inactive regardless of the status + # returned by await. + + bufmode = FBUFMODE(fp) + FBUFMODE(fp) = INACTIVE + + if (bufmode == READ_IN_PROGRESS) { + if (nchars == ERR) + call filerr (FNAME(fp), SYS_FREAD) + else + itop[fd] = bufptr[fd] + nchars + + } else if (nchars == ERR) { + # If an i/o error occurs on a write invalidate the buffer + # else during error recovery close will try again to write + # the data, probably causing another error. + + otop[fd] = bufptr[fd] + call filerr (FNAME(fp), SYS_FWRITE) + } + + otop[fd] = bufptr[fd] + } +end |