home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Professional / OS2PRO194.ISO / os2 / prgramer / rcs / sources / rcsbase.h < prev    next >
C/C++ Source or Header  |  1992-02-17  |  24KB  |  700 lines

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