home *** CD-ROM | disk | FTP | other *** search
/ The Atari Compendium / The Atari Compendium (Toad Computers) (1994).iso / files / prgtools / programm.ing / rcs5ap1s.lzh / RCSBASE.H < prev    next >
Encoding:
C/C++ Source or Header  |  1991-01-30  |  24.8 KB  |  898 lines

  1.  
  2. /*
  3.  *                     RCS common definitions and data structures
  4.  */
  5. #define RCSBASE "$Id: rcsbase.h,v 5.7 1991/01/30 14:21:32 apratt Exp $"
  6.  
  7. /* Copyright (C) 1982, 1988, 1989 Walter Tichy
  8.    Copyright 1990 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 1, 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.7  1991/01/30  14:21:32  apratt
  47.  * CI with RCS version 5
  48.  *
  49.  * Revision 5.6  91/01/11  12:46:18  apratt
  50.  * First version that compiles.
  51.  * 
  52.  * Revision 5.5  90/12/04  05:18:43  eggert
  53.  * checked in with -k by apratt at 91.01.10.13.15.06.
  54.  * 
  55.  * Revision 5.5  1990/12/04  05:18:43  eggert
  56.  * Use -I for prompts and -q for diagnostics.
  57.  *
  58.  * Revision 5.4  1990/11/01  05:03:35  eggert
  59.  * Don't assume that builtins are functions; they may be macros.
  60.  * Permit arbitrary data in logs.
  61.  *
  62.  * Revision 5.3  1990/09/26  23:36:58  eggert
  63.  * Port wait() to non-Posix ANSI C hosts.
  64.  *
  65.  * Revision 5.2  1990/09/04  08:02:20  eggert
  66.  * Don't redefine NAME_MAX, PATH_MAX.
  67.  * Improve incomplete line handling.  Standardize yes-or-no procedure.
  68.  *
  69.  * Revision 5.1  1990/08/29  07:13:53  eggert
  70.  * Add -kkvl.  Fix type typos exposed by porting.  Clean old log messages too.
  71.  *
  72.  * Revision 5.0  1990/08/22  08:12:44  eggert
  73.  * Adjust ANSI C / Posix support.  Add -k, -V, setuid.  Don't call access().
  74.  * Remove compile-time limits; use malloc instead.
  75.  * Ansify and Posixate.  Add support for ISO 8859.
  76.  * Remove snoop and v2 support.
  77.  *
  78.  * Revision 4.9  89/05/01  15:17:14  narten
  79.  * botched previous USG fix 
  80.  * 
  81.  * Revision 4.8  89/05/01  14:53:05  narten
  82.  * changed #include <strings.h> -> string.h for USG systems.
  83.  * 
  84.  * Revision 4.7  88/11/08  15:58:45  narten
  85.  * removed defs for functions loaded from libraries
  86.  * 
  87.  * Revision 4.6  88/08/09  19:12:36  eggert
  88.  * Shrink stdio code size; remove lint; permit -Dhshsize=nn.
  89.  * 
  90.  * Revision 4.5  87/12/18  17:06:41  narten
  91.  * made removed BSD ifdef, now uses V4_2BSD
  92.  * 
  93.  * Revision 4.4  87/10/18  10:29:49  narten
  94.  * Updating version numbers
  95.  * Changes relative to 1.1 are actually relative to 4.2
  96.  * 
  97.  * Revision 1.3  87/09/24  14:02:25  narten
  98.  * changes for lint
  99.  * 
  100.  * Revision 1.2  87/03/27  14:22:02  jenkins
  101.  * Port to suns
  102.  * 
  103.  * Revision 4.2  83/12/20  16:04:20  wft
  104.  * merged 3.6.1.1 and 4.1 (SMALLOG, logsize).
  105.  * moved setting of STRICT_LOCKING to Makefile.
  106.  * changed DOLLAR to UNKN (conflict with KDELIM).
  107.  * 
  108.  * Revision 4.1  83/05/04  09:12:41  wft
  109.  * Added markers Id and RCSfile.
  110.  * Added Dbranch for default branches.
  111.  * 
  112.  * Revision 3.6.1.1  83/12/02  21:56:22  wft
  113.  * Increased logsize, added macro SMALLOG.
  114.  * 
  115.  * Revision 3.6  83/01/15  16:43:28  wft
  116.  * 4.2 prerelease
  117.  * 
  118.  * Revision 3.6  83/01/15  16:43:28  wft
  119.  * Replaced dbm.h with BYTESIZ, fixed definition of rindex().
  120.  * Added variants of NCPFN and NCPPN for bsd 4.2, selected by defining V4_2BSD.
  121.  * Added macro DELNUMFORM to have uniform format for printing delta text nodes.
  122.  * Added macro DELETE to mark deleted deltas.
  123.  *
  124.  * Revision 3.5  82/12/10  12:16:56  wft
  125.  * Added two forms of DATEFORM, one using %02d, the other %.2d.
  126.  *
  127.  * Revision 3.4  82/12/04  20:01:25  wft
  128.  * added LOCKER, Locker, and USG (redefinition of rindex).
  129.  *
  130.  * Revision 3.3  82/12/03  12:22:04  wft
  131.  * Added dbm.h, stdio.h, RCSBASE, RCSSEP, RCSSUF, WORKMODE, TMPFILE3,
  132.  * PRINTDATE, PRINTTIME, map, and ctab; removed Suffix. Redefined keyvallength
  133.  * using NCPPN. Changed putc() to abort on write error.
  134.  *
  135.  * Revision 3.2  82/10/18  15:03:52  wft
  136.  * added macro STRICT_LOCKING, removed RCSUMASK.
  137.  * renamed JOINFILE[1,2] to JOINFIL[1,2].
  138.  *
  139.  * Revision 3.1  82/10/11  19:41:17  wft
  140.  * removed NBPW, NBPC, NCPW.
  141.  * added typdef int void to aid compiling
  142.  */
  143.  
  144. /* GCC */
  145. #if __GNUC__ && !__STRICT_ANSI__
  146. #    define exiting volatile
  147. #else
  148. #    define exiting
  149. #endif
  150.  
  151.  
  152. /* standard include files */
  153.  
  154. #include "conf.h"
  155.  
  156. #if !MAKEDEPEND
  157.  
  158. #include <errno.h>
  159. #include <signal.h>
  160. #include <time.h>
  161.  
  162.  
  163. /* AKP: set ANSI_INCLUDE_FILES to 1 in conf.h if you have them. */
  164.  
  165. #if !ANSI_INCLUDE_FILES
  166.  
  167. /* ANSI C library */
  168. /* These declarations are for the benefit of non-ANSI C hosts.  */
  169.  
  170.     /* <errno.h> */
  171. #    ifndef errno
  172.         extern int errno;
  173. #    endif
  174.  
  175.     /* <limits.h> */
  176. #    ifndef CHAR_BIT
  177. #        define CHAR_BIT 8
  178. #    endif
  179. #    ifndef ULONG_MAX
  180. #        define ULONG_MAX (-(unsigned long)1)
  181. #    endif
  182.  
  183.     /* <signal.h> */
  184. #    ifndef signal
  185.         signal_type (*signal P((int,signal_type(*)P((int)))))P((int));
  186. #    endif
  187.  
  188.     /* <stdio.h> */
  189.     /* conf.h declares the troublesome printf family.  */
  190. #    ifndef L_tmpnam
  191. #        define L_tmpnam 25 /* sizeof("/usr/tmp/xxxxxxxxxxxxxxx") */
  192. #    endif
  193. #    ifndef SEEK_SET
  194. #        define SEEK_SET 0
  195. #    endif
  196. #    ifndef fopen
  197.         FILE *fopen P((const char*,const char*));
  198. #    endif
  199. #    ifndef fread
  200.         fread_type fread P((void*,size_t,size_t,FILE*));
  201. #    endif
  202. #    ifndef fwrite
  203.         fread_type fwrite P((const void*,size_t,size_t,FILE*));
  204. #    endif
  205. #    ifndef fclose
  206.         int fclose P((FILE*));
  207. #    endif
  208. #    ifndef fflush
  209.         int fflush P((FILE*));
  210. #    endif
  211. #    ifndef fputs
  212.         int fputs P((const char*,FILE*));
  213. #    endif
  214. #    ifndef fseek
  215.         int fseek P((FILE*,long,int));
  216. #    endif
  217. #    ifndef perror
  218.         void perror P((const char*));
  219. #    endif
  220. #    ifndef clearerr
  221.         void clearerr P((FILE*));
  222. #    endif
  223. #    ifndef feof
  224.         int feof P((FILE*));
  225. #    endif
  226. #    ifndef ferror
  227.         int ferror P((FILE*));
  228. #    endif
  229. #    if has_rename && !defined(rename)
  230.         int rename P((const char*,const char*));
  231. #    endif
  232. #    if has_tmpnam && !defined(tmpnam)
  233.         char *tmpnam P((char*));
  234. #    endif
  235.  
  236.     /* <stdlib.h> */
  237. #    ifndef EXIT_FAILURE
  238. #        define EXIT_FAILURE 1
  239. #    endif
  240. #    ifndef EXIT_SUCCESS
  241. #        define EXIT_SUCCESS 0
  242. #    endif
  243. #    ifndef getenv
  244.         char *getenv P((const char*));
  245. #    endif
  246. #    ifndef exit
  247.         exiting exit_type exit P((int));
  248. #    endif
  249. #    ifndef _exit
  250.         exiting underscore_exit_type _exit P((int));
  251. #    endif
  252. #    ifndef free
  253.         free_type free P((malloc_type));
  254. #    endif
  255. #    ifndef atoi
  256.         int atoi P((const char*));
  257. #    endif
  258. #    ifndef malloc
  259.         malloc_type malloc P((size_t));
  260. #    endif
  261. #    ifndef realloc
  262.         malloc_type realloc P((malloc_type,size_t));
  263. #    endif
  264.  
  265.     /* <string.h> */
  266. #    ifndef strcat
  267.         char *strcat P((char*,const char*));
  268. #    endif
  269. #    ifndef strcpy
  270.         char *strcpy P((char*,const char*));
  271. #    endif
  272. #    ifndef strncpy
  273.         char *strncpy P((char*,const char*,int));
  274. #    endif
  275. #    ifndef strrchr
  276.         char *strrchr P((const char*,int));
  277. #    endif
  278. #    ifndef strcmp
  279.         int strcmp P((const char*,const char*));
  280. #    endif
  281. #    ifndef strncmp
  282.         int strncmp P((const char*,const char*,int));
  283. #    endif
  284. #    ifndef strlen
  285.         strlen_type strlen P((const char*));
  286. #    endif
  287.  
  288.     /* <time.h> */
  289. #    ifndef time
  290.         time_t time P((time_t*));
  291. #    endif
  292.  
  293. /* end if !ANSI_INCLUDE_FILES */
  294. #endif
  295.  
  296. /* Posix 1003.1-1988 */
  297. /* These declarations are for the benefit of non-Posix hosts.  */
  298.  
  299.     /* <limits.h> */
  300. #    if !defined(NAME_MAX) && !defined(_POSIX_NAME_MAX)
  301. #        if has_sys_dir_h
  302. #            include <sys/dir.h>
  303. #        endif
  304. #        ifndef NAME_MAX
  305. #            ifndef MAXNAMLEN
  306. #                define MAXNAMLEN 14
  307. #            endif
  308. #            define NAME_MAX MAXNAMLEN
  309. #        endif
  310. #    endif
  311. #    if !defined(PATH_MAX) && !defined(_POSIX_PATH_MAX)
  312. #        if has_sys_param_h
  313. #            include <sys/param.h>
  314. #        endif
  315. #        ifndef PATH_MAX
  316. #            ifndef MAXPATHLEN
  317. #                define MAXPATHLEN 256
  318. #            endif
  319. #            define PATH_MAX (MAXPATHLEN-1)
  320. #        endif
  321. #    endif
  322.  
  323. #if !ANSI_INCLUDE_FILES
  324. /* these are really "posix_include_files" but who's counting? */
  325.     /* <sys/wait.h> */
  326. #    if has_sys_wait_h
  327. #        include <sys/wait.h>
  328. #    endif
  329. #    ifndef WEXITSTATUS
  330. #        define WEXITSTATUS(stat_val) ((unsigned)(stat_val) >> 8)
  331. #        undef WIFEXITED /* Avoid 4.3BSD incompatibility with Posix.  */
  332. #    endif
  333. #    ifndef WIFEXITED
  334. #        define WIFEXITED(stat_val) (!((stat_val) & 255))
  335. #    endif
  336.  
  337.     /* <fcntl.h> */
  338.     /* conf.h declares fcntl() and open().  */
  339. #    ifdef F_DUPD
  340. #        undef dup2
  341. #        define dup2(a,b) fcntl(a,F_DUPFD,b)
  342. #    else
  343. #        ifndef dup2
  344.             int dup2 P((int,int));
  345. #        endif
  346. #    endif
  347. #    ifdef O_CREAT
  348. #        define open_can_creat 1
  349. #        undef creat
  350. #        define creat(path,mode) open(path,O_CREAT|O_TRUNC|O_WRONLY,mode)
  351. #    else
  352. #        define open_can_creat 0
  353. #        define O_RDONLY 0
  354. #        define O_WRONLY 1
  355. #        define O_CREAT 01000
  356. #        define O_TRUNC 02000
  357. #        ifndef creat
  358.             int creat P((const char*,mode_t));
  359. #        endif
  360. #    endif
  361.  
  362.     /* <stdio.h> */
  363. #    ifndef fdopen
  364.         FILE *fdopen P((int,const char*));
  365. #    endif
  366. /* end if !ANSI_INCLUDE_FILES */
  367. #endif
  368.     /* <sys/stat.h> */
  369.     /* conf.h declares chmod() and umask().  */
  370. #    ifndef S_IRUSR
  371. #        define S_IRUSR 0400
  372. #        define S_IWUSR 0200
  373. #        define S_IRGRP 0040
  374. #        define S_IWGRP 0020
  375. #        define S_IROTH 0004
  376. #        define S_IWOTH 0002
  377. #    endif
  378. #    ifndef S_ISREG
  379. #        define S_ISREG(n) (((n) & S_IFMT) == S_IFREG)
  380. #    endif
  381. #if !ANSI_INCLUDE_FILES
  382. #    ifndef fstat
  383.         int fstat P((int,struct stat*));
  384. #    endif
  385. #    ifndef stat
  386.         int stat P((const char*,struct stat*));
  387. #    endif
  388. /* end if !ANSI_INCLUDE_FILES */
  389. #endif
  390.  
  391.     /* <unistd.h> */
  392. #    ifndef STDIN_FILENO
  393. #        define STDIN_FILENO 0
  394. #        define STDOUT_FILENO 1
  395. #        define STDERR_FILENO 2
  396. #    endif
  397. #if !ANSI_INCLUDE_FILES
  398. #    ifndef getlogin
  399.         char *getlogin P((void));
  400. #    endif
  401. #    ifndef _exit
  402.         exiting void _exit P((int));
  403. #    endif
  404. #    ifndef close
  405.         int close P((int));
  406. #    endif
  407. #    ifndef execv
  408.         int execv P((const char*,const char*const*));
  409. #    endif
  410. #    ifndef execvp
  411.         int execvp P((const char*,const char*const*));
  412. #    endif
  413. #    ifndef isatty
  414.         int isatty P((int));
  415. #    endif
  416. #    ifndef read
  417.         int read P((int,char*,unsigned));
  418. #    endif
  419. #    ifndef write
  420.         int write P((int,const char*,unsigned));
  421. #    endif
  422. #    ifndef unlink
  423.         int unlink P((const char*));
  424. #    endif
  425. #    if has_getcwd && !defined(getcwd)
  426.         char *getcwd P((char*,size_t));
  427. #    endif
  428.  
  429. /* end if !ANSI_INCLUDE_FILES */
  430. #endif
  431.  
  432. #    if has_getuid
  433. #        ifndef getgid
  434.             gid_t getgid P((void));
  435. #        endif
  436. #        ifndef getuid
  437.             uid_t getuid P((void));
  438. #        endif
  439. #    endif
  440. #    if has_seteuid
  441. #        ifndef setegid
  442.             int setegid P((gid_t));
  443. #        endif
  444. #        ifndef seteuid
  445.             int seteuid P((uid_t));
  446. #        endif
  447. #        ifndef getegid
  448.             gid_t getegid P((void));
  449. #        endif
  450. #        ifndef geteuid
  451.             uid_t geteuid P((void));
  452. #        endif
  453. #    endif
  454.  
  455. #if !DONT_USE_FORK
  456. #    if has_vfork
  457. #        ifndef vfork
  458.             pid_t vfork P((void));
  459. #        endif
  460. #    else
  461. #        define vfork fork
  462. #        ifndef fork
  463.             pid_t fork P((void));
  464. #        endif
  465. #    endif
  466. #endif
  467.  
  468.  
  469. /* traditional Unix library */
  470. #define EXIT_TROUBLE 2 /* code returned by diff(1) if trouble is found */
  471. #if !has_getcwd && !defined(getwd)
  472.     char *getwd P((char*));
  473. #endif
  474. #if !has_tmpnam && !defined(mktemp)
  475.     char *mktemp P((char*));
  476. #endif
  477. #if !has_sigaction & has_sigblock
  478. #    ifndef sigblock
  479.         int sigblock P((int));
  480. #    endif
  481. #    ifndef sigsetmask
  482.         int sigsetmask P((int));
  483. #    endif
  484. #endif
  485. #ifndef _filbuf
  486.     int _filbuf P((FILE*));
  487. #endif
  488. #ifndef _flsbuf
  489.     int _flsbuf P((int,FILE*));
  490. #endif
  491.  
  492.  
  493. #endif /* !MAKEDEPEND */
  494.  
  495.  
  496. /*
  497.  * Parameters
  498.  */
  499.  
  500. /* backwards compatibility with old versions of RCS */
  501. #define VERSION_MIN 3        /* old output RCS format supported */
  502. #define VERSION_MAX 5        /* newest output RCS format supported */
  503. #ifndef VERSION_DEFAULT        /* default RCS output format */
  504. #    define VERSION_DEFAULT VERSION_MAX
  505. #endif
  506. #define VERSION(n) ((n) - VERSION_DEFAULT) /* internally, 0 is the default */
  507.  
  508. #ifndef STRICT_LOCKING
  509. #define STRICT_LOCKING 0
  510. #endif
  511.                   /* 0 sets the default locking to non-strict;  */
  512.                               /* used in experimental environments.         */
  513.                               /* 1 sets the default locking to strict;      */
  514.                               /* used in production environments.           */
  515.  
  516. #define yearlength       16 /* (good through AD 9,999,999,999,999,999)    */
  517. #define datesize (yearlength+16) /* size of output of DATEFORM            */
  518. #define joinlength         20 /* number of joined revisions permitted       */
  519. #define RCSSUF            'v' /* suffix for RCS files                       */
  520. #define KDELIM            '$' /* delimiter for keywords                     */
  521. #define VDELIM            ':' /* separates keywords from values             */
  522. #define DEFAULTSTATE    "Exp" /* default state of revisions                 */
  523.  
  524.  
  525.  
  526. #define true     1
  527. #define false    0
  528. #define nil      0
  529.  
  530.  
  531.  
  532.  
  533. /* This version of putc prints a char, but aborts on write error            */
  534. #if lint
  535. #    define aputc(c,o) afputc(c,o)
  536. #    define GETC(i,o,c) afputc(c=getc(i), o)
  537. #else
  538. #    define aputc(c,o) do { if (putc(c,o)==EOF) IOerror(); } while(0)
  539. #    define GETC(i,o,c) do {c=getc(i); if (o) aputc(c,o); } while(0)
  540. #endif
  541. /* GETC writes a DEL-character (all ones) on end of file.            */
  542.  
  543. #if AKP_MODES
  544. #define WORKMODE(RCSmode, writable) ((RCSmode)&~(S_IWRITE) | ((writable)?S_IWRITE:0))
  545. #else
  546. #define WORKMODE(RCSmode, writable) ((RCSmode)&~(S_IWUSR|S_IWGRP|S_IWOTH) | ((writable)?S_IWUSR:0))
  547. #endif
  548.  
  549. /* computes mode of working file: same as RCSmode, but write permission     */
  550. /* determined by writable */
  551.  
  552.  
  553. /* character classes and token codes */
  554. enum tokens {
  555. /* classes */    DELIM,    DIGIT,    IDCHAR,    NEWLN,    LETTER,    Letter,
  556.         PERIOD,    SBEGIN,    SPACE,    UNKN,
  557. /* tokens */    COLON,    EOFILE,    ID,    NUM,    SEMI,    STRING
  558. };
  559.  
  560. #define SDELIM  '@'     /* the actual character is needed for string handling*/
  561. /* SDELIM must be consistent with map[], so that ctab[SDELIM]==SBEGIN.
  562.  * there should be no overlap among SDELIM, KDELIM, and VDELIM
  563.  */
  564.  
  565. #define isdigit(c) ((unsigned)((c)-'0') <= 9) /* faster than ctab[c]==DIGIT */
  566.  
  567.  
  568.  
  569.  
  570.  
  571. /***************************************
  572.  * Data structures for the symbol table
  573.  ***************************************/
  574.  
  575. /* Buffer of arbitrary data */
  576. struct buf {
  577.     char *string;
  578.     size_t size;
  579. };
  580. struct cbuf {
  581.     const char *string;
  582.     size_t size;
  583. };
  584.  
  585. /* Hash table entry */
  586. struct hshentry {
  587.     const char      * num;      /* pointer to revision number (ASCIZ) */
  588.     const char      * date;     /* pointer to date of checkin        */
  589.     const char      * author;   /* login of person checking in        */
  590.     const char      * lockedby; /* who locks the revision             */
  591.     const char      * state;    /* state of revision (Exp by default) */
  592.     struct cbuf        log;      /* log message requested at checkin   */
  593.         struct branchhead * branches; /* list of first revisions on branches*/
  594.     struct cbuf        ig;          /* ignored phrases of revision        */
  595.         struct hshentry   * next;     /* next revision on same branch       */
  596.     struct hshentry   * nexthsh;  /* next revision with same hash value */
  597.     unsigned long        insertlns;/* lines inserted (computed by rlog)  */
  598.     unsigned long        deletelns;/* lines deleted  (computed by rlog)  */
  599.     char            selector; /* true if selected, false if deleted */
  600. };
  601.  
  602. /* list of hash entries */
  603. struct hshentries {
  604.     struct hshentries *rest;
  605.     struct hshentry *first;
  606. };
  607.  
  608. /* list element for branch lists */
  609. struct branchhead {
  610.         struct hshentry   * hsh;
  611.         struct branchhead * nextbranch;
  612. };
  613.  
  614. /* accesslist element */
  615. struct access {
  616.     const char      * login;
  617.         struct access     * nextaccess;
  618. };
  619.  
  620. /* list element for locks  */
  621. struct lock {
  622.     const char      * login;
  623.         struct hshentry   * delta;
  624.         struct lock       * nextlock;
  625. };
  626.  
  627. /* list element for symbolic names */
  628. struct assoc {
  629.     const char      * symbol;
  630.     const char      * num;
  631.         struct assoc      * nextassoc;
  632. };
  633.  
  634.  
  635. #define mainArgs (argc,argv) int argc; char **argv;
  636.  
  637. #if lint
  638. #    define libId(name,rcsid)
  639. #    define mainProg(name,cmd,rcsid) int name mainArgs
  640. #else
  641. #    define libId(name,rcsid) const char name[] = rcsid;
  642. #    define mainProg(name,cmd,rcsid) const char copyright[] = "Copyright 1982,1988,1989 by Walter F. Tichy\nPurdue CS\nCopyright 1990 by Paul Eggert", rcsbaseId[] = RCSBASE, cmdid[] = cmd; libId(name,rcsid) int main mainArgs
  643. #endif
  644.  
  645. /*
  646.  * Markers for keyword expansion (used in co and ident)
  647.  *    Every byte must have class LETTER or Letter.
  648.  */
  649. #define AUTHOR          "Author"
  650. #define DATE            "Date"
  651. #define HEADER          "Header"
  652. #define IDH             "Id"
  653. #define LOCKER          "Locker"
  654. #define LOG             "Log"
  655. #define RCSFILE         "RCSfile"
  656. #define REVISION        "Revision"
  657. #define SOURCE          "Source"
  658. #define STATE           "State"
  659. #define keylength 8 /* max length of any of the above keywords */
  660.  
  661. enum markers { Nomatch, Author, Date, Header, Id,
  662.            Locker, Log, RCSfile, Revision, Source, State };
  663.     /* This must be in the same order as rcskeys.c's Keyword[] array. */
  664.  
  665. #define DELNUMFORM      "\n\n%s\n%s\n"
  666. /* used by putdtext and scanlogtext */
  667.  
  668. /* main program */
  669. extern const char cmdid[];
  670. exiting void exiterr P((void));
  671.  
  672. /* maketime */
  673. void str2date P((const char*,char[datesize]));
  674. void time2date P((time_t,char[datesize]));
  675.  
  676. /* partime */
  677. int partime P((const char*,struct tm*,int*));
  678.  
  679. /* rcsedit */
  680. #define ciklogsize 23 /* sizeof("checked in with -k by ") */
  681. extern FILE *fcopy;
  682. extern const char *resultfile;
  683. extern const char ciklog[ciklogsize];
  684. extern int locker_expansion;
  685. extern struct buf dirtfname[];
  686. #define newRCSfilename (dirtfname[0].string)
  687. FILE *initeditfiles P((const char*));
  688. FILE *rcswriteopen P((const char*));
  689. const char *makedirtemp P((const char*,int));
  690. int expandline P((FILE*,FILE*,const struct hshentry*,int,FILE*));
  691. void arewind P((FILE*));
  692. void copystring P((void));
  693. void dirtempunlink P((void));
  694. void editstring P((const struct hshentry*));
  695. void finishedit P((const struct hshentry*));
  696. void inittmpeditfiles P((void));
  697. void keepdirtemp P((const char*));
  698. void swapeditfiles P((int));
  699. void xpandstring P((const struct hshentry*));
  700.  
  701. /* rcsfnms */
  702. #define bufautobegin(b) ((void) ((b)->size = 0)) /* for auto on block entry */
  703. extern char *workfilename;
  704. extern const char *RCSfilename;
  705. extern int haveworkstat;
  706. extern struct stat RCSstat;
  707. extern struct stat workstat;
  708. FILE *rcsreadopen P((const char*));
  709. char *bufenlarge P((struct buf*,const char**));
  710. char *maketemp P((int));
  711. const char *bindex P((const char*,int));
  712. const char *getfullRCSname P((void));
  713. const char *tmp();
  714. int getfworkstat P((int));
  715. int getworkstat P((void));
  716. int pairfilenames P((int,char**,FILE*(*)P((const char*)),int,int));
  717. void bufalloc P((struct buf*,size_t));
  718. void bufautoend P((struct buf*));
  719. void bufrealloc P((struct buf*,size_t));
  720. void bufscat P((struct buf*,const char*));
  721. void bufscpy P((struct buf*,const char*));
  722. void ffclose P((FILE*));
  723. void tempunlink P((void));
  724. #if has_rename & !bad_rename
  725. #    define re_name(x,y) rename(x,y)
  726. #else
  727.     int re_name P((const char*,const char*));
  728. #endif
  729.  
  730. #if bad_unlink
  731. int un_link P((const char *a));
  732. #  define unlink(a) un_link(a)
  733. #endif
  734.  
  735. /* rcsgen */
  736. extern int interactiveflag;
  737. extern struct cbuf curlogmsg;
  738. extern struct buf curlogbuf;
  739. const char *buildrevision P((const struct hshentries*,struct hshentry*,int,int));
  740. int getcstdin P((void));
  741. int ttystdin P((void));
  742. int yesorno P((int,const char*,...));
  743. struct cbuf cleanlogmsg P((char*,size_t));
  744. void putdesc P((int,const char*));
  745.  
  746. /* rcskeys */
  747. extern const char *const Keyword[];
  748. enum markers trymatch P((const char*));
  749.  
  750. /* rcslex */
  751. extern FILE *finptr;
  752. extern FILE *foutptr;
  753. extern FILE *frewrite;
  754. extern const char *NextString;
  755. extern enum tokens nexttok;
  756. extern int hshenter;
  757. extern int nerror;
  758. extern int nextc;
  759. extern int quietflag;
  760. extern unsigned long rcsline;
  761. const char *getid P((void));
  762. exiting void efaterror P((const char*));
  763. exiting void faterror P((const char*,...));
  764. exiting void fatserror P((const char*,...));
  765. exiting void IOerror P((void));
  766. exiting void unterminatedString P((void));
  767. char *checkid P((char*,int));
  768. int getkeyopt P((const char*));
  769. int getlex P((enum tokens));
  770. struct cbuf getphrases P((const char*));
  771. struct cbuf savestring P((struct buf*));
  772. struct hshentry *getnum P((void));
  773. void Lexinit P((void));
  774. void afputc P((int,FILE*));
  775. void aprintf P((FILE*,const char*,...));
  776. void aputs P((const char*,FILE*));
  777. void checksid P((char*));
  778. void diagnose P((const char*,...));
  779. void eflush P((void));
  780. void error P((const char*,...));
  781. void eerror P((const char*));
  782. void fvfprintf P((FILE*,const char*,va_list));
  783. void getkey P((const char*));
  784. void getkeystring P((const char*));
  785. void nextlex P((void));
  786. void oflush P((void));
  787. void printstring P((void));
  788. void readstring P((void));
  789. void redefined P((int));
  790. void warn P((const char*,...));
  791. void warnignore P((void));
  792.  
  793. /* rcsmap */
  794. #define ctab (&map[1])
  795. extern const enum tokens map[];
  796.  
  797. /* rcsrev */
  798. char *partialno P((struct buf*,const char*,unsigned));
  799. int cmpnum P((const char*,const char*));
  800. int cmpnumfld P((const char*,const char*,unsigned));
  801. int compartial P((const char*,const char*,unsigned));
  802. int expandsym P((const char*,struct buf*));
  803. struct hshentry *genrevs P((const char*,const char*,const char*,const char*,struct hshentries**));
  804. unsigned countnumflds P((const char*));
  805. void getbranchno P((const char*,struct buf*));
  806.  
  807. /* rcssyn */
  808. /* These expand modes must agree with Expand_names[] in rcssyn.c.  */
  809. #define KEYVAL_EXPAND 0 /* -kkv `$Keyword: value $' */
  810. #define KEYVALLOCK_EXPAND 1 /* -kkvl `$Keyword: value locker $' */
  811. #define KEY_EXPAND 2 /* -kk `$Keyword$' */
  812. #define VAL_EXPAND 3 /* -kv `value' */
  813. #define OLD_EXPAND 4 /* -ko use old string, omitting expansion */
  814. struct diffcmd {
  815.     unsigned long
  816.         line1, /* number of first line */
  817.         nlines, /* number of lines affected */
  818.         adprev, /* previous 'a' line1+1 or 'd' line1 */
  819.         dafter; /* sum of previous 'd' line1 and previous 'd' nlines */
  820. };
  821. extern const char      * Dbranch;
  822. extern struct access   * AccessList;
  823. extern struct assoc    * Symbols;
  824. extern struct cbuf Comment;
  825. extern struct lock     * Locks;
  826. extern struct hshentry * Head;
  827. extern int         Expand;
  828. extern int               StrictLocks;
  829. extern int               TotalDeltas;
  830. extern const char *const expand_names[];
  831. extern const char Kdesc[];
  832. extern const char Klog[];
  833. extern const char Ktext[];
  834. int getdiffcmd P((FILE*,int,FILE*,struct diffcmd*));
  835. int putdftext P((const char*,struct cbuf,FILE*,FILE*,int));
  836. int putdtext P((const char*,struct cbuf,const char*,FILE*,int));
  837. int str2expmode P((const char*));
  838. void getadmin P((void));
  839. void getdesc P((int));
  840. void gettree P((void));
  841. void ignorephrase P((void));
  842. void initdiffcmd P((struct diffcmd*));
  843. void putadmin P((FILE*));
  844. void puttree P((const struct hshentry*,FILE*));
  845.  
  846. /* rcsutil */
  847. extern int RCSversion;
  848. char *cgetenv P((const char*));
  849. const char *getcaller P((void));
  850. const char *fstrsave P((const char*));
  851. const char *strsave P((const char*));
  852. int addlock P((struct hshentry*));
  853. int addsymbol P((const char*,const char*,int));
  854. int checkaccesslist P((void));
  855. int findlock P((int,struct hshentry**));
  856. int run P((const char*,const char*,...));
  857. int runv P((const char**));
  858. malloc_type fremember P((malloc_type));
  859. malloc_type ftestalloc P((size_t));
  860. malloc_type testalloc P((size_t));
  861. malloc_type testrealloc P((malloc_type,size_t));
  862. #define ftalloc(T) ftnalloc(T,1)
  863. #define talloc(T) tnalloc(T,1)
  864. #if lint
  865.     extern malloc_type lintalloc;
  866. #    define ftnalloc(T,n) (lintalloc = ftestalloc(sizeof(T)*(n)), (T*)0)
  867. #    define tnalloc(T,n) (lintalloc = testalloc(sizeof(T)*(n)), (T*)0)
  868. #    define tfree(p)
  869. #else
  870. #    define ftnalloc(T,n) ((T*) ftestalloc(sizeof(T)*(n)))
  871. #    define tnalloc(T,n) ((T*) testalloc(sizeof(T)*(n)))
  872. #    define tfree(p) free((malloc_type)(p))
  873. #endif
  874. void awrite P((const char*,fread_type,FILE*));
  875. void catchints P((void));
  876. void fastcopy P((FILE*,FILE*));
  877. void ffree P((void));
  878. void ffree1 P((const char*));
  879. void initid P((void));
  880. void ignoreints P((void));
  881. void printdate P((FILE*,const char*,const char*));
  882. void restoreints P((void));
  883. void setRCSversion P((const char*));
  884. #define SETID (has_getuid & has_seteuid & DIFF_PATH_HARDWIRED)
  885. #if has_getuid
  886.     extern uid_t ruid;
  887. #    define myself(u) ((u) == ruid)
  888. #else
  889. #    define myself(u) true
  890. #endif
  891. #if SETID
  892.     void seteid P((void));
  893.     void setrid P((void));
  894. #else
  895. #    define seteid()
  896. #    define setrid()
  897. #endif
  898.