1 /* $Header: common.h,v 2.0 86/09/17 15:36:39 lwall Exp $
4 * Revision 2.0 86/09/17 15:36:39 lwall
5 * Baseline for netwide release.
13 /* shut lint up about the following when return value ignored */
15 #define Signal (void)signal
16 #define Unlink (void)unlink
17 #define Lseek (void)lseek
18 #define Fseek (void)fseek
19 #define Fstat (void)fstat
20 #define Pclose (void)pclose
21 #define Close (void)close
22 #define Fclose (void)fclose
23 #define Fflush (void)fflush
24 #define Sprintf (void)sprintf
25 #define Mktemp (void)mktemp
26 #define Strcpy (void)strcpy
27 #define Strcat (void)strcat
31 #include <sys/types.h>
41 #define MAXHUNKSIZE 100000 /* is this enough lines? */
42 #define INITHUNKMAX 125 /* initial dynamic allocation size */
43 #define MAXLINELEN 1024
44 #define BUFFERSIZE 1024
45 #define ORIGEXT ".orig"
46 #define SCCSPREFIX "s."
47 #define GET "get -e %s"
48 #define RCSSUFFIX ",v"
49 #define CHECKOUT "co -l %s"
51 /* handy definitions */
53 #define Null(t) ((t)0)
54 #define Nullch Null(char *)
55 #define Nullfp Null(FILE *)
56 #define Nulline Null(LINENUM)
58 #define Ctl(ch) ((ch) & 037)
60 #define strNE(s1,s2) (strcmp(s1, s2))
61 #define strEQ(s1,s2) (!strcmp(s1, s2))
62 #define strnNE(s1,s2,l) (strncmp(s1, s2, l))
63 #define strnEQ(s1,s2,l) (!strncmp(s1, s2, l))
68 typedef long LINENUM; /* must be signed */
69 typedef unsigned MEM; /* what to feed malloc */
73 EXT int Argc; /* guess */
75 EXT int Argc_last; /* for restarting plan_b */
78 EXT struct stat filestat; /* file statistics area */
79 EXT int filemode INIT(0644);
81 EXT char buf[MAXLINELEN]; /* general purpose buffer */
82 EXT FILE *ofp INIT(Nullfp); /* output file pointer */
83 EXT FILE *rejfp INIT(Nullfp); /* reject file pointer */
85 EXT bool using_plan_a INIT(TRUE); /* try to keep everything in memory */
86 EXT bool out_of_mem INIT(FALSE); /* ran out of memory in plan a */
89 EXT int filec INIT(0); /* how many file arguments? */
90 EXT char *filearg[MAXFILEC];
91 EXT bool ok_to_create_file INIT(FALSE);
92 EXT char *bestguess INIT(Nullch); /* guess at correct filename */
94 EXT char *outname INIT(Nullch);
95 EXT char rejname[128];
97 EXT char *origext INIT(Nullch);
99 EXT char TMPOUTNAME[] INIT("/tmp/patchoXXXXXX");
100 EXT char TMPINNAME[] INIT("/tmp/patchiXXXXXX"); /* might want /usr/tmp here */
101 EXT char TMPREJNAME[] INIT("/tmp/patchrXXXXXX");
102 EXT char TMPPATNAME[] INIT("/tmp/patchpXXXXXX");
103 EXT bool toutkeep INIT(FALSE);
104 EXT bool trejkeep INIT(FALSE);
106 EXT LINENUM last_offset INIT(0);
108 EXT int debug INIT(0);
110 EXT LINENUM maxfuzz INIT(2);
111 EXT bool force INIT(FALSE);
112 EXT bool verbose INIT(TRUE);
113 EXT bool reverse INIT(FALSE);
114 EXT bool noreverse INIT(FALSE);
115 EXT bool skip_rest_of_patch INIT(FALSE);
116 EXT int strippath INIT(957);
117 EXT bool canonicalize INIT(FALSE);
119 #define CONTEXT_DIFF 1
120 #define NORMAL_DIFF 2
122 #define NEW_CONTEXT_DIFF 4
123 EXT int diff_type INIT(0);
125 EXT bool do_defines INIT(FALSE); /* patch using ifdef, ifndef, etc. */
126 EXT char if_defined[128]; /* #ifdef xyzzy */
127 EXT char not_defined[128]; /* #ifndef xyzzy */
128 EXT char else_defined[] INIT("#else\n");/* #else */
129 EXT char end_defined[128]; /* #endif xyzzy */
131 EXT char *revision INIT(Nullch); /* prerequisite revision, if any */