Annotation of src/usr.bin/cvs/cvs.h, Revision 1.108
1.108 ! joris 1: /* $OpenBSD: cvs.h,v 1.107 2006/05/27 18:04:46 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.107 joris 102: #define CVS_UMASK_DEFAULT 002
1.1 jfb 103:
1.70 xsa 104: /* extensions */
105: #define CVS_DESCR_FILE_EXT ",t"
1.1 jfb 106:
107: /* server-side paths */
1.108 ! joris 108: #define CVS_PATH_DEVNULL "/dev/null"
1.74 xsa 109: #define CVS_PATH_ROOT "CVSROOT"
110: #define CVS_PATH_EMPTYDIR CVS_PATH_ROOT "/Emptydir"
111: #define CVS_PATH_COMMITINFO CVS_PATH_ROOT "/commitinfo"
112: #define CVS_PATH_CONFIG CVS_PATH_ROOT "/config"
113: #define CVS_PATH_CVSIGNORE CVS_PATH_ROOT "/cvsignore"
114: #define CVS_PATH_CVSWRAPPERS CVS_PATH_ROOT "/cvswrappers"
115: #define CVS_PATH_EDITINFO CVS_PATH_ROOT "/editinfo"
116: #define CVS_PATH_HISTORY CVS_PATH_ROOT "/history"
117: #define CVS_PATH_LOGINFO CVS_PATH_ROOT "/loginfo"
118: #define CVS_PATH_MODULES CVS_PATH_ROOT "/modules"
1.101 xsa 119: #define CVS_PATH_NOTIFY_R CVS_PATH_ROOT "/notify"
1.74 xsa 120: #define CVS_PATH_RCSINFO CVS_PATH_ROOT "/rcsinfo"
121: #define CVS_PATH_TAGINFO CVS_PATH_ROOT "/taginfo"
122: #define CVS_PATH_VERIFYMSG CVS_PATH_ROOT "/verifymsg"
1.1 jfb 123:
124: /* client-side paths */
1.74 xsa 125: #define CVS_PATH_RC ".cvsrc"
126: #define CVS_PATH_CVSDIR "CVS"
1.100 xsa 127: #define CVS_PATH_BASEDIR CVS_PATH_CVSDIR "/Base"
128: #define CVS_PATH_BASEREV CVS_PATH_CVSDIR "/Baserev"
129: #define CVS_PATH_BASEREVTMP CVS_PATH_CVSDIR "/Baserev.tmp"
130: #define CVS_PATH_CHECKINPROG CVS_PATH_CVSDIR "/Checkin.prog"
1.74 xsa 131: #define CVS_PATH_ENTRIES CVS_PATH_CVSDIR "/Entries"
132: #define CVS_PATH_STATICENTRIES CVS_PATH_CVSDIR "/Entries.Static"
133: #define CVS_PATH_LOGENTRIES CVS_PATH_CVSDIR "/Entries.Log"
1.89 joris 134: #define CVS_PATH_BACKUPENTRIES CVS_PATH_CVSDIR "/Entries.Backup"
1.100 xsa 135: #define CVS_PATH_NOTIFY CVS_PATH_CVSDIR "/Notify"
136: #define CVS_PATH_NOTIFYTMP CVS_PATH_CVSDIR "/Notify.tmp"
1.74 xsa 137: #define CVS_PATH_ROOTSPEC CVS_PATH_CVSDIR "/Root"
138: #define CVS_PATH_REPOSITORY CVS_PATH_CVSDIR "/Repository"
1.81 xsa 139: #define CVS_PATH_TAG CVS_PATH_CVSDIR "/Tag"
1.100 xsa 140: #define CVS_PATH_TEMPLATE CVS_PATH_CVSDIR "/Template"
141: #define CVS_PATH_UPDATEPROG CVS_PATH_CVSDIR "/Update.prog"
1.1 jfb 142:
1.46 joris 143: struct cvs_cmd {
1.103 joris 144: u_int cmd_op;
145: u_int cmd_req;
1.86 reyk 146: char cmd_name[CVS_CMD_MAXNAMELEN];
147: char cmd_alias[CVS_CMD_MAXALIAS][CVS_CMD_MAXNAMELEN];
148: char cmd_descr[CVS_CMD_MAXDESCRLEN];
149: char *cmd_synopsis;
150: char *cmd_opts;
151: char *cmd_defargs;
1.58 jfb 152:
1.104 joris 153: int (*cmd)(int, char **);
154: };
155:
156: struct cvsroot;
1.58 jfb 157:
1.104 joris 158: struct cvs_recursion {
159: void (*enterdir)(struct cvs_file *);
160: void (*leavedir)(struct cvs_file *);
161: void (*local)(struct cvs_file *);
162: void (*remote)(struct cvs_file *, struct cvsroot *);
1.106 joris 163: int flags;
1.46 joris 164: };
1.106 joris 165:
166: #define CR_RECURSE_DIRS 0x01
167: #define CR_ATTIC 0x02
168: #define CR_REPO 0x04
1.1 jfb 169:
1.41 jfb 170: struct cvs_var {
171: char *cv_name;
172: char *cv_val;
173: TAILQ_ENTRY(cvs_var) cv_link;
174: };
175:
1.74 xsa 176: #define CVS_ROOT_CONNECTED 0x01
1.36 jfb 177:
1.1 jfb 178: struct cvsroot {
1.11 jfb 179: char *cr_str;
1.1 jfb 180: u_int cr_method;
181: char *cr_buf;
182: char *cr_user;
183: char *cr_pass;
184: char *cr_host;
185: char *cr_dir;
186: u_int cr_port;
1.11 jfb 187: u_int cr_ref;
188:
189: /* connection data */
1.36 jfb 190: u_int cr_flags;
1.11 jfb 191: FILE *cr_srvin;
192: FILE *cr_srvout;
1.21 jfb 193: FILE *cr_srverr;
1.29 jfb 194: char *cr_version; /* version of remote server */
195: u_char cr_vrmask[16]; /* mask of valid requests supported by server */
1.78 joris 196:
197: TAILQ_ENTRY(cvsroot) root_cache;
1.1 jfb 198: };
1.20 jfb 199:
1.74 xsa 200: #define CVS_SETVR(rt, rq) ((rt)->cr_vrmask[(rq) / 8] |= (1 << ((rq) % 8)))
201: #define CVS_GETVR(rt, rq) ((rt)->cr_vrmask[(rq) / 8] & (1 << ((rq) % 8)))
202: #define CVS_CLRVR(rt, rq) ((rt)->cr_vrmask[(rq) / 8] &= ~(1 << ((rq) % 8)))
203: #define CVS_RSTVR(rt) memset((rt)->cr_vrmask, 0, sizeof((rt)->cr_vrmask))
204:
205: #define CVS_HIST_ADDED 'A'
206: #define CVS_HIST_EXPORT 'E'
207: #define CVS_HIST_RELEASE 'F'
208: #define CVS_HIST_MODIFIED 'M'
209: #define CVS_HIST_CHECKOUT 'O'
210: #define CVS_HIST_COMMIT 'R'
211: #define CVS_HIST_TAG 'T'
212:
213: #define CVS_DATE_DUMMY "dummy timestamp"
214: #define CVS_DATE_DMSEC (time_t)-1
215:
216: #define CVS_ENT_NONE 0
217: #define CVS_ENT_FILE 1
218: #define CVS_ENT_DIR 2
219:
220: #define CVS_ENT_REG 0
221: #define CVS_ENT_ADDED 1
222: #define CVS_ENT_REMOVED 2
223: #define CVS_ENT_UPTODATE 3
1.80 xsa 224:
225: #define CVS_ENT_MAXLINELEN 1024
1.1 jfb 226:
1.104 joris 227: #define ENT_NOSYNC 0
228: #define ENT_SYNC 1
1.17 jfb 229:
1.85 joris 230: #define STRIP_SLASH(p) \
231: do { \
232: size_t _slen; \
233: _slen = strlen(p); \
234: while ((_slen > 0) && (p[_slen - 1] == '/')) \
235: p[--_slen] = '\0'; \
236: } while (0)
1.104 joris 237:
1.1 jfb 238: struct cvs_ent {
1.104 joris 239: char *ce_buf;
240: char *ce_name;
241: char *ce_opts;
242: char *ce_tag;
243: char *ce_conflict;
244: time_t ce_mtime;
245: u_int16_t ce_type;
246: u_int16_t ce_status;
247: RCSNUM *ce_rev;
248: };
249:
250: struct cvs_ent_line {
251: char *buf;
252: TAILQ_ENTRY(cvs_ent_line) entries_list;
1.1 jfb 253: };
254:
255: typedef struct cvs_entries {
1.74 xsa 256: char *cef_path;
1.89 joris 257: char *cef_bpath;
1.104 joris 258: char *cef_lpath;
1.1 jfb 259:
1.104 joris 260: TAILQ_HEAD(, cvs_ent_line) cef_ent;
1.1 jfb 261: } CVSENTRIES;
262:
1.104 joris 263: extern struct cvs_wklhead temp_files;
264: extern volatile sig_atomic_t sig_received;
265: extern volatile sig_atomic_t cvs_quit;
266: extern struct cvsroot *current_cvsroot;
1.107 joris 267: extern char *cvs_tagname;
1.64 joris 268: extern char *cvs_repo_base;
1.22 jfb 269: extern char *cvs_command;
1.18 jfb 270: extern char *cvs_editor;
1.76 xsa 271: extern char *cvs_homedir;
1.30 krapht 272: extern char *cvs_msg;
1.42 jfb 273: extern char *cvs_rsh;
1.77 xsa 274: extern char *cvs_tmpdir;
1.22 jfb 275:
1.107 joris 276: extern int cvs_umask;
1.42 jfb 277: extern int verbosity;
278: extern int cvs_trace;
279: extern int cvs_nolog;
280: extern int cvs_compress;
281: extern int cvs_cmdop;
282: extern int cvs_nocase;
1.57 xsa 283: extern int cvs_noexec;
1.42 jfb 284: extern int cvs_readonly;
1.72 joris 285: extern int cvs_error;
1.15 jfb 286:
1.58 jfb 287: extern struct cvs_cmd *cvs_cdt[];
1.1 jfb 288:
1.58 jfb 289: extern struct cvs_cmd cvs_cmd_add;
290: extern struct cvs_cmd cvs_cmd_admin;
291: extern struct cvs_cmd cvs_cmd_annotate;
292: extern struct cvs_cmd cvs_cmd_checkout;
293: extern struct cvs_cmd cvs_cmd_commit;
294: extern struct cvs_cmd cvs_cmd_diff;
295: extern struct cvs_cmd cvs_cmd_edit;
296: extern struct cvs_cmd cvs_cmd_editors;
297: extern struct cvs_cmd cvs_cmd_export;
298: extern struct cvs_cmd cvs_cmd_history;
299: extern struct cvs_cmd cvs_cmd_import;
300: extern struct cvs_cmd cvs_cmd_init;
301: extern struct cvs_cmd cvs_cmd_log;
302: extern struct cvs_cmd cvs_cmd_login;
303: extern struct cvs_cmd cvs_cmd_logout;
304: extern struct cvs_cmd cvs_cmd_rdiff;
305: extern struct cvs_cmd cvs_cmd_release;
306: extern struct cvs_cmd cvs_cmd_remove;
307: extern struct cvs_cmd cvs_cmd_rlog;
308: extern struct cvs_cmd cvs_cmd_rtag;
309: extern struct cvs_cmd cvs_cmd_status;
310: extern struct cvs_cmd cvs_cmd_tag;
311: extern struct cvs_cmd cvs_cmd_update;
312: extern struct cvs_cmd cvs_cmd_version;
313: extern struct cvs_cmd cvs_cmd_server;
314: extern struct cvs_cmd cvs_cmd_unedit;
315: extern struct cvs_cmd cvs_cmd_watch;
316: extern struct cvs_cmd cvs_cmd_watchers;
317:
1.104 joris 318: /* cmd.c */
1.74 xsa 319: struct cvs_cmd *cvs_findcmd(const char *);
320: struct cvs_cmd *cvs_findcmdbyreq(int);
321:
1.104 joris 322: /* cvs.c */
1.74 xsa 323: int cvs_var_set(const char *, const char *);
324: int cvs_var_unset(const char *);
325: const char *cvs_var_get(const char *);
1.104 joris 326: void cvs_cleanup(void);
1.1 jfb 327:
1.104 joris 328: /* date.y */
329: time_t cvs_date_parse(const char *);
330:
331: /* entries.c */
332: struct cvs_ent *cvs_ent_parse(const char *);
333: struct cvs_ent *cvs_ent_get(CVSENTRIES *, const char *);
334: CVSENTRIES *cvs_ent_open(const char *);
335: void cvs_ent_add(CVSENTRIES *, const char *);
336: void cvs_ent_remove(CVSENTRIES *, const char *);
337: void cvs_ent_close(CVSENTRIES *, int);
338: void cvs_ent_free(struct cvs_ent *);
339: int cvs_ent_exists(CVSENTRIES *, const char *);
1.1 jfb 340:
1.69 xsa 341: /* root.c */
1.74 xsa 342: struct cvsroot *cvsroot_parse(const char *);
1.104 joris 343: struct cvsroot *cvsroot_get(const char *);
1.83 joris 344: void cvsroot_remove(struct cvsroot *);
1.87 joris 345:
1.104 joris 346: /* misc stuff */
347: void cvs_update_local(struct cvs_file *);
348: void cvs_update_enterdir(struct cvs_file *);
1.105 joris 349: void cvs_update_leavedir(struct cvs_file *);
1.104 joris 350: int cvs_checkout_file(struct cvs_file *, RCSNUM *, int);
1.1 jfb 351:
1.91 joris 352: #endif