1 /*- 2 * Copyright (c) 1980 The Regents of the University of California. 3 * All rights reserved. 4 * 5 * %sccs.include.proprietary.c% 6 */ 7 8 #ifndef lint 9 static char sccsid[] = "@(#)getc_.c 5.2 (Berkeley) 04/12/91"; 10 #endif /* not lint */ 11 12 /* 13 * get a character from the standard input 14 * 15 * calling sequence: 16 * integer getc 17 * ierror = getc (char) 18 * where: 19 * char will be read from the standard input, usually the terminal 20 * ierror will be 0 if successful; a system error code otherwise. 21 */ 22 23 #include "../libI77/f_errno.h" 24 #include "../libI77/fiodefs.h" 25 26 extern unit units[]; /* logical units table from iolib */ 27 28 long getc_(c, clen) 29 char *c; long clen; 30 { 31 int i; 32 unit *lu; 33 34 lu = &units[STDIN]; 35 if (!lu->ufd) 36 return((long)(errno=F_ERNOPEN)); 37 if (lu->uwrt && ! nowreading(lu)) 38 return((long)errno); 39 if ((i = getc (lu->ufd)) < 0) 40 { 41 if (feof(lu->ufd)) 42 return(-1L); 43 i = errno; 44 clearerr(lu->ufd); 45 return((long)i); 46 } 47 *c = i; 48 return(0L); 49 } 50