117721Speter/*
2175277Sobrien * Copyright (C) 1986-2005 The Free Software Foundation, Inc.
3175277Sobrien *
4175277Sobrien * Portions Copyright (C) 1998-2005 Derek Price, Ximbiot <http://ximbiot.com>,
5175277Sobrien *                                  and others.
6175277Sobrien *
7175277Sobrien * Portions Copyright (C) 1992, Brian Berliner and Jeff Polk
8175277Sobrien * Portions Copyright (C) 1989-1992, Brian Berliner
917721Speter *
1017721Speter * You may distribute under the terms of the GNU General Public License as
1132789Speter * specified in the README file that comes with the CVS source distribution.
1217721Speter *
1317721Speter * RCS source control definitions needed by rcs.c and friends
1454431Speter *
1554431Speter * $FreeBSD$
1617721Speter */
1717721Speter
1866528Speter/* Strings which indicate a conflict if they occur at the start of a line.  */
1966528Speter#define	RCS_MERGE_PAT_1 "<<<<<<< "
2066528Speter#define	RCS_MERGE_PAT_2 "=======\n"
2166528Speter#define	RCS_MERGE_PAT_3 ">>>>>>> "
2225839Speter
2317721Speter#define	RCSEXT		",v"
2417721Speter#define RCSPAT		"*,v"
2517721Speter#define	RCSHEAD		"head"
2617721Speter#define	RCSBRANCH	"branch"
2717721Speter#define	RCSSYMBOLS	"symbols"
2817721Speter#define	RCSDATE		"date"
2917721Speter#define	RCSDESC		"desc"
3017721Speter#define RCSEXPAND	"expand"
3117721Speter
3217721Speter/* Used by the version of death support which resulted from old
3317721Speter   versions of CVS (e.g. 1.5 if you define DEATH_SUPPORT and not
3417721Speter   DEATH_STATE).  Only a hacked up RCS (used by those old versions of
3517721Speter   CVS) will put this into RCS files.  Considered obsolete.  */
3617721Speter#define RCSDEAD		"dead"
3717721Speter
3817721Speter#define	DATEFORM	"%02d.%02d.%02d.%02d.%02d.%02d"
3917721Speter#define	SDATEFORM	"%d.%d.%d.%d.%d.%d"
4017721Speter
4117721Speter/*
4217721Speter * Opaque structure definitions used by RCS specific lookup routines
4317721Speter */
4417721Speter#define VALID	0x1			/* flags field contains valid data */
4517721Speter#define	INATTIC	0x2			/* RCS file is located in the Attic */
4617721Speter#define PARTIAL 0x4			/* RCS file not completly parsed */
4717721Speter
4832789Speter/* All the "char *" fields in RCSNode, Deltatext, and RCSVers are
4932789Speter   '\0'-terminated (except "text" in Deltatext).  This means that we
5032789Speter   can't deal with fields containing '\0', which is a limitation that
5132789Speter   RCS does not have.  Would be nice to fix this some day.  */
5232789Speter
5317721Speterstruct rcsnode
5417721Speter{
5532789Speter    /* Reference count for this structure.  Used to deal with the
5632789Speter       fact that there might be a pointer from the Vers_TS or might
5732789Speter       not.  Callers who increment this field are responsible for
5832789Speter       calling freercsnode when they are done with their reference.  */
5917721Speter    int refcount;
6032789Speter
6132789Speter    /* Flags (INATTIC, PARTIAL, &c), see above.  */
6217721Speter    int flags;
6325839Speter
6425839Speter    /* File name of the RCS file.  This is not necessarily the name
6525839Speter       as specified by the user, but it is a name which can be passed to
6625839Speter       system calls and a name which is OK to print in error messages
6725839Speter       (the various names might differ in case).  */
6817721Speter    char *path;
6925839Speter
7032789Speter    /* Value for head keyword from RCS header, or NULL if empty.  */
7117721Speter    char *head;
7232789Speter
7332789Speter    /* Value for branch keyword from RCS header, or NULL if omitted.  */
7417721Speter    char *branch;
7532789Speter
7632789Speter    /* Raw data on symbolic revisions.  The first time that RCS_symbols is
7732789Speter       called, we parse these into ->symbols, and free ->symbols_data.  */
7817721Speter    char *symbols_data;
7932789Speter
8032789Speter    /* Value for expand keyword from RCS header, or NULL if omitted.  */
8117721Speter    char *expand;
8232789Speter
8332789Speter    /* List of nodes, the key of which is the symbolic name and the data
8432789Speter       of which is the numeric revision that it corresponds to (malloc'd).  */
8517721Speter    List *symbols;
8632789Speter
8732789Speter    /* List of nodes (type RCSVERS), the key of which the numeric revision
8832789Speter       number, and the data of which is an RCSVers * for the revision.  */
8917721Speter    List *versions;
9032789Speter
9132789Speter    /* Value for access keyword from RCS header, or NULL if empty.
9232789Speter       FIXME: RCS_delaccess would also seem to use "" for empty.  We
9332789Speter       should pick one or the other.  */
9432789Speter    char *access;
9532789Speter
9632789Speter    /* Raw data on locked revisions.  The first time that RCS_getlocks is
9732789Speter       called, we parse these into ->locks, and free ->locks_data.  */
9832789Speter    char *locks_data;
9932789Speter
10032789Speter    /* List of nodes, the key of which is the numeric revision and the
10132789Speter       data of which is the user that it corresponds to (malloc'd).  */
10232789Speter    List *locks;
10332789Speter
10432789Speter    /* Set for the strict keyword from the RCS header.  */
10532789Speter    int strict_locks;
10632789Speter
10732789Speter    /* Value for the comment keyword from RCS header (comment leader), or
10832789Speter       NULL if omitted.  */
10932789Speter    char *comment;
11032789Speter
11132789Speter    /* Value for the desc field in the RCS file, or NULL if empty.  */
11232789Speter    char *desc;
11332789Speter
11432789Speter    /* File offset of the first deltatext node, so we can seek there.  */
11525839Speter    long delta_pos;
11632789Speter
11732789Speter    /* Newphrases from the RCS header.  List of nodes, the key of which
11832789Speter       is the "id" which introduces the newphrase, and the value of which
11932789Speter       is the value from the newphrase.  */
12025839Speter    List *other;
12117721Speter};
12217721Speter
12317721Spetertypedef struct rcsnode RCSNode;
12417721Speter
12532789Speterstruct deltatext {
12632789Speter    char *version;
12732789Speter
12832789Speter    /* Log message, or NULL if we do not intend to change the log message
12932789Speter       (that is, RCS_copydeltas should just use the log message from the
13032789Speter       file).  */
13132789Speter    char *log;
13232789Speter
13332789Speter    /* Change text, or NULL if we do not intend to change the change text
13432789Speter       (that is, RCS_copydeltas should just use the change text from the
13532789Speter       file).  Note that it is perfectly legal to have log be NULL and
13632789Speter       text non-NULL, or vice-versa.  */
13732789Speter    char *text;
13832789Speter    size_t len;
13932789Speter
14032789Speter    /* Newphrase fields from deltatext nodes.  FIXME: duplicates the
14132789Speter       other field in the rcsversnode, I think.  */
14232789Speter    List *other;
14332789Speter};
14432789Spetertypedef struct deltatext Deltatext;
14532789Speter
14617721Speterstruct rcsversnode
14717721Speter{
14832789Speter    /* Duplicate of the key by which this structure is indexed.  */
14917721Speter    char *version;
15032789Speter
15117721Speter    char *date;
15217721Speter    char *author;
15325839Speter    char *state;
15417721Speter    char *next;
15517721Speter    int dead;
15632789Speter    int outdated;
15732789Speter    Deltatext *text;
15817721Speter    List *branches;
15932789Speter    /* Newphrase fields from deltatext nodes.  Also contains ";add" and
16032789Speter       ";delete" magic fields (see rcs.c, log.c).  I think this is
16132789Speter       only used by log.c (where it looks up "log").  Duplicates the
16232789Speter       other field in struct deltatext, I think.  */
16325839Speter    List *other;
16432789Speter    /* Newphrase fields from delta nodes.  */
16532789Speter    List *other_delta;
16644856Speter#ifdef PRESERVE_PERMISSIONS_SUPPORT
16744856Speter    /* Hard link information for each revision. */
16844856Speter    List *hardlinks;
16944856Speter#endif
17017721Speter};
17117721Spetertypedef struct rcsversnode RCSVers;
17217721Speter
17317721Speter/*
17417721Speter * CVS reserves all even-numbered branches for its own use.  "magic" branches
17517721Speter * (see rcs.c) are contained as virtual revision numbers (within symbolic
17617721Speter * tags only) off the RCS_MAGIC_BRANCH, which is 0.  CVS also reserves the
17717721Speter * ".1" branch for vendor revisions.  So, if you do your own branching, you
17817721Speter * should limit your use to odd branch numbers starting at 3.
17917721Speter */
18017721Speter#define	RCS_MAGIC_BRANCH	0
18117721Speter
18225839Speter/* The type of a function passed to RCS_checkout.  */
18325839Spetertypedef void (*RCSCHECKOUTPROC) PROTO ((void *, const char *, size_t));
18425839Speter
18534467Speter#ifdef __STDC__
18634467Speterstruct rcsbuffer;
18734467Speter#endif
18834467Speter
18981407Speter/* What RCS_deltas is supposed to do.  */
19081407Speterenum rcs_delta_op {RCS_ANNOTATE, RCS_FETCH};
19181407Speter
19217721Speter/*
19317721Speter * exported interfaces
19417721Speter */
19517721SpeterRCSNode *RCS_parse PROTO((const char *file, const char *repos));
196128269SpeterRCSNode *RCS_parsercsfile PROTO((const char *rcsfile));
19725839Spetervoid RCS_fully_parse PROTO((RCSNode *));
19834467Spetervoid RCS_reparsercsfile PROTO((RCSNode *, FILE **, struct rcsbuffer *));
19954431Speterextern int RCS_setattic PROTO ((RCSNode *, int));
20032789Speter
20117721Speterchar *RCS_check_kflag PROTO((const char *arg));
202128269Speterchar *RCS_getdate PROTO((RCSNode * rcs, const char *date,
203128269Speter                         int force_tag_match));
204128269Speterchar *RCS_gettag PROTO((RCSNode * rcs, const char *symtag, int force_tag_match,
205128269Speter                        int *simple_tag));
20644856Speterint RCS_exist_rev PROTO((RCSNode *rcs, char *rev));
20744856Speterint RCS_exist_tag PROTO((RCSNode *rcs, char *tag));
20844856Speterchar *RCS_tag2rev PROTO((RCSNode *rcs, char *tag));
209128269Speterchar *RCS_getversion PROTO((RCSNode * rcs, const char *tag, const char *date,
210128269Speter                            int force_tag_match, int *simple_tag));
21117721Speterchar *RCS_magicrev PROTO((RCSNode *rcs, char *rev));
21217721Speterint RCS_isbranch PROTO((RCSNode *rcs, const char *rev));
21317721Speterint RCS_nodeisbranch PROTO((RCSNode *rcs, const char *tag));
21417721Speterchar *RCS_whatbranch PROTO((RCSNode *rcs, const char *tag));
21517721Speterchar *RCS_head PROTO((RCSNode * rcs));
216128269Speterint RCS_datecmp PROTO((const char *date1, const char *date2));
217128269Spetertime_t RCS_getrevtime PROTO((RCSNode * rcs, const char *rev, char *date,
218128269Speter                             int fudge));
21917721SpeterList *RCS_symbols PROTO((RCSNode *rcs));
22017721Spetervoid RCS_check_tag PROTO((const char *tag));
22144856Speterint RCS_valid_rev PROTO ((char *rev));
22232789SpeterList *RCS_getlocks PROTO((RCSNode *rcs));
22317721Spetervoid freercsnode PROTO((RCSNode ** rnodep));
224128269Speterchar *RCS_getbranch PROTO((RCSNode * rcs, const char *tag,
225128269Speter                           int force_tag_match));
22644856Speterchar *RCS_branch_head PROTO ((RCSNode *rcs, char *rev));
22717721Speter
22817721Speterint RCS_isdead PROTO((RCSNode *, const char *));
22917721Speterchar *RCS_getexpand PROTO ((RCSNode *));
230128269Spetervoid RCS_setexpand PROTO ((RCSNode *, const char *));
231128269Speterint RCS_checkout PROTO ((RCSNode *, const char *, const char *, const char *,
232128269Speter                         const char *, const char *, RCSCHECKOUTPROC, void *));
233128269Speterint RCS_checkin PROTO ((RCSNode *rcs, const char *workfile,
234175277Sobrien                        const char *message, const char *rev, time_t citime,
235175277Sobrien			int flags));
236128269Speterint RCS_cmp_file PROTO((RCSNode *, const char *, char **, const char *,
237128269Speter                        const char *, const char *));
23825839Speterint RCS_settag PROTO ((RCSNode *, const char *, const char *));
23932789Speterint RCS_deltag PROTO ((RCSNode *, const char *));
24025839Speterint RCS_setbranch PROTO((RCSNode *, const char *));
241128269Speterint RCS_lock PROTO ((RCSNode *, const char *, int));
24281407Speterint RCS_unlock PROTO ((RCSNode *, char *, int));
24332789Speterint RCS_delete_revs PROTO ((RCSNode *, char *, char *, int));
24432789Spetervoid RCS_addaccess PROTO ((RCSNode *, char *));
24532789Spetervoid RCS_delaccess PROTO ((RCSNode *, char *));
24632789Speterchar *RCS_getaccess PROTO ((RCSNode *));
24766528SpeterRETSIGTYPE rcs_cleanup PROTO ((void));
24832789Spetervoid RCS_rewrite PROTO ((RCSNode *, Deltatext *, char *));
24966528Spetervoid RCS_abandon PROTO ((RCSNode *));
25025839Speterint rcs_change_text PROTO ((const char *, char *, size_t, const char *,
25125839Speter			    size_t, char **, size_t *));
252128269Spetervoid RCS_deltas PROTO ((RCSNode *, FILE *, struct rcsbuffer *, const char *,
25381407Speter			enum rcs_delta_op, char **, size_t *,
25481407Speter			char **, size_t *));
25532789Spetervoid RCS_setincexc PROTO ((const char *arg));
25625865Spetervoid RCS_setlocalid PROTO ((const char *arg));
257128269Speterchar *make_file_label PROTO ((const char *, const char *, RCSNode *));
25826804Speter
259131688Sdesextern int datesep;
26034467Speterextern int preserve_perms;
26134467Speter
26226804Speter/* From import.c.  */
263128269Speterextern int add_rcs_file PROTO ((const char *, const char *, const char *,
264128269Speter                                const char *, const char *, const char *,
265128269Speter                                const char *, int, char **, const char *,
266128269Speter                                size_t, FILE *));
267