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