w32tex
About: TeX Live provides a comprehensive TeX system including all the major TeX-related programs, macro packages, and fonts that are free software. Windows sources.
  Fossies Dox: w32tex-src.tar.xz  ("unofficial" and yet experimental doxygen-generated source code documentation)  

libpbm4.c
Go to the documentation of this file.
1 /* libpbm4.c - pbm utility library part 4
2 **
3 ** Copyright (C) 1988 by Jef Poskanzer.
4 **
5 ** Permission to use, copy, modify, and distribute this software and its
6 ** documentation for any purpose and without fee is hereby granted, provided
7 ** that the above copyright notice appear in all copies and that both that
8 ** copyright notice and this permission notice appear in supporting
9 ** documentation. This software is provided "as is" without express or
10 ** implied warranty.
11 */
12 
13 #include "pbm.h"
14 #include "libpbm.h"
15 
16 char
18  FILE* file;
19  {
20  register int ich;
21  register char ch;
22 
23  ich = getc( file );
24  if ( ich == EOF )
25  pm_error( "EOF / read error" );
26  ch = (char) ich;
27 
28  if ( ch == '#' )
29  {
30  do
31  {
32  ich = getc( file );
33  if ( ich == EOF )
34  pm_error( "EOF / read error" );
35  ch = (char) ich;
36  }
37  while ( ch != '\n' && ch != '\r' );
38  }
39 
40  return ch;
41  }
42 
43 
44 
45 /* This is useful for PBM files. It used to be used for PGM and PPM files
46  too, since the sample size was always one byte. Now, use pbm_getrawsample()
47  for PGM and PPM files.
48 */
49 
50 unsigned char
52  FILE* file;
53  {
54  register int iby;
55 
56  iby = getc( file );
57  if ( iby == EOF )
58  pm_error( "EOF / read error reading a one-byte sample" );
59  return (unsigned char) iby;
60  }
61 
62 int
64  FILE* file;
65  {
66  register char ch;
67  register int i;
68 
69  do
70  {
71  ch = pbm_getc( file );
72  }
73  while ( ch == ' ' || ch == '\t' || ch == '\n' || ch == '\r' );
74 
75  if ( ch < '0' || ch > '9' )
76  pm_error( "junk in file where an integer should be" );
77 
78  i = 0;
79  do
80  {
81  i = i * 10 + ch - '0';
82  ch = pbm_getc( file );
83  }
84  while ( ch >= '0' && ch <= '9' );
85 
86  return i;
87  }
small capitals from c petite p scientific i
Definition: afcover.h:80
#define EOF
Definition: afmparse.c:59
#define getc
Definition: line.c:39
char pbm_getc(FILE *file)
Definition: libpbm4.c:17
unsigned char pbm_getrawbyte(FILE *file)
Definition: libpbm4.c:51
int pbm_getint(FILE *file)
Definition: libpbm4.c:63
#define pm_error
Definition: png22pnm.c:118
Definition: filedef.h:30
#define FILE
Definition: t1stdio.h:34
ch
Definition: t4ht.c:1443
char * file
Definition: t4ht.c:931