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