Annotation of src/usr.bin/cvs/cvs.h, Revision 1.178
1.178 ! ray 1: /* $OpenBSD: cvs.h,v 1.177 2010/07/23 08:31:19 ray Exp $ */
1.1 jfb 2: /*
3: * Copyright (c) 2004 Jean-Francois Brousseau <jfb@openbsd.org>
1.35 tedu 4: * All rights reserved.
1.1 jfb 5: *
1.35 tedu 6: * Redistribution and use in source and binary forms, with or without
7: * modification, are permitted provided that the following conditions
8: * are met:
1.1 jfb 9: *
1.35 tedu 10: * 1. Redistributions of source code must retain the above copyright
11: * notice, this list of conditions and the following disclaimer.
1.1 jfb 12: * 2. The name of the author may not be used to endorse or promote products
1.35 tedu 13: * derived from this software without specific prior written permission.
1.1 jfb 14: *
15: * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
16: * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
17: * AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
18: * THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
19: * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
20: * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
21: * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
22: * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
23: * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
1.35 tedu 24: * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
1.1 jfb 25: */
26:
27: #ifndef CVS_H
28: #define CVS_H
1.9 jfb 29:
1.134 otto 30: #include <signal.h>
31:
32: #include "config.h"
33: #include "file.h"
34: #include "log.h"
35: #include "worklist.h"
36: #include "repository.h"
1.167 joris 37: #include "trigger.h"
1.128 niallo 38: #include "util.h"
1.104 joris 39: #include "xmalloc.h"
1.1 jfb 40:
1.174 joris 41: #define CVS_VERSION "OpenCVS 4.5"
1.1 jfb 42:
1.135 xsa 43: #define CVS_CKSUM_LEN MD5_DIGEST_STRING_LENGTH
1.140 xsa 44:
45: #define CVS_REV_BUFSZ 32
46: #define CVS_TIME_BUFSZ 64
1.161 xsa 47:
48: #define CVS_DATE_FMT "%Y.%m.%d.%H.%M.%S"
1.1 jfb 49:
50: /* operations */
1.74 xsa 51: #define CVS_OP_UNKNOWN 0
52: #define CVS_OP_ADD 1
53: #define CVS_OP_ADMIN 2
54: #define CVS_OP_ANNOTATE 3
55: #define CVS_OP_CHECKOUT 4
56: #define CVS_OP_COMMIT 5
57: #define CVS_OP_DIFF 6
58: #define CVS_OP_EDIT 7
59: #define CVS_OP_EDITORS 8
60: #define CVS_OP_EXPORT 9
61: #define CVS_OP_HISTORY 10
62: #define CVS_OP_IMPORT 11
63: #define CVS_OP_INIT 12
64: #define CVS_OP_LOG 13
65: #define CVS_OP_RANNOTATE 14
66: #define CVS_OP_RDIFF 15
67: #define CVS_OP_RELEASE 16
68: #define CVS_OP_REMOVE 17
69: #define CVS_OP_RLOG 18
70: #define CVS_OP_RTAG 19
71: #define CVS_OP_SERVER 20
72: #define CVS_OP_STATUS 21
73: #define CVS_OP_TAG 22
74: #define CVS_OP_UNEDIT 23
75: #define CVS_OP_UPDATE 24
76: #define CVS_OP_VERSION 25
77: #define CVS_OP_WATCH 26
78: #define CVS_OP_WATCHERS 27
1.1 jfb 79:
80: /* methods */
1.74 xsa 81: #define CVS_METHOD_NONE 0
82: #define CVS_METHOD_LOCAL 1 /* local access */
83: #define CVS_METHOD_SERVER 2 /* tunnel through CVS_RSH */
84: #define CVS_METHOD_PSERVER 3 /* cvs pserver */
85: #define CVS_METHOD_KSERVER 4 /* kerberos */
86: #define CVS_METHOD_GSERVER 5 /* gssapi server */
87: #define CVS_METHOD_EXT 6
88: #define CVS_METHOD_FORK 7 /* local but fork */
89:
90: #define CVS_CMD_MAXNAMELEN 16
91: #define CVS_CMD_MAXALIAS 2
92: #define CVS_CMD_MAXDESCRLEN 64
1.1 jfb 93:
1.149 tobias 94: /* flags */
1.164 joris 95: #define CVS_USE_WDIR 0x01
96: #define CVS_LOCK_REPO 0x02
1.149 tobias 97:
1.1 jfb 98: /* defaults */
1.74 xsa 99: #define CVS_SERVER_DEFAULT "cvs"
100: #define CVS_RSH_DEFAULT "ssh"
101: #define CVS_EDITOR_DEFAULT "vi"
1.77 xsa 102: #define CVS_TMPDIR_DEFAULT "/tmp"
1.107 joris 103: #define CVS_UMASK_DEFAULT 002
1.1 jfb 104:
1.70 xsa 105: /* extensions */
106: #define CVS_DESCR_FILE_EXT ",t"
1.1 jfb 107:
108: /* server-side paths */
1.108 joris 109: #define CVS_PATH_DEVNULL "/dev/null"
1.74 xsa 110: #define CVS_PATH_ROOT "CVSROOT"
111: #define CVS_PATH_EMPTYDIR CVS_PATH_ROOT "/Emptydir"
1.112 xsa 112: #define CVS_PATH_CHECKOUTLIST CVS_PATH_ROOT "/checkoutlist"
1.74 xsa 113: #define CVS_PATH_COMMITINFO CVS_PATH_ROOT "/commitinfo"
114: #define CVS_PATH_CONFIG CVS_PATH_ROOT "/config"
115: #define CVS_PATH_CVSIGNORE CVS_PATH_ROOT "/cvsignore"
116: #define CVS_PATH_CVSWRAPPERS CVS_PATH_ROOT "/cvswrappers"
117: #define CVS_PATH_EDITINFO CVS_PATH_ROOT "/editinfo"
118: #define CVS_PATH_HISTORY CVS_PATH_ROOT "/history"
119: #define CVS_PATH_LOGINFO CVS_PATH_ROOT "/loginfo"
120: #define CVS_PATH_MODULES CVS_PATH_ROOT "/modules"
1.101 xsa 121: #define CVS_PATH_NOTIFY_R CVS_PATH_ROOT "/notify"
1.74 xsa 122: #define CVS_PATH_RCSINFO CVS_PATH_ROOT "/rcsinfo"
123: #define CVS_PATH_TAGINFO CVS_PATH_ROOT "/taginfo"
1.112 xsa 124: #define CVS_PATH_VALTAGS CVS_PATH_ROOT "/val-tags"
1.74 xsa 125: #define CVS_PATH_VERIFYMSG CVS_PATH_ROOT "/verifymsg"
1.1 jfb 126:
127: /* client-side paths */
1.74 xsa 128: #define CVS_PATH_RC ".cvsrc"
129: #define CVS_PATH_CVSDIR "CVS"
1.100 xsa 130: #define CVS_PATH_BASEDIR CVS_PATH_CVSDIR "/Base"
131: #define CVS_PATH_BASEREV CVS_PATH_CVSDIR "/Baserev"
132: #define CVS_PATH_BASEREVTMP CVS_PATH_CVSDIR "/Baserev.tmp"
133: #define CVS_PATH_CHECKINPROG CVS_PATH_CVSDIR "/Checkin.prog"
1.74 xsa 134: #define CVS_PATH_ENTRIES CVS_PATH_CVSDIR "/Entries"
135: #define CVS_PATH_STATICENTRIES CVS_PATH_CVSDIR "/Entries.Static"
136: #define CVS_PATH_LOGENTRIES CVS_PATH_CVSDIR "/Entries.Log"
1.89 joris 137: #define CVS_PATH_BACKUPENTRIES CVS_PATH_CVSDIR "/Entries.Backup"
1.100 xsa 138: #define CVS_PATH_NOTIFY CVS_PATH_CVSDIR "/Notify"
139: #define CVS_PATH_NOTIFYTMP CVS_PATH_CVSDIR "/Notify.tmp"
1.74 xsa 140: #define CVS_PATH_ROOTSPEC CVS_PATH_CVSDIR "/Root"
141: #define CVS_PATH_REPOSITORY CVS_PATH_CVSDIR "/Repository"
1.81 xsa 142: #define CVS_PATH_TAG CVS_PATH_CVSDIR "/Tag"
1.100 xsa 143: #define CVS_PATH_TEMPLATE CVS_PATH_CVSDIR "/Template"
144: #define CVS_PATH_UPDATEPROG CVS_PATH_CVSDIR "/Update.prog"
1.110 joris 145: #define CVS_PATH_ATTIC "Attic"
1.1 jfb 146:
1.136 joris 147: /* history stuff */
148: #define CVS_HISTORY_TAG 0
149: #define CVS_HISTORY_CHECKOUT 1
150: #define CVS_HISTORY_EXPORT 2
151: #define CVS_HISTORY_RELEASE 3
152: #define CVS_HISTORY_UPDATE_REMOVE 4
153: #define CVS_HISTORY_UPDATE_CO 5
154: #define CVS_HISTORY_UPDATE_MERGED 6
155: #define CVS_HISTORY_UPDATE_MERGED_ERR 7
156: #define CVS_HISTORY_COMMIT_MODIFIED 8
157: #define CVS_HISTORY_COMMIT_ADDED 9
158: #define CVS_HISTORY_COMMIT_REMOVED 10
159:
160: void cvs_history_add(int, struct cvs_file *, const char *);
161:
1.46 joris 162: struct cvs_cmd {
1.103 joris 163: u_int cmd_op;
1.149 tobias 164: u_int cmd_flags;
1.86 reyk 165: char cmd_name[CVS_CMD_MAXNAMELEN];
166: char cmd_alias[CVS_CMD_MAXALIAS][CVS_CMD_MAXNAMELEN];
167: char cmd_descr[CVS_CMD_MAXDESCRLEN];
168: char *cmd_synopsis;
169: char *cmd_opts;
170: char *cmd_defargs;
1.58 jfb 171:
1.104 joris 172: int (*cmd)(int, char **);
173: };
174:
175: struct cvsroot;
1.58 jfb 176:
1.104 joris 177: struct cvs_recursion {
178: void (*enterdir)(struct cvs_file *);
179: void (*leavedir)(struct cvs_file *);
1.114 joris 180: void (*fileproc)(struct cvs_file *);
1.106 joris 181: int flags;
1.46 joris 182: };
1.106 joris 183:
184: #define CR_RECURSE_DIRS 0x01
185: #define CR_ATTIC 0x02
186: #define CR_REPO 0x04
1.1 jfb 187:
1.41 jfb 188: struct cvs_var {
189: char *cv_name;
190: char *cv_val;
191: TAILQ_ENTRY(cvs_var) cv_link;
192: };
1.122 xsa 193:
194: TAILQ_HEAD(, cvs_var) cvs_variables;
1.41 jfb 195:
1.74 xsa 196: #define CVS_ROOT_CONNECTED 0x01
1.36 jfb 197:
1.1 jfb 198: struct cvsroot {
1.11 jfb 199: char *cr_str;
1.1 jfb 200: u_int cr_method;
201: char *cr_buf;
202: char *cr_user;
203: char *cr_pass;
204: char *cr_host;
205: char *cr_dir;
1.145 joris 206: u_int cr_port;
1.11 jfb 207:
208: /* connection data */
209: FILE *cr_srvin;
210: FILE *cr_srvout;
1.21 jfb 211: FILE *cr_srverr;
1.1 jfb 212: };
1.74 xsa 213:
214: #define CVS_HIST_ADDED 'A'
215: #define CVS_HIST_EXPORT 'E'
216: #define CVS_HIST_RELEASE 'F'
217: #define CVS_HIST_MODIFIED 'M'
218: #define CVS_HIST_CHECKOUT 'O'
219: #define CVS_HIST_COMMIT 'R'
220: #define CVS_HIST_TAG 'T'
221:
222: #define CVS_DATE_DUMMY "dummy timestamp"
223: #define CVS_DATE_DMSEC (time_t)-1
224:
225: #define CVS_ENT_NONE 0
226: #define CVS_ENT_FILE 1
227: #define CVS_ENT_DIR 2
228:
229: #define CVS_ENT_REG 0
230: #define CVS_ENT_ADDED 1
231: #define CVS_ENT_REMOVED 2
232: #define CVS_ENT_UPTODATE 3
1.175 joris 233: #define CVS_ENT_UNKNOWN 4
1.80 xsa 234:
235: #define CVS_ENT_MAXLINELEN 1024
1.1 jfb 236:
1.104 joris 237: #define ENT_NOSYNC 0
238: #define ENT_SYNC 1
1.17 jfb 239:
1.85 joris 240: #define STRIP_SLASH(p) \
241: do { \
242: size_t _slen; \
243: _slen = strlen(p); \
244: while ((_slen > 0) && (p[_slen - 1] == '/')) \
245: p[--_slen] = '\0'; \
246: } while (0)
1.104 joris 247:
1.1 jfb 248: struct cvs_ent {
1.104 joris 249: char *ce_buf;
1.159 joris 250: char *ce_conflict;
1.104 joris 251: char *ce_name;
252: char *ce_opts;
253: char *ce_tag;
1.160 joris 254: time_t ce_date;
1.104 joris 255: time_t ce_mtime;
256: u_int16_t ce_type;
257: u_int16_t ce_status;
258: RCSNUM *ce_rev;
259: };
260:
261: struct cvs_ent_line {
262: char *buf;
263: TAILQ_ENTRY(cvs_ent_line) entries_list;
1.1 jfb 264: };
265:
266: typedef struct cvs_entries {
1.74 xsa 267: char *cef_path;
1.89 joris 268: char *cef_bpath;
1.104 joris 269: char *cef_lpath;
1.1 jfb 270:
1.104 joris 271: TAILQ_HEAD(, cvs_ent_line) cef_ent;
1.1 jfb 272: } CVSENTRIES;
1.157 joris 273:
274: extern char *checkout_target_dir;
1.163 joris 275: extern char *cvs_join_rev1;
276: extern char *cvs_join_rev2;
1.151 joris 277:
278: extern struct module_checkout *current_module;
279: extern char *module_repo_root;
1.1 jfb 280:
1.152 joris 281: extern struct ignore_head checkout_ign_pats;
1.177 ray 282: extern struct wklhead temp_files;
1.104 joris 283: extern volatile sig_atomic_t sig_received;
284: extern volatile sig_atomic_t cvs_quit;
285: extern struct cvsroot *current_cvsroot;
1.107 joris 286: extern char *cvs_tagname;
1.18 jfb 287: extern char *cvs_editor;
1.76 xsa 288: extern char *cvs_homedir;
1.30 krapht 289: extern char *cvs_msg;
1.42 jfb 290: extern char *cvs_rsh;
1.77 xsa 291: extern char *cvs_tmpdir;
1.110 joris 292: extern char *import_repository;
1.116 joris 293: extern char *cvs_server_path;
1.155 tobias 294: extern time_t cvs_specified_date;
1.168 tobias 295: extern time_t cvs_directory_date;
1.141 joris 296: extern char *cvs_specified_tag;
1.146 joris 297: extern char *cvs_directory_tag;
1.22 jfb 298:
1.107 joris 299: extern int cvs_umask;
1.42 jfb 300: extern int verbosity;
301: extern int cvs_trace;
302: extern int cvs_nolog;
303: extern int cvs_compress;
304: extern int cvs_cmdop;
305: extern int cvs_nocase;
1.57 xsa 306: extern int cvs_noexec;
1.42 jfb 307: extern int cvs_readonly;
1.124 xsa 308: extern int cvs_readonlyfs;
1.116 joris 309: extern int cvs_server_active;
1.156 tobias 310: extern int reset_option;
311: extern int reset_tag;
1.153 tobias 312: extern int kflag;
1.15 jfb 313:
1.148 tobias 314: extern struct cvs_cmd *cmdp;
1.58 jfb 315: extern struct cvs_cmd *cvs_cdt[];
1.1 jfb 316:
1.58 jfb 317: extern struct cvs_cmd cvs_cmd_add;
318: extern struct cvs_cmd cvs_cmd_admin;
319: extern struct cvs_cmd cvs_cmd_annotate;
320: extern struct cvs_cmd cvs_cmd_checkout;
321: extern struct cvs_cmd cvs_cmd_commit;
322: extern struct cvs_cmd cvs_cmd_diff;
323: extern struct cvs_cmd cvs_cmd_edit;
324: extern struct cvs_cmd cvs_cmd_editors;
325: extern struct cvs_cmd cvs_cmd_export;
326: extern struct cvs_cmd cvs_cmd_history;
327: extern struct cvs_cmd cvs_cmd_import;
328: extern struct cvs_cmd cvs_cmd_init;
329: extern struct cvs_cmd cvs_cmd_log;
1.150 tobias 330: extern struct cvs_cmd cvs_cmd_rannotate;
1.58 jfb 331: extern struct cvs_cmd cvs_cmd_rdiff;
332: extern struct cvs_cmd cvs_cmd_release;
333: extern struct cvs_cmd cvs_cmd_remove;
334: extern struct cvs_cmd cvs_cmd_rlog;
335: extern struct cvs_cmd cvs_cmd_rtag;
336: extern struct cvs_cmd cvs_cmd_status;
337: extern struct cvs_cmd cvs_cmd_tag;
338: extern struct cvs_cmd cvs_cmd_update;
339: extern struct cvs_cmd cvs_cmd_version;
340: extern struct cvs_cmd cvs_cmd_server;
341: extern struct cvs_cmd cvs_cmd_unedit;
342: extern struct cvs_cmd cvs_cmd_watch;
343: extern struct cvs_cmd cvs_cmd_watchers;
1.169 tobias 344:
345: /* add.c */
346: void cvs_add_tobranch(struct cvs_file *, char *);
1.58 jfb 347:
1.104 joris 348: /* cmd.c */
1.74 xsa 349: struct cvs_cmd *cvs_findcmd(const char *);
350:
1.104 joris 351: /* cvs.c */
1.165 tobias 352: int cvs_build_cmd(char ***, char **, int);
1.74 xsa 353: int cvs_var_set(const char *, const char *);
354: int cvs_var_unset(const char *);
355: const char *cvs_var_get(const char *);
1.104 joris 356: void cvs_cleanup(void);
1.1 jfb 357:
1.104 joris 358: /* date.y */
1.178 ! ray 359: time_t date_parse(const char *);
1.104 joris 360:
361: /* entries.c */
362: struct cvs_ent *cvs_ent_parse(const char *);
363: struct cvs_ent *cvs_ent_get(CVSENTRIES *, const char *);
364: CVSENTRIES *cvs_ent_open(const char *);
1.162 deraadt 365: void cvs_ent_add(CVSENTRIES *, const char *);
366: void cvs_ent_remove(CVSENTRIES *, const char *);
367: void cvs_ent_close(CVSENTRIES *, int);
1.104 joris 368: void cvs_ent_free(struct cvs_ent *);
1.158 xsa 369: void cvs_ent_line_str(const char *, char *, char *, char *, char *,
370: int, int, char *, size_t);
1.113 xsa 371: void cvs_parse_tagfile(char *, char **, char **, int *);
1.154 tobias 372: void cvs_write_tagfile(const char *, char *, char *);
1.1 jfb 373:
1.69 xsa 374: /* root.c */
1.104 joris 375: struct cvsroot *cvsroot_get(const char *);
1.126 joris 376:
377: /* logmsg.c */
1.167 joris 378: char *cvs_logmsg_read(const char *);
379: char *cvs_logmsg_create(char *, struct cvs_flisthead *,
380: struct cvs_flisthead *, struct cvs_flisthead *);
381: int cvs_logmsg_verify(char *);
1.87 joris 382:
1.104 joris 383: /* misc stuff */
384: void cvs_update_local(struct cvs_file *);
385: void cvs_update_enterdir(struct cvs_file *);
1.105 joris 386: void cvs_update_leavedir(struct cvs_file *);
1.147 joris 387: void cvs_checkout_file(struct cvs_file *, RCSNUM *, char *, int);
1.163 joris 388: void cvs_remove_local(struct cvs_file *);
389: void cvs_add_local(struct cvs_file *);
1.109 joris 390: int update_has_conflict_markers(struct cvs_file *);
391:
392: #define CO_MERGE 0x01
1.111 joris 393: #define CO_SETSTICKY 0x02
1.115 reyk 394: #define CO_DUMP 0x04
1.125 joris 395: #define CO_COMMIT 0x08
1.138 joris 396: #define CO_REMOVE 0x10
1.116 joris 397:
398: /* commands */
1.117 xsa 399: int cvs_add(int, char **);
1.120 xsa 400: int cvs_admin(int, char **);
1.123 xsa 401: int cvs_annotate(int, char **);
1.131 xsa 402: int cvs_checkout(int, char **);
1.116 joris 403: int cvs_commit(int, char **);
404: int cvs_diff(int, char **);
1.127 xsa 405: int cvs_edit(int, char **);
406: int cvs_editors(int, char **);
1.131 xsa 407: int cvs_export(int, char **);
1.118 xsa 408: int cvs_getlog(int, char **);
1.136 joris 409: int cvs_history(int, char **);
1.132 xsa 410: int cvs_import(int, char **);
1.119 xsa 411: int cvs_init(int, char **);
1.137 xsa 412: int cvs_release(int, char **);
1.117 xsa 413: int cvs_remove(int, char **);
1.116 joris 414: int cvs_status(int, char **);
1.118 xsa 415: int cvs_tag(int, char **);
1.127 xsa 416: int cvs_unedit(int, char **);
1.116 joris 417: int cvs_update(int, char **);
1.121 xsa 418: int cvs_version(int, char **);
1.127 xsa 419: int cvs_watch(int, char **);
420: int cvs_watchers(int, char **);
1.134 otto 421:
1.1 jfb 422:
1.91 joris 423: #endif