45 extern int getopt(
int,
char**,
char*);
48 #define streq(a,b) (strcmp(a,b) == 0) 60 static struct proto Pass[] = {
65 static struct proto Horiz[] = {
70 static struct proto V0[] = {
75 static struct proto VR[] = {
82 static struct proto VL[] = {
89 static struct proto Ext[] = {
94 static struct proto EOLV[] = {
99 static struct proto MakeUpW[] = {
130 static struct proto MakeUpB[] = {
161 static struct proto MakeUp[] = {
178 static struct proto TermW[] = {
246 static struct proto TermB[] = {
314 static struct proto EOLH[] = {
322 int limit = 1 << Size;
325 int width = P->
val & 15;
326 int param = P->
val >> 4;
327 int incr = 1 << width;
329 for (code = P->
code; code < limit; code += incr) {
339 static char* storage_class =
"";
340 static char* const_class =
"";
341 static int packoutput = 1;
342 static char* prebrace =
"";
343 static char* postbrace =
"";
351 fprintf(fd,
"%s %s TIFFFaxTabEnt %s[%d] = {",
352 storage_class, const_class, name, Size);
355 for (i = 0; i < Size; i++) {
356 fprintf(fd,
"%s%s%d,%d,%d%s",
358 if (((i+1) % 10) == 0)
366 for (i = 0; i < Size; i++) {
367 fprintf(fd,
"%s%s%3d,%3d,%4d%s",
369 if (((i+1) % 6) == 0)
376 fprintf(fd,
"\n};\n");
389 while ((c =
getopt(argc, argv,
"c:s:bp")) != -1)
392 const_class = optarg;
395 storage_class = optarg;
406 "usage: %s [-c const] [-s storage] [-p] [-b] file\n",
410 outputfile = optind < argc ? argv[optind] :
"g3states.h";
411 fd = fopen(outputfile,
"w");
413 fprintf(stderr,
"%s: %s: Cannot create output file.\n",
414 argv[0], outputfile);
417 FillTable(MainTable, 7, Pass,
S_Pass);
418 FillTable(MainTable, 7, Horiz,
S_Horiz);
419 FillTable(MainTable, 7, V0,
S_V0);
420 FillTable(MainTable, 7, VR,
S_VR);
421 FillTable(MainTable, 7, VL,
S_VL);
422 FillTable(MainTable, 7, Ext,
S_Ext);
423 FillTable(MainTable, 7, EOLV,
S_EOL);
424 FillTable(WhiteTable, 12, MakeUpW,
S_MakeUpW);
425 FillTable(WhiteTable, 12, MakeUp,
S_MakeUp);
426 FillTable(WhiteTable, 12, TermW,
S_TermW);
427 FillTable(WhiteTable, 12, EOLH,
S_EOL);
428 FillTable(BlackTable, 13, MakeUpB,
S_MakeUpB);
429 FillTable(BlackTable, 13, MakeUp,
S_MakeUp);
430 FillTable(BlackTable, 13, TermB,
S_TermB);
431 FillTable(BlackTable, 13, EOLH,
S_EOL);
433 fprintf(fd,
"/* WARNING, this file was automatically generated by the\n");
434 fprintf(fd,
" mkg3states program */\n");
435 fprintf(fd,
"#include \"tiff.h\"\n");
436 fprintf(fd,
"#include \"tif_fax3.h\"\n");
437 WriteTable(fd, MainTable, 128,
"TIFFFaxMainTable");
438 WriteTable(fd, WhiteTable, 4096,
"TIFFFaxWhiteTable");
439 WriteTable(fd, BlackTable, 8192,
"TIFFFaxBlackTable");
void WriteTable(FILE *fd, const TIFFFaxTabEnt *T, int Size, const char *name)
int getopt(int, char **, char *)
int main(int argc, char *argv[])
TIFFFaxTabEnt WhiteTable[4096]
TIFFFaxTabEnt BlackTable[8192]
TIFFFaxTabEnt MainTable[128]