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

1.30    ! xsa         1: /*     $OpenBSD: rcs.h,v 1.29 2005/05/26 01:45:54 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:
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.30    ! xsa        52: #define RCS_STATE_EXP          "Exp"
        !            53: #define RCS_STATE_DEAD         "dead"
1.17      jfb        54:
1.12      jfb        55: /* lock types */
1.30    ! xsa        56: #define RCS_LOCK_INVAL         (-1)
        !            57: #define RCS_LOCK_LOOSE         0
        !            58: #define RCS_LOCK_STRICT                1
1.12      jfb        59:
                     60:
1.6       jfb        61: /* RCS keyword expansion modes (kflags) */
1.30    ! xsa        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 */
1.6       jfb        68:
1.30    ! xsa        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)
1.6       jfb        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:
1.30    ! xsa        78: #define RCSNUM_MAXNUM  USHRT_MAX
        !            79: #define RCSNUM_MAXLEN  64
1.6       jfb        80:
1.30    ! xsa        81: #define RCSNUM_ISBRANCH(n)     ((n)->rn_len % 2)
1.17      jfb        82:
1.1       jfb        83:
                     84: /* file flags */
1.30    ! xsa        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 */
1.9       jfb        89:
                     90: /* internal flags */
1.30    ! xsa        91: #define RCS_PARSED     0x010000        /* file has been parsed */
        !            92: #define RCS_SYNCED     0x020000        /* in-mem copy is sync with disk copy */
        !            93: #define RCS_SLOCK      0x040000        /* strict lock */
1.1       jfb        94:
                     95: /* delta flags */
1.30    ! xsa        96: #define RCS_RD_DEAD    0x01    /* dead */
1.5       jfb        97:
1.14      jfb        98: /* RCS error codes */
1.30    ! xsa        99: #define RCS_ERR_NOERR  0
        !           100: #define RCS_ERR_NOENT  1
        !           101: #define RCS_ERR_DUPENT 2
        !           102: #define RCS_ERR_BADNUM 3
        !           103: #define RCS_ERR_BADSYM 4
        !           104: #define RCS_ERR_PARSE  5
        !           105: #define RCS_ERR_ERRNO  255
1.5       jfb       106:
1.1       jfb       107: typedef struct rcs_num {
1.30    ! xsa       108:        u_int            rn_len;
        !           109:        u_int16_t       *rn_id;
1.1       jfb       110: } RCSNUM;
                    111:
                    112:
1.11      jfb       113: struct rcs_access {
1.30    ! xsa       114:        char                    *ra_name;
        !           115:        uid_t                    ra_uid;
        !           116:        TAILQ_ENTRY(rcs_access)  ra_list;
1.11      jfb       117: };
                    118:
1.1       jfb       119: struct rcs_sym {
1.30    ! xsa       120:        char                    *rs_name;
        !           121:        RCSNUM                  *rs_num;
        !           122:        TAILQ_ENTRY(rcs_sym)     rs_list;
1.1       jfb       123: };
                    124:
                    125: struct rcs_lock {
1.30    ! xsa       126:        char    *rl_name;
        !           127:        RCSNUM  *rl_num;
1.1       jfb       128:
1.30    ! xsa       129:        TAILQ_ENTRY(rcs_lock)   rl_list;
1.1       jfb       130: };
                    131:
                    132:
                    133: struct rcs_branch {
1.30    ! xsa       134:        RCSNUM                  *rb_num;
        !           135:        TAILQ_ENTRY(rcs_branch) rb_list;
1.1       jfb       136: };
                    137:
                    138: struct rcs_dlist {
1.30    ! xsa       139:        struct rcs_delta        *tqh_first;
        !           140:        struct rcs_delta        **tqh_last;
1.1       jfb       141: };
                    142:
                    143: struct rcs_delta {
1.30    ! xsa       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;
        !           151:        u_char          *rd_text;
        !           152:        size_t           rd_tlen;
        !           153:
        !           154:        struct rcs_dlist                rd_snodes;
        !           155:        TAILQ_HEAD(, rcs_branch)        rd_branches;
        !           156:        TAILQ_ENTRY(rcs_delta)          rd_list;
1.1       jfb       157: };
                    158:
                    159:
                    160: typedef struct rcs_file {
1.30    ! xsa       161:        char    *rf_path;
        !           162:        u_int    rf_ref;
        !           163:        mode_t   rf_mode;
        !           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:
        !           172:        u_int                                   rf_ndelta;
        !           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.30    ! xsa       178:        void    *rf_pdata;
1.1       jfb       179: } RCSFILE;
                    180:
                    181:
1.14      jfb       182: extern int rcs_errno;
                    183:
                    184:
1.30    ! xsa       185: RCSFILE                *rcs_open(const char *, int, ...);
        !           186: void            rcs_close(RCSFILE *);
        !           187: const RCSNUM   *rcs_head_get(RCSFILE *);
        !           188: int             rcs_head_set(RCSFILE *, const RCSNUM *);
        !           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 *);
        !           197: int             rcs_sym_check(const char *);
        !           198: int             rcs_lock_getmode(RCSFILE *);
        !           199: int             rcs_lock_setmode(RCSFILE *, int);
        !           200: int             rcs_lock_add(RCSFILE *, const char *, RCSNUM *);
        !           201: int             rcs_lock_remove(RCSFILE *, const RCSNUM *);
        !           202: BUF            *rcs_getrev(RCSFILE *, RCSNUM *);
        !           203: const char     *rcs_desc_get(RCSFILE *);
        !           204: int             rcs_desc_set(RCSFILE *, const char *);
        !           205: const char     *rcs_comment_lookup(const char *);
        !           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 *);
        !           210: int             rcs_rev_add(RCSFILE *, RCSNUM *, const char *, time_t);
        !           211: int            rcs_rev_remove(RCSFILE *, RCSNUM *);
        !           212: RCSNUM         *rcs_tag_resolve(RCSFILE *, const char *);
        !           213: const char     *rcs_errstr(int);
        !           214:
        !           215:
        !           216: int    rcs_kflag_get(const char *);
        !           217: void   rcs_kflag_usage(void);
        !           218: int    rcs_kw_expand(RCSFILE *, u_char *, size_t, size_t *);
        !           219:
        !           220: BUF    *rcs_patch(const char *, const char *);
        !           221:
        !           222: RCSNUM *rcsnum_alloc(void);
        !           223: RCSNUM *rcsnum_parse(const char *);
        !           224: RCSNUM *rcsnum_brtorev(const RCSNUM *);
        !           225: RCSNUM *rcsnum_revtobr(const RCSNUM *);
        !           226: RCSNUM *rcsnum_inc(RCSNUM *);
        !           227: void    rcsnum_free(RCSNUM *);
        !           228: int     rcsnum_aton(const char *, char **, RCSNUM *);
        !           229: char   *rcsnum_tostr(const RCSNUM *, char *, size_t);
        !           230: int     rcsnum_cpy(const RCSNUM *, RCSNUM *, u_int);
        !           231: int     rcsnum_cmp(const RCSNUM *, const RCSNUM *, u_int);
1.1       jfb       232:
1.30    ! xsa       233: #endif /* RCS_H */