#! /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 archive 1 (of 1)."
# Contents:  MANIFEST Makefile README example.ps npr.1 npr.c npr.h
#   npr.prologue
# Wrapped by stefan@mikros on Mon Sep 12 18:41:56 1988
PATH=/bin:/usr/bin:/usr/ucb ; export PATH
if test -f MANIFEST -a "${1}" != "-c" ; then 
  echo shar: Will not over-write existing file \"MANIFEST\"
else
echo shar: Extracting \"MANIFEST\" \(473 characters\)
sed "s/^X//" >MANIFEST <<'END_OF_MANIFEST'
X   File Name		Archive #	Description
X-----------------------------------------------------------
X MANIFEST                  1	This shipping list
X Makefile                  1	Guess
X README                    1	Information
X example.ps                1	An example of an article
X npr.1                     1	Manual page
X npr.c                     1	News Pretty Printer source code
X npr.h                     1	Common definitions
X npr.prologue              1	PostScript prologue
END_OF_MANIFEST
if test 473 -ne `wc -c <MANIFEST`; then
    echo shar: \"MANIFEST\" 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\" \(345 characters\)
sed "s/^X//" >Makefile <<'END_OF_Makefile'
X#
X# Makefile news pretty printer
X#
X# SCCSID= @(#)Makefile	1.3 (Mikros) 88/08/24
X#
XSHELL=	/bin/sh
XSCCSPATH= SCCS/
X
XDEFINES=-Dsinix -Dvoid=int
X#DEFINES=-DBSD
X#DEFINES=-DSYSV
X
XCC=	cc
XCFLAGS=	-O ${DEFINES}
XLFLAGS=
XLIBS=
X
Xnpr:	npr.o
X	${CC} ${LFLAGS} npr.o -o $@ ${LIBS}
X
Xnpr.o:	npr.h
X
Xclean:
X	-rm -f *.o
X
Xclobber: clean
X	-rm -f a.out core npr print
X
END_OF_Makefile
if test 345 -ne `wc -c <Makefile`; then
    echo shar: \"Makefile\" unpacked with wrong size!
fi
# end of overwriting check
fi
if test -f README -a "${1}" != "-c" ; then 
  echo shar: Will not over-write existing file \"README\"
else
echo shar: Extracting \"README\" \(723 characters\)
sed "s/^X//" >README <<'END_OF_README'
X			NEWS PRETTY PRINTER
X			===================
X
XThis directory contains the source code for the news pretty printer.
XThere are no system dependend definitions, although the programm may
Xcontain some dependencies.
X
XApply the make command to build the programm and have a cup of coffee.
X
XPlease note that this preliminary version of the news printer lacks
Xsome features which are already prepared for in the source code.
X
XPlease note also that the program is not copyrighted, so you can use
Xit freely, but do not redistribute it or post it before the final
Xversion has been released.
X
XI would like to here your comments, improvements and/or bug reports.
XSend e-mail to stefan@mikros.uucp or stefan@systemware.de.
X
XHave fun...
END_OF_README
if test 723 -ne `wc -c <README`; then
    echo shar: \"README\" unpacked with wrong size!
fi
# end of overwriting check
fi
if test -f example.ps -a "${1}" != "-c" ; then 
  echo shar: Will not over-write existing file \"example.ps\"
else
echo shar: Extracting \"example.ps\" \(8076 characters\)
sed "s/^X//" >example.ps <<'END_OF_example.ps'
X%!PS-Adobe-1.0
X%%Title: USENET News
X%%Creator: npr by Stefan Stapelberg
X%%CreationDate: @(#)npr.c	1.2 (Mikros) 88/08/16
X%%BoundingBox: 54 36 558 792
X%%For: stefan
X%%DocumentFonts: ??
X%%Pages: ??
X%%EndComments
X
X%
X% NPR prologue
X% Written (w) 1988 by Stefan Stapelberg
X% @(#)npr.prologue	1.2 (Mikros) 88/08/16
X%
X
X% Font definitions you may want to change.
X% Note: if you change the point size of a font,
X%       you should change vertical spacing also
X%
X/Logofont /Bookman-DemiItalic findfont def		% for Logo, not scaled
X/Headfont /Bookman-Demi findfont 11 scalefont def	% for From:-Header etc.
X/Linefont /Bookman-Light findfont 11 scalefont def	% for From:-Lines etc.
X/Textfont /Courier findfont 10 scalefont def		% normal text font
X
X% vertical spacing
X%
X/nldist 11 def		% text newline distance
X/hldist 12 def		% header newline distance
X
X% don't bother for the rest, things
X% should already working perfectly
X%
X/tident 10 def		% text indent
X/hident 10 def		% header ident (internal only)
X/nstr 5 string def	% string storage
X/inch { 72 mul } def	% convert inch to point
X
X/DrawBox		% stack: boundary box x1,y1 x2,y2
X { /radius 10 def
X   radius sub /uborder exch def		% upper border
X   radius sub /rborder exch def		% right border
X   radius add /dborder exch def		% lower border
X   radius add /lborder exch def		% left border
X
X   newpath
X     lborder radius sub uborder moveto	% draw box
X     lborder dborder radius 180 270 arc
X     rborder dborder radius 270 0 arc
X     rborder uborder radius 0 90 arc
X     lborder uborder radius 90 180 arc
X   closepath
X } def
X
X/Logo0			% print nice logo, version 1
X { gsave
X     Logofont 28 scalefont setfont
X     (NetNEWS) dup /Title exch def		% logo string
X       stringwidth pop /Titlelen exch def	% length of string
X
X     RM 2.5 inch sub TM 0.5 inch sub translate
X     0 0 2.5 inch 0.5 inch DrawBox
X     1.5 setlinewidth stroke
X
X     newpath					% set clipping path
X       2.5 inch Titlelen sub 2 div 9 translate
X       0 0 moveto Title true
X     charpath clip
X
X     newpath					% draw rays
X       Titlelen 2 div -7 translate
X       0.25 setlinewidth
X       0 1.5 179
X       { gsave
X           rotate
X           0 0 moveto 108 0 lineto stroke
X         grestore
X       }for
X
X   grestore
X } def
X
X/Logo1			% print logo, version 2
X { gsave
X     RM 2.5 inch sub TM 0.5 inch sub translate
X     0 0 2.5 inch 0.5 inch DrawBox clip	% set clip path
X
X     Logofont 9 scalefont setfont	% print background
X     newpath
X       0 0.5 inch 7 sub moveto
X       (NEWS ) /Title exch def
X       0.5 setgray
X       { { pop pop currentpoint pop 2.5 inch gt
X	   { currentpoint 9 sub exch pop 0 exch moveto } if } Title kshow
X           currentpoint exch pop -0 lt { exit } if
X       } loop
X
X     Logofont 28 scalefont setfont	% print logo over background
X     newpath
X       (NetNEWS) dup stringwidth pop
X       2.5 inch exch sub 2 div 9 moveto
X       0 setgray show
X
X   grestore
X } def
X
X/Logo2			% print logo, version 3
X { gsave
X     Logofont 28 scalefont setfont
X     (NetNEWS) dup /Title exch def		% logo string
X       stringwidth pop /Titlelen exch def	% length of string
X
X     RM 2.5 inch sub TM 0.5 inch sub translate
X     0 0 2.5 inch 0.5 inch DrawBox
X     1.5 setlinewidth stroke
X
X     newpath
X       2.5 inch Titlelen sub 2 div 5 add 3 translate
X       .95 -.05 0 { setgray 0 0 moveto Title show -1 .5 translate } for
X       1 setgray 0 0 moveto Title show
X
X   grestore
X } def
X
X/Logo3			% print logo, version 4
X { gsave
X     Logofont 28 scalefont setfont
X     (NetNEWS) dup /Title exch def		% logo string
X       stringwidth pop /Titlelen exch def	% length of string
X
X     RM 2.5 inch sub TM 0.5 inch sub translate
X     0 0 2.5 inch 0.5 inch DrawBox
X     0 setgray fill
X
X     newpath					% set clipping path
X     (NetNEWS) dup stringwidth pop
X       2.5 inch exch sub 2 div 0 translate
X       1 setgray 1 1.5 scale 0 -1 moveto show
X
X   grestore
X } def
X
X/Logo4			% print logo, version 5
X { gsave
X     RM 2.5 inch sub TM 0.5 inch sub translate
X     0 0 2.5 inch 0.5 inch DrawBox
X     1.5 setlinewidth stroke
X
X     Logofont 28 scalefont setfont
X     newpath
X       (NetNEWS) dup stringwidth pop
X       2.5 inch exch sub 2 div 9 moveto
X       true charpath 0.5 setlinewidth stroke
X
X   grestore
X } def
X
X
X/PrintHeadline		% print header line at top of each page
X { 1 page eq			% this is first page,
X   { PrintLogo cvx exec		% so draw a logo on it
X     LM TM 0.5 inch sub		% prepare clipping path
X     RM 2.5 inch sub 9 sub TM }	% for rest of header
X   { LM TM 0.5 inch sub RM TM } ifelse
X
X   DrawBox
X   gsave 0.8 setgray fill grestore
X   gsave 1.5 setlinewidth stroke grestore
X   gsave clip
X     Headfont setfont
X     LM tident add TM 28 sub translate
X     newpath
X       0 0 moveto Subline show
X       0 12 moveto Headline show
X     RM LM sub tident 2 mul sub
X     (Page 999) stringwidth pop sub 12 moveto
X     (Page ) show page nstr cvs show
X   grestore
X } def
X
X/InitPage		% stack: pageno
X { /page exch def
X   /ypos TM 0.625 inch sub def
X   PrintHeadline
X   Textfont setfont
X } def
X
X/PrintPage
X { showpage
X   page 1 add InitPage
X   2 Newline
X } def
X
X/Newline		% stack: number of newlines
X { nldist mul ypos exch sub /ypos exch def
X   LM tident add ypos moveto
X   ypos BM lt { PrintPage } if
X } def
X
X/Nextline
X { hldist ypos exch sub /ypos exch def
X   LM hident add ypos moveto
X } def
X
X/PrintField		% stack: [(Headerstring) (Fieldstring)]
X { aload pop exch
X   /hident tident def
X   Nextline Headfont setfont
X   dup stringwidth pop tident add /hident exch def show
X   Linefont setfont
X   { pop pop currentpoint pop RM tident 2 mul sub ge { Nextline } if } exch kshow
X } def
X
X/PrintHeader		% print header array on title page
X { gsave
X     HeaderList { PrintField } forall
X     /ypos ypos 9 sub def
X     LM ypos RM TM 0.6 inch sub DrawBox stroke
X   grestore
X   2 Newline
X } def
X
X/PrintText		% print text, take care of line wrap
X {
X   { pop pop currentpoint pop RM tident sub ge { 1 Newline } if } exch kshow
X } def
X
X/EndText		% ouput last page
X { showpage
X } def
X
X%%EndProlog
X
X% Begin program
X/LM 0.750 inch def	% left margin
X/RM 7.750 inch def	% right margin
X/TM 11.000 inch def	% top margin
X/BM 0.500 inch def	% bottom margin
X
X/PrintLogo /Logo1 def
X/Subline (news pretty printer) def
X/Headline (Article 1 from stdin) def
X/HeaderList [		% begin array:
X   [ (Path: )  (mikros!stefan) ]
X   [ (From: )  (stefan@mikros.systemware.de \(Stefan Stapelberg\)) ]
X   [ (Newsgroups: )  (dnet.general) ]
X   [ (Subject: )  (news pretty printer) ]
X   [ (Date: )  (16 Aug 88 15:48:14 GMT) ]
X   [ (Message-ID: )  (<317@mikros.systemware.de>) ]
X   [ (Reply-To: )  (stefan@mikros.UUCP \(Stefan Stapelberg\)) ]
X   [ (Distribution: )  (dnet) ]
X   [ (Organization: )  (MIKROS Systemware, Lohr/W-Germany) ]
X   [ (Lines: )  (22) ]
X   [ (Summary: )  (Wer testet mit?) ]
X ] def
X1 InitPage PrintHeader
X1 Newline
X(Moin Gemeinde,)
X   PrintText  2 Newline
X(ich habe einen vorlaeufigen  Release meines "News Pretty Printer")
X   PrintText  1 Newline
X(fertig und suche noch begeisterte Mit-Tester.)
X   PrintText  2 Newline
X(Das Programm druckt Artikel auf einem PostScript-Laserdrucker und)
X   PrintText  1 Newline
X(funktioniert soweit schon zufriedenstellend. Bevor ich das Geraet)
X   PrintText  1 Newline
X(nun in den sources-Gruppen poste,  wuerde ich gerne vorher einige)
X   PrintText  1 Newline
X(Verbesserungen vornehmen  und insbesondere auf  die verschiedenen)
X   PrintText  1 Newline
X(UNIX-Systeme anpassen. Bisher laeuft  es unter SINIX \(fuer dieje-)
X   PrintText  1 Newline
X(nigen, die das nicht kennen:  ein bischen BSD, ein bischen V7 und)
X   PrintText  1 Newline
X(etwas System V, aber immer grossen und ganzen doch eher SIII :-\).)
X   PrintText  2 Newline
X(Jemand lustig?)
X   PrintText  2 Newline
X(Gruesse, Stefan)
X   PrintText  2 Newline
X(--)
X   PrintText  1 Newline
X(MIKROS Systemware       stefan@mikros.UUCP, {uunet,mcvax}!unido!mikros!stefan)
X   PrintText  1 Newline
X(Stefan Stapelberg       stefan@mikros.systemware.de, stefan@ira.uka.de)
X   PrintText  1 Newline
X(Phone +49 9352 5948     ^D: These are my employer's opinions - you wonder why?)
X   PrintText  
XEndText
X%Trailer
END_OF_example.ps
if test 8076 -ne `wc -c <example.ps`; then
    echo shar: \"example.ps\" unpacked with wrong size!
fi
# end of overwriting check
fi
if test -f npr.1 -a "${1}" != "-c" ; then 
  echo shar: Will not over-write existing file \"npr.1\"
else
echo shar: Extracting \"npr.1\" \(3511 characters\)
sed "s/^X//" >npr.1 <<'END_OF_npr.1'
X.TH NPR 1
X.\"@(#)npr.1	1.2 (Mikros) 88/08/16
X.SH NAME
Xnpr \- news pretty printer
X.SH SYNTAX
X.B npr
X[\fB-{pP}\fP \fIprolog\fP]
X[\fB-i\fP \fIident\fP]
X[\fB-h\fP \fItitle\fP]
X[\fB-H\fP \fIhlist\fP]
X[\fB-f\fP \fIfont\fP]
X[\fB-s\fP \fIsize\fP]
X[\fIfile ...\fP]
X.SH DESCRIPTION
X.B Npr
Xproduces PostScript output which can be used to print news articles on
Xappropriate laser printers.
X.B Npr
Xreads the named files and looks for header lines found in news articles.
XThere may be one or more files and each file may contain one or more articles.
XThe headers will be printed separated from the text.
XThe text itself may be printed in any font and size you like.
X.LP
X.B Npr
Xonly starts printing articles, if it recognizes correct headers.
XCurrently the formats of articles saved from a
X.I rn(1)
Xsession will be understood by
X.B npr
Xas well as articles directly feeded into
X.B npr
Xvia stdin.
X.LP
XYou may supress printing of individual headers by giving the option
X.B -H
Xand a header list.
X.SH PARAMETER
X.TP 12
X\fB-p\fP \fIprolog\fP
XUse the file
X.I prolog
Xinstead of the standard PostScript prologue file.
XNormally, the location for the standard prologue file is
X.I /usr/local/lib/npr.prologue
X(Your system manager may have changed this default).
XSpecifying
X.B -p
Xwill cause
X.B npr
Xto look in the current directory, while
X.B -P
Xwill cause
X.B npr
Xto look in both the current directory and in the directory
Xwhere the standard prologue file resides.
X.TP 12
X\fB-i\fP \fIident\fP
XSpecifies the indentation from the left margin in inches.
XThe default indentation is set in the prologue file.
X.TP 12
X\fB-h\fP \fItitle\fP
XPrint the string
X.I title
Xinstead of the "Subject" line from the article at the top of each page.
XIf the article does not contain a "Subject" line and this option is not
Xgiven, then your login name and the current date will be printed.
X.TP 12
X\fB-H\fP \fIhlist\fP
XSupress or print headers from the
X.I headerlist.
XThe format of the
X.I headerlist
Xmay be
X.I -field
Xto supress the given field, and
X.I +field
Xto print the given field (e.g. if it is suppressed by default).
XBe sure to quote blanks between two or more fields.
XAn example for supressing the Path-, Message-ID-, and Approved-fields:
X.RS 20
X.B -H '-Path: -Message-ID: -Approved:'
X.RE
X.TP 12
X\fB-f\fP \fIfont\fP
XUse
X.I font
Xinstead of the standard font for printing text.
XNormally, the standard font (as defined in the prologue file)
Xis the monospaced Courier font.
XYou can specify almost all fonts which are supplied by your
Xlaser printer.
X.TP 12
X\fB-s\fP \fIsize\fP
XPrint text in size
X.I size
Xinstead of in the standard size defined in the prologue file.
XBecause
X.B npr
Xdoes not do any formatting, you can use all available font sizes.
X.TP 12
X\fIfile\fP
XOne or more names of the files to be processed.
XIf a file does not contain valid headers (or \fBnpr\fP does not realize
Xthis headers :-) a warning will be given and the processing of the
Xremaining files will be continued.
XIf no file is given,
X.B npr
Xreads the standard input.
X.sp
X.LP
XAll the parameters listet above may be given in the environment variable
X.B NPROPT.
XHowever, the parameters given in the command line have higher
Xpreceedence than the parameters set in this variable.
X.SH FILES
X.TP
X/usr/local/lib/npr.prologue
XPostScript prologue to define required vocabulary for news printing.
X.SH AUTHOR
XStefan Stapelberg <stefan@mikros.uucp>
X.SH NOTES
XIn the current (preliminary) version
X.B npr
Xwill silently supress unknown headers.
XThis may be subject of change in the future.
X.SH BUGS
XSure.
END_OF_npr.1
if test 3511 -ne `wc -c <npr.1`; then
    echo shar: \"npr.1\" unpacked with wrong size!
fi
# end of overwriting check
fi
if test -f npr.c -a "${1}" != "-c" ; then 
  echo shar: Will not over-write existing file \"npr.c\"
else
echo shar: Extracting \"npr.c\" \(23788 characters\)
sed "s/^X//" >npr.c <<'END_OF_npr.c'
X#ifndef lint
Xstatic char sccsid[] = "@(#)npr.c	1.2.1.2 (Mikros) 88/08/24";
X#endif
X
X/*
X * npr - news pretty printer
X *
X * This program is similar to the mail pretty printer, which
X * recently flows on the net. It will pretty print news articles
X * on a PostScript laser-printer. 77% of this software has been
X * published with other software (so as the header functions
X * comes from the news software distribution), 22% are my own
X * work and 1% may be Bugs :-)
X *
X * Written (w) 1988 by Stefan Stapelberg, stefan@mikros.uucp
X *
X ***************************************************************
X *
X * SCCS CONTROL BLOCK
X * MODULE:       npr.c
X * TYPE:         
X * VERSION:      1.2.1.2
X * LAST CHANGED: 18:10:59 88/08/24
X * RETRIEVED:    18:36:02 88/08/24
X *
X ***************************************************************
X *
X * Modification History
X *
X *	88/08/18	<stefan@mikros>
X *		Fixed -h flag, which ignores given header title
X *
X *	88/08/18	<bernd@actisb>
X *		Fixed DocumentFont-comment, made work
X *		on 4.3BSD and SYS V R2/R3
X *
X *	88/08/24	<stefan@mikros>
X *		Misc cleanup
X *
X */
X
X#include <stdio.h>
X#include <ctype.h>
X#include <sys/types.h>
X#include <pwd.h>
X#include <time.h>
X
X#ifdef BSD
X#include <strings.h>
X#define strchr	index
X#define strrchr	rindex
X#else /* !BSD */
X#ifdef SYSV
X#include <string.h>
X#else /* !BSD && !SYSV */
Xextern char *strcpy(), *strncpy();
Xextern char *strcat(), *strncat();
Xextern char *strchr(), *strrchr();
Xextern char *malloc(), *getenv();
X#endif /* !SYSV */
X#endif /* !BSD */
X
X#include "npr.h"		/* local definitions */
X
X#define LMARG	 0.75		/* left margin at 0.75 inch */
X#define RMARG	 7.75		/* right margin at 7.75 inch */
X#define BMARG	 0.5		/* bottom margin at 0.5 inch */
X#define TMARG	11.0		/* top margin at 11 inch */
X
X#define LOGOS	4		/* highest logo number (starting from 0) */
X
X#define POINT(inch)	((int)(inch * 72.0))	/* convert inches to points */
X
Xstatic void syserr(), prterr();
X
X/*
X * global variables
X */
X
Xstatic char usage[] = "Usage:\n \
X  %s [-p prolog] [-h title] [-H-field +field] [-f font] [-s size] [file ...]\n";
X
Xstatic char *progname = NULL;		/* program's name */
Xstatic char *username = NULL;		/* user's name */
Xstatic char *textfont = NULL;		/* default text font */
Xstatic char *headline = NULL;		/* user setable headline */
Xstatic char *profile = PRODEF;		/* file containing PS prologue */
Xstatic char *curfile = NULL;		/* current file name */
Xstatic char *artid = NULL;		/* local article number */
Xstatic char *fonts[10];			/* font definitions from prologue */
X
Xstatic int textsize = 10;		/* default text font size */
Xstatic int dirlookup = 1;		/* directory lookup for prologue file */
Xstatic int newline = 0;			/* accumulated newlines */
Xstatic int mailbox = 0;			/* set if mbox.saved */
Xstatic int artno = 0;			/* article sequence number */
Xstatic int fontidx = 0;			/* index into font definition list */
X
Xstatic double lmarg = LMARG;		/* left margin (indent) */
X
Xstatic int ismbox(), isnorm();		/* this are the header functions */
Xstatic int isfrom(), ishead();
Xstatic int isnewl(), other();
X
Xstatic void setmbox(), setnorm();	/* this are the header actions */
Xstatic void setfrom(), sethead();
Xstatic void prtext(), prhead();
X
Xextern char *fgets(), *hfgets();
X
Xenum STATE { CHECK, HEADER, TEXT };
X
Xstatic struct {
X	enum STATE oldstate;		/* state */
X	int (*cond)();			/* condition */
X	void (*fct)();			/* action */
X	enum STATE newstate;		/* new state */
X	char *(*nextline)();		/* get next line */
X} automat[] = {
X/* old state	condition	action		newstate	nextline */
X { CHECK,	ismbox,		setmbox,	CHECK,		fgets  },
X { CHECK,	isnorm,		setnorm,	CHECK,		fgets  },
X { CHECK,	isfrom,		setfrom,	HEADER,		hfgets },
X { CHECK,	isnewl,		prtext,		CHECK,		fgets  },
X { CHECK,	other,		prtext,		TEXT,		fgets  },
X { HEADER,	ishead,		sethead,	HEADER,		hfgets },
X { HEADER,	other,		prhead,		TEXT,		fgets  },
X { TEXT,	isnewl,		prtext,		CHECK,		fgets  },
X { TEXT,	other,		prtext,		TEXT,		fgets  }
X};
X
Xstatic struct header headtab[] = {
X { "Path: ",		NULL,	MIXED },
X { "From: ",		NULL,	MIXED },
X { "Newsgroups: ",	NULL,	MIXED },
X { "Subject: ",		NULL,	MIXED },
X { "Date: ",		NULL,	MIXED },
X { "Date-Received: ",	NULL,	MIXED },
X { "Received: ",	NULL,	MIXED },
X { "Expires: ",		NULL,	MIXED },
X { "Article-I.D.: ",	NULL,	MIXED },
X { "Message-ID: ",	NULL,	MIXED },
X { "Reply-To: ",	NULL,	MIXED },
X { "References: ",	NULL,	MIXED },
X { "Control: ",		NULL,	MIXED },
X { "Sender: ",		NULL,	MIXED },
X { "Followup-To: ",	NULL,	MIXED },
X { "Distribution: ",	NULL,	MIXED },
X { "Organization: ",	NULL,	MIXED },
X { "Lines: ",		NULL,	MIXED },
X { "Summary: ",		NULL,	MIXED },
X { "Keywoards: ",	NULL,	MIXED },
X { "Approved: ",	NULL,	MIXED },
X { "Nf-ID: ",		NULL,	HIDE  },
X { "Nf-From: ",		NULL,	HIDE  },
X { "Supersedes: ",	NULL,	HIDE  },
X { "Xref: ",		NULL,	HIDE  },
X { "Xpath: ",		NULL,	HIDE  },
X { "Posting-Version: ",	NULL,	HIDE  },
X { "Relay-Version: ",	NULL,	HIDE  }
X};
X
X
X
Xmain(argc, argv)
Xint argc;
Xchar *argv[];
X{
X	extern char *getenv();
X	extern void srand();
X	int setopt(), vstrip();
X	int prologue();
X	void printnews();
X
X	char *ep = NULL;		/* ptr to environment variable */
X	char *optv[50];			/* array of ptrs to options */
X	int optc;			/* no of broken down fields in optv */
X	int fc = 0;			/* no of cmd line args */
X	int rc = 0;			/* contains exit code */
X	FILE *fp, *fopen();
X
X
X	progname = argv[0];		/* save program name */
X	srand(getpid());		/* initialize random generator */
X
X	/* get options from environment variable */
X	if ((ep = getenv("NPROPT")) != NULL) {
X		optv[0] = progname;
X		optc = vstrip(ep, optv+1, TABSIZE(optv)-1);
X		if (optc++ > 0 && setopt(optc, optv) == 0)
X			rc++;
X	}
X
X	/* get options from command line */
X	if ((fc = setopt(argc, argv)) == 0)
X		rc++;
X
X	if (rc) {
X		fprintf(stderr, usage, progname);
X		exit(rc);
X	}
X
X	/* print prologue file */
X	if (rc = prologue())
X		exit(rc);
X
X	/* finally print news */
X	if (fc == argc) {
X		curfile = "stdin";
X		printnews(stdin);
X	} else for (argv += fc; *argv != NULL; argv++) {
X		if ((fp = fopen(*argv, "r")) == NULL) {
X			syserr("Can't open `%s'", *argv);
X			rc++;
X			continue;
X		}
X		curfile = *argv;
X		printnews(fp);
X		fclose(fp);
X	}
X	printf("%%%%Trailer\n");
X	printf("%%%%DocumentFonts:");
X	while (fontidx && fonts[--fontidx] != NULL)
X		printf(" %s", fonts[fontidx]);
X	putchar('\n');
X
X	exit(rc);
X}
X
X
Xstatic int prologue()
X{
X	extern char *getlogin();
X	char *strsave();
X	char *strfind();
X	char *strback();
X	char *expand();
X
X	char lbuf[LBUFLEN];			/* line buffer */
X	char tbuf[BUFLEN];			/* temp buffer */
X	char *p, *p1;				/* pointer into buffer */
X
X	FILE *fp, *fopen();			/* file ptr prologue file */
X	struct passwd *pw, *getpwuid();		/* user's real name */
X
X	username = getlogin();		/* get user's name */
X	if (username == NULL || *username == '\0') {
X		if ((pw = getpwuid(getuid())) == NULL) {
X			prterr("Cannot get user's name");
X			return 1;
X		}
X		username = pw->pw_name;
X	}
X
X	/* open prologue file, print it */
X	if ((fp = fopen(profile, "r")) == NULL && dirlookup && *profile != '/') {
X		sprintf(tbuf, "%s/%s", PRODIR, profile);
X		fp = fopen(tbuf, "r");
X	}
X
X	if (fp == NULL) {
X		prterr("Can't open prologue file `%s'", profile);
X		return 1;
X	}
X
X	printf("%%!PS-Adobe-1.0\n");
X	printf("%%%%Title: USENET News\n");
X	printf("%%%%Creator: npr by Stefan Stapelberg\n");
X	printf("%%%%CreationDate: %s\n", sccsid);
X	printf("%%%%BoundingBox: %d %d %d %d\n",
X		POINT(lmarg), POINT(BMARG), POINT(RMARG), POINT(TMARG));
X	printf("%%%%For: %s\n", username);
X	printf("%%%%DocumentFonts: (atend)\n");
X	printf("%%%%Pages: (atend)\n");
X	printf("%%%%EndComments\n\n");
X
X	while (fgets(lbuf, sizeof lbuf, fp) != NULL) {
X		if ((p=strfind(lbuf,"findfont")) && (p=strback(lbuf,p,'/')) &&
X		    (p1=strchr(p,' '))) {
X			strncpy(tbuf,p+1,p1-p-1);
X			tbuf[p1-p-1] = '\0';
X			fonts[fontidx++] = strsave(tbuf);
X		}
X		fputs(lbuf, stdout);
X	}
X	fclose(fp);
X
X	printf("/LM %3.3f inch def\t%% left margin\n", lmarg);
X	printf("/RM %3.3f inch def\t%% right margin\n", RMARG);
X	printf("/TM %3.3f inch def\t%% top margin\n", TMARG);
X	printf("/BM %3.3f inch def\t%% bottom margin\n\n", BMARG);
X
X	if (textfont != NULL) {
X		printf("/Textfont /%s findfont %d scalefont bind def\n", textfont, textsize);
X		printf("/nldist %d def\t%% text nl distance\n", textsize+1);
X	}
X
X	printf("%%%%EndProlog\n\n");
X
X	return 0;
X}
X
X
Xstatic void printnews(fp)
XFILE *fp;
X{
X	extern char *hfgets(), *expand();
X
X	char lbuf[LBUFLEN];		/* line buffer */
X	enum STATE state = CHECK;	/* current state */
X	int i;
X
X
X	if (hfgets(lbuf, sizeof lbuf, fp) == NULL) {
X		prterr("Premature EOF on %s", curfile);
X		return;
X	}
X
X	do {
X		for (i=0; i < TABSIZE(automat); i++)
X			if (state == automat[i].oldstate &&
X			    (*automat[i].cond)(lbuf)) {
X				(*automat[i].fct)(lbuf);
X				state = automat[i].newstate;
X				break;
X			}
X		if (i == TABSIZE(automat)) {
X			prterr("Error in automaton - state %d", state);
X			return;
X		}
X	} while ((*automat[i].nextline)(lbuf, sizeof lbuf, fp) != NULL);
X
X	if (artno > 0)
X		printf("\nEndText\n");
X	else
X		prterr("No articles found in %s\n", curfile);
X
X	return;
X}
X
X
X/*
X * ismbox - check for mailbox saved style.
X *	This is indicated by a line like
X *		"From user date",
X *	so we just look for "From "
X */
X
Xstatic int ismbox(p)
Xchar *p;
X{
X	return(isalpha(*p) && PREFIX(p, "From "));
X}
X
X/*
X * isnorm - check for norm saved style.
X *	This is indicated by a line like
X *		"Article num of news.group:"
X *	Lets look for the colon terminating the
X *	line, and the prefix "Article "
X */
X
Xstatic int isnorm(p)
Xchar *p;
X{
X	char *colon = strchr(p, ':');
X	return(colon && *(colon+1) == '\n' && PREFIX(p, "Article "));
X}
X
X/*
X * isfrom - check for interactive saved style.
X *	Lines are beginning with "From: " or "Path: "
X *	We must take into account, that mbox.saved news
X *	has a ">From: " line rather than "From: "
X */
X
Xstatic int isfrom(p)
Xchar *p;
X{
X	if (!ishead(p))
X		return 0;
X	
X	if (mailbox && *p == '>')
X		p++;
X
X	if (PREFIX(p, "From: ") || PREFIX(p, "Path: "))
X		return 1;
X
X	return 0;
X}
X
X/*
X * ishead - check for header line. These are lines with
X *	a colon followed by a space and an optional text.
X */
X
Xstatic int ishead(p)
Xchar *p;
X{
X	char *colon = strchr(p, ':');
X	char *space = strchr(p, ' ');
X
X	return(colon && space && colon < space);
X}
X
X/*
X * isnewl - check for line containing only a newline character.
X */
X
Xstatic int isnewl(p)
Xchar *p;
X{
X	return(*p == '\n');
X}
X
X/*
X * other - dummy function always returning TRUE
X */
X
Xstatic int other(p)	/* ARGSUSED */
Xchar *p;
X{
X	return 1;
X}
X
X/*
X * setmbox - set mailbox variable to indicate stupid
X *	mbox.saved style.  We later have to look for
X *	a ">From: " header rather than just "From: "
X */
X
Xstatic void setmbox(p)	/* ARGSUSED */
Xchar *p;
X{
X	mailbox = 1;
X	return;
X}
X
X/*
X * setnorm - save article number for later usage.
X */
X
Xstatic void setnorm(p)	/* ARGSUSED */
Xchar *p;
X{
X	static char ident[BUFLEN];
X
X	(void) nstrip(p);
X	ident[0] = '\0';
X	artid = strncpy(ident, p, sizeof ident-1);
X	return;
X}
X
X/*
X * setfrom - initialize header table.
X *	Insert from/path header.
X */
X
Xstatic void setfrom(p)	/* ARGSUSED */
Xchar *p;
X{
X	void sethead();
X
X	int i;
X
X	/* clear table */
X	for (i=0; i < TABSIZE(headtab); i++) {
X		if (headtab[i].h_string != NULL) {
X			(void) free(headtab[i].h_string);
X			headtab[i].h_string = NULL;
X		}
X	}
X
X	sethead(p);
X	return;
X}
X
X/*
X * sethead - insert header into header table.
X */
X
Xstatic void sethead(p)	/* ARGSUSED */
Xchar *p;
X{
X	char *getfield();
X	int i, type();
X
X	if (mailbox && *p == '>')
X		p++;
X
X	if ((i = type(p)) < 0)		/* unknown headers are thrown away */
X		return;
X	
X	if (headtab[i].h_string == NULL)
X		headtab[i].h_string = getfield(p);
X	return;
X}
X
X/*
X * prhead - print collected header, if the entry
X *	collected so far is valid
X */
X
Xstatic void prhead(p)	/* ARGSUSED */
Xchar *p;
X{
X	extern char *ctime();
X	extern int rand();
X	extern long time();			/* know C :-) */
X
X	char *expand();
X	int isfield(), type();
X
X	char tbuf[BUFLEN];
X	int i;
X	long curtim;
X
X
X	if (!(isfield("From: ") || isfield("Path: ")) ||
X	     !isfield("Date: ") || !isfield("Message-ID: ")) {
X		prterr("Invalid header lines in %s", curfile);
X		return;
X	}
X	
X	if (++artno > 1)
X		printf("\nEndText\n\n");
X
X	printf("/PrintLogo /Logo%d def\n", rand() % LOGOS);
X
X	printf("/Headline ");
X	if (headline != NULL) {
X		printf("(%s) ", expand(headline));
X	} else if (artid != NULL) {
X		printf("(%s) ", expand(artid));
X		artid = NULL;
X	} else {
X		printf("(Article %d from %s) ", artno, curfile);
X	}
X	printf("def\n");
X
X	if ((i = type("Subject: ")) >= 0 && headtab[i].h_string != NULL) {
X		printf("/Subline (%s) def\n", expand(headtab[i].h_string));
X	} else {
X		curtim = time((long *)0);
X		(void) sprintf(tbuf, "Printed for %s, %s",
X		     username, ctime(&curtim));
X		(void) nstrip(tbuf);
X		printf("/Subline (%s) def\n", expand(tbuf));
X	}
X
X	/* print header of article */
X	printf("/HeaderList [\t\t%% begin array:\n");
X
X	for (i=0; i < TABSIZE(headtab); i++)
X		if (headtab[i].h_display && headtab[i].h_string) {
X			printf("   [ (%s) ", expand(headtab[i].h_prefix));
X			printf(" (%s) ]\n", expand(headtab[i].h_string));
X		}
X
X	printf(" ] def\n");
X
X	printf("%%%%Page 1 1\n");
X	printf("1 InitPage PrintHeader\n");
X
X	return;
X}
X
X/*
X * prtext - print ordinary text line, but
X *	only if we are inside of an article
X */
X
Xstatic void prtext(p)	/* ARGSUSED */
Xchar *p;
X{
X	void tflush();
X	char *expand();
X
X	if (artno == 0)		/* no current article */
X		return;
X	
X	if (*p != '\n') {
X		tflush();
X		(void) nstrip(p);
X		printf("(%s)\n   PrintText  ", expand(p));
X	}
X	newline++;
X
X	return;
X}
X
X
Xstatic int setopt(ac, av)
Xint ac;
Xchar *av[];
X{
X	extern char *optarg;
X	extern int optind;
X	extern int getopt();
X	extern double atof();
X	void headign();
X
X	int c, rc = 0;
X
X	optind = 1;
X	while ((c = getopt(ac, av, "h:H:i:f:s:p:P:")) != EOF) {
X		switch (c) {
X		   case 'P':		/* look for file in PRODIR also */
X		   case 'p':		/* look for file in current dir only */
X			dirlookup = isupper(c) ? 1 : 0;
X			if ((profile = optarg) == NULL || *profile == '\0')
X				rc++;
X			break;
X		   case 'i':
X			if ((lmarg = atof(optarg)) < 0.25 || lmarg > 5.0)
X				lmarg = LMARG;
X			break;
X		   case 'f':
X			textfont = optarg;
X			if (*textfont == '/')
X				textfont++;
X			break;
X		   case 'h':
X			headline = optarg;
X			break;
X		   case 'H':
X			headign(optarg);
X			break;
X		   case 's':
X			if ((textsize = atoi(optarg)) < 1 || textsize > 20)
X				textsize = 10;
X			break;
X		   default:
X			rc++;
X			break;
X		}
X	}
X	return(rc ? 0 : optind);
X}
X
Xstatic void headign(l)
Xchar *l;
X{
X	char tmpbuf[NAMELEN];
X	char *p = l;
X	int i, type();
X
X	do {
X		while (*p != '\0' && *p != ' ' && *p != '\t')
X			p++;
X		
X		if (*p != '\0')
X			*p++ = '\0';
X		
X		if (p-l > 2) {
X			(void) sprintf(tmpbuf, "%s ", l+1);
X			if ((i = type(tmpbuf)) >= 0) {
X				switch (*l) {
X				  case '-':	headtab[i].h_display = HIDE;
X						break;
X				  case '+':	headtab[i].h_display = MIXED;
X						break;
X				  case '*':	headtab[i].h_display = BOLD;
X						break;
X				}
X			}
X		}
X		l = p;
X	} while (*l != '\0');
X
X	return;
X}
X
X
Xstatic void tflush()
X{
X	if (newline) {
X		printf("%d Newline\n", newline);
X		newline = 0;
X	}
X	return;
X}
X
X
X#define SPACEFOR(count)	((tp - tmpbuf) < (sizeof(tmpbuf) - count))
X#define TABSTOP		8
X
Xstatic char *expand(s)
Xchar *s;
X{
X	static char tmpbuf[LBUFLEN];
X	char c, *tp = tmpbuf;
X	int overflow = 0;
X	int n, col = 0;
X
X	if (s == NULL) {
X		strcpy(tmpbuf, "(null)");
X		return((char *)tmpbuf);
X	}
X
X	while (!overflow && (c = *s++) != '\0') {
X		switch (c) {
X		   case '\\':
X		   case '(':
X		   case ')':
X			if (SPACEFOR(2)) {
X				*tp++ = '\\';
X				*tp++ = c;
X				col++;
X			} else
X				overflow++;
X			break;
X		   case '\t':
X			n = (col > 0) ? TABSTOP - (col % TABSTOP) : TABSTOP;
X			if (SPACEFOR(n)) {
X				while (n-- > 0) {
X					*tp++ = ' ';
X					col++;
X				}
X			} else
X				overflow++;
X			break;
X		    case '\n':
X		    case '\b':
X		    case '\f':
X		    case '\r':
X			if ((col = (c == '\b') ? col-1 : 0) < 0)
X				col = 0;
X			if (SPACEFOR(2)) {
X				*tp++ = '^';
X				*tp++ = c + '@';
X			}
X			break;
X		    default:
X			if (SPACEFOR(1)) {
X				*tp++ = c;
X				col++;
X			} else
X				overflow++;
X			break;
X		}
X	}
X	*tp = '\0';
X
X	return (char *)tmpbuf;
X}
X
Xstatic int vstrip(from, av, len)
Xchar *from, *av[];
Xint len;
X{
X	static char lbuf[LBUFLEN];
X	char c, quote = '\0';
X	char *to = lbuf;
X	int inword = 0;
X	int i = 0;
X
X	av[i] = lbuf;
X
X	while ((c = *from++) != '\0'
X	    && i < (len - 1) && (to - lbuf) < (sizeof lbuf - 1)) {
X		switch (c) {
X		   case '"':
X		   case '\'':
X		   case '\\':
X			if (quote != '\\' && (quote == '\0' || quote == c)) {
X				quote = (quote == '\0' ? c : '\0');
X				break;
X			}
X		   case ' ':
X		   case '\t':
X			if (quote == '\0') {
X				if (inword) {
X					*to++ = '\0';
X					av[++i] = to;
X					inword = 0;
X				}
X				break;
X			}
X		   default:
X			*to++ = c;
X			inword = 1;
X			if (quote == '\\')
X				quote = '\0';
X			break;
X		}
X	}
X
X	if (inword) {
X		*to = '\0';
X		i++;
X	}
X	av[i] = NULL;
X
X	return i;
X}
X
X
X/*
X * syserr --	prints system error messages.
X *		Assumes that command name has been
X *		assigned to variable `progname'.
X */
X
Xstatic void syserr(m1, m2, m3)	/*VARARGS*/
Xchar *m1, *m2, *m3;
X{
X	extern int errno, sys_nerr;
X	extern char *sys_errlist[];
X
X	if (progname)
X		fprintf(stderr, "%s: ", progname);
X
X	fprintf(stderr, m1, m2, m3);
X
X	fprintf(stderr, " (%d", errno);		/* generate error message */
X	if(errno > 0 && errno < sys_nerr)
X		fprintf(stderr, ": %s)", sys_errlist[errno]);
X	else
X		fputc(')', stderr);
X
X	fputc('\n', stderr);
X	return;
X}
X
X/*
X * prterr --	prints error messages.
X *	Assumes that command name has been
X *	assigned to variable `progname'.
X */
X
Xstatic void prterr(m1, m2, m3)	/*VARARGS*/
Xchar *m1, *m2, *m3;
X{
X	if (progname)
X		fprintf(stderr, "%s: ", progname);
X
X	fprintf(stderr, m1, m2, m3);
X	fputc('\n', stderr);
X
X	return;
X}
X
X
Xstatic int isfield(field)
Xchar *field;
X{
X	int i = type(field);
X	return (i < 0) || (headtab[i].h_string == NULL) ? FALSE : TRUE;
X}
X
Xstatic char *strsave(str)
Xchar *str;
X{
X	extern char *malloc();
X	char *p = malloc(strlen(str) + 1);
X
X	return (p == NULL) ? p : strcpy(p, str);
X}
X
Xstatic char *strfind(s1, s2)
Xchar *s1, *s2;
X{
X	int l1 = strlen(s1);
X	int l2 = strlen(s2);
X
X	while (l1 >= l2 && strncmp(s1, s2, l2)) {
X		l1--;
X		s1++;
X	}
X	return l1 >= l2 ? s1 : NULL;
X}
X
Xstatic char *strback(s, s1, c)
Xchar *s, *s1;
Xchar c;
X{
X	while (s1 > s && *s1 != c)
X		s1--;
X	return *s1 == c ? s1 : NULL;
X}
X
X
X/*
X * Get the given field of a header (char * parm) from bfr,
X * but only if there's something actually there (after the colon).
X */
X
Xstatic char *getfield(bp)
Xchar *bp;
X{
X	char *strsave();
X	char *p = strchr(bp, ':');
X
X	if (p == NULL || *++p != ' ')
X		return NULL;
X
X	for (++p; isspace(*p); p++)
X		;
X	
X	if (*p == '\0')
X		return NULL;
X	
X	(void) nstrip(p);
X	return strsave(p);
X}
X
X
Xstatic int type(p)
Xchar *p;
X{
X	char *colon, *space;
X	int i;
X
X	if (p == NULL || *p == '\0')
X		return -1;
X
X	colon = strchr(p, ':');
X	space = strchr(p, ' ');
X
X	if (!colon || space && space < colon)
X		return -1;
X
X	for (i = 0; i < TABSIZE(headtab); i++) {
X		if (PREFIX(p, headtab[i].h_prefix))
X			break;
X	}
X
X	if (i == TABSIZE(headtab))
X		return -1;
X
X	return i;
X}
X
X/*
X * hfgets is like fgets, but deals with continuation lines.
X * It also ensures that even if a line that is too long is
X * received, the remainder of the line is thrown away
X * instead of treated like a second line.
X */
X
Xstatic char *hfgets(buf, len, fp)
Xchar *buf;
Xint len;
XFILE *fp;
X{
X	int c;
X	int n = 0;
X	char *cp;
X
X	cp = buf;
X	while (n < len && (c = getc(fp)) != EOF) {
X		if (c == '\n')
X			break;
X		if (isprint(c) || c == '\b' || c == ' ' || c == '\t') {
X			*cp++ = c;
X			n++;
X		}
X	}
X	if (c == EOF && cp == buf)
X		return NULL;
X	*cp = '\0';
X
X	if (c != '\n') {
X		/* Line too long - part read didn't fit into a newline */
X		while ((c = getc(fp)) != '\n' && c != EOF)
X			;
X	} else if (cp == buf) {
X		/* Don't look for continuation of blank lines */
X		*cp++ = '\n';
X		*cp = '\0';
X		return buf;
X	}
X
X	while ((c = getc(fp)) == ' ' || c == '\t') {	/* for each cont line */
X		/* Continuation line. */
X		while ((c = getc(fp)) == ' ' || c == '\t')
X			;
X		if (c == '\n')
X			continue;
X
X		if (n++ < len)
X			*cp++ = ' ';
X		do {
X			if ((isprint(c) || c == '\b' || c == ' ' || c == '\t')
X				&& n++ < len)
X				*cp++ = c;
X		} while ((c = getc(fp)) != '\n' && c != EOF);
X	}
X	if (n >= len - 1)
X		cp = buf + len - 2;
X	*cp++ = '\n';
X	*cp = '\0';
X	if (c != EOF)
X		(void) ungetc(c, fp); /* push back first char of next header */
X	return buf;
X}
X
X
X/*
X * auxiliary functions
X * most of this code comes from the network.
X */
X
X
X/*
X * Strip trailing newlines, blanks, and tabs from 's'.
X * Return TRUE if newline was found, else FALSE.
X */
X
Xstatic int nstrip(s)
Xchar *s;
X{
X	char *p;
X	int rc;
X
X	rc = FALSE;
X	p = s;
X	while (*p)
X		if (*p++ == '\n')
X			rc = TRUE;
X	while (--p >= s && (*p == '\n' || *p == ' ' || *p == '\t'))
X		;
X	*++p = '\0';
X	return rc;
X}
X
X/* From UC Berkeley @(#)strcasecmp.c	1.3 (Berkeley) 8/3/87 */
X
X/*
X * This array is designed for mapping upper and lower case letter
X * together for a case independent comparison.  The mappings are
X * based upon ascii character sequences.
X */
Xchar charmap[] = {
X	'\000', '\001', '\002', '\003', '\004', '\005', '\006', '\007',
X	'\010', '\011', '\012', '\013', '\014', '\015', '\016', '\017',
X	'\020', '\021', '\022', '\023', '\024', '\025', '\026', '\027',
X	'\030', '\031', '\032', '\033', '\034', '\035', '\036', '\037',
X	'\040', '\041', '\042', '\043', '\044', '\045', '\046', '\047',
X	'\050', '\051', '\052', '\053', '\054', '\055', '\056', '\057',
X	'\060', '\061', '\062', '\063', '\064', '\065', '\066', '\067',
X	'\070', '\071', '\072', '\073', '\074', '\075', '\076', '\077',
X	'\100', '\141', '\142', '\143', '\144', '\145', '\146', '\147',
X	'\150', '\151', '\152', '\153', '\154', '\155', '\156', '\157',
X	'\160', '\161', '\162', '\163', '\164', '\165', '\166', '\167',
X	'\170', '\171', '\172', '\133', '\134', '\135', '\136', '\137',
X	'\140', '\141', '\142', '\143', '\144', '\145', '\146', '\147',
X	'\150', '\151', '\152', '\153', '\154', '\155', '\156', '\157',
X	'\160', '\161', '\162', '\163', '\164', '\165', '\166', '\167',
X	'\170', '\171', '\172', '\173', '\174', '\175', '\176', '\177',
X	'\200', '\201', '\202', '\203', '\204', '\205', '\206', '\207',
X	'\210', '\211', '\212', '\213', '\214', '\215', '\216', '\217',
X	'\220', '\221', '\222', '\223', '\224', '\225', '\226', '\227',
X	'\230', '\231', '\232', '\233', '\234', '\235', '\236', '\237',
X	'\240', '\241', '\242', '\243', '\244', '\245', '\246', '\247',
X	'\250', '\251', '\252', '\253', '\254', '\255', '\256', '\257',
X	'\260', '\261', '\262', '\263', '\264', '\265', '\266', '\267',
X	'\270', '\271', '\272', '\273', '\274', '\275', '\276', '\277',
X	'\300', '\341', '\342', '\343', '\344', '\345', '\346', '\347',
X	'\350', '\351', '\352', '\353', '\354', '\355', '\356', '\357',
X	'\360', '\361', '\362', '\363', '\364', '\365', '\366', '\367',
X	'\370', '\371', '\372', '\333', '\334', '\335', '\336', '\337',
X	'\340', '\341', '\342', '\343', '\344', '\345', '\346', '\347',
X	'\350', '\351', '\352', '\353', '\354', '\355', '\356', '\357',
X	'\360', '\361', '\362', '\363', '\364', '\365', '\366', '\367',
X	'\370', '\371', '\372', '\373', '\374', '\375', '\376', '\377',
X};
X
Xstatic int strcasecmp(s1, s2)
Xregister char *s1, *s2;
X{
X	register char *cm = charmap;
X
X	while (cm[*s1] == cm[*s2++])
X		if (*s1++ == '\0')
X			return 0;
X	return cm[*s1] - cm[*--s2];
X}
X
Xstatic int strncasecmp(s1, s2, n)
Xregister char *s1, *s2;
Xregister int n;
X{
X	register char *cm = charmap;
X
X	while (--n >= 0 && cm[*s1] == cm[*s2++])
X		if (*s1++ == '\0')
X			return 0;
X	return n < 0 ? 0 : cm[*s1] - cm[*--s2];
X}
X
Xstatic int prefix(full, pref)
Xregister char *full, *pref;
X{
X	register char *cm = charmap;
X
X	while (*pref != '\0') {
X		if (cm[*full++] != cm[*pref++])
X			return FALSE;
X	}
X	return TRUE;
X}
X
X
Xstatic void lcase(s)
Xregister char *s;
X{
X	register char *ptr;
X
X	for (ptr = s; *ptr; ptr++)
X		if (isupper(*ptr))
X			*ptr = tolower(*ptr);
X
X	return;
X}
END_OF_npr.c
if test 23788 -ne `wc -c <npr.c`; then
    echo shar: \"npr.c\" unpacked with wrong size!
fi
# end of overwriting check
fi
if test -f npr.h -a "${1}" != "-c" ; then 
  echo shar: Will not over-write existing file \"npr.h\"
else
echo shar: Extracting \"npr.h\" \(1475 characters\)
sed "s/^X//" >npr.h <<'END_OF_npr.h'
X/*
X * npr.h	news pretty printer definitions
X *
X * SCCSID = @(#)npr.h	1.2.1.2 (Mikros) 88/08/24
X */
X
X#ifndef PRODIR			/* where the prologue file may be found */
X# define PRODIR		"/usr/local/lib"
X#endif
X
X#ifndef PRODEF			/* default prologue file */
X# define PRODEF		"npr.prologue"
X#endif
X
X/* End of user configuration section */
X
X#define BUFLEN	256	/* standard buffer size */
X#define LBUFLEN 1024	/* big buffer size */
X#define SBUFLEN 32	/* small buffer size (for system names, etc) */
X
X#define PATHLEN 512	/* length of longest source string */
X#define DATELEN	64	/* length of longest allowed date string */
X#define NAMELEN	128	/* length of longest possible message ID */
X#define NETCHRS	"!:@^%,"/* Punct. chars used for various networks */
X#define TRUE	1	/* boolean true */
X#define FALSE	0	/* boolean false */
X#define NGDELIM	','	/* delimit character in news group line */
X
X#define STRCMP(a,b)  ((*(a) != *(b)) ? (*(a)-*(b)) : strcmp((a)+1, (b)+1))
X#define STRNCMP(a,b,n)  ((*(a) != *(b)) ? (*(a)-*(b)) : strncmp(a, b, n))
Xextern char charmap[];
X#define PREFIX(a,b)  ((charmap[*(a)] != charmap[*(b)]) ? FALSE : prefix((a)+1, (b)+1))
X
X#define TABSIZE(tab)	(sizeof(tab) / sizeof(tab[0]))
X
X/* Article header format */
Xstruct header {
X	char *h_prefix;		/* Field: - prefix */
X	char *h_string;		/* string value */
X	int  h_display;		/* display/ignore flag */
X};
X
X#define HIDE	0		/* do not print this field */
X#define MIXED	1		/* normal print */
X#define BOLD	2		/* boldface print */
X
END_OF_npr.h
if test 1475 -ne `wc -c <npr.h`; then
    echo shar: \"npr.h\" unpacked with wrong size!
fi
# end of overwriting check
fi
if test -f npr.prologue -a "${1}" != "-c" ; then 
  echo shar: Will not over-write existing file \"npr.prologue\"
else
echo shar: Extracting \"npr.prologue\" \(5766 characters\)
sed "s/^X//" >npr.prologue <<'END_OF_npr.prologue'
X%
X% NPR prologue
X% Written (w) 1988 by Stefan Stapelberg
X% @(#)npr.prologue	1.2 (Mikros) 88/08/16
X%
X
X% Font definitions you may want to change.
X% Note: if you change the point size of a font,
X%       you should change vertical spacing also
X%
X/Logofont /Bookman-DemiItalic findfont def		% for Logo, not scaled
X/Headfont /Bookman-Demi findfont 11 scalefont def	% for From:-Header etc.
X/Linefont /Bookman-Light findfont 11 scalefont def	% for From:-Lines etc.
X/Textfont /Courier findfont 10 scalefont def		% normal text font
X
X% vertical spacing
X%
X/nldist 11 def		% text newline distance
X/hldist 12 def		% header newline distance
X
X% don't bother for the rest, things
X% should already working perfectly
X%
X/tident 10 def		% text indent
X/hident 10 def		% header ident (internal only)
X/nstr 5 string def	% string storage
X/inch { 72 mul } def	% convert inch to point
X
X/DrawBox		% stack: boundary box x1,y1 x2,y2
X { /radius 10 def
X   radius sub /uborder exch def		% upper border
X   radius sub /rborder exch def		% right border
X   radius add /dborder exch def		% lower border
X   radius add /lborder exch def		% left border
X
X   newpath
X     lborder radius sub uborder moveto	% draw box
X     lborder dborder radius 180 270 arc
X     rborder dborder radius 270 0 arc
X     rborder uborder radius 0 90 arc
X     lborder uborder radius 90 180 arc
X   closepath
X } def
X
X/Logo0			% print nice logo, version 1
X { gsave
X     Logofont 28 scalefont setfont
X     (NetNEWS) dup /Title exch def		% logo string
X       stringwidth pop /Titlelen exch def	% length of string
X
X     RM 2.5 inch sub TM 0.5 inch sub translate
X     0 0 2.5 inch 0.5 inch DrawBox
X     1.5 setlinewidth stroke
X
X     newpath					% set clipping path
X       2.5 inch Titlelen sub 2 div 9 translate
X       0 0 moveto Title true
X     charpath clip
X
X     newpath					% draw rays
X       Titlelen 2 div -7 translate
X       0.25 setlinewidth
X       0 1.5 179
X       { gsave
X           rotate
X           0 0 moveto 108 0 lineto stroke
X         grestore
X       }for
X
X   grestore
X } def
X
X/Logo1			% print logo, version 2
X { gsave
X     RM 2.5 inch sub TM 0.5 inch sub translate
X     0 0 2.5 inch 0.5 inch DrawBox clip	% set clip path
X
X     Logofont 9 scalefont setfont	% print background
X     newpath
X       0 0.5 inch 7 sub moveto
X       (NEWS ) /Title exch def
X       0.5 setgray
X       { { pop pop currentpoint pop 2.5 inch gt
X	   { currentpoint 9 sub exch pop 0 exch moveto } if } Title kshow
X           currentpoint exch pop -0 lt { exit } if
X       } loop
X
X     Logofont 28 scalefont setfont	% print logo over background
X     newpath
X       (NetNEWS) dup stringwidth pop
X       2.5 inch exch sub 2 div 9 moveto
X       0 setgray show
X
X   grestore
X } def
X
X/Logo2			% print logo, version 3
X { gsave
X     Logofont 28 scalefont setfont
X     (NetNEWS) dup /Title exch def		% logo string
X       stringwidth pop /Titlelen exch def	% length of string
X
X     RM 2.5 inch sub TM 0.5 inch sub translate
X     0 0 2.5 inch 0.5 inch DrawBox
X     1.5 setlinewidth stroke
X
X     newpath
X       2.5 inch Titlelen sub 2 div 5 add 3 translate
X       .95 -.05 0 { setgray 0 0 moveto Title show -1 .5 translate } for
X       1 setgray 0 0 moveto Title show
X
X   grestore
X } def
X
X/Logo3			% print logo, version 4
X { gsave
X     Logofont 28 scalefont setfont
X     (NetNEWS) dup /Title exch def		% logo string
X       stringwidth pop /Titlelen exch def	% length of string
X
X     RM 2.5 inch sub TM 0.5 inch sub translate
X     0 0 2.5 inch 0.5 inch DrawBox
X     0 setgray fill
X
X     newpath					% set clipping path
X     (NetNEWS) dup stringwidth pop
X       2.5 inch exch sub 2 div 0 translate
X       1 setgray 1 1.5 scale 0 -1 moveto show
X
X   grestore
X } def
X
X/Logo4			% print logo, version 5
X { gsave
X     RM 2.5 inch sub TM 0.5 inch sub translate
X     0 0 2.5 inch 0.5 inch DrawBox
X     1.5 setlinewidth stroke
X
X     Logofont 28 scalefont setfont
X     newpath
X       (NetNEWS) dup stringwidth pop
X       2.5 inch exch sub 2 div 9 moveto
X       true charpath 0.5 setlinewidth stroke
X
X   grestore
X } def
X
X
X/PrintHeadline		% print header line at top of each page
X { 1 page eq			% this is first page,
X   { PrintLogo cvx exec		% so draw a logo on it
X     LM TM 0.5 inch sub		% prepare clipping path
X     RM 2.5 inch sub 9 sub TM }	% for rest of header
X   { LM TM 0.5 inch sub RM TM } ifelse
X
X   DrawBox
X   gsave 0.8 setgray fill grestore
X   gsave 1.5 setlinewidth stroke grestore
X   gsave clip
X     Headfont setfont
X     LM tident add TM 28 sub translate
X     newpath
X       0 0 moveto Subline show
X       0 12 moveto Headline show
X     RM LM sub tident 2 mul sub
X     (Page 999) stringwidth pop sub 12 moveto
X     (Page ) show page nstr cvs show
X   grestore
X } def
X
X/InitPage		% stack: pageno
X { /page exch def
X   /ypos TM 0.625 inch sub def
X   PrintHeadline
X   Textfont setfont
X } def
X
X/PrintPage
X { showpage
X   page 1 add InitPage
X   2 Newline
X } def
X
X/Newline		% stack: number of newlines
X { nldist mul ypos exch sub /ypos exch def
X   LM tident add ypos moveto
X   ypos BM lt { PrintPage } if
X } def
X
X/Nextline
X { hldist ypos exch sub /ypos exch def
X   LM hident add ypos moveto
X } def
X
X/PrintField		% stack: [(Headerstring) (Fieldstring)]
X { aload pop exch
X   /hident tident def
X   Nextline Headfont setfont
X   dup stringwidth pop tident add /hident exch def show
X   Linefont setfont
X   { pop pop currentpoint pop RM tident 2 mul sub ge { Nextline } if } exch kshow
X } def
X
X/PrintHeader		% print header array on title page
X { gsave
X     HeaderList { PrintField } forall
X     /ypos ypos 9 sub def
X     LM ypos RM TM 0.6 inch sub DrawBox stroke
X   grestore
X   2 Newline
X } def
X
X/PrintText		% print text, take care of line wrap
X {
X   { pop pop currentpoint pop RM tident sub ge { 1 Newline } if } exch kshow
X } def
X
X/EndText		% ouput last page
X { showpage
X } def
X
END_OF_npr.prologue
if test 5766 -ne `wc -c <npr.prologue`; then
    echo shar: \"npr.prologue\" unpacked with wrong size!
fi
# end of overwriting check
fi
echo shar: End of archive 1 \(of 1\).
cp /dev/null ark1isdone
MISSING=""
for I in 1 ; do
    if test ! -f ark${I}isdone ; then
	MISSING="${MISSING} ${I}"
    fi
done
if test "${MISSING}" = "" ; then
    echo You have unpacked all 1 archives.
    rm -f ark[1-9]isdone
else
    echo You still need to unpack the following archives:
    echo "        " ${MISSING}
fi
##  End of shell archive.
exit 0
