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