1*47944Sbostic /*- 2*47944Sbostic * Copyright (c) 1980 The Regents of the University of California. 3*47944Sbostic * All rights reserved. 42411Sdlw * 5*47944Sbostic * %sccs.include.proprietary.c% 623020Skre */ 723020Skre 8*47944Sbostic #ifndef lint 9*47944Sbostic static char sccsid[] = "@(#)getc_.c 5.2 (Berkeley) 04/12/91"; 10*47944Sbostic #endif /* not lint */ 11*47944Sbostic 1223020Skre /* 132411Sdlw * get a character from the standard input 142411Sdlw * 152411Sdlw * calling sequence: 162411Sdlw * integer getc 172411Sdlw * ierror = getc (char) 182411Sdlw * where: 192411Sdlw * char will be read from the standard input, usually the terminal 202411Sdlw * ierror will be 0 if successful; a system error code otherwise. 212411Sdlw */ 222411Sdlw 232411Sdlw #include "../libI77/f_errno.h" 242411Sdlw #include "../libI77/fiodefs.h" 252411Sdlw 262411Sdlw extern unit units[]; /* logical units table from iolib */ 272411Sdlw getc_(c,clen)282411Sdlwlong getc_(c, clen) 292411Sdlw char *c; long clen; 302411Sdlw { 313896Sdlw int i; 323896Sdlw unit *lu; 332411Sdlw 343896Sdlw lu = &units[STDIN]; 353896Sdlw if (!lu->ufd) 362411Sdlw return((long)(errno=F_ERNOPEN)); 374109Sdlw if (lu->uwrt && ! nowreading(lu)) 384109Sdlw return((long)errno); 393896Sdlw if ((i = getc (lu->ufd)) < 0) 402411Sdlw { 413896Sdlw if (feof(lu->ufd)) 422411Sdlw return(-1L); 432411Sdlw i = errno; 443896Sdlw clearerr(lu->ufd); 452411Sdlw return((long)i); 462411Sdlw } 4718452Sralph *c = i; 482411Sdlw return(0L); 492411Sdlw } 50