[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.43

1.43    ! niallo      1: /*     $OpenBSD: rcs.h,v 1.42 2005/12/08 18:56:10 joris 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:
1.30      xsa        37: #define RCS_DIFF_MAXARG                32
1.1       jfb        38: #define RCS_DIFF_DIV \
                     39:        "==================================================================="
                     40:
1.30      xsa        41: #define RCSDIR                 "RCS"
                     42: #define RCS_FILE_EXT           ",v"
1.1       jfb        43:
1.30      xsa        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:
1.30      xsa        49: #define RCS_SYM_INVALCHAR      "$,.:;@"
1.1       jfb        50:
1.12      jfb        51:
1.31      joris      52: #define RCS_MAGIC_BRANCH       ".0."
1.30      xsa        53: #define RCS_STATE_EXP          "Exp"
                     54: #define RCS_STATE_DEAD         "dead"
1.17      jfb        55:
1.12      jfb        56: /* lock types */
1.30      xsa        57: #define RCS_LOCK_INVAL         (-1)
                     58: #define RCS_LOCK_LOOSE         0
                     59: #define RCS_LOCK_STRICT                1
1.12      jfb        60:
                     61:
1.6       jfb        62: /* RCS keyword expansion modes (kflags) */
1.30      xsa        63: #define RCS_KWEXP_NONE 0x00
                     64: #define RCS_KWEXP_NAME 0x01    /* include keyword name */
                     65: #define RCS_KWEXP_VAL  0x02    /* include keyword value */
                     66: #define RCS_KWEXP_LKR  0x04    /* include name of locker */
                     67: #define RCS_KWEXP_OLD  0x08    /* generate old keyword string */
                     68: #define RCS_KWEXP_ERR  0x10    /* mode has an error */
1.6       jfb        69:
1.30      xsa        70: #define RCS_KWEXP_DEFAULT      (RCS_KWEXP_NAME | RCS_KWEXP_VAL)
                     71: #define RCS_KWEXP_KVL          (RCS_KWEXP_NAME | RCS_KWEXP_VAL | RCS_KWEXP_LKR)
1.6       jfb        72:
1.9       jfb        73: #define RCS_KWEXP_INVAL(k) \
1.13      jfb        74:        ((k & RCS_KWEXP_ERR) || \
                     75:        ((k & RCS_KWEXP_OLD) && (RCS_KWEXP_OLD & ~RCS_KWEXP_OLD)))
1.9       jfb        76:
1.6       jfb        77:
                     78:
1.30      xsa        79: #define RCSNUM_MAXNUM  USHRT_MAX
                     80: #define RCSNUM_MAXLEN  64
1.6       jfb        81:
1.30      xsa        82: #define RCSNUM_ISBRANCH(n)     ((n)->rn_len % 2)
1.17      jfb        83:
1.1       jfb        84:
                     85: /* file flags */
1.43    ! niallo     86: #define RCS_READ         (1<<0)
        !            87: #define RCS_WRITE        (1<<1)
        !            88: #define RCS_RDWR         (RCS_READ|RCS_WRITE)
        !            89: #define RCS_CREATE       (1<<2)  /* create the file */
        !            90: #define RCS_PARSE_FULLY   (1<<3)  /* fully parse it on open */
1.9       jfb        91:
                     92: /* internal flags */
1.43    ! niallo     93: #define RCS_PARSED       (1<<4)  /* file has been parsed */
        !            94: #define RCS_SYNCED       (1<<5)  /* in-mem copy is sync with disk copy */
        !            95: #define RCS_SLOCK        (1<<6)  /* strict lock */
        !            96:
        !            97: /* parser flags */
        !            98: #define PARSED_DELTAS     (1<<7)  /* all deltas are parsed */
        !            99: #define PARSED_DESC       (1<<8)  /* the description is parsed */
        !           100: #define PARSED_DELTATEXTS (1<<9)  /* all delta texts are parsed */
1.1       jfb       101:
                    102: /* delta flags */
1.30      xsa       103: #define RCS_RD_DEAD    0x01    /* dead */
1.5       jfb       104:
1.14      jfb       105: /* RCS error codes */
1.30      xsa       106: #define RCS_ERR_NOERR  0
                    107: #define RCS_ERR_NOENT  1
                    108: #define RCS_ERR_DUPENT 2
                    109: #define RCS_ERR_BADNUM 3
                    110: #define RCS_ERR_BADSYM 4
                    111: #define RCS_ERR_PARSE  5
                    112: #define RCS_ERR_ERRNO  255
1.40      joris     113:
                    114: /* used for cvs_checkout_rev */
                    115: #define CHECKOUT_REV_CREATED   1
                    116: #define CHECKOUT_REV_MERGED    2
                    117: #define CHECKOUT_REV_REMOVED   3
1.41      joris     118: #define CHECKOUT_REV_UPDATED   4
1.5       jfb       119:
1.1       jfb       120: typedef struct rcs_num {
1.30      xsa       121:        u_int            rn_len;
                    122:        u_int16_t       *rn_id;
1.1       jfb       123: } RCSNUM;
                    124:
                    125:
1.11      jfb       126: struct rcs_access {
1.30      xsa       127:        char                    *ra_name;
                    128:        uid_t                    ra_uid;
                    129:        TAILQ_ENTRY(rcs_access)  ra_list;
1.11      jfb       130: };
                    131:
1.1       jfb       132: struct rcs_sym {
1.30      xsa       133:        char                    *rs_name;
                    134:        RCSNUM                  *rs_num;
                    135:        TAILQ_ENTRY(rcs_sym)     rs_list;
1.1       jfb       136: };
                    137:
                    138: struct rcs_lock {
1.30      xsa       139:        char    *rl_name;
                    140:        RCSNUM  *rl_num;
1.1       jfb       141:
1.30      xsa       142:        TAILQ_ENTRY(rcs_lock)   rl_list;
1.1       jfb       143: };
                    144:
                    145:
                    146: struct rcs_branch {
1.30      xsa       147:        RCSNUM                  *rb_num;
                    148:        TAILQ_ENTRY(rcs_branch) rb_list;
1.1       jfb       149: };
                    150:
                    151: struct rcs_dlist {
1.30      xsa       152:        struct rcs_delta        *tqh_first;
                    153:        struct rcs_delta        **tqh_last;
1.1       jfb       154: };
                    155:
                    156: struct rcs_delta {
1.30      xsa       157:        RCSNUM          *rd_num;
                    158:        RCSNUM          *rd_next;
                    159:        u_int            rd_flags;
                    160:        struct tm        rd_date;
                    161:        char            *rd_author;
                    162:        char            *rd_state;
                    163:        char            *rd_log;
1.42      joris     164:        char            *rd_locker;
1.30      xsa       165:        u_char          *rd_text;
                    166:        size_t           rd_tlen;
                    167:
                    168:        struct rcs_dlist                rd_snodes;
                    169:        TAILQ_HEAD(, rcs_branch)        rd_branches;
                    170:        TAILQ_ENTRY(rcs_delta)          rd_list;
1.1       jfb       171: };
                    172:
                    173:
                    174: typedef struct rcs_file {
1.30      xsa       175:        char    *rf_path;
                    176:        u_int    rf_ref;
                    177:        mode_t   rf_mode;
                    178:        u_int    rf_flags;
                    179:
                    180:        RCSNUM  *rf_head;
                    181:        RCSNUM  *rf_branch;
                    182:        char    *rf_comment;
                    183:        char    *rf_expand;
                    184:        char    *rf_desc;
                    185:
                    186:        u_int                                   rf_ndelta;
                    187:        struct rcs_dlist                        rf_delta;
                    188:        TAILQ_HEAD(rcs_alist, rcs_access)       rf_access;
                    189:        TAILQ_HEAD(rcs_slist, rcs_sym)          rf_symbols;
                    190:        TAILQ_HEAD(rcs_llist, rcs_lock)         rf_locks;
1.9       jfb       191:
1.30      xsa       192:        void    *rf_pdata;
1.1       jfb       193: } RCSFILE;
                    194:
                    195:
1.14      jfb       196: extern int rcs_errno;
                    197:
                    198:
1.39      xsa       199: RCSFILE                        *rcs_open(const char *, int, ...);
                    200: void                    rcs_close(RCSFILE *);
                    201: const RCSNUM           *rcs_head_get(RCSFILE *);
1.43    ! niallo    202: int                     rcs_head_set(RCSFILE *, RCSNUM *);
1.39      xsa       203: const RCSNUM           *rcs_branch_get(RCSFILE *);
                    204: int                     rcs_branch_set(RCSFILE *, const RCSNUM *);
                    205: int                     rcs_access_add(RCSFILE *, const char *);
                    206: int                     rcs_access_remove(RCSFILE *, const char *);
                    207: int                     rcs_access_check(RCSFILE *, const char *);
1.43    ! niallo    208: struct rcs_delta       *rcs_findrev(RCSFILE *, RCSNUM *);
1.39      xsa       209: int                     rcs_sym_add(RCSFILE *, const char *, RCSNUM *);
                    210: int                     rcs_sym_remove(RCSFILE *, const char *);
                    211: RCSNUM                 *rcs_sym_getrev(RCSFILE *, const char *);
                    212: int                     rcs_sym_check(const char *);
                    213: int                     rcs_lock_getmode(RCSFILE *);
                    214: int                     rcs_lock_setmode(RCSFILE *, int);
                    215: int                     rcs_lock_add(RCSFILE *, const char *, RCSNUM *);
1.42      joris     216: int                     rcs_lock_remove(RCSFILE *, const char *, RCSNUM *);
1.39      xsa       217: BUF                    *rcs_getrev(RCSFILE *, RCSNUM *);
                    218: int                     rcs_deltatext_set(RCSFILE *, RCSNUM *, const char *);
                    219: const char             *rcs_desc_get(RCSFILE *);
                    220: int                     rcs_desc_set(RCSFILE *, const char *);
                    221: const char             *rcs_comment_lookup(const char *);
                    222: const char             *rcs_comment_get(RCSFILE *);
                    223: int                     rcs_comment_set(RCSFILE *, const char *);
                    224: int                     rcs_kwexp_set(RCSFILE *, int);
                    225: int                     rcs_kwexp_get(RCSFILE *);
                    226: int                     rcs_rev_add(RCSFILE *, RCSNUM *, const char *, time_t,
                    227:                             const char *);
                    228: time_t                  rcs_rev_getdate(RCSFILE *, RCSNUM *);
                    229: int                     rcs_rev_setlog(RCSFILE *, RCSNUM *, const char *);
                    230: int                     rcs_rev_remove(RCSFILE *, RCSNUM *);
                    231: int                     rcs_state_set(RCSFILE *, RCSNUM *, const char *);
                    232: const char             *rcs_state_get(RCSFILE *, RCSNUM *);
                    233: int                     rcs_state_check(const char *);
                    234: RCSNUM                 *rcs_tag_resolve(RCSFILE *, const char *);
                    235: const char             *rcs_errstr(int);
1.30      xsa       236:
                    237:
                    238: int    rcs_kflag_get(const char *);
                    239: void   rcs_kflag_usage(void);
                    240: int    rcs_kw_expand(RCSFILE *, u_char *, size_t, size_t *);
                    241:
                    242: RCSNUM *rcsnum_alloc(void);
                    243: RCSNUM *rcsnum_parse(const char *);
                    244: RCSNUM *rcsnum_brtorev(const RCSNUM *);
                    245: RCSNUM *rcsnum_revtobr(const RCSNUM *);
                    246: RCSNUM *rcsnum_inc(RCSNUM *);
1.33      joris     247: RCSNUM *rcsnum_dec(RCSNUM *);
1.30      xsa       248: void    rcsnum_free(RCSNUM *);
                    249: int     rcsnum_aton(const char *, char **, RCSNUM *);
                    250: char   *rcsnum_tostr(const RCSNUM *, char *, size_t);
                    251: int     rcsnum_cpy(const RCSNUM *, RCSNUM *, u_int);
                    252: int     rcsnum_cmp(const RCSNUM *, const RCSNUM *, u_int);
1.1       jfb       253:
1.30      xsa       254: #endif /* RCS_H */