aboutsummaryrefslogtreecommitdiff
path: root/unix/boot/bootlib/osdir.c
diff options
context:
space:
mode:
authorJoseph Hunkeler <jhunkeler@gmail.com>2015-07-08 20:46:52 -0400
committerJoseph Hunkeler <jhunkeler@gmail.com>2015-07-08 20:46:52 -0400
commitfa080de7afc95aa1c19a6e6fc0e0708ced2eadc4 (patch)
treebdda434976bc09c864f2e4fa6f16ba1952b1e555 /unix/boot/bootlib/osdir.c
downloadiraf-linux-fa080de7afc95aa1c19a6e6fc0e0708ced2eadc4.tar.gz
Initial commit
Diffstat (limited to 'unix/boot/bootlib/osdir.c')
-rw-r--r--unix/boot/bootlib/osdir.c93
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