2019-12-02 14:17:32 -08:00
|
|
|
/* $OpenBSD: common.h,v 1.30 2019/12/02 22:17:32 jca Exp $ */
|
2003-08-15 01:00:51 -07:00
|
|
|
|
|
|
|
/*
|
|
|
|
* patch - a program to apply diffs to original files
|
|
|
|
*
|
|
|
|
* Copyright 1986, Larry Wall
|
|
|
|
*
|
|
|
|
* Redistribution and use in source and binary forms, with or without
|
|
|
|
* modification, are permitted provided that the following condition is met:
|
|
|
|
* 1. Redistributions of source code must retain the above copyright notice,
|
|
|
|
* this condition and the following disclaimer.
|
|
|
|
*
|
|
|
|
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND ANY
|
|
|
|
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
|
|
|
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
|
|
* DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE FOR
|
|
|
|
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
|
|
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
|
|
|
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
|
|
|
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
|
|
|
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
|
|
|
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
|
|
|
* SUCH DAMAGE.
|
|
|
|
*
|
|
|
|
* -C option added in 1998, original code by Marc Espie, based on FreeBSD
|
|
|
|
* behaviour
|
|
|
|
*/
|
2003-08-01 13:30:48 -07:00
|
|
|
|
2006-03-11 11:41:30 -08:00
|
|
|
#include <sys/types.h>
|
|
|
|
|
2014-11-25 02:26:07 -08:00
|
|
|
#include <limits.h>
|
2003-08-01 13:30:48 -07:00
|
|
|
#include <stdbool.h>
|
1995-10-18 01:37:01 -07:00
|
|
|
|
|
|
|
#define DEBUGGING
|
|
|
|
|
|
|
|
/* constants */
|
|
|
|
|
2003-07-21 07:00:41 -07:00
|
|
|
#define MAXHUNKSIZE 100000 /* is this enough lines? */
|
|
|
|
#define INITHUNKMAX 125 /* initial dynamic allocation size */
|
2019-12-02 14:17:32 -08:00
|
|
|
#define INITLINELEN 8192
|
1995-10-18 01:37:01 -07:00
|
|
|
#define BUFFERSIZE 1024
|
2014-11-25 02:26:07 -08:00
|
|
|
#define LINENUM_MAX LONG_MAX
|
1995-10-18 01:37:01 -07:00
|
|
|
|
|
|
|
#define ORIGEXT ".orig"
|
|
|
|
#define REJEXT ".rej"
|
|
|
|
|
|
|
|
/* handy definitions */
|
|
|
|
|
|
|
|
#define strNE(s1,s2) (strcmp(s1, s2))
|
|
|
|
#define strEQ(s1,s2) (!strcmp(s1, s2))
|
|
|
|
#define strnNE(s1,s2,l) (strncmp(s1, s2, l))
|
|
|
|
#define strnEQ(s1,s2,l) (!strncmp(s1, s2, l))
|
|
|
|
|
|
|
|
/* typedefs */
|
|
|
|
|
2003-07-21 07:00:41 -07:00
|
|
|
typedef long LINENUM; /* must be signed */
|
1995-10-18 01:37:01 -07:00
|
|
|
|
|
|
|
/* globals */
|
|
|
|
|
2006-03-11 11:41:30 -08:00
|
|
|
extern mode_t filemode;
|
1995-10-18 01:37:01 -07:00
|
|
|
|
2019-12-02 14:17:32 -08:00
|
|
|
extern char *buf; /* general purpose buffer */
|
|
|
|
extern size_t bufsz; /* general purpose buffer size */
|
1995-10-18 01:37:01 -07:00
|
|
|
|
2003-07-28 11:35:36 -07:00
|
|
|
extern bool using_plan_a; /* try to keep everything in memory */
|
|
|
|
extern bool out_of_mem; /* ran out of memory in plan a */
|
1995-10-18 01:37:01 -07:00
|
|
|
|
|
|
|
#define MAXFILEC 2
|
|
|
|
|
2003-07-28 11:35:36 -07:00
|
|
|
extern char *filearg[MAXFILEC];
|
|
|
|
extern bool ok_to_create_file;
|
|
|
|
extern char *outname;
|
|
|
|
extern char *origprae;
|
1995-10-18 01:37:01 -07:00
|
|
|
|
2003-07-28 11:35:36 -07:00
|
|
|
extern char *TMPOUTNAME;
|
|
|
|
extern char *TMPINNAME;
|
|
|
|
extern char *TMPREJNAME;
|
|
|
|
extern char *TMPPATNAME;
|
|
|
|
extern bool toutkeep;
|
|
|
|
extern bool trejkeep;
|
1995-10-18 01:37:01 -07:00
|
|
|
|
|
|
|
#ifdef DEBUGGING
|
2003-07-28 11:35:36 -07:00
|
|
|
extern int debug;
|
1995-10-18 01:37:01 -07:00
|
|
|
#endif
|
2003-07-28 11:35:36 -07:00
|
|
|
|
|
|
|
extern bool force;
|
|
|
|
extern bool batch;
|
|
|
|
extern bool verbose;
|
|
|
|
extern bool reverse;
|
|
|
|
extern bool noreverse;
|
|
|
|
extern bool skip_rest_of_patch;
|
|
|
|
extern int strippath;
|
|
|
|
extern bool canonicalize;
|
2003-07-22 10:18:49 -07:00
|
|
|
/* TRUE if -C was specified on command line. */
|
2003-07-28 11:35:36 -07:00
|
|
|
extern bool check_only;
|
2003-07-31 07:10:21 -07:00
|
|
|
extern bool warn_on_invalid_line;
|
2003-08-10 14:28:48 -07:00
|
|
|
extern bool last_line_missing_eol;
|
2003-07-22 10:18:49 -07:00
|
|
|
|
1995-10-18 01:37:01 -07:00
|
|
|
|
|
|
|
#define CONTEXT_DIFF 1
|
|
|
|
#define NORMAL_DIFF 2
|
|
|
|
#define ED_DIFF 3
|
|
|
|
#define NEW_CONTEXT_DIFF 4
|
|
|
|
#define UNI_DIFF 5
|
|
|
|
|
2003-07-28 11:35:36 -07:00
|
|
|
extern int diff_type;
|
|
|
|
extern char *revision; /* prerequisite revision, if any */
|
|
|
|
extern LINENUM input_lines; /* how long is input file in lines */
|
|
|
|
|
2003-10-31 12:20:45 -08:00
|
|
|
extern int posix;
|
1995-10-18 01:37:01 -07:00
|
|
|
|