aboutsummaryrefslogtreecommitdiff
path: root/sys/etc/gen/nmireadb.x
diff options
context:
space:
mode:
authorJoseph Hunkeler <jhunkeler@gmail.com>2015-07-08 20:46:52 -0400
committerJoseph Hunkeler <jhunkeler@gmail.com>2015-07-08 20:46:52 -0400
commitfa080de7afc95aa1c19a6e6fc0e0708ced2eadc4 (patch)
treebdda434976bc09c864f2e4fa6f16ba1952b1e555 /sys/etc/gen/nmireadb.x
downloadiraf-linux-fa080de7afc95aa1c19a6e6fc0e0708ced2eadc4.tar.gz
Initial commit
Diffstat (limited to 'sys/etc/gen/nmireadb.x')
-rw-r--r--sys/etc/gen/nmireadb.x50
1 files changed, 50 insertions, 0 deletions
diff --git a/sys/etc/gen/nmireadb.x b/sys/etc/gen/nmireadb.x
new file mode 100644
index 00000000..c3c0f75e
--- /dev/null
+++ b/sys/etc/gen/nmireadb.x
@@ -0,0 +1,50 @@
+# Copyright(c) 1986 Association of Universities for Research in Astronomy Inc.
+
+include <nmi.h>
+
+# NMIREAD -- Read a block of data stored externally in NMI format.
+# Data is returned in the format of the local host machine.
+
+int procedure nmi_readb (fd, spp, maxelem)
+
+int fd #I input file
+bool spp[ARB] #O receives data
+int maxelem # max number of data elements to be read
+
+pointer sp, bp
+int pksize, nchars, nelem
+int nmipksize(), nminelem(), read()
+errchk read()
+
+long note()
+
+begin
+ pksize = nmipksize (maxelem, NMI_BOOL)
+ nelem = EOF
+
+ if (pksize > maxelem * SZ_BOOL) {
+ # Read data into local buffer and unpack into user buffer.
+
+ call smark (sp)
+ call salloc (bp, pksize, TY_CHAR)
+
+ nchars = read (fd, Memc[bp], pksize)
+ if (nchars != EOF) {
+ nelem = min (maxelem, nminelem (nchars, NMI_BOOL))
+ call nmiupkb (Memc[bp], spp, nelem, TY_BOOL)
+ }
+
+ call sfree (sp)
+
+ } else {
+ # Read data into user buffer and unpack in place.
+
+ nchars = read (fd, spp, pksize)
+ if (nchars != EOF) {
+ nelem = min (maxelem, nminelem (nchars, NMI_BOOL))
+ call nmiupkb (spp, spp, nelem, TY_BOOL)
+ }
+ }
+
+ return (nelem)
+end