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