Annotation of src/usr.bin/cvs/cvs.h, Revision 1.72
1.72 ! joris 1: /* $OpenBSD: cvs.h,v 1.71 2005/07/23 10:49:35 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
29:
30: #include <sys/param.h>
1.63 xsa 31:
32: #include <dirent.h>
1.8 jfb 33: #include <stdio.h>
1.9 jfb 34:
1.1 jfb 35: #include "rcs.h"
1.19 jfb 36: #include "file.h"
1.1 jfb 37:
1.19 jfb 38: #define CVS_VERSION_MAJOR 0
1.58 jfb 39: #define CVS_VERSION_MINOR 3
40: #define CVS_VERSION "OpenCVS 0.3"
1.1 jfb 41:
42:
43: #define CVS_HIST_CACHE 128
44: #define CVS_HIST_NBFLD 6
45:
46:
47: #define CVS_CKSUM_LEN 33 /* length of a CVS checksum string */
48:
1.50 joris 49: /* error codes */
1.66 xsa 50: #define CVS_EX_ERR -1
1.51 jfb 51: #define CVS_EX_OK 0
1.50 joris 52: #define CVS_EX_USAGE 1
53: #define CVS_EX_DATA 2
54: #define CVS_EX_PROTO 3
55: #define CVS_EX_FILE 4
1.52 jfb 56: #define CVS_EX_BADTAG 5
1.53 jfb 57: #define CVS_EX_BADROOT 6
1.1 jfb 58:
59: /* operations */
1.19 jfb 60: #define CVS_OP_UNKNOWN 0
1.1 jfb 61: #define CVS_OP_ADD 1
1.43 jfb 62: #define CVS_OP_ADMIN 2
63: #define CVS_OP_ANNOTATE 3
64: #define CVS_OP_CHECKOUT 4
65: #define CVS_OP_COMMIT 5
66: #define CVS_OP_DIFF 6
67: #define CVS_OP_EDIT 7
68: #define CVS_OP_EDITORS 8
69: #define CVS_OP_EXPORT 9
1.68 joris 70: #define CVS_OP_HISTORY 10
1.43 jfb 71: #define CVS_OP_IMPORT 11
72: #define CVS_OP_INIT 12
73: #define CVS_OP_LOG 13
74: #define CVS_OP_RANNOTATE 14
75: #define CVS_OP_RDIFF 15
76: #define CVS_OP_RELEASE 16
77: #define CVS_OP_REMOVE 17
78: #define CVS_OP_RLOG 18
79: #define CVS_OP_RTAG 19
80: #define CVS_OP_SERVER 20
81: #define CVS_OP_STATUS 21
82: #define CVS_OP_TAG 22
83: #define CVS_OP_UNEDIT 23
84: #define CVS_OP_UPDATE 24
85: #define CVS_OP_VERSION 25
86: #define CVS_OP_WATCH 26
87: #define CVS_OP_WATCHERS 27
1.1 jfb 88:
1.19 jfb 89: #define CVS_OP_ANY 64 /* all operations */
1.1 jfb 90:
91:
92: /* methods */
93: #define CVS_METHOD_NONE 0
94: #define CVS_METHOD_LOCAL 1 /* local access */
95: #define CVS_METHOD_SERVER 2 /* tunnel through CVS_RSH */
96: #define CVS_METHOD_PSERVER 3 /* cvs pserver */
97: #define CVS_METHOD_KSERVER 4 /* kerberos */
98: #define CVS_METHOD_GSERVER 5 /* gssapi server */
99: #define CVS_METHOD_EXT 6
100: #define CVS_METHOD_FORK 7 /* local but fork */
101:
102: #define CVS_CMD_MAXNAMELEN 16
103: #define CVS_CMD_MAXALIAS 2
104: #define CVS_CMD_MAXDESCRLEN 64
1.34 jfb 105: #define CVS_CMD_MAXARG 128
1.1 jfb 106:
107:
108: /* defaults */
1.21 jfb 109: #define CVS_SERVER_DEFAULT "cvs"
1.1 jfb 110: #define CVS_RSH_DEFAULT "ssh"
111: #define CVS_EDITOR_DEFAULT "vi"
112:
1.70 xsa 113: /* extensions */
114: #define CVS_DESCR_FILE_EXT ",t"
1.1 jfb 115:
116: /* server-side paths */
117: #define CVS_PATH_ROOT "CVSROOT"
1.69 xsa 118: #define CVS_PATH_EMPTYDIR CVS_PATH_ROOT "/Emptydir"
1.1 jfb 119: #define CVS_PATH_COMMITINFO CVS_PATH_ROOT "/commitinfo"
120: #define CVS_PATH_CONFIG CVS_PATH_ROOT "/config"
121: #define CVS_PATH_CVSIGNORE CVS_PATH_ROOT "/cvsignore"
122: #define CVS_PATH_CVSWRAPPERS CVS_PATH_ROOT "/cvswrappers"
123: #define CVS_PATH_EDITINFO CVS_PATH_ROOT "/editinfo"
124: #define CVS_PATH_HISTORY CVS_PATH_ROOT "/history"
125: #define CVS_PATH_LOGINFO CVS_PATH_ROOT "/loginfo"
126: #define CVS_PATH_MODULES CVS_PATH_ROOT "/modules"
127: #define CVS_PATH_NOTIFY CVS_PATH_ROOT "/notify"
128: #define CVS_PATH_RCSINFO CVS_PATH_ROOT "/rcsinfo"
129: #define CVS_PATH_TAGINFO CVS_PATH_ROOT "/taginfo"
130: #define CVS_PATH_VERIFYMSG CVS_PATH_ROOT "/verifymsg"
131:
132:
133: /* client-side paths */
134: #define CVS_PATH_RC ".cvsrc"
135: #define CVS_PATH_CVSDIR "CVS"
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"
139: #define CVS_PATH_ROOTSPEC CVS_PATH_CVSDIR "/Root"
1.10 jfb 140: #define CVS_PATH_REPOSITORY CVS_PATH_CVSDIR "/Repository"
1.1 jfb 141:
1.46 joris 142:
143: /* flags for cmd_flags */
144: #define CVS_CMD_ALLOWSPEC 0x01
145: #define CVS_CMD_SENDARGS1 0x04
146: #define CVS_CMD_SENDARGS2 0x08
147: #define CVS_CMD_SENDDIR 0x10
1.60 joris 148: #define CVS_CMD_PRUNEDIRS 0x20
1.46 joris 149:
1.58 jfb 150:
1.46 joris 151: struct cvs_cmd {
1.58 jfb 152: int cmd_op;
153: int cmd_req;
154: char cmd_name[CVS_CMD_MAXNAMELEN];
155: char cmd_alias[CVS_CMD_MAXALIAS][CVS_CMD_MAXNAMELEN];
156: char cmd_descr[CVS_CMD_MAXDESCRLEN];
1.46 joris 157: char *cmd_synopsis;
158: char *cmd_opts;
159: char *cmd_defargs;
1.58 jfb 160: int file_flags;
161:
162: /* operations vector */
163: int (*cmd_init) (struct cvs_cmd *, int, char **, int *);
164: int (*cmd_pre_exec) (struct cvsroot *);
165: int (*cmd_exec_remote) (CVSFILE *, void *);
166: int (*cmd_exec_local) (CVSFILE *, void *);
167: int (*cmd_post_exec) (struct cvsroot *);
168: int (*cmd_cleanup) (void);
169:
170: /* flags for cvs_file_get() */
171: int cmd_flags;
1.46 joris 172: };
1.1 jfb 173:
1.7 jfb 174: struct cvs_file;
175: struct cvs_dir;
1.19 jfb 176: struct cvs_flist;
1.7 jfb 177:
1.41 jfb 178: struct cvs_var {
179: char *cv_name;
180: char *cv_val;
181: TAILQ_ENTRY(cvs_var) cv_link;
182: };
183:
184:
185:
1.1 jfb 186: struct cvs_op {
1.19 jfb 187: u_int co_op;
188: uid_t co_uid; /* user performing the operation */
189: char *co_tag; /* tag or branch, NULL if HEAD */
190: char *co_msg; /* message string (on commit or add) */
191: struct cvs_flist co_files;
1.1 jfb 192: };
193:
194:
1.36 jfb 195: #define CVS_ROOT_CONNECTED 0x01
196:
1.1 jfb 197: struct cvsroot {
1.11 jfb 198: char *cr_str;
1.1 jfb 199: u_int cr_method;
200: char *cr_buf;
201: char *cr_user;
202: char *cr_pass;
203: char *cr_host;
204: char *cr_dir;
205: u_int cr_port;
1.11 jfb 206: u_int cr_ref;
207:
208: /* connection data */
1.36 jfb 209: u_int cr_flags;
1.11 jfb 210: FILE *cr_srvin;
211: FILE *cr_srvout;
1.21 jfb 212: FILE *cr_srverr;
1.29 jfb 213: char *cr_version; /* version of remote server */
214: u_char cr_vrmask[16]; /* mask of valid requests supported by server */
1.1 jfb 215: };
1.20 jfb 216:
1.29 jfb 217: #define CVS_SETVR(rt, rq) ((rt)->cr_vrmask[(rq) / 8] |= (1 << ((rq) % 8)))
218: #define CVS_GETVR(rt, rq) ((rt)->cr_vrmask[(rq) / 8] & (1 << ((rq) % 8)))
219: #define CVS_CLRVR(rt, rq) ((rt)->cr_vrmask[(rq) / 8] &= ~(1 << ((rq) % 8)))
1.20 jfb 220: #define CVS_RSTVR(rt) memset((rt)->cr_vrmask, 0, sizeof((rt)->cr_vrmask))
1.1 jfb 221:
222:
223: #define CVS_HIST_ADDED 'A'
224: #define CVS_HIST_EXPORT 'E'
225: #define CVS_HIST_RELEASE 'F'
226: #define CVS_HIST_MODIFIED 'M'
227: #define CVS_HIST_CHECKOUT 'O'
228: #define CVS_HIST_COMMIT 'R'
229: #define CVS_HIST_TAG 'T'
230:
231:
1.28 jfb 232: #define CVS_DATE_DUMMY "dummy timestamp"
233: #define CVS_DATE_DMSEC (time_t)-1
1.27 jfb 234:
1.1 jfb 235: #define CVS_ENT_NONE 0
236: #define CVS_ENT_FILE 1
237: #define CVS_ENT_DIR 2
1.27 jfb 238:
1.44 jfb 239: #define CVS_ENT_REG 0
240: #define CVS_ENT_ADDED 1
241: #define CVS_ENT_REMOVED 2
1.67 joris 242: #define CVS_ENT_UPTODATE 3
1.1 jfb 243:
1.17 jfb 244: #define CVS_ENTF_SYNC 0x01 /* contents of disk and memory match */
245: #define CVS_ENTF_WR 0x02 /* file is opened for writing too */
246:
1.1 jfb 247:
248: struct cvs_ent {
1.44 jfb 249: char *ce_buf;
250: u_int16_t ce_type;
251: u_int16_t ce_status;
252: char *ce_name;
253: RCSNUM *ce_rev;
254: time_t ce_mtime;
255: char *ce_opts;
256: char *ce_tag;
1.4 jfb 257: TAILQ_ENTRY(cvs_ent) ce_list;
1.1 jfb 258: };
259:
260: typedef struct cvs_entries {
261: char *cef_path;
1.17 jfb 262: u_int cef_flags;
1.1 jfb 263:
1.4 jfb 264: TAILQ_HEAD(, cvs_ent) cef_ent;
265: struct cvs_ent *cef_cur;
1.1 jfb 266: } CVSENTRIES;
267:
268:
269: struct cvs_hent {
270: char ch_event;
271: time_t ch_date;
272: uid_t ch_uid;
273: char *ch_user;
274: char *ch_curdir;
275: char *ch_repo;
276: RCSNUM *ch_rev;
277: char *ch_arg;
278: };
279:
280:
281: typedef struct cvs_histfile {
282: int chf_fd;
283: char *chf_buf; /* read buffer */
284: size_t chf_blen; /* buffer size */
285: size_t chf_bused; /* bytes used in buffer */
286:
287: off_t chf_off; /* next read */
288: u_int chf_sindex; /* history entry index of first in array */
289: u_int chf_cindex; /* current index (for getnext()) */
290: u_int chf_nbhent; /* number of valid entries in the array */
291:
292: struct cvs_hent chf_hent[CVS_HIST_CACHE];
293:
294: } CVSHIST;
295:
296:
1.67 joris 297: extern char *cvs_req_modulename;
1.64 joris 298: extern char *cvs_repo_base;
1.22 jfb 299: extern char *cvs_command;
1.18 jfb 300: extern char *cvs_editor;
1.30 krapht 301: extern char *cvs_msg;
1.42 jfb 302: extern char *cvs_rsh;
1.22 jfb 303:
1.42 jfb 304: extern int verbosity;
305: extern int cvs_trace;
306: extern int cvs_nolog;
307: extern int cvs_compress;
308: extern int cvs_cmdop;
309: extern int cvs_nocase;
1.57 xsa 310: extern int cvs_noexec;
1.42 jfb 311: extern int cvs_readonly;
1.72 ! joris 312: extern int cvs_error;
1.23 jfb 313: extern CVSFILE *cvs_files;
1.15 jfb 314:
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;
330: extern struct cvs_cmd cvs_cmd_login;
331: extern struct cvs_cmd cvs_cmd_logout;
332: extern struct cvs_cmd cvs_cmd_rdiff;
333: extern struct cvs_cmd cvs_cmd_release;
334: extern struct cvs_cmd cvs_cmd_remove;
335: extern struct cvs_cmd cvs_cmd_rlog;
336: extern struct cvs_cmd cvs_cmd_rtag;
337: extern struct cvs_cmd cvs_cmd_status;
338: extern struct cvs_cmd cvs_cmd_tag;
339: extern struct cvs_cmd cvs_cmd_update;
340: extern struct cvs_cmd cvs_cmd_version;
341: extern struct cvs_cmd cvs_cmd_server;
342: extern struct cvs_cmd cvs_cmd_unedit;
343: extern struct cvs_cmd cvs_cmd_watch;
344: extern struct cvs_cmd cvs_cmd_watchers;
345:
346:
347: struct cvs_cmd* cvs_findcmd (const char *);
348: struct cvs_cmd* cvs_findcmdbyreq (int);
349: int cvs_startcmd (struct cvs_cmd *, int, char **);
350: int cvs_server (int, char **);
1.41 jfb 351:
352: int cvs_var_set (const char *, const char *);
353: int cvs_var_unset (const char *);
354: const char* cvs_var_get (const char *);
1.1 jfb 355:
356:
1.69 xsa 357: /* root.c */
1.1 jfb 358: struct cvsroot* cvsroot_parse (const char *);
359: void cvsroot_free (struct cvsroot *);
360: struct cvsroot* cvsroot_get (const char *);
1.2 jfb 361:
362:
1.1 jfb 363: /* Entries API */
1.3 jfb 364: CVSENTRIES* cvs_ent_open (const char *, int);
1.1 jfb 365: struct cvs_ent* cvs_ent_get (CVSENTRIES *, const char *);
366: struct cvs_ent* cvs_ent_next (CVSENTRIES *);
367: int cvs_ent_add (CVSENTRIES *, struct cvs_ent *);
1.5 jfb 368: int cvs_ent_addln (CVSENTRIES *, const char *);
1.1 jfb 369: int cvs_ent_remove (CVSENTRIES *, const char *);
1.17 jfb 370: int cvs_ent_write (CVSENTRIES *);
1.1 jfb 371: struct cvs_ent* cvs_ent_parse (const char *);
372: void cvs_ent_close (CVSENTRIES *);
1.8 jfb 373: void cvs_ent_free (struct cvs_ent *);
1.1 jfb 374:
375: /* history API */
376: CVSHIST* cvs_hist_open (const char *);
377: void cvs_hist_close (CVSHIST *);
378: int cvs_hist_parse (CVSHIST *);
379: struct cvs_hent* cvs_hist_getnext (CVSHIST *);
380: int cvs_hist_append (CVSHIST *, struct cvs_hent *);
381:
1.69 xsa 382: /* logmsg.c */
1.31 jfb 383: char* cvs_logmsg_open (const char *);
1.37 jfb 384: char* cvs_logmsg_get (const char *, struct cvs_flist *, struct cvs_flist *, struct cvs_flist *);
1.31 jfb 385: int cvs_logmsg_send (struct cvsroot *, const char *);
1.1 jfb 386:
1.69 xsa 387: /* date.y */
1.56 jfb 388: time_t cvs_date_parse (const char *);
1.28 jfb 389:
1.69 xsa 390: /* util.c */
391: int cvs_readrepo (const char *, char *, size_t);
392: int cvs_modetostr (mode_t, char *, size_t);
393: int cvs_strtomode (const char *, mode_t *);
394: int cvs_splitpath (const char *, char *, size_t, char **);
395: int cvs_mkadmin (const char *, const char *, const char *);
396: int cvs_cksum (const char *, char *, size_t);
397: int cvs_exec (int, char **, int []);
398: int cvs_getargv (const char *, char **, int);
1.71 xsa 399: int cvs_chdir (const char *);
1.69 xsa 400: int cvs_remove_dir (const char *);
401: int cvs_create_dir (const char *, int, char *, char *);
402: char* cvs_rcs_getpath (CVSFILE *, char *, size_t);
403: char** cvs_makeargv (const char *, int *);
404: void cvs_freeargv (char **, int);
405: size_t cvs_path_cat (const char *, const char *, char *, size_t);
1.1 jfb 406:
407:
408: #endif /* CVS_H */