1 
2 //  @(#)print.hh 1.3 93/08/01
3 //
4 //  Contains definitions for class "Print".
5 //
6 //  Copyright (c) Steve Holden and Rich Burridge.
7 //                All rights reserved.
8 //
9 //  Permission is given to distribute these sources, as long as the
10 //  copyright messages are not removed, and no monies are exchanged.
11 //
12 //  No responsibility is taken for any errors or inaccuracies inherent
13 //  either to the comments or the code of this program, but if
14 //  reported to me then an attempt will be made to fix them.
15 
16 #define  EQUALN(a, b) (*a == *b && !strncmp(a, b, strlen(b)))
17 #define  FPRINTF      (void) fprintf
18 #define  FPUTS(s)     (void) fputs((s), ofp)
19 
20 #define  LINELENGTH   80                // Number of characters per line.
21 #define  MAXTTYPES    4                 // Maximum number of text types.
22 #define  PAGELENGTH   60                // Number of lines per page.
23 #define  PRINTPROG    "/usr/spool/lp"   // BSD or System V system?
24 
25 typedef enum { IS_COL, IS_FILE, IS_LINE, IS_PAGE } action_type ;
26 typedef enum { A4, US }                            paper_type ;
27 typedef enum { T_BOLD, T_MIXED, T_PLAIN, T_ROMAN } text_type ;
28 
29 class Print {
30   public:
31 
32   char curfname[MAXPATHLEN] ;   // Current file being printed.
33   char *message_for ;           // "[Mail,News,Listing] for " line.
34   char *printer_name ;          // Printer name (if any) for output.
35 
36   int colct ;                   // Column count on current page.
37   int linect ;                  // Line count on current page.
38   int pageno ;                  // Page number within message.
39   int tpn ;                     // Total number of pages printed.
40 
41   paper_type paper_size ;       // Paper size - default US.
42 
43   FILE *ofp ;                   // Output file pointer (stdout or print cmd).
44 
45        Print         () ;
46   void end           (action_type) ;
47   FILE *makecmd      (char *) ;
48   void print_extra   (void) ;
49   void show_prologue (char *) ;
50   void show_text     (text_type, char *, char *) ;
51   void show_trailer  (void) ;
52   void start         (action_type) ;
53 
54   private:
55   void do_date       (void) ;
56   void expand        (unsigned char *) ;
57   void psdef         (char *, char *) ;
58   void set_defs      (void) ;
59   void useline       (void) ;
60 } ;
61