/contrib/cvs/src/rcs.h

https://bitbucket.org/freebsd/freebsd-head/ · C++ Header · 266 lines · 137 code · 39 blank · 90 comment · 0 complexity · a6bbcc04e3f3ceeeafa1de580b9b29c3 MD5 · raw file

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