Fix markup. Fix backslashes to surive roff.
[netbsd-mini2440.git] / usr.bin / rcs / src / rcsbase.h
blobfcf6fe6a195eb68da9aab5010524dc112930727a
2 /*
3 * RCS common definitions and data structures
4 */
5 #define RCSBASE "$Id: rcsbase.h,v 1.1 1993/03/21 09:58:07 cgd Exp $"
7 /* Copyright (C) 1982, 1988, 1989 Walter Tichy
8 * All rights reserved.
10 * Redistribution and use in source and binary forms are permitted
11 * provided that the above copyright notice and this paragraph are
12 * duplicated in all such forms and that any documentation,
13 * advertising materials, and other materials related to such
14 * distribution and use acknowledge that the software was developed
15 * by Walter Tichy.
16 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
17 * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
18 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
20 * Report all problems and direct all questions to:
21 * rcs-bugs@cs.purdue.edu
34 /*****************************************************************************
35 * INSTRUCTIONS:
36 * =============
37 * The following should be handled in the Makefile:
38 * For USG Unix, define USG; for BSD Unix, don't (see ifdef USG).
39 * For 4.2 bsd, define V4_2BSD; this will replace the routines
40 * getwd() and rename() with the corresponding ones in the C-library.
41 * V4_2BSD also selects different definitions for the macros NCPFN and NCPPN
42 * (max. number of characters per filename, number of characters per path name).
43 * Define STRICT_LOCKING appropriately (see STRICT_LOCKING).
44 * The following need be changed for porting to a different machine:
45 * Define SMALLOG for a machine with small memory (like the PDP11).
46 * SMALLOG conserves space for log messages.
47 * Change BYTESIZ if necessary.
48 * If you need to change the comment leaders, update the table comtable[]
49 * in rcsfnms.c. (This can wait until you know what a comment leader is.)
50 *****************************************************************************
54 /* $Log: rcsbase.h,v $
55 * Revision 4.9 89/05/01 15:17:14 narten
56 * botched previous USG fix
58 * Revision 4.8 89/05/01 14:53:05 narten
59 * changed #include <strings.h> -> string.h for USG systems.
61 * Revision 4.7 88/11/08 15:58:45 narten
62 * removed defs for functions loaded from libraries
64 * Revision 4.6 88/11/08 12:04:06 narten
65 * changes from eggert@sm.unisys.com (Paul Eggert)
67 * Revision 4.6 88/08/09 19:12:36 eggert
68 * Shrink stdio code size; remove lint; permit -Dhshsize=nn.
70 * Revision 4.5 87/12/18 17:06:41 narten
71 * made removed BSD ifdef, now uses V4_2BSD
73 * Revision 4.4 87/10/18 10:29:49 narten
74 * Updating version numbers
75 * Changes relative to 1.1 are actually relative to 4.2
77 * Revision 1.3 87/09/24 14:02:25 narten
78 * changes for lint
80 * Revision 1.2 87/03/27 14:22:02 jenkins
81 * Port to suns
83 * Revision 1.1 84/01/23 14:50:14 kcs
84 * Initial revision
86 * Revision 4.2 83/12/20 16:04:20 wft
87 * merged 3.6.1.1 and 4.1 (SMALLOG, logsize).
88 * moved setting of STRICT_LOCKING to Makefile.
89 * changed DOLLAR to UNKN (conflict with KDELIM).
91 * Revision 4.1 83/05/04 09:12:41 wft
92 * Added markers Id and RCSfile.
93 * Added Dbranch for default branches.
95 * Revision 3.6.1.1 83/12/02 21:56:22 wft
96 * Increased logsize, added macro SMALLOG.
98 * Revision 3.6 83/01/15 16:43:28 wft
99 * 4.2 prerelease
101 * Revision 3.6 83/01/15 16:43:28 wft
102 * Replaced dbm.h with BYTESIZ, fixed definition of rindex().
103 * Added variants of NCPFN and NCPPN for bsd 4.2, selected by defining V4_2BSD.
104 * Added macro DELNUMFORM to have uniform format for printing delta text nodes.
105 * Added macro DELETE to mark deleted deltas.
107 * Revision 3.5 82/12/10 12:16:56 wft
108 * Added two forms of DATEFORM, one using %02d, the other %.2d.
110 * Revision 3.4 82/12/04 20:01:25 wft
111 * added LOCKER, Locker, and USG (redefinition of rindex).
113 * Revision 3.3 82/12/03 12:22:04 wft
114 * Added dbm.h, stdio.h, RCSBASE, RCSSEP, RCSSUF, WORKMODE, TMPFILE3,
115 * PRINTDATE, PRINTTIME, map, and ctab; removed Suffix. Redefined keyvallength
116 * using NCPPN. Changed putc() to abort on write error.
118 * Revision 3.2 82/10/18 15:03:52 wft
119 * added macro STRICT_LOCKING, removed RCSUMASK.
120 * renamed JOINFILE[1,2] to JOINFIL[1,2].
122 * Revision 3.1 82/10/11 19:41:17 wft
123 * removed NBPW, NBPC, NCPW.
124 * added typdef int void to aid compiling
129 #include <stdio.h>
130 #ifdef USG
131 #include <string.h>
132 #else
133 #include <strings.h>
134 #endif
135 #undef putc /* will be redefined */
138 #ifdef USG
139 # define rindex strrchr
140 # define DATEFORM "%.2d.%.2d.%.2d.%.2d.%.2d.%.2d"
141 #else
142 # define DATEFORM "%02d.%02d.%02d.%02d.%02d.%02d"
143 #endif
144 /* Make sure one of %02d or %.2d prints a number with a field width 2, with
145 * leading zeroes. For example, 0, 1, and 22 must be printed as 00, 01, and
146 * 22. Otherwise, there will be problems with the dates.
149 #define PRINTDATE(file,date) fprintf(file,"%.2s/%.2s/%.2s",date,date+3,date+6)
150 #define PRINTTIME(file,date) fprintf(file,"%.2s:%.2s:%.2s",date+9,date+12,date+15)
151 /* print RCS format date and time in nice format from a string */
154 * Parameters
156 #define BYTESIZ 8 /* number of bits in a byte */
158 /*#define STRICT_LOCKING 0 /* 0 sets the default locking to non-strict; */
159 /* used in experimental environments. */
160 /* 1 sets the default locking to strict; */
161 /* used in production environments. */
162 /* STRICT_LOCKING is set in the Makefile! */
163 #ifndef hshsize
164 #define hshsize 239 /* hashtable size; MUST be prime and -1 mod 4 */
165 /* other choices: 547 or 719 */
166 #endif
168 #define strtsize (hshsize * 50) /* string table size */
169 #ifdef SMALLOG
170 # define logsize 1024 /* max. size of log message for pdp11 */
171 #else
172 # define logsize 4096 /* max. size of log message for others */
173 #endif
174 #define revlength 30 /* max. length of revision numbers */
175 #define datelength 20 /* length of a date in RCS format */
176 #define joinlength 20 /* number of joined revisions permitted */
177 #define RCSDIR "RCS/" /* subdirectory for RCS files */
178 #define RCSSUF 'v' /* suffix for RCS files */
179 #define RCSSEP ',' /* separator for RCSSUF */
180 #define KDELIM '$' /* delimiter for keywords */
181 #define VDELIM ':' /* separates keywords from values */
182 #define DEFAULTSTATE "Exp" /* default state of revisions */
183 #ifdef V4_2BSD
184 # define NCPFN 256 /* number of characters per filename */
185 # define NCPPN 1024 /* number of characters per pathname */
186 #else
187 # define NCPFN 14 /* number of characters per filename */
188 # define NCPPN 6*NCPFN /* number of characters per pathname */
189 #endif
190 #define keylength 20 /* buffer length for expansion keywords */
191 #define keyvallength NCPPN+revlength+datelength+60
192 /* buffer length for keyword expansion */
196 #define true 1
197 #define false 0
198 #define nil 0
199 #define elsif else if
200 #define elif else if
203 /* temporary file names */
205 #define NEWRCSFILE ",RCSnewXXXXXX"
206 #define DIFFILE ",RCSciXXXXXX"
207 #define TMPFILE1 ",RCSt1XXXXXX"
208 #define TMPFILE2 ",RCSt2XXXXXX"
209 #define TMPFILE3 ",RCSt3XXXXXX"
210 #define JOINFIL2 ",RCSj2XXXXXX"
211 #define JOINFIL3 ",RCSj3XXXXXX"
214 #ifdef _FSTDIO
215 #define putc(x,p) (--(p)->_w < 0 ? wbuf((unsigned)(x), p) : \
216 (*(p)->_p = (x), (int)*(p)->_p++))
217 #else
218 #define putc(x,p) (--(p)->_cnt>=0? ((int)(*(p)->_ptr++=(unsigned)(x))):fflsbuf((unsigned)(x),p))
219 #endif
220 /* This version of putc prints a char, but aborts on write error */
222 #define GETC(in,out,echo) (c=getc(in), echo?putc(c,out):c)
223 /* GETC modifies a local variable c; a kludge, but smaller and faster. */
224 /* GETC writes a del-character (octal 177) on end of file */
226 #define WORKMODE(RCSmode) (RCSmode&~0222)|((lockflag||!StrictLocks)?0600:0000)
227 /* computes mode of working file: same as RCSmode, but write permission */
228 /* determined by lockflag and StrictLocks. */
231 /* character classes and token codes */
232 enum tokens {
233 /* char classes*/ DIGIT, IDCHAR, NEWLN, LETTER, PERIOD, SBEGIN, SPACE, UNKN,
234 /* tokens */ COLON, DATE, EOFILE, ID, KEYW, NUM, SEMI, STRING,
237 #define AT SBEGIN /* class SBEGIN (string begin) is returned by lex. anal. */
238 #define SDELIM '@' /* the actual character is needed for string handling*/
239 /* these must be changed consistently, for instance to:
240 * #define DQUOTE SBEGIN
241 * #define SDELIM '"'
242 * #define AT IDCHAR
243 * there should be no overlap among SDELIM, KDELIM, and VDELIM
246 /* other characters */
248 #define ACCENT IDCHAR
249 #define AMPER IDCHAR
250 #define BACKSL IDCHAR
251 #define BAR IDCHAR
252 #define COMMA UNKN
253 #define DIVIDE IDCHAR
254 #define DOLLAR UNKN /* overlap with KDELIM */
255 #define DQUOTE IDCHAR
256 #define EQUAL IDCHAR
257 #define EXCLA IDCHAR
258 #define GREAT IDCHAR
259 #define HASH IDCHAR
260 #define INSERT UNKN
261 #define LBRACE IDCHAR
262 #define LBRACK IDCHAR
263 #define LESS IDCHAR
264 #define LPARN IDCHAR
265 #define MINUS IDCHAR
266 #define PERCNT IDCHAR
267 #define PLUS IDCHAR
268 #define QUEST IDCHAR
269 #define RBRACE IDCHAR
270 #define RBRACK IDCHAR
271 #define RPARN IDCHAR
272 #define SQUOTE IDCHAR
273 #define TILDE IDCHAR
274 #define TIMES IDCHAR
275 #define UNDER IDCHAR
276 #define UPARR IDCHAR
281 /***************************************
282 * Data structures for the symbol table
283 ***************************************/
286 /* Hash table entry */
287 struct hshentry {
288 char * num; /* pointer to revision number (ASCIZ) */
289 char * date; /* pointer to date of checking */
290 char * author; /* login of person checking in */
291 char * lockedby; /* who locks the revision */
292 char * log; /* log message requested at checkin */
293 char * state; /* state of revision (Exp by default) */
294 struct branchhead * branches; /* list of first revisions on branches*/
295 struct hshentry * next; /* next revision on same branch */
296 int insertlns;/* lines inserted (computed by rlog) */
297 int deletelns;/* lines deleted (computed by rlog) */
298 char selector; /* marks entry for selection/deletion */
301 /* list element for branch lists */
302 struct branchhead {
303 struct hshentry * hsh;
304 struct branchhead * nextbranch;
307 /* accesslist element */
308 struct access {
309 char * login;
310 struct access * nextaccess;
313 /* list element for locks */
314 struct lock {
315 char * login;
316 struct hshentry * delta;
317 struct lock * nextlock;
320 /* list element for symbolic names */
321 struct assoc {
322 char * symbol;
323 struct hshentry * delta;
324 struct assoc * nextassoc;
328 /* common variables (getadmin and getdelta())*/
329 extern char * Comment;
330 extern struct access * AccessList;
331 extern struct assoc * Symbols;
332 extern struct lock * Locks;
333 extern struct hshentry * Head;
334 extern struct hshentry * Dbranch;
335 extern int StrictLocks;
336 extern int TotalDeltas;
337 #ifndef lint
338 static char copyright[]="Copyright (C) 1982 by Walter F. Tichy";
339 #endif
341 /* common variables (lexical analyzer)*/
342 extern enum tokens map[];
343 #define ctab (&map[1])
344 extern enum tokens nexttok;
345 extern int hshenter;
346 extern char * NextString;
347 extern char * cmdid;
349 #if defined(USG) || defined(V4_2BSD)
350 #define VOID (void)
351 #else
352 typedef int void;
353 #define VOID
354 #endif
356 /* common routines */
357 extern char *talloc();
358 extern int serror();
359 extern int faterror();
360 extern int fatserror();
361 extern void ignoreints();
362 extern void catchints();
363 extern void restoreints();
365 #ifdef USG
366 extern int sprintf();
367 #endif
370 * Markers for keyword expansion (used in co and ident)
372 #define AUTHOR "Author"
373 #define DATE "Date"
374 #define HEADER "Header"
375 #define IDH "Id"
376 #define LOCKER "Locker"
377 #define LOG "Log"
378 #define RCSFILE "RCSfile"
379 #define REVISION "Revision"
380 #define SOURCE "Source"
381 #define STATE "State"
383 enum markers { Nomatch, Author, Date, Header, Id,
384 Locker, Log, RCSfile, Revision, Source, State };
386 #define DELNUMFORM "\n\n%s\n%s\n"
387 /* used by putdtext and scanlogtext */
388 #define DELETE 'D'
389 /* set by rcs -o and used by puttree() in rcssyn */