diff.h revision 1.1
11.1Snia/*	$OpenBSD: diff.h,v 1.34 2020/11/01 18:16:08 jcs Exp $	*/
21.1Snia
31.1Snia/*-
41.1Snia * Copyright (c) 1991, 1993
51.1Snia *	The Regents of the University of California.  All rights reserved.
61.1Snia *
71.1Snia * Redistribution and use in source and binary forms, with or without
81.1Snia * modification, are permitted provided that the following conditions
91.1Snia * are met:
101.1Snia * 1. Redistributions of source code must retain the above copyright
111.1Snia *    notice, this list of conditions and the following disclaimer.
121.1Snia * 2. Redistributions in binary form must reproduce the above copyright
131.1Snia *    notice, this list of conditions and the following disclaimer in the
141.1Snia *    documentation and/or other materials provided with the distribution.
151.1Snia * 3. Neither the name of the University nor the names of its contributors
161.1Snia *    may be used to endorse or promote products derived from this software
171.1Snia *    without specific prior written permission.
181.1Snia *
191.1Snia * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
201.1Snia * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
211.1Snia * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
221.1Snia * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
231.1Snia * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
241.1Snia * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
251.1Snia * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
261.1Snia * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
271.1Snia * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
281.1Snia * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
291.1Snia * SUCH DAMAGE.
301.1Snia *
311.1Snia *	@(#)diff.h	8.1 (Berkeley) 6/6/93
321.1Snia */
331.1Snia
341.1Snia#include <sys/types.h>
351.1Snia
361.1Snia#include <stdbool.h>
371.1Snia#include <regex.h>
381.1Snia
391.1Snia/*
401.1Snia * Output format options
411.1Snia */
421.1Snia#define	D_NORMAL	0	/* Normal output */
431.1Snia#define	D_EDIT		-1	/* Editor script out */
441.1Snia#define	D_REVERSE	1	/* Reverse editor script */
451.1Snia#define	D_CONTEXT	2	/* Diff with context */
461.1Snia#define	D_UNIFIED	3	/* Unified context diff */
471.1Snia#define	D_IFDEF		4	/* Diff with merged #ifdef's */
481.1Snia#define	D_NREVERSE	5	/* Reverse ed script with numbered
491.1Snia				   lines and no trailing . */
501.1Snia#define	D_BRIEF		6	/* Say if the files differ */
511.1Snia#define	D_GFORMAT	7	/* Diff with defined changed group format */
521.1Snia#define D_SIDEBYSIDE    8	/* Side by side */
531.1Snia
541.1Snia#define	D_UNSET		-2
551.1Snia
561.1Snia
571.1Snia/*
581.1Snia * Output flags
591.1Snia */
601.1Snia#define	D_HEADER	0x001	/* Print a header/footer between files */
611.1Snia#define	D_EMPTY1	0x002	/* Treat first file as empty (/dev/null) */
621.1Snia#define	D_EMPTY2	0x004	/* Treat second file as empty (/dev/null) */
631.1Snia
641.1Snia/*
651.1Snia * Command line flags
661.1Snia */
671.1Snia#define D_FORCEASCII		0x008	/* Treat file as ascii regardless of content */
681.1Snia#define D_FOLDBLANKS		0x010	/* Treat all white space as equal */
691.1Snia#define D_MINIMAL		0x020	/* Make diff as small as possible */
701.1Snia#define D_IGNORECASE		0x040	/* Case-insensitive matching */
711.1Snia#define D_PROTOTYPE		0x080	/* Display C function prototype */
721.1Snia#define D_EXPANDTABS		0x100	/* Expand tabs to spaces */
731.1Snia#define D_IGNOREBLANKS		0x200	/* Ignore white space changes */
741.1Snia#define D_STRIPCR		0x400	/* Strip trailing cr */
751.1Snia#define D_SKIPBLANKLINES	0x800	/* Skip blank lines */
761.1Snia#define D_MATCHLAST		0x1000	/* Display last line matching provided regex */
771.1Snia
781.1Snia/*
791.1Snia * Status values for print_status() and diffreg() return values
801.1Snia */
811.1Snia#define	D_SAME		0	/* Files are the same */
821.1Snia#define	D_DIFFER	1	/* Files are different */
831.1Snia#define	D_BINARY	2	/* Binary files are different */
841.1Snia#define	D_MISMATCH1	3	/* path1 was a dir, path2 a file */
851.1Snia#define	D_MISMATCH2	4	/* path1 was a file, path2 a dir */
861.1Snia#define	D_SKIPPED1	5	/* path1 was a special file */
871.1Snia#define	D_SKIPPED2	6	/* path2 was a special file */
881.1Snia#define	D_ERROR		7	/* A file access error occurred */
891.1Snia
901.1Snia/*
911.1Snia * Color options
921.1Snia */
931.1Snia#define COLORFLAG_NEVER		0
941.1Snia#define COLORFLAG_AUTO		1
951.1Snia#define COLORFLAG_ALWAYS	2
961.1Snia
971.1Sniastruct excludes {
981.1Snia	char *pattern;
991.1Snia	struct excludes *next;
1001.1Snia};
1011.1Snia
1021.1Sniaextern bool	lflag, Nflag, Pflag, rflag, sflag, Tflag, cflag;
1031.1Sniaextern bool	ignore_file_case, suppress_common;
1041.1Sniaextern int	diff_format, diff_context, status;
1051.1Sniaextern int	width;
1061.1Sniaextern char	*start, *ifdefname, *diffargs, *label[2];
1071.1Sniaextern char	*ignore_pats, *most_recent_pat;
1081.1Sniaextern char	*group_format;
1091.1Sniaextern const char	*add_code, *del_code;
1101.1Sniaextern struct	stat stb1, stb2;
1111.1Sniaextern struct	excludes *excludes_list;
1121.1Sniaextern regex_t	ignore_re, most_recent_re;
1131.1Snia
1141.1Sniaint	diffreg(char *, char *, int);
1151.1Sniavoid	diffdir(char *, char *, int);
1161.1Sniavoid	print_status(int, char *, char *, const char *);
117