add affiliation for Oz
[unix-history] / usr / src / usr.bin / patch / common.h
CommitLineData
26494f61
KB
1/* $Header: common.h,v 2.0 86/09/17 15:36:39 lwall Exp $
2 *
3 * $Log: common.h,v $
4 * Revision 2.0 86/09/17 15:36:39 lwall
5 * Baseline for netwide release.
6 *
7 */
8
9#define DEBUGGING
10
11#include "config.h"
12
13/* shut lint up about the following when return value ignored */
14
15#define Signal (void)signal
16#define Unlink (void)unlink
17#define Lseek (void)lseek
18#define Fseek (void)fseek
19#define Fstat (void)fstat
20#define Pclose (void)pclose
21#define Close (void)close
22#define Fclose (void)fclose
23#define Fflush (void)fflush
24#define Sprintf (void)sprintf
25#define Mktemp (void)mktemp
26#define Strcpy (void)strcpy
27#define Strcat (void)strcat
28
29#include <stdio.h>
30#include <assert.h>
31#include <sys/types.h>
32#include <sys/stat.h>
33#include <ctype.h>
34#include <signal.h>
35
36/* constants */
37
38#define TRUE (1)
39#define FALSE (0)
40
41#define MAXHUNKSIZE 100000 /* is this enough lines? */
42#define INITHUNKMAX 125 /* initial dynamic allocation size */
43#define MAXLINELEN 1024
44#define BUFFERSIZE 1024
45#define ORIGEXT ".orig"
46#define SCCSPREFIX "s."
47#define GET "get -e %s"
48#define RCSSUFFIX ",v"
49#define CHECKOUT "co -l %s"
50
51/* handy definitions */
52
53#define Null(t) ((t)0)
54#define Nullch Null(char *)
55#define Nullfp Null(FILE *)
56#define Nulline Null(LINENUM)
57
58#define Ctl(ch) ((ch) & 037)
59
60#define strNE(s1,s2) (strcmp(s1, s2))
61#define strEQ(s1,s2) (!strcmp(s1, s2))
62#define strnNE(s1,s2,l) (strncmp(s1, s2, l))
63#define strnEQ(s1,s2,l) (!strncmp(s1, s2, l))
64
65/* typedefs */
66
67typedef char bool;
68typedef long LINENUM; /* must be signed */
69typedef unsigned MEM; /* what to feed malloc */
70
71/* globals */
72
73EXT int Argc; /* guess */
74EXT char **Argv;
75EXT int Argc_last; /* for restarting plan_b */
76EXT char **Argv_last;
77
78EXT struct stat filestat; /* file statistics area */
79EXT int filemode INIT(0644);
80
81EXT char buf[MAXLINELEN]; /* general purpose buffer */
82EXT FILE *ofp INIT(Nullfp); /* output file pointer */
83EXT FILE *rejfp INIT(Nullfp); /* reject file pointer */
84
85EXT bool using_plan_a INIT(TRUE); /* try to keep everything in memory */
86EXT bool out_of_mem INIT(FALSE); /* ran out of memory in plan a */
87
88#define MAXFILEC 2
89EXT int filec INIT(0); /* how many file arguments? */
90EXT char *filearg[MAXFILEC];
91EXT bool ok_to_create_file INIT(FALSE);
92EXT char *bestguess INIT(Nullch); /* guess at correct filename */
93
94EXT char *outname INIT(Nullch);
95EXT char rejname[128];
96
97EXT char *origext INIT(Nullch);
98
99EXT char TMPOUTNAME[] INIT("/tmp/patchoXXXXXX");
100EXT char TMPINNAME[] INIT("/tmp/patchiXXXXXX"); /* might want /usr/tmp here */
101EXT char TMPREJNAME[] INIT("/tmp/patchrXXXXXX");
102EXT char TMPPATNAME[] INIT("/tmp/patchpXXXXXX");
103EXT bool toutkeep INIT(FALSE);
104EXT bool trejkeep INIT(FALSE);
105
106EXT LINENUM last_offset INIT(0);
107#ifdef DEBUGGING
108EXT int debug INIT(0);
109#endif
110EXT LINENUM maxfuzz INIT(2);
111EXT bool force INIT(FALSE);
112EXT bool verbose INIT(TRUE);
113EXT bool reverse INIT(FALSE);
114EXT bool noreverse INIT(FALSE);
115EXT bool skip_rest_of_patch INIT(FALSE);
116EXT int strippath INIT(957);
117EXT bool canonicalize INIT(FALSE);
118
119#define CONTEXT_DIFF 1
120#define NORMAL_DIFF 2
121#define ED_DIFF 3
122#define NEW_CONTEXT_DIFF 4
123EXT int diff_type INIT(0);
124
125EXT bool do_defines INIT(FALSE); /* patch using ifdef, ifndef, etc. */
126EXT char if_defined[128]; /* #ifdef xyzzy */
127EXT char not_defined[128]; /* #ifndef xyzzy */
128EXT char else_defined[] INIT("#else\n");/* #else */
129EXT char end_defined[128]; /* #endif xyzzy */
130
131EXT char *revision INIT(Nullch); /* prerequisite revision, if any */
132
133char *malloc();
134char *realloc();
135char *strcpy();
136char *strcat();
26494f61
KB
137long atol();
138long lseek();
139char *mktemp();