Annotation of src/usr.bin/patch/common.h, Revision 1.26.36.1
1.26.36.1! guenther 1: /* $OpenBSD: common.h,v 1.26 2006/03/11 19:41:30 otto Exp $ */
1.24 otto 2:
3: /*
4: * patch - a program to apply diffs to original files
5: *
6: * Copyright 1986, Larry Wall
7: *
8: * Redistribution and use in source and binary forms, with or without
9: * modification, are permitted provided that the following condition is met:
10: * 1. Redistributions of source code must retain the above copyright notice,
11: * this condition and the following disclaimer.
12: *
13: * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND ANY
14: * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
15: * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
16: * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE FOR
17: * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
18: * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
19: * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
20: * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
21: * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
22: * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
23: * SUCH DAMAGE.
24: *
25: * -C option added in 1998, original code by Marc Espie, based on FreeBSD
26: * behaviour
27: */
1.22 otto 28:
1.26 otto 29: #include <sys/types.h>
30:
1.22 otto 31: #include <stdbool.h>
1.1 deraadt 32:
33: #define DEBUGGING
34:
35: /* constants */
36:
1.14 deraadt 37: #define MAXHUNKSIZE 100000 /* is this enough lines? */
38: #define INITHUNKMAX 125 /* initial dynamic allocation size */
1.8 niklas 39: #define MAXLINELEN 8192
1.1 deraadt 40: #define BUFFERSIZE 1024
41:
42: #define ORIGEXT ".orig"
43: #define REJEXT ".rej"
44:
45: /* handy definitions */
46:
47: #define strNE(s1,s2) (strcmp(s1, s2))
48: #define strEQ(s1,s2) (!strcmp(s1, s2))
49: #define strnNE(s1,s2,l) (strncmp(s1, s2, l))
50: #define strnEQ(s1,s2,l) (!strncmp(s1, s2, l))
51:
52: /* typedefs */
53:
1.14 deraadt 54: typedef long LINENUM; /* must be signed */
1.1 deraadt 55:
56: /* globals */
57:
1.26 otto 58: extern mode_t filemode;
1.1 deraadt 59:
1.19 otto 60: extern char buf[MAXLINELEN];/* general purpose buffer */
1.1 deraadt 61:
1.19 otto 62: extern bool using_plan_a; /* try to keep everything in memory */
63: extern bool out_of_mem; /* ran out of memory in plan a */
1.1 deraadt 64:
65: #define MAXFILEC 2
66:
1.19 otto 67: extern char *filearg[MAXFILEC];
68: extern bool ok_to_create_file;
69: extern char *outname;
70: extern char *origprae;
71:
72: extern char *TMPOUTNAME;
73: extern char *TMPINNAME;
74: extern char *TMPREJNAME;
75: extern char *TMPPATNAME;
76: extern bool toutkeep;
77: extern bool trejkeep;
78:
1.1 deraadt 79: #ifdef DEBUGGING
1.19 otto 80: extern int debug;
1.1 deraadt 81: #endif
1.19 otto 82:
83: extern bool force;
84: extern bool batch;
85: extern bool verbose;
86: extern bool reverse;
87: extern bool noreverse;
88: extern bool skip_rest_of_patch;
89: extern int strippath;
90: extern bool canonicalize;
1.17 otto 91: /* TRUE if -C was specified on command line. */
1.19 otto 92: extern bool check_only;
1.21 otto 93: extern bool warn_on_invalid_line;
1.23 otto 94: extern bool last_line_missing_eol;
1.17 otto 95:
1.1 deraadt 96:
97: #define CONTEXT_DIFF 1
98: #define NORMAL_DIFF 2
99: #define ED_DIFF 3
100: #define NEW_CONTEXT_DIFF 4
101: #define UNI_DIFF 5
102:
1.19 otto 103: extern int diff_type;
104: extern char *revision; /* prerequisite revision, if any */
105: extern LINENUM input_lines; /* how long is input file in lines */
106:
1.25 millert 107: extern int posix;
1.1 deraadt 108: