Annotation of src/usr.bin/cvs/cvs.h, Revision 1.7
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:
1.7 ! jfb 215: struct cvs_file;
! 216: struct cvs_dir;
! 217:
! 218:
1.1 jfb 219: struct cvs_op {
220: u_int co_op;
221: uid_t co_uid; /* user performing the operation */
222: char *co_path; /* target path of the operation */
223: char *co_tag; /* tag or branch, NULL if HEAD */
224: };
225:
226:
227:
228: struct cvsroot {
229: u_int cr_method;
230: char *cr_buf;
231: char *cr_user;
232: char *cr_pass;
233: char *cr_host;
234: char *cr_dir;
235: u_int cr_port;
236: };
237:
238:
1.7 ! jfb 239: #define CF_STAT 0x01 /* allocate space for file stats */
! 240: #define CF_IGNORE 0x02 /* apply regular ignore rules */
! 241: #define CF_RECURSE 0x04 /* recurse on directory operations */
! 242: #define CF_SORT 0x08 /* all files are sorted alphabetically */
! 243:
! 244:
! 245: /*
! 246: * The cvs_file structure is used to represent any file or directory within
! 247: * the CVS tree's hierarchy. The <cf_path> field is a path relative to the
! 248: * directory in which the cvs command was executed. The <cf_parent> field
! 249: * points back to the parent node in the directory tree structure (it is
! 250: * NULL if the directory is at the wd of the command).
! 251: *
! 252: * If the file's type is DT_DIR, then the <cf_ddat> pointer will point to
! 253: * a cvs_dir structure containing data specific to the directory (such as
! 254: * the contents of the directory's CVS/Entries, CVS/Root, etc.).
! 255: */
! 256:
! 257: struct cvs_file {
! 258: char *cf_path;
! 259: struct cvs_file *cf_parent; /* parent directory (NULL if none) */
! 260: char *cf_name;
! 261: u_int cf_type; /* uses values from dirent.h */
! 262: struct stat *cf_stat;
! 263: struct cvs_dir *cf_ddat; /* only for directories */
! 264:
! 265: LIST_ENTRY(cvs_file) cf_list;
! 266: };
! 267:
! 268:
! 269: struct cvs_dir {
! 270: struct cvsroot *cd_root;
! 271: char *cd_repo;
! 272: LIST_HEAD(cvs_flist, cvs_file) cd_files;
! 273: };
! 274:
1.1 jfb 275: #define CVS_HIST_ADDED 'A'
276: #define CVS_HIST_EXPORT 'E'
277: #define CVS_HIST_RELEASE 'F'
278: #define CVS_HIST_MODIFIED 'M'
279: #define CVS_HIST_CHECKOUT 'O'
280: #define CVS_HIST_COMMIT 'R'
281: #define CVS_HIST_TAG 'T'
282:
283:
284: #define CVS_ENT_NONE 0
285: #define CVS_ENT_FILE 1
286: #define CVS_ENT_DIR 2
287:
288:
289: struct cvs_ent {
290: char *ce_line;
291: char *ce_buf;
292: u_int ce_type;
293: char *ce_name;
294: RCSNUM *ce_rev;
295: char *ce_timestamp;
296: char *ce_opts;
297: char *ce_tag;
1.4 jfb 298: TAILQ_ENTRY(cvs_ent) ce_list;
1.1 jfb 299: };
300:
301: typedef struct cvs_entries {
302: char *cef_path;
1.3 jfb 303: FILE *cef_file;
1.1 jfb 304:
1.4 jfb 305: TAILQ_HEAD(, cvs_ent) cef_ent;
306: struct cvs_ent *cef_cur;
1.1 jfb 307: } CVSENTRIES;
308:
309:
310:
311: struct cvs_hent {
312: char ch_event;
313: time_t ch_date;
314: uid_t ch_uid;
315: char *ch_user;
316: char *ch_curdir;
317: char *ch_repo;
318: RCSNUM *ch_rev;
319: char *ch_arg;
320: };
321:
322:
323: typedef struct cvs_histfile {
324: int chf_fd;
325: char *chf_buf; /* read buffer */
326: size_t chf_blen; /* buffer size */
327: size_t chf_bused; /* bytes used in buffer */
328:
329: off_t chf_off; /* next read */
330: u_int chf_sindex; /* history entry index of first in array */
331: u_int chf_cindex; /* current index (for getnext()) */
332: u_int chf_nbhent; /* number of valid entries in the array */
333:
334: struct cvs_hent chf_hent[CVS_HIST_CACHE];
335:
336: } CVSHIST;
337:
338:
339:
340: /* client command handlers */
341: int cvs_add (int, char **);
342: int cvs_commit (int, char **);
343: int cvs_diff (int, char **);
344: int cvs_getlog (int, char **);
345: int cvs_history (int, char **);
346: int cvs_init (int, char **);
347: int cvs_server (int, char **);
348: int cvs_update (int, char **);
349: int cvs_version (int, char **);
350:
351:
352: /* proto.c */
353: int cvs_req_handle (char *);
354: const char* cvs_req_getbyid (int);
355: int cvs_req_getbyname (const char *);
356: char* cvs_req_getvalid (void);
357:
1.2 jfb 358:
1.1 jfb 359: int cvs_resp_handle (char *);
360: const char* cvs_resp_getbyid (int);
361: int cvs_resp_getbyname (const char *);
362: char* cvs_resp_getvalid (void);
363:
364: int cvs_sendfile (const char *);
365: int cvs_recvfile (const char *);
366:
367:
368: /* from client.c */
369: int cvs_client_connect (void);
370: void cvs_client_disconnect (void);
371: int cvs_client_sendreq (u_int, const char *, int);
372: int cvs_client_sendarg (const char *, int);
373: int cvs_client_sendln (const char *);
374: int cvs_client_sendraw (const void *, size_t);
375: ssize_t cvs_client_recvraw (void *, size_t);
376: int cvs_client_getln (char *, size_t);
377: int cvs_client_senddir (const char *);
378:
379:
380: /* from root.c */
381: struct cvsroot* cvsroot_parse (const char *);
382: void cvsroot_free (struct cvsroot *);
383: struct cvsroot* cvsroot_get (const char *);
1.2 jfb 384:
385:
1.7 ! jfb 386: /* from file.c */
! 387: int cvs_file_init (void);
! 388: int cvs_file_ignore (const char *);
! 389: int cvs_file_isignored (const char *);
! 390: char** cvs_file_getv (const char *, int *, int);
! 391: struct cvs_file* cvs_file_get (const char *, int);
! 392: void cvs_file_free (struct cvs_file *);
1.1 jfb 393:
394:
395: /* Entries API */
1.3 jfb 396: CVSENTRIES* cvs_ent_open (const char *, int);
1.1 jfb 397: struct cvs_ent* cvs_ent_get (CVSENTRIES *, const char *);
398: struct cvs_ent* cvs_ent_next (CVSENTRIES *);
399: int cvs_ent_add (CVSENTRIES *, struct cvs_ent *);
1.5 jfb 400: int cvs_ent_addln (CVSENTRIES *, const char *);
1.1 jfb 401: int cvs_ent_remove (CVSENTRIES *, const char *);
402: struct cvs_ent* cvs_ent_parse (const char *);
403: void cvs_ent_close (CVSENTRIES *);
404:
405: /* history API */
406: CVSHIST* cvs_hist_open (const char *);
407: void cvs_hist_close (CVSHIST *);
408: int cvs_hist_parse (CVSHIST *);
409: struct cvs_hent* cvs_hist_getnext (CVSHIST *);
410: int cvs_hist_append (CVSHIST *, struct cvs_hent *);
411:
412:
413: /* from util.c */
414: int cvs_readrepo (const char *, char *, size_t);
415: int cvs_splitpath (const char *, char *, size_t, char *, size_t);
416: int cvs_modetostr (mode_t, char *, size_t);
417: int cvs_strtomode (const char *, mode_t *);
418: int cvs_cksum (const char *, char *, size_t);
419: int cvs_exec (int, char **, int []);
1.6 jfb 420: int cvs_getargv (const char *, char **, int);
421: void cvs_freeargv (char **, int);
1.1 jfb 422:
423:
424: #endif /* CVS_H */