"SfR Fresh" - the SfR Freeware/Shareware Archive 
Member "viewfax-2.6/faxexpand.h" of archive viewfax-2.6.tar.gz:
As a special service "SfR Fresh" has tried to format the requested source page into HTML format using (guessed) C and C++ source code syntax highlighting with prefixed line numbers.
Alternatively you can here view or download the uninterpreted source code file.
That can be also achieved for any archive member file by clicking within an archive contents listing on the first character of the file(path) respectively on the according byte size field.
1 /* Include file for fax routines
2 Copyright (C) 1990, 1995 Frank D. Cringle.
3
4 This file is part of viewfax - g3/g4 fax processing software.
5
6 viewfax is free software; you can redistribute it and/or modify it
7 under the terms of the GNU General Public License as published by the
8 Free Software Foundation; either version 2 of the License, or (at your
9 option) any later version.
10
11 This program is distributed in the hope that it will be useful, but
12 WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 General Public License for more details.
15
16 You should have received a copy of the GNU General Public License
17 along with this program; if not, write to the Free Software
18 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
19
20 #include <limits.h>
21
22 #if ULONG_MAX == 4294967295UL
23 typedef unsigned long t32bits;
24 #elif UINT_MAX == 4294967295UL
25 typedef unsigned int t32bits;
26 #else
27 #error need a 32-bit unsigned type
28 /* if you see the above error, add an #elif case for your architecture
29 and tell fdc@cliwe.ping.de about it */
30 #endif
31
32 #if USHRT_MAX == 65535
33 typedef unsigned short t16bits;
34 #elif UINT_MAX == 65535
35 typedef unsigned int t16bits;
36 #else
37 #error need a 16-bit unsigned type
38 /* if you see the above error, add an #elif case for your architecture
39 and tell fdc@cliwe.ping.de about it */
40 #endif
41 typedef t16bits pixnum;
42
43 struct pagenode;
44
45 /* drawfunc() points to a function which processes a line of the
46 expanded image described as a list of run lengths.
47 run is the base of an array of lengths, starting with a
48 (possibly empty) white run for line number linenum.
49 pn points to the page descriptor */
50 typedef void (*drawfunc)(pixnum *run, int linenum, struct pagenode *pn);
51
52 struct strip { /* tiff strip descriptor */
53 off_t offset; /* offset in file */
54 off_t size; /* size of this strip */
55 };
56
57 struct pagenode { /* compressed page descriptor */
58 struct pagenode *prev, *next; /* list links */
59 char *name; /* basename of file */
60 char *pathname; /* full name of file */
61 int pageno; /* page number */
62 int nstrips; /* number of strips */
63 int rowsperstrip; /* number of rows per strip */
64 int stripnum; /* current strip while expanding */
65 struct strip *strips; /* array of strips containing fax data in file */
66 t16bits *data; /* in-memory copy of strip */
67 size_t length; /* length of data */
68 pixnum width; /* width of page in pixels */
69 pixnum height; /* height of page in lines */
70 char inverse; /* black <=> white */
71 char lsbfirst; /* bit order is lsb first */
72 char orient; /* orientation - upsidedown, landscape, mirrored */
73 char vres; /* vertical resolution: 1 = fine */
74 void (*expander)(struct pagenode *, drawfunc);
75 void *extra; /* used for Ximage */
76 };
77 extern struct pagenode *firstpage, *lastpage, *thispage;
78 extern struct pagenode defaultpage;
79
80 /* page orientation flags */
81 #define TURN_U 1
82 #define TURN_L 2
83 #define TURN_M 4
84
85 extern char *ProgName;
86
87 /* fsm state codes */
88 #define S_Null 0
89 #define S_Pass 1
90 #define S_Horiz 2
91 #define S_V0 3
92 #define S_VR 4
93 #define S_VL 5
94 #define S_Ext 6
95 #define S_TermW 7
96 #define S_TermB 8
97 #define S_MakeUpW 9
98 #define S_MakeUpB 10
99 #define S_MakeUp 11
100 #define S_EOL 12
101
102 /* state table entry */
103 struct tabent {
104 unsigned char State;
105 unsigned char Width; /* width of code in bits */
106 pixnum Param; /* run length */
107 };
108
109 extern struct tabent MainTable[]; /* 2-D state table */
110 extern struct tabent WhiteTable[]; /* White run lengths */
111 extern struct tabent BlackTable[]; /* Black run lengths */
112
113 extern int verbose;
114
115 void MHexpand(struct pagenode *pn, drawfunc df);
116 void g31expand(struct pagenode *pn, drawfunc df);
117 void g32expand(struct pagenode *pn, drawfunc df);
118 void g4expand(struct pagenode *pn, drawfunc df);
119
120 unsigned char * getstrip(struct pagenode *pn, int strip);
121 struct pagenode *notefile(char *name);
122 int notetiff(char *name);
123
124 /* initialise code tables */
125 extern void faxinit(void);
126 /* count lines in image */
127 extern int G3count(struct pagenode *pn, int twoD);
128
129 /* get memory or abort if none available */
130 extern char *xmalloc(unsigned int size);
131
132 #ifdef linux
133 #define _HAVE_USLEEP
134 #endif
135
136 #if defined(BSD) || defined(__FreeBSD__) || defined(_BSD_SOURCE)
137 #define _HAVE_USLEEP
138 #ifndef rindex
139 #define rindex strrchr
140 #endif
141 #ifndef bcmp
142 #define memcmp bcmp
143 #endif
144 #define memclr(p,n) bzero(p,n)
145 #else /* not BSD */
146 #define memclr(p,n) memset(p,0,n)
147 #endif