Add CVS 1.12.11.
[dragonfly.git] / contrib / cvs-1.12.11 / 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
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     /* Use when printing paths.  */
64     char *print_path;
65
66     /* Value for head keyword from RCS header, or NULL if empty.  */
67     char *head;
68
69     /* Value for branch keyword from RCS header, or NULL if omitted.  */
70     char *branch;
71
72     /* Raw data on symbolic revisions.  The first time that RCS_symbols is
73        called, we parse these into ->symbols, and free ->symbols_data.  */
74     char *symbols_data;
75
76     /* Value for expand keyword from RCS header, or NULL if omitted.  */
77     char *expand;
78
79     /* List of nodes, the key of which is the symbolic name and the data
80        of which is the numeric revision that it corresponds to (malloc'd).  */
81     List *symbols;
82
83     /* List of nodes (type RCSVERS), the key of which the numeric revision
84        number, and the data of which is an RCSVers * for the revision.  */
85     List *versions;
86
87     /* Value for access keyword from RCS header, or NULL if empty.
88        FIXME: RCS_delaccess would also seem to use "" for empty.  We
89        should pick one or the other.  */
90     char *access;
91
92     /* Raw data on locked revisions.  The first time that RCS_getlocks is
93        called, we parse these into ->locks, and free ->locks_data.  */
94     char *locks_data;
95
96     /* List of nodes, the key of which is the numeric revision and the
97        data of which is the user that it corresponds to (malloc'd).  */
98     List *locks;
99
100     /* Set for the strict keyword from the RCS header.  */
101     int strict_locks;
102
103     /* Value for the comment keyword from RCS header (comment leader), or
104        NULL if omitted.  */
105     char *comment;
106
107     /* Value for the desc field in the RCS file, or NULL if empty.  */
108     char *desc;
109
110     /* File offset of the first deltatext node, so we can seek there.  */
111     off_t delta_pos;
112
113     /* Newphrases from the RCS header.  List of nodes, the key of which
114        is the "id" which introduces the newphrase, and the value of which
115        is the value from the newphrase.  */
116     List *other;
117 };
118
119 typedef struct rcsnode RCSNode;
120
121 struct deltatext {
122     char *version;
123
124     /* Log message, or NULL if we do not intend to change the log message
125        (that is, RCS_copydeltas should just use the log message from the
126        file).  */
127     char *log;
128
129     /* Change text, or NULL if we do not intend to change the change text
130        (that is, RCS_copydeltas should just use the change text from the
131        file).  Note that it is perfectly valid to have log be NULL and
132        text non-NULL, or vice-versa.  */
133     char *text;
134     size_t len;
135
136     /* Newphrase fields from deltatext nodes.  FIXME: duplicates the
137        other field in the rcsversnode, I think.  */
138     List *other;
139 };
140 typedef struct deltatext Deltatext;
141
142 struct rcsversnode
143 {
144     /* Duplicate of the key by which this structure is indexed.  */
145     char *version;
146
147     char *date;
148     char *author;
149     char *state;
150     char *next;
151     int dead;
152     int outdated;
153     Deltatext *text;
154     List *branches;
155     /* Newphrase fields from deltatext nodes.  Also contains ";add" and
156        ";delete" magic fields (see rcs.c, log.c).  I think this is
157        only used by log.c (where it looks up "log").  Duplicates the
158        other field in struct deltatext, I think.  */
159     List *other;
160     /* Newphrase fields from delta nodes.  */
161     List *other_delta;
162 #ifdef PRESERVE_PERMISSIONS_SUPPORT
163     /* Hard link information for each revision. */
164     List *hardlinks;
165 #endif
166 };
167 typedef struct rcsversnode RCSVers;
168
169 /*
170  * CVS reserves all even-numbered branches for its own use.  "magic" branches
171  * (see rcs.c) are contained as virtual revision numbers (within symbolic
172  * tags only) off the RCS_MAGIC_BRANCH, which is 0.  CVS also reserves the
173  * ".1" branch for vendor revisions.  So, if you do your own branching, you
174  * should limit your use to odd branch numbers starting at 3.
175  */
176 #define RCS_MAGIC_BRANCH        0
177
178 /* The type of a function passed to RCS_checkout.  */
179 typedef void (*RCSCHECKOUTPROC) (void *, const char *, size_t);
180
181 struct rcsbuffer;
182
183 /* What RCS_deltas is supposed to do.  */
184 enum rcs_delta_op {RCS_ANNOTATE, RCS_FETCH};
185
186 /*
187  * exported interfaces
188  */
189 RCSNode *RCS_parse (const char *file, const char *repos);
190 RCSNode *RCS_parsercsfile (const char *rcsfile);
191 void RCS_fully_parse (RCSNode *);
192 void RCS_reparsercsfile (RCSNode *, FILE **, struct rcsbuffer *);
193 extern int RCS_setattic (RCSNode *, int);
194
195 char *RCS_check_kflag (const char *arg);
196 char *RCS_getdate (RCSNode * rcs, const char *date, int force_tag_match);
197 char *RCS_gettag (RCSNode * rcs, const char *symtag, int force_tag_match,
198                   int *simple_tag);
199 int RCS_exist_rev (RCSNode *rcs, char *rev);
200 int RCS_exist_tag (RCSNode *rcs, char *tag);
201 char *RCS_tag2rev (RCSNode *rcs, char *tag);
202 char *RCS_getversion (RCSNode *rcs, const char *tag, const char *date,
203                       int force_tag_match, int *simple_tag);
204 char *RCS_magicrev (RCSNode *rcs, char *rev);
205 int RCS_isbranch (RCSNode *rcs, const char *rev);
206 int RCS_nodeisbranch (RCSNode *rcs, const char *tag);
207 char *RCS_whatbranch (RCSNode *rcs, const char *tag);
208 char *RCS_head (RCSNode * rcs);
209 int RCS_datecmp (const char *date1, const char *date2);
210 time_t RCS_getrevtime (RCSNode * rcs, const char *rev, char *date, int fudge);
211 List *RCS_symbols (RCSNode *rcs);
212 void RCS_check_tag (const char *tag);
213 int RCS_valid_rev (const char *rev);
214 List *RCS_getlocks (RCSNode *rcs);
215 void freercsnode (RCSNode ** rnodep);
216 char *RCS_getbranch (RCSNode *rcs, const char *tag, int force_tag_match);
217 char *RCS_branch_head (RCSNode *rcs, char *rev);
218
219 int RCS_isdead (RCSNode *, const char *);
220 char *RCS_getexpand (RCSNode *);
221 void RCS_setexpand (RCSNode *, const char *);
222 int RCS_checkout (RCSNode *, const char *, const char *, const char *,
223                   const char *, const char *, RCSCHECKOUTPROC, void *);
224 int RCS_checkin (RCSNode *rcs, const char *update_dir, const char *workfile,
225                  const char *message, const char *rev, time_t citime,
226                  int flags);
227 int RCS_cmp_file (RCSNode *, const char *, char **, const char *, const char *,
228                   const char * );
229 int RCS_settag (RCSNode *, const char *, const char *);
230 int RCS_deltag (RCSNode *, const char *);
231 int RCS_setbranch (RCSNode *, const char *);
232 int RCS_lock (RCSNode *, const char *, int);
233 int RCS_unlock (RCSNode *, char *, int);
234 int RCS_delete_revs (RCSNode *, char *, char *, int);
235 void RCS_addaccess (RCSNode *, char *);
236 void RCS_delaccess (RCSNode *, char *);
237 char *RCS_getaccess (RCSNode *);
238 void RCS_rewrite (RCSNode *, Deltatext *, char *);
239 void RCS_abandon (RCSNode *);
240 int rcs_change_text (const char *, char *, size_t, const char *,
241                      size_t, char **, size_t *);
242 void RCS_deltas (RCSNode *, FILE *, struct rcsbuffer *, const char *,
243                  enum rcs_delta_op, char **, size_t *,
244                  char **, size_t *);
245 void RCS_setincexc (void **, const char *arg);
246 void RCS_setlocalid (void **, const char *arg);
247 char *make_file_label (const char *, const char *, RCSNode *);
248
249 extern bool preserve_perms;
250
251 /* From import.c.  */
252 extern int add_rcs_file (const char *, const char *, const char *,
253                          const char *, const char *, const char *,
254                          const char *, int, char **, const char *, size_t,
255                          FILE *, bool);
256 void free_keywords (void *keywords);