Annotation of src/usr.bin/cvs/cvs.h, Revision 1.111
1.111 ! joris 1: /* $OpenBSD: cvs.h,v 1.110 2006/05/30 06:34:39 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.110 joris 142: #define CVS_PATH_ATTIC "Attic"
1.1 jfb 143:
1.46 joris 144: struct cvs_cmd {
1.103 joris 145: u_int cmd_op;
146: u_int cmd_req;
1.86 reyk 147: char cmd_name[CVS_CMD_MAXNAMELEN];
148: char cmd_alias[CVS_CMD_MAXALIAS][CVS_CMD_MAXNAMELEN];
149: char cmd_descr[CVS_CMD_MAXDESCRLEN];
150: char *cmd_synopsis;
151: char *cmd_opts;
152: char *cmd_defargs;
1.58 jfb 153:
1.104 joris 154: int (*cmd)(int, char **);
155: };
156:
157: struct cvsroot;
1.58 jfb 158:
1.104 joris 159: struct cvs_recursion {
160: void (*enterdir)(struct cvs_file *);
161: void (*leavedir)(struct cvs_file *);
162: void (*local)(struct cvs_file *);
163: void (*remote)(struct cvs_file *, struct cvsroot *);
1.106 joris 164: int flags;
1.46 joris 165: };
1.106 joris 166:
167: #define CR_RECURSE_DIRS 0x01
168: #define CR_ATTIC 0x02
169: #define CR_REPO 0x04
1.1 jfb 170:
1.41 jfb 171: struct cvs_var {
172: char *cv_name;
173: char *cv_val;
174: TAILQ_ENTRY(cvs_var) cv_link;
175: };
176:
1.74 xsa 177: #define CVS_ROOT_CONNECTED 0x01
1.36 jfb 178:
1.1 jfb 179: struct cvsroot {
1.11 jfb 180: char *cr_str;
1.1 jfb 181: u_int cr_method;
182: char *cr_buf;
183: char *cr_user;
184: char *cr_pass;
185: char *cr_host;
186: char *cr_dir;
187: u_int cr_port;
1.11 jfb 188: u_int cr_ref;
189:
190: /* connection data */
1.36 jfb 191: u_int cr_flags;
1.11 jfb 192: FILE *cr_srvin;
193: FILE *cr_srvout;
1.21 jfb 194: FILE *cr_srverr;
1.29 jfb 195: char *cr_version; /* version of remote server */
196: u_char cr_vrmask[16]; /* mask of valid requests supported by server */
1.78 joris 197:
198: TAILQ_ENTRY(cvsroot) root_cache;
1.1 jfb 199: };
1.20 jfb 200:
1.74 xsa 201: #define CVS_SETVR(rt, rq) ((rt)->cr_vrmask[(rq) / 8] |= (1 << ((rq) % 8)))
202: #define CVS_GETVR(rt, rq) ((rt)->cr_vrmask[(rq) / 8] & (1 << ((rq) % 8)))
203: #define CVS_CLRVR(rt, rq) ((rt)->cr_vrmask[(rq) / 8] &= ~(1 << ((rq) % 8)))
204: #define CVS_RSTVR(rt) memset((rt)->cr_vrmask, 0, sizeof((rt)->cr_vrmask))
205:
206: #define CVS_HIST_ADDED 'A'
207: #define CVS_HIST_EXPORT 'E'
208: #define CVS_HIST_RELEASE 'F'
209: #define CVS_HIST_MODIFIED 'M'
210: #define CVS_HIST_CHECKOUT 'O'
211: #define CVS_HIST_COMMIT 'R'
212: #define CVS_HIST_TAG 'T'
213:
214: #define CVS_DATE_DUMMY "dummy timestamp"
215: #define CVS_DATE_DMSEC (time_t)-1
216:
217: #define CVS_ENT_NONE 0
218: #define CVS_ENT_FILE 1
219: #define CVS_ENT_DIR 2
220:
221: #define CVS_ENT_REG 0
222: #define CVS_ENT_ADDED 1
223: #define CVS_ENT_REMOVED 2
224: #define CVS_ENT_UPTODATE 3
1.80 xsa 225:
226: #define CVS_ENT_MAXLINELEN 1024
1.1 jfb 227:
1.104 joris 228: #define ENT_NOSYNC 0
229: #define ENT_SYNC 1
1.17 jfb 230:
1.85 joris 231: #define STRIP_SLASH(p) \
232: do { \
233: size_t _slen; \
234: _slen = strlen(p); \
235: while ((_slen > 0) && (p[_slen - 1] == '/')) \
236: p[--_slen] = '\0'; \
237: } while (0)
1.104 joris 238:
1.1 jfb 239: struct cvs_ent {
1.104 joris 240: char *ce_buf;
241: char *ce_name;
242: char *ce_opts;
243: char *ce_tag;
244: char *ce_conflict;
245: time_t ce_mtime;
246: u_int16_t ce_type;
247: u_int16_t ce_status;
248: RCSNUM *ce_rev;
249: };
250:
251: struct cvs_ent_line {
252: char *buf;
253: TAILQ_ENTRY(cvs_ent_line) entries_list;
1.1 jfb 254: };
255:
256: typedef struct cvs_entries {
1.74 xsa 257: char *cef_path;
1.89 joris 258: char *cef_bpath;
1.104 joris 259: char *cef_lpath;
1.1 jfb 260:
1.104 joris 261: TAILQ_HEAD(, cvs_ent_line) cef_ent;
1.1 jfb 262: } CVSENTRIES;
263:
1.104 joris 264: extern struct cvs_wklhead temp_files;
265: extern volatile sig_atomic_t sig_received;
266: extern volatile sig_atomic_t cvs_quit;
267: extern struct cvsroot *current_cvsroot;
1.107 joris 268: extern char *cvs_tagname;
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.110 joris 275: extern char *import_repository;
1.22 jfb 276:
1.107 joris 277: extern int cvs_umask;
1.42 jfb 278: extern int verbosity;
279: extern int cvs_trace;
280: extern int cvs_nolog;
281: extern int cvs_compress;
282: extern int cvs_cmdop;
283: extern int cvs_nocase;
1.57 xsa 284: extern int cvs_noexec;
1.42 jfb 285: extern int cvs_readonly;
1.72 joris 286: extern int cvs_error;
1.15 jfb 287:
1.58 jfb 288: extern struct cvs_cmd *cvs_cdt[];
1.1 jfb 289:
1.58 jfb 290: extern struct cvs_cmd cvs_cmd_add;
291: extern struct cvs_cmd cvs_cmd_admin;
292: extern struct cvs_cmd cvs_cmd_annotate;
293: extern struct cvs_cmd cvs_cmd_checkout;
294: extern struct cvs_cmd cvs_cmd_commit;
295: extern struct cvs_cmd cvs_cmd_diff;
296: extern struct cvs_cmd cvs_cmd_edit;
297: extern struct cvs_cmd cvs_cmd_editors;
298: extern struct cvs_cmd cvs_cmd_export;
299: extern struct cvs_cmd cvs_cmd_history;
300: extern struct cvs_cmd cvs_cmd_import;
301: extern struct cvs_cmd cvs_cmd_init;
302: extern struct cvs_cmd cvs_cmd_log;
303: extern struct cvs_cmd cvs_cmd_login;
304: extern struct cvs_cmd cvs_cmd_logout;
305: extern struct cvs_cmd cvs_cmd_rdiff;
306: extern struct cvs_cmd cvs_cmd_release;
307: extern struct cvs_cmd cvs_cmd_remove;
308: extern struct cvs_cmd cvs_cmd_rlog;
309: extern struct cvs_cmd cvs_cmd_rtag;
310: extern struct cvs_cmd cvs_cmd_status;
311: extern struct cvs_cmd cvs_cmd_tag;
312: extern struct cvs_cmd cvs_cmd_update;
313: extern struct cvs_cmd cvs_cmd_version;
314: extern struct cvs_cmd cvs_cmd_server;
315: extern struct cvs_cmd cvs_cmd_unedit;
316: extern struct cvs_cmd cvs_cmd_watch;
317: extern struct cvs_cmd cvs_cmd_watchers;
318:
1.104 joris 319: /* cmd.c */
1.74 xsa 320: struct cvs_cmd *cvs_findcmd(const char *);
321: struct cvs_cmd *cvs_findcmdbyreq(int);
322:
1.104 joris 323: /* cvs.c */
1.74 xsa 324: int cvs_var_set(const char *, const char *);
325: int cvs_var_unset(const char *);
326: const char *cvs_var_get(const char *);
1.104 joris 327: void cvs_cleanup(void);
1.1 jfb 328:
1.104 joris 329: /* date.y */
330: time_t cvs_date_parse(const char *);
331:
332: /* entries.c */
333: struct cvs_ent *cvs_ent_parse(const char *);
334: struct cvs_ent *cvs_ent_get(CVSENTRIES *, const char *);
335: CVSENTRIES *cvs_ent_open(const char *);
336: void cvs_ent_add(CVSENTRIES *, const char *);
337: void cvs_ent_remove(CVSENTRIES *, const char *);
338: void cvs_ent_close(CVSENTRIES *, int);
339: void cvs_ent_free(struct cvs_ent *);
340: int cvs_ent_exists(CVSENTRIES *, const char *);
1.1 jfb 341:
1.69 xsa 342: /* root.c */
1.74 xsa 343: struct cvsroot *cvsroot_parse(const char *);
1.104 joris 344: struct cvsroot *cvsroot_get(const char *);
1.83 joris 345: void cvsroot_remove(struct cvsroot *);
1.87 joris 346:
1.104 joris 347: /* misc stuff */
348: void cvs_update_local(struct cvs_file *);
349: void cvs_update_enterdir(struct cvs_file *);
1.105 joris 350: void cvs_update_leavedir(struct cvs_file *);
1.109 joris 351: void cvs_checkout_file(struct cvs_file *, RCSNUM *, BUF *, int);
352: int update_has_conflict_markers(struct cvs_file *);
353:
354: #define CO_MERGE 0x01
1.111 ! joris 355: #define CO_SETSTICKY 0x02
1.1 jfb 356:
1.91 joris 357: #endif