1 /* $OpenBSD: common.h,v 1.25 2003/10/31 20:20:45 millert Exp $ */ 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 */ 28 29 #include <stdbool.h> 30 31 #define DEBUGGING 32 33 /* constants */ 34 35 #define MAXHUNKSIZE 100000 /* is this enough lines? */ 36 #define INITHUNKMAX 125 /* initial dynamic allocation size */ 37 #define MAXLINELEN 8192 38 #define BUFFERSIZE 1024 39 40 #define SCCSPREFIX "s." 41 #define GET "get -e %s" 42 #define SCCSDIFF "get -p %s | diff - %s >/dev/null" 43 44 #define RCSSUFFIX ",v" 45 #define CHECKOUT "co -l %s" 46 #define RCSDIFF "rcsdiff %s > /dev/null" 47 48 #define ORIGEXT ".orig" 49 #define REJEXT ".rej" 50 51 /* handy definitions */ 52 53 #define strNE(s1,s2) (strcmp(s1, s2)) 54 #define strEQ(s1,s2) (!strcmp(s1, s2)) 55 #define strnNE(s1,s2,l) (strncmp(s1, s2, l)) 56 #define strnEQ(s1,s2,l) (!strncmp(s1, s2, l)) 57 58 /* typedefs */ 59 60 typedef long LINENUM; /* must be signed */ 61 62 /* globals */ 63 64 extern int filemode; 65 66 extern char buf[MAXLINELEN];/* general purpose buffer */ 67 68 extern bool using_plan_a; /* try to keep everything in memory */ 69 extern bool out_of_mem; /* ran out of memory in plan a */ 70 71 #define MAXFILEC 2 72 73 extern char *filearg[MAXFILEC]; 74 extern bool ok_to_create_file; 75 extern char *outname; 76 extern char *origprae; 77 78 extern char *TMPOUTNAME; 79 extern char *TMPINNAME; 80 extern char *TMPREJNAME; 81 extern char *TMPPATNAME; 82 extern bool toutkeep; 83 extern bool trejkeep; 84 85 #ifdef DEBUGGING 86 extern int debug; 87 #endif 88 89 extern bool force; 90 extern bool batch; 91 extern bool verbose; 92 extern bool reverse; 93 extern bool noreverse; 94 extern bool skip_rest_of_patch; 95 extern int strippath; 96 extern bool canonicalize; 97 /* TRUE if -C was specified on command line. */ 98 extern bool check_only; 99 extern bool warn_on_invalid_line; 100 extern bool last_line_missing_eol; 101 102 103 #define CONTEXT_DIFF 1 104 #define NORMAL_DIFF 2 105 #define ED_DIFF 3 106 #define NEW_CONTEXT_DIFF 4 107 #define UNI_DIFF 5 108 109 extern int diff_type; 110 extern char *revision; /* prerequisite revision, if any */ 111 extern LINENUM input_lines; /* how long is input file in lines */ 112 113 extern int posix; 114 115