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