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 /noao/digiphot/ptools/ptutils/t_istable.x | |
download | iraf-osx-40e5a5811c6ffce9b0974e93cdd927cbcf60c157.tar.gz |
Repatch (from linux) of OSX IRAF
Diffstat (limited to 'noao/digiphot/ptools/ptutils/t_istable.x')
-rw-r--r-- | noao/digiphot/ptools/ptutils/t_istable.x | 71 |
1 files changed, 71 insertions, 0 deletions
diff --git a/noao/digiphot/ptools/ptutils/t_istable.x b/noao/digiphot/ptools/ptutils/t_istable.x new file mode 100644 index 00000000..b8cbf5db --- /dev/null +++ b/noao/digiphot/ptools/ptutils/t_istable.x @@ -0,0 +1,71 @@ +include "../../lib/ptkeysdef.h" + +# T_ISTABLE -- Decide whether an input file is an ST Table, an APPHOT style +# text file or neither. + +procedure t_istable () + +pointer infile # name of the input file + +bool table, text, other +int fd, type +pointer sp, line +int access(), tbtopn(), open(), getline(), strmatch() +errchk tbtopn(), open() + +begin + # Get some working space. + call smark (sp) + call salloc (infile, SZ_FNAME, TY_CHAR) + call salloc (line, SZ_LINE, TY_CHAR) + + # Fetch the name of the input file + call clgstr ("infile", Memc[infile], SZ_FNAME) + if (access (Memc[infile], READ_ONLY, TEXT_FILE) == YES) + type = TEXT_FILE + else + type = BINARY_FILE + + if (type == BINARY_FILE) { + iferr { + fd = tbtopn (Memc[infile], READ_ONLY, 0) + } then { + table = false + text = false + other = true + } else { + table = true + text = false + other = false + call tbtclo (fd) + } + } else { + table = false + iferr { + fd = open (Memc[infile], READ_ONLY, TEXT_FILE) + } then { + text = false + other = true + } else { + Memc[line] = EOS + if (getline (fd, Memc[line]) != EOF) { + if (strmatch (Memc[line], KY_CHAR_IRAF) != 0) { + text = true + other = false + } else { + text = false + other = true + } + } + call close (fd) + } + } + + # Store the results in the istable parameter file. + call clputb ("table", table) + call clputb ("text", text) + call clputb ("other", other) + + # Free memory. + call sfree (sp) +end |