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