date and time created 81/02/11 22:33:57 by dlw
authorDavid Wasley <dlw@ucbvax.Berkeley.EDU>
Thu, 12 Feb 1981 14:33:57 +0000 (06:33 -0800)
committerDavid Wasley <dlw@ucbvax.Berkeley.EDU>
Thu, 12 Feb 1981 14:33:57 +0000 (06:33 -0800)
SCCS-vsn: usr.bin/f77/libU77/fgetc_.c 1.1

usr/src/usr.bin/f77/libU77/fgetc_.c [new file with mode: 0644]

diff --git a/usr/src/usr.bin/f77/libU77/fgetc_.c b/usr/src/usr.bin/f77/libU77/fgetc_.c
new file mode 100644 (file)
index 0000000..563be45
--- /dev/null
@@ -0,0 +1,38 @@
+/*
+char id_fgetc[] = "@(#)fgetc_.c        1.1";
+ *
+ * get a character from a logical unit bypassing formatted I/O
+ *
+ * calling sequence:
+ *     integer fgetc
+ *     ierror = fgetc (unit, char)
+ * where:
+ *     char will return a character from logical unit
+ *     ierror will be 0 if successful; a system error code otherwise.
+ */
+
+#include       "../libI77/fiodefs.h"
+#include       "../libI77/f_errno.h"
+
+extern unit units[];   /* logical units table from iolib */
+
+long fgetc_(u, c, clen)
+long *u; char *c; long clen;
+{
+       int i;
+
+       if (*u < 0 || *u >= MXUNIT)
+               return((long)(errno=F_ERARG));
+       if (!units[*u].ufd)
+               return((long)(errno=F_ERNOPEN));
+       if ((i = getc (units[*u].ufd)) < 0)
+       {
+               if (feof(units[*u].ufd))
+                       return(-1L);
+               i = errno;
+               clearerr(units[*u].ufd);
+               return((long)i);
+       }
+       *c = i & 0177;
+       return(0L);
+}