diff options
author | Joe Hunkeler <jhunkeler@gmail.com> | 2015-08-11 16:51:37 -0400 |
---|---|---|
committer | Joe Hunkeler <jhunkeler@gmail.com> | 2015-08-11 16:51:37 -0400 |
commit | 40e5a5811c6ffce9b0974e93cdd927cbcf60c157 (patch) | |
tree | 4464880c571602d54f6ae114729bf62a89518057 /sys/etc/gen/nmireads.x | |
download | iraf-osx-40e5a5811c6ffce9b0974e93cdd927cbcf60c157.tar.gz |
Repatch (from linux) of OSX IRAF
Diffstat (limited to 'sys/etc/gen/nmireads.x')
-rw-r--r-- | sys/etc/gen/nmireads.x | 50 |
1 files changed, 50 insertions, 0 deletions
diff --git a/sys/etc/gen/nmireads.x b/sys/etc/gen/nmireads.x new file mode 100644 index 00000000..190ce28f --- /dev/null +++ b/sys/etc/gen/nmireads.x @@ -0,0 +1,50 @@ +# Copyright(c) 1986 Association of Universities for Research in Astronomy Inc. + +include <nmi.h> + +# NMI_READ -- Read a block of data stored externally in NMI format. +# Data is returned in the format of the local host machine. + +int procedure nmi_reads (fd, spp, maxelem) + +int fd #I input file +short 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_SHORT) + nelem = EOF + + if (pksize > maxelem * SZ_SHORT) { + # 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_SHORT)) + call nmiupks (Memc[bp], spp, nelem, TY_SHORT) + } + + 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_SHORT)) + call nmiupks (spp, spp, nelem, TY_SHORT) + } + } + + return (nelem) +end |