diff options
author | Joris Vink <joris@cvs.openbsd.org> | 2006-05-27 03:30:32 +0000 |
---|---|---|
committer | Joris Vink <joris@cvs.openbsd.org> | 2006-05-27 03:30:32 +0000 |
commit | 7d89f936fbdc2dd3d49c0286998836e36cc68365 (patch) | |
tree | 42e90824fb35b817279c75e6a187f7a54dc474fb /usr.bin/cvs/cvs.h | |
parent | 98bdde20935bf70a07278f2c429c1e05c676ff48 (diff) |
commit the new opencvs code, i have been hacking on
this for the past 2 weeks now and it should go in at
the start of the hackathon so others can help out.
this code is a lot safer, smarter, faster and best of
all it is actually doing what it is suppose to do!
basic checkout, update, status, diff and commit are
working in local mode only.
there is no support for any remote setups now.
Diffstat (limited to 'usr.bin/cvs/cvs.h')
-rw-r--r-- | usr.bin/cvs/cvs.h | 205 |
1 files changed, 65 insertions, 140 deletions
diff --git a/usr.bin/cvs/cvs.h b/usr.bin/cvs/cvs.h index 057e0fd4100..290cc79b348 100644 --- a/usr.bin/cvs/cvs.h +++ b/usr.bin/cvs/cvs.h @@ -1,4 +1,4 @@ -/* $OpenBSD: cvs.h,v 1.103 2006/04/01 20:11:25 joris Exp $ */ +/* $OpenBSD: cvs.h,v 1.104 2006/05/27 03:30:30 joris Exp $ */ /* * Copyright (c) 2004 Jean-Francois Brousseau <jfb@openbsd.org> * All rights reserved. @@ -28,27 +28,25 @@ #define CVS_H #include "rcs.h" -#include "file.h" -#include "util.h" #include "xmalloc.h" +#include "util.h" +#include "file.h" +#include "repository.h" +#include "worklist.h" -#define CVS_VERSION "OpenCVS 0.3" +#define CVS_VERSION_MINOR "0" +#define CVS_VERSION_MAJOR "1" +#define CVS_VERSION_PORT + +#define CVS_VERSION \ + "OpenCVS version " \ + CVS_VERSION_MAJOR "." CVS_VERSION_MINOR CVS_VERSION_PORT #define CVS_HIST_CACHE 128 #define CVS_HIST_NBFLD 6 - #define CVS_CKSUM_LEN 33 /* length of a CVS checksum string */ -/* error codes */ -#define CVS_EX_ERR -1 -#define CVS_EX_OK 0 -#define CVS_EX_USAGE 1 -#define CVS_EX_DATA 2 -#define CVS_EX_PROTO 3 -#define CVS_EX_FILE 4 -#define CVS_EX_BADROOT 5 - /* operations */ #define CVS_OP_UNKNOWN 0 #define CVS_OP_ADD 1 @@ -81,7 +79,6 @@ #define CVS_OP_ANY 64 /* all operations */ - /* methods */ #define CVS_METHOD_NONE 0 #define CVS_METHOD_LOCAL 1 /* local access */ @@ -97,7 +94,6 @@ #define CVS_CMD_MAXDESCRLEN 64 #define CVS_CMD_MAXARG 128 - /* defaults */ #define CVS_SERVER_DEFAULT "cvs" #define CVS_RSH_DEFAULT "ssh" @@ -123,7 +119,6 @@ #define CVS_PATH_TAGINFO CVS_PATH_ROOT "/taginfo" #define CVS_PATH_VERIFYMSG CVS_PATH_ROOT "/verifymsg" - /* client-side paths */ #define CVS_PATH_RC ".cvsrc" #define CVS_PATH_CVSDIR "CVS" @@ -143,15 +138,6 @@ #define CVS_PATH_TEMPLATE CVS_PATH_CVSDIR "/Template" #define CVS_PATH_UPDATEPROG CVS_PATH_CVSDIR "/Update.prog" - -/* flags for cmd_flags */ -#define CVS_CMD_ALLOWSPEC 0x01 -#define CVS_CMD_SENDARGS1 0x04 -#define CVS_CMD_SENDARGS2 0x08 -#define CVS_CMD_SENDDIR 0x10 -#define CVS_CMD_PRUNEDIRS 0x20 - - struct cvs_cmd { u_int cmd_op; u_int cmd_req; @@ -161,23 +147,18 @@ struct cvs_cmd { char *cmd_synopsis; char *cmd_opts; char *cmd_defargs; - int file_flags; - - /* operations vector */ - int (*cmd_init)(struct cvs_cmd *, int, char **, int *); - int (*cmd_pre_exec)(struct cvsroot *); - int (*cmd_exec_remote)(CVSFILE *, void *); - int (*cmd_exec_local)(CVSFILE *, void *); - int (*cmd_post_exec)(struct cvsroot *); - int (*cmd_cleanup)(void); - - /* flags for cvs_file_get() */ - int cmd_flags; + + int (*cmd)(int, char **); }; -struct cvs_file; -struct cvs_dir; -struct cvs_flist; +struct cvsroot; + +struct cvs_recursion { + void (*enterdir)(struct cvs_file *); + void (*leavedir)(struct cvs_file *); + void (*local)(struct cvs_file *); + void (*remote)(struct cvs_file *, struct cvsroot *); +}; struct cvs_var { char *cv_name; @@ -185,17 +166,6 @@ struct cvs_var { TAILQ_ENTRY(cvs_var) cv_link; }; - - -struct cvs_op { - u_int co_op; - uid_t co_uid; /* user performing the operation */ - char *co_tag; /* tag or branch, NULL if HEAD */ - char *co_msg; /* message string (on commit or add) */ - struct cvs_flist co_files; -}; - - #define CVS_ROOT_CONNECTED 0x01 struct cvsroot { @@ -225,7 +195,6 @@ struct cvsroot { #define CVS_CLRVR(rt, rq) ((rt)->cr_vrmask[(rq) / 8] &= ~(1 << ((rq) % 8))) #define CVS_RSTVR(rt) memset((rt)->cr_vrmask, 0, sizeof((rt)->cr_vrmask)) - #define CVS_HIST_ADDED 'A' #define CVS_HIST_EXPORT 'E' #define CVS_HIST_RELEASE 'F' @@ -234,7 +203,6 @@ struct cvsroot { #define CVS_HIST_COMMIT 'R' #define CVS_HIST_TAG 'T' - #define CVS_DATE_DUMMY "dummy timestamp" #define CVS_DATE_DMSEC (time_t)-1 @@ -249,8 +217,8 @@ struct cvsroot { #define CVS_ENT_MAXLINELEN 1024 -#define CVS_ENTF_SYNC 0x01 /* contents of disk and memory match */ -#define CVS_ENTF_WR 0x02 /* file is opened for writing too */ +#define ENT_NOSYNC 0 +#define ENT_SYNC 1 #define STRIP_SLASH(p) \ do { \ @@ -259,62 +227,36 @@ struct cvsroot { while ((_slen > 0) && (p[_slen - 1] == '/')) \ p[--_slen] = '\0'; \ } while (0) + struct cvs_ent { - char *ce_buf; - u_int16_t ce_type; - u_int16_t ce_status; - char *ce_name; - RCSNUM *ce_rev; - time_t ce_mtime; - char *ce_opts; - char *ce_tag; - - /* - * This variable is set to 1 if we have already processed this entry - * in the cvs_file_getdir() function. This is to avoid files being - * passed twice to the callbacks. - */ - int processed; - TAILQ_ENTRY(cvs_ent) ce_list; + char *ce_buf; + char *ce_name; + char *ce_opts; + char *ce_tag; + char *ce_conflict; + time_t ce_mtime; + u_int16_t ce_type; + u_int16_t ce_status; + RCSNUM *ce_rev; +}; + +struct cvs_ent_line { + char *buf; + TAILQ_ENTRY(cvs_ent_line) entries_list; }; typedef struct cvs_entries { char *cef_path; char *cef_bpath; - u_int cef_flags; + char *cef_lpath; - TAILQ_HEAD(cvsentrieshead, cvs_ent) cef_ent; - struct cvs_ent *cef_cur; + TAILQ_HEAD(, cvs_ent_line) cef_ent; } CVSENTRIES; - -struct cvs_hent { - char ch_event; - time_t ch_date; - uid_t ch_uid; - char *ch_user; - char *ch_curdir; - char *ch_repo; - RCSNUM *ch_rev; - char *ch_arg; -}; - - -typedef struct cvs_histfile { - int chf_fd; - char *chf_buf; /* read buffer */ - size_t chf_blen; /* buffer size */ - size_t chf_bused; /* bytes used in buffer */ - - off_t chf_off; /* next read */ - u_int chf_sindex; /* history entry index of first in array */ - u_int chf_cindex; /* current index (for getnext()) */ - u_int chf_nbhent; /* number of valid entries in the array */ - - struct cvs_hent chf_hent[CVS_HIST_CACHE]; - -} CVSHIST; - +extern struct cvs_wklhead temp_files; +extern volatile sig_atomic_t sig_received; +extern volatile sig_atomic_t cvs_quit; +extern struct cvsroot *current_cvsroot; extern char *cvs_repo_base; extern char *cvs_command; extern char *cvs_editor; @@ -332,7 +274,6 @@ extern int cvs_nocase; extern int cvs_noexec; extern int cvs_readonly; extern int cvs_error; -extern CVSFILE *cvs_files; extern struct cvs_cmd *cvs_cdt[]; @@ -365,53 +306,37 @@ extern struct cvs_cmd cvs_cmd_unedit; extern struct cvs_cmd cvs_cmd_watch; extern struct cvs_cmd cvs_cmd_watchers; - +/* cmd.c */ struct cvs_cmd *cvs_findcmd(const char *); struct cvs_cmd *cvs_findcmdbyreq(int); -int cvs_startcmd(struct cvs_cmd *, int, char **); -int cvs_server(int, char **); +/* cvs.c */ int cvs_var_set(const char *, const char *); int cvs_var_unset(const char *); const char *cvs_var_get(const char *); +void cvs_cleanup(void); - -/* root.c */ -struct cvsroot *cvsroot_parse(const char *); -void cvsroot_remove(struct cvsroot *); -struct cvsroot *cvsroot_get(const char *); - +/* date.y */ +time_t cvs_date_parse(const char *); /* entries.c */ -CVSENTRIES *cvs_ent_open(const char *, int); -struct cvs_ent *cvs_ent_get(CVSENTRIES *, const char *); -struct cvs_ent *cvs_ent_next(CVSENTRIES *); -int cvs_ent_add(CVSENTRIES *, struct cvs_ent *); -int cvs_ent_addln(CVSENTRIES *, const char *); -int cvs_ent_remove(CVSENTRIES *, const char *, int); -int cvs_ent_write(CVSENTRIES *); struct cvs_ent *cvs_ent_parse(const char *); -void cvs_ent_close(CVSENTRIES *); -void cvs_ent_free(struct cvs_ent *); - -/* history API */ -CVSHIST *cvs_hist_open(const char *); -void cvs_hist_close(CVSHIST *); -int cvs_hist_parse(CVSHIST *); -struct cvs_hent *cvs_hist_getnext(CVSHIST *); -int cvs_hist_append(CVSHIST *, struct cvs_hent *); - -/* logmsg.c */ -char *cvs_logmsg_open(const char *); -char *cvs_logmsg_get(const char *, struct cvs_flist *, - struct cvs_flist *, struct cvs_flist *); -void cvs_logmsg_send(struct cvsroot *, const char *); +struct cvs_ent *cvs_ent_get(CVSENTRIES *, const char *); +CVSENTRIES *cvs_ent_open(const char *); +void cvs_ent_add(CVSENTRIES *, const char *); +void cvs_ent_remove(CVSENTRIES *, const char *); +void cvs_ent_close(CVSENTRIES *, int); +void cvs_ent_free(struct cvs_ent *); +int cvs_ent_exists(CVSENTRIES *, const char *); -/* date.y */ -time_t cvs_date_parse(const char *); +/* root.c */ +struct cvsroot *cvsroot_parse(const char *); +struct cvsroot *cvsroot_get(const char *); +void cvsroot_remove(struct cvsroot *); -/* XXX */ -int rcs_patch_lines(struct cvs_lines *, struct cvs_lines *); -int cvs_checkout_rev(RCSFILE *, RCSNUM *, CVSFILE *, char *, int, int, ...); +/* misc stuff */ +void cvs_update_local(struct cvs_file *); +void cvs_update_enterdir(struct cvs_file *); +int cvs_checkout_file(struct cvs_file *, RCSNUM *, int); #endif |