From fa080de7afc95aa1c19a6e6fc0e0708ced2eadc4 Mon Sep 17 00:00:00 2001 From: Joseph Hunkeler Date: Wed, 8 Jul 2015 20:46:52 -0400 Subject: Initial commit --- sys/ki/kfgcwd.x | 54 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 54 insertions(+) create mode 100644 sys/ki/kfgcwd.x (limited to 'sys/ki/kfgcwd.x') diff --git a/sys/ki/kfgcwd.x b/sys/ki/kfgcwd.x new file mode 100644 index 00000000..c142eaa8 --- /dev/null +++ b/sys/ki/kfgcwd.x @@ -0,0 +1,54 @@ +# Copyright(c) 1986 Association of Universities for Research in Astronomy Inc. + +include +include +include +include "ki.h" + +# KFGCWD -- Get the name of the current default directory. + +procedure kfgcwd (outstr, maxch, nchars) + +char outstr[maxch] # receives pathname of directory +int maxch # max chars out +int nchars # length of returned string + +int server, op +int gstrcpy(), ki_sendrcv() +include "kinode.com" +include "kii.com" +define err_ 91 + +begin + # If the current directory resides on the local node pass the zfgcwd + # request to the local kernel, else pass it to the kernel on the remote + # (default) node. Leave the CWD in p_sbuf. + + if (n_default == NULL || n_default == n_local) { +err_ call zfgcwd (p_sbuf, SZ_SBUF, nchars) + call strupk (p_sbuf, p_sbuf, SZ_SBUF) + p_arg[2] = 1 + + } else { + # If the current directory is on a remote node then there must be + # a connected kernel server attached to that node. + + server = n_default + + if (ki_sendrcv (server, KI_ZFGCWD, 0) == ERR) { + n_default = n_local + goto err_ + } + } + + # Return node // directory. + + op = gstrcpy (n_defaultnode, outstr, maxch) + 1 + if (op > 1) { + outstr[op] = FNNODE_CHAR + op = op + 1 + } + + nchars = op + gstrcpy (p_sbuf[p_arg[2]], outstr[op], maxch-op+1) + call strpak (outstr, outstr, maxch) +end -- cgit