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