home *** CD-ROM | disk | FTP | other *** search
/ rtsi.com / 2014.01.www.rtsi.com.tar / www.rtsi.com / OS9 / OSK / CMDS / rcs4.lha / rcsbase.h < prev    next >
Text File  |  1993-03-03  |  12KB  |  357 lines

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