home *** CD-ROM | disk | FTP | other *** search
/ Language/OS - Multiplatform Resource Library / LANGUAGE OS.iso / cpp_libs / cool / cool.lha / ice / pisces / rcs / rcsbase.h < prev    next >
Encoding:
C/C++ Source or Header  |  1991-09-04  |  12.8 KB  |  389 lines

  1.  
  2. /*
  3.  *                     RCS common definitions and data structures
  4.  */
  5. #define RCSBASE "$Id: rcsbase.h,v 1.1 90/05/21 13:42:58 neath Exp $"
  6.  
  7. /* Copyright (C) 1982, 1988, 1989 Walter Tichy
  8.    Distributed under license by the Free Software Foundation, Inc.
  9.  
  10. This file is part of RCS.
  11.  
  12. RCS is free software; you can redistribute it and/or modify
  13. it under the terms of the GNU General Public License as published by
  14. the Free Software Foundation; either version 1, or (at your option)
  15. any later version.
  16.  
  17. RCS is distributed in the hope that it will be useful,
  18. but WITHOUT ANY WARRANTY; without even the implied warranty of
  19. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  20. GNU General Public License for more details.
  21.  
  22. You should have received a copy of the GNU General Public License
  23. along with RCS; see the file COPYING.  If not, write to
  24. the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
  25.  
  26. Report problems and direct all questions to:
  27.  
  28.     rcs-bugs@cs.purdue.edu
  29.  
  30. */
  31.  
  32.  
  33.  
  34. /*****************************************************************************
  35.  * INSTRUCTIONS:
  36.  * =============
  37.  * The following should be handled in the Makefile:
  38.  *     For USG Unix, define USG; for BSD Unix, don't (see ifdef USG).
  39.  *     For 4.2 bsd, define V4_2BSD; this will replace the routines
  40.  *     getwd() and rename() with the corresponding ones in the C-library.
  41.  *     V4_2BSD also selects different definitions for the macros NCPFN and NCPPN
  42.  *     (max. number of characters per filename, number of characters per path name).
  43.  *     Define STRICT_LOCKING appropriately (see STRICT_LOCKING).
  44.  * The following need be changed for porting to a different machine:
  45.  *     Define SMALLOG for a machine with small memory (like the PDP11).
  46.  *     SMALLOG conserves space for log messages.
  47.  *     Change BYTESIZ if necessary.
  48.  * If you need to change the comment leaders, update the table comtable[]
  49.  * in rcsfnms.c. (This can wait until you know what a comment leader is.)
  50.  *****************************************************************************
  51.  */
  52.  
  53.  
  54. /* $Log:    rcsbase.h,v $
  55.  * Revision 1.1  90/05/21  13:42:58  neath
  56.  * Initial revision
  57.  * 
  58.  * Revision 4.9  89/05/01  15:17:14  narten
  59.  * botched previous USG fix 
  60.  * 
  61.  * Revision 4.8  89/05/01  14:53:05  narten
  62.  * changed #include <strings.h> -> string.h for USG systems.
  63.  * 
  64.  * Revision 4.7  88/11/08  15:58:45  narten
  65.  * removed defs for functions loaded from libraries
  66.  * 
  67.  * Revision 4.6  88/11/08  12:04:06  narten
  68.  * changes from eggert@sm.unisys.com (Paul Eggert)
  69.  * 
  70.  * Revision 4.6  88/08/09  19:12:36  eggert
  71.  * Shrink stdio code size; remove lint; permit -Dhshsize=nn.
  72.  * 
  73.  * Revision 4.5  87/12/18  17:06:41  narten
  74.  * made removed BSD ifdef, now uses V4_2BSD
  75.  * 
  76.  * Revision 4.4  87/10/18  10:29:49  narten
  77.  * Updating version numbers
  78.  * Changes relative to 1.1 are actually relative to 4.2
  79.  * 
  80.  * Revision 1.3  87/09/24  14:02:25  narten
  81.  * changes for lint
  82.  * 
  83.  * Revision 1.2  87/03/27  14:22:02  jenkins
  84.  * Port to suns
  85.  * 
  86.  * Revision 1.1  84/01/23  14:50:14  kcs
  87.  * Initial revision
  88.  * 
  89.  * Revision 4.2  83/12/20  16:04:20  wft
  90.  * merged 3.6.1.1 and 4.1 (SMALLOG, logsize).
  91.  * moved setting of STRICT_LOCKING to Makefile.
  92.  * changed DOLLAR to UNKN (conflict with KDELIM).
  93.  * 
  94.  * Revision 4.1  83/05/04  09:12:41  wft
  95.  * Added markers Id and RCSfile.
  96.  * Added Dbranch for default branches.
  97.  * 
  98.  * Revision 3.6.1.1  83/12/02  21:56:22  wft
  99.  * Increased logsize, added macro SMALLOG.
  100.  * 
  101.  * Revision 3.6  83/01/15  16:43:28  wft
  102.  * 4.2 prerelease
  103.  * 
  104.  * Revision 3.6  83/01/15  16:43:28  wft
  105.  * Replaced dbm.h with BYTESIZ, fixed definition of rindex().
  106.  * Added variants of NCPFN and NCPPN for bsd 4.2, selected by defining V4_2BSD.
  107.  * Added macro DELNUMFORM to have uniform format for printing delta text nodes.
  108.  * Added macro DELETE to mark deleted deltas.
  109.  *
  110.  * Revision 3.5  82/12/10  12:16:56  wft
  111.  * Added two forms of DATEFORM, one using %02d, the other %.2d.
  112.  *
  113.  * Revision 3.4  82/12/04  20:01:25  wft
  114.  * added LOCKER, Locker, and USG (redefinition of rindex).
  115.  *
  116.  * Revision 3.3  82/12/03  12:22:04  wft
  117.  * Added dbm.h, stdio.h, RCSBASE, RCSSEP, RCSSUF, WORKMODE, TMPFILE3,
  118.  * PRINTDATE, PRINTTIME, map, and ctab; removed Suffix. Redefined keyvallength
  119.  * using NCPPN. Changed putc() to abort on write error.
  120.  *
  121.  * Revision 3.2  82/10/18  15:03:52  wft
  122.  * added macro STRICT_LOCKING, removed RCSUMASK.
  123.  * renamed JOINFILE[1,2] to JOINFIL[1,2].
  124.  *
  125.  * Revision 3.1  82/10/11  19:41:17  wft
  126.  * removed NBPW, NBPC, NCPW.
  127.  * added typdef int void to aid compiling
  128.  */
  129.  
  130.  
  131.  
  132. #include <stdio.h>
  133. #ifdef USG
  134. #include <string.h>
  135. #else
  136. #include <strings.h>
  137. #endif
  138. #undef putc         /* will be redefined */
  139.  
  140.  
  141. #ifdef USG
  142. #       define rindex    strrchr
  143. #       define DATEFORM  "%.2d.%.2d.%.2d.%.2d.%.2d.%.2d"
  144. #else
  145. #       define DATEFORM  "%02d.%02d.%02d.%02d.%02d.%02d"
  146. #endif
  147. /* Make sure one of %02d or %.2d prints a number with a field width 2, with
  148.  * leading zeroes. For example, 0, 1, and 22 must be printed as 00, 01, and
  149.  * 22. Otherwise, there will be problems with the dates.
  150.  */
  151.  
  152. #define PRINTDATE(file,date) fprintf(file,"%.2s/%.2s/%.2s",date,date+3,date+6)
  153. #define PRINTTIME(file,date) fprintf(file,"%.2s:%.2s:%.2s",date+9,date+12,date+15)
  154. /* print RCS format date and time in nice format from a string              */
  155.  
  156. /*
  157.  * Parameters
  158.  */
  159. #define BYTESIZ             8 /* number of bits in a byte                   */
  160.  
  161. /*#define STRICT_LOCKING    0 /* 0 sets the default locking to non-strict;  */
  162.                               /* used in experimental environments.         */
  163.                               /* 1 sets the default locking to strict;      */
  164.                               /* used in production environments.           */
  165.                   /* STRICT_LOCKING is set in the Makefile!     */
  166. #ifndef hshsize
  167. #define hshsize           239 /* hashtable size; MUST be prime and -1 mod 4 */
  168.                               /* other choices: 547 or 719                  */
  169. #endif
  170.  
  171. #define strtsize (hshsize * 50) /* string table size                        */
  172. #ifdef SMALLOG
  173. #  define logsize         1024 /* max. size of log message for pdp11        */
  174. #else
  175. #  define logsize         4096 /* max. size of log message for others       */
  176. #endif
  177. #define revlength          30 /* max. length of revision numbers            */
  178. #define datelength         20 /* length of a date in RCS format             */
  179. #define joinlength         20 /* number of joined revisions permitted       */
  180. #define RCSDIR         "RCS/" /* subdirectory for RCS files                 */
  181. #define RCSSUF            'v' /* suffix for RCS files                       */
  182. #define RCSSEP            ',' /* separator for RCSSUF                       */
  183. #define KDELIM            '$' /* delimiter for keywords                     */
  184. #define VDELIM            ':' /* separates keywords from values             */
  185. #define DEFAULTSTATE    "Exp" /* default state of revisions                 */
  186. #ifdef V4_2BSD
  187. #  define NCPFN           256 /* number of characters per filename          */
  188. #  define NCPPN          1024 /* number of characters per pathname          */
  189. #else
  190. #  define NCPFN            14 /* number of characters per filename          */
  191. #  define NCPPN       6*NCPFN /* number of characters per pathname          */
  192. #endif
  193. #define keylength          20 /* buffer length for expansion keywords       */
  194. #define keyvallength NCPPN+revlength+datelength+60
  195.                               /* buffer length for keyword expansion        */
  196.  
  197.  
  198.  
  199. #define true     1
  200. #define false    0
  201. #define nil      0
  202. #define elsif    else if
  203. #define elif     else if
  204.  
  205.  
  206. /* temporary file names */
  207.  
  208. #define NEWRCSFILE  ",RCSnewXXXXXX"
  209. #define DIFFILE     ",RCSciXXXXXX"
  210. #define TMPFILE1    ",RCSt1XXXXXX"
  211. #define TMPFILE2    ",RCSt2XXXXXX"
  212. #define TMPFILE3    ",RCSt3XXXXXX"
  213. #define JOINFIL2    ",RCSj2XXXXXX"
  214. #define JOINFIL3    ",RCSj3XXXXXX"
  215.  
  216.  
  217. #define putc(x,p) (--(p)->_cnt>=0? ((int)(*(p)->_ptr++=(unsigned)(x))):fflsbuf((unsigned)(x),p))
  218. /* This version of putc prints a char, but aborts on write error            */
  219.  
  220. #define GETC(in,out,echo) (c=getc(in), echo?putc(c,out):c)
  221. /* GETC modifies a local variable c; a kludge, but smaller and faster.      */
  222. /* GETC writes a del-character (octal 177) on end of file                   */
  223.  
  224. #define WORKMODE(RCSmode) (RCSmode&~0222)|((lockflag||!StrictLocks)?0600:0000)
  225. /* computes mode of working file: same as RCSmode, but write permission     */
  226. /* determined by lockflag and StrictLocks.                                  */
  227.  
  228.  
  229. /* character classes and token codes */
  230. enum tokens {
  231. /* char classes*/  DIGIT, IDCHAR, NEWLN, LETTER, PERIOD, SBEGIN, SPACE, UNKN,
  232. /* tokens */       COLON, DATE, EOFILE, ID, KEYW, NUM, SEMI, STRING,
  233. };
  234.  
  235. #define AT      SBEGIN  /* class SBEGIN (string begin) is returned by lex. anal. */
  236. #define SDELIM  '@'     /* the actual character is needed for string handling*/
  237. /* these must be changed consistently, for instance to:
  238.  * #define DQUOTE       SBEGIN
  239.  * #define SDELIM       '"'
  240.  * #define AT           IDCHAR
  241.  * there should be no overlap among SDELIM, KDELIM, and VDELIM
  242.  */
  243.  
  244. /* other characters */
  245.  
  246. #define ACCENT   IDCHAR
  247. #define AMPER    IDCHAR
  248. #define BACKSL   IDCHAR
  249. #define BAR      IDCHAR
  250. #define COMMA    UNKN
  251. #define DIVIDE   IDCHAR
  252. #define DOLLAR   UNKN                /* overlap with KDELIM */
  253. #define DQUOTE   IDCHAR
  254. #define EQUAL    IDCHAR
  255. #define EXCLA    IDCHAR
  256. #define GREAT    IDCHAR
  257. #define HASH     IDCHAR
  258. #define INSERT   UNKN
  259. #define LBRACE   IDCHAR
  260. #define LBRACK   IDCHAR
  261. #define LESS     IDCHAR
  262. #define LPARN    IDCHAR
  263. #define MINUS    IDCHAR
  264. #define PERCNT   IDCHAR
  265. #define PLUS     IDCHAR
  266. #define QUEST    IDCHAR
  267. #define RBRACE   IDCHAR
  268. #define RBRACK   IDCHAR
  269. #define RPARN    IDCHAR
  270. #define SQUOTE   IDCHAR
  271. #define TILDE    IDCHAR
  272. #define TIMES    IDCHAR
  273. #define UNDER    IDCHAR
  274. #define UPARR    IDCHAR
  275.  
  276.  
  277.  
  278.  
  279. /***************************************
  280.  * Data structures for the symbol table
  281.  ***************************************/
  282.  
  283.  
  284. /* Hash table entry */
  285. struct hshentry {
  286.         char              * num;      /* pointer to revision number (ASCIZ) */
  287.         char              * date;     /* pointer to date of checking        */
  288.         char              * author;   /* login of person checking in        */
  289.         char              * lockedby; /* who locks the revision             */
  290.         char              * log;      /* log message requested at checkin   */
  291.         char              * state;    /* state of revision (Exp by default) */
  292.         struct branchhead * branches; /* list of first revisions on branches*/
  293.         struct hshentry   * next;     /* next revision on same branch       */
  294.         int                 insertlns;/* lines inserted (computed by rlog)  */
  295.         int                 deletelns;/* lines deleted  (computed by rlog)  */
  296.         char                selector; /* marks entry for selection/deletion */
  297. };
  298.  
  299. /* list element for branch lists */
  300. struct branchhead {
  301.         struct hshentry   * hsh;
  302.         struct branchhead * nextbranch;
  303. };
  304.  
  305. /* accesslist element */
  306. struct access {
  307.         char              * login;
  308.         struct access     * nextaccess;
  309. };
  310.  
  311. /* list element for locks  */
  312. struct lock {
  313.         char              * login;
  314.         struct hshentry   * delta;
  315.         struct lock       * nextlock;
  316. };
  317.  
  318. /* list element for symbolic names */
  319. struct assoc {
  320.         char              * symbol;
  321.         struct hshentry   * delta;
  322.         struct assoc      * nextassoc;
  323. };
  324.  
  325.  
  326. /* common variables (getadmin and getdelta())*/
  327. extern char            * Comment;
  328. extern struct access   * AccessList;
  329. extern struct assoc    * Symbols;
  330. extern struct lock     * Locks;
  331. extern struct hshentry * Head;
  332. extern struct hshentry * Dbranch;
  333. extern int               StrictLocks;
  334. extern int               TotalDeltas;
  335. #ifndef lint
  336. static char copyright[]="Copyright (C) 1982 by Walter F. Tichy";
  337. #endif
  338.  
  339. /* common variables (lexical analyzer)*/
  340. extern enum tokens map[];
  341. #define ctab (&map[1])
  342. extern enum tokens       nexttok;
  343. extern int               hshenter;
  344. extern char            * NextString;
  345. extern char            * cmdid;
  346.  
  347. #if defined(USG) || defined(V4_2BSD)
  348. #define VOID    (void)
  349. #else
  350. typedef int void;
  351. #define VOID
  352. #endif
  353.  
  354. /* common routines */
  355. extern char *talloc();
  356. extern int serror();
  357. extern int faterror();
  358. extern int fatserror();
  359. extern void ignoreints();
  360. extern void catchints();
  361. extern void restoreints();
  362.  
  363. #ifdef USG
  364. extern int sprintf();
  365. #endif
  366.  
  367. /*
  368.  * Markers for keyword expansion (used in co and ident)
  369.  */
  370. #define AUTHOR          "Author"
  371. #define DATE            "Date"
  372. #define HEADER          "Header"
  373. #define IDH             "Id"
  374. #define LOCKER          "Locker"
  375. #define LOG             "Log"
  376. #define RCSFILE         "RCSfile"
  377. #define REVISION        "Revision"
  378. #define SOURCE          "Source"
  379. #define STATE           "State"
  380.  
  381. enum markers { Nomatch, Author, Date, Header, Id,
  382.            Locker, Log, RCSfile, Revision, Source, State };
  383.  
  384. #define DELNUMFORM      "\n\n%s\n%s\n"
  385. /* used by putdtext and scanlogtext */
  386. #define DELETE          'D'
  387. /* set by rcs -o and used by puttree() in rcssyn */
  388.  
  389.