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