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