diff options
Diffstat (limited to 'noao/onedspec/t_names.x')
-rw-r--r-- | noao/onedspec/t_names.x | 45 |
1 files changed, 45 insertions, 0 deletions
diff --git a/noao/onedspec/t_names.x b/noao/onedspec/t_names.x new file mode 100644 index 00000000..b6f81fe9 --- /dev/null +++ b/noao/onedspec/t_names.x @@ -0,0 +1,45 @@ +# T_NAMES -- Expand record extension format into a list of images. + +procedure t_names () + +pointer list # Input record list +pointer append # String to append to name +bool check # Check existence of image? + +int imtgetim() +bool clgetb() +pointer sp, image, im, imtopenp(), immap() + +begin + call smark (sp) + call salloc (image, SZ_FNAME, TY_CHAR) + call salloc (append, SZ_LINE, TY_CHAR) + + # Get parameters. + list = imtopenp ("input") + call clgstr ("records", Memc[append], SZ_LINE) + call odr_openp (list, Memc[append]) + call clgstr ("append", Memc[append], SZ_LINE) + check = clgetb ("check") + + # Loop over all input images - print name on STDOUT + while (imtgetim (list, Memc[image], SZ_FNAME) != EOF) { + # Open image if check for existence required + if (check) { + ifnoerr (im = immap (Memc[image], READ_ONLY, 0)) { + call printf ("%s%s\n") + call pargstr (Memc[image]) + call pargstr (Memc[append]) + call imunmap (im) + } + } else { + call printf ("%s%s\n") + call pargstr (Memc[image]) + call pargstr (Memc[append]) + } + call flush (STDOUT) + } + + call imtclose (list) + call sfree (sp) +end |