diff options
author | giraffedata <giraffedata@9d0c8265-081b-0410-96cb-a4ca84ce46f8> | 2007-03-30 02:51:36 +0000 |
---|---|---|
committer | giraffedata <giraffedata@9d0c8265-081b-0410-96cb-a4ca84ce46f8> | 2007-03-30 02:51:36 +0000 |
commit | 97e432df4e7ffae5ae89939539172d5923a46014 (patch) | |
tree | 7890f85ba00bbd9a15488a54278ba250f41946ec /lib/libpm.c | |
parent | 64dd4a03dedeea0f0240951d8ec73cd519fb3900 (diff) | |
download | netpbm-mirror-97e432df4e7ffae5ae89939539172d5923a46014.tar.gz netpbm-mirror-97e432df4e7ffae5ae89939539172d5923a46014.tar.xz netpbm-mirror-97e432df4e7ffae5ae89939539172d5923a46014.zip |
Move Advanced series to 10.38
git-svn-id: http://svn.code.sf.net/p/netpbm/code/advanced@267 9d0c8265-081b-0410-96cb-a4ca84ce46f8
Diffstat (limited to 'lib/libpm.c')
-rw-r--r-- | lib/libpm.c | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/lib/libpm.c b/lib/libpm.c index f36b7a50..88b790e6 100644 --- a/lib/libpm.c +++ b/lib/libpm.c @@ -1662,3 +1662,32 @@ pm_check(FILE * const file, +void +pm_drain(FILE * const fileP, + uint const limit, + uint * const bytesReadP) { +/*---------------------------------------------------------------------------- + Read bytes from *fileP until EOF and return as *bytesReadP how many there + were. + + But don't read any more than 'limit'. + + This is a good thing to call after reading an input file to be sure you + didn't leave some input behind, which could mean you didn't properly + interpret the file. +-----------------------------------------------------------------------------*/ + uint bytesRead; + bool eof; + + for (bytesRead = 0, eof = false; !eof && bytesRead < 4096;) { + + int rc; + + rc = fgetc(fileP); + + eof = (rc == EOF); + if (!eof) + ++bytesRead; + } + *bytesReadP = bytesRead; +} |