Annotation of src/usr.bin/cvs/cvs.h, Revision 1.183
1.183 ! joris 1: /* $OpenBSD: cvs.h,v 1.182 2015/04/04 14:19:10 stsp 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.134 otto 30: #include <signal.h>
31:
32: #include "config.h"
33: #include "file.h"
34: #include "log.h"
35: #include "worklist.h"
36: #include "repository.h"
1.167 joris 37: #include "trigger.h"
1.128 niallo 38: #include "util.h"
1.104 joris 39: #include "xmalloc.h"
1.1 jfb 40:
1.174 joris 41: #define CVS_VERSION "OpenCVS 4.5"
1.140 xsa 42:
43: #define CVS_REV_BUFSZ 32
44: #define CVS_TIME_BUFSZ 64
1.161 xsa 45:
46: #define CVS_DATE_FMT "%Y.%m.%d.%H.%M.%S"
1.1 jfb 47:
48: /* operations */
1.74 xsa 49: #define CVS_OP_UNKNOWN 0
50: #define CVS_OP_ADD 1
51: #define CVS_OP_ADMIN 2
52: #define CVS_OP_ANNOTATE 3
53: #define CVS_OP_CHECKOUT 4
54: #define CVS_OP_COMMIT 5
55: #define CVS_OP_DIFF 6
56: #define CVS_OP_EDIT 7
57: #define CVS_OP_EDITORS 8
58: #define CVS_OP_EXPORT 9
59: #define CVS_OP_HISTORY 10
60: #define CVS_OP_IMPORT 11
61: #define CVS_OP_INIT 12
62: #define CVS_OP_LOG 13
63: #define CVS_OP_RANNOTATE 14
64: #define CVS_OP_RDIFF 15
65: #define CVS_OP_RELEASE 16
66: #define CVS_OP_REMOVE 17
67: #define CVS_OP_RLOG 18
68: #define CVS_OP_RTAG 19
69: #define CVS_OP_SERVER 20
70: #define CVS_OP_STATUS 21
71: #define CVS_OP_TAG 22
72: #define CVS_OP_UNEDIT 23
73: #define CVS_OP_UPDATE 24
74: #define CVS_OP_VERSION 25
75: #define CVS_OP_WATCH 26
76: #define CVS_OP_WATCHERS 27
1.1 jfb 77:
78: /* methods */
1.74 xsa 79: #define CVS_METHOD_NONE 0
80: #define CVS_METHOD_LOCAL 1 /* local access */
81: #define CVS_METHOD_SERVER 2 /* tunnel through CVS_RSH */
82: #define CVS_METHOD_PSERVER 3 /* cvs pserver */
83: #define CVS_METHOD_KSERVER 4 /* kerberos */
84: #define CVS_METHOD_GSERVER 5 /* gssapi server */
85: #define CVS_METHOD_EXT 6
86: #define CVS_METHOD_FORK 7 /* local but fork */
87:
88: #define CVS_CMD_MAXNAMELEN 16
89: #define CVS_CMD_MAXALIAS 2
90: #define CVS_CMD_MAXDESCRLEN 64
1.1 jfb 91:
1.149 tobias 92: /* flags */
1.164 joris 93: #define CVS_USE_WDIR 0x01
94: #define CVS_LOCK_REPO 0x02
1.149 tobias 95:
1.1 jfb 96: /* defaults */
1.74 xsa 97: #define CVS_SERVER_DEFAULT "cvs"
98: #define CVS_RSH_DEFAULT "ssh"
99: #define CVS_EDITOR_DEFAULT "vi"
1.77 xsa 100: #define CVS_TMPDIR_DEFAULT "/tmp"
1.107 joris 101: #define CVS_UMASK_DEFAULT 002
1.1 jfb 102:
1.70 xsa 103: /* extensions */
104: #define CVS_DESCR_FILE_EXT ",t"
1.1 jfb 105:
106: /* server-side paths */
1.108 joris 107: #define CVS_PATH_DEVNULL "/dev/null"
1.74 xsa 108: #define CVS_PATH_ROOT "CVSROOT"
109: #define CVS_PATH_EMPTYDIR CVS_PATH_ROOT "/Emptydir"
1.112 xsa 110: #define CVS_PATH_CHECKOUTLIST CVS_PATH_ROOT "/checkoutlist"
1.74 xsa 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"
1.112 xsa 122: #define CVS_PATH_VALTAGS CVS_PATH_ROOT "/val-tags"
1.74 xsa 123: #define CVS_PATH_VERIFYMSG CVS_PATH_ROOT "/verifymsg"
1.1 jfb 124:
125: /* client-side paths */
1.74 xsa 126: #define CVS_PATH_RC ".cvsrc"
127: #define CVS_PATH_CVSDIR "CVS"
1.100 xsa 128: #define CVS_PATH_BASEDIR CVS_PATH_CVSDIR "/Base"
129: #define CVS_PATH_BASEREV CVS_PATH_CVSDIR "/Baserev"
130: #define CVS_PATH_BASEREVTMP CVS_PATH_CVSDIR "/Baserev.tmp"
131: #define CVS_PATH_CHECKINPROG CVS_PATH_CVSDIR "/Checkin.prog"
1.74 xsa 132: #define CVS_PATH_ENTRIES CVS_PATH_CVSDIR "/Entries"
133: #define CVS_PATH_STATICENTRIES CVS_PATH_CVSDIR "/Entries.Static"
134: #define CVS_PATH_LOGENTRIES CVS_PATH_CVSDIR "/Entries.Log"
1.89 joris 135: #define CVS_PATH_BACKUPENTRIES CVS_PATH_CVSDIR "/Entries.Backup"
1.100 xsa 136: #define CVS_PATH_NOTIFY CVS_PATH_CVSDIR "/Notify"
137: #define CVS_PATH_NOTIFYTMP CVS_PATH_CVSDIR "/Notify.tmp"
1.74 xsa 138: #define CVS_PATH_ROOTSPEC CVS_PATH_CVSDIR "/Root"
139: #define CVS_PATH_REPOSITORY CVS_PATH_CVSDIR "/Repository"
1.81 xsa 140: #define CVS_PATH_TAG CVS_PATH_CVSDIR "/Tag"
1.100 xsa 141: #define CVS_PATH_TEMPLATE CVS_PATH_CVSDIR "/Template"
142: #define CVS_PATH_UPDATEPROG CVS_PATH_CVSDIR "/Update.prog"
1.110 joris 143: #define CVS_PATH_ATTIC "Attic"
1.1 jfb 144:
1.136 joris 145: /* history stuff */
146: #define CVS_HISTORY_TAG 0
147: #define CVS_HISTORY_CHECKOUT 1
148: #define CVS_HISTORY_EXPORT 2
149: #define CVS_HISTORY_RELEASE 3
150: #define CVS_HISTORY_UPDATE_REMOVE 4
151: #define CVS_HISTORY_UPDATE_CO 5
152: #define CVS_HISTORY_UPDATE_MERGED 6
153: #define CVS_HISTORY_UPDATE_MERGED_ERR 7
154: #define CVS_HISTORY_COMMIT_MODIFIED 8
155: #define CVS_HISTORY_COMMIT_ADDED 9
156: #define CVS_HISTORY_COMMIT_REMOVED 10
157:
158: void cvs_history_add(int, struct cvs_file *, const char *);
159:
1.46 joris 160: struct cvs_cmd {
1.103 joris 161: u_int cmd_op;
1.149 tobias 162: u_int cmd_flags;
1.86 reyk 163: char cmd_name[CVS_CMD_MAXNAMELEN];
164: char cmd_alias[CVS_CMD_MAXALIAS][CVS_CMD_MAXNAMELEN];
165: char cmd_descr[CVS_CMD_MAXDESCRLEN];
166: char *cmd_synopsis;
167: char *cmd_opts;
168: char *cmd_defargs;
1.58 jfb 169:
1.104 joris 170: int (*cmd)(int, char **);
171: };
172:
173: struct cvsroot;
1.58 jfb 174:
1.104 joris 175: struct cvs_recursion {
176: void (*enterdir)(struct cvs_file *);
177: void (*leavedir)(struct cvs_file *);
1.114 joris 178: void (*fileproc)(struct cvs_file *);
1.106 joris 179: int flags;
1.46 joris 180: };
1.106 joris 181:
182: #define CR_RECURSE_DIRS 0x01
183: #define CR_ATTIC 0x02
184: #define CR_REPO 0x04
1.1 jfb 185:
1.41 jfb 186: struct cvs_var {
187: char *cv_name;
188: char *cv_val;
189: TAILQ_ENTRY(cvs_var) cv_link;
190: };
1.122 xsa 191:
192: TAILQ_HEAD(, cvs_var) cvs_variables;
1.41 jfb 193:
1.74 xsa 194: #define CVS_ROOT_CONNECTED 0x01
1.36 jfb 195:
1.1 jfb 196: struct cvsroot {
1.11 jfb 197: char *cr_str;
1.1 jfb 198: u_int cr_method;
199: char *cr_buf;
200: char *cr_user;
201: char *cr_pass;
202: char *cr_host;
203: char *cr_dir;
1.145 joris 204: u_int cr_port;
1.11 jfb 205:
206: /* connection data */
207: FILE *cr_srvin;
208: FILE *cr_srvout;
1.21 jfb 209: FILE *cr_srverr;
1.1 jfb 210: };
1.74 xsa 211:
212: #define CVS_HIST_ADDED 'A'
213: #define CVS_HIST_EXPORT 'E'
214: #define CVS_HIST_RELEASE 'F'
215: #define CVS_HIST_MODIFIED 'M'
216: #define CVS_HIST_CHECKOUT 'O'
217: #define CVS_HIST_COMMIT 'R'
218: #define CVS_HIST_TAG 'T'
219:
220: #define CVS_DATE_DUMMY "dummy timestamp"
221: #define CVS_DATE_DMSEC (time_t)-1
222:
223: #define CVS_ENT_NONE 0
224: #define CVS_ENT_FILE 1
225: #define CVS_ENT_DIR 2
226:
227: #define CVS_ENT_REG 0
228: #define CVS_ENT_ADDED 1
229: #define CVS_ENT_REMOVED 2
230: #define CVS_ENT_UPTODATE 3
1.175 joris 231: #define CVS_ENT_UNKNOWN 4
1.80 xsa 232:
233: #define CVS_ENT_MAXLINELEN 1024
1.1 jfb 234:
1.104 joris 235: #define ENT_NOSYNC 0
236: #define ENT_SYNC 1
1.17 jfb 237:
1.85 joris 238: #define STRIP_SLASH(p) \
239: do { \
240: size_t _slen; \
241: _slen = strlen(p); \
242: while ((_slen > 0) && (p[_slen - 1] == '/')) \
243: p[--_slen] = '\0'; \
244: } while (0)
1.104 joris 245:
1.1 jfb 246: struct cvs_ent {
1.104 joris 247: char *ce_buf;
1.159 joris 248: char *ce_conflict;
1.104 joris 249: char *ce_name;
250: char *ce_opts;
251: char *ce_tag;
1.182 stsp 252: char *ce_time;
1.160 joris 253: time_t ce_date;
1.104 joris 254: time_t ce_mtime;
255: u_int16_t ce_type;
256: u_int16_t ce_status;
257: RCSNUM *ce_rev;
258: };
259:
260: struct cvs_ent_line {
261: char *buf;
262: TAILQ_ENTRY(cvs_ent_line) entries_list;
1.1 jfb 263: };
264:
265: typedef struct cvs_entries {
1.74 xsa 266: char *cef_path;
1.89 joris 267: char *cef_bpath;
1.104 joris 268: char *cef_lpath;
1.1 jfb 269:
1.104 joris 270: TAILQ_HEAD(, cvs_ent_line) cef_ent;
1.1 jfb 271: } CVSENTRIES;
1.157 joris 272:
273: extern char *checkout_target_dir;
1.163 joris 274: extern char *cvs_join_rev1;
275: extern char *cvs_join_rev2;
1.179 nicm 276: extern int backup_local_changes;
1.151 joris 277:
278: extern struct module_checkout *current_module;
279: extern char *module_repo_root;
1.1 jfb 280:
1.152 joris 281: extern struct ignore_head checkout_ign_pats;
1.177 ray 282: extern struct wklhead temp_files;
1.104 joris 283: extern volatile sig_atomic_t sig_received;
284: extern volatile sig_atomic_t cvs_quit;
285: extern struct cvsroot *current_cvsroot;
1.107 joris 286: extern char *cvs_tagname;
1.18 jfb 287: extern char *cvs_editor;
1.76 xsa 288: extern char *cvs_homedir;
1.42 jfb 289: extern char *cvs_rsh;
1.77 xsa 290: extern char *cvs_tmpdir;
1.110 joris 291: extern char *import_repository;
1.116 joris 292: extern char *cvs_server_path;
1.155 tobias 293: extern time_t cvs_specified_date;
1.168 tobias 294: extern time_t cvs_directory_date;
1.141 joris 295: extern char *cvs_specified_tag;
1.146 joris 296: extern char *cvs_directory_tag;
1.22 jfb 297:
1.107 joris 298: extern int cvs_umask;
1.42 jfb 299: extern int verbosity;
300: extern int cvs_trace;
301: extern int cvs_nolog;
302: extern int cvs_compress;
303: extern int cvs_cmdop;
304: extern int cvs_nocase;
1.57 xsa 305: extern int cvs_noexec;
1.42 jfb 306: extern int cvs_readonly;
1.124 xsa 307: extern int cvs_readonlyfs;
1.116 joris 308: extern int cvs_server_active;
1.156 tobias 309: extern int reset_option;
310: extern int reset_tag;
1.153 tobias 311: extern int kflag;
1.15 jfb 312:
1.148 tobias 313: extern struct cvs_cmd *cmdp;
1.58 jfb 314: extern struct cvs_cmd *cvs_cdt[];
1.1 jfb 315:
1.58 jfb 316: extern struct cvs_cmd cvs_cmd_add;
317: extern struct cvs_cmd cvs_cmd_admin;
318: extern struct cvs_cmd cvs_cmd_annotate;
319: extern struct cvs_cmd cvs_cmd_checkout;
320: extern struct cvs_cmd cvs_cmd_commit;
321: extern struct cvs_cmd cvs_cmd_diff;
322: extern struct cvs_cmd cvs_cmd_edit;
323: extern struct cvs_cmd cvs_cmd_editors;
324: extern struct cvs_cmd cvs_cmd_export;
325: extern struct cvs_cmd cvs_cmd_history;
326: extern struct cvs_cmd cvs_cmd_import;
327: extern struct cvs_cmd cvs_cmd_init;
328: extern struct cvs_cmd cvs_cmd_log;
1.150 tobias 329: extern struct cvs_cmd cvs_cmd_rannotate;
1.58 jfb 330: extern struct cvs_cmd cvs_cmd_rdiff;
331: extern struct cvs_cmd cvs_cmd_release;
332: extern struct cvs_cmd cvs_cmd_remove;
333: extern struct cvs_cmd cvs_cmd_rlog;
334: extern struct cvs_cmd cvs_cmd_rtag;
335: extern struct cvs_cmd cvs_cmd_status;
336: extern struct cvs_cmd cvs_cmd_tag;
337: extern struct cvs_cmd cvs_cmd_update;
338: extern struct cvs_cmd cvs_cmd_version;
339: extern struct cvs_cmd cvs_cmd_server;
340: extern struct cvs_cmd cvs_cmd_unedit;
341: extern struct cvs_cmd cvs_cmd_watch;
342: extern struct cvs_cmd cvs_cmd_watchers;
1.169 tobias 343:
344: /* add.c */
345: void cvs_add_tobranch(struct cvs_file *, char *);
1.58 jfb 346:
1.104 joris 347: /* cmd.c */
1.74 xsa 348: struct cvs_cmd *cvs_findcmd(const char *);
349:
1.104 joris 350: /* cvs.c */
1.165 tobias 351: int cvs_build_cmd(char ***, char **, int);
1.74 xsa 352: int cvs_var_set(const char *, const char *);
353: int cvs_var_unset(const char *);
354: const char *cvs_var_get(const char *);
1.104 joris 355: void cvs_cleanup(void);
1.1 jfb 356:
1.104 joris 357: /* date.y */
1.178 ray 358: time_t date_parse(const char *);
1.104 joris 359:
360: /* entries.c */
361: struct cvs_ent *cvs_ent_parse(const char *);
362: struct cvs_ent *cvs_ent_get(CVSENTRIES *, const char *);
363: CVSENTRIES *cvs_ent_open(const char *);
1.162 deraadt 364: void cvs_ent_add(CVSENTRIES *, const char *);
365: void cvs_ent_remove(CVSENTRIES *, const char *);
366: void cvs_ent_close(CVSENTRIES *, int);
1.104 joris 367: void cvs_ent_free(struct cvs_ent *);
1.158 xsa 368: void cvs_ent_line_str(const char *, char *, char *, char *, char *,
369: int, int, char *, size_t);
1.113 xsa 370: void cvs_parse_tagfile(char *, char **, char **, int *);
1.154 tobias 371: void cvs_write_tagfile(const char *, char *, char *);
1.1 jfb 372:
1.69 xsa 373: /* root.c */
1.104 joris 374: struct cvsroot *cvsroot_get(const char *);
1.126 joris 375:
376: /* logmsg.c */
1.167 joris 377: char *cvs_logmsg_read(const char *);
378: char *cvs_logmsg_create(char *, struct cvs_flisthead *,
379: struct cvs_flisthead *, struct cvs_flisthead *);
380: int cvs_logmsg_verify(char *);
1.87 joris 381:
1.104 joris 382: /* misc stuff */
383: void cvs_update_local(struct cvs_file *);
384: void cvs_update_enterdir(struct cvs_file *);
1.105 joris 385: void cvs_update_leavedir(struct cvs_file *);
1.147 joris 386: void cvs_checkout_file(struct cvs_file *, RCSNUM *, char *, int);
1.163 joris 387: void cvs_remove_local(struct cvs_file *);
388: void cvs_add_local(struct cvs_file *);
1.109 joris 389: int update_has_conflict_markers(struct cvs_file *);
1.179 nicm 390: void cvs_backup_file(struct cvs_file *);
1.183 ! joris 391: void cvs_import_ignored(const char *);
1.109 joris 392:
393: #define CO_MERGE 0x01
1.111 joris 394: #define CO_SETSTICKY 0x02
1.115 reyk 395: #define CO_DUMP 0x04
1.125 joris 396: #define CO_COMMIT 0x08
1.138 joris 397: #define CO_REMOVE 0x10
1.116 joris 398:
399: /* commands */
1.117 xsa 400: int cvs_add(int, char **);
1.120 xsa 401: int cvs_admin(int, char **);
1.123 xsa 402: int cvs_annotate(int, char **);
1.131 xsa 403: int cvs_checkout(int, char **);
1.116 joris 404: int cvs_commit(int, char **);
405: int cvs_diff(int, char **);
1.127 xsa 406: int cvs_edit(int, char **);
407: int cvs_editors(int, char **);
1.131 xsa 408: int cvs_export(int, char **);
1.118 xsa 409: int cvs_getlog(int, char **);
1.136 joris 410: int cvs_history(int, char **);
1.132 xsa 411: int cvs_import(int, char **);
1.119 xsa 412: int cvs_init(int, char **);
1.137 xsa 413: int cvs_release(int, char **);
1.117 xsa 414: int cvs_remove(int, char **);
1.116 joris 415: int cvs_status(int, char **);
1.118 xsa 416: int cvs_tag(int, char **);
1.127 xsa 417: int cvs_unedit(int, char **);
1.116 joris 418: int cvs_update(int, char **);
1.121 xsa 419: int cvs_version(int, char **);
1.127 xsa 420: int cvs_watch(int, char **);
421: int cvs_watchers(int, char **);
1.134 otto 422:
1.1 jfb 423:
1.91 joris 424: #endif