// @(#)input.hh 1.2 93/08/01 // // Contains definitions for class "Input". // // Copyright (c) Steve Holden and Rich Burridge. // All rights reserved. // // Permission is given to distribute these sources, as long as the // copyright messages are not removed, and no monies are exchanged. // // No responsibility is taken for any errors or inaccuracies inherent // either to the comments or the code of this program, but if // reported to me then an attempt will be made to fix them. #define MAXHDRS 64 // Maximum number of -addhdr or -remhdr options. #define MAXLINE 256 // Maximum string length. #define MAXNAMES 512 // Maximum number of files from command line. #define NAMEFIELDS 3 // Default no. of "words" from passwd gecos. #define NAMELENGTH 40 // Maximum allowable real user name. #ifndef MAXPATHLEN #define MAXPATHLEN 1024 #endif // MAXPATHLEN #ifndef PROLOGUE // PostScript prologue file. #define PROLOGUE "/usr/local/lib" #endif // PROLOGUE #define PRO_FILOFAX "mp.pro.ff.ps" #define PRO_FRANKLIN "mp.pro.fp.ps" #define PRO_LANDSCAPE "mp.pro.l.ps" #define PRO_NORMAL "mp.pro.ps" #define PRO_OTHER "other" #define PRO_TIME_MANAGER "mp.pro.tm.ps" #define PRO_TIME_SYSTEM "mp.pro.ts.ps" typedef enum { DO_MAIL, DO_NEWS, DO_TEXT } document_type ; class Input { public: char *addhdrs[MAXHDRS] ; // List of additional headers to be printed. char *hdrs[MAXHDRS] ; // Contents of additional headers. char *namelist[MAXNAMES] ; // List of file names from argv. char nextline[MAXLINE] ; // Read-ahead of the mail message, minus nl. char *owner ; // Name of owner (usually equal to 'to') char *progname ; // Name of this program. char *prologue ; // Name of PostScript prologue file. char proname[MAXPATHLEN] ; // Full pathname of the prologue file. char *ptype ; // Prologue type. char *remhdrs[MAXHDRS] ; // List of headers not to be printed. char *whoami ; // Login name of user. // Command line option flags. int article ; // Set for news in "Article from " format. int banner ; // Print a burst page on the printer? int content ; // Set if Content-Length: has message length. int digest ; // Are we are printing a mail digest. int elm_if ; // ELM mail frontend intermediate file format. int folder ; // Set if we are printing a mail folder. int landscape ; // Set if we are printing in landscape mode. int llen ; // Number of characters per line. int modtime ; // If set, use last modification time. int number ; // If set, than number each output line. int numcols ; // Number of columns per page. int plen ; // Number of lines per page. int print_orig ; // Print From rather than To in mail header. int print_ps ; // Print PostScript files if set. int text_doc ; // Printing normal text. int toprinter ; // Send output to the printer? int wrapwords ; // Wrap words of output. int end_of_file ; // EOF indicator. int end_of_line ; // Is a newline removed from this line. int end_of_page ; // end-of-page indicator - ^L on input. int cols_given ; // Was "-columns #" command line option given? int llen_given ; // Was "-linelength #" command line option given? int plen_given ; // Was "-pagelength #" command line option given? int addhdr_num ; // Number of additional header lines to print. int clen ; // Current line length (including newline). int linenum ; // Current line number from input file. int mlen ; // Number of characters in message (-C option). int namefields ; // Number of "words" from passwd gecos. int namelength ; // Maximum # of chars. from passwd gecos. int numnames ; // Number of file names from command line. int remhdr_num ; // Number of additional header lines not to print. document_type doc_type ; // Printing type - default mail. FILE *ifp ; // Input file pointer for current file. Input () ; void get_options (int, char **) ; void init_setup (void) ; void readline (void) ; private: char iobuf[MAXLINE] ; // Overflow buffer when -wrap is used. char *nameptr ; // Used to getenv the NAME variable. int cpos ; // Current column position for usage output. int overflow ; // # of chars of text wraparound if -wrap. int tabsize ; // Number of spaces in a tab character. int argcmp (char *, char *, int) ; void get_hdr_arg (char *, char **, int *) ; void process_name_field (char *, char *, int, int) ; void usage (void) ; void usageoption (char *) ; } ;