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