1 /* RCS common definitions and data structures */
3 #define RCSBASE "$FreeBSD$"
5 /* Copyright 1982, 1988, 1989 Walter Tichy
6 Copyright 1990, 1991, 1992, 1993, 1994, 1995 Paul Eggert
7 Distributed under license by the Free Software Foundation, Inc.
9 This file is part of RCS.
11 RCS is free software; you can redistribute it and/or modify
12 it under the terms of the GNU General Public License as published by
13 the Free Software Foundation; either version 2, or (at your option)
16 RCS is distributed in the hope that it will be useful,
17 but WITHOUT ANY WARRANTY; without even the implied warranty of
18 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 GNU General Public License for more details.
21 You should have received a copy of the GNU General Public License
22 along with RCS; see the file COPYING.
23 If not, write to the Free Software Foundation,
24 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
26 Report problems and direct all questions to:
28 rcs-bugs@cs.purdue.edu
33 * Revision 5.20 1995/06/16 06:19:24 eggert
36 * Revision 5.19 1995/06/01 16:23:43 eggert
37 * (SIZEABLE_PATH): Don't depend on PATH_MAX: it's not worth configuring.
38 * (Ioffset_type,BINARY_EXPAND,MIN_UNEXPAND,MIN_UNCHANGED_EXPAND): New macros.
39 * (maps_memory): New macro; replaces many instances of `has_mmap'.
40 * (cacheptr): Renamed from cachetell.
41 * (struct RILE): New alternate name for RILE; the type is now recursive.
42 * (deallocate): New member for RILE, used for generic buffer deallocation.
43 * (cacheunget_): No longer take a failure arg; just call Ierror on failure.
44 * (struct rcslock): Renamed from struct lock, to avoid collisions with
45 * system headers on some hosts. All users changed.
46 * (basefilename): Renamed from basename, likewise.
47 * (dirtpname): Remove; no longer external.
48 * (dirlen, dateform): Remove; no longer used.
49 * (cmpdate, fopenSafer, fdSafer, readAccessFilenameBuffer): New functions.
50 * (zonelenmax): Increase to 9 for full ISO 8601 format.
51 * (catchmmapints): Depend on has_NFS.
53 * Revision 5.18 1994/03/17 14:05:48 eggert
54 * Add primitives for reading backwards from a RILE;
55 * this is needed to go back and find the $Log prefix.
56 * Specify subprocess input via file descriptor, not file name. Remove lint.
58 * Revision 5.17 1993/11/09 17:40:15 eggert
59 * Move RCS-specific time handling into rcstime.c.
60 * printf_string now takes two arguments, alas.
62 * Revision 5.16 1993/11/03 17:42:27 eggert
63 * Don't arbitrarily limit the number of joins. Remove `nil'.
64 * Add Name keyword. Don't discard ignored phrases.
65 * Add support for merge -A vs -E, and allow up to three labels.
66 * Improve quality of diagnostics and prototypes.
68 * Revision 5.15 1992/07/28 16:12:44 eggert
69 * Statement macro names now end in _.
71 * Revision 5.14 1992/02/17 23:02:22 eggert
72 * Add -T support. Work around NFS mmap SIGBUS problem.
74 * Revision 5.13 1992/01/24 18:44:19 eggert
75 * Add support for bad_creat0. lint -> RCS_lint
77 * Revision 5.12 1992/01/06 02:42:34 eggert
78 * while (E) ; -> while (E) continue;
80 * Revision 5.11 1991/10/07 17:32:46 eggert
81 * Support piece tables even if !has_mmap.
83 * Revision 5.10 1991/09/24 00:28:39 eggert
84 * Remove unexported functions.
86 * Revision 5.9 1991/08/19 03:13:55 eggert
87 * Add piece tables and other tuneups, and NFS workarounds.
89 * Revision 5.8 1991/04/21 11:58:20 eggert
90 * Add -x, RCSINIT, MS-DOS support.
92 * Revision 5.7 1991/02/28 19:18:50 eggert
93 * Try setuid() if seteuid() doesn't work.
95 * Revision 5.6 1991/02/26 17:48:37 eggert
96 * Support new link behavior. Move ANSI C / Posix declarations into conf.sh.
98 * Revision 5.5 1990/12/04 05:18:43 eggert
99 * Use -I for prompts and -q for diagnostics.
101 * Revision 5.4 1990/11/01 05:03:35 eggert
102 * Don't assume that builtins are functions; they may be macros.
103 * Permit arbitrary data in logs.
105 * Revision 5.3 1990/09/26 23:36:58 eggert
106 * Port wait() to non-Posix ANSI C hosts.
108 * Revision 5.2 1990/09/04 08:02:20 eggert
109 * Don't redefine NAME_MAX, PATH_MAX.
110 * Improve incomplete line handling. Standardize yes-or-no procedure.
112 * Revision 5.1 1990/08/29 07:13:53 eggert
113 * Add -kkvl. Fix type typos exposed by porting. Clean old log messages too.
115 * Revision 5.0 1990/08/22 08:12:44 eggert
116 * Adjust ANSI C / Posix support. Add -k, -V, setuid. Don't call access().
117 * Remove compile-time limits; use malloc instead.
118 * Ansify and Posixate. Add support for ISO 8859.
119 * Remove snoop and v2 support.
121 * Revision 4.9 89/05/01 15:17:14 narten
122 * botched previous USG fix
124 * Revision 4.8 89/05/01 14:53:05 narten
125 * changed #include <strings.h> -> string.h for USG systems.
127 * Revision 4.7 88/11/08 15:58:45 narten
128 * removed defs for functions loaded from libraries
130 * Revision 4.6 88/08/09 19:12:36 eggert
131 * Shrink stdio code size; remove lint; permit -Dhshsize=nn.
133 * Revision 4.5 87/12/18 17:06:41 narten
134 * made removed BSD ifdef, now uses V4_2BSD
136 * Revision 4.4 87/10/18 10:29:49 narten
137 * Updating version numbers
138 * Changes relative to 1.1 are actually relative to 4.2
140 * Revision 1.3 87/09/24 14:02:25 narten
143 * Revision 1.2 87/03/27 14:22:02 jenkins
146 * Revision 4.2 83/12/20 16:04:20 wft
147 * merged 3.6.1.1 and 4.1 (SMALLOG, logsize).
148 * moved setting of STRICT_LOCKING to Makefile.
149 * changed DOLLAR to UNKN (conflict with KDELIM).
151 * Revision 4.1 83/05/04 09:12:41 wft
152 * Added markers Id and RCSfile.
153 * Added Dbranch for default branches.
155 * Revision 3.6.1.1 83/12/02 21:56:22 wft
156 * Increased logsize, added macro SMALLOG.
158 * Revision 3.6 83/01/15 16:43:28 wft
161 * Revision 3.6 83/01/15 16:43:28 wft
162 * Replaced dbm.h with BYTESIZ, fixed definition of rindex().
163 * Added variants of NCPFN and NCPPN for bsd 4.2, selected by defining V4_2BSD.
164 * Added macro DELNUMFORM to have uniform format for printing delta text nodes.
165 * Added macro DELETE to mark deleted deltas.
167 * Revision 3.5 82/12/10 12:16:56 wft
168 * Added two forms of DATEFORM, one using %02d, the other %.2d.
170 * Revision 3.4 82/12/04 20:01:25 wft
171 * added LOCKER, Locker, and USG (redefinition of rindex).
173 * Revision 3.3 82/12/03 12:22:04 wft
174 * Added dbm.h, stdio.h, RCSBASE, RCSSEP, RCSSUF, WORKMODE, TMPFILE3,
175 * PRINTDATE, PRINTTIME, map, and ctab; removed Suffix. Redefined keyvallength
176 * using NCPPN. Changed putc() to abort on write error.
178 * Revision 3.2 82/10/18 15:03:52 wft
179 * added macro STRICT_LOCKING, removed RCSUMASK.
180 * renamed JOINFILE[1,2] to JOINFIL[1,2].
182 * Revision 3.1 82/10/11 19:41:17 wft
183 * removed NBPW, NBPC, NCPW.
184 * added typdef int void to aid compiling
191 #define EXIT_TROUBLE DIFF_TROUBLE
193 #ifdef _POSIX_PATH_MAX
194 # define SIZEABLE_PATH _POSIX_PATH_MAX
196 # define SIZEABLE_PATH 255 /* size of a large path; not a hard limit */
199 /* for traditional C hosts with unusual size arguments */
200 #define Fread(p,s,n,f) fread(p, (freadarg_type)(s), (freadarg_type)(n), f)
201 #define Fwrite(p,s,n,f) fwrite(p, (freadarg_type)(s), (freadarg_type)(n), f)
208 /* backwards compatibility with old versions of RCS */
209 #define VERSION_min 3 /* old output RCS format supported */
210 #define VERSION_max 5 /* newest output RCS format supported */
211 #ifndef VERSION_DEFAULT /* default RCS output format */
212 # define VERSION_DEFAULT VERSION_max
214 #define VERSION(n) ((n) - VERSION_DEFAULT) /* internally, 0 is the default */
216 #ifndef STRICT_LOCKING
217 #define STRICT_LOCKING 1
219 /* 0 sets the default locking to non-strict; */
220 /* used in experimental environments. */
221 /* 1 sets the default locking to strict; */
222 /* used in production environments. */
224 #define yearlength 16 /* (good through AD 9,999,999,999,999,999) */
225 #define datesize (yearlength+16) /* size of output of time2date */
226 #define RCSTMPPREFIX '_' /* prefix for temp files in working dir */
227 #define KDELIM '$' /* delimiter for keywords */
228 #define VDELIM ':' /* separates keywords from values */
229 #define DEFAULTSTATE "Exp" /* default state of revisions */
238 * RILE - readonly file
239 * declarecache; - declares local cache for RILE variable(s)
240 * setupcache - sets up the local RILE cache, but does not initialize it
241 * cache, uncache - caches and uncaches the local RILE;
242 * (uncache,cache) is needed around functions that advance the RILE pointer
243 * Igeteof_(f,c,s) - get a char c from f, executing statement s at EOF
244 * cachegeteof_(c,s) - Igeteof_ applied to the local RILE
245 * Iget_(f,c) - like Igeteof_, except EOF is an error
246 * cacheget_(c) - Iget_ applied to the local RILE
247 * cacheunget_(f,c,s) - read c backwards from cached f, executing s at BOF
248 * Ifileno, Ioffset_type, Irewind, Itell - analogs to stdio routines
250 * By conventions, macros whose names end in _ are statements, not expressions.
251 * Following such macros with `; else' results in a syntax error.
254 #define maps_memory (has_map_fd || has_mmap)
257 typedef unsigned char const *Iptr_type;
258 typedef struct RILE {
260 unsigned char *base; /* not Iptr_type for lint's sake */
261 unsigned char *readlim;
264 void (*deallocate) P((struct RILE *));
270 # define declarecache register Iptr_type ptr, lim
271 # define setupcache(f) (lim = (f)->lim)
272 # define Igeteof_(f,c,s) if ((f)->ptr==(f)->lim) s else (c)= *(f)->ptr++;
273 # define cachegeteof_(c,s) if (ptr==lim) s else (c)= *ptr++;
275 int Igetmore P((RILE*));
276 # define declarecache register Iptr_type ptr; register RILE *rRILE
277 # define setupcache(f) (rRILE = (f))
278 # define Igeteof_(f,c,s) if ((f)->ptr==(f)->readlim && !Igetmore(f)) s else (c)= *(f)->ptr++;
279 # define cachegeteof_(c,s) if (ptr==rRILE->readlim && !Igetmore(rRILE)) s else (c)= *ptr++;
281 # define uncache(f) ((f)->ptr = ptr)
282 # define cache(f) (ptr = (f)->ptr)
283 # define Iget_(f,c) Igeteof_(f,c,Ieof();)
284 # define cacheget_(c) cachegeteof_(c,Ieof();)
285 # define cacheunget_(f,c) (c)=(--ptr)[-1];
286 # define Ioffset_type size_t
287 # define Itell(f) ((f)->ptr - (f)->base)
288 # define Irewind(f) ((f)->ptr = (f)->base)
289 # define cacheptr() ptr
290 # define Ifileno(f) ((f)->fd)
293 # define declarecache register FILE *ptr
294 # define setupcache(f) (ptr = (f))
297 # define Igeteof_(f,c,s) {if(((c)=getc(f))==EOF){testIerror(f);if(feof(f))s}}
298 # define cachegeteof_(c,s) Igeteof_(ptr,c,s)
299 # define Iget_(f,c) { if (((c)=getc(f))==EOF) testIeof(f); }
300 # define cacheget_(c) Iget_(ptr,c)
301 # define cacheunget_(f,c) if(fseek(ptr,-2L,SEEK_CUR))Ierror();else cacheget_(c)
302 # define Ioffset_type long
303 # define Itell(f) ftell(f)
304 # define Ifileno(f) fileno(f)
307 /* Print a char, but abort on write error. */
308 #define aputc_(c,o) { if (putc(c,o)==EOF) testOerror(o); }
310 /* Get a character from an RCS file, perhaps copying to a new RCS file. */
311 #define GETCeof_(o,c,s) { cachegeteof_(c,s) if (o) aputc_(c,o) }
312 #define GETC_(o,c) { cacheget_(c) if (o) aputc_(c,o) }
315 #define WORKMODE(RCSmode, writable) (((RCSmode)&(mode_t)~(S_IWUSR|S_IWGRP|S_IWOTH)) | ((writable)?S_IWUSR:0))
316 /* computes mode of working file: same as RCSmode, but write permission */
317 /* determined by writable */
320 /* character classes and token codes */
322 /* classes */ DELIM, DIGIT, IDCHAR, NEWLN, LETTER, Letter,
323 PERIOD, SBEGIN, SPACE, UNKN,
324 /* tokens */ COLON, ID, NUM, SEMI, STRING
327 #define SDELIM '@' /* the actual character is needed for string handling*/
328 /* SDELIM must be consistent with ctab[], so that ctab[SDELIM]==SBEGIN.
329 * there should be no overlap among SDELIM, KDELIM, and VDELIM
332 #define isdigit(c) (((unsigned)(c)-'0') <= 9) /* faster than ctab[c]==DIGIT */
338 /***************************************
339 * Data structures for the symbol table
340 ***************************************/
342 /* Buffer of arbitrary data */
352 /* Hash table entry */
354 char const * num; /* pointer to revision number (ASCIZ) */
355 char const * date; /* pointer to date of checkin */
356 char const * author; /* login of person checking in */
357 char const * lockedby; /* who locks the revision */
358 char const * state; /* state of revision (Exp by default) */
359 char const * name; /* name (if any) by which retrieved */
360 struct cbuf log; /* log message requested at checkin */
361 struct branchhead * branches; /* list of first revisions on branches*/
362 struct cbuf ig; /* ignored phrases in admin part */
363 struct cbuf igtext; /* ignored phrases in deltatext part */
364 struct hshentry * next; /* next revision on same branch */
365 struct hshentry * nexthsh; /* next revision with same hash value */
366 long insertlns;/* lines inserted (computed by rlog) */
367 long deletelns;/* lines deleted (computed by rlog) */
368 char selector; /* true if selected, false if deleted */
371 /* list of hash entries */
373 struct hshentries *rest;
374 struct hshentry *first;
377 /* list element for branch lists */
379 struct hshentry * hsh;
380 struct branchhead * nextbranch;
383 /* accesslist element */
386 struct access * nextaccess;
389 /* list element for locks */
392 struct hshentry * delta;
393 struct rcslock * nextlock;
396 /* list element for symbolic names */
400 struct assoc * nextassoc;
404 #define mainArgs (argc,argv) int argc; char **argv;
407 # define libId(name,rcsid)
408 # define mainProg(name,cmd,rcsid) int name mainArgs
410 # define libId(name,rcsid) char const name[] = rcsid;
411 # define mainProg(n,c,i) char const Copyright[] = "Copyright 1982,1988,1989 Walter F. Tichy, Purdue CS\nCopyright 1990,1991,1992,1993,1994,1995 Paul Eggert", baseid[] = RCSBASE, cmdid[] = c; libId(n,i) int main P((int,char**)); int main mainArgs
415 * Markers for keyword expansion (used in co and ident)
416 * Every byte must have class LETTER or Letter.
418 #define AUTHOR "Author"
420 #define HEADER "Header"
422 #define LOCKER "Locker"
425 #define RCSFILE "RCSfile"
426 #define REVISION "Revision"
427 #define SOURCE "Source"
428 #define STATE "State"
429 #define CVSHEADER "CVSHeader"
430 #define keylength 9 /* max length of any of the above keywords */
432 enum markers { Nomatch, Author, Date, Header, Id,
433 Locker, Log, Name, RCSfile, Revision, Source, State, CVSHeader,
435 /* This must be in the same order as rcskeys.c's Keyword[] array. */
437 #define DELNUMFORM "\n\n%s\n%s\n"
438 /* used by putdtext and scanlogtext */
440 #define EMPTYLOG "*** empty log message ***" /* used by ci and rlog */
443 extern char const cmdid[];
444 void exiterr P((void)) exiting;
447 int merge P((int,char const*,char const*const[3],char const*const[3]));
450 #define ciklogsize 23 /* sizeof("checked in with -k by ") */
452 extern char const *resultname;
453 extern char const ciklog[ciklogsize];
454 extern int locker_expansion;
455 RILE *rcswriteopen P((struct buf*,struct stat*,int));
456 char const *makedirtemp P((int));
457 char const *getcaller P((void));
458 int addlock P((struct hshentry*,int));
459 int addsymbol P((char const*,char const*,int));
460 int checkaccesslist P((void));
461 int chnamemod P((FILE**,char const*,char const*,int,mode_t,time_t));
462 int donerewrite P((int,time_t));
463 int dorewrite P((int,int));
464 int expandline P((RILE*,FILE*,struct hshentry const*,int,FILE*,int));
465 int findlock P((int,struct hshentry**));
466 int setmtime P((char const*,time_t));
467 void ORCSclose P((void));
468 void ORCSerror P((void));
469 void copystring P((void));
470 void dirtempunlink P((void));
471 void enterstring P((void));
472 void finishedit P((struct hshentry const*,FILE*,int));
473 void keepdirtemp P((char const*));
474 void openfcopy P((FILE*));
475 void snapshotedit P((FILE*));
476 void xpandstring P((struct hshentry const*));
477 #if has_NFS || bad_unlink
478 int un_link P((char const*));
480 # define un_link(s) unlink(s)
483 void edit_string P((void));
484 # define editstring(delta) edit_string()
486 void editstring P((struct hshentry const*));
490 int rcsfcmp P((RILE*,struct stat const*,char const*,struct hshentry const*));
493 #define bufautobegin(b) clear_buf(b)
494 #define clear_buf(b) (VOID ((b)->string = 0, (b)->size = 0))
495 extern FILE *workstdout;
496 extern char *workname;
497 extern char const *RCSname;
498 extern char const *suffixes;
500 extern struct stat RCSstat;
501 RILE *rcsreadopen P((struct buf*,struct stat*,int));
502 char *bufenlarge P((struct buf*,char const**));
503 char const *basefilename P((char const*));
504 char const *getfullRCSname P((void));
505 char const *getfullCVSname P((void));
506 char const *maketemp P((int));
507 char const *rcssuffix P((char const*));
508 int pairnames P((int,char**,RILE*(*)P((struct buf*,struct stat*,int)),int,int));
509 struct cbuf bufremember P((struct buf*,size_t));
510 void bufalloc P((struct buf*,size_t));
511 void bufautoend P((struct buf*));
512 void bufrealloc P((struct buf*,size_t));
513 void bufscat P((struct buf*,char const*));
514 void bufscpy P((struct buf*,char const*));
515 void tempunlink P((void));
518 extern int interactiveflag;
519 extern struct buf curlogbuf;
520 char const *buildrevision P((struct hshentries const*,struct hshentry*,FILE*,int));
521 int getcstdin P((void));
522 int putdtext P((struct hshentry const*,char const*,FILE*,int));
523 int ttystdin P((void));
524 int yesorno P((int,char const*,...)) printf_string(2,3);
525 struct cbuf cleanlogmsg P((char*,size_t));
526 struct cbuf getsstdin P((char const*,char const*,char const*,struct buf*));
527 void putdesc P((int,char*));
528 void putdftext P((struct hshentry const*,RILE*,FILE*,int));
532 extern struct buf prevauthor, prevdate, prevname, prevrev, prevstate;
533 int getoldkeys P((RILE*));
536 extern char const *Keyword[];
537 extern enum markers LocalIdMode;
538 enum markers trymatch P((char const*));
539 void setRCSLocalId(char const *);
540 void setIncExc(char const *);
543 extern FILE *foutptr;
544 extern FILE *frewrite;
546 extern char const *NextString;
547 extern enum tokens nexttok;
551 extern int quietflag;
553 char const *getid P((void));
554 void efaterror P((char const*)) exiting;
555 void enfaterror P((int,char const*)) exiting;
556 void fatcleanup P((int)) exiting;
557 void faterror P((char const*,...)) printf_string_exiting(1,2);
558 void fatserror P((char const*,...)) printf_string_exiting(1,2);
559 void rcsfaterror P((char const*,...)) printf_string_exiting(1,2);
560 void Ieof P((void)) exiting;
561 void Ierror P((void)) exiting;
562 void Oerror P((void)) exiting;
563 char *checkid P((char*,int));
564 char *checksym P((char*,int));
565 int eoflex P((void));
566 int getkeyopt P((char const*));
567 int getlex P((enum tokens));
568 struct cbuf getphrases P((char const*));
569 struct cbuf savestring P((struct buf*));
570 struct hshentry *getnum P((void));
571 void Ifclose P((RILE*));
572 void Izclose P((RILE**));
573 void Lexinit P((void));
574 void Ofclose P((FILE*));
575 void Orewind P((FILE*));
576 void Ozclose P((FILE**));
577 void aflush P((FILE*));
578 void afputc P((int,FILE*));
579 void aprintf P((FILE*,char const*,...)) printf_string(2,3);
580 void aputs P((char const*,FILE*));
581 void checksid P((char*));
582 void checkssym P((char*));
583 void diagnose P((char const*,...)) printf_string(1,2);
584 void eerror P((char const*));
585 void eflush P((void));
586 void enerror P((int,char const*));
587 void error P((char const*,...)) printf_string(1,2);
588 void fvfprintf P((FILE*,char const*,va_list));
589 void getkey P((char const*));
590 void getkeystring P((char const*));
591 void nextlex P((void));
592 void oflush P((void));
593 void printstring P((void));
594 void readstring P((void));
595 void redefined P((int));
596 void rcserror P((char const*,...)) printf_string(1,2);
597 void rcswarn P((char const*,...)) printf_string(1,2);
598 void testIerror P((FILE*));
599 void testOerror P((FILE*));
600 void warn P((char const*,...)) printf_string(1,2);
601 void warnignore P((void));
602 void workerror P((char const*,...)) printf_string(1,2);
603 void workwarn P((char const*,...)) printf_string(1,2);
604 #if has_madvise && has_mmap && large_memory
605 void advise_access P((RILE*,int));
606 # define if_advise_access(p,f,advice) if (p) advise_access(f,advice)
608 # define advise_access(f,advice)
609 # define if_advise_access(p,f,advice)
611 #if large_memory && maps_memory
612 RILE *I_open P((char const*,struct stat*));
613 # define Iopen(f,m,s) I_open(f,s)
615 RILE *Iopen P((char const*,char const*,struct stat*));
618 void testIeof P((FILE*));
619 void Irewind P((RILE*));
623 extern enum tokens const ctab[];
626 char *partialno P((struct buf*,char const*,int));
627 char const *namedrev P((char const*,struct hshentry*));
628 char const *tiprev P((void));
629 int cmpdate P((char const*,char const*));
630 int cmpnum P((char const*,char const*));
631 int cmpnumfld P((char const*,char const*,int));
632 int compartial P((char const*,char const*,int));
633 int expandsym P((char const*,struct buf*));
634 int fexpandsym P((char const*,struct buf*,RILE*));
635 struct hshentry *genrevs P((char const*,char const*,char const*,char const*,struct hshentries**));
636 int countnumflds P((char const*));
637 void getbranchno P((char const*,struct buf*));
640 /* These expand modes must agree with Expand_names[] in rcssyn.c. */
641 #define KEYVAL_EXPAND 0 /* -kkv `$Keyword: value $' */
642 #define KEYVALLOCK_EXPAND 1 /* -kkvl `$Keyword: value locker $' */
643 #define KEY_EXPAND 2 /* -kk `$Keyword$' */
644 #define VAL_EXPAND 3 /* -kv `value' */
645 #define OLD_EXPAND 4 /* -ko use old string, omitting expansion */
646 #define BINARY_EXPAND 5 /* -kb like -ko, but use binary mode I/O */
647 #define MIN_UNEXPAND OLD_EXPAND /* min value for no logical expansion */
648 #define MIN_UNCHANGED_EXPAND (OPEN_O_BINARY ? BINARY_EXPAND : OLD_EXPAND)
649 /* min value guaranteed to yield an identical file */
652 line1, /* number of first line */
653 nlines, /* number of lines affected */
654 adprev, /* previous 'a' line1+1 or 'd' line1 */
655 dafter; /* sum of previous 'd' line1 and previous 'd' nlines */
657 extern char const * Dbranch;
658 extern struct access * AccessList;
659 extern struct assoc * Symbols;
660 extern struct cbuf Comment;
661 extern struct cbuf Ignored;
662 extern struct rcslock *Locks;
663 extern struct hshentry * Head;
665 extern int StrictLocks;
666 extern int TotalDeltas;
667 extern char const *const expand_names[];
669 Kaccess[], Kauthor[], Kbranch[], Kcomment[],
670 Kdate[], Kdesc[], Kexpand[], Khead[], Klocks[], Klog[],
671 Knext[], Kstate[], Kstrict[], Ksymbols[], Ktext[];
672 void unexpected_EOF P((void)) exiting;
673 int getdiffcmd P((RILE*,int,FILE*,struct diffcmd*));
674 int str2expmode P((char const*));
675 void getadmin P((void));
676 void getdesc P((int));
677 void gettree P((void));
678 void ignorephrases P((char const*));
679 void initdiffcmd P((struct diffcmd*));
680 void putadmin P((void));
681 void putstring P((FILE*,int,struct cbuf,int));
682 void puttree P((struct hshentry const*,FILE*));
685 #define zonelenmax 9 /* maxiumum length of time zone string, e.g. "+12:34:56" */
686 char const *date2str P((char const[datesize],char[datesize + zonelenmax]));
687 time_t date2time P((char const[datesize]));
688 void str2date P((char const*,char[datesize]));
689 void time2date P((time_t,char[datesize]));
690 void zone_set P((char const*));
693 extern int RCSversion;
694 FILE *fopenSafer P((char const*,char const*));
695 char *cgetenv P((char const*));
696 char *fstr_save P((char const*));
697 char *str_save P((char const*));
698 char const *getusername P((int));
699 int fdSafer P((int));
700 int getRCSINIT P((int,char**,char***));
701 int run P((int,char const*,...));
702 int runv P((int,char const*,char const**));
703 malloc_type fremember P((malloc_type));
704 malloc_type ftestalloc P((size_t));
705 malloc_type testalloc P((size_t));
706 malloc_type testrealloc P((malloc_type,size_t));
707 #define ftalloc(T) ftnalloc(T,1)
708 #define talloc(T) tnalloc(T,1)
710 extern malloc_type lintalloc;
711 # define ftnalloc(T,n) (lintalloc = ftestalloc(sizeof(T)*(n)), (T*)0)
712 # define tnalloc(T,n) (lintalloc = testalloc(sizeof(T)*(n)), (T*)0)
713 # define trealloc(T,p,n) (lintalloc = testrealloc((malloc_type)0, sizeof(T)*(n)), p)
716 # define ftnalloc(T,n) ((T*) ftestalloc(sizeof(T)*(n)))
717 # define tnalloc(T,n) ((T*) testalloc(sizeof(T)*(n)))
718 # define trealloc(T,p,n) ((T*) testrealloc((malloc_type)(p), sizeof(T)*(n)))
719 # define tfree(p) free((malloc_type)(p))
721 time_t now P((void));
722 void awrite P((char const*,size_t,FILE*));
723 void fastcopy P((RILE*,FILE*));
724 void ffree P((void));
725 void ffree1 P((char const*));
726 void setRCSversion P((char const*));
728 void catchints P((void));
729 void ignoreints P((void));
730 void restoreints P((void));
733 # define ignoreints()
734 # define restoreints()
736 #if has_mmap && large_memory
737 # if has_NFS && mmap_signal
738 void catchmmapints P((void));
739 void readAccessFilenameBuffer P((char const*,unsigned char const*));
741 # define catchmmapints()
745 uid_t ruid P((void));
746 # define myself(u) ((u) == ruid())
748 # define myself(u) true
751 uid_t euid P((void));
752 void nosetid P((void));
753 void seteid P((void));
754 void setrid P((void));
762 extern char const RCS_version_string[];