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