From: SMTP%"DSJ@WKUVX1.WKU.EDU" 7-FEB-1995 12:49:58.78 To: EVERHART CC: Subj: DECEMBER94.SQUEEZ From: DSJ-Mgr@WKUVX1.WKU.EDU Message-Id: <199502071725.MAA23766@mx2.smtp.psi.net> X-FileServer: Digital Systems Journal File Server Date: Tue, 07 Feb 1995 11:25:16 CST Sender: DSJ-Mgr@WKUVX1.WKU.EDU Errors-To: DSJ-Mgr@WKUVX1.WKU.EDU Warnings-To: <> Reply-To: DSJ@WKUVX1.WKU.EDU Subject: DECEMBER94.SQUEEZ To: EVERHART@arisia.gce.com $! ------------------ CUT HERE ----------------------- $ v='f$verify(f$trnlnm("SHARE_UNPACK_VERIFY"))' $! $! This archive created: $! Name : SQUEEZ $! By : Hunter Goatley $! Date : 4-JAN-1995 09:16:23.71 $! Using: VMS_SHARE 8.5-1, (C) 1993 Andy Harper, Kings College London UK $! $! Credit is due to these people for their original ideas: $! James Gray, Michael Bednarek $! $! To unpack this archive: $! Minimum of VMS 4.4 (VAX) / OpenVMS 1.0 (Alpha) is required. $! Remove the headers of the first part, up to `cut here' line. $! Execute file as a command procedure. $! $! The following file(s) will be created after unpacking: $! 1. SQUEEZ.DSJ;1 $! $ set="set" $ set symbol/scope=(nolocal,noglobal) $ f="SYS$SCRATCH:."+f$getjpi("","PID")+";" $ if f$trnlnm("SHARE_UNPACK") .nes. "" then $ - f=f$parse("SHARE_UNPACK_TEMP",f) $ e="write sys$error ""%UNPACK"", " $ w="write sys$output ""%UNPACK"", " $ if .not. f$trnlnm("SHARE_UNPACK_LOG") then $ w = "!" $ if f$getsyi("CPU") .gt. 127 then $ goto start $ ve=f$getsyi("version") $ if ve-f$extract(0,1,ve) .ges. "4.4" then $ goto start $ e "-E-OLDVER, Must run at least VMS 4.4" $ v=f$verify(v) $ exit 44 $unpack:subroutine!P1=file,P2=chksum,P3=attrib,P4=size,P5=fileno,P6=filetotal $ if f$parse(P1) .nes. "" then $ goto dirok $ dn=f$parse(P1,,,"DIRECTORY") $ w "-I-CREDIR, Creating directory ''dn'" $ create/dir 'dn' $ if $status then $ goto dirok $ e "-E-CREDIRFAIL, Unable to create ''dn' File skipped" $ delete 'f'* $ exit $dirok: $ x=f$search(P1) $ if x .eqs. "" then $ goto file_absent $ e "-W-EXISTS, File ''P1' exists. Skipped" $ delete 'f'* $ exit $file_absent: $ w "-I-UNPACK, Unpacking ", P5, " of ", P6, " - ", P1, " - ", P4, " Blocks" $ n=P1 $ if P3 .nes. "" then $ n=f $ if .not. f$verify() then $ define/user sys$output nl: $ EDIT/TPU/NOSEC/NODIS/COM=SYS$INPUT/NOJOURNAL 'f'/OUT='n' PROCEDURE GetHex(s,p)LOCAL x1,x2;x1:=INDEX(t,SUBSTR(s,p,1))-1;x2:=INDEX(t, SUBSTR(s,p+1,1))-1;RETURN 16*x1+x2;ENDPROCEDURE;PROCEDURE SkipPartsep LOCAL m; LOOP m:=MARK(NONE);EXITIF m=END_OF(CURRENT_BUFFER);DELETE(m);EXITIF INDEX( ERASE_LINE,"-+-+-+-+-+-+-+-+")=1;ENDLOOP;ENDPROCEDURE; PROCEDURE ProcessLine LOCAL c,s,l,b,n,p;s := ERASE_LINE;c := SUBSTR(s,1,1);s := s-c;IF c = "X" THEN SPLIT_LINE; ENDIF;MOVE_HORIZONTAL(-1);l := LENGTH(s);p := 1;LOOP EXITIF p > l;c := SUBSTR(s,p,1);p := p+1;CASE c FROM ' ' TO '`' ['`'] : COPY_TEXT(ASCII(GetHex(s,p))); p:=p+2;[' ']: p:=p+1;[INRANGE,OUTRANGE] : COPY_TEXT(c);ENDCASE;ENDLOOP;ENDPROCEDURE;PROCEDURE Decode(b)LOCAL m; POSITION(BEGINNING_OF(b));LOOP m:=MARK(NONE);EXITIF m=END_OF(b);DELETE(m); IF INDEX(CURRENT_LINE,"+-+-+-+-+-+-+-+-")=1 THEN SkipPartSep;ELSE ProcessLine; MOVE_HORIZONTAL(1);ENDIF;ENDLOOP;ENDPROCEDURE;SET(FACILITY_NAME,"UNPACK");SET( SUCCESS,OFF);SET(INFORMATIONAL,OFF);t:="0123456789ABCDEF";f:=GET_INFO( COMMAND_LINE,"file_name");o:=CREATE_BUFFER(f,f);Decode(o);WRITE_FILE(o, GET_INFO(COMMAND_LINE,"output_file"));QUIT; $ if p3 .eqs. "" then $ goto dl $ open/write fdl &f $ write fdl "RECORD" $ write fdl P3 $ close fdl $ w "-I-CONVRFM, Converting record format to ", P3 $ convert/fdl='f' 'f'-1 'f' $ fa=f$getdvi(f$parse(f),"ALLDEVNAM") $ Pa=f$getdvi(f$parse(P1),"ALLDEVNAM") $ if fa .eqs. Pa then $ rename &f 'f$parse(P1)' $ if fa .nes. Pa then $ copy &f 'f$parse(P1)' $dl: delete 'f'* $ checksum 'P1' $ if checksum$checksum .nes. P2 then $ - e "-E-CHKSMFAIL, Checksum of ''P1' failed." $ exit $ endsubroutine $start: $! $ create 'f' X/* X`20*`20SQUEEZE.C`20-`20compress`20PostScript`20image`20file`20(output`20by`20D VDIF`20convertor). X`20*`20Copyright`20(C)`20Nick`20Brown,`201994.`20`20All`20rights`20reserved. X`20*`20Contains`20constants`20suitable`20for`20processing`20faxes`20from`20Top VCall`20system: X`20*`20`20may`20need`20changing`20for`20other`20applications. X`20*`20Looks`20for`20certain`20key`20lines,`20so`20may`20be`20version-dependen Vt. X`20*/ X X#include`20 X#include`20 X#include`20 X X/* X`20*`20Edit`20the`20next`20section`20for`20your`20machine`20to`20show`20whethe Vr`20arrays`20can X`20*`20`20exceed`2032K`20bytes`20in`20size. X`20*/ X#ifdef`20VAX X#define`20BIGARRAY`201 X#else X#define`20BIGARRAY`200 X#endif X X#define`20ERROR`200x10000002 X#define`20SEVERE_ERROR`200x10000004 X X#if`20BIGARRAY X#define`20MAX_INPUT_RECORD`202048`09`09/*`20room`20for`20input`20record`20*/ X#else X#define`20MAX_INPUT_RECORD`20511`09`09/*`20room`20for`20input`20record`20*/ X#endif X Xstatic`20unsigned`20char`20white`20=`200;`09`09/*`20mask`20of`20all`20white`20 Vbits`20*/ X Xstatic`20int`20only_one_bit`20=`200;`09`09/*`20force`20only`20one`20bit`20per V`20sample`20*/ Xstatic`20int`20bits_per_sample;`09`09/*`20value`20currently`20in`20use`20*/ Xstatic`20int`20file_bits`20=`200;`09`09/*`20value`20from`20image`20file`20*/ X X#define`20MAX_X_SAMPLE_BYTES`2032`09`09/*`20up`20to`20256`20bits`20horizontall Vy`20*/ X#define`20DEFAULT_X_SAMPLE_BYTES`208`09/*`2064`20bits`20horizontally`20by`20de Vfault`20*/ X#define`20BITS_PER_BYTE`208 X X#if`20BIGARRAY X#define`20MAX_Y_SAMPLE_BITS`20256`09`09/*`20up`20to`20this`20many`20bits`20ver Vtically`20*/ X#else X#define`20MAX_Y_SAMPLE_BITS`20128`09`09/*`20up`20to`20this`20many`20bits`20ver Vtically`20*/ X#endif X#define`20DEFAULT_Y_SAMPLE_BITS`2040`09/*`2040`20bits`20vertically`20by`20defa Vult`20*/ X Xstatic`20int`20x_sample_bytes`20=`20DEFAULT_X_SAMPLE_BYTES; Xstatic`20int`20x_sample_bits`20=`20DEFAULT_X_SAMPLE_BYTES`20*`20BITS_PER_BYTE; V Xstatic`20int`20y_sample_bits`20=`20DEFAULT_Y_SAMPLE_BITS; X X#define`20MAX_X_MARGIN`20288 X#define`20DEFAULT_X_MARGIN`200 X X#define`20MAX_Y_MARGIN`20288 X#define`20DEFAULT_Y_MARGIN`200 X Xstatic`20int`20x_margin`20=`20DEFAULT_X_MARGIN; Xstatic`20int`20y_margin`20=`20DEFAULT_Y_MARGIN; X Xstatic`20int`20y_hack`20=`200x7fffffff;`09`09/*`20hack`20for`20TopCall`20high- Vdensity`20bug`20*/ X X/* X`20*`20X`20and`20Y`20resolution.`20`20This`20could`20be`20obtained`20from`20th Ve`20image`20file`20by`20a X`20*`20`20more`20sophisticated`20parser,`20by`20spotting`20the`20scale`20in`20 Vuse,`20then`20calculating X`20*`20`20x_res`20=`20x_bits`20*`2072`20/`20x_scale,`20etc.`20`20However,`20we V`20don't`20do`20that:`20you`20have X`20*`20`20to`20provide`20it`20on`20the`20command`20line.`20`20The`20default`20 Vvalues`20below`20are`20for X`20*`20`20our`20application`20(incoming`20faxes). X`20*/ X#define`20MIN_X_RES`2072.0 X#define`20DEFAULT_X_RES`20204.0`09/*`20for`20faxes`20*/ X#define`20MAX_X_RES`202160.0 X X#define`20MIN_Y_RES`2072.0 X#define`20DEFAULT_Y_RES`20196.0`09/*`20for`20faxes`20*/ X#define`20MAX_Y_RES`202160.0 X Xstatic`20double`20x_res`20=`20DEFAULT_X_RES; Xstatic`20double`20y_res`20=`20DEFAULT_Y_RES; X Xstatic`20double`20x_points; Xstatic`20double`20y_points; Xstatic`20double`20y_points_hack; X Xstatic`20int`20file_record_size`20=`200;`09/*`20bytes`20per`20multi-line`20inp Vut`20record`20*/ X X/* X`20*`20Structure`20that`20describes`20one`20scan`20line`20-`20just`20an`20arra Vy`20for`20now. X`20*/ Xtypedef`20struct`20`7B X`20`20unsigned`20char`20x_line`20`5BMAX_INPUT_RECORD`5D; X`7D`20SCAN_REC; X X/* X`20*`20Output`20a`20double-precision`20floating-point`20number`20in`20as`20sma Vll`20a`20field`20as X`20*`20`20possible,`20stripping`20leading`20and`20trailing`20zeroes.`20`20Most V`20numbers`20in`20the X`20*`20`20range`20used`20by`20this`20program`20(0.0-999.0)`20will`20be`20outpu Vt`20to`205`20figures. X`20*/ Xstatic Xvoid Xfprint_double`20(FILE`20*fp,`20double`20number) X`7B X`20`20char`20string`20`5B20`5D; X`20`20char`20*sp; X`20`20char`20*cp; X`20`20int`20decimals; X`20`20double`20absnum`20=`20(number`20>`200.0`20?`20number`20:`200.0`20-`20num Vber); X X`20`20if`20(absnum`20>=`20100.0)`20`7B X`20`20`20`20decimals`20=`202; X`20`20`7D X`20`20else`20if`20(absnum`20>=`2010.0)`20`7B X`20`20`20`20decimals`20=`203; X`20`20`7D X`20`20else`20if`20(absnum`20>=`201.0)`20`7B X`20`20`20`20decimals`20=`204; X`20`20`7D X`20`20else`20`7B X`20`20`20`20decimals`20=`205; X`20`20`7D X X`20`20sprintf(string,`20"%.*f",`20decimals,`20number); X`20`20sp`20=`20string; X`20`20while`20(*sp`20==`20'0')`20`7B X`20`20`20`20++sp;`09`09`09/*`20skip`20leading`20zeroes`20*/ X`20`20`7D X X`20`20cp`20=`20sp`20+`20strlen(sp); X`20`20while`20(*--cp`20==`20'0')`20`7B X`20`20`20`20*cp`20=`20'`5C0';`09`09`09/*`20strip`20trailing`20zeroes`20*/ X`20`20`7D X X`20`20if`20(*cp`20==`20'.')`20`7B X`20`20`20`20*cp--`20=`20'`5C0';`09`09/*`20strip`20trailing`20period`20*/ X`20`20`7D X X`20`20if`20(sp`20>`20cp)`20`7B`09`09/*`20we've`20removed`20everything`20*/ X`20`20`20`20*++cp`20=`20'0';`09`09/*`20put`20back`20a`20zero`20*/ X`20`20`7D X X`20`20*++cp`20=`20'`20';`09`09`09/*`20add`20trailing`20space`20*/ X`20`20*++cp`20=`20'`5C0';`09`09`09/*`20terminate`20string`20*/ X X`20`20fputs(sp,`20fp); X`7D X X/* X`20*`20Routine`20to`20optimise`20buffer`20by`20detecting`20and`20eliminating V`20patterns. X`20*/ Xstatic Xint Xoptimise_buffer`20(unsigned`20char`20*buffer,`20int`20length) X`7B X`20`20int`20i; X`20`20int`20p; X#define`20N_PRIMES`205 X`20`20static`20int`20primes`20`5BN_PRIMES`5D`20=`20`7B`200,`202,`203,`205,`207 V`20`7D; X X`20`20if`20(length`20<=`201)`20`7B X`20`20`20`20return`20length;`09`09/*`20can't`20optimise`20this`20!`20*/ X`20`20`7D X X/* X`20*`20If`20the`20buffer`20consists`20of`20a`20number`20of`20repetitions`20of V`20the`20same`20data,`20we`20can X`20*`20`20just`20output`20the`20first`20instance;`20the`20PostScript`20image V`20operator`20will`20repeat X`20*`20`20the`20data.`20`20We`20can`20apply`20this`20iteratively. X`20*`20The`20first`20'prime'`20we`20try`20is`20the`20whole`20length`20of`20the V`20buffer;`20if`20this`20matches, X`20*`20`20it`20means`20the`20whole`20buffer`20consists`20of`20identical`20byte Vs. X`20*`20If`20the`20buffer`20length`20is`20not`20divisible`20by`20a`20prime,`20i Vt`20doesn't`20matter:`20we X`20*`20`20consider`20the`20buffer`20to`20be`20padded`20on`20the`20right`20with V`20"dont-care"`20bytes. X`20*`20These`20bytes`20will`20not`20be`20read`20when`20image`20re-uses`20the V`20string`20for`20the`20last`20time. X`20*/ X`20`20primes`5B0`5D`20=`20length; X`20`20for`20(p`20=`200;`20(p`20<`20N_PRIMES)`20`26`26`20(length`20>=`20primes V`5Bp`5D);`20p++)`20`7B X`20`20`20`20int`20chunk`20=`20(length`20+`20primes`5Bp`5D`20-`201)`20/`20prime Vs`5Bp`5D;`09/*`20size`20of`20chunk`20*/ X`20`20`20`20int`20match`20=`201;`09`09`09/*`20assume`20we`20will`20find`20a`20 Vmatch`20*/ X X`20`20`20`20for`20(i`20=`200;`20i`20<`20chunk;`20i++)`20`7B`09/*`20for`20each V`20byte`20in`20first`20chunk`20*/ X`20`20`20`20`20`20int`20j; X X`20`20`20`20`20`20for`20(j`20=`201;`20j`20<`20primes`5Bp`5D;`20j++)`20`7B`09/* V`20for`20each`20subsequent`20chunk`20*/ X`20`20`20`20`20`20`20`20int`20tp`20=`20(chunk`20*`20j)`20+`20i;`09/*`20corresp Vonding`20byte`20in`20chunk`20*/ X X`20`20`20`20`20`20`20`20if`20((tp`20<`20length)`20`26`26`20(buffer`5Bi`5D`20!= V`20buffer`5Btp`5D))`20`7B X`20`20`20`20`20`20`20`20`20`20match`20=`200;`09`09/*`20byte`20is`20valid`20and V`20does`20not`20match`20*/ X`20`20`20`20`20`20`20`20`20`20goto`20break_prime;`09/*`20never`20apologise,`20 Vnever`20explain`20*/ X`20`20`20`20`20`20`20`20`7D X`20`20`20`20`20`20`7D X`20`20`20`20`7D X`20`20break_prime: X X`20`20`20`20if`20(match)`20`7B X`20`20`20`20`20`20length`20=`20chunk;`09`09/*`20all`20chunks`20were`20identica Vl`20*/ X`20`20`20`20`7D X`20`20`7D X X`20`20return`20length; X`7D X X/* X`20*`20Routine`20to`20output`20a`20group`20of`20scan`20lines. X`20*/ Xstatic Xvoid Xoutput_records`20(FILE`20*fp,`20SCAN_REC`20*srp,`20int`20n_records,`20int`20y_ Voffset) X`7B X`20`20int`20x0; X`20`20int`20record_size`20=`20file_record_size; X X/* X`20*`20If`20we`20are`20reducing`20the`20bits`20in`20each`20sample,`20compress V`20the`20record`20here. X`20*/ X`20`20if`20(bits_per_sample`20<`20file_bits)`20`7B X`20`20`20`20int`20y; X`20`20`20`20int`20use_bits`20=`20BITS_PER_BYTE`20/`20file_bits; X`20`20`20`20int`20rightshift`20=`20BITS_PER_BYTE`20-`20use_bits; X X`20`20`20`20for`20(y`20=`200;`20y`20<`20n_records;`20y++)`20`7B X`20`20`20`20`20`20unsigned`20char`20*inline`20=`20srp`5By`5D.x_line; X`20`20`20`20`20`20unsigned`20char`20*outline`20=`20inline; X X`20`20`20`20`20`20for`20(x0`20=`200;`20x0`20<`20record_size;`20x0`20+=`20file_ Vbits)`20`7B X`20`20`20`20`20`20`20`20int`20x; X`20`20`20`20`20`20`20`20unsigned`20char`20c`20=`200; X X`20`20`20`20`20`20`20`20for`20(x`20=`200;`20x`20<`20file_bits;`20x++)`20`7B X`20`20`20`20`20`20`20`20`20`20int`20leftshift`20=`20BITS_PER_BYTE`20-`20((x`20 V+`201)`20*`20use_bits); X`20`20`20`20`20`20`20`20`20`20unsigned`20char`20byte; X X`20`20`20`20`20`20`20`20`20`20byte`20=`20((x0`20+`20x)`20<`20record_size`20? V`20inline`5Bx0`20+`20x`5D`20:`20white); X`20`20`20`20`20`20`20`20`20`20c`20`7C=`20((byte`20>>`20rightshift)`20<<`20left Vshift); X`20`20`20`20`20`20`20`20`7D X X`20`20`20`20`20`20`20`20*outline++`20=`20c; X`20`20`20`20`20`20`7D X`20`20`20`20`7D X X`20`20`20`20record_size`20=`20(record_size`20+`20file_bits`20-`201)`20/`20file V_bits; X`20`20`7D X X/* X`20*`20Treat`20each`20block`20of`20bytes`20as`20a`20separate`20image.`20`20If V`20any`20bit`20is`20non-zero, X`20*`20`20we`20will`20output`20the`20image,`20after`20stripping`20zero`20bits V`20from`20the`20edges. X`20*/ X`20`20for`20(x0`20=`200;`20x0`20<`20record_size;`20x0`20+=`20x_sample_bytes) V`20`7B X`20`20`20`20int`20y; X`20`20`20`20int`20print_this`20=`200; X`20`20`20`20int`20x_limit`20=`20(`20`20`20((x0`20+`20x_sample_bytes)`20>=`20re Vcord_size) X`20`20`20`20`20`20`20`20`20`20`20`20`20`20`20`20`20`20`20`20?`20record_size`20 V-`20x0 X`20`20`20`20`20`20`20`20`20`20`20`20`20`20`20`20`20`20`20`20:`20x_sample_bytes V X`20`20`20`20`20`20`20`20`20`20`20`20`20`20`20`20`20`20); X`20`20`20`20int`20x_min`20=`20x_limit; X`20`20`20`20int`20x_max`20=`200; X`20`20`20`20int`20y_min`20=`20n_records; X`20`20`20`20int`20y_max`20=`200; X X`20`20`20`20for`20(y`20=`200;`20y`20<`20n_records;`20y++)`20`7B X`20`20`20`20`20`20int`20x; X X`20`20`20`20`20`20for`20(x`20=`200;`20x`20<`20x_limit;`20x++)`20`7B X`20`20`20`20`20`20`20`20if`20(srp`5By`5D.x_line`5Bx0`20+`20x`5D`20!=`20white) V`20`7B`09/*`20non-blank`20*/ X`20`20`20`20`20`20`20`20`20`20print_this`20=`201; X X`20`20`20`20`20`20`20`20`20`20if`20(x`20<`20x_min)`20`7B X`20`20`20`20`20`20`20`20`20`20`20`20x_min`20=`20x; X`20`20`20`20`20`20`20`20`20`20`7D X X`20`20`20`20`20`20`20`20`20`20if`20(x`20>`20x_max)`20`7B X`20`20`20`20`20`20`20`20`20`20`20`20x_max`20=`20x; X`20`20`20`20`20`20`20`20`20`20`7D X X`20`20`20`20`20`20`20`20`20`20if`20(y`20<`20y_min)`20`7B X`20`20`20`20`20`20`20`20`20`20`20`20y_min`20=`20y; X`20`20`20`20`20`20`20`20`20`20`7D X X`20`20`20`20`20`20`20`20`20`20if`20(y`20>`20y_max)`20`7B X`20`20`20`20`20`20`20`20`20`20`20`20y_max`20=`20y; X`20`20`20`20`20`20`20`20`20`20`7D X`20`20`20`20`20`20`20`20`7D X`20`20`20`20`20`20`7D X`20`20`20`20`7D X X`20`20`20`20if`20(print_this)`20`7B X`20`20`20`20`20`20int`20x_bits`20=`20((x_max`20-`20x_min`20+`201)`20*`20BITS_P VER_BYTE)`20/`20bits_per_sample; X`20`20`20`20`20`20int`20y_bits`20=`20y_max`20-`20y_min`20+`201; X X`20`20`20`20`20`20int`20x_line`20=`20((x0`20+`20x_min)`20*`20BITS_PER_BYTE)`20 V/`20bits_per_sample; X`20`20`20`20`20`20int`20y_line`20=`20y_offset`20+`20(n_records`20-`20y_max`20- V`201); X X`20`20`20`20`20`20double`20x_pos`20=`20(x_line`20*`20x_points)`20+`20x_margin; V X`20`20`20`20`20`20double`20y_pos`20=`20(y_line`20*`20y_points_hack)`20+`20y_ma Vrgin; X X`20`20`20`20`20`20unsigned`20char`20ps_string`20`5BMAX_X_SAMPLE_BYTES`20*`20MA VX_Y_SAMPLE_BITS`5D; X`20`20`20`20`20`20unsigned`20char`20*psp`20=`20ps_string; X`20`20`20`20`20`20int`20ps_string_size; X X`20`20`20`20`20`20unsigned`20char`20out_line`20`5BMAX_X_SAMPLE_BYTES`20*`20MAX V_Y_SAMPLE_BITS`20*`204`20+`204`5D; X`20`20`20`20`20`20unsigned`20char`20*olp`20=`20out_line; X X`20`20`20`20`20`20int`20double_up`20=`200; X X#define`20DOUBLE_UP`201 X#if`20DOUBLE_UP X/* X`20*`20If`20the`20image`20is`20a`20low-density`20fax,`20lines`20will`20come`20 Vin`20identical`20pairs. X`20*`20If`20we`20detect`20this,`20we`20change`20the`20aspect`20ratio`20and`20h Valve`20the`20bytes`20sent. X`20*`20If`20this`20can't`20happen`20in`20your`20application,`20just`20define V`20USE_DOUBLE_UP`20to`200 X`20*`20`20and`20recompile,`20to`20save`20execution`20time. X`20*/ X`20`20`20`20`20`20if`20((y_max`20-`20y_min)`20`26`201)`20`7B`09`09/*`20even`20 Vnumber`20of`20lines`20*/ X`20`20`20`20`20`20`20`20double_up`20=`201; X X`20`20`20`20`20`20`20`20for`20(y`20=`20y_min;`20y`20<`20y_max;`20y`20+=`202) V`20`7B X`20`20`20`20`20`20`20`20`20`20int`20x; X X`20`20`20`20`20`20`20`20`20`20for`20(x`20=`20x_min;`20x`20<=`20x_max;`20x++) V`20`7B X`20`20`20`20`20`20`20`20`20`20`20`20if`20(srp`5By`5D.x_line`5Bx0+x`5D`20!=`20s Vrp`5By+1`5D.x_line`5Bx0+x`5D)`20`7B X`20`20`20`20`20`20`20`20`20`20`20`20`20`20double_up`20=`200; X`20`20`20`20`20`20`20`20`20`20`20`20`20`20goto`20break_double_up;`09/*`20never V`20apologise,`20never`20explain`20*/ X`20`20`20`20`20`20`20`20`20`20`20`20`7D X`20`20`20`20`20`20`20`20`20`20`7D X`20`20`20`20`20`20`20`20`7D X`20`20`20`20`20`20`7D X`20`20`20`20break_double_up: X#endif X X/* X`20*`20Insert`20each`20byte`20in`20the`20block`20into`20a`20linear`20buffer, V`20for`20more`20analysis. X`20*`20We`20restore`20any`20bitwise`20inversion`20first. X`20*/ X`20`20`20`20`20`20for`20(y`20=`20y_min;`20y`20<=`20y_max;`20y`20+=`20(1`20+`20 Vdouble_up))`20`7B X`20`20`20`20`20`20`20`20int`20x; X X`20`20`20`20`20`20`20`20for`20(x`20=`20x_min;`20x`20<=`20x_max;`20x++)`20`7B X`20`20`20`20`20`20`20`20`20`20*psp++`20=`20srp`5By`5D.x_line`5Bx0+x`5D; X`20`20`20`20`20`20`20`20`7D X`20`20`20`20`20`20`7D X X/* X`20*`20Call`20routine`20which`20will`20optimise`20buffer`20and`20return`20new V`20length. X`20*/ X`20`20`20`20`20`20ps_string_size`20=`20optimise_buffer(ps_string,`20psp`20-`20 Vps_string); X X/* X`20*`20Encode`20each`20byte`20in`20turn`20to`20form`20the`20string.`20`20A`20f Vew`20bytes`20must`20be`20escaped X`20*`20`20into`20octal`20to`20make`20it`20across`20a`20serial`20line;`20here, V`20we`20assume`20that`20the X`20*`20`20file`20will`20be`20printed`20using`20Digital's`20DCPS$SMB`20symbiont V`20across`20a`20serial X`20*`20`20line`20set`20up`20by`20the`20DCPS`20default`20command`20files,`20wit Vh`20Pasthru`20and`20Eightbit. X`20*`20You`20may`20need`20different`20escapes,`20depending`20on`20your`20conne Vction. X`20*/ X`20`20`20`20`20`20if`20(ps_string_size`20>`200)`20`7B X`20`20`20`20`20`20`20`20int`20psi; X X`20`20`20`20`20`20`20`20*olp++`20=`20'`7B';`09`09`09`09/*`20start`20procedure V`20*/ X`20`20`20`20`20`20`20`20*olp++`20=`20'(';`09`09`09`09/*`20start`20string`20*/ V X X`20`20`20`20`20`20`20`20for`20(psi`20=`200;`20psi`20<`20ps_string_size;`20psi+ V+)`20`7B X`20`20`20`20`20`20`20`20`20`20unsigned`20char`20c`20=`20ps_string`5Bpsi`5D; X X`20`20`20`20`20`20`20`20`20`20switch`20(c)`20`7B X`20`20`20`20`20`20`20`20`20`20`20`20case`203:`20case`204: X`20`20`20`20`20`20`20`20`20`20`20`20case`2017:`20case`2019:`20case`2020:`20`7B V`09/*`20need`20octal`20conversion`20*/ X`20`20`20`20`20`20`20`20`20`20`20`20`20`20*olp++`20=`20'`5C`5C'; X`20`20`20`20`20`20`20`20`20`20`20`20`20`20*olp++`20=`20(c`20>>`206)`20+`20'0'; V X`20`20`20`20`20`20`20`20`20`20`20`20`20`20*olp++`20=`20((c`20>>`203)`20`26`207 V)`20+`20'0'; X`20`20`20`20`20`20`20`20`20`20`20`20`20`20*olp++`20=`20(c`20`26`207)`20+`20'0' V; X`20`20`20`20`20`20`20`20`20`20`20`20`20`20break; X`20`20`20`20`20`20`20`20`20`20`20`20`7D X X`20`20`20`20`20`20`20`20`20`20`20`20case`20'`5C`5C':`20case`20'(':`20case`20') V':`20`7B X`20`20`20`20`20`20`20`20`20`20`20`20`20`20*olp++`20=`20'`5C`5C'; X`20`20`20`20`20`20`20`20`20`20`20`20`20`20*olp++`20=`20c; X`20`20`20`20`20`20`20`20`20`20`20`20`20`20break; X`20`20`20`20`20`20`20`20`20`20`20`20`7D X X`20`20`20`20`20`20`20`20`20`20`20`20case`20'`5Cn':`20`7B X`20`20`20`20`20`20`20`20`20`20`20`20`20`20*olp++`20=`20'`5C`5C'; X`20`20`20`20`20`20`20`20`20`20`20`20`20`20*olp++`20=`20'n'; X`20`20`20`20`20`20`20`20`20`20`20`20`20`20break; X`20`20`20`20`20`20`20`20`20`20`20`20`7D X X`20`20`20`20`20`20`20`20`20`20`20`20case`20'`5Cr':`20`7B X`20`20`20`20`20`20`20`20`20`20`20`20`20`20*olp++`20=`20'`5C`5C'; X`20`20`20`20`20`20`20`20`20`20`20`20`20`20*olp++`20=`20'r'; X`20`20`20`20`20`20`20`20`20`20`20`20`20`20break; X`20`20`20`20`20`20`20`20`20`20`20`20`7D X X`20`20`20`20`20`20`20`20`20`20`20`20default:`20`7B X`20`20`20`20`20`20`20`20`20`20`20`20`20`20*olp++`20=`20c; X`20`20`20`20`20`20`20`20`20`20`20`20`20`20break; X`20`20`20`20`20`20`20`20`20`20`20`20`7D X`20`20`20`20`20`20`20`20`20`20`7D X`20`20`20`20`20`20`20`20`7D X X`20`20`20`20`20`20`20`20*olp++`20=`20')';`09`09`09`09/*`20end`20string`20*/ X`20`20`20`20`20`20`20`20*olp++`20=`20'`7D';`09`09`09`09/*`20end`20procedure`20 V*/ X`20`20`20`20`20`20`20`20fwrite(out_line,`20olp`20-`20out_line,`201,`20fp); X X`20`20`20`20`20`20`20`20fprint_double(fp,`20x_pos); X`20`20`20`20`20`20`20`20fprint_double(fp,`20y_pos); X X/* X`20*`20We`20could`20make`20the`20next`20check`20quite`20complex`20and`20optimi Vse`20further,`20for`20example X`20*`20`20by`20seeing`20if`20the`20X`20bit`20count`20matches`20the`20Y`20maxim Vum,`20defining`20other X`20*`20`20single-byte`20variables,`20etc;`20but`20the`20gains`20are`20unlikely V`20to`20be`20great. X`20*/ X`20`20`20`20`20`20`20`20fprintf(fp,`20(x_bits`20==`20x_sample_bits)`20?`20"i V`20"`20:`20"%d`20",`20x_bits); X`20`20`20`20`20`20`20`20fprintf(fp,`20(`20`20`20(y_bits`20==`20y_sample_bits) V X`20`20`20`20`20`20`20`20`20`20`20`20`20`20`20`20`20`20`20`20`20`20?`20(double_ Vup)`20?`20"k`20"`20:`20"j`20" X`20`20`20`20`20`20`20`20`20`20`20`20`20`20`20`20`20`20`20`20`20`20:`20"%d`20" V X`20`20`20`20`20`20`20`20`20`20`20`20`20`20`20`20`20`20`20`20),`20(double_up) V`20?`20y_bits/2`20:`20y_bits X`20`20`20`20`20`20`20`20`20`20`20`20`20`20`20); X X`20`20`20`20`20`20`20`20fprintf(fp,`20"%c`5Cn",`20(double_up)`20?`20'b'`20:`20 V'a'); X`20`20`20`20`20`20`7D X`20`20`20`20`7D X`20`20`7D X`7D X X/* X`20*`20Routine`20to`20do`20most`20of`20the`20work`20processing`20an`20image`20 Vfile. X`20*/ Xstatic Xvoid Xprocess_file`20(char`20*input_file,`20char`20*output_file) X`7B X`20`20FILE`20*ifp; X`20`20FILE`20*ofp; X`20`20unsigned`20char`20input_line`20`5B512`5D;`09/*`20input`20text`20line`20* V/ X`20`20int`20in_image;`09`09`09/*`20flag`20to`20say`20if`20we're`20in`20an`20im Vage`20*/ X`20`20int`20hex_records; X`20`20int`20i; X`20`20int`20need_header`20=`201; X X`20`20unsigned`20char`20dehex`20`5B128`5D`20=`20`7B`09`09/*`20hex`20digit`20to V`20binary`20conversion`20*/ X`20`20`20`200xff,`200xff,`200xff,`200xff,`200xff,`200xff,`200xff,`200xff, X`20`20`20`200xff,`200xff,`200xff,`200xff,`200xff,`200xff,`200xff,`200xff, X`20`20`20`200xff,`200xff,`200xff,`200xff,`200xff,`200xff,`200xff,`200xff, X`20`20`20`200xff,`200xff,`200xff,`200xff,`200xff,`200xff,`200xff,`200xff, X`20`20`20`200xff,`200xff,`200xff,`200xff,`200xff,`200xff,`200xff,`200xff, X`20`20`20`200xff,`200xff,`200xff,`200xff,`200xff,`200xff,`200xff,`200xff, X`20`20`20`200x00,`200x01,`200x02,`200x03,`200x04,`200x05,`200x06,`200x07, X`20`20`20`200x08,`200x09,`200xff,`200xff,`200xff,`200xff,`200xff,`200xff, X`20`20`20`200xff,`200x0a,`200x0b,`200x0c,`200x0d,`200x0e,`200x0f,`200xff, X`20`20`20`200xff,`200xff,`200xff,`200xff,`200xff,`200xff,`200xff,`200xff, X`20`20`20`200xff,`200xff,`200xff,`200xff,`200xff,`200xff,`200xff,`200xff, X`20`20`20`200xff,`200xff,`200xff,`200xff,`200xff,`200xff,`200xff,`200xff, X`20`20`20`200xff,`200x0a,`200x0b,`200x0c,`200x0d,`200x0e,`200x0f,`200xff, X`20`20`20`200xff,`200xff,`200xff,`200xff,`200xff,`200xff,`200xff,`200xff, X`20`20`20`200xff,`200xff,`200xff,`200xff,`200xff,`200xff,`200xff,`200xff, X`20`20`20`200xff,`200xff,`200xff,`200xff,`200xff,`200xff,`200xff,`200xff X`20`20`7D; X X`20`20if`20(*input_file)`20`7B X`20`20`20`20if`20((ifp`20=`20fopen(input_file,`20"r"))`20==`20NULL)`20`7B X`20`20`20`20`20`20fprintf(stderr,`20"Unable`20to`20open`20input`20file`20'%s' V`5Cn",`20input_file); X`20`20`20`20`20`20exit(ERROR); X`20`20`20`20`7D X`20`20`7D X`20`20else`20`7B X`20`20`20`20ifp`20=`20stdin; X`20`20`7D X X`20`20in_image`20=`200; X`20`20while`20(fgets(input_line,`20sizeof(input_line),`20ifp)`20!=`20NULL)`20 V`7B X`20`20`20`20SCAN_REC`20scan_recs`20`5BMAX_Y_SAMPLE_BITS`5D; X`20`20`20`20int`20x_top; X`20`20`20`20int`20y_top; X`20`20`20`20unsigned`20char`20hexbyte;`09/*`20hex`20byte`20read`20from`20file V`20*/ X`20`20`20`20int`20nibble_valid;`09`09/*`20nibble`20left`20over`20from`20previo Vus`20line`20*/ X`20`20`20`20int`20byteno;`09`09`09/*`20offset`20in`20record`20*/ X X`20`20`20`20input_line`5Bstrlen(input_line)`20-`201`5D`20=`20'`5C0';`09/*`20st Vrip`20newline`20*/ X X/* X`20*`20Look`20for`20translation`20matrix. X`20*`20DDIF`20translator`20puts`20this`20at`20the`20start`20of`20a`20line. X`20*`20Hack:`20Halve`20y_points`20for`20this`20page`20if`20y_top`20is`20above V`20threshold. X`20*/ X`20`20`20`20if`20(sscanf(input_line,`20"`5B%d`20%*d`20%*d`20%*d`20%*d`20%d`5D" V,`20`26x_top,`20`26y_top)`20==`202)`20`7B X`20`20`20`20`20`20file_record_size`20=`20(x_top`20*`20file_bits)`20/`20BITS_PE VR_BYTE; X`20`20`20`20`20`20y_points_hack`20=`20y_points`20/`20((y_top`20>=`20y_hack)`20 V+`201); X`20`20`20`20`7D X`20`20`20`20else`20if`20(sscanf(input_line,`20"%*d`20%*d`20%d",`20`26file_bits V)`20==`201)`20`7B X`20`20`20`20`20`20if`20(`20`20`20`20(file_bits`20!=`201) X`20`20`20`20`20`20`20`20`20`20`20`26`26`20(file_bits`20!=`202) X`20`20`20`20`20`20`20`20`20`20`20`26`26`20(file_bits`20!=`204) X`20`20`20`20`20`20`20`20`20`20`20`26`26`20(file_bits`20!=`208) X`20`20`20`20`20`20`20`20`20)`20`7B X`20`20`20`20`20`20`20`20file_bits`20=`200;`09`09/*`20ignore`20invalid`20bits-p Ver-sample`20values`20*/ X`20`20`20`20`20`20`7D X`20`20`20`20`7D X/* X`20*`20Look`20for`20image`20command. X`20*`20DDIF`20translator`20puts`20this`20on`20a`20line`20of`20its`20own,`20jus Vt`20before`20the`20hex`20data. X`20*/ X`20`20`20`20else`20if`20(!`20strcmp(input_line,`20"image"))`20`7B X`20`20`20`20`20`20if`20(file_record_size`20==`200)`20`7B X`20`20`20`20`20`20`20`20fprintf(stderr,`20"Image`20data`20starting,`20but`20re Vcord`20size`20not`20seen`5Cn"); X`20`20`20`20`20`20`20`20exit(ERROR); X`20`20`20`20`20`20`7D X X`20`20`20`20`20`20if`20(file_bits`20==`200)`20`7B X`20`20`20`20`20`20`20`20fprintf(stderr,`20"Image`20data`20starting,`20but`20bi Vts`20per`20sample`20not`20seen`5Cn"); X`20`20`20`20`20`20`20`20exit(ERROR); X`20`20`20`20`20`20`7D X X`20`20`20`20`20`20bits_per_sample`20=`20(only_one_bit`20?`201`20:`20file_bits) V; X`20`20`20`20`20`20in_image`20=`201;`09`09/*`20image`20data`20starts`20now`20*/ V X`20`20`20`20`20`20hex_records`20=`200;`09`09/*`20no`20records`20seen`20so`20fa Vr`20*/ X`20`20`20`20`20`20nibble_valid`20=`200;`09`09/*`20no`20half-byte`20left`20over V`20*/ X`20`20`20`20`20`20byteno`20=`200;`09`09/*`20offset`20in`20X`20scan`20record`20 V*/ X X`20`20`20`20`20`20if`20(need_header)`20`7B`09/*`20haven't`20output`20header`20 Vyet`20(first`20image)`20*/ X`20`20`20`20`20`20`20`20if`20(*output_file)`20`7B X`20`20`20`20`20`20`20`20`20`20if`20((ofp`20=`20fopen(output_file,`20"w"))`20== V`20NULL)`20`7B X`20`20`20`20`20`20`20`20`20`20`20`20fprintf(stderr,`20"Unable`20to`20open`20ou Vtput`20file`20'%s'`5Cn",`20output_file); X`20`20`20`20`20`20`20`20`20`20`20`20exit(ERROR); X`20`20`20`20`20`20`20`20`20`20`7D X`20`20`20`20`20`20`20`20`7D X`20`20`20`20`20`20`20`20else`20`7B X`20`20`20`20`20`20`20`20`20`20ofp`20=`20stdout; X`20`20`20`20`20`20`20`20`7D X X`20`20`20`20`20`20`20`20fprintf(ofp,`20"%%!`5Cn");`09`09`09/*`20identify`20PS V`20file`20*/ X`20`20`20`20`20`20`20`20fprintf(ofp,`20"32`20dict`20begin`5Cn"); X`20`20`20`20`20`20`20`20fprintf(ofp,`20"/d`20`7Bdef`7D`20def`5Cn"); X X/* X`20*`20Define`20image`20handlers:`20A`20is`20for`20single-height`20pixels,`20B V`20for`20double-height. X`20*/ X#if`20DOUBLE_UP X`20`20`20`20`20`20`20`20for`20(i`20=`201;`20i`20<=`202;`20i++) X#else X`20`20`20`20`20`20`20`20i`20=`201; X#endif X`20`20`20`20`20`20`20`20`7B X`20`20`20`20`20`20`20`20`20`20fprintf(ofp,`20"/%c`20`7B`20",`20'`60'`20+`20i); V`09/*`20a`20or`20b`20*/ X`20`20`20`20`20`20`20`20`20`20fprintf(ofp,`20"/y`20exch`20def`20");`09`09/*`20 VY`20pixels`20from`20stack`20*/ X`20`20`20`20`20`20`20`20`20`20fprintf(ofp,`20"/x`20exch`20def`20");`09`09/*`20 VX`20pixels`20from`20stack`20*/ X`20`20`20`20`20`20`20`20`20`20fprintf(ofp,`20"initmatrix`20");`09`09/*`20reset V`20coordinates`20*/ X`20`20`20`20`20`20`20`20`20`20fprintf(ofp,`20"translate`20");`09`09/*`20X`20an Vd`20Y`20offset`20from`20stack`20*/ X`20`20`20`20`20`20`20`20`20`20fprintf(ofp,`20"x`20%.5f`20mul`20",`20x_points); V`09/*`20X`20size`20*/ X`20`20`20`20`20`20`20`20`20`20fprintf(ofp,`20"y`20%.5f`20mul`20",`20y_points_h Vack`20*`20i);`09/*`20Y`20size`20*/ X`20`20`20`20`20`20`20`20`20`20fprintf(ofp,`20"scale`20");`09`09/*`20scale`20up V`20*/ X`20`20`20`20`20`20`20`20`20`20fprintf(ofp,`20"x`20y`20s`20");`09/*`20first`203 V`20parameters`20for`20image`20*/ X`20`20`20`20`20`20`20`20`20`20fprintf(ofp,`20"`5Bx`200`200`200`20y`20sub`200 V`20y`5D`20");`09/*`20transform`20matrix`20(with`20-Y)`20*/ X`20`20`20`20`20`20`20`20`20`20fprintf(ofp,`20"5`20-1`20roll`20");`09`09/*`20im Vage`20proc`20is`20on`20stack`20*/ X`20`20`20`20`20`20`20`20`20`20fprintf(ofp,`20"image");`09`09/*`20build`20the V`20image`20*/ X`20`20`20`20`20`20`20`20`20`20fprintf(ofp,`20"`7D`20def`5Cn");`09`09/*`20defin Ve`20image`20handler`20*/ X`20`20`20`20`20`20`20`20`7D X X`20`20`20`20`20`20`20`20need_header`20=`200; X`20`20`20`20`20`20`7D X X/* X`20*`20Save`20VM`20context. X`20*/ X`20`20`20`20`20`20fprintf(ofp,`20"/snapshot`20save`20def`20"); X X/* X`20*`20If`20required,`20initalise`20transfer`20mode`20(black`20on`20white). X`20*/ X`20`20`20`20`20`20if`20(white`20==`200)`20`7B X`20`20`20`20`20`20`20`20fprintf(ofp,`20"`7B1`20exch`20sub`7D`20settransfer`20" V); X`20`20`20`20`20`20`7D X X/* X`20*`20Define`20shorthand`20for`20X`20and`20Y`20maximum`20values,`20and`20bits V`20per`20sample. X`20*/ X`20`20`20`20`20`20fprintf(ofp,`20"/i`20%d`20d`20/j`20%d`20d`20/s`20%d`20d", X`20`20`20`20`20`20`20`20`20`20`20`20`20`20`20`20`20`20`20x_sample_bits,`20y_sa Vmple_bits,`20bits_per_sample); X#if`20DOUBLE_UP X`20`20`20`20`20`20fprintf(ofp,`20"`20/k`20%d`20d",`20y_sample_bits`20/`202); X#endif X`20`20`20`20`20`20fprintf(ofp,`20"`5Cn"); X`20`20`20`20`7D X/* X`20*`20Look`20for`20line`20which`20DDIF`20translator`20uses`20to`20indicate`20 Vthe`20end`20of`20the`20image. X`20*/ X`20`20`20`20else`20if`20(!`20strcmp(input_line,`20"saveobj`20restore"))`20`7B V X`20`20`20`20`20`20in_image`20=`200;`09`09`09`09/*`20finished`20hex`20data`20*/ V X X`20`20`20`20`20`20if`20((hex_records`20%`20y_sample_bits)`20!=`200)`20`7B`09/* V`20some`20records`20left`20*/ X`20`20`20`20`20`20`20`20output_records(ofp,`20scan_recs,`20hex_records`20%`20y V_sample_bits,`200); X`20`20`20`20`20`20`7D X X`20`20`20`20`20`20file_bits`20=`200;`09`09`09`09/*`20required`20for`20next`20t Vime`20*/ X`20`20`20`20`20`20fprintf(ofp,`20"snapshot`20restore`20showpage`5Cn");`09/*`20 Voutput`20the`20page`20*/ X`20`20`20`20`7D X`20`20`20`20else`20if`20(in_image)`20`7B`09`09`09/*`20line`20of`20hex`20data V`20*/ X`20`20`20`20`20`20int`20max`20=`20strlen(input_line); X`20`20`20`20`20`20unsigned`20char`20*record`20=`20scan_recs`5Bhex_records`20% V`20y_sample_bits`5D.x_line; X X`20`20`20`20`20`20for`20(i`20=`200;`20i`20<`20max;`20i++)`20`7B X`20`20`20`20`20`20`20`20unsigned`20char`20nibble`20=`20dehex`5Binput_line`5Bi V`5D`5D; X X`20`20`20`20`20`20`20`20if`20(nibble`20==`200xff)`20`7B`09`09/*`20non-hax`20ch Varacter`20*/ X`20`20`20`20`20`20`20`20`20`20continue; X`20`20`20`20`20`20`20`20`7D X X`20`20`20`20`20`20`20`20if`20(nibble_valid)`20`7B`09`09/*`20this`20is`20second V`20nibble`20*/ X`20`20`20`20`20`20`20`20`20`20record`5Bbyteno++`5D`20=`20hexbyte`20+`20nibble; V`09/*`20complete`20byte`20*/ X`20`20`20`20`20`20`20`20`20`20nibble_valid`20=`200; X`20`20`20`20`20`20`20`20`7D X`20`20`20`20`20`20`20`20else`20`7B`09`09`09`09/*`20this`20is`20first`20nibble V`20*/ X`20`20`20`20`20`20`20`20`20`20hexbyte`20=`20nibble`20<<`204;`09/*`20partial`20 Vbyte`20(high-order`20nibble)`20*/ X`20`20`20`20`20`20`20`20`20`20nibble_valid`20=`201; X`20`20`20`20`20`20`20`20`7D X`20`20`20`20`20`20`7D X X`20`20`20`20`20`20if`20(byteno`20>=`20file_record_size)`20`7B`09`09`09/*`20ful Vl`20record`20*/ X`20`20`20`20`20`20`20`20++hex_records; X`20`20`20`20`20`20`20`20byteno`20=`200; X X`20`20`20`20`20`20`20`20if`20((hex_records`20%`20y_sample_bits)`20==`200)`20 V`7B`09/*`20enough`20records`20*/ X`20`20`20`20`20`20`20`20`20`20output_records(ofp,`20scan_recs,`20y_sample_bits V,`20y_top`20-`20hex_records); X`20`20`20`20`20`20`20`20`7D X`20`20`20`20`20`20`7D X`20`20`20`20`7D X`20`20`7D X X`20`20if`20(!`20need_header)`20`7B X`20`20`20`20fprintf(ofp,`20"end`5Cn");`09`09/*`20finished`20with`20dict`20*/ X`20`20`7D X X`20`20fclose(ifp); X`20`20fclose(ofp); X`7D X Xstatic Xvoid Xusage`20(void) X`7B X`20`20fprintf(stderr,`20"Usage:`20SQUEEZE"); X`20`20fprintf(stderr,`20"`20`5B-b`5D`20`5B-g`5D`20`5B-hyN`5D`20`5B-mxM`5D`20 V`5B-myM`5D"); X`20`20fprintf(stderr,`20"`20`5B-rxD`5D`20`5B-ryD`5D`20`5B-sxN`5D`20`5B-syN`5D" V); X`20`20fprintf(stderr,`20"`20`5Binfile`20`5Boutfile`5D`5D`5Cn"); X X`20`20fprintf(stderr,`20"-b:`200`20bit`20indicates`20black`20(default`20is`20w Vhite)`5Cn"); X X`20`20fprintf(stderr,`20"-g:`20use`20only`201`20bit`20per`20sample`5Cn"); X X`20`20fprintf(stderr,`20"-hyN:`20Y`20hack`20threshold`20=`20N`20bits`5Cn"); X`20`20fprintf(stderr,`20"`20(if`20image`20exceeds`20threshold,`20resolution`20 Vis`20halved)`5Cn"); X X`20`20fprintf(stderr,`20"-mxM:`20X`20margin`20=`20M`20PostScript`20units`20(72 V`20per`20inch)"); X`20`20fprintf(stderr,`20"`20(min`200,`20max`20%d)`5Cn",`20MAX_X_MARGIN); X`20`20fprintf(stderr,`20"-myM:`20Y`20margin`20=`20M`20PostScript`20units`20(72 V`20per`20inch)"); X`20`20fprintf(stderr,`20"`20(min`200,`20max`20%d)`5Cn",`20MAX_Y_MARGIN); X X`20`20fprintf(stderr,`20"-rxN:`20X`20resolution`20=`20D`20dots`20per`20inch"); V X`20`20fprintf(stderr,`20"`20(min`20%.1f,`20max`20%.1f)`5Cn",`20MIN_X_RES,`20MA VX_X_RES); X`20`20fprintf(stderr,`20"-ryN:`20Y`20resolution`20=`20D`20dots`20per`20inch"); V X`20`20fprintf(stderr,`20"`20(min`20%.1f,`20max`20%.1f)`5Cn",`20MIN_Y_RES,`20MA VX_Y_RES); X X`20`20fprintf(stderr,`20"-sxN:`20X`20sample`20size`20=`20N`20bits"); X`20`20fprintf(stderr,`20"`20(multiple`20of`20%d,`20max`20%d)`5Cn", X`20`20`20`20`20`20`20`20`20`20`20`20`20`20`20`20`20`20BITS_PER_BYTE,`20MAX_X_S VAMPLE_BYTES`20*`20BITS_PER_BYTE X`20`20`20`20`20`20`20`20`20); X`20`20fprintf(stderr,`20"-syN:`20Y`20sample`20size`20=`20N`20bits"); X`20`20fprintf(stderr,`20"`20("); X#if`20DOUBLE_UP X`20`20fprintf(stderr,`20"multiple`20of`202,`20"); X#endif X`20`20fprintf(stderr,`20"max`20%d)`5Cn",`20MAX_Y_SAMPLE_BITS); X X`20`20exit(ERROR); X`7D X Xmain`20(int`20argc,`20char`20*argv`5B`5D) X`7B X`20`20int`20i; X`20`20int`20n_parm`20=`200; X`20`20char`20input_file`20`5B255`5D`20=`20""; X`20`20char`20output_file`20`5B255`5D`20=`20""; X X`20`20for`20(i`20=`201;`20i`20<`20argc;`20i++)`20`7B X`20`20`20`20char`20*argp; X X`20`20`20`20if`20((argp`20=`20argv`5Bi`5D)`5B0`5D`20==`20'-')`20`7B X`20`20`20`20`20`20switch`20(*++argp)`20`7B X`20`20`20`20`20`20`20`20case`20'B':`20case`20'b':`20`7B X`20`20`20`20`20`20`20`20`20`20if`20(*++argp)`20`7B X`20`20`20`20`20`20`20`20`20`20`20`20usage(); X`20`20`20`20`20`20`20`20`20`20`7D X X`20`20`20`20`20`20`20`20`20`20white`20=`200xff; X`20`20`20`20`20`20`20`20`20`20break; X`20`20`20`20`20`20`20`20`7D X X`20`20`20`20`20`20`20`20case`20'G':`20case`20'g':`20`7B X`20`20`20`20`20`20`20`20`20`20if`20(*++argp)`20`7B X`20`20`20`20`20`20`20`20`20`20`20`20usage(); X`20`20`20`20`20`20`20`20`20`20`7D X X`20`20`20`20`20`20`20`20`20`20only_one_bit`20=`201; X`20`20`20`20`20`20`20`20`20`20break; X`20`20`20`20`20`20`20`20`7D X X`20`20`20`20`20`20`20`20case`20'H':`20case`20'h':`20`7B X`20`20`20`20`20`20`20`20`20`20switch`20(*++argp)`20`7B X`20`20`20`20`20`20`20`20`20`20`20`20case`20'Y':`20case`20'y':`20`7B X`20`20`20`20`20`20`20`20`20`20`20`20`20`20if`20(`20`20`20`20(sscanf(++argp,`20 V"%d",`20`26y_hack)`20!=`201) X`20`20`20`20`20`20`20`20`20`20`20`20`20`20`20`20`20`20`20`7C`7C`20(y_hack`20< V`200) X`20`20`20`20`20`20`20`20`20`20`20`20`20`20`20`20`20)`20`7B X`20`20`20`20`20`20`20`20`20`20`20`20`20`20`20`20usage(); X`20`20`20`20`20`20`20`20`20`20`20`20`20`20`7D X X`20`20`20`20`20`20`20`20`20`20`20`20`20`20break; X`20`20`20`20`20`20`20`20`20`20`20`20`7D X X`20`20`20`20`20`20`20`20`20`20`20`20default:`20`7B X`20`20`20`20`20`20`20`20`20`20`20`20`20`20usage(); X`20`20`20`20`20`20`20`20`20`20`20`20`20`20break; X`20`20`20`20`20`20`20`20`20`20`20`20`7D X`20`20`20`20`20`20`20`20`20`20`7D X X`20`20`20`20`20`20`20`20`20`20break; X`20`20`20`20`20`20`20`20`7D X X`20`20`20`20`20`20`20`20case`20'M':`20case`20'm':`20`7B X`20`20`20`20`20`20`20`20`20`20switch`20(*++argp)`20`7B X`20`20`20`20`20`20`20`20`20`20`20`20case`20'X':`20case`20'x':`20`7B X`20`20`20`20`20`20`20`20`20`20`20`20`20`20if`20(`20`20`20`20(sscanf(++argp,`20 V"%d",`20`26x_margin)`20!=`201) X`20`20`20`20`20`20`20`20`20`20`20`20`20`20`20`20`20`20`20`7C`7C`20(x_margin`20 V>`20MAX_X_MARGIN) X`20`20`20`20`20`20`20`20`20`20`20`20`20`20`20`20`20`20`20`7C`7C`20(x_margin`20 V<`200) X`20`20`20`20`20`20`20`20`20`20`20`20`20`20`20`20`20)`20`7B X`20`20`20`20`20`20`20`20`20`20`20`20`20`20`20`20usage(); X`20`20`20`20`20`20`20`20`20`20`20`20`20`20`7D X X`20`20`20`20`20`20`20`20`20`20`20`20`20`20break; X`20`20`20`20`20`20`20`20`20`20`20`20`7D X X`20`20`20`20`20`20`20`20`20`20`20`20case`20'Y':`20case`20'y':`20`7B X`20`20`20`20`20`20`20`20`20`20`20`20`20`20if`20(`20`20`20`20(sscanf(++argp,`20 V"%d",`20`26y_margin)`20!=`201) X`20`20`20`20`20`20`20`20`20`20`20`20`20`20`20`20`20`20`20`7C`7C`20(y_margin`20 V>`20MAX_Y_MARGIN) X`20`20`20`20`20`20`20`20`20`20`20`20`20`20`20`20`20`20`20`7C`7C`20(y_margin`20 V<`200) X`20`20`20`20`20`20`20`20`20`20`20`20`20`20`20`20`20)`20`7B X`20`20`20`20`20`20`20`20`20`20`20`20`20`20`20`20usage(); X`20`20`20`20`20`20`20`20`20`20`20`20`20`20`7D X X`20`20`20`20`20`20`20`20`20`20`20`20`20`20break; X`20`20`20`20`20`20`20`20`20`20`20`20`7D X X`20`20`20`20`20`20`20`20`20`20`20`20default:`20`7B X`20`20`20`20`20`20`20`20`20`20`20`20`20`20usage(); X`20`20`20`20`20`20`20`20`20`20`20`20`20`20break; X`20`20`20`20`20`20`20`20`20`20`20`20`7D X`20`20`20`20`20`20`20`20`20`20`7D X X`20`20`20`20`20`20`20`20`20`20break; X`20`20`20`20`20`20`20`20`7D X X`20`20`20`20`20`20`20`20case`20'R':`20case`20'r':`20`7B X`20`20`20`20`20`20`20`20`20`20switch`20(*++argp)`20`7B X`20`20`20`20`20`20`20`20`20`20`20`20case`20'X':`20case`20'x':`20`7B X`20`20`20`20`20`20`20`20`20`20`20`20`20`20if`20(`20`20`20`20(sscanf(++argp,`20 V"%f",`20`26x_res)`20!=`201) X`20`20`20`20`20`20`20`20`20`20`20`20`20`20`20`20`20`20`20`7C`7C`20(x_res`20> V`20MAX_X_RES) X`20`20`20`20`20`20`20`20`20`20`20`20`20`20`20`20`20`20`20`7C`7C`20(x_res`20< V`20MIN_X_RES) X`20`20`20`20`20`20`20`20`20`20`20`20`20`20`20`20`20)`20`7B X`20`20`20`20`20`20`20`20`20`20`20`20`20`20`20`20usage(); X`20`20`20`20`20`20`20`20`20`20`20`20`20`20`7D X X`20`20`20`20`20`20`20`20`20`20`20`20`20`20break; X`20`20`20`20`20`20`20`20`20`20`20`20`7D X X`20`20`20`20`20`20`20`20`20`20`20`20case`20'Y':`20case`20'y':`20`7B X`20`20`20`20`20`20`20`20`20`20`20`20`20`20if`20(`20`20`20`20(sscanf(++argp,`20 V"%f",`20`26y_res)`20!=`201) X`20`20`20`20`20`20`20`20`20`20`20`20`20`20`20`20`20`20`20`7C`7C`20(y_res`20> V`20MAX_Y_RES) X`20`20`20`20`20`20`20`20`20`20`20`20`20`20`20`20`20`20`20`7C`7C`20(y_res`20< V`20MIN_Y_RES) X`20`20`20`20`20`20`20`20`20`20`20`20`20`20`20`20`20)`20`7B X`20`20`20`20`20`20`20`20`20`20`20`20`20`20`20`20usage(); X`20`20`20`20`20`20`20`20`20`20`20`20`20`20`7D X X`20`20`20`20`20`20`20`20`20`20`20`20`20`20break; X`20`20`20`20`20`20`20`20`20`20`20`20`7D X X`20`20`20`20`20`20`20`20`20`20`20`20default:`20`7B X`20`20`20`20`20`20`20`20`20`20`20`20`20`20usage(); X`20`20`20`20`20`20`20`20`20`20`20`20`20`20break; X`20`20`20`20`20`20`20`20`20`20`20`20`7D X`20`20`20`20`20`20`20`20`20`20`7D X X`20`20`20`20`20`20`20`20`20`20break; X`20`20`20`20`20`20`20`20`7D X X`20`20`20`20`20`20`20`20case`20'S':`20case`20's':`20`7B X`20`20`20`20`20`20`20`20`20`20switch`20(*++argp)`20`7B X`20`20`20`20`20`20`20`20`20`20`20`20case`20'X':`20case`20'x':`20`7B X`20`20`20`20`20`20`20`20`20`20`20`20`20`20if`20(`20`20`20`20(sscanf(++argp,`20 V"%d",`20`26x_sample_bits)`20!=`201) X`20`20`20`20`20`20`20`20`20`20`20`20`20`20`20`20`20`20`20`7C`7C`20((x_sample_b Vits`20%`20BITS_PER_BYTE)`20!=`200) X`20`20`20`20`20`20`20`20`20`20`20`20`20`20`20`20`20`20`20`7C`7C`20(x_sample_bi Vts`20>`20(MAX_X_SAMPLE_BYTES`20*`20BITS_PER_BYTE)) X`20`20`20`20`20`20`20`20`20`20`20`20`20`20`20`20`20`20`20`7C`7C`20(x_sample_bi Vts`20<=`200) X`20`20`20`20`20`20`20`20`20`20`20`20`20`20`20`20`20)`20`7B X`20`20`20`20`20`20`20`20`20`20`20`20`20`20`20`20usage(); X`20`20`20`20`20`20`20`20`20`20`20`20`20`20`7D X X`20`20`20`20`20`20`20`20`20`20`20`20`20`20x_sample_bytes`20=`20x_sample_bits V`20/`20BITS_PER_BYTE; X`20`20`20`20`20`20`20`20`20`20`20`20`20`20break; X`20`20`20`20`20`20`20`20`20`20`20`20`7D X X`20`20`20`20`20`20`20`20`20`20`20`20case`20'Y':`20case`20'y':`20`7B X`20`20`20`20`20`20`20`20`20`20`20`20`20`20if`20(`20`20`20`20(sscanf(++argp,`20 V"%d",`20`26y_sample_bits)`20!=`201) X`20`20`20`20`20`20`20`20`20`20`20`20`20`20`20`20`20`20`20`7C`7C`20(y_sample_bi Vts`20>`20MAX_Y_SAMPLE_BITS) X#if`20DOUBLE_UP X`20`20`20`20`20`20`20`20`20`20`20`20`20`20`20`20`20`20`20`7C`7C`20((y_sample_b Vits`20%`202)`20!=`200) X#endif X`20`20`20`20`20`20`20`20`20`20`20`20`20`20`20`20`20`20`20`7C`7C`20(y_sample_bi Vts`20<=`200) X`20`20`20`20`20`20`20`20`20`20`20`20`20`20`20`20`20)`20`7B X`20`20`20`20`20`20`20`20`20`20`20`20`20`20`20`20usage(); X`20`20`20`20`20`20`20`20`20`20`20`20`20`20`7D X X`20`20`20`20`20`20`20`20`20`20`20`20`20`20break; X`20`20`20`20`20`20`20`20`20`20`20`20`7D X X`20`20`20`20`20`20`20`20`20`20`20`20default:`20`7B X`20`20`20`20`20`20`20`20`20`20`20`20`20`20usage(); X`20`20`20`20`20`20`20`20`20`20`20`20`20`20break; X`20`20`20`20`20`20`20`20`20`20`20`20`7D X`20`20`20`20`20`20`20`20`20`20`7D X X`20`20`20`20`20`20`20`20`20`20break; X`20`20`20`20`20`20`20`20`7D X X`20`20`20`20`20`20`20`20default:`20`7B X`20`20`20`20`20`20`20`20`20`20usage(); X`20`20`20`20`20`20`20`20`20`20break; X`20`20`20`20`20`20`20`20`7D X`20`20`20`20`20`20`7D X`20`20`20`20`7D X`20`20`20`20else`20`7B X`20`20`20`20`20`20switch(n_parm++)`20`7B X`20`20`20`20`20`20`20`20case`200:`20`7B X`20`20`20`20`20`20`20`20`20`20strcpy(input_file,`20argv`5Bi`5D); X`20`20`20`20`20`20`20`20`20`20break; X`20`20`20`20`20`20`20`20`7D X X`20`20`20`20`20`20`20`20case`201:`20`7B X`20`20`20`20`20`20`20`20`20`20strcpy(output_file,`20argv`5Bi`5D); X`20`20`20`20`20`20`20`20`20`20break; X`20`20`20`20`20`20`20`20`7D X X`20`20`20`20`20`20`20`20default:`20`7B X`20`20`20`20`20`20`20`20`20`20break; X`20`20`20`20`20`20`20`20`7D X`20`20`20`20`20`20`7D X`20`20`20`20`7D X`20`20`7D X X`20`20if`20(n_parm`20>`202)`20`7B X`20`20`20`20usage(); X`20`20`7D X X`20`20x_points`20=`20(72.0`20/`20x_res); X`20`20y_points`20=`20(72.0`20/`20y_res); X X`20`20process_file(input_file,`20output_file); X`7D X $ call unpack SQUEEZ.DSJ;1 1275444428 "" 50 1 1 $ v=f$verify(v) $ exit