12411Sdlw /* 2*23020Skre * Copyright (c) 1980 Regents of the University of California. 3*23020Skre * All rights reserved. The Berkeley software License Agreement 4*23020Skre * specifies the terms and conditions for redistribution. 52411Sdlw * 6*23020Skre * @(#)getc_.c 5.1 06/07/85 7*23020Skre */ 8*23020Skre 9*23020Skre /* 102411Sdlw * get a character from the standard input 112411Sdlw * 122411Sdlw * calling sequence: 132411Sdlw * integer getc 142411Sdlw * ierror = getc (char) 152411Sdlw * where: 162411Sdlw * char will be read from the standard input, usually the terminal 172411Sdlw * ierror will be 0 if successful; a system error code otherwise. 182411Sdlw */ 192411Sdlw 202411Sdlw #include "../libI77/f_errno.h" 212411Sdlw #include "../libI77/fiodefs.h" 222411Sdlw 232411Sdlw extern unit units[]; /* logical units table from iolib */ 242411Sdlw 252411Sdlw long getc_(c, clen) 262411Sdlw char *c; long clen; 272411Sdlw { 283896Sdlw int i; 293896Sdlw unit *lu; 302411Sdlw 313896Sdlw lu = &units[STDIN]; 323896Sdlw if (!lu->ufd) 332411Sdlw return((long)(errno=F_ERNOPEN)); 344109Sdlw if (lu->uwrt && ! nowreading(lu)) 354109Sdlw return((long)errno); 363896Sdlw if ((i = getc (lu->ufd)) < 0) 372411Sdlw { 383896Sdlw if (feof(lu->ufd)) 392411Sdlw return(-1L); 402411Sdlw i = errno; 413896Sdlw clearerr(lu->ufd); 422411Sdlw return((long)i); 432411Sdlw } 4418452Sralph *c = i; 452411Sdlw return(0L); 462411Sdlw } 47