diff -aprNU5 jbigkit.orig/Makefile jbigkit/Makefile --- jbigkit.orig/Makefile 2004-06-11 18:05:26 +0000 +++ jbigkit/Makefile 2007-02-27 19:15:46 +0000 @@ -1,22 +1,28 @@ # Unix makefile for JBIG-KIT # $Id: Makefile,v 1.14 2004-06-10 22:00:30+01 mgk25 Exp $ +SHELL = /bin/sh # Select an ANSI/ISO C compiler here, GNU gcc is recommended CC = gcc # Options for the compiler: A high optimization level is suggested CCFLAGS = -O2 -W +#CCFLAGS = -O -g -W -Wall -pedantic #-DDEBUG # developer only #CCFLAGS = -O -g -W -Wall -ansi -pedantic #-DDEBUG # developer only CFLAGS = $(CCFLAGS) -I../libjbig VERSION=1.6 all: lib pbm @echo "Enter 'make test' in order to start some automatic tests." +install: lib pbm + (cd libjbig; make "CC=$(CC)" "CFLAGS=$(CFLAGS)" install) + (cd pbmtools; make "CC=$(CC)" "CFLAGS=$(CFLAGS)" install) + lib: (cd libjbig; make "CC=$(CC)" "CFLAGS=$(CFLAGS)") pbm: lib (cd pbmtools; make "CC=$(CC)" "CFLAGS=$(CFLAGS)") diff -aprNU5 jbigkit.orig/libjbig/Makefile jbigkit/libjbig/Makefile --- jbigkit.orig/libjbig/Makefile 2004-06-08 14:40:06 +0000 +++ jbigkit/libjbig/Makefile 2007-02-27 19:24:04 +0000 @@ -1,30 +1,43 @@ # Unix makefile for the JBIG-KIT library # $Id: Makefile,v 1.9 2004-06-08 15:40:06+01 mgk25 Exp $ +SHELL = /bin/sh + +prefix=/dev/env/DJDIR + +EXEEXT = .exe + # Select an ANSI/ISO C compiler here, GNU gcc is recommended CC = gcc # Options for the compiler: A high optimization level is suggested -CFLAGS = -O -Wall -ansi -pedantic +CFLAGS = -O2 -Wall -pedantic +#CFLAGS = -O -Wall -ansi -pedantic + +all: libjbig.a tstcodec.exe -all: libjbig.a tstcodec +install: libjbig.a + mkdir -p $(prefix)/include + mkdir -p $(prefix)/lib + /dev/env/DJDIR/bin/ginstall -c jbig.h $(prefix)/include/jbig.h + /dev/env/DJDIR/bin/ginstall -c libjbig.a $(prefix)/lib/libjbig.a -tstcodec: tstcodec.c jbig.c jbig.h jbig_tab.o - $(CC) $(CFLAGS) -o tstcodec -DTEST_CODEC tstcodec.c jbig.c \ +tstcodec$(EXEEXT): tstcodec.c jbig.c jbig.h jbig_tab.o + $(CC) $(CFLAGS) -o tstcodec$(EXEEXT) -DTEST_CODEC tstcodec.c jbig.c \ jbig_tab.o libjbig.a: jbig.o jbig_tab.o rm -f libjbig.a ar rc libjbig.a jbig.o jbig_tab.o -ranlib libjbig.a jbig.o: jbig.c jbig.h -test: tstcodec - ./tstcodec +test: tstcodec$(EXEEXT) + ./tstcodec$(EXEEXT) -t82test.pbm: tstcodec - ./tstcodec $@ +t82test.pbm: tstcodec$(EXEEXT) + ./tstcodec$(EXEEXT) $@ clean: - rm -f *.o *~ core gmon.out dbg_d\=??.pbm tstcodec t82test.pbm + rm -f *.o *~ core gmon.out dbg_d\=??.pbm tstcodec$(EXEEXT) t82test.pbm diff -aprNU5 jbigkit.orig/pbmtools/Makefile jbigkit/pbmtools/Makefile --- jbigkit.orig/pbmtools/Makefile 2003-06-11 17:27:22 +0000 +++ jbigkit/pbmtools/Makefile 2007-02-27 19:24:04 +0000 @@ -1,31 +1,48 @@ # Unix makefile for the JBIG-KIT PBM tools # $Id: Makefile,v 1.12 2003-06-11 18:27:22+01 mgk25 Exp $ +SHELL = /bin/sh + +prefix=/dev/env/DJDIR + +EXEEXT = .exe + # Select an ANSI/ISO C compiler here, e.g. GNU gcc is recommended CC = gcc # Options for the compiler -CFLAGS = -g -Wall -ansi -pedantic -I../libjbig +CFLAGS = -O2 -Wall -pedantic -I../libjbig +#CFLAGS = -O -Wall -ansi -pedantic -I../libjbig .SUFFIXES: .1 .5 .txt $(SUFFIXES) -all: pbmtojbg jbgtopbm pbmtojbg.txt jbgtopbm.txt pbm.txt pgm.txt +all: pbmtojbg$(EXEEXT) jbgtopbm$(EXEEXT) pbmtojbg.txt jbgtopbm.txt pbm.txt pgm.txt + +install: pbmtojbg$(EXEEXT) jbgtopbm$(EXEEXT) + mkdir -p $(prefix)/bin + mkdir -p $(prefix)/share/man/man1 + mkdir -p $(prefix)/share/man/man5 + /dev/env/DJDIR/bin/ginstall -c pbmtojbg$(EXEEXT) $(prefix)/bin/pbmtojbg$(EXEEXT) + /dev/env/DJDIR/bin/ginstall -c jbgtopbm$(EXEEXT) $(prefix)/bin/jbgtopbm$(EXEEXT) + /dev/env/DJDIR/bin/ginstall -c jbgtopbm.1 $(prefix)/share/man/man1/jbgtopbm.1 + /dev/env/DJDIR/bin/ginstall -c pbmtojbg.1 $(prefix)/share/man/man1/pbmtojbg.1 + /dev/env/DJDIR/bin/ginstall -c pbm.5 $(prefix)/share/man/man5/pbm.5 -pbmtojbg: pbmtojbg.o ../libjbig/libjbig.a - $(CC) $(CFLAGS) -o pbmtojbg pbmtojbg.o -L../libjbig -ljbig +pbmtojbg$(EXEEXT): pbmtojbg.o ../libjbig/libjbig.a + $(CC) $(CFLAGS) -o pbmtojbg$(EXEEXT) pbmtojbg.o -L../libjbig -ljbig -jbgtopbm: jbgtopbm.o ../libjbig/libjbig.a - $(CC) $(CFLAGS) -o jbgtopbm jbgtopbm.o -L../libjbig -ljbig +jbgtopbm$(EXEEXT): jbgtopbm.o ../libjbig/libjbig.a + $(CC) $(CFLAGS) -o jbgtopbm$(EXEEXT) jbgtopbm.o -L../libjbig -ljbig jbgtopbm.o: jbgtopbm.c ../libjbig/jbig.h pbmtojbg.o: pbmtojbg.c ../libjbig/jbig.h ../libjbig/libjbig.a: ../libjbig/jbig.c ../libjbig/jbig.h cd ../libjbig ; make libjbig.a -test: pbmtojbg jbgtopbm +test: pbmtojbg$(EXEEXT) jbgtopbm$(EXEEXT) make IMG=ccitt1 OPTIONSJ= OPTIONSP= dotest1 make IMG=ccitt2 OPTIONSJ= OPTIONSP= dotest1 make IMG=ccitt3 OPTIONSJ= OPTIONSP= dotest1 make IMG=xvlogo OPTIONSJ= "OPTIONSP=-d 3" dotest1 make IMG=sandra OPTIONSP= OPTIONSJ= dotest2g @@ -39,47 +56,47 @@ test: pbmtojbg jbgtopbm make IMG=mx "OPTIONSP=-q -s 3 -m 128" dotest2b make IMG=mx "OPTIONSP=-q -s 3 -m 128 -p 92" dotest2b make IMG=mx "OPTIONSP=-q -Y -1" dotest2b make IMG=mx "OPTIONSP=-Y -1" dotest2b rm -f test-*.jbg test-*.pbm test-*.pgm - ./jbgtopbm ../examples/ccitt1.jbg | ./pbmtojbg > test-ccitt1.jbg + ./jbgtopbm$(EXEEXT) ../examples/ccitt1.jbg | ./pbmtojbg$(EXEEXT) > test-ccitt1.jbg cmp ../examples/ccitt1.jbg test-ccitt1.jbg rm -f test-*.jbg test-*.pbm test-*.pgm - ./jbgtopbm < ../examples/ccitt1.jbg | ./pbmtojbg - test-ccitt1.jbg + ./jbgtopbm$(EXEEXT) < ../examples/ccitt1.jbg | ./pbmtojbg$(EXEEXT) - test-ccitt1.jbg cmp ../examples/ccitt1.jbg test-ccitt1.jbg rm -f test-*.jbg test-*.pbm test-*.pgm - ./jbgtopbm < ../examples/ccitt1.jbg - test-ccitt1.pbm ; \ - ./pbmtojbg test-ccitt1.pbm test-ccitt1.jbg + ./jbgtopbm$(EXEEXT) < ../examples/ccitt1.jbg - test-ccitt1.pbm ; \ + ./pbmtojbg$(EXEEXT) test-ccitt1.pbm test-ccitt1.jbg cmp ../examples/ccitt1.jbg test-ccitt1.jbg rm -f test-*.jbg test-*.pbm test-*.pgm - ./jbgtopbm ../examples/ccitt1.jbg test-ccitt1.pbm ; \ - ./pbmtojbg test-ccitt1.pbm >test-ccitt1.jbg + ./jbgtopbm$(EXEEXT) ../examples/ccitt1.jbg test-ccitt1.pbm ; \ + ./pbmtojbg$(EXEEXT) test-ccitt1.pbm >test-ccitt1.jbg cmp ../examples/ccitt1.jbg test-ccitt1.jbg rm -f test-*.jbg test-*.pbm test-*.pgm @echo @echo "The pbmtools have PASSED the functional tests. Good!" @echo dotest1: - ./jbgtopbm $(OPTIONSJ) ../examples/$(IMG).jbg test-$(IMG).pbm - ./pbmtojbg $(OPTIONSP) test-$(IMG).pbm test-$(IMG).jbg + ./jbgtopbm$(EXEEXT) $(OPTIONSJ) ../examples/$(IMG).jbg test-$(IMG).pbm + ./pbmtojbg$(EXEEXT) $(OPTIONSP) test-$(IMG).pbm test-$(IMG).jbg cmp test-$(IMG).jbg ../examples/$(IMG).jbg dotest2b: - ./pbmtojbg $(OPTIONSP) test-$(IMG).pbm test-$(IMG).jbg - ./jbgtopbm $(OPTIONSJ) test-$(IMG).jbg test-$(IMG)-2.pbm + ./pbmtojbg$(EXEEXT) $(OPTIONSP) test-$(IMG).pbm test-$(IMG).jbg + ./jbgtopbm$(EXEEXT) $(OPTIONSJ) test-$(IMG).jbg test-$(IMG)-2.pbm cmp test-$(IMG).pbm test-$(IMG)-2.pbm dotest2g: - ./pbmtojbg $(OPTIONSP) ../examples/$(IMG).pgm test-$(IMG).jbg - ./jbgtopbm $(OPTIONSJ) test-$(IMG).jbg test-$(IMG).pgm + ./pbmtojbg$(EXEEXT) $(OPTIONSP) ../examples/$(IMG).pgm test-$(IMG).jbg + ./jbgtopbm$(EXEEXT) $(OPTIONSJ) test-$(IMG).jbg test-$(IMG).pgm cmp test-$(IMG).pgm ../examples/$(IMG).pgm .1.txt: gtroff -man -Tascii $< | grotty -u -b - >$@ .5.txt: gtroff -man -Tascii $< | grotty -u -b - >$@ clean: - rm -f *.o *~ core pbmtojbg jbgtopbm + rm -f *.o *~ core pbmtojbg$(EXEEXT) jbgtopbm$(EXEEXT) rm -f test-*.jbg test-*.pbm test-*.pgm diff -aprNU5 jbigkit.orig/pbmtools/jbgtopbm.c jbigkit/pbmtools/jbgtopbm.c --- jbigkit.orig/pbmtools/jbgtopbm.c 2004-06-11 14:17:56 +0000 +++ jbigkit/pbmtools/jbgtopbm.c 2007-02-27 19:15:46 +0000 @@ -9,10 +9,30 @@ #include #include #include #include "jbig.h" +/* + * For systems that distinguish between binary and text mode, + * define this macro to 1 to set stdin and stdout into O_BINARY mode + * or define it to 0 to set stdin and stdout into O_TEXT mode. + * If stdio/stdout has been set to binary mode the program **can not** + * be interrupted with cntl-c nor cntl-break. This means that you will + * have to reset your machine to gain control again but you will be able + * process image files from and to a pipe. + * If stdin/stdout has been set to text mode the program **can not** + * process images receive from stdin nor send images to stdout, but + * you will be able to interrupt the program under any circumstances. + */ +#define SET_STDIN_STDOUT_IN_BINARY_MODE 1 + +#if SET_STDIN_STDOUT_IN_BINARY_MODE +# include +# include +# include +#endif + char *progname; /* global pointer to argv[0] */ /* * Print usage message and abort @@ -110,11 +130,11 @@ void diagnose_bie(FILE *f) int layers, planes, sde = 0; /* read BIH */ read_file(&bie, &buflen, &len, f); if (len < 20) { - fprintf(d, "Error: Input file is %d < 20 bytes long and therefore " + fprintf(d, "Error: Input file is %U < 20 bytes long and therefore " "does not contain an intact BIE header!\n", len); return; } /* parse BIH */ @@ -156,11 +176,11 @@ void diagnose_bie(FILE *f) p = bie + 20; /* skip BIH */ if ((bie[19] & (JBG_DPON | JBG_DPPRIV | JBG_DPLAST)) == (JBG_DPON | JBG_DPPRIV)) p += 1728; /* skip DPTABLE */ if (p > bie + len) { - fprintf(d, "Error: Input file is %d < 20+1728 bytes long and therefore " + fprintf(d, "Error: Input file is %U < 20+1728 bytes long and therefore " "does not contain an intact BIE header with DPTABLE!\n", len); return; } while (p != bie + len) { if (p > bie + len - 2) { @@ -295,12 +315,17 @@ int main (int argc, char **argv) if (!fin) { fprintf(stderr, "Can't open input file '%s", fnin); perror("'"); exit(1); } - } else + } else { fnin = ""; +#if SET_STDIN_STDOUT_IN_BINARY_MODE + setmode(fileno(fin), O_BINARY); + __djgpp_set_ctrl_c(1); +#endif + } if (diagnose) { diagnose_bie(fin); exit(0); } if (fnout) { @@ -308,20 +333,25 @@ int main (int argc, char **argv) if (!fout) { fprintf(stderr, "Can't open input file '%s", fnout); perror("'"); exit(1); } - } else + } else { fnout = ""; +#if SET_STDIN_STDOUT_IN_BINARY_MODE + setmode(fileno(fout), O_BINARY); + __djgpp_set_ctrl_c(1); +#endif + } /* send input file to decoder */ jbg_dec_init(&s); jbg_dec_maxsize(&s, xmax, ymax); /* read BIH first to check VLENGTH */ len = fread(buffer, 1, 20, fin); if (len < 20) { - fprintf(stderr, "Input file '%s' (%d bytes) must be at least " + fprintf(stderr, "Input file '%s' (%U bytes) must be at least " "20 bytes long\n", fnin, len); if (fout != stdout) { fclose(fout); remove(fnout); } diff -aprNU5 jbigkit.orig/pbmtools/pbmtojbg.c jbigkit/pbmtools/pbmtojbg.c --- jbigkit.orig/pbmtools/pbmtojbg.c 2004-06-11 14:17:58 +0000 +++ jbigkit/pbmtools/pbmtojbg.c 2007-02-27 19:15:46 +0000 @@ -10,10 +10,30 @@ #include #include #include "jbig.h" +/* + * For systems that distinguish between binary and text mode, + * define this macro to 1 to set stdin and stdout into O_BINARY mode + * or define it to 0 to set stdin and stdout into O_TEXT mode. + * If stdio/stdout has been set to binary mode the program **can not** + * be interrupted with cntl-c nor cntl-break. This means that you will + * have to reset your machine to gain control again but you will be able + * process image files from and to a pipe. + * If stdin/stdout has been set to text mode the program **can not** + * process images receive from stdin nor send images to stdout, but + * you will be able to interrupt the program under any circumstances. + */ +#define SET_STDIN_STDOUT_IN_BINARY_MODE 1 + +#if SET_STDIN_STDOUT_IN_BINARY_MODE +# include +# include +# include +#endif + char *progname; /* global pointer to argv[0] */ unsigned long total_length = 0; /* used for determining output file length */ /* @@ -222,21 +242,31 @@ int main (int argc, char **argv) if (!fin) { fprintf(stderr, "Can't open input file '%s", fnin); perror("'"); exit(1); } - } else + } else { fnin = ""; +#if SET_STDIN_STDOUT_IN_BINARY_MODE + setmode(fileno(fin), O_BINARY); + __djgpp_set_ctrl_c(1); +#endif + } if (fnout) { fout = fopen(fnout, "wb"); if (!fout) { fprintf(stderr, "Can't open input file '%s", fnout); perror("'"); exit(1); } - } else + } else { fnout = ""; +#if SET_STDIN_STDOUT_IN_BINARY_MODE + setmode(fileno(fout), O_BINARY); + __djgpp_set_ctrl_c(1); +#endif + } /* read PBM header */ while ((c = getc(fin)) != EOF && (isspace(c) || c == '#')) if (c == '#') while ((c = getc(fin)) != EOF && !(c == 13 || c == 10)) ;