aboutsummaryrefslogtreecommitdiff
path: root/sys/fio/fchdir.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/fchdir.x
downloadiraf-osx-40e5a5811c6ffce9b0974e93cdd927cbcf60c157.tar.gz
Repatch (from linux) of OSX IRAF
Diffstat (limited to 'sys/fio/fchdir.x')
-rw-r--r--sys/fio/fchdir.x57
1 files changed, 57 insertions, 0 deletions
diff --git a/sys/fio/fchdir.x b/sys/fio/fchdir.x
new file mode 100644
index 00000000..92b34ee0
--- /dev/null
+++ b/sys/fio/fchdir.x
@@ -0,0 +1,57 @@
+# Copyright(c) 1986 Association of Universities for Research in Astronomy Inc.
+
+include <syserr.h>
+include <knet.h>
+
+# FCHDIR -- Change the current working directory.
+
+procedure fchdir (newdir)
+
+char newdir[ARB]
+
+int ip, status
+pointer sp, vfn, osfn1, osfn2
+int ki_extnode(), envfind()
+errchk fmapfn, ki_extnode
+
+begin
+ call smark (sp)
+ call salloc (vfn, SZ_FNAME, TY_CHAR)
+ call salloc (osfn1, SZ_PATHNAME, TY_CHAR)
+ call salloc (osfn2, SZ_PATHNAME, TY_CHAR)
+
+ call strcpy (newdir, Memc[vfn], SZ_FNAME)
+
+ # Check for names of the form "node!" and convert them into
+ # "node!home$". This will also convert the null string into
+ # a chdir to home$.
+
+ ip = ki_extnode (Memc[vfn], Memc[osfn1], SZ_PATHNAME, status)
+ if (newdir[ip+1] == EOS)
+ call strcat ("home$", Memc[vfn], SZ_FNAME)
+
+ # Try the name as is.
+ call fmapfn (Memc[vfn], Memc[osfn1], SZ_PATHNAME)
+ call strupk (Memc[osfn1], Memc[osfn1], SZ_PATHNAME)
+
+ call zfpath (Memc[osfn1], Memc[osfn2], SZ_PATHNAME, status)
+ call zfsubd (Memc[osfn2], SZ_PATHNAME, "", status)
+
+ call strpak (Memc[osfn2], Memc[osfn2], SZ_PATHNAME)
+ call zfchdr (Memc[osfn2], status)
+
+ # Try chdir ldir$.
+ if (status == ERR) {
+ call strcpy (Memc[vfn], Memc[osfn1], SZ_FNAME)
+ if (envfind (Memc[osfn1], Memc[osfn2], SZ_PATHNAME) > 0) {
+ call strcat ("$", Memc[osfn1], SZ_PATHNAME)
+ call fmapfn (Memc[osfn1], Memc[osfn2], SZ_PATHNAME)
+ call zfchdr (Memc[osfn2], status)
+ } else
+ status = ERR
+ }
+
+ call sfree (sp)
+ if (status == ERR)
+ call syserrs (SYS_FCHDIR, newdir)
+end