- Make fwe(4) aware of IFF_POLLING setting in its if_init().
[dragonfly/port-amd64.git] / usr.bin / patch / common.h
blobd31448db5e120eafb9b8504b661e24fdb894bd68
1 /*
2 * $OpenBSD: common.h,v 1.25 2003/10/31 20:20:45 millert Exp $
3 * $DragonFly: src/usr.bin/patch/common.h,v 1.3 2006/04/18 22:11:35 joerg Exp $
4 */
6 /*
7 * patch - a program to apply diffs to original files
8 *
9 * Copyright 1986, Larry Wall
11 * Redistribution and use in source and binary forms, with or without
12 * modification, are permitted provided that the following condition is met:
13 * 1. Redistributions of source code must retain the above copyright notice,
14 * this condition and the following disclaimer.
16 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND ANY
17 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19 * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE FOR
20 * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
21 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
22 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
23 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
24 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
25 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
26 * SUCH DAMAGE.
28 * -C option added in 1998, original code by Marc Espie, based on FreeBSD
29 * behaviour
32 #include <stdbool.h>
35 * SIZE_MAX: older BSD compatibility for buildworld bootstrap mode only
37 #if defined(BOOTSTRAPPING) && !defined(SIZE_MAX)
38 #define SIZE_MAX 0x7fffffff
39 #endif
41 #define DEBUGGING
43 /* constants */
45 #define MAXHUNKSIZE 100000 /* is this enough lines? */
46 #define INITHUNKMAX 125 /* initial dynamic allocation size */
47 #define MAXLINELEN 8192
48 #define BUFFERSIZE 1024
50 #define SCCSPREFIX "s."
51 #define GET "get -e %s"
52 #define SCCSDIFF "get -p %s | diff - %s >/dev/null"
54 #define RCSSUFFIX ",v"
55 #define CHECKOUT "co -l %s"
56 #define RCSDIFF "rcsdiff %s > /dev/null"
58 #define ORIGEXT ".orig"
59 #define REJEXT ".rej"
61 /* handy definitions */
63 #define strNE(s1,s2) (strcmp(s1, s2))
64 #define strEQ(s1,s2) (!strcmp(s1, s2))
65 #define strnNE(s1,s2,l) (strncmp(s1, s2, l))
66 #define strnEQ(s1,s2,l) (!strncmp(s1, s2, l))
68 /* typedefs */
70 typedef long LINENUM; /* must be signed */
72 /* globals */
74 extern int filemode;
76 extern char buf[MAXLINELEN];/* general purpose buffer */
77 extern size_t buf_len;
79 extern bool using_plan_a; /* try to keep everything in memory */
80 extern bool out_of_mem; /* ran out of memory in plan a */
82 #define MAXFILEC 2
84 extern char *filearg[MAXFILEC];
85 extern bool ok_to_create_file;
86 extern char *outname;
87 extern char *origprae;
89 extern char *TMPOUTNAME;
90 extern char *TMPINNAME;
91 extern char *TMPREJNAME;
92 extern char *TMPPATNAME;
93 extern bool toutkeep;
94 extern bool trejkeep;
96 #ifdef DEBUGGING
97 extern int debug;
98 #endif
100 extern bool force;
101 extern bool batch;
102 extern bool verbose;
103 extern bool reverse;
104 extern bool noreverse;
105 extern bool skip_rest_of_patch;
106 extern int strippath;
107 extern bool canonicalize;
108 /* TRUE if -C was specified on command line. */
109 extern bool check_only;
110 extern bool warn_on_invalid_line;
111 extern bool last_line_missing_eol;
114 #define CONTEXT_DIFF 1
115 #define NORMAL_DIFF 2
116 #define ED_DIFF 3
117 #define NEW_CONTEXT_DIFF 4
118 #define UNI_DIFF 5
120 extern int diff_type;
121 extern char *revision; /* prerequisite revision, if any */
122 extern LINENUM input_lines; /* how long is input file in lines */
124 extern int posix;