Annotation of src/usr.bin/cvs/cvs.h, Revision 1.89
1.89 ! joris 1: /* $OpenBSD: cvs.h,v 1.88 2005/12/03 01:02:08 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
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.74 xsa 38: #define CVS_VERSION_MAJOR 0
39: #define CVS_VERSION_MINOR 3
40: #define CVS_VERSION "OpenCVS 0.3"
1.1 jfb 41:
42:
1.74 xsa 43: #define CVS_HIST_CACHE 128
44: #define CVS_HIST_NBFLD 6
1.1 jfb 45:
46:
1.74 xsa 47: #define CVS_CKSUM_LEN 33 /* length of a CVS checksum string */
1.1 jfb 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.74 xsa 60: #define CVS_OP_UNKNOWN 0
61: #define CVS_OP_ADD 1
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
70: #define CVS_OP_HISTORY 10
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.74 xsa 89: #define CVS_OP_ANY 64 /* all operations */
1.1 jfb 90:
91:
92: /* methods */
1.74 xsa 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
105: #define CVS_CMD_MAXARG 128
1.1 jfb 106:
107:
108: /* defaults */
1.74 xsa 109: #define CVS_SERVER_DEFAULT "cvs"
110: #define CVS_RSH_DEFAULT "ssh"
111: #define CVS_EDITOR_DEFAULT "vi"
1.77 xsa 112: #define CVS_TMPDIR_DEFAULT "/tmp"
1.1 jfb 113:
1.70 xsa 114: /* extensions */
115: #define CVS_DESCR_FILE_EXT ",t"
1.1 jfb 116:
117: /* server-side paths */
1.74 xsa 118: #define CVS_PATH_ROOT "CVSROOT"
119: #define CVS_PATH_EMPTYDIR CVS_PATH_ROOT "/Emptydir"
120: #define CVS_PATH_COMMITINFO CVS_PATH_ROOT "/commitinfo"
121: #define CVS_PATH_CONFIG CVS_PATH_ROOT "/config"
122: #define CVS_PATH_CVSIGNORE CVS_PATH_ROOT "/cvsignore"
123: #define CVS_PATH_CVSWRAPPERS CVS_PATH_ROOT "/cvswrappers"
124: #define CVS_PATH_EDITINFO CVS_PATH_ROOT "/editinfo"
125: #define CVS_PATH_HISTORY CVS_PATH_ROOT "/history"
126: #define CVS_PATH_LOGINFO CVS_PATH_ROOT "/loginfo"
127: #define CVS_PATH_MODULES CVS_PATH_ROOT "/modules"
128: #define CVS_PATH_NOTIFY CVS_PATH_ROOT "/notify"
129: #define CVS_PATH_RCSINFO CVS_PATH_ROOT "/rcsinfo"
130: #define CVS_PATH_TAGINFO CVS_PATH_ROOT "/taginfo"
131: #define CVS_PATH_VERIFYMSG CVS_PATH_ROOT "/verifymsg"
1.1 jfb 132:
133:
134: /* client-side paths */
1.74 xsa 135: #define CVS_PATH_RC ".cvsrc"
136: #define CVS_PATH_CVSDIR "CVS"
137: #define CVS_PATH_ENTRIES CVS_PATH_CVSDIR "/Entries"
138: #define CVS_PATH_STATICENTRIES CVS_PATH_CVSDIR "/Entries.Static"
139: #define CVS_PATH_LOGENTRIES CVS_PATH_CVSDIR "/Entries.Log"
1.89 ! joris 140: #define CVS_PATH_BACKUPENTRIES CVS_PATH_CVSDIR "/Entries.Backup"
1.74 xsa 141: #define CVS_PATH_ROOTSPEC CVS_PATH_CVSDIR "/Root"
142: #define CVS_PATH_REPOSITORY CVS_PATH_CVSDIR "/Repository"
1.81 xsa 143: #define CVS_PATH_TAG CVS_PATH_CVSDIR "/Tag"
1.1 jfb 144:
1.46 joris 145:
146: /* flags for cmd_flags */
147: #define CVS_CMD_ALLOWSPEC 0x01
148: #define CVS_CMD_SENDARGS1 0x04
149: #define CVS_CMD_SENDARGS2 0x08
150: #define CVS_CMD_SENDDIR 0x10
1.60 joris 151: #define CVS_CMD_PRUNEDIRS 0x20
1.46 joris 152:
1.58 jfb 153:
1.46 joris 154: struct cvs_cmd {
1.86 reyk 155: int cmd_op;
156: int cmd_req;
157: char cmd_name[CVS_CMD_MAXNAMELEN];
158: char cmd_alias[CVS_CMD_MAXALIAS][CVS_CMD_MAXNAMELEN];
159: char cmd_descr[CVS_CMD_MAXDESCRLEN];
160: char *cmd_synopsis;
161: char *cmd_opts;
162: char *cmd_defargs;
163: int file_flags;
1.58 jfb 164:
165: /* operations vector */
1.86 reyk 166: int (*cmd_init)(struct cvs_cmd *, int, char **, int *);
167: int (*cmd_pre_exec)(struct cvsroot *);
168: int (*cmd_exec_remote)(CVSFILE *, void *);
169: int (*cmd_exec_local)(CVSFILE *, void *);
170: int (*cmd_post_exec)(struct cvsroot *);
171: int (*cmd_cleanup)(void);
1.58 jfb 172:
173: /* flags for cvs_file_get() */
1.86 reyk 174: int cmd_flags;
1.46 joris 175: };
1.1 jfb 176:
1.7 jfb 177: struct cvs_file;
178: struct cvs_dir;
1.19 jfb 179: struct cvs_flist;
1.7 jfb 180:
1.41 jfb 181: struct cvs_var {
182: char *cv_name;
183: char *cv_val;
184: TAILQ_ENTRY(cvs_var) cv_link;
185: };
186:
187:
188:
1.1 jfb 189: struct cvs_op {
1.19 jfb 190: u_int co_op;
191: uid_t co_uid; /* user performing the operation */
192: char *co_tag; /* tag or branch, NULL if HEAD */
193: char *co_msg; /* message string (on commit or add) */
194: struct cvs_flist co_files;
1.1 jfb 195: };
196:
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:
228: #define CVS_HIST_ADDED 'A'
229: #define CVS_HIST_EXPORT 'E'
230: #define CVS_HIST_RELEASE 'F'
231: #define CVS_HIST_MODIFIED 'M'
232: #define CVS_HIST_CHECKOUT 'O'
233: #define CVS_HIST_COMMIT 'R'
234: #define CVS_HIST_TAG 'T'
235:
236:
237: #define CVS_DATE_DUMMY "dummy timestamp"
238: #define CVS_DATE_DMSEC (time_t)-1
239:
240: #define CVS_ENT_NONE 0
241: #define CVS_ENT_FILE 1
242: #define CVS_ENT_DIR 2
243:
244: #define CVS_ENT_REG 0
245: #define CVS_ENT_ADDED 1
246: #define CVS_ENT_REMOVED 2
247: #define CVS_ENT_UPTODATE 3
1.80 xsa 248:
249: #define CVS_ENT_MAXLINELEN 1024
1.1 jfb 250:
1.74 xsa 251: #define CVS_ENTF_SYNC 0x01 /* contents of disk and memory match */
252: #define CVS_ENTF_WR 0x02 /* file is opened for writing too */
1.17 jfb 253:
1.85 joris 254: #define STRIP_SLASH(p) \
255: do { \
256: size_t _slen; \
257: _slen = strlen(p); \
258: while ((_slen > 0) && (p[_slen - 1] == '/')) \
259: p[--_slen] = '\0'; \
260: } while (0)
1.1 jfb 261: struct cvs_ent {
1.74 xsa 262: char *ce_buf;
263: u_int16_t ce_type;
264: u_int16_t ce_status;
265: char *ce_name;
266: RCSNUM *ce_rev;
267: time_t ce_mtime;
268: char *ce_opts;
269: char *ce_tag;
1.82 joris 270:
271: /*
272: * This variable is set to 1 if we have already processed this entry
273: * in the cvs_file_getdir() function. This is to avoid files being
274: * passed twice to the callbacks.
275: */
276: int processed;
1.74 xsa 277: TAILQ_ENTRY(cvs_ent) ce_list;
1.1 jfb 278: };
279:
280: typedef struct cvs_entries {
1.74 xsa 281: char *cef_path;
1.89 ! joris 282: char *cef_bpath;
1.74 xsa 283: u_int cef_flags;
1.1 jfb 284:
1.88 joris 285: TAILQ_HEAD(cvsentrieshead, cvs_ent) cef_ent;
1.74 xsa 286: struct cvs_ent *cef_cur;
1.1 jfb 287: } CVSENTRIES;
288:
289:
290: struct cvs_hent {
1.74 xsa 291: char ch_event;
292: time_t ch_date;
293: uid_t ch_uid;
294: char *ch_user;
295: char *ch_curdir;
296: char *ch_repo;
297: RCSNUM *ch_rev;
298: char *ch_arg;
1.1 jfb 299: };
300:
301:
302: typedef struct cvs_histfile {
1.74 xsa 303: int chf_fd;
304: char *chf_buf; /* read buffer */
305: size_t chf_blen; /* buffer size */
306: size_t chf_bused; /* bytes used in buffer */
307:
308: off_t chf_off; /* next read */
309: u_int chf_sindex; /* history entry index of first in array */
310: u_int chf_cindex; /* current index (for getnext()) */
311: u_int chf_nbhent; /* number of valid entries in the array */
1.1 jfb 312:
1.74 xsa 313: struct cvs_hent chf_hent[CVS_HIST_CACHE];
1.1 jfb 314:
315: } CVSHIST;
316:
317:
1.67 joris 318: extern char *cvs_req_modulename;
1.64 joris 319: extern char *cvs_repo_base;
1.22 jfb 320: extern char *cvs_command;
1.18 jfb 321: extern char *cvs_editor;
1.76 xsa 322: extern char *cvs_homedir;
1.30 krapht 323: extern char *cvs_msg;
1.42 jfb 324: extern char *cvs_rsh;
1.77 xsa 325: extern char *cvs_tmpdir;
1.22 jfb 326:
1.42 jfb 327: extern int verbosity;
328: extern int cvs_trace;
329: extern int cvs_nolog;
330: extern int cvs_compress;
331: extern int cvs_cmdop;
332: extern int cvs_nocase;
1.57 xsa 333: extern int cvs_noexec;
1.42 jfb 334: extern int cvs_readonly;
1.72 joris 335: extern int cvs_error;
1.23 jfb 336: extern CVSFILE *cvs_files;
1.15 jfb 337:
1.58 jfb 338: extern struct cvs_cmd *cvs_cdt[];
1.1 jfb 339:
1.58 jfb 340: extern struct cvs_cmd cvs_cmd_add;
341: extern struct cvs_cmd cvs_cmd_admin;
342: extern struct cvs_cmd cvs_cmd_annotate;
343: extern struct cvs_cmd cvs_cmd_checkout;
344: extern struct cvs_cmd cvs_cmd_commit;
345: extern struct cvs_cmd cvs_cmd_diff;
346: extern struct cvs_cmd cvs_cmd_edit;
347: extern struct cvs_cmd cvs_cmd_editors;
348: extern struct cvs_cmd cvs_cmd_export;
349: extern struct cvs_cmd cvs_cmd_history;
350: extern struct cvs_cmd cvs_cmd_import;
351: extern struct cvs_cmd cvs_cmd_init;
352: extern struct cvs_cmd cvs_cmd_log;
353: extern struct cvs_cmd cvs_cmd_login;
354: extern struct cvs_cmd cvs_cmd_logout;
355: extern struct cvs_cmd cvs_cmd_rdiff;
356: extern struct cvs_cmd cvs_cmd_release;
357: extern struct cvs_cmd cvs_cmd_remove;
358: extern struct cvs_cmd cvs_cmd_rlog;
359: extern struct cvs_cmd cvs_cmd_rtag;
360: extern struct cvs_cmd cvs_cmd_status;
361: extern struct cvs_cmd cvs_cmd_tag;
362: extern struct cvs_cmd cvs_cmd_update;
363: extern struct cvs_cmd cvs_cmd_version;
364: extern struct cvs_cmd cvs_cmd_server;
365: extern struct cvs_cmd cvs_cmd_unedit;
366: extern struct cvs_cmd cvs_cmd_watch;
367: extern struct cvs_cmd cvs_cmd_watchers;
368:
369:
1.74 xsa 370: struct cvs_cmd *cvs_findcmd(const char *);
371: struct cvs_cmd *cvs_findcmdbyreq(int);
372: int cvs_startcmd(struct cvs_cmd *, int, char **);
373: int cvs_server(int, char **);
374:
375: int cvs_var_set(const char *, const char *);
376: int cvs_var_unset(const char *);
377: const char *cvs_var_get(const char *);
1.1 jfb 378:
379:
1.69 xsa 380: /* root.c */
1.74 xsa 381: struct cvsroot *cvsroot_parse(const char *);
1.83 joris 382: void cvsroot_remove(struct cvsroot *);
1.74 xsa 383: struct cvsroot *cvsroot_get(const char *);
1.2 jfb 384:
385:
1.81 xsa 386: /* entries.c */
1.74 xsa 387: CVSENTRIES *cvs_ent_open(const char *, int);
388: struct cvs_ent *cvs_ent_get(CVSENTRIES *, const char *);
389: struct cvs_ent *cvs_ent_next(CVSENTRIES *);
390: int cvs_ent_add(CVSENTRIES *, struct cvs_ent *);
391: int cvs_ent_addln(CVSENTRIES *, const char *);
1.88 joris 392: int cvs_ent_remove(CVSENTRIES *, const char *, int);
1.74 xsa 393: int cvs_ent_write(CVSENTRIES *);
394: struct cvs_ent *cvs_ent_parse(const char *);
395: void cvs_ent_close(CVSENTRIES *);
396: void cvs_ent_free(struct cvs_ent *);
1.1 jfb 397:
398: /* history API */
1.74 xsa 399: CVSHIST *cvs_hist_open(const char *);
400: void cvs_hist_close(CVSHIST *);
401: int cvs_hist_parse(CVSHIST *);
402: struct cvs_hent *cvs_hist_getnext(CVSHIST *);
403: int cvs_hist_append(CVSHIST *, struct cvs_hent *);
1.1 jfb 404:
1.69 xsa 405: /* logmsg.c */
1.74 xsa 406: char *cvs_logmsg_open(const char *);
407: char *cvs_logmsg_get(const char *, struct cvs_flist *,
408: struct cvs_flist *, struct cvs_flist *);
409: int cvs_logmsg_send(struct cvsroot *, const char *);
1.1 jfb 410:
1.69 xsa 411: /* date.y */
1.74 xsa 412: time_t cvs_date_parse(const char *);
1.28 jfb 413:
1.69 xsa 414: /* util.c */
1.87 joris 415:
416: struct cvs_line {
417: char *l_line;
418: int l_lineno;
419: TAILQ_ENTRY(cvs_line) l_list;
420: };
421:
422: TAILQ_HEAD(cvs_tqh, cvs_line);
423:
424: struct cvs_lines {
425: int l_nblines;
426: char *l_data;
427: struct cvs_tqh l_lines;
428: };
429:
1.74 xsa 430: int cvs_readrepo(const char *, char *, size_t);
431: int cvs_modetostr(mode_t, char *, size_t);
432: int cvs_strtomode(const char *, mode_t *);
433: int cvs_splitpath(const char *, char *, size_t, char **);
1.84 xsa 434: int cvs_mkadmin(const char *, const char *, const char *, char *,
435: char *, int);
1.74 xsa 436: int cvs_cksum(const char *, char *, size_t);
437: int cvs_exec(int, char **, int []);
438: int cvs_getargv(const char *, char **, int);
439: int cvs_chdir(const char *);
1.79 xsa 440: int cvs_rename(const char *, const char *);
1.74 xsa 441: int cvs_unlink(const char *);
1.75 xsa 442: int cvs_rmdir(const char *);
1.74 xsa 443: int cvs_create_dir(const char *, int, char *, char *);
444: char *cvs_rcs_getpath(CVSFILE *, char *, size_t);
445: char **cvs_makeargv(const char *, int *);
446: void cvs_freeargv(char **, int);
1.81 xsa 447: void cvs_write_tagfile(char *, char *, int);
448: void cvs_parse_tagfile(char **, char **, int *);
1.74 xsa 449: size_t cvs_path_cat(const char *, const char *, char *, size_t);
1.1 jfb 450:
1.87 joris 451: BUF *cvs_patchfile(const char *, const char *,
452: int (*p)(struct cvs_lines *, struct cvs_lines *));
453: struct cvs_lines *cvs_splitlines(const char *);
454: void cvs_freelines(struct cvs_lines *);
455:
456: /* XXX */
457: int rcs_patch_lines(struct cvs_lines *, struct cvs_lines *);
1.88 joris 458: int cvs_checkout_rev(RCSFILE *, RCSNUM *, CVSFILE *, char *, int, int, ...);
1.1 jfb 459:
1.74 xsa 460: #endif /* CVS_H */