xref: /illumos-gate/usr/src/cmd/diff/diff.h (revision 8b80e8cb6855118d46f605e91b5ed4ce83417395)
1 /*
2  * CDDL HEADER START
3  *
4  * The contents of this file are subject to the terms of the
5  * Common Development and Distribution License, Version 1.0 only
6  * (the "License").  You may not use this file except in compliance
7  * with the License.
8  *
9  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10  * or http://www.opensolaris.org/os/licensing.
11  * See the License for the specific language governing permissions
12  * and limitations under the License.
13  *
14  * When distributing Covered Code, include this CDDL HEADER in each
15  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16  * If applicable, add the following below this CDDL HEADER, with the
17  * fields enclosed by brackets "[]" replaced with your own identifying
18  * information: Portions Copyright [yyyy] [name of copyright owner]
19  *
20  * CDDL HEADER END
21  */
22 /*
23  * Copyright 2001 Sun Microsystems, Inc.  All rights reserved.
24  * Use is subject to license terms.
25  */
26 
27 /*	Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T	*/
28 /*	  All Rights Reserved  	*/
29 
30 /*
31  * University Copyright- Copyright (c) 1982, 1986, 1988
32  * The Regents of the University of California
33  * All Rights Reserved
34  *
35  * University Acknowledgment- Portions of this document are derived from
36  * software developed by the University of California, Berkeley, and its
37  * contributors.
38  */
39 
40 #ifndef	_DIFF_H
41 #define	_DIFF_H
42 
43 #pragma ident	"%Z%%M%	%I%	%E% SMI"
44 
45 
46 #ifdef	__cplusplus
47 extern "C" {
48 #endif
49 
50 /*
51  * Output format options
52  */
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_IFDEF		3	/* Diff with merged #ifdef's */
61 #define	D_NREVERSE	4	/* Reverse ed script with numbered */
62 				/* lines and no trailing . */
63 
64 /*
65  * Constant declarations
66  */
67 #define	HALFMASK	0xf
68 
69 #define	prints(s)	fputs(s, stdout)
70 
71 #define	MAX_CONTEXT	128
72 
73 /*
74  * diff - directory comparison
75  */
76 #define	d_flags	d_ino
77 
78 #define	ONLY	1		/* Only in this directory */
79 #define	SAME	2		/* Both places and same */
80 #define	DIFFER	4		/* Both places and different */
81 #define	DIRECT	8		/* Directory */
82 
83 struct dir {
84 	ulong_t		d_ino;
85 	int16_t		d_reclen;
86 	int16_t		d_namlen;
87 	char		*d_entry;
88 };
89 
90 
91 /*
92  * type definitions
93  */
94 
95 struct cand {
96 	int x;
97 	int y;
98 	int pred;
99 } cand;
100 
101 struct line {
102 	int serial;
103 	int value;
104 } *file[2], line;
105 
106 /*
107  * The following struct is used to record change information when
108  * doing a "context" diff.  (see routine "change" to understand the
109  * highly mneumonic field names)
110  */
111 struct context_vec {
112 	int	a;	/* start line in old file */
113 	int	b;	/* end line in old file */
114 	int	c;	/* start line in new file */
115 	int	d;	/* end line in new file */
116 };
117 
118 
119 /*
120  * Algorithm related options
121  */
122 int bflag = 0;
123 int tflag = 0;
124 int wflag = 0;
125 int iflag = 0;
126 int rflag = 0;
127 int lflag = 0;
128 int sflag = 0;
129 int hflag = 0;
130 int uflag = 0;
131 
132 /*
133  * Variables for D_IFDEF option.
134  */
135 int wantelses = 0;	/* used with D_IFDEF */
136 char *ifdef1, *ifdef2;  /* hold the ifdef strings */
137 char *endifname;
138 int inifdef = 0;
139 
140 /*
141  * Variables for -C (-c) context option.
142  */
143 int context = 0;	/* number of lines specfied with the C flag */
144 
145 char *empty = "";	/* the empty string */
146 
147 char **diffargv;	/* keep track of argv for diffdir */
148 
149 char start[256];	/* specify where to start, used with -S */
150 
151 FILE *input[2];		/* two input files */
152 int  len[2];
153 struct line *sfile[2];  /* shortened by pruning common prefix and suffix */
154 int  slen[2];
155 
156 struct stat stb1;
157 
158 /*
159  * Input file names.
160  * With diffdir, file1 and file2 are allocated BUFSIZ space,
161  * and padded with a '/', and then efile0 and efile1 point after
162  * the '/'.
163  */
164 char	*file1, *file2, *efile1, *efile2;
165 struct	stat stb1, stb2;
166 
167 /*
168  * input_file1 and input_file2 are to display
169  * the filenames in the output
170  */
171 char	*input_file1, *input_file2;
172 
173 char pr[] = "/usr/bin/pr";
174 char diff[] = "/usr/bin/diff";
175 char diffh[] = "/usr/lib/diffh";
176 int status = 2;
177 int anychange = 0;
178 
179 struct	context_vec	*context_vec_start,
180 			*context_vec_end,
181 			*context_vec_ptr;
182 
183 char tempfile[2][16];	/* used when comparing against std input */
184 			/* or char special devices */
185 int whichtemp;
186 
187 #ifdef	__cplusplus
188 }
189 #endif
190 
191 #endif	/* _DIFF_H */
192