diff options
author | Guillaume Cottenceau <gc@mandriva.com> | 2001-05-14 13:47:49 +0000 |
---|---|---|
committer | Guillaume Cottenceau <gc@mandriva.com> | 2001-05-14 13:47:49 +0000 |
commit | f15aa3a552022743398a652165d76bf912c715e5 (patch) | |
tree | b58f8b4c47fc571fbb498d83a4bd4fca226ac6c4 /mdk-stage1/dietlibc/libstdio/fgetc.c | |
parent | 189b01c358a1181ddc951adba97a0258d5fc2cf1 (diff) | |
download | drakx-backup-do-not-use-f15aa3a552022743398a652165d76bf912c715e5.tar drakx-backup-do-not-use-f15aa3a552022743398a652165d76bf912c715e5.tar.gz drakx-backup-do-not-use-f15aa3a552022743398a652165d76bf912c715e5.tar.bz2 drakx-backup-do-not-use-f15aa3a552022743398a652165d76bf912c715e5.tar.xz drakx-backup-do-not-use-f15aa3a552022743398a652165d76bf912c715e5.zip |
Initial revision
Diffstat (limited to 'mdk-stage1/dietlibc/libstdio/fgetc.c')
-rw-r--r-- | mdk-stage1/dietlibc/libstdio/fgetc.c | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/mdk-stage1/dietlibc/libstdio/fgetc.c b/mdk-stage1/dietlibc/libstdio/fgetc.c new file mode 100644 index 000000000..90d83961a --- /dev/null +++ b/mdk-stage1/dietlibc/libstdio/fgetc.c @@ -0,0 +1,40 @@ +#include "dietstdio.h" +#include <unistd.h> + +extern int feof(FILE *stream); + +int fgetc(FILE *stream) { + unsigned char c; +#ifdef WANT_UNGETC + if (stream->ungotten) { + stream->ungotten=0; + return stream->ungetbuf; + } +#endif + if (feof(stream)) + return EOF; +#ifdef WANT_BUFFERED_STDIO + if (__fflush4(stream,BUFINPUT)) return EOF; + if (stream->bm>=stream->bs) { + int len=read(stream->fd,stream->buf,BUFSIZE); + if (len==0) { + stream->flags|=EOFINDICATOR; + return EOF; + } else if (len<0) { + stream->flags|=ERRORINDICATOR; + return EOF; + } + stream->bm=0; + stream->bs=len; + } + c=stream->buf[stream->bm]; + ++stream->bm; + return c; +#else + if (read(stream->fd,&c,1)!=1) { + stream->flags|=ERRORINDICATOR; + return EOF; + } + return c; +#endif +} |