Annotation of src/usr.bin/cvs/cvs.h, Revision 1.106
1.106 ! joris 1: /* $OpenBSD: cvs.h,v 1.105 2006/05/27 05:20:25 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.1 jfb 30: #include "rcs.h"
1.104 joris 31: #include "xmalloc.h"
32: #include "util.h"
1.19 jfb 33: #include "file.h"
1.104 joris 34: #include "repository.h"
35: #include "worklist.h"
1.1 jfb 36:
1.104 joris 37: #define CVS_VERSION_MINOR "0"
38: #define CVS_VERSION_MAJOR "1"
39: #define CVS_VERSION_PORT
40:
41: #define CVS_VERSION \
42: "OpenCVS version " \
43: CVS_VERSION_MAJOR "." CVS_VERSION_MINOR CVS_VERSION_PORT
1.1 jfb 44:
1.74 xsa 45: #define CVS_HIST_CACHE 128
46: #define CVS_HIST_NBFLD 6
1.1 jfb 47:
1.74 xsa 48: #define CVS_CKSUM_LEN 33 /* length of a CVS checksum string */
1.1 jfb 49:
50: /* operations */
1.74 xsa 51: #define CVS_OP_UNKNOWN 0
52: #define CVS_OP_ADD 1
53: #define CVS_OP_ADMIN 2
54: #define CVS_OP_ANNOTATE 3
55: #define CVS_OP_CHECKOUT 4
56: #define CVS_OP_COMMIT 5
57: #define CVS_OP_DIFF 6
58: #define CVS_OP_EDIT 7
59: #define CVS_OP_EDITORS 8
60: #define CVS_OP_EXPORT 9
61: #define CVS_OP_HISTORY 10
62: #define CVS_OP_IMPORT 11
63: #define CVS_OP_INIT 12
64: #define CVS_OP_LOG 13
65: #define CVS_OP_RANNOTATE 14
66: #define CVS_OP_RDIFF 15
67: #define CVS_OP_RELEASE 16
68: #define CVS_OP_REMOVE 17
69: #define CVS_OP_RLOG 18
70: #define CVS_OP_RTAG 19
71: #define CVS_OP_SERVER 20
72: #define CVS_OP_STATUS 21
73: #define CVS_OP_TAG 22
74: #define CVS_OP_UNEDIT 23
75: #define CVS_OP_UPDATE 24
76: #define CVS_OP_VERSION 25
77: #define CVS_OP_WATCH 26
78: #define CVS_OP_WATCHERS 27
1.1 jfb 79:
1.74 xsa 80: #define CVS_OP_ANY 64 /* all operations */
1.1 jfb 81:
82: /* methods */
1.74 xsa 83: #define CVS_METHOD_NONE 0
84: #define CVS_METHOD_LOCAL 1 /* local access */
85: #define CVS_METHOD_SERVER 2 /* tunnel through CVS_RSH */
86: #define CVS_METHOD_PSERVER 3 /* cvs pserver */
87: #define CVS_METHOD_KSERVER 4 /* kerberos */
88: #define CVS_METHOD_GSERVER 5 /* gssapi server */
89: #define CVS_METHOD_EXT 6
90: #define CVS_METHOD_FORK 7 /* local but fork */
91:
92: #define CVS_CMD_MAXNAMELEN 16
93: #define CVS_CMD_MAXALIAS 2
94: #define CVS_CMD_MAXDESCRLEN 64
95: #define CVS_CMD_MAXARG 128
1.1 jfb 96:
97: /* defaults */
1.74 xsa 98: #define CVS_SERVER_DEFAULT "cvs"
99: #define CVS_RSH_DEFAULT "ssh"
100: #define CVS_EDITOR_DEFAULT "vi"
1.77 xsa 101: #define CVS_TMPDIR_DEFAULT "/tmp"
1.1 jfb 102:
1.70 xsa 103: /* extensions */
104: #define CVS_DESCR_FILE_EXT ",t"
1.1 jfb 105:
106: /* server-side paths */
1.74 xsa 107: #define CVS_PATH_ROOT "CVSROOT"
108: #define CVS_PATH_EMPTYDIR CVS_PATH_ROOT "/Emptydir"
109: #define CVS_PATH_COMMITINFO CVS_PATH_ROOT "/commitinfo"
110: #define CVS_PATH_CONFIG CVS_PATH_ROOT "/config"
111: #define CVS_PATH_CVSIGNORE CVS_PATH_ROOT "/cvsignore"
112: #define CVS_PATH_CVSWRAPPERS CVS_PATH_ROOT "/cvswrappers"
113: #define CVS_PATH_EDITINFO CVS_PATH_ROOT "/editinfo"
114: #define CVS_PATH_HISTORY CVS_PATH_ROOT "/history"
115: #define CVS_PATH_LOGINFO CVS_PATH_ROOT "/loginfo"
116: #define CVS_PATH_MODULES CVS_PATH_ROOT "/modules"
1.101 xsa 117: #define CVS_PATH_NOTIFY_R CVS_PATH_ROOT "/notify"
1.74 xsa 118: #define CVS_PATH_RCSINFO CVS_PATH_ROOT "/rcsinfo"
119: #define CVS_PATH_TAGINFO CVS_PATH_ROOT "/taginfo"
120: #define CVS_PATH_VERIFYMSG CVS_PATH_ROOT "/verifymsg"
1.1 jfb 121:
122: /* client-side paths */
1.74 xsa 123: #define CVS_PATH_RC ".cvsrc"
124: #define CVS_PATH_CVSDIR "CVS"
1.100 xsa 125: #define CVS_PATH_BASEDIR CVS_PATH_CVSDIR "/Base"
126: #define CVS_PATH_BASEREV CVS_PATH_CVSDIR "/Baserev"
127: #define CVS_PATH_BASEREVTMP CVS_PATH_CVSDIR "/Baserev.tmp"
128: #define CVS_PATH_CHECKINPROG CVS_PATH_CVSDIR "/Checkin.prog"
1.74 xsa 129: #define CVS_PATH_ENTRIES CVS_PATH_CVSDIR "/Entries"
130: #define CVS_PATH_STATICENTRIES CVS_PATH_CVSDIR "/Entries.Static"
131: #define CVS_PATH_LOGENTRIES CVS_PATH_CVSDIR "/Entries.Log"
1.89 joris 132: #define CVS_PATH_BACKUPENTRIES CVS_PATH_CVSDIR "/Entries.Backup"
1.100 xsa 133: #define CVS_PATH_NOTIFY CVS_PATH_CVSDIR "/Notify"
134: #define CVS_PATH_NOTIFYTMP CVS_PATH_CVSDIR "/Notify.tmp"
1.74 xsa 135: #define CVS_PATH_ROOTSPEC CVS_PATH_CVSDIR "/Root"
136: #define CVS_PATH_REPOSITORY CVS_PATH_CVSDIR "/Repository"
1.81 xsa 137: #define CVS_PATH_TAG CVS_PATH_CVSDIR "/Tag"
1.100 xsa 138: #define CVS_PATH_TEMPLATE CVS_PATH_CVSDIR "/Template"
139: #define CVS_PATH_UPDATEPROG CVS_PATH_CVSDIR "/Update.prog"
1.1 jfb 140:
1.46 joris 141: struct cvs_cmd {
1.103 joris 142: u_int cmd_op;
143: u_int cmd_req;
1.86 reyk 144: char cmd_name[CVS_CMD_MAXNAMELEN];
145: char cmd_alias[CVS_CMD_MAXALIAS][CVS_CMD_MAXNAMELEN];
146: char cmd_descr[CVS_CMD_MAXDESCRLEN];
147: char *cmd_synopsis;
148: char *cmd_opts;
149: char *cmd_defargs;
1.58 jfb 150:
1.104 joris 151: int (*cmd)(int, char **);
152: };
153:
154: struct cvsroot;
1.58 jfb 155:
1.104 joris 156: struct cvs_recursion {
157: void (*enterdir)(struct cvs_file *);
158: void (*leavedir)(struct cvs_file *);
159: void (*local)(struct cvs_file *);
160: void (*remote)(struct cvs_file *, struct cvsroot *);
1.106 ! joris 161: int flags;
1.46 joris 162: };
1.106 ! joris 163:
! 164: #define CR_RECURSE_DIRS 0x01
! 165: #define CR_ATTIC 0x02
! 166: #define CR_REPO 0x04
1.1 jfb 167:
1.41 jfb 168: struct cvs_var {
169: char *cv_name;
170: char *cv_val;
171: TAILQ_ENTRY(cvs_var) cv_link;
172: };
173:
1.74 xsa 174: #define CVS_ROOT_CONNECTED 0x01
1.36 jfb 175:
1.1 jfb 176: struct cvsroot {
1.11 jfb 177: char *cr_str;
1.1 jfb 178: u_int cr_method;
179: char *cr_buf;
180: char *cr_user;
181: char *cr_pass;
182: char *cr_host;
183: char *cr_dir;
184: u_int cr_port;
1.11 jfb 185: u_int cr_ref;
186:
187: /* connection data */
1.36 jfb 188: u_int cr_flags;
1.11 jfb 189: FILE *cr_srvin;
190: FILE *cr_srvout;
1.21 jfb 191: FILE *cr_srverr;
1.29 jfb 192: char *cr_version; /* version of remote server */
193: u_char cr_vrmask[16]; /* mask of valid requests supported by server */
1.78 joris 194:
195: TAILQ_ENTRY(cvsroot) root_cache;
1.1 jfb 196: };
1.20 jfb 197:
1.74 xsa 198: #define CVS_SETVR(rt, rq) ((rt)->cr_vrmask[(rq) / 8] |= (1 << ((rq) % 8)))
199: #define CVS_GETVR(rt, rq) ((rt)->cr_vrmask[(rq) / 8] & (1 << ((rq) % 8)))
200: #define CVS_CLRVR(rt, rq) ((rt)->cr_vrmask[(rq) / 8] &= ~(1 << ((rq) % 8)))
201: #define CVS_RSTVR(rt) memset((rt)->cr_vrmask, 0, sizeof((rt)->cr_vrmask))
202:
203: #define CVS_HIST_ADDED 'A'
204: #define CVS_HIST_EXPORT 'E'
205: #define CVS_HIST_RELEASE 'F'
206: #define CVS_HIST_MODIFIED 'M'
207: #define CVS_HIST_CHECKOUT 'O'
208: #define CVS_HIST_COMMIT 'R'
209: #define CVS_HIST_TAG 'T'
210:
211: #define CVS_DATE_DUMMY "dummy timestamp"
212: #define CVS_DATE_DMSEC (time_t)-1
213:
214: #define CVS_ENT_NONE 0
215: #define CVS_ENT_FILE 1
216: #define CVS_ENT_DIR 2
217:
218: #define CVS_ENT_REG 0
219: #define CVS_ENT_ADDED 1
220: #define CVS_ENT_REMOVED 2
221: #define CVS_ENT_UPTODATE 3
1.80 xsa 222:
223: #define CVS_ENT_MAXLINELEN 1024
1.1 jfb 224:
1.104 joris 225: #define ENT_NOSYNC 0
226: #define ENT_SYNC 1
1.17 jfb 227:
1.85 joris 228: #define STRIP_SLASH(p) \
229: do { \
230: size_t _slen; \
231: _slen = strlen(p); \
232: while ((_slen > 0) && (p[_slen - 1] == '/')) \
233: p[--_slen] = '\0'; \
234: } while (0)
1.104 joris 235:
1.1 jfb 236: struct cvs_ent {
1.104 joris 237: char *ce_buf;
238: char *ce_name;
239: char *ce_opts;
240: char *ce_tag;
241: char *ce_conflict;
242: time_t ce_mtime;
243: u_int16_t ce_type;
244: u_int16_t ce_status;
245: RCSNUM *ce_rev;
246: };
247:
248: struct cvs_ent_line {
249: char *buf;
250: TAILQ_ENTRY(cvs_ent_line) entries_list;
1.1 jfb 251: };
252:
253: typedef struct cvs_entries {
1.74 xsa 254: char *cef_path;
1.89 joris 255: char *cef_bpath;
1.104 joris 256: char *cef_lpath;
1.1 jfb 257:
1.104 joris 258: TAILQ_HEAD(, cvs_ent_line) cef_ent;
1.1 jfb 259: } CVSENTRIES;
260:
1.104 joris 261: extern struct cvs_wklhead temp_files;
262: extern volatile sig_atomic_t sig_received;
263: extern volatile sig_atomic_t cvs_quit;
264: extern struct cvsroot *current_cvsroot;
1.64 joris 265: extern char *cvs_repo_base;
1.22 jfb 266: extern char *cvs_command;
1.18 jfb 267: extern char *cvs_editor;
1.76 xsa 268: extern char *cvs_homedir;
1.30 krapht 269: extern char *cvs_msg;
1.42 jfb 270: extern char *cvs_rsh;
1.77 xsa 271: extern char *cvs_tmpdir;
1.22 jfb 272:
1.42 jfb 273: extern int verbosity;
274: extern int cvs_trace;
275: extern int cvs_nolog;
276: extern int cvs_compress;
277: extern int cvs_cmdop;
278: extern int cvs_nocase;
1.57 xsa 279: extern int cvs_noexec;
1.42 jfb 280: extern int cvs_readonly;
1.72 joris 281: extern int cvs_error;
1.15 jfb 282:
1.58 jfb 283: extern struct cvs_cmd *cvs_cdt[];
1.1 jfb 284:
1.58 jfb 285: extern struct cvs_cmd cvs_cmd_add;
286: extern struct cvs_cmd cvs_cmd_admin;
287: extern struct cvs_cmd cvs_cmd_annotate;
288: extern struct cvs_cmd cvs_cmd_checkout;
289: extern struct cvs_cmd cvs_cmd_commit;
290: extern struct cvs_cmd cvs_cmd_diff;
291: extern struct cvs_cmd cvs_cmd_edit;
292: extern struct cvs_cmd cvs_cmd_editors;
293: extern struct cvs_cmd cvs_cmd_export;
294: extern struct cvs_cmd cvs_cmd_history;
295: extern struct cvs_cmd cvs_cmd_import;
296: extern struct cvs_cmd cvs_cmd_init;
297: extern struct cvs_cmd cvs_cmd_log;
298: extern struct cvs_cmd cvs_cmd_login;
299: extern struct cvs_cmd cvs_cmd_logout;
300: extern struct cvs_cmd cvs_cmd_rdiff;
301: extern struct cvs_cmd cvs_cmd_release;
302: extern struct cvs_cmd cvs_cmd_remove;
303: extern struct cvs_cmd cvs_cmd_rlog;
304: extern struct cvs_cmd cvs_cmd_rtag;
305: extern struct cvs_cmd cvs_cmd_status;
306: extern struct cvs_cmd cvs_cmd_tag;
307: extern struct cvs_cmd cvs_cmd_update;
308: extern struct cvs_cmd cvs_cmd_version;
309: extern struct cvs_cmd cvs_cmd_server;
310: extern struct cvs_cmd cvs_cmd_unedit;
311: extern struct cvs_cmd cvs_cmd_watch;
312: extern struct cvs_cmd cvs_cmd_watchers;
313:
1.104 joris 314: /* cmd.c */
1.74 xsa 315: struct cvs_cmd *cvs_findcmd(const char *);
316: struct cvs_cmd *cvs_findcmdbyreq(int);
317:
1.104 joris 318: /* cvs.c */
1.74 xsa 319: int cvs_var_set(const char *, const char *);
320: int cvs_var_unset(const char *);
321: const char *cvs_var_get(const char *);
1.104 joris 322: void cvs_cleanup(void);
1.1 jfb 323:
1.104 joris 324: /* date.y */
325: time_t cvs_date_parse(const char *);
326:
327: /* entries.c */
328: struct cvs_ent *cvs_ent_parse(const char *);
329: struct cvs_ent *cvs_ent_get(CVSENTRIES *, const char *);
330: CVSENTRIES *cvs_ent_open(const char *);
331: void cvs_ent_add(CVSENTRIES *, const char *);
332: void cvs_ent_remove(CVSENTRIES *, const char *);
333: void cvs_ent_close(CVSENTRIES *, int);
334: void cvs_ent_free(struct cvs_ent *);
335: int cvs_ent_exists(CVSENTRIES *, const char *);
1.1 jfb 336:
1.69 xsa 337: /* root.c */
1.74 xsa 338: struct cvsroot *cvsroot_parse(const char *);
1.104 joris 339: struct cvsroot *cvsroot_get(const char *);
1.83 joris 340: void cvsroot_remove(struct cvsroot *);
1.87 joris 341:
1.104 joris 342: /* misc stuff */
343: void cvs_update_local(struct cvs_file *);
344: void cvs_update_enterdir(struct cvs_file *);
1.105 joris 345: void cvs_update_leavedir(struct cvs_file *);
1.104 joris 346: int cvs_checkout_file(struct cvs_file *, RCSNUM *, int);
1.1 jfb 347:
1.91 joris 348: #endif