Annotation of src/usr.bin/patch/common.h, Revision 1.17
1.17 ! otto 1: /* $OpenBSD: common.h,v 1.16 2003/07/21 14:32:21 deraadt 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.14 deraadt 66: EXT char rejname[128];
1.1 deraadt 67:
1.17 ! otto 68: EXT char *origprae INIT(NULL);
1.1 deraadt 69:
1.14 deraadt 70: EXT char *TMPOUTNAME;
71: EXT char *TMPINNAME;
72: EXT char *TMPREJNAME;
73: EXT char *TMPPATNAME;
1.1 deraadt 74: EXT bool toutkeep INIT(FALSE);
75: EXT bool trejkeep INIT(FALSE);
76:
77: EXT LINENUM last_offset INIT(0);
78: #ifdef DEBUGGING
1.14 deraadt 79: EXT int debug INIT(0);
1.1 deraadt 80: #endif
81: EXT LINENUM maxfuzz INIT(2);
1.14 deraadt 82: EXT bool force INIT(FALSE);
83: EXT bool batch INIT(FALSE);
1.1 deraadt 84: EXT bool verbose INIT(TRUE);
85: EXT bool reverse INIT(FALSE);
86: EXT bool noreverse INIT(FALSE);
87: EXT bool skip_rest_of_patch INIT(FALSE);
88: EXT int strippath INIT(957);
89: EXT bool canonicalize INIT(FALSE);
1.17 ! otto 90: /* TRUE if -C was specified on command line. */
! 91: EXT bool check_only INIT(FALSE);
! 92:
1.1 deraadt 93:
94: #define CONTEXT_DIFF 1
95: #define NORMAL_DIFF 2
96: #define ED_DIFF 3
97: #define NEW_CONTEXT_DIFF 4
98: #define UNI_DIFF 5
99: EXT int diff_type INIT(0);
100:
1.14 deraadt 101: EXT bool do_defines INIT(FALSE);/* patch using ifdef, ifndef, etc. */
102: EXT char if_defined[128];/* #ifdef xyzzy */
103: EXT char not_defined[128]; /* #ifndef xyzzy */
104: EXT char else_defined[] INIT("#else\n"); /* #else */
105: EXT char end_defined[128]; /* #endif xyzzy */
1.1 deraadt 106:
1.17 ! otto 107: EXT char *revision INIT(NULL); /* prerequisite revision, if any */