|
|
1.1 root 1:
2: /*
3: * RCS common definitions and data structures
4: */
5: #define RCSBASE "$Id: rcsbase.h,v 4.9 89/05/01 15:17:14 narten Exp $"
6:
7: /* Copyright (C) 1982, 1988, 1989 Walter Tichy
8: * All rights reserved.
9: *
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.
19: *
20: * Report all problems and direct all questions to:
21: * [email protected]
22: *
23:
24:
25:
26:
27:
28:
29:
30: */
31:
32:
33:
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: *****************************************************************************
51: */
52:
53:
54: /* $Log: rcsbase.h,v $
55: * Revision 4.9 89/05/01 15:17:14 narten
56: * botched previous USG fix
57: *
58: * Revision 4.8 89/05/01 14:53:05 narten
59: * changed #include <strings.h> -> string.h for USG systems.
60: *
61: * Revision 4.7 88/11/08 15:58:45 narten
62: * removed defs for functions loaded from libraries
63: *
64: * Revision 4.6 88/11/08 12:04:06 narten
65: * changes from [email protected] (Paul Eggert)
66: *
67: * Revision 4.6 88/08/09 19:12:36 eggert
68: * Shrink stdio code size; remove lint; permit -Dhshsize=nn.
69: *
70: * Revision 4.5 87/12/18 17:06:41 narten
71: * made removed BSD ifdef, now uses V4_2BSD
72: *
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
76: *
77: * Revision 1.3 87/09/24 14:02:25 narten
78: * changes for lint
79: *
80: * Revision 1.2 87/03/27 14:22:02 jenkins
81: * Port to suns
82: *
83: * Revision 1.1 84/01/23 14:50:14 kcs
84: * Initial revision
85: *
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).
90: *
91: * Revision 4.1 83/05/04 09:12:41 wft
92: * Added markers Id and RCSfile.
93: * Added Dbranch for default branches.
94: *
95: * Revision 3.6.1.1 83/12/02 21:56:22 wft
96: * Increased logsize, added macro SMALLOG.
97: *
98: * Revision 3.6 83/01/15 16:43:28 wft
99: * 4.2 prerelease
100: *
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.
106: *
107: * Revision 3.5 82/12/10 12:16:56 wft
108: * Added two forms of DATEFORM, one using %02d, the other %.2d.
109: *
110: * Revision 3.4 82/12/04 20:01:25 wft
111: * added LOCKER, Locker, and USG (redefinition of rindex).
112: *
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.
117: *
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].
121: *
122: * Revision 3.1 82/10/11 19:41:17 wft
123: * removed NBPW, NBPC, NCPW.
124: * added typdef int void to aid compiling
125: */
126:
127:
128:
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 */
136:
137:
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.
147: */
148:
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 */
152:
153: /*
154: * Parameters
155: */
156: #define BYTESIZ 8 /* number of bits in a byte */
157:
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
167:
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 */
193:
194:
195:
196: #define true 1
197: #define false 0
198: #define nil 0
199: #define elsif else if
200: #define elif else if
201:
202:
203: /* temporary file names */
204:
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"
212:
213:
214: #define putc(x,p) (--(p)->_cnt>=0? ((int)(*(p)->_ptr++=(unsigned)(x))):fflsbuf((unsigned)(x),p))
215: /* This version of putc prints a char, but aborts on write error */
216:
217: #define GETC(in,out,echo) (c=getc(in), echo?putc(c,out):c)
218: /* GETC modifies a local variable c; a kludge, but smaller and faster. */
219: /* GETC writes a del-character (octal 177) on end of file */
220:
221: #define WORKMODE(RCSmode) (RCSmode&~0222)|((lockflag||!StrictLocks)?0600:0000)
222: /* computes mode of working file: same as RCSmode, but write permission */
223: /* determined by lockflag and StrictLocks. */
224:
225:
226: /* character classes and token codes */
227: enum tokens {
228: /* char classes*/ DIGIT, IDCHAR, NEWLN, LETTER, PERIOD, SBEGIN, SPACE, UNKN,
229: /* tokens */ COLON, DATE, EOFILE, ID, KEYW, NUM, SEMI, STRING,
230: };
231:
232: #define AT SBEGIN /* class SBEGIN (string begin) is returned by lex. anal. */
233: #define SDELIM '@' /* the actual character is needed for string handling*/
234: /* these must be changed consistently, for instance to:
235: * #define DQUOTE SBEGIN
236: * #define SDELIM '"'
237: * #define AT IDCHAR
238: * there should be no overlap among SDELIM, KDELIM, and VDELIM
239: */
240:
241: /* other characters */
242:
243: #define ACCENT IDCHAR
244: #define AMPER IDCHAR
245: #define BACKSL IDCHAR
246: #define BAR IDCHAR
247: #define COMMA UNKN
248: #define DIVIDE IDCHAR
249: #define DOLLAR UNKN /* overlap with KDELIM */
250: #define DQUOTE IDCHAR
251: #define EQUAL IDCHAR
252: #define EXCLA IDCHAR
253: #define GREAT IDCHAR
254: #define HASH IDCHAR
255: #define INSERT UNKN
256: #define LBRACE IDCHAR
257: #define LBRACK IDCHAR
258: #define LESS IDCHAR
259: #define LPARN IDCHAR
260: #define MINUS IDCHAR
261: #define PERCNT IDCHAR
262: #define PLUS IDCHAR
263: #define QUEST IDCHAR
264: #define RBRACE IDCHAR
265: #define RBRACK IDCHAR
266: #define RPARN IDCHAR
267: #define SQUOTE IDCHAR
268: #define TILDE IDCHAR
269: #define TIMES IDCHAR
270: #define UNDER IDCHAR
271: #define UPARR IDCHAR
272:
273:
274:
275:
276: /***************************************
277: * Data structures for the symbol table
278: ***************************************/
279:
280:
281: /* Hash table entry */
282: struct hshentry {
283: char * num; /* pointer to revision number (ASCIZ) */
284: char * date; /* pointer to date of checking */
285: char * author; /* login of person checking in */
286: char * lockedby; /* who locks the revision */
287: char * log; /* log message requested at checkin */
288: char * state; /* state of revision (Exp by default) */
289: struct branchhead * branches; /* list of first revisions on branches*/
290: struct hshentry * next; /* next revision on same branch */
291: int insertlns;/* lines inserted (computed by rlog) */
292: int deletelns;/* lines deleted (computed by rlog) */
293: char selector; /* marks entry for selection/deletion */
294: };
295:
296: /* list element for branch lists */
297: struct branchhead {
298: struct hshentry * hsh;
299: struct branchhead * nextbranch;
300: };
301:
302: /* accesslist element */
303: struct access {
304: char * login;
305: struct access * nextaccess;
306: };
307:
308: /* list element for locks */
309: struct lock {
310: char * login;
311: struct hshentry * delta;
312: struct lock * nextlock;
313: };
314:
315: /* list element for symbolic names */
316: struct assoc {
317: char * symbol;
318: struct hshentry * delta;
319: struct assoc * nextassoc;
320: };
321:
322:
323: /* common variables (getadmin and getdelta())*/
324: extern char * Comment;
325: extern struct access * AccessList;
326: extern struct assoc * Symbols;
327: extern struct lock * Locks;
328: extern struct hshentry * Head;
329: extern struct hshentry * Dbranch;
330: extern int StrictLocks;
331: extern int TotalDeltas;
332: #ifndef lint
333: static char copyright[]="Copyright (C) 1982 by Walter F. Tichy";
334: #endif
335:
336: /* common variables (lexical analyzer)*/
337: extern enum tokens map[];
338: #define ctab (&map[1])
339: extern enum tokens nexttok;
340: extern int hshenter;
341: extern char * NextString;
342: extern char * cmdid;
343:
344: #if defined(USG) || defined(V4_2BSD)
345: #define VOID (void)
346: #else
347: typedef int void;
348: #define VOID
349: #endif
350:
351: /* common routines */
352: extern char *talloc();
353: extern int serror();
354: extern int faterror();
355: extern int fatserror();
356: extern void ignoreints();
357: extern void catchints();
358: extern void restoreints();
359:
360: #ifdef USG
361: extern int sprintf();
362: #endif
363:
364: /*
365: * Markers for keyword expansion (used in co and ident)
366: */
367: #define AUTHOR "Author"
368: #define DATE "Date"
369: #define HEADER "Header"
370: #define IDH "Id"
371: #define LOCKER "Locker"
372: #define LOG "Log"
373: #define RCSFILE "RCSfile"
374: #define REVISION "Revision"
375: #define SOURCE "Source"
376: #define STATE "State"
377:
378: enum markers { Nomatch, Author, Date, Header, Id,
379: Locker, Log, RCSfile, Revision, Source, State };
380:
381: #define DELNUMFORM "\n\n%s\n%s\n"
382: /* used by putdtext and scanlogtext */
383: #define DELETE 'D'
384: /* set by rcs -o and used by puttree() in rcssyn */
385:
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.