/* pps211.c asci to postscript konverter --------------------------------*/ /* control commands : _.PF._ page feed */ /* _.COURIER._ select courier font */ /* _.BIGFONT._ select double size font */ /* _.BOLD._ bold font */ /* _.NORM._ Restore normal font */ /* _.LINE._nn mm font size nn= width in points */ /* mm: up to x position */ /* Pascal to C: T. Kriegl, Erfurter Str 8, 8000 Muenchen 50, T 089/1411201*/ /*-----------------------------------------------------------------------*/ /* ASCII menu driven listing program that generates PostScript commands to the Apple LaserWriter. Allows selection of bold and normal fonts, font size and line spacing. Output can go to a disk file (output.ps) or directly to the printer. Limitations: Handling tabs is limited to move to an absolute location on the line. Program is not smart about the actual widths of characters in different fonts... it just uses an average width per character of fontsize/2. Epson font change escapes _.BOLD._ for bold and _.NORM._ for normal are used. Spacing for a tab is based on an average of 8 nominal characters... as a result the tab spacing after some text with capital letters may not be wide enough and the text starting after the tab may overlap with previous text. (On the other hand, the worst case width of 8 widest characters is too large for normal use). Can be invoked with filename as a parameter: nlist filename Free for non-commercial use only. (C) Copywrite Nate Liskov 27 Jan 1986 */ #include #define true 1 #define false 0 #define OFFSET 28 float round(), trunc(); FILE *fopen(); unsigned char DateTimeStr[27]; unsigned char *onoff[2] ={"On","Off"}; unsigned char msg[128]; unsigned char newline[256]; unsigned char null_ptr[2] = {0,0}; unsigned char i_str[255]; float xpos, ypos; int startofpiece, leadingblanks; char locatetext; int paramcount = 0; unsigned char **paramstr; int numberofcopies, linecount, n, m, page, linelength, entryline; int topspaces, bottomspaces, leftmargin, rightmargin, lm, rm ; int oldfont; unsigned char option; unsigned char *filename, filname[45]; unsigned char temp[256]; unsigned char right[80], left[80]; FILE *source, *sink; float linesize; int header, automatic, maxline; unsigned char input_str[80],*strng; char hellfreezesover,autoexit; unsigned char *datetimestr; float linesperpage,linespacing; int nfont,bfont,currentfont, nout,pagefeed,pagetype ; int cfont = 3; int fontsize, bigfontsize; int save_fontsize; char fontsused[37]; char formatsused[2]; unsigned char *pageformat[2] = { "Portrait ","Landscape"}; unsigned char *font[37] = {"Helvetica","Times-Roman","Courier", "Helvetica-Oblique","Times-Italic","Courier-Oblique", "Helvetica-Bold","Times-Bold","Courier-Bold", "Helvetica-BoldOblique","Times-BoldItalic", "Courier-BoldOblique","AvantGarde-Book", "AvantGarde-BookOblique","AvantGarde-Demi", "AvantGarde-DemiOblique","Bookman-Demi", "Bookman-DemiItalic","Bookman-Light", "Bookman-LightItalic","Helvetica-Narrow", "Helvetica-Narrow-Bold", "Helvetica-Narrow-Oblique", "Helvetica-Narrow-BoldOblique", "NewCenturySchlbk-Roman", "NewCenturySchlbk-Bold","NewCenturySchlbk-Italic", "NewCenturySchlbk-BoldItalic","Palatino-Roman", "Palatino-Bold","Palatino-Italic","Palatino-BoldItalic", "ZapfChancery-MediumItalic","Helvetica-Condensed", "Helvetica-Condensed-Bold", "Helvetica-Condensed-Oblique", "Helvetica-Condensed-BoldObl"}; float spacewidth[37] = {0.556,0.5,0.6,0.556,0.5,0.6, 0.556,0.5,0.6,0.556,0.5,0.6, 0.554,0.554,0.554,0.554,0.660,0.660,0.660,0.66, 0.456,0.456,0.456,0.456,0.556,0.556,0.556,0.556, 0.5,0.5,0.5,0.5,0.44,0.456,0.456,0.456,0.456}; /*spacewidth is width of space for courier, ;else spacewidth is twice width of space which is same as the width of a number character*/ unsigned char *outfile[2] = {"Printer","Disk File: Output.ps"}; unsigned char *upword(wrd) char *wrd; { int n; for( n = 0; n < strlen(wrd); n++ ){ wrd[n]=toupper(wrd[n]); } return (unsigned char *)wrd; } spaces(n,str) int n; unsigned char *str; { for( m = 0 ; m < n ; m++ ){ *str++ = ' '; } *str = 0; } setlinesize() { if( pagetype == 1 ) linesize = round(594.0/((float)fontsize*spacewidth[nfont-1])); else linesize = round(774.0/((float)fontsize*spacewidth[nfont-1])); if(!in(nfont,"\03\06\011\014")) linesize=round(linesize*1.04); /*fudge factor*/ } help() { printf(" PPS HELP"); printf; printf(" Command Line Parameters"); printf; printf(" ?, help help on command line parameters"); printf(" -0=10 sets fontsize to 10"); printf(" -1=13 sets line spacing to 13"); printf(" -2 pagefeed commands are in input file (default for .mem file)"); printf(" -3=25 normal font is font 25"); printf(" -4=13 bold font is font 13"); printf(" -5=2 suppress header line (default for .mem file)"); printf(" -6 output to printer vs output.ps"); printf(" -7=5 topspaces = 5"); printf(" -8=7 bottomspaces = 7"); printf(" -9 automatic margins"); printf(" -G go, ){ exit program"); printf(" -L=12 left margin is 12"); printf(" -N=7 normal font is font 7"); printf(" -P landscape page format"); printf(" -R=12 right margin is 12"); printf(" -foobar input file is foobar"); getchar(); /* exit(); */ } parameters() { int n,err; filename = null_ptr; for( n = 1; n < paramcount; n++ ){ strng = upword(paramstr[n]); if( (*strng == '?') || !strcmp(strng,"HELP" ) ) help(); if( pos("-0=",strng) != 0 ){ delete(strng,1,3); val(strng,fontsize,err); }; if( pos("-1=",strng) ==1 ){ delete(strng,1,3); val(strng,linespacing,err); }; if( pos("-3=",strng)==1 ){ delete(strng,1,3); val(strng,nfont,err); }; if( pos("-4=",strng)==1 ){ delete(strng,1,3); val(strng,bfont,err); } if( pos("-7=",strng)==1 ){ delete(strng,1,3); val(strng,topspaces,err); } if( pos("-8=",strng)==1 ){ delete(strng,1,3); val(strng,bottomspaces,err); } if( pos("-L=",strng)==1 ){ delete(strng,1,3); val(strng,leftmargin,err); /* if( err==0 ) spaces(leftmargin,left);*/ } if( pos("-R=",strng)==1 ){ delete(strng,1,3); val(strng,rightmargin,err); if( err==0 ) spaces(rightmargin, right); } if( pos("-N=",strng)==1 ){ delete(strng,1,3); val(strng,nfont,err); } if(!strcmp( strng,"-2") ) pagefeed=2; if(!strcmp( strng,"-5") ) header=2; if(!strcmp( strng,"-6") ) nout=1; if(!strcmp( strng,"-9") ) automatic=1; if(!strcmp( strng,"-P") ) pagetype=2; if(!strcmp( strng,"-G") ) autoexit=true; }/* for n...*/ for( n = 0; n < paramcount; n++ ){ strng = upword(paramstr[n]); if( pos("-",strng)!=1 ) filename = paramstr[n]; } iassign(&source,filename); strng = upword(filename); if( pos(".MEM",strng)!=0 ) { nout =2; pagefeed = 2; header = 2; } setlinesize(); if( pagetype == 1 ) linesperpage = 792 / linespacing; else linesperpage = 612 / linespacing; } unsigned char *datetime() { #ifdef NEVER TYPE monthname = ARRAY[1..12] OF unsigned char[3]; daynames = ARRAY[1..7] OF unsigned char[3]; CONST mon: monthname = ("Jan","Feb","Mar","Apr","May","Jun", "Jul","Aug","Sep","Oct","Nov","Dec"); days: daynames = ("Sun","Mon","Tue","Wed","Thu","Fri","Sat"); VAR year,month,day,dayofweek,hour,min,sec,sec100:word; str1:string[1]; daystr,hourstr,minstr,secstr:string[2]; yearstr:string[4]; { getdate(year,month,day,dayofweek); gettime(hour,min,sec,sec100); if( day>9 ){ str(day,daystr) ;else { str(day,str1); daystr=" "+str1;}; if( hour>9 ){ str(hour,hourstr) ;else { str(hour,str1); hourstr="0"+str1;}; if( min>9 ){ str(min,minstr) ;else { str(min,str1);minstr="0"+str1;}; if( sec>9 ){ str(sec,secstr) ;else { str(sec,str1);secstr="0"+str1;}; str(year,yearstr); datetime = days[1+dayofweek]+" "+daystr+" "+mon[month]+" "+yearstr +" "+hourstr+":"+minstr+":"+secstr; #endif return (unsigned char *) "Date"; } init() { autoexit=false; nfont = 2 ; /*default normal font is times_roman*/ currentfont = nfont; bfont = 8; /*default bold font is times-bold */ nout = 2; /*default output is to file*/ pagefeed = 1; /*default is to do page feed*/ pagetype = 1; /*default is portrait page format*/ fontsize = 12; save_fontsize = fontsize; bigfontsize = 2 * fontsize; linespacing = 12; setlinesize(); linesperpage = 792 / linespacing; header = 1; /*default is header line on*/ automatic = 2; /*default is zero margins*/ topspaces = 2; bottomspaces = 0; leftmargin = 0; rightmargin = 0; numberofcopies = 1; *right = 0; *left = 0; entryline = 23; filename = null_ptr; if( paramcount ){ parameters();} for( n=0; n < 37; n++ ){ fontsused[n]=false;} for( n=0; n < 2; n++ ){ formatsused[n]=false;} if( nout==2 ) assign(&sink,"output.ps"); else assign(&sink,"lpt1"); hellfreezesover = false; fprintf(sink,"%%!PS-Adobe-2.0 EPSF-1.2\n"); fprintf(sink,"%%%%BeginDocument: PPS ASCII-to-Postscript Conversion\n"); fprintf(sink,"%%%%Title: PPS generated file\n"); fprintf(sink,"%%%%Creator: PPS version 2.11\n"); fprintf(sink,"%%%%BoundingBox: (atend)\n"); fprintf(sink,"%%%%DocumentFonts: (atend)\n"); fprintf(sink,"%%%%CreationDate: %s\n",datetime()); fprintf(sink,"%%%%Pages: %d\n",numberofcopies); fprintf(sink,"%%%%EndComments\n"); fprintf(sink,"%%%%EndProlog\n"); fprintf(sink,"%%Copywrite 1988 (C) by Nathan Liskov. All Rights Reserved\n"); } optionline() { printf(" Enter Option Choice "); } menu() /*gives main menu options*/ { printf("Postscript File Listing Utility for Apple LaserWriter - Version 2.11\n"); printf(" ____________(C) 1986 Nathan Liskov_____________\n"); printf; printf(" 0 = Font Size : %d\n",fontsize); printf(" 1 = Line Spacing : %3.2f linesperpage: %3.2f\n",linespacing, linesperpage); printf(" 2 = Page Feed : %s\n",onoff[pagefeed-1]); printf(" 3 = Normal Font : %s\n",font[nfont-1]); printf(" 4 = Bold Font : %s\n",font[bfont-1]); printf(" 5 = Header Line : %s\n",onoff[header-1]); printf(" 6 = Output Goes To : %s\n",outfile[nout-1]); printf(" 7 = Extra Top Blank Lines : %d\n",topspaces); printf(" 8 = Extra Bottom Blank Lines : %d\n",bottomspaces); printf(" 9 = Automatic L/R Margins : %s\n",onoff[automatic-1]); printf(" L = Extra Left Margin : %d\n",leftmargin); printf(" R = Extra Right Margin : %d\n",rightmargin); printf(" P = Page Format : %s\n",pageformat[pagetype-1]); printf(" N = Number of Copies : %d\n",numberofcopies); printf("\n"); printf(" F = File Name : %s\n",filename); printf; printf(" G = GO ESC,Q = QUIT Z = Zeroize Output.ps\n"); printf("\n"); optionline(); page = 0; } get_file() { gotoxy(1,entryline); xscanf(" Enter name of file to list: ",filname); iassign(&source,filname); filename = filname; } settopmargin() { gotoxy(1,entryline); topspaces = xscanf(" Enter number of extra top spaces: ", input_str); } setbottommargin() { gotoxy(1,entryline); bottomspaces = xscanf(" Enter number of extra bottom spaces: ",input_str); } setleftmargin() { gotoxy(1,entryline); leftmargin = xscanf(" Enter number of extra left margin spaces: ",input_str); spaces(leftmargin, left); /* tk */ } setnumberofcopies() { gotoxy(1,entryline); numberofcopies = xscanf(" Enter number of copies: ",input_str); } setfontsize() { gotoxy(1,entryline); save_fontsize = fontsize = xscanf(" Enter new fontsize: ",input_str); bigfontsize = 2 * fontsize; setlinesize(); } setlinespacing() { gotoxy(1,entryline); linespacing = (float) xscanf(" Enter new linespacing: ",input_str); if( pagetype == 1 ) linesperpage = 792 / linespacing; else linesperpage = 612 / linespacing; } setrightmargin() { gotoxy(1,entryline); rightmargin = xscanf(" Enter number of extra right margin spaces: ",input_str); spaces(rightmargin, right); } setpageformat() { if( pagetype == 1 ) pagetype = 2; else pagetype = 1; setlinesize(); if( pagetype == 1 ) linesperpage = 792 / linespacing ; else linesperpage = 612 / linespacing; } setfont(n) int n; { if( n==nfont ) fprintf(sink,"normalfont\n"); else fprintf(sink,"boldfont\n"); setlinesize(); } page_feed() { fprintf(sink," showpage\n"); fprintf(sink,"saveobj2 restore\n"); fprintf(sink,"/saveobj2 save def\n"); setfont(nfont); linecount = 1; ++page; } countlb(strng,leadingblanks) char *strng; int *leadingblanks; { *leadingblanks = 0; while( *strng++ == ' ' ) { ++*leadingblanks; } } escape(ch ,txtline) char ch; unsigned char *txtline; { /*adds \ escape for postscript*/ unsigned char lineout[255],*r; register int i; int m = strlen(txtline); r = lineout; for(i = 0; i < m; i++){ if(txtline[i] == ch) *r++ = '\\'; *r++ = txtline[i]; } *r = 0; strcpy(txtline, lineout); } dosubpiece(txtpiece) char *txtpiece; /*process text piece without tabs or font escapes*/ { escape('\\',txtpiece); escape(')',txtpiece); escape('(',txtpiece); if( locatetext ) fprintf(sink,"%3.2f %3.2f m (%s) s\n",xpos,ypos,txtpiece); locatetext=false; } dotextpiece(textpiece) /*process text that may have tabs*/ unsigned char *textpiece; { int m,xposition,ofset; ofset= OFFSET; if( pagetype == 1 ) ypos = 792.0-linespacing*linecount; else ypos = 612.0-linespacing*linecount; xpos=(startofpiece-1)*fontsize*spacewidth[nfont-1] + ofset; xpos=xpos+leftmargin*fontsize*spacewidth[nfont-1]; if( automatic==1 ) xpos=xpos-ofset; while( pos("\t",textpiece)>0 ) { /*tab processing*/ m = pos("\t",textpiece); textpiece[m - 1] = 0; if( strlen(textpiece)>0 ) dosubpiece(textpiece);/*output piece before tab*/ textpiece[m - 1] = '\t'; locatetext=true; xposition = startofpiece + m-1; xposition = ((xposition-1) / 8 + 1)*8; startofpiece = xposition+1; xpos = (xposition)*fontsize*spacewidth[nfont-1] + ofset; if( automatic==1 ) xpos=xpos-ofset; /*this spaces a tab exactly equal to 8 spaces in courier font*/ textpiece += m; if(!in(nfont, "\03\06\011\014" ) ) { countlb(textpiece,&leadingblanks); xpos=xpos+leadingblanks*fontsize*spacewidth[nfont-1]/2; } xpos=xpos+leftmargin*fontsize*spacewidth[nfont-1]; } if( strlen(textpiece)>0 ) dosubpiece(textpiece); } output_line() { unsigned char *restofline,*textpiece; float xpos; int bold, norm, place ; int line_width, line_end; /*output_line*/ if( (place = pos("_.COURIER._",temp)) > 0) /*assume form feed is only character on a line*/ { fprintf(sink, "courierfont\n"); fontsize = save_fontsize; setlinesize(); return; } if( (place = pos("_.BIGFONT._",temp)) > 0) /*assume form feed is only character on a line*/ { fprintf(sink, "bigfont\n"); fontsize = bigfontsize; setlinesize(); return; } if( (place = pos("_.LINE._",temp)) > 0) /*assume form feed is only character on a line*/ { sscanf(&temp[place + 7],"%d %d",&line_width, &line_end); if( pagetype == 1 ) ypos = 792.0-linespacing*linecount; else ypos = 612.0-linespacing*linecount; xpos=(startofpiece-1)*fontsize*spacewidth[nfont-1] + OFFSET; xpos=xpos+leftmargin*fontsize*spacewidth[nfont-1]; fprintf(sink, "%d setlinewidth \n", line_width); fprintf(sink, "%3.2f %3.2f m ", xpos, ypos); xpos += line_end; /*linesize; */ fprintf(sink, "%3.2f %3.2f lineto stroke\n",xpos, ypos); return; } if( pos("_.PF._",temp) > 0) /*assume form feed is only character on a line*/ { page_feed(); linecount = 0; /*printf("\nPage %d ",page);*/ /*status info to screen*/ return; } /*compute number of leading blanks*/ locatetext = true; countlb(temp,&leadingblanks); /*look for enable or disable bold*/ restofline = temp; while( ((bold = pos("_.BOLD._",restofline)) > 0) || ((norm = pos("_.NORM._",restofline)) > 0) ) { if( bold > 0) /*esc G enables bold*/ { restofline[bold-1] = 0; startofpiece = strlen(temp)-strlen(restofline)+1; dotextpiece(restofline); restofline[bold-1] = '_'; restofline += bold - 1 + strlen("_.BOLD._"); setfont(bfont); currentfont = bfont; } else if( norm > 0 ) /* esc H disables bold*/ { restofline[norm-1] = 0; startofpiece = strlen(temp)-strlen(restofline)+1; dotextpiece(restofline); restofline[norm-1] = '_'; restofline += norm - 1 + strlen("_.NORM._"); fontsize = save_fontsize; /* tk */ setlinesize(); /* tk */ setfont(nfont); currentfont = nfont; } } startofpiece = strlen(temp)-strlen(restofline)+1; dotextpiece(restofline); locatetext=false; } insertblankline() { *temp = 0; output_line(); printf("."); fflush(stdout); ++linecount; } inserttoplines() { for( n = 0 ; n < topspaces; n++ ) insertblankline(); } title() /*prints filename, datetime, and page number on each page*/ { int nspaces; char seg[20]; nspaces = (linesize - 36- strlen(filename)) / 2; if( in(nfont,"\03\06\011\014") ) /*test for courier font*/ nspaces = (linesize - 36- strlen(filename)) / 4; strcpy(temp,"File:"); strcat(temp,filename); spaces(nspaces,&temp[strlen(temp)]); strcat(temp,"Page "); sprintf(seg,"%d",page); strcat(temp, seg); output_line(); printf("."); fflush(stdout); linecount = 2; } automaticmargins() { char templine[255]; int eof; /*sets margins so longest line in file is centered*/ lm = leftmargin; rm = rightmargin; maxline = 0; do{ eof = fscanf(source,"%s",temp); m = strlen(temp); if( m > maxline ) maxline=m; } while(eof != EOF); fseek(source,0l, 0); /*fclose(source); */ leftmargin = (linesize-maxline) / 2; if( leftmargin < 0) leftmargin = 0; rightmargin = 0; spaces(rightmargin, right); /* spaces(leftmargin, left);fprintf(leftmargin);*/ /*fprintf(linesize," ",leftmargin);*/ } doaline() { output_line(); ++linecount ; printf("."); fflush(stdout); if((linecount > (9*linesperpage/10) - bottomspaces) && (pagefeed ==1) ) page_feed(); if( linecount ==1) { /*do after page break*/ gotoxy(1,entryline+2); clreol(); printf("\nPage %d",page); /*status info to screen*/ if( (header == 1) && (pagefeed==1)) title(); if( (topspaces >0) && (pagefeed==1) ) inserttoplines(); } } printfile() { int n,len; char *eof, *fgets(); unsigned char *templine; if( automatic == 1) automaticmargins(); fprintf(sink,"save mark\n"); fprintf(sink,"/m {moveto} def\n"); fprintf(sink,"/s {show} def\n"); formatsused[pagetype-1]=true; fontsused[cfont-1]=true; fontsused[nfont-1]=true; fontsused[bfont-1]=true; fprintf(sink,"/bigfont {/%s findfont %d scalefont setfont} def\n", font[nfont-1],fontsize * 2); fprintf(sink,"/normalfont {/%s findfont %d scalefont setfont} def\n", font[nfont-1],fontsize); fprintf(sink,"/boldfont {/%s findfont %d scalefont setfont} def\n", font[bfont-1],fontsize); fprintf(sink,"/courierfont {/%s findfont %d scalefont setfont} def\n", font[cfont-1],fontsize); fprintf(sink,"/#copies %d def\n",numberofcopies); fprintf(sink,"%%clippath pathbbox\n"); fprintf(sink,"0.98 0.98 scale\n"); if( pagetype == 2 ) fprintf(sink,"612 0 translate 90 rotate\n"); fprintf(sink,"/saveobj2 save def\n"); setfont(nfont); page = 1; linecount = 1; linelength = linesize -rightmargin-leftmargin; if( linelength <= 0 ) { clrscr(); printf("ERROR...Illegal margin size\n"); halt(); } printf("\n"); do{ /*for every line in file*/ if( linecount ==1) { gotoxy(1,entryline+2); printf("\nPage %d ",page); /*status info to screen*/ fflush(stdout); if( (header == 1) && (pagefeed==1)){ title(); } if( (topspaces >0) && (pagefeed==1)){ inserttoplines(); } } eof = fgets(temp, 254, source); /*read in one line*/ remove_trailing_newline(temp); templine=temp; if( *temp == 0 || only_blanks(temp)) doaline() ; else while( strlen(templine)>0 ) { /*process piece of full line*/ countlb(templine,&leadingblanks); if(in(nfont,"\03\06\011\014" )) { len=linesize-leftmargin-rightmargin; strcpy(newline, left); strncat(newline, templine,len); strcat(newline, right); templine += len; } else { len=(int) (linesize-trunc((leadingblanks+leftmargin+rightmargin)*spacewidth[nfont-1])); strcpy(newline, left); spaces(leadingblanks, &newline[strlen(newline)]); strncat(newline, &templine[leadingblanks],len); strcat(newline, right); templine += leadingblanks + len; } strcpy(temp,newline); doaline(); } /*processing pieces of long line*/ } while(eof != (char *)0); /*done all lines*/ /*final page feed to eject last page*/ fprintf(sink," showpage\n"); fprintf(sink,"saveobj2 restore\n"); fprintf(sink,"1.02 1.02 scale\n"); fprintf(sink,"cleartomark restore\n"); if( automatic == 1) /*restore margin values*/ { leftmargin = lm; spaces(leftmargin, left); rightmargin = rm; spaces(rightmargin, right); } menu(); } quit() /*restores default conditions on printer*/ { fprintf(sink,"%%%%Trailer\n"); if( formatsused[0] && formatsused[1] ) fprintf(sink,"%%%%BoundingBox: 0 0 792 792\n") ; else if( pagetype == 1 ) fprintf(sink,"%%%%BoundingBox: 0 0 612 792\n"); else fprintf(sink,"%%%%BoundingBox:0 0 792 612\n"); fprintf(sink,"%%%%DocumentFonts:\n"); for( n=0; n < 37; n++ ) if( fontsused[n-1] ) fprintf(sink,"%%+ %s\n",font[n-1]); fprintf(sink,"%%%%EOF\n"); fprintf(sink,"%%%%EndDocument\n"); fprintf(sink,chr(4)); close(sink); clrscr(); halt(); } zeroize() { fclose(sink); if( nout==2 ) assign(&sink,"output.ps") ;else assign(&sink,"lpt1"); } action() { switch( option){ case '0': { setfontsize();setlinesize();} break; case '1': setlinespacing(); break; case '2': { if( pagefeed == 1 ) pagefeed = 2; else pagefeed = 1; } break; case '3': { nfont = (nfont % 37 + 1) % 38; setlinesize(); } break; case '4': { bfont = (bfont % 37 + 1) % 38; gotoxy(36,8); } break; case '5': { if( header==1) header = 2; else header = 1; } break; case '6': { if( nout==1) nout = 2; else nout = 1; fclose(sink); if( nout==2 ) assign(&sink,"output.ps"); else assign(&sink,"lpt1"); } break; case '7': settopmargin(); break; case '8': setbottommargin(); break; case '9': { if( automatic==1) automatic = 2; else automatic = 1; } break; case 'L': setleftmargin(); break; case 'R': setrightmargin(); break; case 'F': get_file(); break; case 'G': if( *filename != 0) printfile(); break; case 'Q': quit(); break; case 27: quit(); break; case 'P': setpageformat(); break; case 'N': setnumberofcopies(); break; case 'Z': zeroize(); break; } menu(); optionline(); } main(argc, argv) int argc; unsigned char **argv; { paramcount = argc - 1; paramstr = argv; init(); menu(); if( autoexit && (*filename!= 0)){ printfile(); quit(); halt(); } do{ do{ option = getchar(); option = toupper(option); } while(!in(option, "0123456gGqQ78FRL9PNZ\033")); action(); } while(hellfreezesover == false); } assign(fp, name) FILE **fp; char *name; { if((*fp = fopen(name, "w")) == (FILE *) 0){ printf("kann %s nicht oeffnen\n", name); } } iassign(fp, name) FILE **fp; char *name; { if((*fp = fopen(name, "r")) == (FILE *) 0){ printf("kann %s nicht oeffnen\n", name); } } in(ch, str) char ch; char *str; { while(*str){ if(ch == *str++) return 1; } return 0; } gotoxy(x,y) int x,y; { } float round(n) float n; { return (float)n; } pos(str, in_str) char *str, *in_str; { register int i = strlen(str); char *save_str = in_str; while(*in_str){ if(!strncmp(str, in_str, i)) return (int)(in_str - save_str + 1); else ++in_str; } return 0; } delete(strng,n,m) char *strng; int n,m; { } val(strng,fontsize,err) char *strng; int fontsize, err; { } clreol() { } clrscr() { } halt() { printf("Press return\n"); getchar(); exit(0); } chr(n) int n; { return n; } float trunc(n) float n; { return n; } xscanf(s1, s2) char *s1, *s2; { int ret; do{ printf("%s",s1); scanf("%s",s2); }while(!*s2 || *s2 == '\n'); sscanf(s2,"%d", &ret); return ret; } remove_trailing_newline(s) char *s; { register int i; int len = strlen(s) - 1; for(i = len; i >= 0; i--){ if(s[i] == '\n'){ s[i] = 0; return; } } } only_blanks(s) unsigned char *s; { while(*s) if(*s++ != ' ') return 0; return 1; }