home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 22 gnu / 22-gnu.zip / rcs57pc3.zip / rcs / src / rcsbase.h < prev    next >
C/C++ Source or Header  |  1996-04-15  |  27KB  |  762 lines

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