aboutsummaryrefslogtreecommitdiff
path: root/sys/etc/prfilbuf.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/etc/prfilbuf.x
downloadiraf-osx-40e5a5811c6ffce9b0974e93cdd927cbcf60c157.tar.gz
Repatch (from linux) of OSX IRAF
Diffstat (limited to 'sys/etc/prfilbuf.x')
-rw-r--r--sys/etc/prfilbuf.x38
1 files changed, 38 insertions, 0 deletions
diff --git a/sys/etc/prfilbuf.x b/sys/etc/prfilbuf.x
new file mode 100644
index 00000000..4ec09907
--- /dev/null
+++ b/sys/etc/prfilbuf.x
@@ -0,0 +1,38 @@
+# Copyright(c) 1986 Association of Universities for Research in Astronomy Inc.
+
+include <config.h>
+include <fio.h>
+
+# PRFILBUF -- Fill the FIO buffer from a process. The function is equivalent
+# to the ordinary FIO filbuf with the exception that pseudofile read and
+# write directives are intercepted and processed. Hence, the reader sees a
+# stream of application specific commands need not know about pseudofile i/o.
+
+int procedure prfilbuf (fd)
+
+int fd # parent's input IPC from child process
+
+int pr
+int filbuf(), prpsio()
+include "prc.com"
+
+begin
+ # Determine which process has the given file as its CLIN stream.
+ # If FD not associated with a process call ordinary FILBUF, otherwise
+ # call PR_PSIO. To minimize searches of the process table we keep
+ # track of the slot number of the last active pid.
+
+ if (pr_infd[pr_lastio] == fd && pr_pid[pr_lastio] != NULL)
+ pr = pr_lastio
+ else {
+ for (pr=1; pr <= MAX_CHILDPROCS; pr=pr+1)
+ if (pr_pid[pr] != NULL)
+ if (pr_infd[pr] == fd)
+ break
+ if (pr > MAX_CHILDPROCS)
+ return (filbuf (fd)) # normal file
+ pr_lastio = pr
+ }
+
+ return (prpsio (pr_pid[pr], CLIN, FF_READ))
+end