xref: /dflybsd-src/contrib/cvs-1.12/src/rcs.h (revision 86d7f5d305c6adaa56ff4582ece9859d73106103)
186d7f5d3SJohn Marino /*
286d7f5d3SJohn Marino  * Copyright (C) 1986-2005 The Free Software Foundation, Inc.
386d7f5d3SJohn Marino  *
486d7f5d3SJohn Marino  * Portions Copyright (C) 1998-2005 Derek Price, Ximbiot <http://ximbiot.com>,
586d7f5d3SJohn Marino  *                                  and others.
686d7f5d3SJohn Marino  *
786d7f5d3SJohn Marino  * Portions Copyright (C) 1992, Brian Berliner and Jeff Polk
886d7f5d3SJohn Marino  * Portions Copyright (C) 1989-1992, Brian Berliner
986d7f5d3SJohn Marino  *
1086d7f5d3SJohn Marino  * You may distribute under the terms of the GNU General Public License as
1186d7f5d3SJohn Marino  * specified in the README file that comes with the CVS source distribution.
1286d7f5d3SJohn Marino  *
1386d7f5d3SJohn Marino  * RCS source control definitions needed by rcs.c and friends
1486d7f5d3SJohn Marino  */
1586d7f5d3SJohn Marino 
1686d7f5d3SJohn Marino /* Strings which indicate a conflict if they occur at the start of a line.  */
1786d7f5d3SJohn Marino #define	RCS_MERGE_PAT_1 "<<<<<<< "
1886d7f5d3SJohn Marino #define	RCS_MERGE_PAT_2 "=======\n"
1986d7f5d3SJohn Marino #define	RCS_MERGE_PAT_3 ">>>>>>> "
2086d7f5d3SJohn Marino 
2186d7f5d3SJohn Marino #define	RCSEXT		",v"
2286d7f5d3SJohn Marino #define RCSPAT		"*,v"
2386d7f5d3SJohn Marino #define	RCSHEAD		"head"
2486d7f5d3SJohn Marino #define	RCSBRANCH	"branch"
2586d7f5d3SJohn Marino #define	RCSSYMBOLS	"symbols"
2686d7f5d3SJohn Marino #define	RCSDATE		"date"
2786d7f5d3SJohn Marino #define	RCSDESC		"desc"
2886d7f5d3SJohn Marino #define RCSEXPAND	"expand"
2986d7f5d3SJohn Marino 
3086d7f5d3SJohn Marino /* Used by the version of death support which resulted from old
3186d7f5d3SJohn Marino    versions of CVS (e.g. 1.5 if you define DEATH_SUPPORT and not
3286d7f5d3SJohn Marino    DEATH_STATE).  Only a hacked up RCS (used by those old versions of
3386d7f5d3SJohn Marino    CVS) will put this into RCS files.  Considered obsolete.  */
3486d7f5d3SJohn Marino #define RCSDEAD		"dead"
3586d7f5d3SJohn Marino 
3686d7f5d3SJohn Marino #define	DATEFORM	"%02d.%02d.%02d.%02d.%02d.%02d"
3786d7f5d3SJohn Marino #define	SDATEFORM	"%d.%d.%d.%d.%d.%d"
3886d7f5d3SJohn Marino 
3986d7f5d3SJohn Marino /*
4086d7f5d3SJohn Marino  * Opaque structure definitions used by RCS specific lookup routines
4186d7f5d3SJohn Marino  */
4286d7f5d3SJohn Marino #define VALID	0x1			/* flags field contains valid data */
4386d7f5d3SJohn Marino #define	INATTIC	0x2			/* RCS file is located in the Attic */
4486d7f5d3SJohn Marino #define PARTIAL 0x4			/* RCS file not completly parsed */
4586d7f5d3SJohn Marino 
4686d7f5d3SJohn Marino /* All the "char *" fields in RCSNode, Deltatext, and RCSVers are
4786d7f5d3SJohn Marino    '\0'-terminated (except "text" in Deltatext).  This means that we
4886d7f5d3SJohn Marino    can't deal with fields containing '\0', which is a limitation that
4986d7f5d3SJohn Marino    RCS does not have.  Would be nice to fix this some day.  */
5086d7f5d3SJohn Marino 
5186d7f5d3SJohn Marino struct rcsnode
5286d7f5d3SJohn Marino {
5386d7f5d3SJohn Marino     /* Reference count for this structure.  Used to deal with the
5486d7f5d3SJohn Marino        fact that there might be a pointer from the Vers_TS or might
5586d7f5d3SJohn Marino        not.  Callers who increment this field are responsible for
5686d7f5d3SJohn Marino        calling freercsnode when they are done with their reference.  */
5786d7f5d3SJohn Marino     int refcount;
5886d7f5d3SJohn Marino 
5986d7f5d3SJohn Marino     /* Flags (INATTIC, PARTIAL, &c), see above.  */
6086d7f5d3SJohn Marino     int flags;
6186d7f5d3SJohn Marino 
6286d7f5d3SJohn Marino     /* File name of the RCS file.  This is not necessarily the name
6386d7f5d3SJohn Marino        as specified by the user, but it is a name which can be passed to
6486d7f5d3SJohn Marino        system calls and a name which is OK to print in error messages
6586d7f5d3SJohn Marino        (the various names might differ in case).  */
6686d7f5d3SJohn Marino     char *path;
6786d7f5d3SJohn Marino 
6886d7f5d3SJohn Marino     /* Use when printing paths.  */
6986d7f5d3SJohn Marino     char *print_path;
7086d7f5d3SJohn Marino 
7186d7f5d3SJohn Marino     /* Value for head keyword from RCS header, or NULL if empty.  HEAD may only
7286d7f5d3SJohn Marino      * be empty in a valid RCS file when the file has no revisions, a state
7386d7f5d3SJohn Marino      * that should not be able to occur with CVS.
7486d7f5d3SJohn Marino      */
7586d7f5d3SJohn Marino     char *head;
7686d7f5d3SJohn Marino 
7786d7f5d3SJohn Marino     /* Value for branch keyword from RCS header, or NULL if omitted.  */
7886d7f5d3SJohn Marino     char *branch;
7986d7f5d3SJohn Marino 
8086d7f5d3SJohn Marino     /* Raw data on symbolic revisions.  The first time that RCS_symbols is
8186d7f5d3SJohn Marino        called, we parse these into ->symbols, and free ->symbols_data.  */
8286d7f5d3SJohn Marino     char *symbols_data;
8386d7f5d3SJohn Marino 
8486d7f5d3SJohn Marino     /* Value for expand keyword from RCS header, or NULL if omitted.  */
8586d7f5d3SJohn Marino     char *expand;
8686d7f5d3SJohn Marino 
8786d7f5d3SJohn Marino     /* List of nodes, the key of which is the symbolic name and the data
8886d7f5d3SJohn Marino        of which is the numeric revision that it corresponds to (malloc'd).  */
8986d7f5d3SJohn Marino     List *symbols;
9086d7f5d3SJohn Marino 
9186d7f5d3SJohn Marino     /* List of nodes (type RCSVERS), the key of which the numeric revision
9286d7f5d3SJohn Marino        number, and the data of which is an RCSVers * for the revision.  */
9386d7f5d3SJohn Marino     List *versions;
9486d7f5d3SJohn Marino 
9586d7f5d3SJohn Marino     /* Value for access keyword from RCS header, or NULL if empty.
9686d7f5d3SJohn Marino        FIXME: RCS_delaccess would also seem to use "" for empty.  We
9786d7f5d3SJohn Marino        should pick one or the other.  */
9886d7f5d3SJohn Marino     char *access;
9986d7f5d3SJohn Marino 
10086d7f5d3SJohn Marino     /* Raw data on locked revisions.  The first time that RCS_getlocks is
10186d7f5d3SJohn Marino        called, we parse these into ->locks, and free ->locks_data.  */
10286d7f5d3SJohn Marino     char *locks_data;
10386d7f5d3SJohn Marino 
10486d7f5d3SJohn Marino     /* List of nodes, the key of which is the numeric revision and the
10586d7f5d3SJohn Marino        data of which is the user that it corresponds to (malloc'd).  */
10686d7f5d3SJohn Marino     List *locks;
10786d7f5d3SJohn Marino 
10886d7f5d3SJohn Marino     /* Set for the strict keyword from the RCS header.  */
10986d7f5d3SJohn Marino     int strict_locks;
11086d7f5d3SJohn Marino 
11186d7f5d3SJohn Marino     /* Value for the comment keyword from RCS header (comment leader), or
11286d7f5d3SJohn Marino        NULL if omitted.  */
11386d7f5d3SJohn Marino     char *comment;
11486d7f5d3SJohn Marino 
11586d7f5d3SJohn Marino     /* Value for the desc field in the RCS file, or NULL if empty.  */
11686d7f5d3SJohn Marino     char *desc;
11786d7f5d3SJohn Marino 
11886d7f5d3SJohn Marino     /* File offset of the first deltatext node, so we can seek there.  */
11986d7f5d3SJohn Marino     off_t delta_pos;
12086d7f5d3SJohn Marino 
12186d7f5d3SJohn Marino     /* Newphrases from the RCS header.  List of nodes, the key of which
12286d7f5d3SJohn Marino        is the "id" which introduces the newphrase, and the value of which
12386d7f5d3SJohn Marino        is the value from the newphrase.  */
12486d7f5d3SJohn Marino     List *other;
12586d7f5d3SJohn Marino };
12686d7f5d3SJohn Marino 
12786d7f5d3SJohn Marino typedef struct rcsnode RCSNode;
12886d7f5d3SJohn Marino 
12986d7f5d3SJohn Marino struct deltatext {
13086d7f5d3SJohn Marino     char *version;
13186d7f5d3SJohn Marino 
13286d7f5d3SJohn Marino     /* Log message, or NULL if we do not intend to change the log message
13386d7f5d3SJohn Marino        (that is, RCS_copydeltas should just use the log message from the
13486d7f5d3SJohn Marino        file).  */
13586d7f5d3SJohn Marino     char *log;
13686d7f5d3SJohn Marino 
13786d7f5d3SJohn Marino     /* Change text, or NULL if we do not intend to change the change text
13886d7f5d3SJohn Marino        (that is, RCS_copydeltas should just use the change text from the
13986d7f5d3SJohn Marino        file).  Note that it is perfectly valid to have log be NULL and
14086d7f5d3SJohn Marino        text non-NULL, or vice-versa.  */
14186d7f5d3SJohn Marino     char *text;
14286d7f5d3SJohn Marino     size_t len;
14386d7f5d3SJohn Marino 
14486d7f5d3SJohn Marino     /* Newphrase fields from deltatext nodes.  FIXME: duplicates the
14586d7f5d3SJohn Marino        other field in the rcsversnode, I think.  */
14686d7f5d3SJohn Marino     List *other;
14786d7f5d3SJohn Marino };
14886d7f5d3SJohn Marino typedef struct deltatext Deltatext;
14986d7f5d3SJohn Marino 
15086d7f5d3SJohn Marino struct rcsversnode
15186d7f5d3SJohn Marino {
15286d7f5d3SJohn Marino     /* Duplicate of the key by which this structure is indexed.  */
15386d7f5d3SJohn Marino     char *version;
15486d7f5d3SJohn Marino 
15586d7f5d3SJohn Marino     char *date;
15686d7f5d3SJohn Marino     char *author;
15786d7f5d3SJohn Marino     char *state;
15886d7f5d3SJohn Marino     char *next;
15986d7f5d3SJohn Marino     int dead;
16086d7f5d3SJohn Marino     int outdated;
16186d7f5d3SJohn Marino     Deltatext *text;
16286d7f5d3SJohn Marino     List *branches;
16386d7f5d3SJohn Marino     /* Newphrase fields from deltatext nodes.  Also contains ";add" and
16486d7f5d3SJohn Marino        ";delete" magic fields (see rcs.c, log.c).  I think this is
16586d7f5d3SJohn Marino        only used by log.c (where it looks up "log").  Duplicates the
16686d7f5d3SJohn Marino        other field in struct deltatext, I think.  */
16786d7f5d3SJohn Marino     List *other;
16886d7f5d3SJohn Marino     /* Newphrase fields from delta nodes.  */
16986d7f5d3SJohn Marino     List *other_delta;
17086d7f5d3SJohn Marino #ifdef PRESERVE_PERMISSIONS_SUPPORT
17186d7f5d3SJohn Marino     /* Hard link information for each revision. */
17286d7f5d3SJohn Marino     List *hardlinks;
17386d7f5d3SJohn Marino #endif
17486d7f5d3SJohn Marino };
17586d7f5d3SJohn Marino typedef struct rcsversnode RCSVers;
17686d7f5d3SJohn Marino 
17786d7f5d3SJohn Marino /*
17886d7f5d3SJohn Marino  * CVS reserves all even-numbered branches for its own use.  "magic" branches
17986d7f5d3SJohn Marino  * (see rcs.c) are contained as virtual revision numbers (within symbolic
18086d7f5d3SJohn Marino  * tags only) off the RCS_MAGIC_BRANCH, which is 0.  CVS also reserves the
18186d7f5d3SJohn Marino  * ".1" branch for vendor revisions.  So, if you do your own branching, you
18286d7f5d3SJohn Marino  * should limit your use to odd branch numbers starting at 3.
18386d7f5d3SJohn Marino  */
18486d7f5d3SJohn Marino #define	RCS_MAGIC_BRANCH	0
18586d7f5d3SJohn Marino 
18686d7f5d3SJohn Marino /* The type of a function passed to RCS_checkout.  */
18786d7f5d3SJohn Marino typedef void (*RCSCHECKOUTPROC) (void *, const char *, size_t);
18886d7f5d3SJohn Marino 
18986d7f5d3SJohn Marino struct rcsbuffer;
19086d7f5d3SJohn Marino 
19186d7f5d3SJohn Marino /* What RCS_deltas is supposed to do.  */
19286d7f5d3SJohn Marino enum rcs_delta_op {RCS_ANNOTATE, RCS_ANNOTATE_BACKWARDS, RCS_FETCH};
19386d7f5d3SJohn Marino 
19486d7f5d3SJohn Marino /*
19586d7f5d3SJohn Marino  * exported interfaces
19686d7f5d3SJohn Marino  */
19786d7f5d3SJohn Marino RCSNode *RCS_parse (const char *file, const char *repos);
19886d7f5d3SJohn Marino RCSNode *RCS_parsercsfile (const char *rcsfile);
19986d7f5d3SJohn Marino void RCS_fully_parse (RCSNode *);
20086d7f5d3SJohn Marino void RCS_reparsercsfile (RCSNode *, FILE **, struct rcsbuffer *);
20186d7f5d3SJohn Marino extern int RCS_setattic (RCSNode *, int);
20286d7f5d3SJohn Marino 
20386d7f5d3SJohn Marino char *RCS_check_kflag (const char *arg);
20486d7f5d3SJohn Marino char *RCS_getdate (RCSNode * rcs, const char *date, int force_tag_match);
20586d7f5d3SJohn Marino char *RCS_gettag (RCSNode * rcs, const char *symtag, int force_tag_match,
20686d7f5d3SJohn Marino 		  int *simple_tag);
20786d7f5d3SJohn Marino int RCS_exist_rev (RCSNode *rcs, char *rev);
20886d7f5d3SJohn Marino int RCS_exist_tag (RCSNode *rcs, char *tag);
20986d7f5d3SJohn Marino char *RCS_tag2rev (RCSNode *rcs, char *tag);
21086d7f5d3SJohn Marino char *RCS_getversion (RCSNode *rcs, const char *tag, const char *date,
21186d7f5d3SJohn Marino 		      int force_tag_match, int *simple_tag);
21286d7f5d3SJohn Marino char *RCS_magicrev (RCSNode *rcs, char *rev);
21386d7f5d3SJohn Marino int RCS_isbranch (RCSNode *rcs, const char *rev);
21486d7f5d3SJohn Marino int RCS_nodeisbranch (RCSNode *rcs, const char *tag);
21586d7f5d3SJohn Marino char *RCS_whatbranch (RCSNode *rcs, const char *tag);
21686d7f5d3SJohn Marino char *RCS_head (RCSNode * rcs);
21786d7f5d3SJohn Marino int RCS_datecmp (const char *date1, const char *date2);
21886d7f5d3SJohn Marino time_t RCS_getrevtime (RCSNode * rcs, const char *rev, char *date, int fudge);
21986d7f5d3SJohn Marino List *RCS_symbols (RCSNode *rcs);
22086d7f5d3SJohn Marino void RCS_check_tag (const char *tag);
22186d7f5d3SJohn Marino int RCS_valid_rev (const char *rev);
22286d7f5d3SJohn Marino List *RCS_getlocks (RCSNode *rcs);
22386d7f5d3SJohn Marino void freercsnode (RCSNode ** rnodep);
22486d7f5d3SJohn Marino char *RCS_getbranch (RCSNode *rcs, const char *tag, int force_tag_match);
22586d7f5d3SJohn Marino char *RCS_branch_head (RCSNode *rcs, char *rev);
22686d7f5d3SJohn Marino 
22786d7f5d3SJohn Marino int RCS_isdead (RCSNode *, const char *);
22886d7f5d3SJohn Marino char *RCS_getexpand (RCSNode *);
22986d7f5d3SJohn Marino void RCS_setexpand (RCSNode *, const char *);
23086d7f5d3SJohn Marino int RCS_checkout (RCSNode *, const char *, const char *, const char *,
23186d7f5d3SJohn Marino                   const char *, const char *, RCSCHECKOUTPROC, void *);
23286d7f5d3SJohn Marino int RCS_checkin (RCSNode *rcs, const char *update_dir, const char *workfile,
23386d7f5d3SJohn Marino 		 const char *message, const char *rev, time_t citime,
23486d7f5d3SJohn Marino 		 int flags);
23586d7f5d3SJohn Marino int RCS_cmp_file (RCSNode *, const char *, char **, const char *, const char *,
23686d7f5d3SJohn Marino 		  const char * );
23786d7f5d3SJohn Marino int RCS_settag (RCSNode *, const char *, const char *);
23886d7f5d3SJohn Marino int RCS_deltag (RCSNode *, const char *);
23986d7f5d3SJohn Marino int RCS_setbranch (RCSNode *, const char *);
24086d7f5d3SJohn Marino int RCS_lock (RCSNode *, const char *, int);
24186d7f5d3SJohn Marino int RCS_unlock (RCSNode *, char *, int);
24286d7f5d3SJohn Marino int RCS_delete_revs (RCSNode *, char *, char *, int);
24386d7f5d3SJohn Marino void RCS_addaccess (RCSNode *, char *);
24486d7f5d3SJohn Marino void RCS_delaccess (RCSNode *, char *);
24586d7f5d3SJohn Marino char *RCS_getaccess (RCSNode *);
24686d7f5d3SJohn Marino void RCS_rewrite (RCSNode *, Deltatext *, char *);
24786d7f5d3SJohn Marino void RCS_abandon (RCSNode *);
24886d7f5d3SJohn Marino int rcs_change_text (const char *, char *, size_t, const char *,
24986d7f5d3SJohn Marino 		     size_t, char **, size_t *);
25086d7f5d3SJohn Marino void RCS_deltas (RCSNode *, FILE *, struct rcsbuffer *, const char *,
25186d7f5d3SJohn Marino 		 enum rcs_delta_op, char **, size_t *,
25286d7f5d3SJohn Marino 		 char **, size_t *);
25386d7f5d3SJohn Marino void RCS_setincexc (void **, const char *arg);
25486d7f5d3SJohn Marino void RCS_setlocalid (const char *, unsigned int, void **, const char *arg);
25586d7f5d3SJohn Marino char *make_file_label (const char *, const char *, RCSNode *);
25686d7f5d3SJohn Marino 
25786d7f5d3SJohn Marino extern bool preserve_perms;
25886d7f5d3SJohn Marino 
25986d7f5d3SJohn Marino /* From import.c.  */
26086d7f5d3SJohn Marino extern int add_rcs_file (const char *, const char *, const char *,
26186d7f5d3SJohn Marino                          const char *, const char *, const char *,
26286d7f5d3SJohn Marino                          const char *, int, char **, const char *, size_t,
26386d7f5d3SJohn Marino                          FILE *, bool);
26486d7f5d3SJohn Marino void free_keywords (void *keywords);
265