xref: /openbsd-src/gnu/usr.bin/cvs/src/rcs.h (revision b2ea75c1b17e1a9a339660e7ed45cd24946b230e)
1 /*
2  * Copyright (c) 1992, Brian Berliner and Jeff Polk
3  * Copyright (c) 1989-1992, Brian Berliner
4  *
5  * You may distribute under the terms of the GNU General Public License as
6  * specified in the README file that comes with the CVS source distribution.
7  *
8  * RCS source control definitions needed by rcs.c and friends
9  */
10 
11 /* Strings which indicate a conflict if they occur at the start of a line.  */
12 #define	RCS_MERGE_PAT_1 "<<<<<<< "
13 #define	RCS_MERGE_PAT_2 "=======\n"
14 #define	RCS_MERGE_PAT_3 ">>>>>>> "
15 
16 #define	RCSEXT		",v"
17 #define RCSPAT		"*,v"
18 #define	RCSHEAD		"head"
19 #define	RCSBRANCH	"branch"
20 #define	RCSSYMBOLS	"symbols"
21 #define	RCSDATE		"date"
22 #define	RCSDESC		"desc"
23 #define RCSEXPAND	"expand"
24 
25 /* Used by the version of death support which resulted from old
26    versions of CVS (e.g. 1.5 if you define DEATH_SUPPORT and not
27    DEATH_STATE).  Only a hacked up RCS (used by those old versions of
28    CVS) will put this into RCS files.  Considered obsolete.  */
29 #define RCSDEAD		"dead"
30 
31 #define	DATEFORM	"%02d.%02d.%02d.%02d.%02d.%02d"
32 #define	SDATEFORM	"%d.%d.%d.%d.%d.%d"
33 
34 /*
35  * Opaque structure definitions used by RCS specific lookup routines
36  */
37 #define VALID	0x1			/* flags field contains valid data */
38 #define	INATTIC	0x2			/* RCS file is located in the Attic */
39 #define PARTIAL 0x4			/* RCS file not completly parsed */
40 
41 /* All the "char *" fields in RCSNode, Deltatext, and RCSVers are
42    '\0'-terminated (except "text" in Deltatext).  This means that we
43    can't deal with fields containing '\0', which is a limitation that
44    RCS does not have.  Would be nice to fix this some day.  */
45 
46 struct rcsnode
47 {
48     /* Reference count for this structure.  Used to deal with the
49        fact that there might be a pointer from the Vers_TS or might
50        not.  Callers who increment this field are responsible for
51        calling freercsnode when they are done with their reference.  */
52     int refcount;
53 
54     /* Flags (INATTIC, PARTIAL, &c), see above.  */
55     int flags;
56 
57     /* File name of the RCS file.  This is not necessarily the name
58        as specified by the user, but it is a name which can be passed to
59        system calls and a name which is OK to print in error messages
60        (the various names might differ in case).  */
61     char *path;
62 
63     /* Value for head keyword from RCS header, or NULL if empty.  */
64     char *head;
65 
66     /* Value for branch keyword from RCS header, or NULL if omitted.  */
67     char *branch;
68 
69     /* Raw data on symbolic revisions.  The first time that RCS_symbols is
70        called, we parse these into ->symbols, and free ->symbols_data.  */
71     char *symbols_data;
72 
73     /* Value for expand keyword from RCS header, or NULL if omitted.  */
74     char *expand;
75 
76     /* List of nodes, the key of which is the symbolic name and the data
77        of which is the numeric revision that it corresponds to (malloc'd).  */
78     List *symbols;
79 
80     /* List of nodes (type RCSVERS), the key of which the numeric revision
81        number, and the data of which is an RCSVers * for the revision.  */
82     List *versions;
83 
84     /* Value for access keyword from RCS header, or NULL if empty.
85        FIXME: RCS_delaccess would also seem to use "" for empty.  We
86        should pick one or the other.  */
87     char *access;
88 
89     /* Raw data on locked revisions.  The first time that RCS_getlocks is
90        called, we parse these into ->locks, and free ->locks_data.  */
91     char *locks_data;
92 
93     /* List of nodes, the key of which is the numeric revision and the
94        data of which is the user that it corresponds to (malloc'd).  */
95     List *locks;
96 
97     /* Set for the strict keyword from the RCS header.  */
98     int strict_locks;
99 
100     /* Value for the comment keyword from RCS header (comment leader), or
101        NULL if omitted.  */
102     char *comment;
103 
104     /* Value for the desc field in the RCS file, or NULL if empty.  */
105     char *desc;
106 
107     /* File offset of the first deltatext node, so we can seek there.  */
108     long delta_pos;
109 
110     /* Newphrases from the RCS header.  List of nodes, the key of which
111        is the "id" which introduces the newphrase, and the value of which
112        is the value from the newphrase.  */
113     List *other;
114 };
115 
116 typedef struct rcsnode RCSNode;
117 
118 struct deltatext {
119     char *version;
120 
121     /* Log message, or NULL if we do not intend to change the log message
122        (that is, RCS_copydeltas should just use the log message from the
123        file).  */
124     char *log;
125 
126     /* Change text, or NULL if we do not intend to change the change text
127        (that is, RCS_copydeltas should just use the change text from the
128        file).  Note that it is perfectly legal to have log be NULL and
129        text non-NULL, or vice-versa.  */
130     char *text;
131     size_t len;
132 
133     /* Newphrase fields from deltatext nodes.  FIXME: duplicates the
134        other field in the rcsversnode, I think.  */
135     List *other;
136 };
137 typedef struct deltatext Deltatext;
138 
139 struct rcsversnode
140 {
141     /* Duplicate of the key by which this structure is indexed.  */
142     char *version;
143 
144     char *date;
145     char *author;
146     char *state;
147     char *next;
148     int dead;
149     int outdated;
150     Deltatext *text;
151     List *branches;
152     /* Newphrase fields from deltatext nodes.  Also contains ";add" and
153        ";delete" magic fields (see rcs.c, log.c).  I think this is
154        only used by log.c (where it looks up "log").  Duplicates the
155        other field in struct deltatext, I think.  */
156     List *other;
157     /* Newphrase fields from delta nodes.  */
158     List *other_delta;
159 #ifdef PRESERVE_PERMISSIONS_SUPPORT
160     /* Hard link information for each revision. */
161     List *hardlinks;
162 #endif
163 };
164 typedef struct rcsversnode RCSVers;
165 
166 /*
167  * CVS reserves all even-numbered branches for its own use.  "magic" branches
168  * (see rcs.c) are contained as virtual revision numbers (within symbolic
169  * tags only) off the RCS_MAGIC_BRANCH, which is 0.  CVS also reserves the
170  * ".1" branch for vendor revisions.  So, if you do your own branching, you
171  * should limit your use to odd branch numbers starting at 3.
172  */
173 #define	RCS_MAGIC_BRANCH	0
174 
175 /* The type of a function passed to RCS_checkout.  */
176 typedef void (*RCSCHECKOUTPROC) PROTO ((void *, const char *, size_t));
177 
178 #ifdef __STDC__
179 struct rcsbuffer;
180 #endif
181 
182 /*
183  * exported interfaces
184  */
185 RCSNode *RCS_parse PROTO((const char *file, const char *repos));
186 RCSNode *RCS_parsercsfile PROTO((char *rcsfile));
187 void RCS_fully_parse PROTO((RCSNode *));
188 void RCS_reparsercsfile PROTO((RCSNode *, FILE **, struct rcsbuffer *));
189 extern int RCS_setattic PROTO ((RCSNode *, int));
190 
191 char *RCS_check_kflag PROTO((const char *arg));
192 char *RCS_getdate PROTO((RCSNode * rcs, char *date, int force_tag_match));
193 char *RCS_gettag PROTO((RCSNode * rcs, char *symtag, int force_tag_match,
194 			int *simple_tag));
195 int RCS_exist_rev PROTO((RCSNode *rcs, char *rev));
196 int RCS_exist_tag PROTO((RCSNode *rcs, char *tag));
197 char *RCS_tag2rev PROTO((RCSNode *rcs, char *tag));
198 char *RCS_getversion PROTO((RCSNode * rcs, char *tag, char *date,
199 		      int force_tag_match, int *simple_tag));
200 char *RCS_magicrev PROTO((RCSNode *rcs, char *rev));
201 int RCS_isbranch PROTO((RCSNode *rcs, const char *rev));
202 int RCS_nodeisbranch PROTO((RCSNode *rcs, const char *tag));
203 char *RCS_whatbranch PROTO((RCSNode *rcs, const char *tag));
204 char *RCS_head PROTO((RCSNode * rcs));
205 int RCS_datecmp PROTO((char *date1, char *date2));
206 time_t RCS_getrevtime PROTO((RCSNode * rcs, char *rev, char *date, int fudge));
207 List *RCS_symbols PROTO((RCSNode *rcs));
208 void RCS_check_tag PROTO((const char *tag));
209 int RCS_valid_rev PROTO ((char *rev));
210 List *RCS_getlocks PROTO((RCSNode *rcs));
211 void freercsnode PROTO((RCSNode ** rnodep));
212 char *RCS_getbranch PROTO((RCSNode * rcs, char *tag, int force_tag_match));
213 char *RCS_branch_head PROTO ((RCSNode *rcs, char *rev));
214 
215 int RCS_isdead PROTO((RCSNode *, const char *));
216 char *RCS_getexpand PROTO ((RCSNode *));
217 void RCS_setexpand PROTO ((RCSNode *, char *));
218 int RCS_checkout PROTO ((RCSNode *, char *, char *, char *, char *, char *,
219 			 RCSCHECKOUTPROC, void *));
220 int RCS_checkin PROTO ((RCSNode *rcs, char *workfile, char *message,
221 			char *rev, int flags));
222 int RCS_cmp_file PROTO ((RCSNode *, char *, char *, const char *));
223 int RCS_settag PROTO ((RCSNode *, const char *, const char *));
224 int RCS_deltag PROTO ((RCSNode *, const char *));
225 int RCS_setbranch PROTO((RCSNode *, const char *));
226 int RCS_lock PROTO ((RCSNode *, const char *, int));
227 int RCS_unlock PROTO ((RCSNode *, const char *, int));
228 int RCS_delete_revs PROTO ((RCSNode *, char *, char *, int));
229 void RCS_addaccess PROTO ((RCSNode *, char *));
230 void RCS_delaccess PROTO ((RCSNode *, char *));
231 char *RCS_getaccess PROTO ((RCSNode *));
232 RETSIGTYPE rcs_cleanup PROTO ((void));
233 void RCS_rewrite PROTO ((RCSNode *, Deltatext *, char *));
234 void RCS_abandon PROTO ((RCSNode *));
235 int rcs_change_text PROTO ((const char *, char *, size_t, const char *,
236 			    size_t, char **, size_t *));
237 char *make_file_label PROTO ((char *, char *, RCSNode *));
238 
239 extern int preserve_perms;
240 
241 /* From import.c.  */
242 extern int add_rcs_file PROTO ((char *, char *, char *, char *, char *,
243 				char *, char *, int, char **,
244 				char *, size_t, FILE *));
245