From 40e5a5811c6ffce9b0974e93cdd927cbcf60c157 Mon Sep 17 00:00:00 2001 From: Joe Hunkeler Date: Tue, 11 Aug 2015 16:51:37 -0400 Subject: Repatch (from linux) of OSX IRAF --- noao/mtlocal/pds/pds_read.x | 71 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 71 insertions(+) create mode 100644 noao/mtlocal/pds/pds_read.x (limited to 'noao/mtlocal/pds/pds_read.x') diff --git a/noao/mtlocal/pds/pds_read.x b/noao/mtlocal/pds/pds_read.x new file mode 100644 index 00000000..0cba96d7 --- /dev/null +++ b/noao/mtlocal/pds/pds_read.x @@ -0,0 +1,71 @@ + +include +include +include "rpds.h" + +# PDS_READ -- Convert a PDS file +# An EOT is signalled by returning EOF. + +int procedure pds_read (pdsfile, iraffile) + +char pdsfile[ARB], iraffile[ARB] +int pds_fd +int stat +long parameters[LEN_PAR_ARRAY] +pointer im + +int pds_read_header(), mtopen() +pointer immap() + +errchk salloc, pds_read_header, pds_read_image, mtopen, immap, imdelete + +include "rpds.com" + +begin + # Open input PDS data + pds_fd = mtopen (pdsfile, READ_ONLY, 0) + + if (long_header == YES || short_header == YES) { + if (make_image == YES) { + call printf ("File: %s ") + call pargstr (iraffile) + } else { + call printf ("File: %s ") + call pargstr (pdsfile) + } + if (long_header == YES) + call printf ("\n") + } + + # Create IRAF image header. If only a header listing is desired + # then a temporary image header is created and later deleted. + + if (make_image == NO) + call strcpy ("dev$null", iraffile, SZ_FNAME) + + im = immap (iraffile, NEW_IMAGE, 0) + + # Read header. EOT is signalled by an EOF status from pds_read_header. + iferr { + stat = pds_read_header (pds_fd, im, parameters) + if (stat == EOF) + call printf ("End of data\n") + else { + # Create an IRAF image if desired + if (make_image == YES) + call pds_read_image (pds_fd, im, parameters) + } + } then + call erract (EA_WARN) + + if (long_header == YES) + call printf ("\n") + + # Close files and clean up + call imunmap (im) + if (stat == EOF || make_image == NO) + call imdelete (iraffile) + call close (pds_fd) + + return (stat) +end -- cgit