home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 22 gnu / 22-gnu.zip / rcs567s.zip / rcs / src / rcsbase.h < prev    next >
C/C++ Source or Header  |  1994-03-17  |  24KB  |  728 lines

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