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 /unix/boot/bootlib/osdir.c | |
download | iraf-osx-40e5a5811c6ffce9b0974e93cdd927cbcf60c157.tar.gz |
Repatch (from linux) of OSX IRAF
Diffstat (limited to 'unix/boot/bootlib/osdir.c')
-rw-r--r-- | unix/boot/bootlib/osdir.c | 93 |
1 files changed, 93 insertions, 0 deletions
diff --git a/unix/boot/bootlib/osdir.c b/unix/boot/bootlib/osdir.c new file mode 100644 index 00000000..d3807302 --- /dev/null +++ b/unix/boot/bootlib/osdir.c @@ -0,0 +1,93 @@ +/* Copyright(c) 1986 Association of Universities for Research in Astronomy Inc. + */ + +#include <string.h> +#include "bootlib.h" + + +/* + * OS_DIR -- A package for accessing a directory as a list of files. + */ + +#ifndef NOVOS + +/* OS_DIROPEN -- Open the directory. + */ +int +os_diropen (char *dirname) +{ + PKCHAR osfn[SZ_PATHNAME+1]; + XINT chan; + + extern int ZOPDIR(); + + + strcpy ((char *)osfn, dirname); + ZOPDIR (osfn, &chan); + + return (chan); +} + + +/* OS_DIRCLOSE -- Close the directory. + */ +int +os_dirclose (int chan) +{ + XINT x_chan=chan, status; + + extern int ZCLDIR(); + + + ZCLDIR (&x_chan, &status); + return (status); +} + + +/* OS_GFDIR -- Get the next filename from the directory. + */ +int +os_gfdir ( + int chan, + char *fname, + int maxch +) +{ + PKCHAR osfn[SZ_PATHNAME+1]; + XINT x_chan=chan, x_maxch=maxch, status; + + extern int ZGFDIR(); + + for (;;) { + ZGFDIR (&x_chan, osfn, &x_maxch, &status); + if (status > 0) { + /* Omit the self referential directory files "." and ".." + * or recursion may result. + */ + if (strcmp ((char *)osfn, ".") == 0) + continue; + if (strcmp ((char *)osfn, "..") == 0) + continue; + + strncpy (fname, osfn2vfn ((char *)osfn), maxch); + return (status); + + } else { + /* End of directory. + */ + *fname = EOS; + return (0); + } + } +} + +#else +/* NOVOS bootsrap. Just stub these out until we re-boostrap using the + * VOS libs, which provide zopdir. + */ + +int os_dirclose (int chan) { return (-1); } +int os_diropen (char *dirname) { return (-1); } +int os_gfdir (int chan, char *fname, int maxch) { return (0); } + +#endif |