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