aboutsummaryrefslogtreecommitdiff
path: root/sys/etc/gen/miireadi.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/miireadi.x
downloadiraf-linux-fa080de7afc95aa1c19a6e6fc0e0708ced2eadc4.tar.gz
Initial commit
Diffstat (limited to 'sys/etc/gen/miireadi.x')
-rw-r--r--sys/etc/gen/miireadi.x50
1 files changed, 50 insertions, 0 deletions
diff --git a/sys/etc/gen/miireadi.x b/sys/etc/gen/miireadi.x
new file mode 100644
index 00000000..666166e6
--- /dev/null
+++ b/sys/etc/gen/miireadi.x
@@ -0,0 +1,50 @@
+# Copyright(c) 1986 Association of Universities for Research in Astronomy Inc.
+
+include <mii.h>
+
+# MIIREAD -- Read a block of data stored externally in MII format.
+# Data is returned in the format of the local host machine.
+
+int procedure mii_readi (fd, spp, maxelem)
+
+int fd #I input file
+int spp[ARB] #O receives data
+int maxelem # max number of data elements to be read
+
+pointer sp, bp
+int pksize, nchars, nelem
+int miipksize(), miinelem(), read()
+errchk read()
+
+long note()
+
+begin
+ pksize = miipksize (maxelem, MII_INT)
+ nelem = EOF
+
+ if (pksize > maxelem * SZ_INT) {
+ # 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, miinelem (nchars, MII_INT))
+ call miiupki (Memc[bp], spp, nelem, TY_INT)
+ }
+
+ call sfree (sp)
+
+ } else {
+ # Read data into user buffer and unpack in place.
+
+ nchars = read (fd, spp, pksize)
+ if (nchars != EOF) {
+ nelem = min (maxelem, miinelem (nchars, MII_INT))
+ call miiupki (spp, spp, nelem, TY_INT)
+ }
+ }
+
+ return (nelem)
+end