/**** 
 ****   pp  Amiga PagePrint Program
 ****   Version 1.0
 ****/
 
/***
 ***    (C) Copyright 1986  Phil Mercurio (Quicksilver Software)
 ***    All Rights Reserved
 ***
 ***    This software is released as a shareware product.  It may
 ***    be copied providing that no charge is made to the recipient
 ***    and that this copyright notice remains intact.
 ***
 ***    If you use and find value in this software, please send $10
 ***    to the author at this address:
 ***
 ***        Phil Mercurio
 ***        Quicksilver Software
 ***        2515 #9 Camino Del Mar
 ***        Del Mar, CA  92014
 ***
 ***    Be sure to include your name and address, as this will place
 ***    you on the Quicksilver Software mailing list.  Your support
 ***    of shareware products will encourage the further production
 ***    of low-cost software.
 ***/

#include <stdio.h>
#include <libraries/dos.h>
#include <libraries/dosextens.h>
#include <intuition/intuition.h>

/**
 ** User-Configurable Constants; change to taste 
 **/
/*
 *  These definitions control the header and footer contents.  You probably
 *  won't want to change the definitions controlling the page number, 
 *  unless you're going to be printing files with more than 9999 pages.
 *  You'll definitely want to change "OwnerName".
 */
#define OwnerName   "Quicksilver Software" /* used in the copyright footer */
#define AllRights   "All Rights Reserved"  /* used in the copyright footer */
#define PageTemplate    "Page ####"        /* page number template */
#define NPageChars  (4)     /* # chars alloted for page number */
#define PageNumFmt  "%4d"   /* printf format matching above */

/*
 *  These definitions configure the left margin and the things printed
 *  in it.  Both LineNumFmt and Arrow must consume Indent characters.
 */
#define Indent      (6)     /* left margin indentation */
#define LineNumFmt  "%5d "  /* printf format for line numbers in margin */
#define Arrow       "==>   "    /* continuation arrow */

/*
 *  The following two definitions specify the codes to highlight
 *  the line numbers and continuation arrow.  If you don't want
 *  these highlighted, set both of these definitions to "".  Otherwise,
 *  the putPrefix() function will insert the ESCAPE for you.  These
 *  are ANSI printer codes, but if you change configure() to open
 *  "PAR:" or "SER:" instead of "PRT:" (i.e., if you by-pass the printer
 *  driver), you should use your own printer-specific codes instead.
 */
#define HiLiteOn    "[2v"   /* ANSI for superscript on */
#define HiLiteOff   "[1v"   /* ANSI for superscript off */
#define ESC         (033)   /* ASCII escape character */

#define TabStop     (8)     /* number of chars in a tab */

/*
 *  These definitions determine the format of each page.
 */
#define PreHeader   (3)     /* number of lines to preceed header */
#define NLHeader    (1)     /* number of lines in the header */
#define PreBody     (3)     /* number of lines between header and body */
#define PreFooter   (3)     /* number of lines between body and footer */
#define NLFooter    (1)     /* number of lines in the footer */
#define PostFooter  (1)     /* number of lines after the footer */
#define NonBody     (PreHeader+NLHeader+PreBody+PreFooter+NLFooter+\
                    PostFooter) /* sum of non-body lines on page */

/**
 ** Internal Buffer Sizes; may be changed if necessary
 **/
#define MaxFiles    (128)   /* maximum number of files */
#define BufSiz      (256)   /* input line buffer */
#define StrSiz      (128)   /* string size */

/**
 ** Sacred Constants & Macros; don't touch
 **/
#ifndef Yes
#define Yes (1)
#define No  (0)
#endif

#define IsDigit(c)  (c >= '0' && c <= '9')
#define IsWhite(c)            (c == ' ' || c == '\t')
#define IsEndOfBuffer(c)      (c == '\n' || c == 0)

#define CSI     (0x9B)  /* CLI Control Sequence Introducer */

/**
 ** Global Variables
 **/

int CopyRight;          /* if Yes, print copyright footer */
int Debug;              /* if Yes, do debugging */
int LeftMargin;         /* location of left margin */
int LineWidth;          /* number of chars in a line */
int LinesPerPage;       /* number of text lines per page */
int Quiet;		/* if Yes, don't write anything to the screen */

struct Preferences  Prefs;  /* user's preferences */
struct FileInfoBlock FIB;   /* used to file information */
extern int Enable_Abort;    /* when Yes, enables ^C termination */

struct DateStamp DateBuf;   /* stores file date */
struct DateStamp Now;       /* stores current date */

char    Date[StrSiz];       /* string representation of file date */
char    Time[StrSiz];       /* string representation of file time */

char    MyName[StrSiz];     /* name of this program */
char    Header[StrSiz];     /* string containing the header */
char    Footer[StrSiz];     /* string containing the footer */

FILE    *Prt;               /* the printer file pointer */
FILE	*xopen();           /* eXpress open function */
FILE    *fopen();           /* file open function */

int     LineCount;          /* if non-zero, increment for line numbers */
int     Line;               /* current line number */
int     RealLine;           /* current physical line number on page */
int     Page;               /* current page number */
char    FileName[MaxFiles][StrSiz];    /* names of files to print */
int     NFiles;             /* number of files */

char    Buf1[BufSiz];       /* input line buffer */
char    Buf2[BufSiz];       /* input buffer with tabs expanded */
char    *BufPtr;            /* pointer to above */
    
/**
 ** Libraries used by pp
 **/
LONG    IntuitionBase;      /* Intuition */
LONG    xOpenLibrary();     /* the eXpress open library function */
