aboutsummaryrefslogtreecommitdiff
path: root/unix/os/zfpath.c
diff options
context:
space:
mode:
authorJoe Hunkeler <jhunkeler@gmail.com>2015-08-11 16:51:37 -0400
committerJoe Hunkeler <jhunkeler@gmail.com>2015-08-11 16:51:37 -0400
commit40e5a5811c6ffce9b0974e93cdd927cbcf60c157 (patch)
tree4464880c571602d54f6ae114729bf62a89518057 /unix/os/zfpath.c
downloadiraf-osx-40e5a5811c6ffce9b0974e93cdd927cbcf60c157.tar.gz
Repatch (from linux) of OSX IRAF
Diffstat (limited to 'unix/os/zfpath.c')
-rw-r--r--unix/os/zfpath.c50
1 files changed, 50 insertions, 0 deletions
diff --git a/unix/os/zfpath.c b/unix/os/zfpath.c
new file mode 100644
index 00000000..76d66929
--- /dev/null
+++ b/unix/os/zfpath.c
@@ -0,0 +1,50 @@
+/* Copyright(c) 1986 Association of Universities for Research in Astronomy Inc.
+ */
+
+#include <stdio.h>
+#include <ctype.h>
+#define import_spp
+#define import_kernel
+#define import_knames
+#include <iraf.h>
+
+/* ZFPATH -- Return the absolute pathname equivalent of an OSFN. If the null
+ * string is given the OSFN of the current working directory is returned.
+ */
+int
+ZFPATH (
+ XCHAR *osfn, /* input OS filename [NOT PACKED] */
+ XCHAR *pathname, /* output pathname [NOT PACKED] */
+ XINT *maxch,
+ XINT *nchars
+)
+{
+ register char *cp;
+ register XCHAR *ip, *op;
+ register int n = *maxch;
+ PKCHAR cwd[SZ_PATHNAME+1];
+
+ extern int ZFGCWD();
+
+
+ op = pathname;
+ for (ip=osfn; *ip == ' '; ip++)
+ ;
+
+ /* If the OSFN begins with a / it is already an absolute pathname.
+ */
+ if (*ip != '/') {
+ ZFGCWD (cwd, maxch, nchars);
+ for (cp=(char *)cwd; --n >= 0 && (*op = *cp++); op++)
+ ;
+ }
+
+ /* Append the filename */
+ while (--n >= 0 && (*op = *ip++) != XEOS)
+ op++;
+
+ *op = XEOS;
+ *nchars = (op - pathname);
+
+ return (XOK);
+}