home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Club Amiga de Montreal - CAM
/
CAM_CD_1.iso
/
files
/
309.lha
/
PBM_PLUS
/
pbm
/
libpbm4.c
< prev
next >
Wrap
C/C++ Source or Header
|
1980-12-04
|
2KB
|
82 lines
/* libpbm4.c - pbm utility library part 4
**
** Copyright (C) 1988 by Jef Poskanzer.
**
** Permission to use, copy, modify, and distribute this software and its
** documentation for any purpose and without fee is hereby granted, provided
** that the above copyright notice appear in all copies and that both that
** copyright notice and this permission notice appear in supporting
** documentation. This software is provided "as is" without express or
** implied warranty.
*/
#include <stdio.h>
#include "pbm.h"
#include "libpbm.h"
char
pbm_getc( file )
FILE *file;
{
register int ich;
register char ch;
ich = getc( file );
if ( ich == EOF )
pm_error( "premature EOF", 0,0,0,0,0 );
ch = (char) ich;
if ( ch == '#' )
{
do
{
ich = getc( file );
if ( ich == EOF )
pm_error( "premature EOF", 0,0,0,0,0 );
ch = (char) ich;
}
while ( ch != '\n' );
}
return ch;
}
unsigned char
pbm_getrawbyte( file )
FILE *file;
{
register int iby;
iby = getc( file );
if ( iby == EOF )
pm_error( "premature EOF", 0,0,0,0,0 );
return (unsigned char) iby;
}
int
pbm_getint( file )
FILE *file;
{
register char ch;
register int i;
do
{
ch = pbm_getc( file );
}
while ( ch == ' ' || ch == '\t' || ch == '\n' );
if ( ch < '0' || ch > '9' )
pm_error( "junk in file where an integer should be", 0,0,0,0,0 );
i = 0;
do
{
i = i * 10 + ch - '0';
ch = pbm_getc( file );
}
while ( ch >= '0' && ch <= '9' );
return i;
}