[BACK]Return to rcs.h CVS log [TXT][DIR] Up to [local] / src / usr.bin / cvs

Annotation of src/usr.bin/cvs/rcs.h, Revision 1.28

1.28    ! jfb         1: /*     $OpenBSD: rcs.h,v 1.27 2005/05/25 21:32:31 jfb Exp $    */
1.1       jfb         2: /*
                      3:  * Copyright (c) 2004 Jean-Francois Brousseau <jfb@openbsd.org>
1.2       tedu        4:  * All rights reserved.
1.1       jfb         5:  *
1.2       tedu        6:  * Redistribution and use in source and binary forms, with or without
                      7:  * modification, are permitted provided that the following conditions
                      8:  * are met:
1.1       jfb         9:  *
1.2       tedu       10:  * 1. Redistributions of source code must retain the above copyright
                     11:  *    notice, this list of conditions and the following disclaimer.
1.1       jfb        12:  * 2. The name of the author may not be used to endorse or promote products
1.2       tedu       13:  *    derived from this software without specific prior written permission.
1.1       jfb        14:  *
                     15:  * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
                     16:  * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
                     17:  * AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
                     18:  * THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
                     19:  * EXEMPLARY, OR CONSEQUENTIAL  DAMAGES (INCLUDING, BUT NOT LIMITED TO,
                     20:  * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
                     21:  * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
                     22:  * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
                     23:  * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
1.2       tedu       24:  * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
1.1       jfb        25:  */
                     26:
                     27: #ifndef RCS_H
                     28: #define RCS_H
                     29:
                     30: #include <sys/types.h>
                     31: #include <sys/queue.h>
                     32:
                     33: #include <time.h>
                     34:
                     35: #include "buf.h"
                     36:
                     37: #define RCS_DIFF_MAXARG   32
                     38: #define RCS_DIFF_DIV \
                     39:        "==================================================================="
                     40:
1.14      jfb        41: #define RCSDIR         "RCS"
1.1       jfb        42: #define RCS_FILE_EXT   ",v"
                     43:
1.17      jfb        44: #define RCS_HEAD_BRANCH  "HEAD"
                     45: #define RCS_HEAD_INIT    "1.1"
                     46: #define RCS_HEAD_REV     ((RCSNUM *)(-1))
1.23      jfb        47:
                     48:
                     49: #define RCS_SYM_INVALCHAR  "$,.:;@"
1.1       jfb        50:
1.12      jfb        51:
1.17      jfb        52: #define RCS_STATE_EXP    "Exp"
                     53: #define RCS_STATE_DEAD   "dead"
                     54:
1.12      jfb        55: /* lock types */
1.26      jfb        56: #define RCS_LOCK_INVAL  (-1)
1.12      jfb        57: #define RCS_LOCK_LOOSE    0
                     58: #define RCS_LOCK_STRICT   1
                     59:
                     60:
1.6       jfb        61: /* RCS keyword expansion modes (kflags) */
                     62: #define RCS_KWEXP_NONE     0x00
                     63: #define RCS_KWEXP_NAME     0x01                /* include keyword name */
                     64: #define RCS_KWEXP_VAL      0x02                /* include keyword value */
                     65: #define RCS_KWEXP_LKR      0x04                /* include name of locker */
                     66: #define RCS_KWEXP_OLD      0x08                /* generate old keyword string */
                     67: #define RCS_KWEXP_ERR      0x10                /* mode has an error */
                     68:
                     69: #define RCS_KWEXP_DEFAULT  (RCS_KWEXP_NAME | RCS_KWEXP_VAL)
                     70: #define RCS_KWEXP_KVL      (RCS_KWEXP_NAME | RCS_KWEXP_VAL | RCS_KWEXP_LKR)
                     71:
1.9       jfb        72: #define RCS_KWEXP_INVAL(k) \
1.13      jfb        73:        ((k & RCS_KWEXP_ERR) || \
                     74:        ((k & RCS_KWEXP_OLD) && (RCS_KWEXP_OLD & ~RCS_KWEXP_OLD)))
1.9       jfb        75:
1.6       jfb        76:
                     77:
                     78: #define RCSNUM_MAXNUM  USHRT_MAX
                     79: #define RCSNUM_MAXLEN  64
                     80:
1.17      jfb        81: #define RCSNUM_ISBRANCH(n)    (((n)->rn_len % 2) == 0)
                     82:
1.1       jfb        83:
                     84: /* file flags */
1.9       jfb        85: #define RCS_READ    0x01
                     86: #define RCS_WRITE   0x02
                     87: #define RCS_RDWR    (RCS_READ|RCS_WRITE)
                     88: #define RCS_CREATE  0x04                       /* create the file */
                     89:
                     90: /* internal flags */
                     91: #define RCS_PARSED  0x010000   /* file has been parsed */
                     92: #define RCS_SYNCED  0x020000   /* in-memory copy is in sync with disk copy */
                     93: #define RCS_SLOCK   0x040000   /* strict lock */
1.1       jfb        94:
                     95: /* delta flags */
                     96: #define RCS_RD_DEAD   0x01     /* dead */
1.5       jfb        97:
1.14      jfb        98: /* RCS error codes */
                     99: #define RCS_ERR_NOERR    0
                    100: #define RCS_ERR_NOENT    1
                    101: #define RCS_ERR_DUPENT   2
                    102: #define RCS_ERR_BADNUM   3
1.22      jfb       103: #define RCS_ERR_BADSYM   4
                    104: #define RCS_ERR_PARSE    5
1.24      jfb       105: #define RCS_ERR_ERRNO  255
1.5       jfb       106:
1.1       jfb       107: typedef struct rcs_num {
                    108:        u_int      rn_len;
                    109:        u_int16_t *rn_id;
                    110: } RCSNUM;
                    111:
                    112:
1.11      jfb       113: struct rcs_access {
                    114:        char    *ra_name;
                    115:        uid_t    ra_uid;
                    116:        TAILQ_ENTRY(rcs_access) ra_list;
                    117: };
                    118:
1.1       jfb       119: struct rcs_sym {
                    120:        char    *rs_name;
                    121:        RCSNUM  *rs_num;
                    122:        TAILQ_ENTRY(rcs_sym) rs_list;
                    123: };
                    124:
                    125: struct rcs_lock {
1.17      jfb       126:        char     *rl_name;
1.1       jfb       127:        RCSNUM   *rl_num;
                    128:
                    129:        TAILQ_ENTRY(rcs_lock) rl_list;
                    130: };
                    131:
                    132:
                    133: struct rcs_branch {
                    134:        RCSNUM  *rb_num;
                    135:        TAILQ_ENTRY(rcs_branch) rb_list;
                    136: };
                    137:
                    138: struct rcs_dlist {
                    139:        struct rcs_delta *tqh_first;
                    140:        struct rcs_delta **tqh_last;
                    141: };
                    142:
                    143: struct rcs_delta {
1.18      jfb       144:        RCSNUM    *rd_num;
                    145:        RCSNUM    *rd_next;
                    146:        u_int      rd_flags;
                    147:        struct tm  rd_date;
                    148:        char      *rd_author;
                    149:        char      *rd_state;
                    150:        char      *rd_log;
1.20      jfb       151:        u_char    *rd_text;
1.18      jfb       152:        size_t     rd_tlen;
1.1       jfb       153:
1.18      jfb       154:        struct rcs_dlist         rd_snodes;
1.1       jfb       155:        TAILQ_HEAD(, rcs_branch) rd_branches;
1.18      jfb       156:        TAILQ_ENTRY(rcs_delta)   rd_list;
1.1       jfb       157: };
                    158:
                    159:
                    160: typedef struct rcs_file {
                    161:        char   *rf_path;
                    162:        u_int   rf_ref;
1.9       jfb       163:        mode_t  rf_mode;
1.1       jfb       164:        u_int   rf_flags;
                    165:
                    166:        RCSNUM *rf_head;
                    167:        RCSNUM *rf_branch;
                    168:        char   *rf_comment;
                    169:        char   *rf_expand;
                    170:        char   *rf_desc;
                    171:
1.9       jfb       172:        u_int   rf_ndelta;
1.11      jfb       173:        struct rcs_dlist                  rf_delta;
                    174:        TAILQ_HEAD(rcs_alist, rcs_access) rf_access;
                    175:        TAILQ_HEAD(rcs_slist, rcs_sym)    rf_symbols;
                    176:        TAILQ_HEAD(rcs_llist, rcs_lock)   rf_locks;
1.9       jfb       177:
1.1       jfb       178:        void   *rf_pdata;
                    179: } RCSFILE;
                    180:
                    181:
1.14      jfb       182: extern int rcs_errno;
                    183:
                    184:
1.16      jfb       185: RCSFILE*      rcs_open          (const char *, int, ...);
                    186: void          rcs_close         (RCSFILE *);
1.19      jfb       187: const RCSNUM* rcs_head_get      (RCSFILE *);
                    188: int           rcs_head_set      (RCSFILE *, const RCSNUM *);
1.16      jfb       189: const RCSNUM* rcs_branch_get    (RCSFILE *);
                    190: int           rcs_branch_set    (RCSFILE *, const RCSNUM *);
                    191: int           rcs_access_add    (RCSFILE *, const char *);
                    192: int           rcs_access_remove (RCSFILE *, const char *);
                    193: int           rcs_access_check  (RCSFILE *, const char *);
                    194: int           rcs_sym_add       (RCSFILE *, const char *, RCSNUM *);
                    195: int           rcs_sym_remove    (RCSFILE *, const char *);
                    196: RCSNUM*       rcs_sym_getrev    (RCSFILE *, const char *);
1.22      jfb       197: int           rcs_sym_check     (const char *);
1.16      jfb       198: int           rcs_lock_getmode  (RCSFILE *);
                    199: int           rcs_lock_setmode  (RCSFILE *, int);
1.17      jfb       200: int           rcs_lock_add      (RCSFILE *, const char *, RCSNUM *);
                    201: int           rcs_lock_remove   (RCSFILE *, const RCSNUM *);
1.16      jfb       202: BUF*          rcs_getrev        (RCSFILE *, RCSNUM *);
                    203: const char*   rcs_desc_get      (RCSFILE *);
                    204: int           rcs_desc_set      (RCSFILE *, const char *);
1.25      jfb       205: const char*   rcs_comment_lookup(const char *);
1.16      jfb       206: const char*   rcs_comment_get   (RCSFILE *);
                    207: int           rcs_comment_set   (RCSFILE *, const char *);
                    208: int           rcs_kwexp_set     (RCSFILE *, int);
                    209: int           rcs_kwexp_get     (RCSFILE *);
1.27      jfb       210: int           rcs_rev_add       (RCSFILE *, RCSNUM *, const char *, time_t);
1.24      jfb       211: int           rcs_rev_remove    (RCSFILE *, RCSNUM *);
1.17      jfb       212: RCSNUM*       rcs_tag_resolve   (RCSFILE *, const char *);
1.16      jfb       213: const char*   rcs_errstr        (int);
1.24      jfb       214:
1.6       jfb       215:
                    216: int       rcs_kflag_get    (const char *);
1.7       jfb       217: void      rcs_kflag_usage  (void);
1.9       jfb       218: int       rcs_kw_expand    (RCSFILE *, u_char *, size_t, size_t *);
1.1       jfb       219:
                    220: BUF*      rcs_patch     (const char *, const char *);
                    221:
                    222: RCSNUM*   rcsnum_alloc  (void);
1.8       jfb       223: RCSNUM*   rcsnum_parse  (const char *);
1.1       jfb       224: void      rcsnum_free   (RCSNUM *);
                    225: int       rcsnum_aton   (const char *, char **, RCSNUM *);
                    226: char*     rcsnum_tostr  (const RCSNUM *, char *, size_t);
                    227: int       rcsnum_cpy    (const RCSNUM *, RCSNUM *, u_int);
                    228: int       rcsnum_cmp    (const RCSNUM *, const RCSNUM *, u_int);
                    229:
                    230: #endif /* RCS_H */