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

1.12    ! jfb         1: /*     $OpenBSD: rcs.h,v 1.11 2005/03/04 18:21:00 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:
                     41: #define RCS_FILE_EXT   ",v"
                     42:
                     43: #define RCS_HEAD_INIT  "1.1"
                     44:
1.12    ! jfb        45:
        !            46: /* lock types */
        !            47: #define RCS_LOCK_LOOSE    0
        !            48: #define RCS_LOCK_STRICT   1
        !            49:
        !            50:
1.6       jfb        51: /* RCS keyword expansion modes (kflags) */
                     52: #define RCS_KWEXP_NONE     0x00
                     53: #define RCS_KWEXP_NAME     0x01                /* include keyword name */
                     54: #define RCS_KWEXP_VAL      0x02                /* include keyword value */
                     55: #define RCS_KWEXP_LKR      0x04                /* include name of locker */
                     56: #define RCS_KWEXP_OLD      0x08                /* generate old keyword string */
                     57: #define RCS_KWEXP_ERR      0x10                /* mode has an error */
                     58:
                     59: #define RCS_KWEXP_DEFAULT  (RCS_KWEXP_NAME | RCS_KWEXP_VAL)
                     60: #define RCS_KWEXP_KVL      (RCS_KWEXP_NAME | RCS_KWEXP_VAL | RCS_KWEXP_LKR)
                     61:
1.9       jfb        62: #define RCS_KWEXP_INVAL(k) \
                     63:        ((k & RCS_KWEXP_ERR) || ((k & RCS_KWEXP_OLD) != RCS_KWEXP_OLD))
                     64:
1.6       jfb        65:
                     66:
                     67: #define RCSNUM_MAXNUM  USHRT_MAX
                     68: #define RCSNUM_MAXLEN  64
                     69:
1.1       jfb        70:
                     71: /* file flags */
1.9       jfb        72: #define RCS_READ    0x01
                     73: #define RCS_WRITE   0x02
                     74: #define RCS_RDWR    (RCS_READ|RCS_WRITE)
                     75: #define RCS_CREATE  0x04                       /* create the file */
                     76:
                     77: /* internal flags */
                     78: #define RCS_PARSED  0x010000   /* file has been parsed */
                     79: #define RCS_SYNCED  0x020000   /* in-memory copy is in sync with disk copy */
                     80: #define RCS_SLOCK   0x040000   /* strict lock */
1.1       jfb        81:
                     82: /* delta flags */
                     83: #define RCS_RD_DEAD   0x01     /* dead */
1.5       jfb        84:
                     85:
1.1       jfb        86: typedef struct rcs_num {
                     87:        u_int      rn_len;
                     88:        u_int16_t *rn_id;
                     89: } RCSNUM;
                     90:
                     91:
1.11      jfb        92: struct rcs_access {
                     93:        char    *ra_name;
                     94:        uid_t    ra_uid;
                     95:        TAILQ_ENTRY(rcs_access) ra_list;
                     96: };
                     97:
1.1       jfb        98: struct rcs_sym {
                     99:        char    *rs_name;
                    100:        RCSNUM  *rs_num;
                    101:        TAILQ_ENTRY(rcs_sym) rs_list;
                    102: };
                    103:
                    104: struct rcs_lock {
                    105:        RCSNUM   *rl_num;
                    106:
                    107:        TAILQ_ENTRY(rcs_lock) rl_list;
                    108: };
                    109:
                    110:
                    111: struct rcs_branch {
                    112:        RCSNUM  *rb_num;
                    113:        TAILQ_ENTRY(rcs_branch) rb_list;
                    114: };
                    115:
                    116: struct rcs_dlist {
                    117:        struct rcs_delta *tqh_first;
                    118:        struct rcs_delta **tqh_last;
                    119: };
                    120:
                    121: struct rcs_delta {
                    122:        RCSNUM      *rd_num;
                    123:        RCSNUM      *rd_next;
                    124:        u_int        rd_flags;
                    125:        struct tm    rd_date;
                    126:        char        *rd_author;
                    127:        char        *rd_state;
                    128:        char        *rd_log;
                    129:        char        *rd_text;
                    130:
                    131:        struct rcs_dlist rd_snodes;
                    132:
                    133:        TAILQ_HEAD(, rcs_branch) rd_branches;
                    134:        TAILQ_ENTRY(rcs_delta)  rd_list;
                    135: };
                    136:
                    137:
                    138: typedef struct rcs_file {
                    139:        char   *rf_path;
                    140:        u_int   rf_ref;
1.9       jfb       141:        mode_t  rf_mode;
1.1       jfb       142:        u_int   rf_flags;
                    143:
                    144:        RCSNUM *rf_head;
                    145:        RCSNUM *rf_branch;
                    146:        char   *rf_comment;
                    147:        char   *rf_expand;
                    148:        char   *rf_desc;
                    149:
1.9       jfb       150:        u_int   rf_ndelta;
1.11      jfb       151:        struct rcs_dlist                  rf_delta;
                    152:        TAILQ_HEAD(rcs_alist, rcs_access) rf_access;
                    153:        TAILQ_HEAD(rcs_slist, rcs_sym)    rf_symbols;
                    154:        TAILQ_HEAD(rcs_llist, rcs_lock)   rf_locks;
1.9       jfb       155:
1.1       jfb       156:
                    157:        void   *rf_pdata;
                    158: } RCSFILE;
                    159:
                    160:
1.11      jfb       161: RCSFILE*    rcs_open          (const char *, int, ...);
                    162: void        rcs_close         (RCSFILE *);
                    163: int         rcs_access_add    (RCSFILE *, const char *);
                    164: int         rcs_access_remove (RCSFILE *, const char *);
                    165: int         rcs_access_check  (RCSFILE *, const char *);
                    166: int         rcs_sym_add       (RCSFILE *, const char *, RCSNUM *);
                    167: int         rcs_sym_remove    (RCSFILE *, const char *);
                    168: RCSNUM*     rcs_sym_getrev    (RCSFILE *, const char *);
1.12    ! jfb       169: int         rcs_lock_getmode  (RCSFILE *);
        !           170: int         rcs_lock_setmode  (RCSFILE *, int);
1.11      jfb       171: BUF*        rcs_getrev        (RCSFILE *, RCSNUM *);
                    172: BUF*        rcs_gethead       (RCSFILE *);
                    173: RCSNUM*     rcs_getrevbydate  (RCSFILE *, struct tm *);
                    174: const char* rcs_desc_get      (RCSFILE *);
                    175: int         rcs_desc_set      (RCSFILE *, const char *);
                    176: int         rcs_kwexp_set     (RCSFILE *, int);
                    177: int         rcs_kwexp_get     (RCSFILE *);
1.6       jfb       178:
                    179: int       rcs_kflag_get    (const char *);
1.7       jfb       180: void      rcs_kflag_usage  (void);
1.9       jfb       181: int       rcs_kw_expand    (RCSFILE *, u_char *, size_t, size_t *);
1.1       jfb       182:
                    183: BUF*      rcs_patch     (const char *, const char *);
                    184: size_t    rcs_stresc    (int, const char *, char *, size_t *);
                    185:
                    186: RCSNUM*   rcsnum_alloc  (void);
1.8       jfb       187: RCSNUM*   rcsnum_parse  (const char *);
1.1       jfb       188: void      rcsnum_free   (RCSNUM *);
                    189: int       rcsnum_aton   (const char *, char **, RCSNUM *);
                    190: char*     rcsnum_tostr  (const RCSNUM *, char *, size_t);
                    191: int       rcsnum_cpy    (const RCSNUM *, RCSNUM *, u_int);
                    192: int       rcsnum_cmp    (const RCSNUM *, const RCSNUM *, u_int);
                    193:
1.3       jfb       194: /* from cache.c */
                    195: int       rcs_cache_init    (u_int);
                    196: RCSFILE  *rcs_cache_fetch   (const char *path);
                    197: int       rcs_cache_store   (RCSFILE *);
                    198: void      rcs_cache_destroy (void);
1.1       jfb       199:
                    200: #endif /* RCS_H */