3 * RCS common definitions and data structures
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
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
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 /*****************************************************************************
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
80 * Revision 1.2 87/03/27 14:22:02 jenkins
83 * Revision 1.1 84/01/23 14:50:14 kcs
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
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
135 #undef putc /* will be redefined */
139 # define rindex strrchr
140 # define DATEFORM "%.2d.%.2d.%.2d.%.2d.%.2d.%.2d"
142 # define DATEFORM "%02d.%02d.%02d.%02d.%02d.%02d"
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 */
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! */
164 #define hshsize 239 /* hashtable size; MUST be prime and -1 mod 4 */
165 /* other choices: 547 or 719 */
168 #define strtsize (hshsize * 50) /* string table size */
170 # define logsize 1024 /* max. size of log message for pdp11 */
172 # define logsize 4096 /* max. size of log message for others */
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 */
184 # define NCPFN 256 /* number of characters per filename */
185 # define NCPPN 1024 /* number of characters per pathname */
187 # define NCPFN 14 /* number of characters per filename */
188 # define NCPPN 6*NCPFN /* number of characters per pathname */
190 #define keylength 20 /* buffer length for expansion keywords */
191 #define keyvallength NCPPN+revlength+datelength+60
192 /* buffer length for keyword expansion */
199 #define elsif 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"
215 #define putc(x,p) (--(p)->_w < 0 ? wbuf((unsigned)(x), p) : \
216 (*(p)->_p = (x), (int)*(p)->_p++))
218 #define putc(x,p) (--(p)->_cnt>=0? ((int)(*(p)->_ptr++=(unsigned)(x))):fflsbuf((unsigned)(x),p))
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 */
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
243 * there should be no overlap among SDELIM, KDELIM, and VDELIM
246 /* other characters */
248 #define ACCENT IDCHAR
250 #define BACKSL IDCHAR
253 #define DIVIDE IDCHAR
254 #define DOLLAR UNKN /* overlap with KDELIM */
255 #define DQUOTE IDCHAR
261 #define LBRACE IDCHAR
262 #define LBRACK IDCHAR
266 #define PERCNT IDCHAR
269 #define RBRACE IDCHAR
270 #define RBRACK IDCHAR
272 #define SQUOTE IDCHAR
281 /***************************************
282 * Data structures for the symbol table
283 ***************************************/
286 /* Hash table entry */
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 */
303 struct hshentry
* hsh
;
304 struct branchhead
* nextbranch
;
307 /* accesslist element */
310 struct access
* nextaccess
;
313 /* list element for locks */
316 struct hshentry
* delta
;
317 struct lock
* nextlock
;
320 /* list element for symbolic names */
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
;
338 static char copyright
[]="Copyright (C) 1982 by Walter F. Tichy";
341 /* common variables (lexical analyzer)*/
342 extern enum tokens map
[];
343 #define ctab (&map[1])
344 extern enum tokens nexttok
;
346 extern char * NextString
;
349 #if defined(USG) || defined(V4_2BSD)
356 /* common routines */
357 extern char *talloc();
359 extern int faterror();
360 extern int fatserror();
361 extern void ignoreints();
362 extern void catchints();
363 extern void restoreints();
366 extern int sprintf();
370 * Markers for keyword expansion (used in co and ident)
372 #define AUTHOR "Author"
374 #define HEADER "Header"
376 #define LOCKER "Locker"
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 */
389 /* set by rcs -o and used by puttree() in rcssyn */