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