aboutsummaryrefslogtreecommitdiff
path: root/sys/libc/zztest.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 /sys/libc/zztest.c
downloadiraf-osx-40e5a5811c6ffce9b0974e93cdd927cbcf60c157.tar.gz
Repatch (from linux) of OSX IRAF
Diffstat (limited to 'sys/libc/zztest.c')
-rw-r--r--sys/libc/zztest.c98
1 files changed, 98 insertions, 0 deletions
diff --git a/sys/libc/zztest.c b/sys/libc/zztest.c
new file mode 100644
index 00000000..b43fe705
--- /dev/null
+++ b/sys/libc/zztest.c
@@ -0,0 +1,98 @@
+/* Copyright(c) 1986 Association of Universities for Research in Astronomy Inc.
+ */
+
+#define import_libc
+#define import_stdio
+#define import_spp
+#define import_error
+#define import_xwhen
+#include <iraf.h>
+
+thello_()
+{
+ fputs ("hello, world\n", stdout);
+}
+
+
+tprint_()
+{
+ char buf[128];
+
+ sprintf (buf, "\tabcdef %0*d[%-5.2s], %h\n", 5, 99, "wxyz", 12.5);
+ fputs (buf, stdout);
+}
+
+
+tcopy_()
+{
+ FILE *in, *out;
+ int ch;
+
+ if ((in = fopen ("junk", "r")) == NULL)
+ c_erract (EA_ERROR);
+ if ((out = fopen ("junk2", "wb")) == NULL)
+ c_erract (EA_ERROR);
+
+ while ((ch = getc (in)) != EOF)
+ putc (ch, out);
+
+ fclose (in);
+ fclose (out);
+}
+
+
+tscan_()
+{
+ char buf[SZ_LINE];
+ char str[SZ_LINE];
+ char cval;
+ int ival, nscan, n1, n2;
+ int onint(), oldint;
+ double dval;
+
+ c_xwhen (X_INT, onint, &oldint);
+
+ printf (">> \n");
+ fflush (stdout);
+
+ while (fgets (buf, SZ_LINE, stdin) != NULL) {
+ nscan = sscanf (buf,
+ "%n%c %*s %d %lg %s%n", &n1, &cval, &ival, &dval, str, &n2);
+ printf ("nscan=%d: %d '%c' %d %g '%s' %d\n",
+ nscan, n1, cval, ival, dval, str, n2);
+ printf (">> \n");
+ fflush (stdout);
+ }
+
+ eprintf ("all done\n");
+}
+
+
+onint (code, old_handler)
+int *code; /* NOTUSED */
+int *old_handler;
+{
+ write (2, "\7", 1);
+ *old_handler = 0;
+}
+
+
+tgettk_()
+{
+ XCHAR fname[SZ_FNAME+1];
+ char token[SZ_LINE+1], delim;
+ int maxch = SZ_FNAME;
+ FILE *fp;
+
+ clgstr_ (c_sppstr("fname"), fname, &maxch);
+ c_strpak (fname, token, maxch);
+
+ fp = fopen (token, "r");
+ if (fp == NULL)
+ c_erract (EA_ERROR);
+
+ while (fscanf (fp, " %[^ \t\n,:()!^&+-*/;|?<>]%c", token,&delim) != EOF)
+ eprintf ("%s\n%c\n", token, delim);
+
+ fclose (fp);
+}