Annotation of src/usr.bin/cvs/cvs.h, Revision 1.102
1.102 ! niallo 1: /* $OpenBSD: cvs.h,v 1.101 2006/02/10 10:15:48 xsa 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.1 jfb 30: #include "rcs.h"
1.19 jfb 31: #include "file.h"
1.102 ! niallo 32: #include "util.h"
1.91 joris 33: #include "xmalloc.h"
1.1 jfb 34:
1.98 xsa 35: #define CVS_VERSION "OpenCVS 0.3"
1.1 jfb 36:
1.74 xsa 37: #define CVS_HIST_CACHE 128
38: #define CVS_HIST_NBFLD 6
1.1 jfb 39:
40:
1.74 xsa 41: #define CVS_CKSUM_LEN 33 /* length of a CVS checksum string */
1.1 jfb 42:
1.50 joris 43: /* error codes */
1.66 xsa 44: #define CVS_EX_ERR -1
1.51 jfb 45: #define CVS_EX_OK 0
1.50 joris 46: #define CVS_EX_USAGE 1
47: #define CVS_EX_DATA 2
48: #define CVS_EX_PROTO 3
49: #define CVS_EX_FILE 4
1.99 xsa 50: #define CVS_EX_BADROOT 5
1.1 jfb 51:
52: /* operations */
1.74 xsa 53: #define CVS_OP_UNKNOWN 0
54: #define CVS_OP_ADD 1
55: #define CVS_OP_ADMIN 2
56: #define CVS_OP_ANNOTATE 3
57: #define CVS_OP_CHECKOUT 4
58: #define CVS_OP_COMMIT 5
59: #define CVS_OP_DIFF 6
60: #define CVS_OP_EDIT 7
61: #define CVS_OP_EDITORS 8
62: #define CVS_OP_EXPORT 9
63: #define CVS_OP_HISTORY 10
64: #define CVS_OP_IMPORT 11
65: #define CVS_OP_INIT 12
66: #define CVS_OP_LOG 13
67: #define CVS_OP_RANNOTATE 14
68: #define CVS_OP_RDIFF 15
69: #define CVS_OP_RELEASE 16
70: #define CVS_OP_REMOVE 17
71: #define CVS_OP_RLOG 18
72: #define CVS_OP_RTAG 19
73: #define CVS_OP_SERVER 20
74: #define CVS_OP_STATUS 21
75: #define CVS_OP_TAG 22
76: #define CVS_OP_UNEDIT 23
77: #define CVS_OP_UPDATE 24
78: #define CVS_OP_VERSION 25
79: #define CVS_OP_WATCH 26
80: #define CVS_OP_WATCHERS 27
1.1 jfb 81:
1.74 xsa 82: #define CVS_OP_ANY 64 /* all operations */
1.1 jfb 83:
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:
101: /* defaults */
1.74 xsa 102: #define CVS_SERVER_DEFAULT "cvs"
103: #define CVS_RSH_DEFAULT "ssh"
104: #define CVS_EDITOR_DEFAULT "vi"
1.77 xsa 105: #define CVS_TMPDIR_DEFAULT "/tmp"
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.74 xsa 111: #define CVS_PATH_ROOT "CVSROOT"
112: #define CVS_PATH_EMPTYDIR CVS_PATH_ROOT "/Emptydir"
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"
124: #define CVS_PATH_VERIFYMSG CVS_PATH_ROOT "/verifymsg"
1.1 jfb 125:
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.1 jfb 145:
1.46 joris 146:
147: /* flags for cmd_flags */
148: #define CVS_CMD_ALLOWSPEC 0x01
149: #define CVS_CMD_SENDARGS1 0x04
150: #define CVS_CMD_SENDARGS2 0x08
151: #define CVS_CMD_SENDDIR 0x10
1.60 joris 152: #define CVS_CMD_PRUNEDIRS 0x20
1.46 joris 153:
1.58 jfb 154:
1.46 joris 155: struct cvs_cmd {
1.86 reyk 156: int cmd_op;
157: int cmd_req;
158: char cmd_name[CVS_CMD_MAXNAMELEN];
159: char cmd_alias[CVS_CMD_MAXALIAS][CVS_CMD_MAXNAMELEN];
160: char cmd_descr[CVS_CMD_MAXDESCRLEN];
161: char *cmd_synopsis;
162: char *cmd_opts;
163: char *cmd_defargs;
164: int file_flags;
1.58 jfb 165:
166: /* operations vector */
1.86 reyk 167: int (*cmd_init)(struct cvs_cmd *, int, char **, int *);
168: int (*cmd_pre_exec)(struct cvsroot *);
169: int (*cmd_exec_remote)(CVSFILE *, void *);
170: int (*cmd_exec_local)(CVSFILE *, void *);
171: int (*cmd_post_exec)(struct cvsroot *);
172: int (*cmd_cleanup)(void);
1.58 jfb 173:
174: /* flags for cvs_file_get() */
1.86 reyk 175: int cmd_flags;
1.46 joris 176: };
1.1 jfb 177:
1.7 jfb 178: struct cvs_file;
179: struct cvs_dir;
1.19 jfb 180: struct cvs_flist;
1.7 jfb 181:
1.41 jfb 182: struct cvs_var {
183: char *cv_name;
184: char *cv_val;
185: TAILQ_ENTRY(cvs_var) cv_link;
186: };
187:
188:
189:
1.1 jfb 190: struct cvs_op {
1.19 jfb 191: u_int co_op;
192: uid_t co_uid; /* user performing the operation */
193: char *co_tag; /* tag or branch, NULL if HEAD */
194: char *co_msg; /* message string (on commit or add) */
195: struct cvs_flist co_files;
1.1 jfb 196: };
197:
198:
1.74 xsa 199: #define CVS_ROOT_CONNECTED 0x01
1.36 jfb 200:
1.1 jfb 201: struct cvsroot {
1.11 jfb 202: char *cr_str;
1.1 jfb 203: u_int cr_method;
204: char *cr_buf;
205: char *cr_user;
206: char *cr_pass;
207: char *cr_host;
208: char *cr_dir;
209: u_int cr_port;
1.11 jfb 210: u_int cr_ref;
211:
212: /* connection data */
1.36 jfb 213: u_int cr_flags;
1.11 jfb 214: FILE *cr_srvin;
215: FILE *cr_srvout;
1.21 jfb 216: FILE *cr_srverr;
1.29 jfb 217: char *cr_version; /* version of remote server */
218: u_char cr_vrmask[16]; /* mask of valid requests supported by server */
1.78 joris 219:
220: TAILQ_ENTRY(cvsroot) root_cache;
1.1 jfb 221: };
1.20 jfb 222:
1.74 xsa 223: #define CVS_SETVR(rt, rq) ((rt)->cr_vrmask[(rq) / 8] |= (1 << ((rq) % 8)))
224: #define CVS_GETVR(rt, rq) ((rt)->cr_vrmask[(rq) / 8] & (1 << ((rq) % 8)))
225: #define CVS_CLRVR(rt, rq) ((rt)->cr_vrmask[(rq) / 8] &= ~(1 << ((rq) % 8)))
226: #define CVS_RSTVR(rt) memset((rt)->cr_vrmask, 0, sizeof((rt)->cr_vrmask))
227:
228:
229: #define CVS_HIST_ADDED 'A'
230: #define CVS_HIST_EXPORT 'E'
231: #define CVS_HIST_RELEASE 'F'
232: #define CVS_HIST_MODIFIED 'M'
233: #define CVS_HIST_CHECKOUT 'O'
234: #define CVS_HIST_COMMIT 'R'
235: #define CVS_HIST_TAG 'T'
236:
237:
238: #define CVS_DATE_DUMMY "dummy timestamp"
239: #define CVS_DATE_DMSEC (time_t)-1
240:
241: #define CVS_ENT_NONE 0
242: #define CVS_ENT_FILE 1
243: #define CVS_ENT_DIR 2
244:
245: #define CVS_ENT_REG 0
246: #define CVS_ENT_ADDED 1
247: #define CVS_ENT_REMOVED 2
248: #define CVS_ENT_UPTODATE 3
1.80 xsa 249:
250: #define CVS_ENT_MAXLINELEN 1024
1.1 jfb 251:
1.74 xsa 252: #define CVS_ENTF_SYNC 0x01 /* contents of disk and memory match */
253: #define CVS_ENTF_WR 0x02 /* file is opened for writing too */
1.17 jfb 254:
1.85 joris 255: #define STRIP_SLASH(p) \
256: do { \
257: size_t _slen; \
258: _slen = strlen(p); \
259: while ((_slen > 0) && (p[_slen - 1] == '/')) \
260: p[--_slen] = '\0'; \
261: } while (0)
1.1 jfb 262: struct cvs_ent {
1.74 xsa 263: char *ce_buf;
264: u_int16_t ce_type;
265: u_int16_t ce_status;
266: char *ce_name;
267: RCSNUM *ce_rev;
268: time_t ce_mtime;
269: char *ce_opts;
270: char *ce_tag;
1.82 joris 271:
272: /*
273: * This variable is set to 1 if we have already processed this entry
274: * in the cvs_file_getdir() function. This is to avoid files being
275: * passed twice to the callbacks.
276: */
277: int processed;
1.74 xsa 278: TAILQ_ENTRY(cvs_ent) ce_list;
1.1 jfb 279: };
280:
281: typedef struct cvs_entries {
1.74 xsa 282: char *cef_path;
1.89 joris 283: char *cef_bpath;
1.74 xsa 284: u_int cef_flags;
1.1 jfb 285:
1.88 joris 286: TAILQ_HEAD(cvsentrieshead, cvs_ent) cef_ent;
1.74 xsa 287: struct cvs_ent *cef_cur;
1.1 jfb 288: } CVSENTRIES;
289:
290:
291: struct cvs_hent {
1.74 xsa 292: char ch_event;
293: time_t ch_date;
294: uid_t ch_uid;
295: char *ch_user;
296: char *ch_curdir;
297: char *ch_repo;
298: RCSNUM *ch_rev;
299: char *ch_arg;
1.1 jfb 300: };
301:
302:
303: typedef struct cvs_histfile {
1.74 xsa 304: int chf_fd;
305: char *chf_buf; /* read buffer */
306: size_t chf_blen; /* buffer size */
307: size_t chf_bused; /* bytes used in buffer */
308:
309: off_t chf_off; /* next read */
310: u_int chf_sindex; /* history entry index of first in array */
311: u_int chf_cindex; /* current index (for getnext()) */
312: u_int chf_nbhent; /* number of valid entries in the array */
1.1 jfb 313:
1.74 xsa 314: struct cvs_hent chf_hent[CVS_HIST_CACHE];
1.1 jfb 315:
316: } CVSHIST;
317:
318:
1.67 joris 319: extern char *cvs_req_modulename;
1.64 joris 320: extern char *cvs_repo_base;
1.22 jfb 321: extern char *cvs_command;
1.18 jfb 322: extern char *cvs_editor;
1.76 xsa 323: extern char *cvs_homedir;
1.30 krapht 324: extern char *cvs_msg;
1.42 jfb 325: extern char *cvs_rsh;
1.77 xsa 326: extern char *cvs_tmpdir;
1.22 jfb 327:
1.42 jfb 328: extern int verbosity;
329: extern int cvs_trace;
330: extern int cvs_nolog;
331: extern int cvs_compress;
332: extern int cvs_cmdop;
333: extern int cvs_nocase;
1.57 xsa 334: extern int cvs_noexec;
1.42 jfb 335: extern int cvs_readonly;
1.72 joris 336: extern int cvs_error;
1.23 jfb 337: extern CVSFILE *cvs_files;
1.15 jfb 338:
1.58 jfb 339: extern struct cvs_cmd *cvs_cdt[];
1.1 jfb 340:
1.58 jfb 341: extern struct cvs_cmd cvs_cmd_add;
342: extern struct cvs_cmd cvs_cmd_admin;
343: extern struct cvs_cmd cvs_cmd_annotate;
344: extern struct cvs_cmd cvs_cmd_checkout;
345: extern struct cvs_cmd cvs_cmd_commit;
346: extern struct cvs_cmd cvs_cmd_diff;
347: extern struct cvs_cmd cvs_cmd_edit;
348: extern struct cvs_cmd cvs_cmd_editors;
349: extern struct cvs_cmd cvs_cmd_export;
350: extern struct cvs_cmd cvs_cmd_history;
351: extern struct cvs_cmd cvs_cmd_import;
352: extern struct cvs_cmd cvs_cmd_init;
353: extern struct cvs_cmd cvs_cmd_log;
354: extern struct cvs_cmd cvs_cmd_login;
355: extern struct cvs_cmd cvs_cmd_logout;
356: extern struct cvs_cmd cvs_cmd_rdiff;
357: extern struct cvs_cmd cvs_cmd_release;
358: extern struct cvs_cmd cvs_cmd_remove;
359: extern struct cvs_cmd cvs_cmd_rlog;
360: extern struct cvs_cmd cvs_cmd_rtag;
361: extern struct cvs_cmd cvs_cmd_status;
362: extern struct cvs_cmd cvs_cmd_tag;
363: extern struct cvs_cmd cvs_cmd_update;
364: extern struct cvs_cmd cvs_cmd_version;
365: extern struct cvs_cmd cvs_cmd_server;
366: extern struct cvs_cmd cvs_cmd_unedit;
367: extern struct cvs_cmd cvs_cmd_watch;
368: extern struct cvs_cmd cvs_cmd_watchers;
369:
370:
1.74 xsa 371: struct cvs_cmd *cvs_findcmd(const char *);
372: struct cvs_cmd *cvs_findcmdbyreq(int);
373: int cvs_startcmd(struct cvs_cmd *, int, char **);
374: int cvs_server(int, char **);
375:
376: int cvs_var_set(const char *, const char *);
377: int cvs_var_unset(const char *);
378: const char *cvs_var_get(const char *);
1.1 jfb 379:
380:
1.69 xsa 381: /* root.c */
1.74 xsa 382: struct cvsroot *cvsroot_parse(const char *);
1.83 joris 383: void cvsroot_remove(struct cvsroot *);
1.74 xsa 384: struct cvsroot *cvsroot_get(const char *);
1.2 jfb 385:
386:
1.81 xsa 387: /* entries.c */
1.74 xsa 388: CVSENTRIES *cvs_ent_open(const char *, int);
389: struct cvs_ent *cvs_ent_get(CVSENTRIES *, const char *);
390: struct cvs_ent *cvs_ent_next(CVSENTRIES *);
391: int cvs_ent_add(CVSENTRIES *, struct cvs_ent *);
392: int cvs_ent_addln(CVSENTRIES *, const char *);
1.88 joris 393: int cvs_ent_remove(CVSENTRIES *, const char *, int);
1.74 xsa 394: int cvs_ent_write(CVSENTRIES *);
395: struct cvs_ent *cvs_ent_parse(const char *);
396: void cvs_ent_close(CVSENTRIES *);
397: void cvs_ent_free(struct cvs_ent *);
1.1 jfb 398:
399: /* history API */
1.74 xsa 400: CVSHIST *cvs_hist_open(const char *);
401: void cvs_hist_close(CVSHIST *);
402: int cvs_hist_parse(CVSHIST *);
403: struct cvs_hent *cvs_hist_getnext(CVSHIST *);
404: int cvs_hist_append(CVSHIST *, struct cvs_hent *);
1.1 jfb 405:
1.69 xsa 406: /* logmsg.c */
1.74 xsa 407: char *cvs_logmsg_open(const char *);
408: char *cvs_logmsg_get(const char *, struct cvs_flist *,
409: struct cvs_flist *, struct cvs_flist *);
1.94 joris 410: void cvs_logmsg_send(struct cvsroot *, const char *);
1.1 jfb 411:
1.69 xsa 412: /* date.y */
1.74 xsa 413: time_t cvs_date_parse(const char *);
1.87 joris 414:
415: /* XXX */
416: int rcs_patch_lines(struct cvs_lines *, struct cvs_lines *);
1.88 joris 417: int cvs_checkout_rev(RCSFILE *, RCSNUM *, CVSFILE *, char *, int, int, ...);
1.1 jfb 418:
1.91 joris 419: #endif