/********** gpmmain.c *************************************************/ /* ** General driver for gpm variants. Only accesses gpm() externally. ** Exports FileName and LineNumber for error messages. ** Exports PrintErrorLine(). ** ** argv[x] is made NULL if gpmmain thinks it's a flag that ** it can interpret. Then argv[] is passed to gpminit, ** which can read more flags. */ #define GPMMAIN_C_ #include "gpmdefs.h" #include "gpmmain.h" #include "gpm.h" #define NAMESIZE 128 /* Longest exec() name for us */ #ifdef CAREFUL #include #include #endif int LineNumber=0; /* for Monitor */ char *FileName=(char *)NULL; /* for Monitor */ char ExeName[NAMESIZE]; /* Space for storing exec() name */ int Special[SpecialCount]; #ifdef ESCAPE char *SpecialDefault="{|<~>}`\\"; int SpecialSet[CHARSETSIZE]; #else char *SpecialDefault="{|<~>}`"; #endif #ifdef VERBOSESET # ifdef VERBOSEDEFAULT static int VerboseLevel = 1; # else static int VerboseLevel = 0; # endif #endif #ifdef QUOTEMSET # ifdef QUOTEMDEF int QuoteMLevel = 1; # else int QuoteMLevel = 0; # endif #endif #ifdef AUTHOR void Author() { fprintf(stderr,"\nTo complain, send E-mail to:\n\n"); fprintf(stderr,"to: adridg@sci.kun.nl\nor : wupper@cs.kun.nl\n"); fprintf(stderr,"\n(Valid per Mar 24, 1995)\n"); } #endif void PrintErrorLine() { /* ** BAD PRACTICE!! This hard-coded size for s must be big ** enough to hold any of the messages printed to it in ** this function. */ char s[128]; s[0]=0; /* Make sure it terminates */ #ifdef FILENAME # ifdef LINENUMBER sprintf(s,"(line %d of file %s)\n",LineNumber,FileName); # else sprintf(s,"(file %s)\n",FileName); # endif #else # ifdef LINENUMBER sprintf(s,"(line %d)\n",LineNumber); # endif #endif fprintf(stderr,"\n%s\n",s); } void Usage() { fprintf(stderr,"Usage: %s [options] [files]\n : %s -h for help.\n", ExeName,ExeName); } int main(argc, argv, envp) int argc; char **argv; char **envp; { int c; int in_file_count=0; /* number of files to process */ int dryrun=0; /* flag a no-process run */ #ifdef CAREFUL int force=0; /* flag for force overwrite */ struct stat out_stat; #endif char *in_file = (char *) NULL; /* name of each file to process */ char *out_file = (char *) NULL; /* -o file */ char *special_chars = (char *) NULL; /* -s chars */ strcpy(ExeName,argv[0]); /* get exec(2v) name passed in */ for (c=1; c