xref: /illumos-gate/usr/src/cmd/diff/diff.h (revision 8365a6eace264590da157cd110d1ad159fdd448e)
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  /*
41   * Copyright 2022 OmniOS Community Edition (OmniOSce) Association.
42   */
43  
44  #ifndef	_DIFF_H
45  #define	_DIFF_H
46  
47  #ifdef	__cplusplus
48  extern "C" {
49  #endif
50  
51  /*
52   * Output format options
53   */
54  
55  int	opt;
56  
57  #define	D_NORMAL	0	/* Normal output */
58  #define	D_EDIT		-1	/* Editor script out */
59  #define	D_REVERSE	1	/* Reverse editor script */
60  #define	D_CONTEXT	2	/* Diff with context */
61  #define	D_IFDEF		3	/* Diff with merged #ifdef's */
62  #define	D_NREVERSE	4	/* Reverse ed script with numbered */
63  				/* lines and no trailing . */
64  
65  /*
66   * Constant declarations
67   */
68  #define	HALFMASK	0xf
69  
70  #define	prints(s)	fputs(s, stdout)
71  
72  #define	MAX_CONTEXT	128
73  
74  /*
75   * diff - directory comparison
76   */
77  #define	d_flags	d_ino
78  
79  #define	ONLY	1		/* Only in this directory */
80  #define	SAME	2		/* Both places and same */
81  #define	DIFFER	4		/* Both places and different */
82  #define	DIRECT	8		/* Directory */
83  
84  struct dir {
85  	ulong_t		d_ino;
86  	int16_t		d_reclen;
87  	int16_t		d_namlen;
88  	char		*d_entry;
89  };
90  
91  
92  /*
93   * type definitions
94   */
95  
96  struct cand {
97  	int x;
98  	int y;
99  	int pred;
100  } cand;
101  
102  struct line {
103  	int serial;
104  	int value;
105  } *file[2], line;
106  
107  /*
108   * The following struct is used to record change information when
109   * doing a "context" diff.  (see routine "change" to understand the
110   * highly mneumonic field names)
111   */
112  struct context_vec {
113  	int	a;	/* start line in old file */
114  	int	b;	/* end line in old file */
115  	int	c;	/* start line in new file */
116  	int	d;	/* end line in new file */
117  };
118  
119  
120  /*
121   * Algorithm related options
122   */
123  int bflag = 0;
124  int tflag = 0;
125  int wflag = 0;
126  int iflag = 0;
127  int qflag = 0;
128  int rflag = 0;
129  int lflag = 0;
130  int sflag = 0;
131  int hflag = 0;
132  int uflag = 0;
133  
134  /*
135   * Variables for D_IFDEF option.
136   */
137  int wantelses = 0;	/* used with D_IFDEF */
138  char *ifdef1, *ifdef2;  /* hold the ifdef strings */
139  char *endifname;
140  int inifdef = 0;
141  
142  /*
143   * Variables for -C (-c) context option.
144   */
145  int context = 0;	/* number of lines specfied with the C flag */
146  
147  char *empty = "";	/* the empty string */
148  
149  char **diffargv;	/* keep track of argv for diffdir */
150  
151  char start[256];	/* specify where to start, used with -S */
152  
153  FILE *input[2];		/* two input files */
154  int  len[2];
155  struct line *sfile[2];  /* shortened by pruning common prefix and suffix */
156  int  slen[2];
157  
158  struct stat stb1;
159  
160  /*
161   * Input file names.
162   * With diffdir, file1 and file2 are allocated BUFSIZ space,
163   * and padded with a '/', and then efile0 and efile1 point after
164   * the '/'.
165   */
166  char	*file1, *file2, *efile1, *efile2;
167  struct	stat stb1, stb2;
168  
169  /*
170   * input_file1 and input_file2 are to display
171   * the filenames in the output
172   */
173  char	*input_file1, *input_file2;
174  
175  char pr[] = "/usr/bin/pr";
176  char diff[] = "/usr/bin/diff";
177  char diffh[] = "/usr/lib/diffh";
178  int status = 2;
179  int anychange = 0;
180  
181  struct	context_vec	*context_vec_start,
182  			*context_vec_end,
183  			*context_vec_ptr;
184  
185  char tempfile[2][16];	/* used when comparing against std input */
186  			/* or char special devices */
187  int whichtemp;
188  
189  #ifdef	__cplusplus
190  }
191  #endif
192  
193  #endif	/* _DIFF_H */
194