aboutsummaryrefslogtreecommitdiff
path: root/pkg/system/pathnames.x
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 /pkg/system/pathnames.x
downloadiraf-linux-fa080de7afc95aa1c19a6e6fc0e0708ced2eadc4.tar.gz
Initial commit
Diffstat (limited to 'pkg/system/pathnames.x')
-rw-r--r--pkg/system/pathnames.x55
1 files changed, 55 insertions, 0 deletions
diff --git a/pkg/system/pathnames.x b/pkg/system/pathnames.x
new file mode 100644
index 00000000..86ee74f4
--- /dev/null
+++ b/pkg/system/pathnames.x
@@ -0,0 +1,55 @@
+# Copyright(c) 1986 Association of Universities for Research in Astronomy Inc.
+
+# PATHNAMES -- Convert one or more filenames into OS pathnames. If the input
+# is redirected, filenames are read from the standard input. Otherwise,
+# a file name template is expanded and used as the list of filenames to be
+# transformed. If called without any arguments, return the pathname of the
+# current working directory.
+
+procedure t_pathnames()
+
+int list
+pointer sp, fname, osfname
+bool streq(), clgetb()
+int clgeti(), clpopni(), clpopnu(), clgfil(), fscan()
+
+begin
+ call smark (sp)
+ call salloc (fname, SZ_LINE, TY_CHAR)
+ call salloc (osfname, SZ_LINE, TY_CHAR)
+
+ # If no arguments, return the pathame of the current
+ # directory: do not prompt for the template.
+
+ if (clgeti ("$nargs") == 0) {
+ call fpathname ("", Memc[osfname], SZ_LINE)
+ call printf ("%s\n")
+ call pargstr (Memc[osfname])
+ call sfree (sp)
+ return
+ }
+
+ # Expand template, output pathname of each file therein.
+ if (clgetb ("sort"))
+ list = clpopni ("template")
+ else
+ list = clpopnu ("template")
+
+ while (clgfil (list, Memc[fname], SZ_FNAME) != EOF) {
+ if (streq (Memc[fname], "STDIN")) {
+ while (fscan (STDIN) != EOF) {
+ call gargstr (Memc[fname], SZ_LINE)
+ call fpathname (Memc[fname], Memc[osfname], SZ_LINE)
+ call printf ("%s\n")
+ call pargstr (Memc[osfname])
+ }
+ } else {
+ call fpathname (Memc[fname], Memc[osfname], SZ_LINE)
+ call printf ("%s\n")
+ call pargstr (Memc[osfname])
+ }
+ }
+
+ call clpcls (list)
+ call sfree (sp)
+end