aboutsummaryrefslogtreecommitdiff
path: root/sys/fio/ffilbf.x
diff options
context:
space:
mode:
authorJoe Hunkeler <jhunkeler@gmail.com>2015-08-11 16:51:37 -0400
committerJoe Hunkeler <jhunkeler@gmail.com>2015-08-11 16:51:37 -0400
commit40e5a5811c6ffce9b0974e93cdd927cbcf60c157 (patch)
tree4464880c571602d54f6ae114729bf62a89518057 /sys/fio/ffilbf.x
downloadiraf-osx-40e5a5811c6ffce9b0974e93cdd927cbcf60c157.tar.gz
Repatch (from linux) of OSX IRAF
Diffstat (limited to 'sys/fio/ffilbf.x')
-rw-r--r--sys/fio/ffilbf.x37
1 files changed, 37 insertions, 0 deletions
diff --git a/sys/fio/ffilbf.x b/sys/fio/ffilbf.x
new file mode 100644
index 00000000..8948ce89
--- /dev/null
+++ b/sys/fio/ffilbf.x
@@ -0,0 +1,37 @@
+# Copyright(c) 1986 Association of Universities for Research in Astronomy Inc.
+
+include <config.h>
+include <fio.h>
+
+# FFILBF -- Called by FFAULT to fill the file buffer for a binary file.
+
+procedure ffilbf (fd, bp, bufsize, buffer_offset)
+
+int fd, bufsize
+pointer bp
+bool at_eof, stream_dev
+long buffer_offset
+errchk fwatio
+include <fio.com>
+
+begin
+ fp = fiodes[fd]
+
+ if (FBUFMODE(fp) != INACTIVE)
+ call fwatio (fd)
+
+ # If streaming device, read unconditionally, otherwise if
+ # positioned at EOF, initialize buffer pointers and return,
+ # else initiate read to fill buffer from file and return.
+
+ stream_dev = (FBLKSIZE(fp) == 0)
+ at_eof = (FILSIZE(fp) >= 0 && buffer_offset > FILSIZE(fp))
+
+ if (!stream_dev && at_eof) {
+ itop[fd] = bufptr[fd]
+ otop[fd] = bufptr[fd]
+ } else {
+ call aread (fd, Memc[bp], bufsize, buffer_offset)
+ FBUFMODE(fp) = READ_IN_PROGRESS
+ }
+end