xref: /openbsd-src/usr.bin/diff/diff.h (revision 49dffe13d7fe900b7adc58a2f8d6809cffbe02d7)
1 /*	$OpenBSD: diff.h,v 1.7 2003/06/25 21:43:49 millert Exp $	*/
2 
3 /*
4  * Copyright (C) Caldera International Inc.  2001-2002.
5  * All rights reserved.
6  *
7  * Redistribution and use in source and binary forms, with or without
8  * modification, are permitted provided that the following conditions
9  * are met:
10  * 1. Redistributions of source code and documentation must retain the above
11  *    copyright notice, this list of conditions and the following disclaimer.
12  * 2. Redistributions in binary form must reproduce the above copyright
13  *    notice, this list of conditions and the following disclaimer in the
14  *    documentation and/or other materials provided with the distribution.
15  * 3. All advertising materials mentioning features or use of this software
16  *    must display the following acknowledgement:
17  *	This product includes software developed or owned by Caldera
18  *	International, Inc.
19  * 4. Neither the name of Caldera International, Inc. nor the names of other
20  *    contributors may be used to endorse or promote products derived from
21  *    this software without specific prior written permission.
22  *
23  * USE OF THE SOFTWARE PROVIDED FOR UNDER THIS LICENSE BY CALDERA
24  * INTERNATIONAL, INC. AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR
25  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
26  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
27  * IN NO EVENT SHALL CALDERA INTERNATIONAL, INC. BE LIABLE FOR ANY DIRECT,
28  * INDIRECT INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29  * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
30  * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
31  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
32  * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
33  * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
34  * POSSIBILITY OF SUCH DAMAGE.
35  */
36 
37 /*	diff.h	4.7	85/08/16	*/
38 
39 /*
40  * diff - common declarations
41  */
42 
43 #include <sys/param.h>
44 #include <sys/stat.h>
45 
46 #include <ctype.h>
47 #include <err.h>
48 #include <signal.h>
49 #include <stdio.h>
50 
51 /*
52  * Output format options
53  */
54 int	opt;
55 
56 #define	D_NORMAL	0	/* Normal output */
57 #define	D_EDIT		-1	/* Editor script out */
58 #define	D_REVERSE	1	/* Reverse editor script */
59 #define	D_CONTEXT	2	/* Diff with context */
60 #define	D_UNIFIED	3	/* Unified context diff */
61 #define	D_IFDEF		4	/* Diff with merged #ifdef's */
62 #define	D_NREVERSE	5	/* Reverse ed script with numbered
63 				   lines and no trailing . */
64 
65 int	tflag;			/* expand tabs on output */
66 
67 /*
68  * Algorithm related options
69  */
70 int	hflag;			/* -h, use halfhearted DIFFH */
71 int	bflag;			/* ignore blanks in comparisons */
72 int	wflag;			/* totally ignore blanks in comparisons */
73 int	iflag;			/* ignore case in comparisons */
74 
75 /*
76  * Options on hierarchical diffs.
77  */
78 int	lflag;			/* long output format with header */
79 int	rflag;			/* recursively trace directories */
80 int	sflag;			/* announce files which are same */
81 char	*start;			/* do file only if name >= this */
82 
83 /*
84  * Variables for -I D_IFDEF option.
85  */
86 int	wantelses;		/* -E */
87 char	*ifdef1;		/* String for -1 */
88 char	*ifdef2;		/* String for -2 */
89 char	*endifname;		/* What we will print on next #endif */
90 int	inifdef;
91 
92 /*
93  * Variables for -c context option.
94  */
95 int	context;		/* lines of context to be printed */
96 
97 /*
98  * State for exit status.
99  */
100 int	status;
101 int	anychange;
102 char	*tempfile;		/* used when comparing against std input */
103 
104 /*
105  * Variables for diffdir.
106  */
107 char	**diffargv;		/* option list to pass to recursive diffs */
108 
109 /*
110  * Input file names.
111  * With diffdir, file1 and file2 are allocated BUFSIZ space,
112  * and padded with a '/', and then efile0 and efile1 point after
113  * the '/'.
114  */
115 char	*file1, *file2, *efile1, *efile2;
116 struct	stat stb1, stb2;
117 
118 void	*emalloc(size_t);
119 void	*erealloc(void *, size_t);
120 char	*splice(char *, char *);
121 char	*copytemp(void);
122 void	diffdir(char **);
123 void	diffreg(void);
124 int	max(int, int);
125 int	min(int, int);
126 __dead void done(int);
127 
128 extern	char diffh[], diff[], pr[];
129