Annotation of src/usr.bin/cvs/cvs.h, Revision 1.30
1.1 jfb 1: /* $OpenBSD$ */
2: /*
3: * Copyright (c) 2004 Jean-Francois Brousseau <jfb@openbsd.org>
4: * All rights reserved.
5: *
6: * Redistribution and use in source and binary forms, with or without
7: * modification, are permitted provided that the following conditions
8: * are met:
9: *
10: * 1. Redistributions of source code must retain the above copyright
11: * notice, this list of conditions and the following disclaimer.
12: * 2. The name of the author may not be used to endorse or promote products
13: * derived from this software without specific prior written permission.
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
24: * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
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:
48:
49: /* operations */
1.19 jfb 50: #define CVS_OP_UNKNOWN 0
1.1 jfb 51: #define CVS_OP_ADD 1
52: #define CVS_OP_ANNOTATE 2
1.16 jfb 53: #define CVS_OP_CHECKOUT 3
54: #define CVS_OP_COMMIT 4
55: #define CVS_OP_DIFF 5
56: #define CVS_OP_HISTORY 6
57: #define CVS_OP_IMPORT 7
58: #define CVS_OP_INIT 8
59: #define CVS_OP_LOG 9
60: #define CVS_OP_REMOVE 10
61: #define CVS_OP_SERVER 11
62: #define CVS_OP_STATUS 12
63: #define CVS_OP_TAG 13
64: #define CVS_OP_UPDATE 14
65: #define CVS_OP_VERSION 15
1.1 jfb 66:
1.19 jfb 67: #define CVS_OP_ANY 64 /* all operations */
1.1 jfb 68:
69:
70:
71: /* methods */
72: #define CVS_METHOD_NONE 0
73: #define CVS_METHOD_LOCAL 1 /* local access */
74: #define CVS_METHOD_SERVER 2 /* tunnel through CVS_RSH */
75: #define CVS_METHOD_PSERVER 3 /* cvs pserver */
76: #define CVS_METHOD_KSERVER 4 /* kerberos */
77: #define CVS_METHOD_GSERVER 5 /* gssapi server */
78: #define CVS_METHOD_EXT 6
79: #define CVS_METHOD_FORK 7 /* local but fork */
80:
81: #define CVS_CMD_MAXNAMELEN 16
82: #define CVS_CMD_MAXALIAS 2
83: #define CVS_CMD_MAXDESCRLEN 64
84:
85:
86: /* defaults */
1.21 jfb 87: #define CVS_SERVER_DEFAULT "cvs"
1.1 jfb 88: #define CVS_RSH_DEFAULT "ssh"
89: #define CVS_EDITOR_DEFAULT "vi"
90:
91:
92: /* server-side paths */
93: #define CVS_PATH_ROOT "CVSROOT"
94: #define CVS_PATH_COMMITINFO CVS_PATH_ROOT "/commitinfo"
95: #define CVS_PATH_CONFIG CVS_PATH_ROOT "/config"
96: #define CVS_PATH_CVSIGNORE CVS_PATH_ROOT "/cvsignore"
97: #define CVS_PATH_CVSWRAPPERS CVS_PATH_ROOT "/cvswrappers"
98: #define CVS_PATH_EDITINFO CVS_PATH_ROOT "/editinfo"
99: #define CVS_PATH_HISTORY CVS_PATH_ROOT "/history"
100: #define CVS_PATH_LOGINFO CVS_PATH_ROOT "/loginfo"
101: #define CVS_PATH_MODULES CVS_PATH_ROOT "/modules"
102: #define CVS_PATH_NOTIFY CVS_PATH_ROOT "/notify"
103: #define CVS_PATH_RCSINFO CVS_PATH_ROOT "/rcsinfo"
104: #define CVS_PATH_TAGINFO CVS_PATH_ROOT "/taginfo"
105: #define CVS_PATH_VERIFYMSG CVS_PATH_ROOT "/verifymsg"
106:
107:
108: /* client-side paths */
109: #define CVS_PATH_RC ".cvsrc"
110: #define CVS_PATH_CVSDIR "CVS"
111: #define CVS_PATH_ENTRIES CVS_PATH_CVSDIR "/Entries"
112: #define CVS_PATH_STATICENTRIES CVS_PATH_CVSDIR "/Entries.Static"
113: #define CVS_PATH_LOGENTRIES CVS_PATH_CVSDIR "/Entries.Log"
114: #define CVS_PATH_ROOTSPEC CVS_PATH_CVSDIR "/Root"
1.10 jfb 115: #define CVS_PATH_REPOSITORY CVS_PATH_CVSDIR "/Repository"
1.1 jfb 116:
117:
1.7 jfb 118: struct cvs_file;
119: struct cvs_dir;
1.19 jfb 120: struct cvs_flist;
1.7 jfb 121:
1.1 jfb 122: struct cvs_op {
1.19 jfb 123: u_int co_op;
124: uid_t co_uid; /* user performing the operation */
125: char *co_tag; /* tag or branch, NULL if HEAD */
126: char *co_msg; /* message string (on commit or add) */
127: struct cvs_flist co_files;
1.1 jfb 128: };
129:
130:
131:
132: struct cvsroot {
1.11 jfb 133: char *cr_str;
1.1 jfb 134: u_int cr_method;
135: char *cr_buf;
136: char *cr_user;
137: char *cr_pass;
138: char *cr_host;
139: char *cr_dir;
140: u_int cr_port;
1.11 jfb 141: u_int cr_ref;
142:
143: /* connection data */
144: FILE *cr_srvin;
145: FILE *cr_srvout;
1.21 jfb 146: FILE *cr_srverr;
1.29 jfb 147: char *cr_version; /* version of remote server */
148: u_char cr_vrmask[16]; /* mask of valid requests supported by server */
1.1 jfb 149: };
1.20 jfb 150:
1.29 jfb 151: #define CVS_SETVR(rt, rq) ((rt)->cr_vrmask[(rq) / 8] |= (1 << ((rq) % 8)))
152: #define CVS_GETVR(rt, rq) ((rt)->cr_vrmask[(rq) / 8] & (1 << ((rq) % 8)))
153: #define CVS_CLRVR(rt, rq) ((rt)->cr_vrmask[(rq) / 8] &= ~(1 << ((rq) % 8)))
1.20 jfb 154: #define CVS_RSTVR(rt) memset((rt)->cr_vrmask, 0, sizeof((rt)->cr_vrmask))
1.1 jfb 155:
156:
157: #define CVS_HIST_ADDED 'A'
158: #define CVS_HIST_EXPORT 'E'
159: #define CVS_HIST_RELEASE 'F'
160: #define CVS_HIST_MODIFIED 'M'
161: #define CVS_HIST_CHECKOUT 'O'
162: #define CVS_HIST_COMMIT 'R'
163: #define CVS_HIST_TAG 'T'
164:
165:
1.28 jfb 166: #define CVS_DATE_DUMMY "dummy timestamp"
167: #define CVS_DATE_DMSEC (time_t)-1
1.27 jfb 168:
1.1 jfb 169: #define CVS_ENT_NONE 0
170: #define CVS_ENT_FILE 1
171: #define CVS_ENT_DIR 2
1.27 jfb 172:
1.1 jfb 173:
1.17 jfb 174: #define CVS_ENTF_SYNC 0x01 /* contents of disk and memory match */
175: #define CVS_ENTF_WR 0x02 /* file is opened for writing too */
176:
1.1 jfb 177:
178: struct cvs_ent {
179: char *ce_buf;
180: u_int ce_type;
181: char *ce_name;
182: RCSNUM *ce_rev;
1.26 jfb 183: time_t ce_mtime;
1.1 jfb 184: char *ce_opts;
185: char *ce_tag;
1.4 jfb 186: TAILQ_ENTRY(cvs_ent) ce_list;
1.1 jfb 187: };
188:
189: typedef struct cvs_entries {
190: char *cef_path;
1.3 jfb 191: FILE *cef_file;
1.17 jfb 192: u_int cef_flags;
1.1 jfb 193:
1.4 jfb 194: TAILQ_HEAD(, cvs_ent) cef_ent;
195: struct cvs_ent *cef_cur;
1.1 jfb 196: } CVSENTRIES;
197:
198:
199:
200: struct cvs_hent {
201: char ch_event;
202: time_t ch_date;
203: uid_t ch_uid;
204: char *ch_user;
205: char *ch_curdir;
206: char *ch_repo;
207: RCSNUM *ch_rev;
208: char *ch_arg;
209: };
210:
211:
212: typedef struct cvs_histfile {
213: int chf_fd;
214: char *chf_buf; /* read buffer */
215: size_t chf_blen; /* buffer size */
216: size_t chf_bused; /* bytes used in buffer */
217:
218: off_t chf_off; /* next read */
219: u_int chf_sindex; /* history entry index of first in array */
220: u_int chf_cindex; /* current index (for getnext()) */
221: u_int chf_nbhent; /* number of valid entries in the array */
222:
223: struct cvs_hent chf_hent[CVS_HIST_CACHE];
224:
225: } CVSHIST;
226:
227:
1.15 jfb 228: #ifdef CVS
1.22 jfb 229: extern char *cvs_command;
1.18 jfb 230: extern char *cvs_editor;
1.30 ! krapht 231: extern char *cvs_msg;
1.22 jfb 232:
233: extern int cvs_cmdop;
1.24 jfb 234: extern int cvs_nocase;
1.22 jfb 235:
1.23 jfb 236: extern CVSFILE *cvs_files;
237:
1.15 jfb 238: #endif
239:
240:
1.1 jfb 241:
242: /* client command handlers */
243: int cvs_add (int, char **);
1.9 jfb 244: int cvs_checkout (int, char **);
1.1 jfb 245: int cvs_commit (int, char **);
246: int cvs_diff (int, char **);
247: int cvs_getlog (int, char **);
248: int cvs_history (int, char **);
1.30 ! krapht 249: int cvs_import (int, char **);
1.1 jfb 250: int cvs_init (int, char **);
251: int cvs_server (int, char **);
1.15 jfb 252: int cvs_status (int, char **);
1.1 jfb 253: int cvs_update (int, char **);
254: int cvs_version (int, char **);
255:
256:
257: /* from root.c */
258: struct cvsroot* cvsroot_parse (const char *);
259: void cvsroot_free (struct cvsroot *);
260: struct cvsroot* cvsroot_get (const char *);
1.2 jfb 261:
262:
1.1 jfb 263: /* Entries API */
1.3 jfb 264: CVSENTRIES* cvs_ent_open (const char *, int);
1.1 jfb 265: struct cvs_ent* cvs_ent_get (CVSENTRIES *, const char *);
266: struct cvs_ent* cvs_ent_next (CVSENTRIES *);
267: int cvs_ent_add (CVSENTRIES *, struct cvs_ent *);
1.5 jfb 268: int cvs_ent_addln (CVSENTRIES *, const char *);
1.1 jfb 269: int cvs_ent_remove (CVSENTRIES *, const char *);
1.17 jfb 270: int cvs_ent_write (CVSENTRIES *);
1.1 jfb 271: struct cvs_ent* cvs_ent_parse (const char *);
272: void cvs_ent_close (CVSENTRIES *);
1.8 jfb 273: void cvs_ent_free (struct cvs_ent *);
274: struct cvs_ent* cvs_ent_getent (const char *);
1.1 jfb 275:
276: /* history API */
277: CVSHIST* cvs_hist_open (const char *);
278: void cvs_hist_close (CVSHIST *);
279: int cvs_hist_parse (CVSHIST *);
280: struct cvs_hent* cvs_hist_getnext (CVSHIST *);
281: int cvs_hist_append (CVSHIST *, struct cvs_hent *);
282:
283:
284: /* from util.c */
1.28 jfb 285:
286: #define CVS_DATE_CTIME 0
287: #define CVS_DATE_RFC822 1
288:
1.1 jfb 289: int cvs_readrepo (const char *, char *, size_t);
1.28 jfb 290: time_t cvs_datesec (const char *, int, int);
1.1 jfb 291: int cvs_modetostr (mode_t, char *, size_t);
292: int cvs_strtomode (const char *, mode_t *);
1.26 jfb 293: int cvs_splitpath (const char *, char *, size_t, char **);
1.10 jfb 294: int cvs_mkadmin (struct cvs_file *, mode_t);
1.1 jfb 295: int cvs_cksum (const char *, char *, size_t);
296: int cvs_exec (int, char **, int []);
1.6 jfb 297: int cvs_getargv (const char *, char **, int);
298: void cvs_freeargv (char **, int);
1.1 jfb 299:
300:
301: #endif /* CVS_H */