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