Annotation of 42BSD/usr.lib/libU77/fgetc_.c, revision 1.1.1.1

1.1       root        1: /*
                      2: char id_fgetc[] = "@(#)fgetc_.c        1.4";
                      3:  *
                      4:  * get a character from a logical unit bypassing formatted I/O
                      5:  *
                      6:  * calling sequence:
                      7:  *     integer fgetc
                      8:  *     ierror = fgetc (unit, char)
                      9:  * where:
                     10:  *     char will return a character from logical unit
                     11:  *     ierror will be 0 if successful; a system error code otherwise.
                     12:  */
                     13: 
                     14: #include       "../libI77/fiodefs.h"
                     15: #include       "../libI77/f_errno.h"
                     16: 
                     17: extern unit units[];   /* logical units table from iolib */
                     18: 
                     19: long fgetc_(u, c, clen)
                     20: long *u; char *c; long clen;
                     21: {
                     22:        int     i;
                     23:        unit    *lu;
                     24: 
                     25:        if (*u < 0 || *u >= MXUNIT)
                     26:                return((long)(errno=F_ERUNIT));
                     27:        lu = &units[*u];
                     28:        if (!lu->ufd)
                     29:                return((long)(errno=F_ERNOPEN));
                     30:        if (lu->uwrt && ! nowreading(lu))
                     31:                return((long)errno);
                     32:        if ((i = getc (lu->ufd)) < 0)
                     33:        {
                     34:                if (feof(lu->ufd))
                     35:                        return(-1L);
                     36:                i = errno;
                     37:                clearerr(lu->ufd);
                     38:                return((long)i);
                     39:        }
                     40:        *c = i & 0177;
                     41:        return(0L);
                     42: }

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.