Annotation of src/usr.bin/cvs/cvs.h, Revision 1.6
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>
31:
32: #include "rcs.h"
33:
34: #define CVS_VERSION "OpenCVS 0.1"
35:
36:
37: #define CVS_HIST_CACHE 128
38: #define CVS_HIST_NBFLD 6
39:
40:
41: #define CVS_REQ_TIMEOUT 300
42:
43:
44:
45: #define CVS_CKSUM_LEN 33 /* length of a CVS checksum string */
46:
47:
48: /* operations */
49: #define CVS_OP_ADD 1
50: #define CVS_OP_ANNOTATE 2
51: #define CVS_OP_COMMIT 3
52: #define CVS_OP_DIFF 4
53: #define CVS_OP_TAG 5
54: #define CVS_OP_UPDATE 6
55:
56:
57:
58:
59: /* methods */
60: #define CVS_METHOD_NONE 0
61: #define CVS_METHOD_LOCAL 1 /* local access */
62: #define CVS_METHOD_SERVER 2 /* tunnel through CVS_RSH */
63: #define CVS_METHOD_PSERVER 3 /* cvs pserver */
64: #define CVS_METHOD_KSERVER 4 /* kerberos */
65: #define CVS_METHOD_GSERVER 5 /* gssapi server */
66: #define CVS_METHOD_EXT 6
67: #define CVS_METHOD_FORK 7 /* local but fork */
68:
69: /* client/server protocol requests */
70: #define CVS_REQ_NONE 0
71: #define CVS_REQ_ROOT 1
72: #define CVS_REQ_VALIDREQ 2
73: #define CVS_REQ_VALIDRESP 3
74: #define CVS_REQ_DIRECTORY 4
75: #define CVS_REQ_MAXDOTDOT 5
76: #define CVS_REQ_STATICDIR 6
77: #define CVS_REQ_STICKY 7
78: #define CVS_REQ_ENTRY 8
79: #define CVS_REQ_ENTRYEXTRA 9
80: #define CVS_REQ_CHECKINTIME 10
81: #define CVS_REQ_MODIFIED 11
82: #define CVS_REQ_ISMODIFIED 12
83: #define CVS_REQ_UNCHANGED 13
84: #define CVS_REQ_USEUNCHANGED 14
85: #define CVS_REQ_NOTIFY 15
86: #define CVS_REQ_NOTIFYUSER 16
87: #define CVS_REQ_QUESTIONABLE 17
88: #define CVS_REQ_CASE 18
89: #define CVS_REQ_UTF8 19
90: #define CVS_REQ_ARGUMENT 20
91: #define CVS_REQ_ARGUMENTX 21
92: #define CVS_REQ_GLOBALOPT 22
93: #define CVS_REQ_GZIPSTREAM 23
94: #define CVS_REQ_KERBENCRYPT 24
95: #define CVS_REQ_GSSENCRYPT 25
96: #define CVS_REQ_PROTOENCRYPT 26
97: #define CVS_REQ_GSSAUTH 27
98: #define CVS_REQ_PROTOAUTH 28
99: #define CVS_REQ_READCVSRC2 29
100: #define CVS_REQ_READWRAP 30
101: #define CVS_REQ_ERRIFREADER 31
102: #define CVS_REQ_VALIDRCSOPT 32
103: #define CVS_REQ_READIGNORE 33
104: #define CVS_REQ_SET 34
105: #define CVS_REQ_XPANDMOD 35
106: #define CVS_REQ_CI 36
107: #define CVS_REQ_CHOWN 37
108: #define CVS_REQ_SETOWN 38
109: #define CVS_REQ_SETPERM 39
110: #define CVS_REQ_CHACL 40
111: #define CVS_REQ_LISTPERM 41
112: #define CVS_REQ_LISTACL 42
113: #define CVS_REQ_SETPASS 43
114: #define CVS_REQ_PASSWD 44
115: #define CVS_REQ_DIFF 45
116: #define CVS_REQ_STATUS 46
117: #define CVS_REQ_LS 47
118: #define CVS_REQ_TAG 48
119: #define CVS_REQ_IMPORT 49
120: #define CVS_REQ_ADMIN 50
121: #define CVS_REQ_HISTORY 51
122: #define CVS_REQ_WATCHERS 52
123: #define CVS_REQ_EDITORS 53
124: #define CVS_REQ_ANNOTATE 54
125: #define CVS_REQ_LOG 55
126: #define CVS_REQ_CO 56
127: #define CVS_REQ_EXPORT 57
128: #define CVS_REQ_RANNOTATE 58
129: #define CVS_REQ_INIT 59
130: #define CVS_REQ_UPDATE 60
131: #define CVS_REQ_ADD 62
132: #define CVS_REQ_REMOVE 63
133: #define CVS_REQ_NOOP 64
134: #define CVS_REQ_RTAG 65
135: #define CVS_REQ_RELEASE 66
136: #define CVS_REQ_RLOG 67
137: #define CVS_REQ_RDIFF 68
138: #define CVS_REQ_VERSION 69
139:
140: #define CVS_REQ_MAX 69
141:
142:
143: /* responses */
144: #define CVS_RESP_OK 1
145: #define CVS_RESP_ERROR 2
146: #define CVS_RESP_VALIDREQ 3
147: #define CVS_RESP_CHECKEDIN 4
148: #define CVS_RESP_NEWENTRY 5
149: #define CVS_RESP_CKSUM 6
150: #define CVS_RESP_COPYFILE 7
151: #define CVS_RESP_UPDATED 8
152: #define CVS_RESP_CREATED 9
153: #define CVS_RESP_UPDEXIST 10
154: #define CVS_RESP_MERGED 11
155: #define CVS_RESP_PATCHED 12
156: #define CVS_RESP_RCSDIFF 13
157: #define CVS_RESP_MODE 14
158: #define CVS_RESP_MODTIME 15
159: #define CVS_RESP_REMOVED 16
160: #define CVS_RESP_RMENTRY 17
161: #define CVS_RESP_SETSTATDIR 18
162: #define CVS_RESP_CLRSTATDIR 19
163: #define CVS_RESP_SETSTICKY 20
164: #define CVS_RESP_CLRSTICKY 21
165: #define CVS_RESP_TEMPLATE 22
166: #define CVS_RESP_SETCIPROG 23
167: #define CVS_RESP_SETUPDPROG 24
168: #define CVS_RESP_NOTIFIED 25
169: #define CVS_RESP_MODXPAND 26
170: #define CVS_RESP_WRAPRCSOPT 27
171: #define CVS_RESP_M 28
172: #define CVS_RESP_MBINARY 29
173: #define CVS_RESP_E 30
174: #define CVS_RESP_F 31
175: #define CVS_RESP_MT 32
176:
177:
178:
179:
180: #define CVS_CMD_MAXNAMELEN 16
181: #define CVS_CMD_MAXALIAS 2
182: #define CVS_CMD_MAXDESCRLEN 64
183:
184:
185: /* defaults */
186: #define CVS_RSH_DEFAULT "ssh"
187: #define CVS_EDITOR_DEFAULT "vi"
188:
189:
190: /* server-side paths */
191: #define CVS_PATH_ROOT "CVSROOT"
192: #define CVS_PATH_COMMITINFO CVS_PATH_ROOT "/commitinfo"
193: #define CVS_PATH_CONFIG CVS_PATH_ROOT "/config"
194: #define CVS_PATH_CVSIGNORE CVS_PATH_ROOT "/cvsignore"
195: #define CVS_PATH_CVSWRAPPERS CVS_PATH_ROOT "/cvswrappers"
196: #define CVS_PATH_EDITINFO CVS_PATH_ROOT "/editinfo"
197: #define CVS_PATH_HISTORY CVS_PATH_ROOT "/history"
198: #define CVS_PATH_LOGINFO CVS_PATH_ROOT "/loginfo"
199: #define CVS_PATH_MODULES CVS_PATH_ROOT "/modules"
200: #define CVS_PATH_NOTIFY CVS_PATH_ROOT "/notify"
201: #define CVS_PATH_RCSINFO CVS_PATH_ROOT "/rcsinfo"
202: #define CVS_PATH_TAGINFO CVS_PATH_ROOT "/taginfo"
203: #define CVS_PATH_VERIFYMSG CVS_PATH_ROOT "/verifymsg"
204:
205:
206: /* client-side paths */
207: #define CVS_PATH_RC ".cvsrc"
208: #define CVS_PATH_CVSDIR "CVS"
209: #define CVS_PATH_ENTRIES CVS_PATH_CVSDIR "/Entries"
210: #define CVS_PATH_STATICENTRIES CVS_PATH_CVSDIR "/Entries.Static"
211: #define CVS_PATH_LOGENTRIES CVS_PATH_CVSDIR "/Entries.Log"
212: #define CVS_PATH_ROOTSPEC CVS_PATH_CVSDIR "/Root"
213:
214:
215: struct cvs_op {
216: u_int co_op;
217: uid_t co_uid; /* user performing the operation */
218: char *co_path; /* target path of the operation */
219: char *co_tag; /* tag or branch, NULL if HEAD */
220: };
221:
222:
223:
224:
225:
226:
227: struct cvsroot {
228: u_int cr_method;
229: char *cr_buf;
230: char *cr_user;
231: char *cr_pass;
232: char *cr_host;
233: char *cr_dir;
234: u_int cr_port;
235: };
236:
237:
238: #define CVS_HIST_ADDED 'A'
239: #define CVS_HIST_EXPORT 'E'
240: #define CVS_HIST_RELEASE 'F'
241: #define CVS_HIST_MODIFIED 'M'
242: #define CVS_HIST_CHECKOUT 'O'
243: #define CVS_HIST_COMMIT 'R'
244: #define CVS_HIST_TAG 'T'
245:
246:
247: #define CVS_ENT_NONE 0
248: #define CVS_ENT_FILE 1
249: #define CVS_ENT_DIR 2
250:
251:
252: struct cvs_ent {
253: char *ce_line;
254: char *ce_buf;
255: u_int ce_type;
256: char *ce_name;
257: RCSNUM *ce_rev;
258: char *ce_timestamp;
259: char *ce_opts;
260: char *ce_tag;
1.4 jfb 261: TAILQ_ENTRY(cvs_ent) ce_list;
1.1 jfb 262: };
263:
264: typedef struct cvs_entries {
265: char *cef_path;
1.3 jfb 266: FILE *cef_file;
1.1 jfb 267:
1.4 jfb 268: TAILQ_HEAD(, cvs_ent) cef_ent;
269: struct cvs_ent *cef_cur;
1.1 jfb 270: } CVSENTRIES;
271:
272:
273:
274: struct cvs_hent {
275: char ch_event;
276: time_t ch_date;
277: uid_t ch_uid;
278: char *ch_user;
279: char *ch_curdir;
280: char *ch_repo;
281: RCSNUM *ch_rev;
282: char *ch_arg;
283: };
284:
285:
286: typedef struct cvs_histfile {
287: int chf_fd;
288: char *chf_buf; /* read buffer */
289: size_t chf_blen; /* buffer size */
290: size_t chf_bused; /* bytes used in buffer */
291:
292: off_t chf_off; /* next read */
293: u_int chf_sindex; /* history entry index of first in array */
294: u_int chf_cindex; /* current index (for getnext()) */
295: u_int chf_nbhent; /* number of valid entries in the array */
296:
297: struct cvs_hent chf_hent[CVS_HIST_CACHE];
298:
299: } CVSHIST;
300:
301:
302:
303: /* client command handlers */
304: int cvs_add (int, char **);
305: int cvs_commit (int, char **);
306: int cvs_diff (int, char **);
307: int cvs_getlog (int, char **);
308: int cvs_history (int, char **);
309: int cvs_init (int, char **);
310: int cvs_server (int, char **);
311: int cvs_update (int, char **);
312: int cvs_version (int, char **);
313:
314:
315: /* proto.c */
316: int cvs_req_handle (char *);
317: const char* cvs_req_getbyid (int);
318: int cvs_req_getbyname (const char *);
319: char* cvs_req_getvalid (void);
320:
1.2 jfb 321:
1.1 jfb 322: int cvs_resp_handle (char *);
323: const char* cvs_resp_getbyid (int);
324: int cvs_resp_getbyname (const char *);
325: char* cvs_resp_getvalid (void);
326:
327: int cvs_sendfile (const char *);
328: int cvs_recvfile (const char *);
329:
330:
331: /* from client.c */
332: int cvs_client_connect (void);
333: void cvs_client_disconnect (void);
334: int cvs_client_sendreq (u_int, const char *, int);
335: int cvs_client_sendarg (const char *, int);
336: int cvs_client_sendln (const char *);
337: int cvs_client_sendraw (const void *, size_t);
338: ssize_t cvs_client_recvraw (void *, size_t);
339: int cvs_client_getln (char *, size_t);
340: int cvs_client_senddir (const char *);
341:
342:
343: /* from root.c */
344: struct cvsroot* cvsroot_parse (const char *);
345: void cvsroot_free (struct cvsroot *);
346: struct cvsroot* cvsroot_get (const char *);
1.2 jfb 347:
348:
349: int cvs_file_init (void);
350: int cvs_file_ignore (const char *);
351: int cvs_file_isignored (const char *);
352: char** cvs_file_getv (const char *, int *);
1.1 jfb 353:
354:
355: /* Entries API */
1.3 jfb 356: CVSENTRIES* cvs_ent_open (const char *, int);
1.1 jfb 357: struct cvs_ent* cvs_ent_get (CVSENTRIES *, const char *);
358: struct cvs_ent* cvs_ent_next (CVSENTRIES *);
359: int cvs_ent_add (CVSENTRIES *, struct cvs_ent *);
1.5 jfb 360: int cvs_ent_addln (CVSENTRIES *, const char *);
1.1 jfb 361: int cvs_ent_remove (CVSENTRIES *, const char *);
362: struct cvs_ent* cvs_ent_parse (const char *);
363: void cvs_ent_close (CVSENTRIES *);
364:
365: /* history API */
366: CVSHIST* cvs_hist_open (const char *);
367: void cvs_hist_close (CVSHIST *);
368: int cvs_hist_parse (CVSHIST *);
369: struct cvs_hent* cvs_hist_getnext (CVSHIST *);
370: int cvs_hist_append (CVSHIST *, struct cvs_hent *);
371:
372:
373: /* from util.c */
374: int cvs_readrepo (const char *, char *, size_t);
375: int cvs_splitpath (const char *, char *, size_t, char *, size_t);
376: int cvs_modetostr (mode_t, char *, size_t);
377: int cvs_strtomode (const char *, mode_t *);
378: int cvs_cksum (const char *, char *, size_t);
379: int cvs_exec (int, char **, int []);
1.6 ! jfb 380: int cvs_getargv (const char *, char **, int);
! 381: void cvs_freeargv (char **, int);
1.1 jfb 382:
383:
384: #endif /* CVS_H */