1 /* $MirOS: src/gnu/usr.bin/cvs/src/rcs.h,v 1.5 2010/09/19 19:43:09 tg Exp $ */ 2 3 /* 4 * Copyright (C) 1986-2005 The Free Software Foundation, Inc. 5 * 6 * Portions Copyright (C) 1998-2005 Derek Price, Ximbiot <http://ximbiot.com>, 7 * and others. 8 * 9 * Portions Copyright (C) 1992, Brian Berliner and Jeff Polk 10 * Portions Copyright (C) 1989-1992, Brian Berliner 11 * 12 * You may distribute under the terms of the GNU General Public License as 13 * specified in the README file that comes with the CVS source distribution. 14 * 15 * RCS source control definitions needed by rcs.c and friends 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 "%02ld.%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 53 struct 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 /* Use when printing paths. */ 71 char *print_path; 72 73 /* Value for head keyword from RCS header, or NULL if empty. HEAD may only 74 * be empty in a valid RCS file when the file has no revisions, a state 75 * that should not be able to occur with CVS. 76 */ 77 char *head; 78 79 /* Value for branch keyword from RCS header, or NULL if omitted. */ 80 char *branch; 81 82 /* Raw data on symbolic revisions. The first time that RCS_symbols is 83 called, we parse these into ->symbols, and free ->symbols_data. */ 84 char *symbols_data; 85 86 /* Value for expand keyword from RCS header, or NULL if omitted. */ 87 char *expand; 88 89 /* List of nodes, the key of which is the symbolic name and the data 90 of which is the numeric revision that it corresponds to (malloc'd). */ 91 List *symbols; 92 93 /* List of nodes (type RCSVERS), the key of which the numeric revision 94 number, and the data of which is an RCSVers * for the revision. */ 95 List *versions; 96 97 /* Value for access keyword from RCS header, or NULL if empty. 98 FIXME: RCS_delaccess would also seem to use "" for empty. We 99 should pick one or the other. */ 100 char *access; 101 102 /* Raw data on locked revisions. The first time that RCS_getlocks is 103 called, we parse these into ->locks, and free ->locks_data. */ 104 char *locks_data; 105 106 /* List of nodes, the key of which is the numeric revision and the 107 data of which is the user that it corresponds to (malloc'd). */ 108 List *locks; 109 110 /* Set for the strict keyword from the RCS header. */ 111 int strict_locks; 112 113 /* Value for the comment keyword from RCS header (comment leader), or 114 NULL if omitted. */ 115 char *comment; 116 117 /* Value for the desc field in the RCS file, or NULL if empty. */ 118 char *desc; 119 120 /* File offset of the first deltatext node, so we can seek there. */ 121 off_t delta_pos; 122 123 /* Newphrases from the RCS header. List of nodes, the key of which 124 is the "id" which introduces the newphrase, and the value of which 125 is the value from the newphrase. */ 126 List *other; 127 }; 128 129 typedef struct rcsnode RCSNode; 130 131 struct deltatext { 132 char *version; 133 134 /* Log message, or NULL if we do not intend to change the log message 135 (that is, RCS_copydeltas should just use the log message from the 136 file). */ 137 char *log; 138 139 /* Change text, or NULL if we do not intend to change the change text 140 (that is, RCS_copydeltas should just use the change text from the 141 file). Note that it is perfectly valid to have log be NULL and 142 text non-NULL, or vice-versa. */ 143 char *text; 144 size_t len; 145 146 /* Newphrase fields from deltatext nodes. FIXME: duplicates the 147 other field in the rcsversnode, I think. */ 148 List *other; 149 }; 150 typedef struct deltatext Deltatext; 151 152 struct rcsversnode 153 { 154 /* Duplicate of the key by which this structure is indexed. */ 155 char *version; 156 157 char *date; 158 char *author; 159 char *state; 160 char *next; 161 int dead; 162 int outdated; 163 Deltatext *text; 164 List *branches; 165 /* Newphrase fields from deltatext nodes. Also contains ";add" and 166 ";delete" magic fields (see rcs.c, log.c). I think this is 167 only used by log.c (where it looks up "log"). Duplicates the 168 other field in struct deltatext, I think. */ 169 List *other; 170 /* Newphrase fields from delta nodes. */ 171 List *other_delta; 172 #ifdef PRESERVE_PERMISSIONS_SUPPORT 173 /* Hard link information for each revision. */ 174 List *hardlinks; 175 #endif 176 }; 177 typedef struct rcsversnode RCSVers; 178 179 /* 180 * CVS reserves all even-numbered branches for its own use. "magic" branches 181 * (see rcs.c) are contained as virtual revision numbers (within symbolic 182 * tags only) off the RCS_MAGIC_BRANCH, which is 0. CVS also reserves the 183 * ".1" branch for vendor revisions. So, if you do your own branching, you 184 * should limit your use to odd branch numbers starting at 3. 185 */ 186 #define RCS_MAGIC_BRANCH 0 187 188 /* The type of a function passed to RCS_checkout. */ 189 typedef void (*RCSCHECKOUTPROC) (void *, const char *, size_t); 190 191 struct rcsbuffer; 192 193 /* What RCS_deltas is supposed to do. */ 194 enum rcs_delta_op {RCS_ANNOTATE, RCS_ANNOTATE_BACKWARDS, RCS_FETCH}; 195 196 /* 197 * exported interfaces 198 */ 199 RCSNode *RCS_parse (const char *file, const char *repos); 200 RCSNode *RCS_parsercsfile (const char *rcsfile); 201 void RCS_fully_parse (RCSNode *); 202 void RCS_reparsercsfile (RCSNode *, FILE **, struct rcsbuffer *); 203 extern int RCS_setattic (RCSNode *, int); 204 205 char *RCS_check_kflag (const char *arg); 206 char *RCS_getdate (RCSNode * rcs, const char *date, int force_tag_match); 207 char *RCS_gettag (RCSNode * rcs, const char *symtag, int force_tag_match, 208 int *simple_tag); 209 int RCS_exist_rev (RCSNode *rcs, char *rev); 210 int RCS_exist_tag (RCSNode *rcs, char *tag); 211 char *RCS_tag2rev (RCSNode *rcs, char *tag); 212 char *RCS_getversion (RCSNode *rcs, const char *tag, const char *date, 213 int force_tag_match, int *simple_tag); 214 char *RCS_magicrev (RCSNode *rcs, char *rev); 215 int RCS_isbranch (RCSNode *rcs, const char *rev); 216 int RCS_nodeisbranch (RCSNode *rcs, const char *tag); 217 char *RCS_whatbranch (RCSNode *rcs, const char *tag); 218 char *RCS_head (RCSNode * rcs); 219 int RCS_datecmp (const char *date1, const char *date2); 220 time_t RCS_getrevtime (RCSNode * rcs, const char *rev, char *date, int fudge); 221 List *RCS_symbols (RCSNode *rcs); 222 void RCS_check_tag (const char *tag); 223 int RCS_valid_rev (const char *rev); 224 List *RCS_getlocks (RCSNode *rcs); 225 void freercsnode (RCSNode ** rnodep); 226 char *RCS_getbranch (RCSNode *rcs, const char *tag, int force_tag_match); 227 char *RCS_branch_head (RCSNode *rcs, char *rev); 228 229 int RCS_isdead (RCSNode *, const char *); 230 char *RCS_getexpand (RCSNode *); 231 void RCS_setexpand (RCSNode *, const char *); 232 int RCS_checkout (RCSNode *, const char *, const char *, const char *, 233 const char *, const char *, RCSCHECKOUTPROC, void *); 234 int RCS_checkin (RCSNode *rcs, const char *update_dir, const char *workfile, 235 const char *message, const char *rev, time_t citime, 236 int flags); 237 int RCS_cmp_file (RCSNode *, const char *, char **, const char *, const char *, 238 const char * ); 239 int RCS_settag (RCSNode *, const char *, const char *); 240 int RCS_deltag (RCSNode *, const char *); 241 int RCS_setbranch (RCSNode *, const char *); 242 int RCS_lock (RCSNode *, const char *, int); 243 int RCS_unlock (RCSNode *, char *, int); 244 int RCS_delete_revs (RCSNode *, char *, char *, int); 245 void RCS_addaccess (RCSNode *, char *); 246 void RCS_delaccess (RCSNode *, char *); 247 char *RCS_getaccess (RCSNode *); 248 void RCS_rewrite (RCSNode *, Deltatext *, char *); 249 void RCS_abandon (RCSNode *); 250 int rcs_change_text (const char *, char *, size_t, const char *, 251 size_t, char **, size_t *); 252 void RCS_deltas (RCSNode *, FILE *, struct rcsbuffer *, const char *, 253 enum rcs_delta_op, char **, size_t *, 254 char **, size_t *); 255 void RCS_setincexc (void **, const char *arg); 256 void RCS_setlocalid (const char *, unsigned int, void **, const char *arg); 257 char *make_file_label (const char *, const char *, RCSNode *); 258 259 extern bool preserve_perms; 260 261 /* From import.c. */ 262 extern int add_rcs_file (const char *, const char *, const char *, 263 const char *, const char *, const char *, 264 const char *, int, char **, const char *, size_t, 265 FILE *, bool); 266 void free_keywords (void *keywords); 267