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

1.96    ! tobias      1: /*     $OpenBSD: rcs.h,v 1.95 2010/08/31 20:42:45 tobias 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: #include "buf.h"
                     30:
                     31: #define RCS_DIFF_DIV \
                     32:        "==================================================================="
                     33:
1.30      xsa        34: #define RCS_FILE_EXT           ",v"
1.1       jfb        35:
1.30      xsa        36: #define RCS_HEAD_BRANCH                "HEAD"
                     37: #define RCS_HEAD_INIT          "1.1"
                     38: #define RCS_HEAD_REV           ((RCSNUM *)(-1))
1.23      jfb        39:
1.63      joris      40: #define RCS_CONFLICT_MARKER1   "<<<<<<< "
                     41: #define RCS_CONFLICT_MARKER2   ">>>>>>> "
                     42: #define RCS_CONFLICT_MARKER3   "=======\n"
1.23      jfb        43:
1.30      xsa        44: #define RCS_SYM_INVALCHAR      "$,.:;@"
1.1       jfb        45:
1.31      joris      46: #define RCS_MAGIC_BRANCH       ".0."
1.30      xsa        47: #define RCS_STATE_EXP          "Exp"
                     48: #define RCS_STATE_DEAD         "dead"
1.17      jfb        49:
1.12      jfb        50: /* lock types */
1.30      xsa        51: #define RCS_LOCK_INVAL         (-1)
                     52: #define RCS_LOCK_LOOSE         0
                     53: #define RCS_LOCK_STRICT                1
1.12      jfb        54:
1.46      niallo     55: /*
                     56:  * Keyword expansion table
                     57:  */
                     58: #define RCS_KW_AUTHOR          0x1000
                     59: #define RCS_KW_DATE            0x2000
                     60: #define RCS_KW_LOG             0x4000
                     61: #define RCS_KW_NAME            0x8000
                     62: #define RCS_KW_RCSFILE         0x0100
                     63: #define RCS_KW_REVISION                0x0200
                     64: #define RCS_KW_SOURCE          0x0400
                     65: #define RCS_KW_STATE           0x0800
                     66: #define RCS_KW_FULLPATH                0x0010
1.76      niallo     67: #define RCS_KW_MDOCDATE                0x0020
1.81      tobias     68: #define RCS_KW_LOCKER          0x0040
1.46      niallo     69:
                     70: #define RCS_KW_ID \
                     71:        (RCS_KW_RCSFILE | RCS_KW_REVISION | RCS_KW_DATE \
                     72:        | RCS_KW_AUTHOR | RCS_KW_STATE)
                     73:
                     74: #define RCS_KW_HEADER  (RCS_KW_ID | RCS_KW_FULLPATH)
                     75:
1.6       jfb        76: /* RCS keyword expansion modes (kflags) */
1.83      tobias     77: #define RCS_KWEXP_NONE 0x01    /* do not expand keywords */
                     78: #define RCS_KWEXP_NAME 0x02    /* include keyword name */
                     79: #define RCS_KWEXP_VAL  0x04    /* include keyword value */
                     80: #define RCS_KWEXP_LKR  0x08    /* include name of locker */
                     81: #define RCS_KWEXP_OLD  0x10    /* generate old keyword string */
                     82: #define RCS_KWEXP_ERR  0x20    /* mode has an error */
1.6       jfb        83:
1.30      xsa        84: #define RCS_KWEXP_DEFAULT      (RCS_KWEXP_NAME | RCS_KWEXP_VAL)
                     85: #define RCS_KWEXP_KVL          (RCS_KWEXP_NAME | RCS_KWEXP_VAL | RCS_KWEXP_LKR)
1.6       jfb        86:
1.9       jfb        87: #define RCS_KWEXP_INVAL(k) \
1.13      jfb        88:        ((k & RCS_KWEXP_ERR) || \
1.51      ray        89:        ((k & RCS_KWEXP_OLD) && (k & ~RCS_KWEXP_OLD)))
1.9       jfb        90:
1.46      niallo     91: struct rcs_kw {
                     92:        char    kw_str[16];
                     93:        int     kw_type;
                     94: };
                     95:
                     96: #define RCS_NKWORDS    (sizeof(rcs_expkw)/sizeof(rcs_expkw[0]))
1.6       jfb        97:
1.30      xsa        98: #define RCSNUM_MAXNUM  USHRT_MAX
                     99: #define RCSNUM_MAXLEN  64
1.6       jfb       100:
1.30      xsa       101: #define RCSNUM_ISBRANCH(n)     ((n)->rn_len % 2)
1.57      joris     102: #define RCSNUM_ISBRANCHREV(n)  (!((n)->rn_len % 2) && ((n)->rn_len >= 4))
1.1       jfb       103:
                    104: /* file flags */
1.43      niallo    105: #define RCS_READ         (1<<0)
                    106: #define RCS_WRITE        (1<<1)
                    107: #define RCS_CREATE       (1<<2)  /* create the file */
                    108: #define RCS_PARSE_FULLY   (1<<3)  /* fully parse it on open */
1.9       jfb       109:
                    110: /* internal flags */
1.43      niallo    111: #define RCS_PARSED       (1<<4)  /* file has been parsed */
                    112: #define RCS_SYNCED       (1<<5)  /* in-mem copy is sync with disk copy */
                    113: #define RCS_SLOCK        (1<<6)  /* strict lock */
                    114:
                    115: /* parser flags */
                    116: #define PARSED_DELTAS     (1<<7)  /* all deltas are parsed */
                    117: #define PARSED_DESC       (1<<8)  /* the description is parsed */
                    118: #define PARSED_DELTATEXTS (1<<9)  /* all delta texts are parsed */
1.1       jfb       119:
                    120: /* delta flags */
1.30      xsa       121: #define RCS_RD_DEAD    0x01    /* dead */
1.56      ray       122: #define RCS_RD_SELECT  0x02    /* select for operation */
1.40      joris     123:
1.1       jfb       124: typedef struct rcs_num {
1.30      xsa       125:        u_int            rn_len;
                    126:        u_int16_t       *rn_id;
1.1       jfb       127: } RCSNUM;
                    128:
1.11      jfb       129: struct rcs_access {
1.30      xsa       130:        char                    *ra_name;
                    131:        TAILQ_ENTRY(rcs_access)  ra_list;
1.11      jfb       132: };
                    133:
1.1       jfb       134: struct rcs_sym {
1.30      xsa       135:        char                    *rs_name;
                    136:        RCSNUM                  *rs_num;
                    137:        TAILQ_ENTRY(rcs_sym)     rs_list;
1.1       jfb       138: };
                    139:
                    140: struct rcs_lock {
1.30      xsa       141:        char    *rl_name;
                    142:        RCSNUM  *rl_num;
1.1       jfb       143:
1.94      ray       144:        TAILQ_ENTRY(rcs_lock)    rl_list;
1.1       jfb       145: };
                    146:
                    147: struct rcs_branch {
1.30      xsa       148:        RCSNUM                  *rb_num;
1.94      ray       149:        TAILQ_ENTRY(rcs_branch)  rb_list;
1.1       jfb       150: };
                    151:
1.50      ray       152: TAILQ_HEAD(rcs_dlist, rcs_delta);
1.1       jfb       153:
                    154: struct rcs_delta {
1.30      xsa       155:        RCSNUM          *rd_num;
                    156:        RCSNUM          *rd_next;
1.75      otto      157:        int              rd_flags;
1.30      xsa       158:        struct tm        rd_date;
                    159:        char            *rd_author;
                    160:        char            *rd_state;
                    161:        char            *rd_log;
1.42      joris     162:        char            *rd_locker;
1.30      xsa       163:        u_char          *rd_text;
                    164:        size_t           rd_tlen;
                    165:
                    166:        TAILQ_HEAD(, rcs_branch)        rd_branches;
                    167:        TAILQ_ENTRY(rcs_delta)          rd_list;
1.1       jfb       168: };
                    169:
                    170:
                    171: typedef struct rcs_file {
1.96    ! tobias    172:        int      rf_fd;
1.64      joris     173:        int      rf_dead;
1.30      xsa       174:        char    *rf_path;
                    175:        mode_t   rf_mode;
1.75      otto      176:        int      rf_flags;
1.30      xsa       177:
                    178:        RCSNUM  *rf_head;
                    179:        RCSNUM  *rf_branch;
                    180:        char    *rf_comment;
                    181:        char    *rf_expand;
                    182:        char    *rf_desc;
                    183:
                    184:        u_int                                   rf_ndelta;
                    185:        struct rcs_dlist                        rf_delta;
                    186:        TAILQ_HEAD(rcs_alist, rcs_access)       rf_access;
                    187:        TAILQ_HEAD(rcs_slist, rcs_sym)          rf_symbols;
                    188:        TAILQ_HEAD(rcs_llist, rcs_lock)         rf_locks;
1.9       jfb       189:
1.30      xsa       190:        void    *rf_pdata;
1.1       jfb       191: } RCSFILE;
                    192:
1.94      ray       193: struct rcs_line;
                    194: struct rcs_lines;
1.14      jfb       195:
1.62      joris     196: RCSFILE                        *rcs_open(const char *, int, int, ...);
1.39      xsa       197: void                    rcs_close(RCSFILE *);
1.68      joris     198: RCSNUM                 *rcs_head_get(RCSFILE *);
1.43      niallo    199: int                     rcs_head_set(RCSFILE *, RCSNUM *);
1.92      tobias    200: RCSNUM                 *rcs_branch_new(RCSFILE *, RCSNUM *);
1.39      xsa       201: const RCSNUM           *rcs_branch_get(RCSFILE *);
                    202: int                     rcs_branch_set(RCSFILE *, const RCSNUM *);
                    203: int                     rcs_access_add(RCSFILE *, const char *);
                    204: int                     rcs_access_remove(RCSFILE *, const char *);
                    205: int                     rcs_access_check(RCSFILE *, const char *);
1.43      niallo    206: struct rcs_delta       *rcs_findrev(RCSFILE *, RCSNUM *);
1.39      xsa       207: int                     rcs_sym_add(RCSFILE *, const char *, RCSNUM *);
1.69      xsa       208: int                     rcs_sym_check(const char *);
                    209: struct rcs_sym         *rcs_sym_get(RCSFILE *, const char *);
1.39      xsa       210: int                     rcs_sym_remove(RCSFILE *, const char *);
                    211: RCSNUM                 *rcs_sym_getrev(RCSFILE *, const char *);
1.65      joris     212: RCSNUM                 *rcs_translate_tag(const char *, RCSFILE *);
1.39      xsa       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.70      joris     217: int                     rcs_deltatext_set(RCSFILE *, RCSNUM *, BUF *);
1.39      xsa       218: const char             *rcs_desc_get(RCSFILE *);
1.52      xsa       219: void                    rcs_desc_set(RCSFILE *, const char *);
1.39      xsa       220: const char             *rcs_comment_lookup(const char *);
                    221: const char             *rcs_comment_get(RCSFILE *);
1.53      xsa       222: void                    rcs_comment_set(RCSFILE *, const char *);
1.47      niallo    223: BUF                    *rcs_kwexp_buf(BUF *, RCSFILE *, RCSNUM *);
1.58      xsa       224: void                    rcs_kwexp_set(RCSFILE *, int);
1.39      xsa       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 *);
1.62      joris     235: void                    rcs_write(RCSFILE *);
1.88      joris     236: int                     rcs_rev_write_stmp(RCSFILE *,  RCSNUM *, char *, int);
1.72      joris     237: void                    rcs_rev_write_fd(RCSFILE *, RCSNUM *, int, int);
1.94      ray       238: struct rcs_lines       *rcs_rev_getlines(RCSFILE *, RCSNUM *,
                    239:                             struct rcs_line ***);
1.80      tobias    240: void                    rcs_annotate_getlines(RCSFILE *, RCSNUM *,
1.94      ray       241:                             struct rcs_line ***);
1.73      joris     242: BUF                    *rcs_rev_getbuf(RCSFILE *, RCSNUM *, int);
1.85      joris     243: void                    rcs_delta_stats(struct rcs_delta *, int *, int *);
1.30      xsa       244:
                    245: int    rcs_kflag_get(const char *);
                    246: void   rcs_kflag_usage(void);
                    247: int    rcs_kw_expand(RCSFILE *, u_char *, size_t, size_t *);
                    248:
                    249: RCSNUM *rcsnum_alloc(void);
                    250: RCSNUM *rcsnum_parse(const char *);
                    251: RCSNUM *rcsnum_brtorev(const RCSNUM *);
                    252: RCSNUM *rcsnum_revtobr(const RCSNUM *);
                    253: RCSNUM *rcsnum_inc(RCSNUM *);
1.33      joris     254: RCSNUM *rcsnum_dec(RCSNUM *);
1.79      joris     255: RCSNUM *rcsnum_branch_root(RCSNUM *);
1.82      tobias    256: RCSNUM *rcsnum_new_branch(RCSNUM *);
1.30      xsa       257: void    rcsnum_free(RCSNUM *);
1.86      tobias    258: int     rcsnum_addmagic(RCSNUM *);
1.30      xsa       259: int     rcsnum_aton(const char *, char **, RCSNUM *);
                    260: char   *rcsnum_tostr(const RCSNUM *, char *, size_t);
1.55      ray       261: void    rcsnum_cpy(const RCSNUM *, RCSNUM *, u_int);
1.67      joris     262: int     rcsnum_cmp(RCSNUM *, RCSNUM *, u_int);
                    263: int     rcsnum_differ(RCSNUM *, RCSNUM *);
1.1       jfb       264:
1.30      xsa       265: #endif /* RCS_H */