Annotation of src/usr.bin/patch/common.h, Revision 1.18
1.18 ! millert 1: /* $OpenBSD: common.h,v 1.17 2003/07/22 17:18:49 otto Exp $ */
1.1 deraadt 2:
3: #define DEBUGGING
4:
5: #include <stdio.h>
6:
7: /* constants */
8:
1.15 deraadt 9: #define TRUE 1
10: #define FALSE 0
1.1 deraadt 11:
1.14 deraadt 12: #define MAXHUNKSIZE 100000 /* is this enough lines? */
13: #define INITHUNKMAX 125 /* initial dynamic allocation size */
1.8 niklas 14: #define MAXLINELEN 8192
1.1 deraadt 15: #define BUFFERSIZE 1024
16:
17: #define SCCSPREFIX "s."
18: #define GET "get -e %s"
19: #define SCCSDIFF "get -p %s | diff - %s >/dev/null"
20:
21: #define RCSSUFFIX ",v"
22: #define CHECKOUT "co -l %s"
23: #define RCSDIFF "rcsdiff %s > /dev/null"
24:
25: #define ORIGEXT ".orig"
26: #define REJEXT ".rej"
27:
28: /* handy definitions */
29:
30: #define strNE(s1,s2) (strcmp(s1, s2))
31: #define strEQ(s1,s2) (!strcmp(s1, s2))
32: #define strnNE(s1,s2,l) (strncmp(s1, s2, l))
33: #define strnEQ(s1,s2,l) (!strncmp(s1, s2, l))
34:
35: /* typedefs */
36:
1.14 deraadt 37: typedef char bool;
38: typedef long LINENUM; /* must be signed */
1.1 deraadt 39:
40: /* globals */
41:
1.14 deraadt 42: EXT int Argc; /* guess */
43: EXT char **Argv;
44: EXT int Argc_last; /* for restarting plan_b */
45: EXT char **Argv_last;
1.1 deraadt 46:
1.14 deraadt 47: EXT struct stat filestat; /* file statistics area */
1.1 deraadt 48: EXT int filemode INIT(0644);
49:
1.14 deraadt 50: EXT char buf[MAXLINELEN];/* general purpose buffer */
1.17 otto 51: EXT FILE *ofp INIT(NULL); /* output file pointer */
52: EXT FILE *rejfp INIT(NULL); /* reject file pointer */
1.1 deraadt 53:
1.14 deraadt 54: EXT int myuid; /* cache getuid return value */
1.1 deraadt 55:
56: EXT bool using_plan_a INIT(TRUE); /* try to keep everything in memory */
1.14 deraadt 57: EXT bool out_of_mem INIT(FALSE);/* ran out of memory in plan a */
1.1 deraadt 58:
59: #define MAXFILEC 2
1.14 deraadt 60: EXT int filec INIT(0); /* how many file arguments? */
61: EXT char *filearg[MAXFILEC];
1.1 deraadt 62: EXT bool ok_to_create_file INIT(FALSE);
1.17 otto 63: EXT char *bestguess INIT(NULL); /* guess at correct filename */
1.1 deraadt 64:
1.17 otto 65: EXT char *outname INIT(NULL);
1.1 deraadt 66:
1.17 otto 67: EXT char *origprae INIT(NULL);
1.1 deraadt 68:
1.14 deraadt 69: EXT char *TMPOUTNAME;
70: EXT char *TMPINNAME;
71: EXT char *TMPREJNAME;
72: EXT char *TMPPATNAME;
1.1 deraadt 73: EXT bool toutkeep INIT(FALSE);
74: EXT bool trejkeep INIT(FALSE);
75:
76: EXT LINENUM last_offset INIT(0);
77: #ifdef DEBUGGING
1.14 deraadt 78: EXT int debug INIT(0);
1.1 deraadt 79: #endif
80: EXT LINENUM maxfuzz INIT(2);
1.14 deraadt 81: EXT bool force INIT(FALSE);
82: EXT bool batch INIT(FALSE);
1.1 deraadt 83: EXT bool verbose INIT(TRUE);
84: EXT bool reverse INIT(FALSE);
85: EXT bool noreverse INIT(FALSE);
86: EXT bool skip_rest_of_patch INIT(FALSE);
87: EXT int strippath INIT(957);
88: EXT bool canonicalize INIT(FALSE);
1.17 otto 89: /* TRUE if -C was specified on command line. */
90: EXT bool check_only INIT(FALSE);
91:
1.1 deraadt 92:
93: #define CONTEXT_DIFF 1
94: #define NORMAL_DIFF 2
95: #define ED_DIFF 3
96: #define NEW_CONTEXT_DIFF 4
97: #define UNI_DIFF 5
98: EXT int diff_type INIT(0);
99:
1.14 deraadt 100: EXT bool do_defines INIT(FALSE);/* patch using ifdef, ifndef, etc. */
101: EXT char if_defined[128];/* #ifdef xyzzy */
102: EXT char not_defined[128]; /* #ifndef xyzzy */
103: EXT char else_defined[] INIT("#else\n"); /* #else */
104: EXT char end_defined[128]; /* #endif xyzzy */
1.1 deraadt 105:
1.17 otto 106: EXT char *revision INIT(NULL); /* prerequisite revision, if any */