Annotation of src/usr.bin/cvs/rcs.h, Revision 1.7
1.7 ! jfb 1: /* $OpenBSD: rcs.h,v 1.6 2005/01/12 19:23:27 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.6 jfb 45: /* RCS keyword expansion modes (kflags) */
46: #define RCS_KWEXP_NONE 0x00
47: #define RCS_KWEXP_NAME 0x01 /* include keyword name */
48: #define RCS_KWEXP_VAL 0x02 /* include keyword value */
49: #define RCS_KWEXP_LKR 0x04 /* include name of locker */
50: #define RCS_KWEXP_OLD 0x08 /* generate old keyword string */
51: #define RCS_KWEXP_ERR 0x10 /* mode has an error */
52:
53: #define RCS_KWEXP_DEFAULT (RCS_KWEXP_NAME | RCS_KWEXP_VAL)
54: #define RCS_KWEXP_KVL (RCS_KWEXP_NAME | RCS_KWEXP_VAL | RCS_KWEXP_LKR)
55:
56: #define RCS_KWEXP_INVAL(k) (k & RCS_KWEXP_ERR)
57:
58:
59: #define RCSNUM_MAXNUM USHRT_MAX
60: #define RCSNUM_MAXLEN 64
61:
1.1 jfb 62:
63: /* open modes */
64: #define RCS_MODE_READ 0x01
65: #define RCS_MODE_WRITE 0x02
66: #define RCS_MODE_RDWR (RCS_MODE_READ|RCS_MODE_WRITE)
67:
68:
69: /* file flags */
70: #define RCS_RF_PARSED 0x01 /* file has been parsed */
71: #define RCS_RF_SYNCED 0x02 /* in-memory copy is in sync with disk copy */
72: #define RCS_RF_SLOCK 0x04 /* strict lock */
73:
74: /* delta flags */
75: #define RCS_RD_DEAD 0x01 /* dead */
1.5 jfb 76:
77:
1.1 jfb 78: typedef struct rcs_num {
79: u_int rn_len;
80: u_int16_t *rn_id;
81: } RCSNUM;
82:
83:
84: struct rcs_sym {
85: char *rs_name;
86: RCSNUM *rs_num;
87: TAILQ_ENTRY(rcs_sym) rs_list;
88: };
89:
90: struct rcs_lock {
91: RCSNUM *rl_num;
92:
93: TAILQ_ENTRY(rcs_lock) rl_list;
94: };
95:
96:
97: struct rcs_branch {
98: RCSNUM *rb_num;
99: TAILQ_ENTRY(rcs_branch) rb_list;
100: };
101:
102: struct rcs_dlist {
103: struct rcs_delta *tqh_first;
104: struct rcs_delta **tqh_last;
105: };
106:
107: struct rcs_delta {
108: RCSNUM *rd_num;
109: RCSNUM *rd_next;
110: u_int rd_flags;
111: struct tm rd_date;
112: char *rd_author;
113: char *rd_state;
114: char *rd_log;
115: char *rd_text;
116:
117: struct rcs_dlist rd_snodes;
118:
119: TAILQ_HEAD(, rcs_branch) rd_branches;
120: TAILQ_ENTRY(rcs_delta) rd_list;
121: };
122:
123:
124: typedef struct rcs_file {
125: char *rf_path;
126: u_int rf_ref;
127: u_int rf_mode;
128: u_int rf_flags;
129:
130: RCSNUM *rf_head;
131: RCSNUM *rf_branch;
132: char *rf_comment;
133: char *rf_expand;
134: char *rf_desc;
135:
136: struct rcs_dlist rf_delta;
137: TAILQ_HEAD(rcs_slist, rcs_sym) rf_symbols;
138: TAILQ_HEAD(rcs_llist, rcs_lock) rf_locks;
139:
140: void *rf_pdata;
141: } RCSFILE;
142:
143:
144: RCSFILE* rcs_open (const char *, u_int);
145: void rcs_close (RCSFILE *);
146: int rcs_parse (RCSFILE *);
147: int rcs_write (RCSFILE *);
148: int rcs_addsym (RCSFILE *, const char *, RCSNUM *);
149: int rcs_rmsym (RCSFILE *, const char *);
150: BUF* rcs_getrev (RCSFILE *, RCSNUM *);
1.4 jfb 151: BUF* rcs_gethead (RCSFILE *);
1.1 jfb 152: RCSNUM* rcs_getrevbydate (RCSFILE *, struct tm *);
1.6 jfb 153:
154: int rcs_kflag_get (const char *);
1.7 ! jfb 155: void rcs_kflag_usage (void);
1.1 jfb 156:
157: BUF* rcs_patch (const char *, const char *);
158: size_t rcs_stresc (int, const char *, char *, size_t *);
159:
160: RCSNUM* rcsnum_alloc (void);
161: void rcsnum_free (RCSNUM *);
162: int rcsnum_aton (const char *, char **, RCSNUM *);
163: char* rcsnum_tostr (const RCSNUM *, char *, size_t);
164: int rcsnum_cpy (const RCSNUM *, RCSNUM *, u_int);
165: int rcsnum_cmp (const RCSNUM *, const RCSNUM *, u_int);
166:
1.3 jfb 167: /* from cache.c */
168: int rcs_cache_init (u_int);
169: RCSFILE *rcs_cache_fetch (const char *path);
170: int rcs_cache_store (RCSFILE *);
171: void rcs_cache_destroy (void);
1.1 jfb 172:
173: #endif /* RCS_H */