Import sources from 2011-03-30 iso image
This commit is contained in:
commit
e5888a1ffd
7810 changed files with 2489717 additions and 0 deletions
30
sys/src/ape/lib/ap/stdio/_IO_getc.c
Executable file
30
sys/src/ape/lib/ap/stdio/_IO_getc.c
Executable file
|
@ -0,0 +1,30 @@
|
|||
/*
|
||||
* pANS stdio -- _IO_getc
|
||||
*/
|
||||
#include "iolib.h"
|
||||
int _IO_getc(FILE *f){
|
||||
int cnt, n;
|
||||
switch(f->state){
|
||||
default: /* CLOSED, WR, ERR, EOF */
|
||||
return EOF;
|
||||
case OPEN:
|
||||
_IO_setvbuf(f);
|
||||
case RDWR:
|
||||
case RD:
|
||||
if(f->flags&STRING) return EOF;
|
||||
if(f->buf == f->unbuf)
|
||||
n = 1;
|
||||
else
|
||||
n = f->bufl;
|
||||
cnt=read(f->fd, f->buf, n);
|
||||
switch(cnt){
|
||||
case -1: f->state=ERR; return EOF;
|
||||
case 0: f->state=END; return EOF;
|
||||
default:
|
||||
f->state=RD;
|
||||
f->rp=f->buf;
|
||||
f->wp=f->buf+cnt;
|
||||
return (*f->rp++)&_IO_CHMASK;
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue