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 * Copyright 2006-2018 J. Schilling 44 * 45 * @(#)diff.h 1.19 20/08/30 J. Schilling 46 */ 47 #if defined(sun) 48 #pragma ident "@(#)diff.h 1.19 20/08/30 J. Schilling" 49 #endif 50 51 #if defined(sun) 52 #pragma ident "@(#)diff.h 1.12 05/06/08 SMI" 53 #endif 54 55 56 #ifdef __cplusplus 57 extern "C" { 58 #endif 59 60 /* 61 * Output format options 62 */ 63 64 int opt; /* Holds one of the definitions from below */ 65 66 #define D_NORMAL 0 /* Normal output */ 67 #define D_EDIT -1 /* Editor script out */ 68 #define D_REVERSE 1 /* Reverse editor script */ 69 #define D_CONTEXT 2 /* Diff with context */ 70 #define D_IFDEF 3 /* Diff with merged #ifdef's */ 71 #define D_NREVERSE 4 /* Reverse ed script with numbered */ 72 /* lines and no trailing . */ 73 #define D_BRIEF 5 /* Say if the files differ */ 74 75 /* 76 * Constant declarations 77 */ 78 #define HALFMASK 0xf 79 80 #define prints(s) fputs(s, stdout) 81 82 #define MAX_CONTEXT 128 83 84 /* 85 * diff - directory comparison 86 */ 87 #define ONLY 1 /* Only in this directory */ 88 #define SAME 2 /* Both places and same */ 89 #define DIFFER 4 /* Both places and different */ 90 #define DIRECT 8 /* Directory */ 91 #define XDIRECT 16 /* Directory present only at right side */ 92 93 struct dir { 94 char d_flags; 95 dev_t d_dev1; 96 dev_t d_dev2; 97 ino_t d_ino1; 98 ino_t d_ino2; 99 char *d_entry; 100 }; 101 102 /* 103 * Structure used to check for directory loops. 104 */ 105 struct pdirs { 106 struct pdirs *p_last; 107 dev_t p_dev1; 108 dev_t p_dev2; 109 ino_t p_ino1; 110 ino_t p_ino2; 111 }; 112 113 /* 114 * type definitions 115 */ 116 117 struct cand { 118 int x; 119 int y; 120 int pred; 121 } cand; 122 123 struct line { 124 int serial; 125 int value; 126 } *file[2], line; 127 128 /* 129 * The following struct is used to record change information when 130 * doing a "context" diff. (see routine "change" to understand the 131 * highly mneumonic field names) 132 */ 133 struct context_vec { 134 int a; /* start line in old file */ 135 int b; /* end line in old file */ 136 int c; /* start line in new file */ 137 int d; /* end line in new file */ 138 }; 139 140 141 /* 142 * Algorithm related options 143 */ 144 int aflag = 0; 145 int bflag = 0; 146 int Bflag = 0; 147 int tflag = 0; 148 int wflag = 0; 149 int iflag = 0; 150 int rflag = 0; 151 int lflag = 0; 152 int sflag = 0; 153 int hflag = 0; 154 int uflag = 0; 155 int Nflag = 0; 156 int pflag = 0; 157 158 /* 159 * Variables for D_IFDEF option. 160 */ 161 int wantelses = 0; /* used with D_IFDEF */ 162 char *ifdef1, *ifdef2; /* hold the ifdef strings */ 163 char *endifname; 164 int inifdef = 0; 165 166 /* 167 * Variables for -C (-c) context option. 168 */ 169 int context = 0; /* number of lines specfied with the C flag */ 170 171 char *empty = ""; /* the empty string */ 172 173 char **diffargv; /* keep track of argv for diffdir */ 174 175 char *start; /* specify where to start, used with -S */ 176 177 FILE *input[2]; /* two input files */ 178 int len[2]; /* The number of lines in the two input files */ 179 struct line *sfile[2]; /* shortened by pruning common prefix and suffix */ 180 int slen[2]; /* Shortened (by pref and suff) number of lines */ 181 182 /* 183 * Input file names. 184 * With diffdir, file1 and file2 are allocated BUFSIZ space, 185 * and padded with a '/', and then efile0 and efile1 point after 186 * the '/'. 187 */ 188 char *file1, *file2, *efile1, *efile2; 189 struct stat stb1, stb2; 190 int file1ok; 191 int file2ok; 192 193 /* 194 * input_file1 and input_file2 are to display 195 * the filenames in the output 196 */ 197 char *input_file1, *input_file2; 198 199 char pr[] = "/usr/bin/pr"; 200 201 #if defined(INS_BASE) 202 #ifdef __STDC__ 203 char diff[] = INS_BASE "/" SCCS_BIN_PRE "bin/diff"; 204 char diffh[] = INS_BASE "/" SCCS_BIN_PRE "lib/diffh"; 205 #else 206 char diff[] = "/usr/ccs/bin/diff"; 207 char diffh[] = "/usr/ccs/lib/diffh"; 208 #endif 209 #else 210 char diff[] = "/usr/bin/diff"; 211 char diffh[] = "/usr/lib/diffh"; 212 #endif 213 int status = 2; 214 int anychange = 0; 215 216 struct context_vec *context_vec_start, 217 *context_vec_end, 218 *context_vec_ptr; 219 220 char tempfile[2][16]; /* used when comparing against std input */ 221 /* or char special devices */ 222 int whichtemp; 223 224 #ifdef __cplusplus 225 } 226 #endif 227 228 #endif /* _DIFF_H */ 229