1: /* $Header: common.h,v 2.0.1.2 88/06/22 20:44:53 lwall Locked $
   2:  *
   3:  * $Log:	common.h,v $
   4:  * Revision 2.0.1.2  88/06/22  20:44:53  lwall
   5:  * patch12: sprintf was declared wrong
   6:  *
   7:  * Revision 2.0.1.1  88/06/03  15:01:56  lwall
   8:  * patch10: support for shorter extensions.
   9:  *
  10:  * Revision 2.0  86/09/17  15:36:39  lwall
  11:  * Baseline for netwide release.
  12:  *
  13:  */
  14: 
  15: #define DEBUGGING
  16: 
  17: #include "config.h"
  18: 
  19: /* shut lint up about the following when return value ignored */
  20: 
  21: #define Signal (void)signal
  22: #define Unlink (void)unlink
  23: #define Lseek (void)lseek
  24: #define Fseek (void)fseek
  25: #define Fstat (void)fstat
  26: #define Pclose (void)pclose
  27: #define Close (void)close
  28: #define Fclose (void)fclose
  29: #define Fflush (void)fflush
  30: #define Sprintf (void)sprintf
  31: #define Mktemp (void)mktemp
  32: #define Strcpy (void)strcpy
  33: #define Strcat (void)strcat
  34: 
  35: #include <stdio.h>
  36: #include <assert.h>
  37: #include <sys/types.h>
  38: #include <sys/stat.h>
  39: #include <ctype.h>
  40: #include <signal.h>
  41: 
  42: /* constants */
  43: 
  44: #define TRUE (1)
  45: #define FALSE (0)
  46: 
  47: #define MAXHUNKSIZE 100000      /* is this enough lines? */
  48: #define INITHUNKMAX 125         /* initial dynamic allocation size */
  49: #define MAXLINELEN 1024
  50: #define BUFFERSIZE 1024
  51: #define SCCSPREFIX "s."
  52: #define GET "get -e %s"
  53: #define RCSSUFFIX ",v"
  54: #define CHECKOUT "co -l %s"
  55: 
  56: #ifdef FLEXFILENAMES
  57: #define ORIGEXT ".orig"
  58: #define REJEXT ".rej"
  59: #else
  60: #define ORIGEXT "~"
  61: #define REJEXT "#"
  62: #endif
  63: 
  64: /* handy definitions */
  65: 
  66: #define Null(t) ((t)0)
  67: #define Nullch Null(char *)
  68: #define Nullfp Null(FILE *)
  69: #define Nulline Null(LINENUM)
  70: 
  71: #define Ctl(ch) ((ch) & 037)
  72: 
  73: #define strNE(s1,s2) (strcmp(s1, s2))
  74: #define strEQ(s1,s2) (!strcmp(s1, s2))
  75: #define strnNE(s1,s2,l) (strncmp(s1, s2, l))
  76: #define strnEQ(s1,s2,l) (!strncmp(s1, s2, l))
  77: 
  78: /* typedefs */
  79: 
  80: typedef char bool;
  81: typedef long LINENUM;           /* must be signed */
  82: typedef unsigned MEM;           /* what to feed malloc */
  83: 
  84: /* globals */
  85: 
  86: EXT int Argc;               /* guess */
  87: EXT char **Argv;
  88: EXT int Argc_last;          /* for restarting plan_b */
  89: EXT char **Argv_last;
  90: 
  91: EXT struct stat filestat;       /* file statistics area */
  92: EXT int filemode INIT(0644);
  93: 
  94: EXT char buf[MAXLINELEN];       /* general purpose buffer */
  95: EXT FILE *ofp INIT(Nullfp);     /* output file pointer */
  96: EXT FILE *rejfp INIT(Nullfp);       /* reject file pointer */
  97: 
  98: EXT bool using_plan_a INIT(TRUE);   /* try to keep everything in memory */
  99: EXT bool out_of_mem INIT(FALSE);    /* ran out of memory in plan a */
 100: 
 101: #define MAXFILEC 2
 102: EXT int filec INIT(0);          /* how many file arguments? */
 103: EXT char *filearg[MAXFILEC];
 104: EXT bool ok_to_create_file INIT(FALSE);
 105: EXT char *bestguess INIT(Nullch);   /* guess at correct filename */
 106: 
 107: EXT char *outname INIT(Nullch);
 108: EXT char rejname[128];
 109: 
 110: EXT char *origext INIT(Nullch);
 111: EXT char *origprae INIT(Nullch);
 112: 
 113: EXT char TMPOUTNAME[] INIT("/tmp/patchoXXXXXX");
 114: EXT char TMPINNAME[] INIT("/tmp/patchiXXXXXX"); /* might want /usr/tmp here */
 115: EXT char TMPREJNAME[] INIT("/tmp/patchrXXXXXX");
 116: EXT char TMPPATNAME[] INIT("/tmp/patchpXXXXXX");
 117: EXT bool toutkeep INIT(FALSE);
 118: EXT bool trejkeep INIT(FALSE);
 119: 
 120: EXT LINENUM last_offset INIT(0);
 121: #ifdef DEBUGGING
 122: EXT int debug INIT(0);
 123: #endif
 124: EXT LINENUM maxfuzz INIT(2);
 125: EXT bool force INIT(FALSE);
 126: EXT bool verbose INIT(TRUE);
 127: EXT bool reverse INIT(FALSE);
 128: EXT bool noreverse INIT(FALSE);
 129: EXT bool skip_rest_of_patch INIT(FALSE);
 130: EXT int strippath INIT(957);
 131: EXT bool canonicalize INIT(FALSE);
 132: 
 133: #define CONTEXT_DIFF 1
 134: #define NORMAL_DIFF 2
 135: #define ED_DIFF 3
 136: #define NEW_CONTEXT_DIFF 4
 137: EXT int diff_type INIT(0);
 138: 
 139: EXT bool do_defines INIT(FALSE);    /* patch using ifdef, ifndef, etc. */
 140: EXT char if_defined[128];       /* #ifdef xyzzy */
 141: EXT char not_defined[128];      /* #ifndef xyzzy */
 142: EXT char else_defined[] INIT("#else\n");/* #else */
 143: EXT char end_defined[128];      /* #endif xyzzy */
 144: 
 145: EXT char *revision INIT(Nullch);    /* prerequisite revision, if any */
 146: 
 147: char *malloc();
 148: char *realloc();
 149: char *strcpy();
 150: char *strcat();
 151: long atol();
 152: long lseek();
 153: char *mktemp();
 154: #ifdef CHARSPRINTF
 155: char *sprintf();
 156: #else
 157: int sprintf();
 158: #endif

Defined variables

Argc defined in line 86; used 13 times
Argc_last defined in line 88; used 2 times
Argv defined in line 87; used 19 times
Argv_last defined in line 89; used 2 times
TMPINNAME defined in line 114; used 7 times
TMPOUTNAME defined in line 113; used 11 times
TMPPATNAME defined in line 116; used 5 times
TMPREJNAME defined in line 115; used 4 times
bestguess defined in line 105; used 14 times
buf defined in line 94; used 126 times
diff_type defined in line 137; used 23 times
do_defines defined in line 139; used 2 times
else_defined defined in line 142; used 4 times
end_defined defined in line 143; used 3 times
filearg defined in line 103; used 22 times
filec defined in line 102; used 4 times
filestat defined in line 91; used 25 times
if_defined defined in line 140; used 3 times
last_offset defined in line 120; used 12 times
maxfuzz defined in line 124; used 3 times
noreverse defined in line 128; used 2 times
not_defined defined in line 141; used 3 times
ok_to_create_file defined in line 104; used 6 times
origext defined in line 110; used 3 times
origprae defined in line 111; used 3 times
outname defined in line 107; used 11 times
rejname defined in line 108; used 10 times
reverse defined in line 127; used 13 times
revision defined in line 145; used 22 times
strippath defined in line 130; used 7 times
toutkeep defined in line 117; used 3 times
trejkeep defined in line 118; used 2 times

Defined typedef's

LINENUM defined in line 81; used 84 times
MEM defined in line 82; used 11 times
bool defined in line 80; used 37 times

Defined macros

BUFFERSIZE defined in line 50; used 9 times
CHECKOUT defined in line 54; used 1 times
Close defined in line 27; used 10 times
Ctl defined in line 71; never used
DEBUGGING defined in line 15; used 12 times
ED_DIFF defined in line 135; used 5 times
FALSE defined in line 45; used 53 times
Fflush defined in line 29; used 6 times
Fseek defined in line 24; used 5 times
Fstat defined in line 25; used 1 times
GET defined in line 52; used 1 times
INITHUNKMAX defined in line 48; used 1 times
Lseek defined in line 23; used 1 times
MAXFILEC defined in line 101; used 3 times
MAXHUNKSIZE defined in line 47; used 2 times
MAXLINELEN defined in line 49; used 1 times
  • in line 94
Mktemp defined in line 31; used 4 times
NORMAL_DIFF defined in line 134; used 4 times
Null defined in line 66; used 23 times
Nullch defined in line 67; used 77 times
Nullfp defined in line 68; used 10 times
Nulline defined in line 69; used 14 times
ORIGEXT defined in line 60; used 1 times
Pclose defined in line 26; used 1 times
RCSSUFFIX defined in line 53; used 2 times
REJEXT defined in line 61; used 1 times
SCCSPREFIX defined in line 51; used 2 times
Signal defined in line 21; used 4 times
Strcat defined in line 33; used 4 times
strNE defined in line 73; never used
strnEQ defined in line 76; used 13 times
strnNE defined in line 75; used 2 times

Usage of this include

Last modified: 1988-06-30
Generated: 2016-12-26
Generated by src2html V0.67
page hit count: 4918
Valid CSS Valid XHTML 1.0 Strict