1*ce7279d8Sjsg /* $OpenBSD: diff.h,v 1.35 2024/05/21 05:00:48 jsg Exp $ */ 2d0c3f575Sderaadt 3abb4f62aSjcs /* 44ec4b3d5Smillert * Copyright (c) 1991, 1993 54ec4b3d5Smillert * The Regents of the University of California. All rights reserved. 6d0c3f575Sderaadt * 7d0c3f575Sderaadt * Redistribution and use in source and binary forms, with or without 8d0c3f575Sderaadt * modification, are permitted provided that the following conditions 9d0c3f575Sderaadt * are met: 104ec4b3d5Smillert * 1. Redistributions of source code must retain the above copyright 114ec4b3d5Smillert * notice, this list of conditions and the following disclaimer. 12d0c3f575Sderaadt * 2. Redistributions in binary form must reproduce the above copyright 13d0c3f575Sderaadt * notice, this list of conditions and the following disclaimer in the 14d0c3f575Sderaadt * documentation and/or other materials provided with the distribution. 154ec4b3d5Smillert * 3. Neither the name of the University nor the names of its contributors 164ec4b3d5Smillert * may be used to endorse or promote products derived from this software 174ec4b3d5Smillert * without specific prior written permission. 18d0c3f575Sderaadt * 194ec4b3d5Smillert * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 204ec4b3d5Smillert * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 214ec4b3d5Smillert * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 224ec4b3d5Smillert * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 234ec4b3d5Smillert * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 244ec4b3d5Smillert * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 254ec4b3d5Smillert * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 264ec4b3d5Smillert * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 274ec4b3d5Smillert * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 284ec4b3d5Smillert * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 294ec4b3d5Smillert * SUCH DAMAGE. 304ec4b3d5Smillert * 314ec4b3d5Smillert * @(#)diff.h 8.1 (Berkeley) 6/6/93 32d0c3f575Sderaadt */ 33d0c3f575Sderaadt 34ccd55a2cSotto #include <sys/types.h> 35ccd55a2cSotto #include <regex.h> 36ccd55a2cSotto 37ae8d569bSderaadt /* 38ae8d569bSderaadt * Output format options 39ae8d569bSderaadt */ 40ae8d569bSderaadt #define D_NORMAL 0 /* Normal output */ 41ae8d569bSderaadt #define D_EDIT -1 /* Editor script out */ 42ae8d569bSderaadt #define D_REVERSE 1 /* Reverse editor script */ 43ae8d569bSderaadt #define D_CONTEXT 2 /* Diff with context */ 44c42aed39Smillert #define D_UNIFIED 3 /* Unified context diff */ 45c42aed39Smillert #define D_IFDEF 4 /* Diff with merged #ifdef's */ 46c42aed39Smillert #define D_NREVERSE 5 /* Reverse ed script with numbered 47ae8d569bSderaadt lines and no trailing . */ 48cab5d83cSmillert #define D_BRIEF 6 /* Say if the files differ */ 49ae8d569bSderaadt 504ec4b3d5Smillert /* 514ec4b3d5Smillert * Output flags 524ec4b3d5Smillert */ 53dba1d6eaSray #define D_HEADER 0x001 /* Print a header/footer between files */ 54dba1d6eaSray #define D_EMPTY1 0x002 /* Treat first file as empty (/dev/null) */ 55dba1d6eaSray #define D_EMPTY2 0x004 /* Treat second file as empty (/dev/null) */ 56dba1d6eaSray 57dba1d6eaSray /* 58dba1d6eaSray * Command line flags 59dba1d6eaSray */ 60dba1d6eaSray #define D_FORCEASCII 0x008 /* Treat file as ascii regardless of content */ 61dba1d6eaSray #define D_FOLDBLANKS 0x010 /* Treat all white space as equal */ 62dba1d6eaSray #define D_MINIMAL 0x020 /* Make diff as small as possible */ 63dba1d6eaSray #define D_IGNORECASE 0x040 /* Case-insensitive matching */ 64dba1d6eaSray #define D_PROTOTYPE 0x080 /* Display C function prototype */ 65dba1d6eaSray #define D_EXPANDTABS 0x100 /* Expand tabs to spaces */ 66dba1d6eaSray #define D_IGNOREBLANKS 0x200 /* Ignore white space changes */ 67ae8d569bSderaadt 68b4bca33fSmillert /* 69b4bca33fSmillert * Status values for print_status() and diffreg() return values 70b4bca33fSmillert */ 71b4bca33fSmillert #define D_SAME 0 /* Files are the same */ 72b4bca33fSmillert #define D_DIFFER 1 /* Files are different */ 73b4bca33fSmillert #define D_BINARY 2 /* Binary files are different */ 7440e7295bSmillert #define D_MISMATCH1 3 /* path1 was a dir, path2 a file */ 7540e7295bSmillert #define D_MISMATCH2 4 /* path1 was a file, path2 a dir */ 7640e7295bSmillert #define D_SKIPPED1 5 /* path1 was a special file */ 7740e7295bSmillert #define D_SKIPPED2 6 /* path2 was a special file */ 78b4bca33fSmillert 794ec4b3d5Smillert struct excludes { 804ec4b3d5Smillert char *pattern; 814ec4b3d5Smillert struct excludes *next; 824ec4b3d5Smillert }; 834ec4b3d5Smillert 8440e7295bSmillert extern int Nflag, Pflag, rflag, sflag, Tflag; 8557003866Sray extern int diff_format, diff_context, status; 867bdb251cSmillert extern char *start, *ifdefname, *diffargs, *label[2], *ignore_pats; 874ec4b3d5Smillert extern struct stat stb1, stb2; 884ec4b3d5Smillert extern struct excludes *excludes_list; 89ccd55a2cSotto extern regex_t ignore_re; 904ec4b3d5Smillert 914ec4b3d5Smillert char *splice(char *, char *); 92b4bca33fSmillert int diffreg(char *, char *, int); 933f8e756bSray void diffdir(char *, char *, int); 944893e147Smillert void print_only(const char *, size_t, const char *); 95b4bca33fSmillert void print_status(int, char *, char *, char *); 96