Annotation of src/usr.bin/cvs/cvs.h, Revision 1.137
1.137 ! xsa 1: /* $OpenBSD: cvs.h,v 1.136 2007/06/18 17:54:13 joris 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.128 niallo 37: #include "util.h"
1.104 joris 38: #include "xmalloc.h"
1.1 jfb 39:
1.104 joris 40: #define CVS_VERSION_MINOR "0"
41: #define CVS_VERSION_MAJOR "1"
42: #define CVS_VERSION_PORT
43:
44: #define CVS_VERSION \
45: "OpenCVS version " \
46: CVS_VERSION_MAJOR "." CVS_VERSION_MINOR CVS_VERSION_PORT
1.1 jfb 47:
1.74 xsa 48: #define CVS_HIST_CACHE 128
49: #define CVS_HIST_NBFLD 6
1.1 jfb 50:
1.135 xsa 51: #define CVS_CKSUM_LEN MD5_DIGEST_STRING_LENGTH
1.1 jfb 52:
53: /* operations */
1.74 xsa 54: #define CVS_OP_UNKNOWN 0
55: #define CVS_OP_ADD 1
56: #define CVS_OP_ADMIN 2
57: #define CVS_OP_ANNOTATE 3
58: #define CVS_OP_CHECKOUT 4
59: #define CVS_OP_COMMIT 5
60: #define CVS_OP_DIFF 6
61: #define CVS_OP_EDIT 7
62: #define CVS_OP_EDITORS 8
63: #define CVS_OP_EXPORT 9
64: #define CVS_OP_HISTORY 10
65: #define CVS_OP_IMPORT 11
66: #define CVS_OP_INIT 12
67: #define CVS_OP_LOG 13
68: #define CVS_OP_RANNOTATE 14
69: #define CVS_OP_RDIFF 15
70: #define CVS_OP_RELEASE 16
71: #define CVS_OP_REMOVE 17
72: #define CVS_OP_RLOG 18
73: #define CVS_OP_RTAG 19
74: #define CVS_OP_SERVER 20
75: #define CVS_OP_STATUS 21
76: #define CVS_OP_TAG 22
77: #define CVS_OP_UNEDIT 23
78: #define CVS_OP_UPDATE 24
79: #define CVS_OP_VERSION 25
80: #define CVS_OP_WATCH 26
81: #define CVS_OP_WATCHERS 27
1.1 jfb 82:
1.74 xsa 83: #define CVS_OP_ANY 64 /* all operations */
1.1 jfb 84:
85: /* methods */
1.74 xsa 86: #define CVS_METHOD_NONE 0
87: #define CVS_METHOD_LOCAL 1 /* local access */
88: #define CVS_METHOD_SERVER 2 /* tunnel through CVS_RSH */
89: #define CVS_METHOD_PSERVER 3 /* cvs pserver */
90: #define CVS_METHOD_KSERVER 4 /* kerberos */
91: #define CVS_METHOD_GSERVER 5 /* gssapi server */
92: #define CVS_METHOD_EXT 6
93: #define CVS_METHOD_FORK 7 /* local but fork */
94:
95: #define CVS_CMD_MAXNAMELEN 16
96: #define CVS_CMD_MAXALIAS 2
97: #define CVS_CMD_MAXDESCRLEN 64
98: #define CVS_CMD_MAXARG 128
1.1 jfb 99:
100: /* defaults */
1.74 xsa 101: #define CVS_SERVER_DEFAULT "cvs"
102: #define CVS_RSH_DEFAULT "ssh"
103: #define CVS_EDITOR_DEFAULT "vi"
1.77 xsa 104: #define CVS_TMPDIR_DEFAULT "/tmp"
1.107 joris 105: #define CVS_UMASK_DEFAULT 002
1.1 jfb 106:
1.70 xsa 107: /* extensions */
108: #define CVS_DESCR_FILE_EXT ",t"
1.1 jfb 109:
110: /* server-side paths */
1.108 joris 111: #define CVS_PATH_DEVNULL "/dev/null"
1.74 xsa 112: #define CVS_PATH_ROOT "CVSROOT"
113: #define CVS_PATH_EMPTYDIR CVS_PATH_ROOT "/Emptydir"
1.112 xsa 114: #define CVS_PATH_CHECKOUTLIST CVS_PATH_ROOT "/checkoutlist"
1.74 xsa 115: #define CVS_PATH_COMMITINFO CVS_PATH_ROOT "/commitinfo"
116: #define CVS_PATH_CONFIG CVS_PATH_ROOT "/config"
117: #define CVS_PATH_CVSIGNORE CVS_PATH_ROOT "/cvsignore"
118: #define CVS_PATH_CVSWRAPPERS CVS_PATH_ROOT "/cvswrappers"
119: #define CVS_PATH_EDITINFO CVS_PATH_ROOT "/editinfo"
120: #define CVS_PATH_HISTORY CVS_PATH_ROOT "/history"
121: #define CVS_PATH_LOGINFO CVS_PATH_ROOT "/loginfo"
122: #define CVS_PATH_MODULES CVS_PATH_ROOT "/modules"
1.101 xsa 123: #define CVS_PATH_NOTIFY_R CVS_PATH_ROOT "/notify"
1.74 xsa 124: #define CVS_PATH_RCSINFO CVS_PATH_ROOT "/rcsinfo"
125: #define CVS_PATH_TAGINFO CVS_PATH_ROOT "/taginfo"
1.112 xsa 126: #define CVS_PATH_VALTAGS CVS_PATH_ROOT "/val-tags"
1.74 xsa 127: #define CVS_PATH_VERIFYMSG CVS_PATH_ROOT "/verifymsg"
1.1 jfb 128:
129: /* client-side paths */
1.74 xsa 130: #define CVS_PATH_RC ".cvsrc"
131: #define CVS_PATH_CVSDIR "CVS"
1.100 xsa 132: #define CVS_PATH_BASEDIR CVS_PATH_CVSDIR "/Base"
133: #define CVS_PATH_BASEREV CVS_PATH_CVSDIR "/Baserev"
134: #define CVS_PATH_BASEREVTMP CVS_PATH_CVSDIR "/Baserev.tmp"
135: #define CVS_PATH_CHECKINPROG CVS_PATH_CVSDIR "/Checkin.prog"
1.74 xsa 136: #define CVS_PATH_ENTRIES CVS_PATH_CVSDIR "/Entries"
137: #define CVS_PATH_STATICENTRIES CVS_PATH_CVSDIR "/Entries.Static"
138: #define CVS_PATH_LOGENTRIES CVS_PATH_CVSDIR "/Entries.Log"
1.89 joris 139: #define CVS_PATH_BACKUPENTRIES CVS_PATH_CVSDIR "/Entries.Backup"
1.100 xsa 140: #define CVS_PATH_NOTIFY CVS_PATH_CVSDIR "/Notify"
141: #define CVS_PATH_NOTIFYTMP CVS_PATH_CVSDIR "/Notify.tmp"
1.74 xsa 142: #define CVS_PATH_ROOTSPEC CVS_PATH_CVSDIR "/Root"
143: #define CVS_PATH_REPOSITORY CVS_PATH_CVSDIR "/Repository"
1.81 xsa 144: #define CVS_PATH_TAG CVS_PATH_CVSDIR "/Tag"
1.100 xsa 145: #define CVS_PATH_TEMPLATE CVS_PATH_CVSDIR "/Template"
146: #define CVS_PATH_UPDATEPROG CVS_PATH_CVSDIR "/Update.prog"
1.110 joris 147: #define CVS_PATH_ATTIC "Attic"
1.1 jfb 148:
1.136 joris 149: /* history stuff */
150: #define CVS_HISTORY_TAG 0
151: #define CVS_HISTORY_CHECKOUT 1
152: #define CVS_HISTORY_EXPORT 2
153: #define CVS_HISTORY_RELEASE 3
154: #define CVS_HISTORY_UPDATE_REMOVE 4
155: #define CVS_HISTORY_UPDATE_CO 5
156: #define CVS_HISTORY_UPDATE_MERGED 6
157: #define CVS_HISTORY_UPDATE_MERGED_ERR 7
158: #define CVS_HISTORY_COMMIT_MODIFIED 8
159: #define CVS_HISTORY_COMMIT_ADDED 9
160: #define CVS_HISTORY_COMMIT_REMOVED 10
161:
162: void cvs_history_add(int, struct cvs_file *, const char *);
163:
1.46 joris 164: struct cvs_cmd {
1.103 joris 165: u_int cmd_op;
166: u_int cmd_req;
1.86 reyk 167: char cmd_name[CVS_CMD_MAXNAMELEN];
168: char cmd_alias[CVS_CMD_MAXALIAS][CVS_CMD_MAXNAMELEN];
169: char cmd_descr[CVS_CMD_MAXDESCRLEN];
170: char *cmd_synopsis;
171: char *cmd_opts;
172: char *cmd_defargs;
1.58 jfb 173:
1.104 joris 174: int (*cmd)(int, char **);
175: };
176:
177: struct cvsroot;
1.58 jfb 178:
1.104 joris 179: struct cvs_recursion {
180: void (*enterdir)(struct cvs_file *);
181: void (*leavedir)(struct cvs_file *);
1.114 joris 182: void (*fileproc)(struct cvs_file *);
1.106 joris 183: int flags;
1.46 joris 184: };
1.106 joris 185:
186: #define CR_RECURSE_DIRS 0x01
187: #define CR_ATTIC 0x02
188: #define CR_REPO 0x04
1.1 jfb 189:
1.41 jfb 190: struct cvs_var {
191: char *cv_name;
192: char *cv_val;
193: TAILQ_ENTRY(cvs_var) cv_link;
194: };
1.122 xsa 195:
196: TAILQ_HEAD(, cvs_var) cvs_variables;
1.41 jfb 197:
1.74 xsa 198: #define CVS_ROOT_CONNECTED 0x01
1.36 jfb 199:
1.1 jfb 200: struct cvsroot {
1.11 jfb 201: char *cr_str;
1.1 jfb 202: u_int cr_method;
203: char *cr_buf;
204: char *cr_user;
205: char *cr_pass;
206: char *cr_host;
207: char *cr_dir;
208: u_int cr_port;
1.11 jfb 209: u_int cr_ref;
210:
211: /* connection data */
1.36 jfb 212: u_int cr_flags;
1.11 jfb 213: FILE *cr_srvin;
214: FILE *cr_srvout;
1.21 jfb 215: FILE *cr_srverr;
1.29 jfb 216: char *cr_version; /* version of remote server */
217: u_char cr_vrmask[16]; /* mask of valid requests supported by server */
1.78 joris 218:
219: TAILQ_ENTRY(cvsroot) root_cache;
1.1 jfb 220: };
1.20 jfb 221:
1.74 xsa 222: #define CVS_SETVR(rt, rq) ((rt)->cr_vrmask[(rq) / 8] |= (1 << ((rq) % 8)))
223: #define CVS_GETVR(rt, rq) ((rt)->cr_vrmask[(rq) / 8] & (1 << ((rq) % 8)))
224: #define CVS_CLRVR(rt, rq) ((rt)->cr_vrmask[(rq) / 8] &= ~(1 << ((rq) % 8)))
225: #define CVS_RSTVR(rt) memset((rt)->cr_vrmask, 0, sizeof((rt)->cr_vrmask))
226:
227: #define CVS_HIST_ADDED 'A'
228: #define CVS_HIST_EXPORT 'E'
229: #define CVS_HIST_RELEASE 'F'
230: #define CVS_HIST_MODIFIED 'M'
231: #define CVS_HIST_CHECKOUT 'O'
232: #define CVS_HIST_COMMIT 'R'
233: #define CVS_HIST_TAG 'T'
234:
235: #define CVS_DATE_DUMMY "dummy timestamp"
236: #define CVS_DATE_DMSEC (time_t)-1
237:
238: #define CVS_ENT_NONE 0
239: #define CVS_ENT_FILE 1
240: #define CVS_ENT_DIR 2
241:
242: #define CVS_ENT_REG 0
243: #define CVS_ENT_ADDED 1
244: #define CVS_ENT_REMOVED 2
245: #define CVS_ENT_UPTODATE 3
1.80 xsa 246:
247: #define CVS_ENT_MAXLINELEN 1024
1.1 jfb 248:
1.104 joris 249: #define ENT_NOSYNC 0
250: #define ENT_SYNC 1
1.17 jfb 251:
1.85 joris 252: #define STRIP_SLASH(p) \
253: do { \
254: size_t _slen; \
255: _slen = strlen(p); \
256: while ((_slen > 0) && (p[_slen - 1] == '/')) \
257: p[--_slen] = '\0'; \
258: } while (0)
1.104 joris 259:
1.1 jfb 260: struct cvs_ent {
1.104 joris 261: char *ce_buf;
262: char *ce_name;
263: char *ce_opts;
264: char *ce_tag;
265: char *ce_conflict;
266: time_t ce_mtime;
267: u_int16_t ce_type;
268: u_int16_t ce_status;
269: RCSNUM *ce_rev;
270: };
271:
272: struct cvs_ent_line {
273: char *buf;
274: TAILQ_ENTRY(cvs_ent_line) entries_list;
1.1 jfb 275: };
276:
277: typedef struct cvs_entries {
1.74 xsa 278: char *cef_path;
1.89 joris 279: char *cef_bpath;
1.104 joris 280: char *cef_lpath;
1.1 jfb 281:
1.104 joris 282: TAILQ_HEAD(, cvs_ent_line) cef_ent;
1.1 jfb 283: } CVSENTRIES;
284:
1.104 joris 285: extern struct cvs_wklhead temp_files;
286: extern volatile sig_atomic_t sig_received;
287: extern volatile sig_atomic_t cvs_quit;
288: extern struct cvsroot *current_cvsroot;
1.107 joris 289: extern char *cvs_tagname;
1.22 jfb 290: extern char *cvs_command;
1.18 jfb 291: extern char *cvs_editor;
1.76 xsa 292: extern char *cvs_homedir;
1.30 krapht 293: extern char *cvs_msg;
1.42 jfb 294: extern char *cvs_rsh;
1.77 xsa 295: extern char *cvs_tmpdir;
1.110 joris 296: extern char *import_repository;
1.116 joris 297: extern char *cvs_server_path;
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.72 joris 309: extern int cvs_error;
1.116 joris 310: extern int cvs_server_active;
1.15 jfb 311:
1.58 jfb 312: extern struct cvs_cmd *cvs_cdt[];
1.1 jfb 313:
1.58 jfb 314: extern struct cvs_cmd cvs_cmd_add;
315: extern struct cvs_cmd cvs_cmd_admin;
316: extern struct cvs_cmd cvs_cmd_annotate;
317: extern struct cvs_cmd cvs_cmd_checkout;
318: extern struct cvs_cmd cvs_cmd_commit;
319: extern struct cvs_cmd cvs_cmd_diff;
320: extern struct cvs_cmd cvs_cmd_edit;
321: extern struct cvs_cmd cvs_cmd_editors;
322: extern struct cvs_cmd cvs_cmd_export;
323: extern struct cvs_cmd cvs_cmd_history;
324: extern struct cvs_cmd cvs_cmd_import;
325: extern struct cvs_cmd cvs_cmd_init;
326: extern struct cvs_cmd cvs_cmd_log;
327: extern struct cvs_cmd cvs_cmd_login;
328: extern struct cvs_cmd cvs_cmd_logout;
329: extern struct cvs_cmd cvs_cmd_rdiff;
330: extern struct cvs_cmd cvs_cmd_release;
331: extern struct cvs_cmd cvs_cmd_remove;
332: extern struct cvs_cmd cvs_cmd_rlog;
333: extern struct cvs_cmd cvs_cmd_rtag;
334: extern struct cvs_cmd cvs_cmd_status;
335: extern struct cvs_cmd cvs_cmd_tag;
336: extern struct cvs_cmd cvs_cmd_update;
337: extern struct cvs_cmd cvs_cmd_version;
338: extern struct cvs_cmd cvs_cmd_server;
339: extern struct cvs_cmd cvs_cmd_unedit;
340: extern struct cvs_cmd cvs_cmd_watch;
341: extern struct cvs_cmd cvs_cmd_watchers;
342:
1.104 joris 343: /* cmd.c */
1.74 xsa 344: struct cvs_cmd *cvs_findcmd(const char *);
1.133 otto 345: struct cvs_cmd *cvs_findcmdbyreq(u_int);
1.74 xsa 346:
1.104 joris 347: /* cvs.c */
1.74 xsa 348: int cvs_var_set(const char *, const char *);
349: int cvs_var_unset(const char *);
350: const char *cvs_var_get(const char *);
1.104 joris 351: void cvs_cleanup(void);
1.1 jfb 352:
1.104 joris 353: /* date.y */
354: time_t cvs_date_parse(const char *);
355:
356: /* entries.c */
357: struct cvs_ent *cvs_ent_parse(const char *);
358: struct cvs_ent *cvs_ent_get(CVSENTRIES *, const char *);
359: CVSENTRIES *cvs_ent_open(const char *);
360: void cvs_ent_add(CVSENTRIES *, const char *);
361: void cvs_ent_remove(CVSENTRIES *, const char *);
362: void cvs_ent_close(CVSENTRIES *, int);
363: void cvs_ent_free(struct cvs_ent *);
364: int cvs_ent_exists(CVSENTRIES *, const char *);
1.113 xsa 365: void cvs_parse_tagfile(char *, char **, char **, int *);
1.133 otto 366: void cvs_write_tagfile(const char *, char *, char *, int);
1.1 jfb 367:
1.69 xsa 368: /* root.c */
1.74 xsa 369: struct cvsroot *cvsroot_parse(const char *);
1.104 joris 370: struct cvsroot *cvsroot_get(const char *);
1.83 joris 371: void cvsroot_remove(struct cvsroot *);
1.126 joris 372:
373: /* logmsg.c */
374: char * cvs_logmsg_read(const char *path);
375: char * cvs_logmsg_create(struct cvs_flisthead *, struct cvs_flisthead *,
376: struct cvs_flisthead *);
1.87 joris 377:
1.104 joris 378: /* misc stuff */
379: void cvs_update_local(struct cvs_file *);
380: void cvs_update_enterdir(struct cvs_file *);
1.105 joris 381: void cvs_update_leavedir(struct cvs_file *);
1.129 joris 382: void cvs_checkout_file(struct cvs_file *, RCSNUM *, int);
1.109 joris 383: int update_has_conflict_markers(struct cvs_file *);
384:
385: #define CO_MERGE 0x01
1.111 joris 386: #define CO_SETSTICKY 0x02
1.115 reyk 387: #define CO_DUMP 0x04
1.125 joris 388: #define CO_COMMIT 0x08
1.116 joris 389:
390: /* commands */
1.117 xsa 391: int cvs_add(int, char **);
1.120 xsa 392: int cvs_admin(int, char **);
1.123 xsa 393: int cvs_annotate(int, char **);
1.131 xsa 394: int cvs_checkout(int, char **);
1.116 joris 395: int cvs_commit(int, char **);
396: int cvs_diff(int, char **);
1.127 xsa 397: int cvs_edit(int, char **);
398: int cvs_editors(int, char **);
1.131 xsa 399: int cvs_export(int, char **);
1.118 xsa 400: int cvs_getlog(int, char **);
1.136 joris 401: int cvs_history(int, char **);
1.132 xsa 402: int cvs_import(int, char **);
1.119 xsa 403: int cvs_init(int, char **);
1.137 ! xsa 404: int cvs_release(int, char **);
1.117 xsa 405: int cvs_remove(int, char **);
1.116 joris 406: int cvs_status(int, char **);
1.118 xsa 407: int cvs_tag(int, char **);
1.127 xsa 408: int cvs_unedit(int, char **);
1.116 joris 409: int cvs_update(int, char **);
1.121 xsa 410: int cvs_version(int, char **);
1.127 xsa 411: int cvs_watch(int, char **);
412: int cvs_watchers(int, char **);
1.134 otto 413:
1.1 jfb 414:
1.91 joris 415: #endif