source: trunk/minix/commands/patch/common.h@ 10

Last change on this file since 10 was 9, checked in by Mattia Monga, 14 years ago

Minix 3.1.2a

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