Postscript filter for System V lp and DOS

Petri Alhola petri at digiw.UUCP
Tue Jan 9 04:36:44 AEST 1990


When i anounced that i have a postscript filter "pscat" for system V lp spooler
and MSDOS jne , i got many request about it.  I am sory about delays
before sending it, but now i have send it out in alt.sources.
I have used it in 386/ix 2.0.2 ( system V rel 3.2 ),


 Petri Alhola
 petri at digiw.fi

#! /bin/sh
# This is a shell archive.  Remove anything before this line, then unpack
# it by saving it into a file and typing "sh file".  To overwrite existing
# files, type "sh file -c".  You can also feed this as standard input via
# unshar, or by typing "sh <file", e.g..  If this archive is complete, you
# will see the following message at the end:
#		"End of shell archive."
# Contents:  README gpr.c pscat.c Makefile COPYING pscript
# Wrapped by petri at digiw on Mon Jan  8 15:33:40 1990
PATH=/bin:/usr/bin:/usr/ucb ; export PATH
if test -f README -a "${1}" != "-c" ; then 
  echo shar: Will not over-write existing file \"README\"
else
echo shar: Extracting \"README\" \(1666 characters\)
sed "s/^X//" >README <<'END_OF_README'
X			PSCAT
X
X
X	This set contains programs that may be usefull for
Xprinting ascii text to postscript printer. The pscat program converts
Xascii text to postscript, it does not do any formatting or headers. It
Xcan be used as filter of it can be called from lp spooler interface 
Xscript. There is included interface script "pscript" for system V 3.x
Xspooler. Pscat program can be also used in MS-DOS, OS/2 and OS-9 systems.
Xit does have minimum number of system dependensies, so it will be very
Xeasy to port in to any other system. I have tested it in Interactive systems 
X386/ix 2.02 that is System V rel 3.2 . I have also used it in MS-DOS
X
X examples to use pscat:
X
X if you have not configured pscat inside of your lp script
X
X  cat file | pscat | lp      -- Prints text as potrait 72 lines per page
X
X  cat file | pscat -U | lp   -- Prints as landskape, two 66 lines pages
X
X if you have pscat lp script
X
X  cat file | lp		     -- Prints text as potrait 72 lines per page
X
X  cat file | lp -o-U         -- Prints as landskape, two 66 lines pages
X
X  cat file | lp -o-C         -- Prints raw postscript to printer
X
X if you are using it from PC-Interface ( from DOS network )
X you can define
X printer lpt1 remote "lp" /t20		-- Text printer
X printer lpt2 remote "lp -o-C" /t20     -- Postscript printer for
X					   windows .. etc
X
XThere is also included program gpr , that is an other pr clone with
Xfew new options, that may be useful if you have files/printers that
Xdoes like / does not like <cr><lf> or <tab> characters. It also supports
Xeuropean date format in headers and it is designed to work also in non
Xunix environments like DOS or OS-9.
X
X Petri Alhola
X petri at digiw.fi
X
END_OF_README
if test 1666 -ne `wc -c <README`; then
    echo shar: \"README\" unpacked with wrong size!
fi
# end of overwriting check
fi
if test -f gpr.c -a "${1}" != "-c" ; then 
  echo shar: Will not over-write existing file \"gpr.c\"
else
echo shar: Extracting \"gpr.c\" \(10876 characters\)
sed "s/^X//" >gpr.c <<'END_OF_gpr.c'
X/*
X
X
X  Generic PRint program      
X                             
X  Author and Copyright Petri Alhola 1987
X
X  email  : petri at digiw.fi
X  home   : tel 358 0 8058958
X  address: Joupinmaensyrja 5 b 11
X           02760 Espoo
X           Finland
X                             
X  Copyright Petri Alhola 1987
X
X  email  : petri at digiw.fi
X  home   : tel + 358 0 8058958
X  address: Joupinmaensyrja 5 b 11
X           02760 Espoo
X           Finland
X
X    This program is free software; you can redistribute it and/or modify
X    it under the terms of the GNU General Public License as published by
X    the Free Software Foundation; either version 1, or (at your option)
X    any later version.
X
X    This program is distributed in the hope that it will be useful,
X    but WITHOUT ANY WARRANTY; without even the implied warranty of
X    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
X    GNU General Public License for more details.
X
X    You should have received a copy of the GNU General Public License
X    along with this program; if not, write to the Free Software
X    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
X
X    Everyone is granted permission to copy, modify and redistribute
X    pscat, but only under the conditions described in the GNU General Public
X    License.   A copy of this license is supposed to have been given to you
X    along with GNU Emacs so you can know your rights and responsibilities.
X    It should be in a file named COPYING.
X
X    Among other things, the copyright notice and this notice must be
X    preserved on all copies.
X
X**********************************************************************
X*/
X#define LINES_AFTER_TITLE 2
X#define LINES_PER_PAGE 72
X#define NUM_OF_COL 96
X
X#include <stdio.h>
X#include <time.h>
X#define unbuf(p)       ((p)->_flag&=~_UNBUF)
X
Xint c_opt;    /* Produce n column output */
Xint f_opt;    /* Use linefeeds instead of formfeed to separete pages */
Xint lines_after_title;    /* Set the number of blank lines after title line */
Xint num_of_col;   /* Set number of columns */
Xint left_marigin; /* Set the left marigin to <num> ( default = 0    */
Xint m_opt;    /* Print all files simultaneously, each in one column */
Xint n_opt;    /* Set line numbering inrement ( default=0 , no linenumbers)*/
Xint o_opt;    /* Truncates longer lines ( default , lines are not truuncated*/
Xint lines_per_page; /* Sets number of lines per page: <num> ( default=72 ) */
Xint s_opt;    /* Separete columns by the single character instead of space*/
Xint t_opt;    /* Does not print title */
Xint e_opt;    /* Expand tabs */
Xint r_opt;    /* Do \r after newline */
Xint u_opt;    /* Print USA ( 66 lines ) documents */
Xint z_opt;    /* read file names from stdin or <path> if given */
Xint P_opt;    /* Page Pause , waits user confirm each page  */
X
Xchar *z_arg;  /* z option argument */
Xint outen;    /* Output enable Flag */
X
Xint tab;		/* Tab size */
Xint row,col,page;	/* Row ,column and page number*/
Xint text_lines;		/* number of active text lines */
Xint line;		/* line number */
Xint files;		/* Number of files printed */
Xint tot_pages;		/* Total number of pages printed */
X#ifdef MSC
Xint errno;		/* Define errno here for MSC 4.0 */
X#else
Xextern int errno;
X#endif
X
Xchar *s_arg;       /* s_option argument */
X
XFILE *inf, *fopen();
Xextern char *optarg;
Xextern int optind;
X/*==========================================================+
X!                                                           !
X!   PRint files                                             !
X!                                                           !
X+===========================================================*/
X
Xmain(argc,argv)
Xint argc;
Xchar *argv[];
X{
X int n,i,c; 
X FILE *f;
X
X#ifdef OSK
X extern int _memmins;
X  _memmins=32768;
X#endif
X tab=8;
X tot_pages=files=row=col=0;
X f_opt=0;
X lines_after_title=LINES_AFTER_TITLE;
X lines_per_page=LINES_PER_PAGE;
X num_of_col    =NUM_OF_COL;
X left_marigin=0;
X e_opt=0;	/* Dont expand tabs as default */
X m_opt=0;
X n_opt=0;
X t_opt=1;
X z_opt=0;
X r_opt=0;
X u_opt=0;
X P_opt=0;
X z_arg=NULL;
X s_arg=NULL;
X outen=1;	/* Output is enabled as default */
X	 
X while((c=getopt(argc,argv,"efPuh:k:l:mn:op:rRtz:Z123456789s:?")) != EOF)
X    switch(c) {
X    	case 'e' : e_opt=1; break;
X    	case 'f' : f_opt=1; break;
X        case 'h' : n=sscanf(optarg,"=%d",&lines_after_title); break;
X        case 'm' : m_opt=1; break;
X        case 'n' : n=sscanf(optarg,"=%d",&n_opt); break;
X    	case 'o' : o_opt=1; break;
X        case 'k' : n=sscanf(optarg,"=%d",&num_of_col); break;
X        case 'l' : n=sscanf(optarg,"=%d",&left_marigin); break;
X    	case 't' : t_opt=0; break;
X        case 'p' : n=sscanf(optarg,"=%d",&lines_per_page); break;
X    	case 's' : s_arg=optarg; break;
X    	case 'u' : u_opt=1; break;
X    	case 'r' : r_opt=1; break;
X    	case 'R' : r_opt=1; e_opt=1; t_opt=0; break;
X        case 'z' : z_arg=optarg; z_opt=1; break;
X        case 'Z' : z_opt=1; break;
X	case 'P' : P_opt=1; break;
X    	case '1' : c_opt=1; break;
X    	case '2' : c_opt=2; break;
X    	case '3' : c_opt=3; break;
X    	case '4' : c_opt=4; break;
X    	case '5' : c_opt=5; break;
X    	case '6' : c_opt=6; break;
X    	case '7' : c_opt=7; break;
X    	case '8' : c_opt=8; break;
X    	case '9' : c_opt=9; break;
X    	case '?' : print_info(); break;
X    	default  : break;
X      }
X 
X text_lines=u_opt ? 66:lines_per_page-lines_after_title-2;
X
X
X if(z_opt) {
X 	if(*z_arg++=='=') {
X	if((f=fopen(z_arg,"r")) == NULL )
X 		fprintf(stderr,"Can't open %s Error %d \n",z_arg,errno);
X   	else 	z_print(f);
X	} else z_print(stdin);
X } else {
X	 for(i=1;i<argc;i++)
X 		if(*argv[i]!='-') { 
X 			print_file(argv[i]);
X			files++;
X			}
X		 }
X	 if(files==0) print_it(stdin,"   ");
X	
X        putchar('\f'); 	/* Flush out last page */
X}
X
Xz_print(f)
XFILE *f;
X{
X	char name[40];
X	while(EOF!=fscanf(f,"%s ",name)) print_file(name);
X}
X        
X/*==========================================================+
X!                                                           !
X!  Print named file                                         !
X!                                                           !
X+===========================================================*/
X
Xprint_file(name)
Xchar *name;
X{
X	FILE *f;
X	int c;
X	
X	if((f=fopen(name,"r")) == NULL ) 
X 		fprintf(stderr,"Can't open %s Error %d \n",name,errno);
X 	else {
X 	 	print_it(f,name);
X	        fclose(f);
X        };
X}
X/*==========================================================+
X!                                                           !
X!  Print path                                               !
X!                                                           !
X+===========================================================*/
Xprint_it(f,name)
XFILE *f;
Xchar *name;
X{ 	  
X	int c;
X	
X   	page=1;
X        line=n_opt;
X 	newpage(name);
X        while(EOF!=(c=getc(f)))
X             switch(c) 	{
X#ifdef OSK
X		case 0x0a :
X#endif
X             	case '\n' : newline(name);
X			    break;
X	        case '\f' : newpage(name);
X	        	    break;
X		case '\t' : if(e_opt) do if(col< num_of_col) {
X					if(outen)	putchar(' ');
X				} while(col++ % tab) ;
X				else if(outen) putchar(c);
X			    break;
X	        default   : if(outen) putchar(c);
X	        	    col+=1;
X	        	    break;
X	        	}
X}
X/*==========================================================+
X!                                                           !
X!  Do newline                                               !
X!                                                           !
X+===========================================================*/
Xdonewline()
X{
X  if(r_opt) putchar('\r');
X  putchar('\n');
X}
X/*==========================================================+
X!                                                           !
X!  Begin new lline                                          !
X!                                                           !
X+===========================================================*/
X
Xnewline(title)
Xchar *title;
X{
X	col=0;
X        row++;
X  	line+=n_opt;
X	if(outen) donewline();
X        if(row>text_lines+lines_after_title) newpage(title);
X	if(outen) while(col++<left_marigin) putchar(' ');
X	if(n_opt && outen) printf("%5d ",line);
X}
X
X/*==========================================================+
X!                                                           !
X!   Begin new page , print header                           !
X!                                                           !
X+===========================================================*/
Xnewpage(title)
Xchar *title;
X{
X#ifdef OSK
X	struct sgtbuf t;
X#else
X  	struct tm *t;
X	long ltime;
X#endif
X	char ask[40];
X	int i;
X	char ans;
X
X	if(P_opt) { /* Page pause ? */
X		sprintf(ask,"\nPage %d  <S> for Skip <cr> to print >",page);
X		write(2,ask,strlen(ask));
X		read(0,&ans,1);
X		outen=(ans!='S') && (ans!='s');
X	};
X	row=0;
X	col=0;
X	if(tot_pages++) if(outen) putchar('\f');
X	if(t_opt) {
X#ifdef OSK	 
X   	 getime(&t);
X	 if(outen) printf("%02d-%02d-%02d %2d:%02d:%02d   %-40s    page %4d",t.t_year,
X	        t.t_month,t.t_day,t.t_hour,t.t_minute,t.t_second,title,page);
X#else
X	 time(&ltime);
X	 t=localtime(&ltime);
X	 if(outen) printf("%02d-%02d-%02d %2d:%02d:%02d   %-40s    page %4d",t->tm_year,
X	        t->tm_mon,t->tm_mday,t->tm_hour,t->tm_min,t->tm_sec,title,page);
X#endif	 
X	row++;
X	for(i=1;i<lines_after_title;i++){
X	     		if(outen) donewline();
X	        	row++;
X	};
X	newline(title);
X	}
X	page++;
X}
X/*==========================================================+
X!                                                           !
X!   Print usage info                                        !
X!                                                           !
X+===========================================================*/
Xprint_info()
X{
Xprintf("GPR 1.2 Author and Copyright Petri Alhola 1987\n");
Xprintf("gpr comes with ABSOLUTELY NO WARRANTY\n");
Xprintf("-e	  Expand tabs\n");
Xprintf("-f        Use linefeeds instead of formfeed to separete pages\n");
Xprintf("-h=<num>  Set the number of blank lines after title line (default=5)\n");
Xprintf("-l=<num>  Set the left marigin to <num> ( default = 0 )\n");
Xprintf("-m=<num>  Print all files simultaneously, each in one column\n");
Xprintf("-n=<num>  Set line numbering inrement ( default=0 , no linenumbers)\n");
Xprintf("-o        Truncates longer lines. default, lines are not truncated\n");
Xprintf("-n=<num>  Sets number of lines per page: <num> ( default=72 )\n");
Xprintf("-t        Does not print title\n");
Xprintf("-u        Print USA, 66 text line documents\n");
Xprintf("-<num>    Produce n column output 1 <= n <= 9 \n");
Xprintf("-s'char'  Separete columns by the single character instead of space\n");
Xprintf("-r        Insert \r ( carrige returns to end of lines\n");
Xprintf("-R        combines -r -e -t\n");
Xprintf("-z=<path> read file names from <path>\n");
Xprintf("-P        Page Pause , waits user confirm eack page\n");
Xprintf("-Z        read file names from stdin \n");
X}
END_OF_gpr.c
if test 10876 -ne `wc -c <gpr.c`; then
    echo shar: \"gpr.c\" unpacked with wrong size!
fi
# end of overwriting check
fi
if test -f pscat.c -a "${1}" != "-c" ; then 
  echo shar: Will not over-write existing file \"pscat.c\"
else
echo shar: Extracting \"pscat.c\" \(13077 characters\)
sed "s/^X//" >pscat.c <<'END_OF_pscat.c'
X/*
X
X  Postscript filter ( ascii list to postscript )
X
X                             
X  Copyright Petri Alhola 1987
X
X  email  : petri at digiw.fi
X  home   : tel + 358 0 8058958
X  address: Joupinmaensyrja 5 b 11
X           02760 Espoo
X           Finland
X
X    This program is free software; you can redistribute it and/or modify
X    it under the terms of the GNU General Public License as published by
X    the Free Software Foundation; either version 1, or (at your option)
X    any later version.
X
X    This program is distributed in the hope that it will be useful,
X    but WITHOUT ANY WARRANTY; without even the implied warranty of
X    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
X    GNU General Public License for more details.
X
X    You should have received a copy of the GNU General Public License
X    along with this program; if not, write to the Free Software
X    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
X
X    Everyone is granted permission to copy, modify and redistribute
X    pscat, but only under the conditions described in the GNU General Public
X    License.   A copy of this license is supposed to have been given to you
X    along with GNU Emacs so you can know your rights and responsibilities.
X    It should be in a file named COPYING.
X
X    Among other things, the copyright notice and this notice must be
X    preserved on all copies.
X
X**********************************************************************
X*/
X#define LINES_PER_PAGE 72
X#define NUM_OF_COL 96
X
X#include <stdio.h>
X#include <time.h>
X
Xint c_opt;	/* Produce n column output */
Xint num_of_col;	/* Set number of columns */
Xint left_marigin; /* Set the left marigin to <num> ( default = 0    */
Xint m_opt;	/* Print all files simultaneously, each in one column */
Xint o_opt;	/* Truncates longer lines ( default , lines are not truuncated*/
Xint lines_per_page; /* Sets number of lines per page: <num> ( default=72 ) */
Xint s_opt;	/* Separete columns by the single character instead of space*/
Xint z_opt;	/* read file names from stdin or <path> if given */
Xint r_opt;	/* Print page rotated as 90 degrees */
Xint C_opt;	/* Cat direct postscript files */
Xchar *catfile;	/* Postscript prologue file */
Xchar *z_arg;	/* z option argument */
X
Xint files;	/* Number of files printed */
Xint row,col,page;  /* Row ,column and page number*/
Xint text_lines;	/* number of active text lines */
Xint tab;	/* Tabulation value */
Xint p_col;	/* printing column */
Xint y;		/* Y cordinate */
Xint x_left;	/* Left x column */
Xint x_ofset;	/* x ofset */
Xint y_spacing;	/* Row spacing */
Xint y_top;	/* Top y cordinate */
Xint fontsize;	/* Size of used font */
Xint showflag;	/* Show open flag */
X
X#ifdef MSC
Xint errno;		/* Define errno here for MSC 4.0 */
X#else
Xextern int errno;
X#endif
X
Xchar *s_arg;       /* s_option argument */
X
XFILE *inf, *fopen();
Xextern char *optarg;
Xextern int optind;
X/*==========================================================+
X!                                                           !
X!   PRint files                                             !
X!                                                           !
X+===========================================================*/
X
Xmain(argc,argv)
Xint argc;
Xchar *argv[];
X{
X int n,i,c; 
X FILE *f;
X
X#ifdef OSK
X extern int _memmins;
X  _memmins=32768;
X#endif 
X
X showflag=files=row=col=0;
X
X lines_per_page=0;
X num_of_col    =NUM_OF_COL;
X left_marigin=0;
X p_col=1;	/* Current page column */
X
X x_ofset=30;
X y_top =772;
X fontsize=10;
X tab=8;
X
X m_opt=z_opt=r_opt=C_opt=0;
X c_opt=1;
X z_arg=NULL;
X s_arg=NULL;
X	 
X while((c=getopt(argc,argv,"f:rc:RUCk:l:mop:tz:Zs:123456789?")) != EOF)
X    switch(c) {
X        case 'm' : m_opt=1; break;
X    	case 'o' : o_opt=1; break;
X        case 'k' : n=sscanf(optarg,"%d",&num_of_col); break;
X        case 'l' : n=sscanf(optarg,"%d",&left_marigin); break;
X        case 'p' : n=sscanf(optarg,"%d",&lines_per_page); break;
X        case 'f' : n=sscanf(optarg,"%d",&fontsize); break;
X	case 'x' : n=sscanf(optarg,"%d",&x_ofset); break;
X	case 'c' : catfile=optarg; print_file(catfile,1); break;
X        case 'r' : r_opt=1; break;
X	case 'C' : C_opt=1; break;
X        case 'R' : r_opt=1;
X        	   fontsize=7;
X        	   c_opt=2;
X        	   o_opt=1;
X        	   num_of_col=92; break;
X        case 'U' : r_opt=1;
X        	   fontsize=8;
X        	   c_opt=2;
X        	   o_opt=1;
X        	   num_of_col=80; break;
X    	case 's' : s_arg=optarg; break;
X    	case 'u' : lines_per_page=66; break;
X        case 'z' : z_arg=optarg; z_opt=1; break;
X        case 'Z' : z_opt=1; break;
X     	case '1' : c_opt=1; break;
X    	case '2' : c_opt=2; break;
X    	case '3' : c_opt=3; break;
X    	case '4' : c_opt=4; break;
X    	case '5' : c_opt=5; break;
X    	case '6' : c_opt=6; break;
X    	case '7' : c_opt=7; break;
X    	case '8' : c_opt=8; break;
X    	case '9' : c_opt=9; break;
X    	case '?' : print_info(); break;
X    	default  : break;
X      }
X
X x_left=x_ofset;
X y_spacing=-fontsize; 
X if(!C_opt) prolog();
X 
X if(r_opt) {	/* Rotated picture */
X 	y_top=-30;
X 	y=y_top;
X	if(lines_per_page==0) lines_per_page=550 / fontsize;
X  } else {
X  		if(lines_per_page==0) lines_per_page=760 / fontsize;
X	}
X
X
X
X if(z_opt) {
X 	if(*z_arg++=='=') {
X	if((f=fopen(z_arg,"r")) == NULL )
X 		fprintf(stderr,"Can't open %s Error %d \n",z_arg,errno);
X   	else 	z_print(f);
X	} else z_print(stdin);
X } else {
X	for(i=1;i<argc;i++) 
X 		if(*argv[i]!='-') { 
X 			print_file(argv[i],C_opt);
X			files++;
X			}
X	}
X	if(files==0) print_it(stdin,C_opt);
X}
X/*==========================================================+
X!                                                           !
X!  Read filenames from stdin                                !
X!                                                           !
X+===========================================================*/
X
Xz_print(f)
XFILE *f;
X{
X	char name[40];
X	while(EOF!=fscanf(f,"%s ",name)) print_file(name,C_opt);
X}
X        
X/*==========================================================+
X!                                                           !
X!  Print named file                                         !
X!                                                           !
X+===========================================================*/
X
Xprint_file(name,cat)
Xchar *name;
Xint cat;
X{
X	FILE *f;
X	int c;
X	
X	if((f=fopen(name,"r")) == NULL ) 
X 		fprintf(stderr,"Can't open %s Error %d \n",name,errno);
X 	else {
X 	 	print_it(f,cat);
X	        fclose(f);
X	}
X}
X/*==========================================================+
X!                                                           !
X!  Print path                                               !
X!                                                           !
X+===========================================================*/
Xprint_it(f,cat)
XFILE *f;
Xint cat;
X{ 	  
X	int c;
X	
X   	page=1;
X	if(cat) { 
X		cat_it(f); 
X		return;
X	};
X   	startpage();
X        while(EOF!=(c=getc(f)))
X             switch(c) 	{
X             	case '\n' : newline();
X			    break;
X	        case '\f' : if(col) newline();
X	        	    newpage();
X	        	    break;
X		case '\t' :  if(col==0) startline();
X			     do if(!o_opt || (col< num_of_col)) {
X					    if(!showflag) startshow();
X						putchar(' ');
X						col++;
X					} while(col % tab) ;
X			    break;
X		case '(':case ')' :case '<' :case '>' :
X		case '[':case ']' :case '{' :case '}' :
X		case '/':case '%' :
X		case '\\':  if(col==0) startline();
X			if(!o_opt || (col< num_of_col)) {
X			    if(!showflag) startshow();
X			    putchar('\\');
X			    putchar(c); 
X	        	    col+=1;
X	        	}
X	        	    break;
X		case 8  : endshow();
X			  printf("(A) stringwidth  exch neg exch rmoveto\n");
X			  break;
X		case  0: case  1: case  2: case  3:
X		case  4: case  5: case  6: case  7:
X		                           case 11:
X	                          case 14: case 15:
X		case 16: case 17: case 18: case 19:
X		case 20: case 21: case 22: case 23:
X		case 24: case 25: case 26: case 27:
X		case 28: case 29: case 30: case 31: break; /* ignore  other controll chars */	     
X
X	        default   : if(col==0) startline();
X        		if(!o_opt || (col< num_of_col)) {
X			    if(!showflag) startshow();
X        			putchar(c);
X	        	    	col+=1;
X	        	    }
X	        	    
X	        	    break;
X	        	}
X	printf("showpage\n");
X}
X/*==========================================================+
X!                                                           !
X!  cat path                                                 !
X!                                                           !
X+===========================================================*/
Xcat_it(f)
XFILE *f;
X{ 	  
X	int c;
X        while(EOF!=(c=getc(f))) putchar(c);
X};
X
X/*==========================================================+
X!                                                           !
X!  Write postscript prolog ( set font and size )            !
X!                                                           !
X+===========================================================*/
Xprolog()
X{
X	printf("/Courier findfont\n");
X	printf("%d scalefont\n",fontsize);
X	printf("setfont\n");
X	y=y_top;
X}
X/*==========================================================+
X!                                                           !
X!  Begining of new line                                     !
X!                                                           !
X+===========================================================*/
Xstartline()
X{
X           	printf("%d %d moveto\n",x_left,y);
X		startshow();
X}
X/*==========================================================+
X!                                                           !
X!  Begining show text                                       !
X!                                                           !
X+===========================================================*/
Xstartshow()
X{
X		if(!showflag) printf("(");
X           	showflag=1;
X}
X/*==========================================================+
X!                                                           !
X!  end of show text                                         !
X!                                                           !
X+===========================================================*/
Xendshow()
X{
X		if(showflag) printf(") show\n");
X           	showflag=0;
X}
X
X/*==========================================================+
X!                                                           !
X!  end of line                                              !
X!                                                           !
X+===========================================================*/
X
Xnewline()
X{
X	endshow();
X	col=0;
X        row++;
X        if(row>lines_per_page) newpage();
X          else
X           	y+=y_spacing;
X}
X/*==========================================================+
X!                                                           !
X!   Start new page                                          !
X!                                                           !
X+===========================================================*/
Xstartpage()
X{
X	if(r_opt) {
X		if(p_col==1) printf("90 rotate\n");
X		x_left=x_ofset+(p_col-1) * (772 / c_opt);
X	} else 
X		x_left=x_ofset+(p_col-1) * (572 / c_opt);
X		
X	y=y_top;	
X}
X
X/*==========================================================+
X!                                                           !
X!   Print page out                                          !
X!                                                           !
X+===========================================================*/
Xnewpage(title)
Xchar *title;
X{
X	row=0;
X	col=0;
X	if(++p_col > c_opt) {
X		printf("showpage\n");
X		p_col=1;
X	}
X	startpage();
X}
X/*==========================================================+
X!                                                           !
X!   Print usage info                                        !
X!                                                           !
X+===========================================================*/
Xprint_info()
X{
Xprintf("pcat 1.2 Text to postscript filter. Copyright Petri Alhola 1987\n");
Xprintf("pcat comes with ABSOLUTELY NO WARRANTY\n");
Xprintf("-c<file> Cat file as postscript prologue\n");
Xprintf("-C       Cat all files as direct postscript files\n");
Xprintf("-f<num>  Set font size to <num> points ( default is 10 )\n");
Xprintf("-k<num>  Set number of columns \n");
Xprintf("-l<num>  Set the left marigin to <num> ( default = 0 )\n");
Xprintf("-<num>    Print file in <num> columns 1..9\n");
Xprintf("-n<num>  Sets number of lines per page: <num> ( default=72 )\n");
Xprintf("-o        Truncates longer lines. default, lines are not truncated\n");
Xprintf("-p<num>  Set number of lines per page\n");
Xprintf("-r        Print page rotated 90 degrees ( landscape )\n");
Xprintf("-u        Print USA, 66 text line documents\n");
Xprintf("-x<num>   Set X offset\n");
Xprintf("-z<path> read file names from <path>\n");
Xprintf("-Z        read file names from stdin \n");
Xprintf("  ----- Combination options -----\n");
Xprintf("-R        -r -o -c=92 -f=7 -2 ( Prints 92 col * 79 row , 2 pages )\n");
Xprintf("-U        -r -o -c=80 -f=8 -2 ( Prints 92 col * 69 row , 2 pages )\n");
X}
END_OF_pscat.c
if test 13077 -ne `wc -c <pscat.c`; then
    echo shar: \"pscat.c\" unpacked with wrong size!
fi
# end of overwriting check
fi
if test -f Makefile -a "${1}" != "-c" ; then 
  echo shar: Will not over-write existing file \"Makefile\"
else
echo shar: Extracting \"Makefile\" \(224 characters\)
sed "s/^X//" >Makefile <<'END_OF_Makefile'
X# 
X# Make gpr and pr for unix
X#
XCFLAGS= -O
X
Xpscat:	pscat.o
X	cc pscat.o -o pscat
X
X
Xgpr:	gpr.o
X	cc gpr.o -o gpr
X  
X
Xshar: README gpr.c pscat.c Makefile COPYING pscript
X	shar README gpr.c pscat.c Makefile COPYING pscript >shar
END_OF_Makefile
if test 224 -ne `wc -c <Makefile`; then
    echo shar: \"Makefile\" unpacked with wrong size!
fi
# end of overwriting check
fi
if test -f COPYING -a "${1}" != "-c" ; then 
  echo shar: Will not over-write existing file \"COPYING\"
else
echo shar: Extracting \"COPYING\" \(12488 characters\)
sed "s/^X//" >COPYING <<'END_OF_COPYING'
X
X		    GNU GENERAL PUBLIC LICENSE
X		     Version 1, February 1989
X
X Copyright (C) 1989 Free Software Foundation, Inc.
X                    675 Mass Ave, Cambridge, MA 02139, USA
X Everyone is permitted to copy and distribute verbatim copies
X of this license document, but changing it is not allowed.
X
X			    Preamble
X
X  The license agreements of most software companies try to keep users
Xat the mercy of those companies.  By contrast, our General Public
XLicense is intended to guarantee your freedom to share and change free
Xsoftware--to make sure the software is free for all its users.  The
XGeneral Public License applies to the Free Software Foundation's
Xsoftware and to any other program whose authors commit to using it.
XYou can use it for your programs, too.
X
X  When we speak of free software, we are referring to freedom, not
Xprice.  Specifically, the General Public License is designed to make
Xsure that you have the freedom to give away or sell copies of free
Xsoftware, that you receive source code or can get it if you want it,
Xthat you can change the software or use pieces of it in new free
Xprograms; and that you know you can do these things.
X
X  To protect your rights, we need to make restrictions that forbid
Xanyone to deny you these rights or to ask you to surrender the rights.
XThese restrictions translate to certain responsibilities for you if you
Xdistribute copies of the software, or if you modify it.
X
X  For example, if you distribute copies of a such a program, whether
Xgratis or for a fee, you must give the recipients all the rights that
Xyou have.  You must make sure that they, too, receive or can get the
Xsource code.  And you must tell them their rights.
X
X  We protect your rights with two steps: (1) copyright the software, and
X(2) offer you this license which gives you legal permission to copy,
Xdistribute and/or modify the software.
X
X  Also, for each author's protection and ours, we want to make certain
Xthat everyone understands that there is no warranty for this free
Xsoftware.  If the software is modified by someone else and passed on, we
Xwant its recipients to know that what they have is not the original, so
Xthat any problems introduced by others will not reflect on the original
Xauthors' reputations.
X
X  The precise terms and conditions for copying, distribution and
Xmodification follow.
X
X		    GNU GENERAL PUBLIC LICENSE
X   TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
X
X  0. This License Agreement applies to any program or other work which
Xcontains a notice placed by the copyright holder saying it may be
Xdistributed under the terms of this General Public License.  The
X"Program", below, refers to any such program or work, and a "work based
Xon the Program" means either the Program or any work containing the
XProgram or a portion of it, either verbatim or with modifications.  Each
Xlicensee is addressed as "you".
X
X  1. You may copy and distribute verbatim copies of the Program's source
Xcode as you receive it, in any medium, provided that you conspicuously and
Xappropriately publish on each copy an appropriate copyright notice and
Xdisclaimer of warranty; keep intact all the notices that refer to this
XGeneral Public License and to the absence of any warranty; and give any
Xother recipients of the Program a copy of this General Public License
Xalong with the Program.  You may charge a fee for the physical act of
Xtransferring a copy.
X
X  2. You may modify your copy or copies of the Program or any portion of
Xit, and copy and distribute such modifications under the terms of Paragraph
X1 above, provided that you also do the following:
X
X    a) cause the modified files to carry prominent notices stating that
X    you changed the files and the date of any change; and
X
X    b) cause the whole of any work that you distribute or publish, that
X    in whole or in part contains the Program or any part thereof, either
X    with or without modifications, to be licensed at no charge to all
X    third parties under the terms of this General Public License (except
X    that you may choose to grant warranty protection to some or all
X    third parties, at your option).
X
X    c) If the modified program normally reads commands interactively when
X    run, you must cause it, when started running for such interactive use
X    in the simplest and most usual way, to print or display an
X    announcement including an appropriate copyright notice and a notice
X    that there is no warranty (or else, saying that you provide a
X    warranty) and that users may redistribute the program under these
X    conditions, and telling the user how to view a copy of this General
X    Public License.
X
X    d) You may charge a fee for the physical act of transferring a
X    copy, and you may at your option offer warranty protection in
X    exchange for a fee.
X
XMere aggregation of another independent work with the Program (or its
Xderivative) on a volume of a storage or distribution medium does not bring
Xthe other work under the scope of these terms.
X
X  3. You may copy and distribute the Program (or a portion or derivative of
Xit, under Paragraph 2) in object code or executable form under the terms of
XParagraphs 1 and 2 above provided that you also do one of the following:
X
X    a) accompany it with the complete corresponding machine-readable
X    source code, which must be distributed under the terms of
X    Paragraphs 1 and 2 above; or,
X
X    b) accompany it with a written offer, valid for at least three
X    years, to give any third party free (except for a nominal charge
X    for the cost of distribution) a complete machine-readable copy of the
X    corresponding source code, to be distributed under the terms of
X    Paragraphs 1 and 2 above; or,
X
X    c) accompany it with the information you received as to where the
X    corresponding source code may be obtained.  (This alternative is
X    allowed only for noncommercial distribution and only if you
X    received the program in object code or executable form alone.)
X
XSource code for a work means the preferred form of the work for making
Xmodifications to it.  For an executable file, complete source code means
Xall the source code for all modules it contains; but, as a special
Xexception, it need not include source code for modules which are standard
Xlibraries that accompany the operating system on which the executable
Xfile runs, or for standard header files or definitions files that
Xaccompany that operating system.
X
X  4. You may not copy, modify, sublicense, distribute or transfer the
XProgram except as expressly provided under this General Public License.
XAny attempt otherwise to copy, modify, sublicense, distribute or transfer
Xthe Program is void, and will automatically terminate your rights to use
Xthe Program under this License.  However, parties who have received
Xcopies, or rights to use copies, from you under this General Public
XLicense will not have their licenses terminated so long as such parties
Xremain in full compliance.
X
X  5. By copying, distributing or modifying the Program (or any work based
Xon the Program) you indicate your acceptance of this license to do so,
Xand all its terms and conditions.
X
X  6. Each time you redistribute the Program (or any work based on the
XProgram), the recipient automatically receives a license from the original
Xlicensor to copy, distribute or modify the Program subject to these
Xterms and conditions.  You may not impose any further restrictions on the
Xrecipients' exercise of the rights granted herein.
X
X  7. The Free Software Foundation may publish revised and/or new versions
Xof the General Public License from time to time.  Such new versions will
Xbe similar in spirit to the present version, but may differ in detail to
Xaddress new problems or concerns.
X
XEach version is given a distinguishing version number.  If the Program
Xspecifies a version number of the license which applies to it and "any
Xlater version", you have the option of following the terms and conditions
Xeither of that version or of any later version published by the Free
XSoftware Foundation.  If the Program does not specify a version number of
Xthe license, you may choose any version ever published by the Free Software
XFoundation.
X
X  8. If you wish to incorporate parts of the Program into other free
Xprograms whose distribution conditions are different, write to the author
Xto ask for permission.  For software which is copyrighted by the Free
XSoftware Foundation, write to the Free Software Foundation; we sometimes
Xmake exceptions for this.  Our decision will be guided by the two goals
Xof preserving the free status of all derivatives of our free software and
Xof promoting the sharing and reuse of software generally.
X
X			    NO WARRANTY
X
X  9. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
XFOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW.  EXCEPT WHEN
XOTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
XPROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
XOR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
XMERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.  THE ENTIRE RISK AS
XTO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU.  SHOULD THE
XPROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
XREPAIR OR CORRECTION.
X
X  10. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
XWILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
XREDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
XINCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
XOUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
XTO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
XYOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
XPROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
XPOSSIBILITY OF SUCH DAMAGES.
X
X		     END OF TERMS AND CONDITIONS
X
X	Appendix: How to Apply These Terms to Your New Programs
X
X  If you develop a new program, and you want it to be of the greatest
Xpossible use to humanity, the best way to achieve this is to make it
Xfree software which everyone can redistribute and change under these
Xterms.
X
X  To do so, attach the following notices to the program.  It is safest to
Xattach them to the start of each source file to most effectively convey
Xthe exclusion of warranty; and each file should have at least the
X"copyright" line and a pointer to where the full notice is found.
X
X    <one line to give the program's name and a brief idea of what it does.>
X    Copyright (C) 19yy  <name of author>
X
X    This program is free software; you can redistribute it and/or modify
X    it under the terms of the GNU General Public License as published by
X    the Free Software Foundation; either version 1, or (at your option)
X    any later version.
X
X    This program is distributed in the hope that it will be useful,
X    but WITHOUT ANY WARRANTY; without even the implied warranty of
X    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
X    GNU General Public License for more details.
X
X    You should have received a copy of the GNU General Public License
X    along with this program; if not, write to the Free Software
X    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
X
XAlso add information on how to contact you by electronic and paper mail.
X
XIf the program is interactive, make it output a short notice like this
Xwhen it starts in an interactive mode:
X
X    Gnomovision version 69, Copyright (C) 19xx name of author
X    Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
X    This is free software, and you are welcome to redistribute it
X    under certain conditions; type `show c' for details.
X
XThe hypothetical commands `show w' and `show c' should show the
Xappropriate parts of the General Public License.  Of course, the
Xcommands you use may be called something other than `show w' and `show
Xc'; they could even be mouse-clicks or menu items--whatever suits your
Xprogram.
X
XYou should also get your employer (if you work as a programmer) or your
Xschool, if any, to sign a "copyright disclaimer" for the program, if
Xnecessary.  Here a sample; alter the names:
X
X  Yoyodyne, Inc., hereby disclaims all copyright interest in the
X  program `Gnomovision' (a program to direct compilers to make passes
X  at assemblers) written by James Hacker.
X
X  <signature of Ty Coon>, 1 April 1989
X  Ty Coon, President of Vice
X
XThat's all there is to it!
END_OF_COPYING
if test 12488 -ne `wc -c <COPYING`; then
    echo shar: \"COPYING\" unpacked with wrong size!
fi
# end of overwriting check
fi
if test -f pscript -a "${1}" != "-c" ; then 
  echo shar: Will not over-write existing file \"pscript\"
else
echo shar: Extracting \"pscript\" \(233 characters\)
sed "s/^X//" >pscript <<'END_OF_pscript'
X# lp interface for postscript printer
X# (c) Petri Alhola 1988
Xoptions=$5
Xcopies=$4
Xshift; shift; shift; shift; shift
Xfiles="$*"
Xi=1
Xwhile [ $i -le $copies ]
Xdo
X	/usr/local/bin/pscat $options $files 2>&1
X	i=`expr $i + 1`
Xdone
Xexit 0
X
END_OF_pscript
if test 233 -ne `wc -c <pscript`; then
    echo shar: \"pscript\" unpacked with wrong size!
fi
chmod +x pscript
# end of overwriting check
fi
echo shar: End of shell archive.
exit 0



More information about the Alt.sources mailing list