aboutsummaryrefslogtreecommitdiff
path: root/sys/fio/fdirname.x
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 /sys/fio/fdirname.x
downloadiraf-osx-40e5a5811c6ffce9b0974e93cdd927cbcf60c157.tar.gz
Repatch (from linux) of OSX IRAF
Diffstat (limited to 'sys/fio/fdirname.x')
-rw-r--r--sys/fio/fdirname.x46
1 files changed, 46 insertions, 0 deletions
diff --git a/sys/fio/fdirname.x b/sys/fio/fdirname.x
new file mode 100644
index 00000000..aa24709d
--- /dev/null
+++ b/sys/fio/fdirname.x
@@ -0,0 +1,46 @@
+# Copyright(c) 1986 Association of Universities for Research in Astronomy Inc.
+
+include <ctype.h>
+include <knet.h>
+
+# FDIRNAME -- Return the concatenatable directory prefix for the named
+# directory. If no vfn is given (null string), a path to the current
+# directory is returned.
+
+procedure fdirname (vfn, path, maxch)
+
+char vfn[ARB] # VFN of directory
+char path[ARB] # unpacked path to directory
+int maxch
+
+int len1, len2, ch
+int gstrcpy()
+
+begin
+ if (vfn[1] == EOS) {
+ # Null vfn; return current directory.
+ call strcpy ("./", path, maxch)
+ return
+ }
+
+ # Do we have an OS directory reference?
+ call zfxdir (vfn, path, maxch, len2)
+ ch = path[len2]
+ if (len2 > 0 && !(IS_ALNUM(ch) || ch == '_'))
+ return
+
+ # Do we have an "ldir$" or "subdir/"? If so, quit, else if the last
+ # char is a normal identifier class filename char, assume that we have
+ # a VFN and add the / delimiter. This technique is not infallible,
+ # and a better solution would be to have ZFXDIR or FDIRNAME itself
+ # execute on the remote node.
+
+ len1 = gstrcpy (vfn, path, maxch)
+ ch = path[len1]
+ if (ch == '$' || ch == '/')
+ return
+
+ # Must be a subdirectory of the form "subdir". Add the /.
+ path[len1+1] = '/'
+ path[len1+2] = EOS
+end