Annotation of src/usr.bin/cvs/rcs.h, Revision 1.24
1.24 ! jfb 1: /* $OpenBSD: rcs.h,v 1.23 2005/04/20 23:11:30 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:
1.14 jfb 41: #define RCSDIR "RCS"
1.1 jfb 42: #define RCS_FILE_EXT ",v"
43:
1.17 jfb 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:
49: #define RCS_SYM_INVALCHAR "$,.:;@"
1.1 jfb 50:
1.12 jfb 51:
1.17 jfb 52: #define RCS_STATE_EXP "Exp"
53: #define RCS_STATE_DEAD "dead"
54:
1.12 jfb 55: /* lock types */
56: #define RCS_LOCK_LOOSE 0
57: #define RCS_LOCK_STRICT 1
58:
59:
1.6 jfb 60: /* RCS keyword expansion modes (kflags) */
61: #define RCS_KWEXP_NONE 0x00
62: #define RCS_KWEXP_NAME 0x01 /* include keyword name */
63: #define RCS_KWEXP_VAL 0x02 /* include keyword value */
64: #define RCS_KWEXP_LKR 0x04 /* include name of locker */
65: #define RCS_KWEXP_OLD 0x08 /* generate old keyword string */
66: #define RCS_KWEXP_ERR 0x10 /* mode has an error */
67:
68: #define RCS_KWEXP_DEFAULT (RCS_KWEXP_NAME | RCS_KWEXP_VAL)
69: #define RCS_KWEXP_KVL (RCS_KWEXP_NAME | RCS_KWEXP_VAL | RCS_KWEXP_LKR)
70:
1.9 jfb 71: #define RCS_KWEXP_INVAL(k) \
1.13 jfb 72: ((k & RCS_KWEXP_ERR) || \
73: ((k & RCS_KWEXP_OLD) && (RCS_KWEXP_OLD & ~RCS_KWEXP_OLD)))
1.9 jfb 74:
1.6 jfb 75:
76:
77: #define RCSNUM_MAXNUM USHRT_MAX
78: #define RCSNUM_MAXLEN 64
79:
1.17 jfb 80: #define RCSNUM_ISBRANCH(n) (((n)->rn_len % 2) == 0)
81:
1.1 jfb 82:
83: /* file flags */
1.9 jfb 84: #define RCS_READ 0x01
85: #define RCS_WRITE 0x02
86: #define RCS_RDWR (RCS_READ|RCS_WRITE)
87: #define RCS_CREATE 0x04 /* create the file */
88:
89: /* internal flags */
90: #define RCS_PARSED 0x010000 /* file has been parsed */
91: #define RCS_SYNCED 0x020000 /* in-memory copy is in sync with disk copy */
92: #define RCS_SLOCK 0x040000 /* strict lock */
1.1 jfb 93:
94: /* delta flags */
95: #define RCS_RD_DEAD 0x01 /* dead */
1.5 jfb 96:
1.14 jfb 97: /* RCS error codes */
98: #define RCS_ERR_NOERR 0
99: #define RCS_ERR_NOENT 1
100: #define RCS_ERR_DUPENT 2
101: #define RCS_ERR_BADNUM 3
1.22 jfb 102: #define RCS_ERR_BADSYM 4
103: #define RCS_ERR_PARSE 5
1.24 ! jfb 104: #define RCS_ERR_ERRNO 255
1.5 jfb 105:
1.1 jfb 106: typedef struct rcs_num {
107: u_int rn_len;
108: u_int16_t *rn_id;
109: } RCSNUM;
110:
111:
1.11 jfb 112: struct rcs_access {
113: char *ra_name;
114: uid_t ra_uid;
115: TAILQ_ENTRY(rcs_access) ra_list;
116: };
117:
1.1 jfb 118: struct rcs_sym {
119: char *rs_name;
120: RCSNUM *rs_num;
121: TAILQ_ENTRY(rcs_sym) rs_list;
122: };
123:
124: struct rcs_lock {
1.17 jfb 125: char *rl_name;
1.1 jfb 126: RCSNUM *rl_num;
127:
128: TAILQ_ENTRY(rcs_lock) rl_list;
129: };
130:
131:
132: struct rcs_branch {
133: RCSNUM *rb_num;
134: TAILQ_ENTRY(rcs_branch) rb_list;
135: };
136:
137: struct rcs_dlist {
138: struct rcs_delta *tqh_first;
139: struct rcs_delta **tqh_last;
140: };
141:
142: struct rcs_delta {
1.18 jfb 143: RCSNUM *rd_num;
144: RCSNUM *rd_next;
145: u_int rd_flags;
146: struct tm rd_date;
147: char *rd_author;
148: char *rd_state;
149: char *rd_log;
1.20 jfb 150: u_char *rd_text;
1.18 jfb 151: size_t rd_tlen;
1.1 jfb 152:
1.18 jfb 153: struct rcs_dlist rd_snodes;
1.1 jfb 154: TAILQ_HEAD(, rcs_branch) rd_branches;
1.18 jfb 155: TAILQ_ENTRY(rcs_delta) rd_list;
1.1 jfb 156: };
157:
158:
159: typedef struct rcs_file {
160: char *rf_path;
161: u_int rf_ref;
1.9 jfb 162: mode_t rf_mode;
1.1 jfb 163: u_int rf_flags;
164:
165: RCSNUM *rf_head;
166: RCSNUM *rf_branch;
167: char *rf_comment;
168: char *rf_expand;
169: char *rf_desc;
170:
1.9 jfb 171: u_int rf_ndelta;
1.11 jfb 172: struct rcs_dlist rf_delta;
173: TAILQ_HEAD(rcs_alist, rcs_access) rf_access;
174: TAILQ_HEAD(rcs_slist, rcs_sym) rf_symbols;
175: TAILQ_HEAD(rcs_llist, rcs_lock) rf_locks;
1.9 jfb 176:
1.1 jfb 177: void *rf_pdata;
178: } RCSFILE;
179:
180:
1.14 jfb 181: extern int rcs_errno;
182:
183:
1.16 jfb 184: RCSFILE* rcs_open (const char *, int, ...);
185: void rcs_close (RCSFILE *);
1.19 jfb 186: const RCSNUM* rcs_head_get (RCSFILE *);
187: int rcs_head_set (RCSFILE *, const RCSNUM *);
1.16 jfb 188: const RCSNUM* rcs_branch_get (RCSFILE *);
189: int rcs_branch_set (RCSFILE *, const RCSNUM *);
190: int rcs_access_add (RCSFILE *, const char *);
191: int rcs_access_remove (RCSFILE *, const char *);
192: int rcs_access_check (RCSFILE *, const char *);
193: int rcs_sym_add (RCSFILE *, const char *, RCSNUM *);
194: int rcs_sym_remove (RCSFILE *, const char *);
195: RCSNUM* rcs_sym_getrev (RCSFILE *, const char *);
1.22 jfb 196: int rcs_sym_check (const char *);
1.16 jfb 197: int rcs_lock_getmode (RCSFILE *);
198: int rcs_lock_setmode (RCSFILE *, int);
1.17 jfb 199: int rcs_lock_add (RCSFILE *, const char *, RCSNUM *);
200: int rcs_lock_remove (RCSFILE *, const RCSNUM *);
1.16 jfb 201: BUF* rcs_getrev (RCSFILE *, RCSNUM *);
202: BUF* rcs_gethead (RCSFILE *);
203: RCSNUM* rcs_getrevbydate (RCSFILE *, struct tm *);
204: const char* rcs_desc_get (RCSFILE *);
205: int rcs_desc_set (RCSFILE *, 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 *);
1.24 ! jfb 210: int rcs_rev_add (RCSFILE *, RCSNUM *, const char *);
! 211: int rcs_rev_remove (RCSFILE *, RCSNUM *);
1.17 jfb 212: RCSNUM* rcs_tag_resolve (RCSFILE *, const char *);
1.16 jfb 213: const char* rcs_errstr (int);
1.24 ! jfb 214:
! 215:
! 216:
1.6 jfb 217:
218: int rcs_kflag_get (const char *);
1.7 jfb 219: void rcs_kflag_usage (void);
1.9 jfb 220: int rcs_kw_expand (RCSFILE *, u_char *, size_t, size_t *);
1.1 jfb 221:
222: BUF* rcs_patch (const char *, const char *);
223:
224: RCSNUM* rcsnum_alloc (void);
1.8 jfb 225: RCSNUM* rcsnum_parse (const char *);
1.1 jfb 226: void rcsnum_free (RCSNUM *);
227: int rcsnum_aton (const char *, char **, RCSNUM *);
228: char* rcsnum_tostr (const RCSNUM *, char *, size_t);
229: int rcsnum_cpy (const RCSNUM *, RCSNUM *, u_int);
230: int rcsnum_cmp (const RCSNUM *, const RCSNUM *, u_int);
231:
232: #endif /* RCS_H */