summaryrefslogtreecommitdiffstats
path: root/usr.bin
diff options
context:
space:
mode:
authorjfb <jfb@openbsd.org>2005-05-24 04:12:25 +0000
committerjfb <jfb@openbsd.org>2005-05-24 04:12:25 +0000
commite4276007dfc80452049f621e2fe571403c1cc0b2 (patch)
tree9690a166970746195780743a210ad5966408f392 /usr.bin
parentoops, new arcfour modes here too (diff)
downloadwireguard-openbsd-e4276007dfc80452049f621e2fe571403c1cc0b2.tar.xz
wireguard-openbsd-e4276007dfc80452049f621e2fe571403c1cc0b2.zip
Merge the cvs_cmd and cvs_cmd_info structures and add the necessary
fields to hook local versions of the commands. This needs to go in before it gets any bigger ok joris
Diffstat (limited to 'usr.bin')
-rw-r--r--usr.bin/cvs/Makefile10
-rw-r--r--usr.bin/cvs/add.c46
-rw-r--r--usr.bin/cvs/admin.c41
-rw-r--r--usr.bin/cvs/annotate.c28
-rw-r--r--usr.bin/cvs/checkout.c117
-rw-r--r--usr.bin/cvs/cmd.c186
-rw-r--r--usr.bin/cvs/commit.c42
-rw-r--r--usr.bin/cvs/cvs.15
-rw-r--r--usr.bin/cvs/cvs.c272
-rw-r--r--usr.bin/cvs/cvs.h126
-rw-r--r--usr.bin/cvs/diff.c339
-rw-r--r--usr.bin/cvs/entries.c3
-rw-r--r--usr.bin/cvs/file.c30
-rw-r--r--usr.bin/cvs/file.h14
-rw-r--r--usr.bin/cvs/getlog.c47
-rw-r--r--usr.bin/cvs/history.c34
-rw-r--r--usr.bin/cvs/import.c180
-rw-r--r--usr.bin/cvs/init.c18
-rw-r--r--usr.bin/cvs/release.c37
-rw-r--r--usr.bin/cvs/remove.c31
-rw-r--r--usr.bin/cvs/req.c30
-rw-r--r--usr.bin/cvs/resp.c10
-rw-r--r--usr.bin/cvs/server.c19
-rw-r--r--usr.bin/cvs/status.c93
-rw-r--r--usr.bin/cvs/tag.c98
-rw-r--r--usr.bin/cvs/update.c45
-rw-r--r--usr.bin/cvs/version.c21
27 files changed, 1041 insertions, 881 deletions
diff --git a/usr.bin/cvs/Makefile b/usr.bin/cvs/Makefile
index 395f16965ae..7f2b58942eb 100644
--- a/usr.bin/cvs/Makefile
+++ b/usr.bin/cvs/Makefile
@@ -1,13 +1,15 @@
-# $OpenBSD: Makefile,v 1.7 2005/05/17 16:45:07 xsa Exp $
+# $OpenBSD: Makefile,v 1.8 2005/05/24 04:12:25 jfb Exp $
PROG= cvs
MAN= cvs.1 cvsrc.5 cvsintro.7
SRCS= cvs.c add.c admin.c annotate.c buf.c checkout.c cmd.c commit.c date.y \
- diff.c entries.c file.c getlog.c history.c hist.c import.c init.c \
- log.c logmsg.c proto.c rcs.c rcsnum.c release.c remove.c req.c resp.c \
- root.c server.c status.c strtab.c tag.c update.c util.c version.c
+ diff.c entries.c file.c getlog.c history.c hist.c \
+ import.c init.c log.c logmsg.c proto.c rcs.c rcsnum.c release.c \
+ remove.c req.c resp.c root.c server.c status.c strtab.c tag.c \
+ update.c util.c version.c
+BINDIR= /usr/bin
BINOWN= root
#BINGRP=_cvsd
diff --git a/usr.bin/cvs/add.c b/usr.bin/cvs/add.c
index e9f8832c370..b6e0a0ca5d5 100644
--- a/usr.bin/cvs/add.c
+++ b/usr.bin/cvs/add.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: add.c,v 1.20 2005/05/20 20:00:53 joris Exp $ */
+/* $OpenBSD: add.c,v 1.21 2005/05/24 04:12:25 jfb Exp $ */
/*
* Copyright (c) 2004 Jean-Francois Brousseau <jfb@openbsd.org>
* All rights reserved.
@@ -40,31 +40,38 @@
extern char *__progname;
-int cvs_add_file(CVSFILE *, void *);
-int cvs_add_options(char *, int, char **, int *);
-int cvs_add_sendflags(struct cvsroot *);
+static int cvs_add_file(CVSFILE *, void *);
+static int cvs_add_init(struct cvs_cmd *, int, char **, int *);
+static int cvs_add_pre_exec(struct cvsroot *);
-struct cvs_cmd_info cvs_add = {
- cvs_add_options,
- cvs_add_sendflags,
- cvs_add_file,
- NULL, NULL,
+struct cvs_cmd cvs_cmd_add = {
+ CVS_OP_ADD, CVS_REQ_ADD, "add",
+ { "ad", "new" },
+ "Add a new file/directory to the repository",
+ "[-k mode] [-m msg] file ...",
+ "k:m:",
+ NULL,
0,
- CVS_REQ_ADD,
+ cvs_add_init,
+ cvs_add_pre_exec,
+ cvs_add_file,
+ cvs_add_file,
+ NULL,
+ NULL,
CVS_CMD_ALLOWSPEC | CVS_CMD_SENDDIR | CVS_CMD_SENDARGS2
};
static int kflag = RCS_KWEXP_DEFAULT;
static char *koptstr;
-int
-cvs_add_options(char *opt, int argc, char **argv, int *arg)
+static int
+cvs_add_init(struct cvs_cmd *cmd, int argc, char **argv, int *arg)
{
int ch;
cvs_msg = NULL;
- while ((ch = getopt(argc, argv, opt)) != -1) {
+ while ((ch = getopt(argc, argv, cmd->cmd_opts)) != -1) {
switch (ch) {
case 'k':
koptstr = optarg;
@@ -91,12 +98,13 @@ cvs_add_options(char *opt, int argc, char **argv, int *arg)
return (0);
}
-int
-cvs_add_sendflags(struct cvsroot *root)
+static int
+cvs_add_pre_exec(struct cvsroot *root)
{
char buf[16];
- if (kflag != RCS_KWEXP_DEFAULT) {
+ if ((root->cr_method != CVS_METHOD_LOCAL) &&
+ (kflag != RCS_KWEXP_DEFAULT)) {
strlcpy(buf, "-k", sizeof(buf));
strlcat(buf, koptstr, sizeof(buf));
if (cvs_sendarg(root, buf, 0) < 0)
@@ -106,7 +114,7 @@ cvs_add_sendflags(struct cvsroot *root)
return (0);
}
-int
+static int
cvs_add_file(CVSFILE *cf, void *arg)
{
int ret;
@@ -128,10 +136,10 @@ cvs_add_file(CVSFILE *cf, void *arg)
if (root->cr_method != CVS_METHOD_LOCAL) {
if (cf->cf_cvstat == CVS_FST_UNKNOWN)
ret = cvs_sendreq(root, CVS_REQ_ISMODIFIED,
- CVS_FILE_NAME(cf));
+ cf->cf_name);
} else {
cvs_log(LP_INFO, "scheduling file `%s' for addition",
- CVS_FILE_NAME(cf));
+ cf->cf_name);
cvs_log(LP_INFO, "use `%s commit' to add this file permanently",
__progname);
}
diff --git a/usr.bin/cvs/admin.c b/usr.bin/cvs/admin.c
index 02a596ffb0e..4d3d59c0514 100644
--- a/usr.bin/cvs/admin.c
+++ b/usr.bin/cvs/admin.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: admin.c,v 1.14 2005/05/20 20:00:53 joris Exp $ */
+/* $OpenBSD: admin.c,v 1.15 2005/05/24 04:12:25 jfb Exp $ */
/*
* Copyright (c) 2004 Jean-Francois Brousseau <jfb@openbsd.org>
* Copyright (c) 2005 Joris Vink <joris@openbsd.org>
@@ -48,17 +48,24 @@
#define FLAG_INTERACTIVE 0x04
#define FLAG_QUIET 0x08
-int cvs_admin_options(char *, int, char **, int *);
-int cvs_admin_sendflags(struct cvsroot *);
-int cvs_admin_file(CVSFILE *, void *);
-
-struct cvs_cmd_info cvs_admin = {
- cvs_admin_options,
- cvs_admin_sendflags,
- cvs_admin_file,
- NULL, NULL,
+static int cvs_admin_init (struct cvs_cmd *, int, char **, int *);
+static int cvs_admin_pre_exec (struct cvsroot *);
+static int cvs_admin_file (CVSFILE *, void *);
+
+struct cvs_cmd cvs_cmd_admin = {
+ CVS_OP_ADMIN, CVS_REQ_ADMIN, "admin",
+ { "adm", "rcs" },
+ "Administrative front-end for RCS",
+ "",
+ "a:A:b::c:e::Ik:l::Lm:n:N:o:qs:t:u::U",
+ NULL,
CF_SORT | CF_IGNORE | CF_RECURSE,
- CVS_REQ_ADMIN,
+ cvs_admin_init,
+ cvs_admin_pre_exec,
+ cvs_admin_file,
+ cvs_admin_file,
+ NULL,
+ NULL,
CVS_CMD_ALLOWSPEC | CVS_CMD_SENDDIR | CVS_CMD_SENDARGS2
};
@@ -67,8 +74,8 @@ static char *alist, *subst, *lockrev_arg, *unlockrev_arg;
static char *state, *userfile, *branch_arg, *elist, *range;
static int runflags, kflag, lockrev, strictlock;
-int
-cvs_admin_options(char *opt, int argc, char **argv, int *arg)
+static int
+cvs_admin_init(struct cvs_cmd *cmd, int argc, char **argv, int *arg)
{
int ch;
RCSNUM *rcs;
@@ -79,7 +86,7 @@ cvs_admin_options(char *opt, int argc, char **argv, int *arg)
range = userfile = branch_arg = unlockrev_arg = NULL;
/* option-o-rama ! */
- while ((ch = getopt(argc, argv, opt)) != -1) {
+ while ((ch = getopt(argc, argv, cmd->cmd_opts)) != -1) {
switch (ch) {
case 'a':
alist = optarg;
@@ -200,8 +207,8 @@ cvs_admin_options(char *opt, int argc, char **argv, int *arg)
return (0);
}
-int
-cvs_admin_sendflags(struct cvsroot *root)
+static int
+cvs_admin_pre_exec(struct cvsroot *root)
{
if ((alist != NULL) && ((cvs_sendarg(root, "-a", 0) < 0) ||
(cvs_sendarg(root, alist, 0) < 0)))
@@ -292,7 +299,7 @@ cvs_admin_sendflags(struct cvsroot *root)
*
* Perform admin commands on each file.
*/
-int
+static int
cvs_admin_file(CVSFILE *cfp, void *arg)
{
int ret, l;
diff --git a/usr.bin/cvs/annotate.c b/usr.bin/cvs/annotate.c
index b92bbfca039..8f25bc324ec 100644
--- a/usr.bin/cvs/annotate.c
+++ b/usr.bin/cvs/annotate.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: annotate.c,v 1.13 2005/05/20 20:00:53 joris Exp $ */
+/* $OpenBSD: annotate.c,v 1.14 2005/05/24 04:12:25 jfb Exp $ */
/*
* Copyright (c) 2004 Jean-Francois Brousseau <jfb@openbsd.org>
* All rights reserved.
@@ -41,16 +41,24 @@
static int cvs_annotate_file (CVSFILE *, void *);
-static int cvs_annotate_options (char *, int, char **, int *);
+static int cvs_annotate_options (struct cvs_cmd *, int, char **, int *);
static int cvs_annotate_sendflags (struct cvsroot *);
-struct cvs_cmd_info cvs_annotate = {
+
+struct cvs_cmd cvs_cmd_annotate = {
+ CVS_OP_ANNOTATE, CVS_REQ_ANNOTATE, "annotate",
+ { "ann", "blame" },
+ "Show last revision where each line was modified",
+ "[-flR] [-D date | -r rev] ...",
+ "D:flRr:",
+ NULL,
+ CF_SORT | CF_RECURSE | CF_IGNORE | CF_NOSYMS,
cvs_annotate_options,
cvs_annotate_sendflags,
cvs_annotate_file,
- NULL, NULL,
- CF_SORT | CF_RECURSE | CF_IGNORE | CF_NOSYMS,
- CVS_REQ_ANNOTATE,
+ cvs_annotate_file,
+ NULL,
+ NULL,
CVS_CMD_ALLOWSPEC | CVS_CMD_SENDDIR | CVS_CMD_SENDARGS2
};
@@ -58,7 +66,7 @@ static char *date, *rev;
static int usehead;
static int
-cvs_annotate_options(char *opt, int argc, char **argv, int *arg)
+cvs_annotate_options(struct cvs_cmd *cmd, int argc, char **argv, int *arg)
{
int ch;
@@ -66,7 +74,7 @@ cvs_annotate_options(char *opt, int argc, char **argv, int *arg)
date = NULL;
rev = NULL;
- while ((ch = getopt(argc, argv, opt)) != -1) {
+ while ((ch = getopt(argc, argv, cmd->cmd_opts)) != -1) {
switch (ch) {
case 'D':
date = optarg;
@@ -75,10 +83,10 @@ cvs_annotate_options(char *opt, int argc, char **argv, int *arg)
usehead = 1;
break;
case 'l':
- cvs_annotate.file_flags &= ~CF_RECURSE;
+ cmd->file_flags &= ~CF_RECURSE;
break;
case 'R':
- cvs_annotate.file_flags |= CF_RECURSE;
+ cmd->file_flags |= CF_RECURSE;
break;
case 'r':
rev = optarg;
diff --git a/usr.bin/cvs/checkout.c b/usr.bin/cvs/checkout.c
index 4b96cc8fa1b..d7849a163fc 100644
--- a/usr.bin/cvs/checkout.c
+++ b/usr.bin/cvs/checkout.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: checkout.c,v 1.21 2005/05/23 17:30:35 xsa Exp $ */
+/* $OpenBSD: checkout.c,v 1.22 2005/05/24 04:12:25 jfb Exp $ */
/*
* Copyright (c) 2004 Jean-Francois Brousseau <jfb@openbsd.org>
* All rights reserved.
@@ -41,33 +41,45 @@
#define CVS_LISTMOD 1
#define CVS_STATMOD 2
-int cvs_checkout_options(char *, int, char **, int *);
-int cvs_checkout_sendflags(struct cvsroot *);
-
-struct cvs_cmd_info cvs_checkout = {
- cvs_checkout_options,
- cvs_checkout_sendflags,
- NULL, NULL, NULL,
+static int cvs_checkout_init (struct cvs_cmd *, int, char **, int *);
+static int cvs_checkout_pre_exec (struct cvsroot *);
+
+struct cvs_cmd cvs_cmd_checkout = {
+ CVS_OP_CHECKOUT, CVS_REQ_CO, "checkout",
+ { "co", "get" },
+ "Checkout sources for editing",
+ "[-AcflNnPpRs] [-D date | -r rev] [-d dir] [-j rev] [-k mode] "
+ "[-t id] module ...",
+ "AcD:d:fj:k:lNnPRr:st:",
+ NULL,
0,
- CVS_REQ_CO,
- CVS_CMD_SENDDIR | CVS_CMD_SENDARGS1 | CVS_CMD_SENDARGS2
+ cvs_checkout_init,
+ cvs_checkout_pre_exec,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ CVS_CMD_ALLOWSPEC | CVS_CMD_SENDDIR | CVS_CMD_SENDARGS2
};
static char *date, *rev, *koptstr, *tgtdir, *rcsid;
static int statmod = 0;
+static int shorten = 1;
+static int usehead = 0;
static int kflag = RCS_KWEXP_DEFAULT;
-static int usehead;
-int
-cvs_checkout_options(char *opt, int argc, char **argv, int *arg)
+/* modules */
+static char **co_mods;
+static int co_nmod;
+
+static int
+cvs_checkout_init(struct cvs_cmd *cmd, int argc, char **argv, int *arg)
{
int ch;
date = rev = koptstr = tgtdir = rcsid = NULL;
- kflag = RCS_KWEXP_DEFAULT;
- usehead = 0;
- while ((ch = getopt(argc, argv, opt)) != -1) {
+ while ((ch = getopt(argc, argv, cmd->cmd_opts)) != -1) {
switch (ch) {
case 'A':
break;
@@ -95,6 +107,9 @@ cvs_checkout_options(char *opt, int argc, char **argv, int *arg)
return (CVS_EX_USAGE);
}
break;
+ case 'N':
+ shorten = 0;
+ break;
case 'p':
cvs_noexec = 1; /* no locks will be created */
break;
@@ -115,6 +130,9 @@ cvs_checkout_options(char *opt, int argc, char **argv, int *arg)
argc -= optind;
argv += optind;
+ co_mods = argv;
+ co_nmod = argc;
+
if (!statmod && (argc == 0)) {
cvs_log(LP_ERR,
"must specify at least one module or directory");
@@ -130,33 +148,50 @@ cvs_checkout_options(char *opt, int argc, char **argv, int *arg)
return (0);
}
-int
-cvs_checkout_sendflags(struct cvsroot *root)
+static int
+cvs_checkout_pre_exec(struct cvsroot *root)
{
- if (cvs_sendreq(root, CVS_REQ_DIRECTORY, ".") < 0)
- return (CVS_EX_PROTO);
- if (cvs_sendraw(root, root->cr_dir, strlen(root->cr_dir)) < 0)
- return (CVS_EX_PROTO);
- if (cvs_sendraw(root, "\n", 1) < 0)
- return (CVS_EX_PROTO);
-
- if (cvs_sendreq(root, CVS_REQ_XPANDMOD, NULL) < 0)
- cvs_log(LP_ERR, "failed to expand module");
+ int i;
- if (usehead && (cvs_sendarg(root, "-f", 0) < 0))
- return (CVS_EX_PROTO);
-
- /* XXX not too sure why we have to send this arg */
- if (cvs_sendarg(root, "-N", 0) < 0)
- return (CVS_EX_PROTO);
-
- if ((statmod == CVS_LISTMOD) &&
- (cvs_sendarg(root, "-c", 0) < 0))
- return (CVS_EX_PROTO);
-
- if ((statmod == CVS_STATMOD) &&
- (cvs_sendarg(root, "-s", 0) < 0))
- return (CVS_EX_PROTO);
+ /* create any required base directories */
+ for (i = 0; i < co_nmod; i++) {
+ if (cvs_file_create(NULL, co_mods[i], DT_DIR, 0755) < 0)
+ return (CVS_EX_DATA);
+ }
+ if (root->cr_method != CVS_METHOD_LOCAL) {
+ for (i = 0; i < co_nmod; i++)
+ if (cvs_sendarg(root, co_mods[i], 0) < 0)
+ return (CVS_EX_PROTO);
+ if (cvs_sendreq(root, CVS_REQ_DIRECTORY, ".") < 0)
+ return (CVS_EX_PROTO);
+ if (cvs_sendln(root, root->cr_dir) < 0)
+ return (CVS_EX_PROTO);
+
+ if (cvs_sendreq(root, CVS_REQ_XPANDMOD, NULL) < 0)
+ cvs_log(LP_ERR, "failed to expand module");
+
+ if (usehead && (cvs_sendarg(root, "-f", 0) < 0))
+ return (CVS_EX_PROTO);
+
+ if ((tgtdir != NULL) &&
+ ((cvs_sendarg(root, "-d", 0) < 0) ||
+ (cvs_sendarg(root, tgtdir, 0) < 0)))
+ return (CVS_EX_PROTO);
+
+ if (!shorten && cvs_sendarg(root, "-N", 0) < 0)
+ return (CVS_EX_PROTO);
+
+ for (i = 0; i < co_nmod; i++)
+ if (cvs_sendarg(root, co_mods[i], 0) < 0)
+ return (CVS_EX_PROTO);
+
+ if ((statmod == CVS_LISTMOD) &&
+ (cvs_sendarg(root, "-c", 0) < 0))
+ return (CVS_EX_PROTO);
+ else if ((statmod == CVS_STATMOD) &&
+ (cvs_sendarg(root, "-s", 0) < 0))
+ return (CVS_EX_PROTO);
+ }
return (0);
}
diff --git a/usr.bin/cvs/cmd.c b/usr.bin/cvs/cmd.c
index 24d406957fd..88a1a672d81 100644
--- a/usr.bin/cvs/cmd.c
+++ b/usr.bin/cvs/cmd.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: cmd.c,v 1.18 2005/05/23 17:43:54 xsa Exp $ */
+/* $OpenBSD: cmd.c,v 1.19 2005/05/24 04:12:25 jfb Exp $ */
/*
* Copyright (c) 2005 Joris Vink <joris@openbsd.org>
* All rights reserved.
@@ -39,6 +39,113 @@
#include "rcs.h"
#include "proto.h"
+
+/*
+ * Command dispatch table
+ * ----------------------
+ *
+ * The synopsis field should only contain the list of arguments that the
+ * command supports, without the actual command's name.
+ *
+ * Command handlers are expected to return 0 if no error occurred, or one of
+ * the CVS_EX_* error codes in case of an error. In case the error
+ * returned is 1, the command's usage string is printed to standard
+ * error before returning.
+ */
+struct cvs_cmd *cvs_cdt[] = {
+ &cvs_cmd_add,
+ &cvs_cmd_admin,
+ &cvs_cmd_annotate,
+ &cvs_cmd_checkout,
+ &cvs_cmd_commit,
+ &cvs_cmd_diff,
+#if 0
+ &cvs_cmd_edit,
+ &cvs_cmd_editors,
+ &cvs_cmd_export,
+#endif
+ &cvs_cmd_history,
+ &cvs_cmd_import,
+ &cvs_cmd_init,
+#if defined(HAVE_KERBEROS)
+ &cvs_cmd_kserver,
+#endif
+ &cvs_cmd_log,
+#if 0
+ &cvs_cmd_login,
+ &cvs_cmd_logout,
+#endif
+ &cvs_cmd_rdiff,
+ &cvs_cmd_release,
+ &cvs_cmd_remove,
+ &cvs_cmd_rlog,
+ &cvs_cmd_rtag,
+ &cvs_cmd_server,
+ &cvs_cmd_status,
+ &cvs_cmd_tag,
+#if 0
+ &cvs_cmd_unedit,
+#endif
+ &cvs_cmd_update,
+ &cvs_cmd_version,
+#if 0
+ &cvs_cmd_watch,
+ &cvs_cmd_watchers,
+#endif
+ NULL
+};
+
+
+
+/*
+ * cvs_findcmd()
+ *
+ * Find the entry in the command dispatch table whose name or one of its
+ * aliases matches <cmd>.
+ * Returns a pointer to the command entry on success, NULL on failure.
+ */
+struct cvs_cmd*
+cvs_findcmd(const char *cmd)
+{
+ int i, j;
+ struct cvs_cmd *cmdp;
+
+ cmdp = NULL;
+
+ for (i = 0; (cvs_cdt[i] != NULL) && (cmdp == NULL); i++) {
+ if (strcmp(cmd, cvs_cdt[i]->cmd_name) == 0)
+ cmdp = cvs_cdt[i];
+ else {
+ for (j = 0; j < CVS_CMD_MAXALIAS; j++) {
+ if (strcmp(cmd,
+ cvs_cdt[i]->cmd_alias[j]) == 0) {
+ cmdp = cvs_cdt[i];
+ break;
+ }
+ }
+ }
+ }
+
+ return (cmdp);
+}
+
+struct cvs_cmd*
+cvs_findcmdbyreq(int reqid)
+{
+ int i;
+ struct cvs_cmd *cmdp;
+
+ cmdp = NULL;
+ for (i = 0; cvs_cdt[i] != NULL; i++)
+ if (cvs_cdt[i]->cmd_req == reqid) {
+ cmdp = cvs_cdt[i];
+ break;
+ }
+
+ return (cmdp);
+}
+
+
/*
* start the execution of a command.
*/
@@ -48,89 +155,82 @@ cvs_startcmd(struct cvs_cmd *cmd, int argc, char **argv)
int i;
int ret;
struct cvsroot *root;
- struct cvs_cmd_info *c = cmd->cmd_info;
+ int (*ex_hdlr)(CVSFILE *, void *);
/* if the command requested is the server one, just call the
* cvs_server() function to handle it, and return after it.
*/
- if (cmd->cmd_op == CVS_OP_SERVER) {
- ret = cvs_server(argc, argv);
- return (ret);
- }
+ if (cmd->cmd_op == CVS_OP_SERVER)
+ return cvs_server(argc, argv);
- if (c->cmd_options != NULL) {
- if ((ret = c->cmd_options(cmd->cmd_opts, argc, argv, &i)) != 0)
+ if (cmd->cmd_init != NULL) {
+ printf("[init]\n");
+ if ((ret = (*cmd->cmd_init)(cmd, argc, argv, &i)) != 0)
return (ret);
argc -= i;
argv += i;
}
- if ((c->cmd_helper != NULL) && ((ret = c->cmd_helper()) != 0))
- return (ret);
+ if (!(cmd->cmd_flags & CVS_CMD_ALLOWSPEC) && (argc > 0))
+ return (CVS_EX_USAGE);
if ((root = cvsroot_get(".")) == NULL)
return (CVS_EX_BADROOT);
+ if ((root->cr_method != CVS_METHOD_LOCAL) && (cvs_connect(root) < 0))
+ return (CVS_EX_PROTO);
if (cvs_trace)
cvs_log(LP_TRACE, "cvs_startcmd() CVSROOT=%s", root->cr_str);
- if (root->cr_method != CVS_METHOD_LOCAL) {
- if (cvs_connect(root) < 0)
- return (CVS_EX_PROTO);
-
- if (c->cmd_flags & CVS_CMD_SENDARGS1) {
- for (i = 0; i < argc; i++) {
- if (cvs_sendarg(root, argv[i], 0) < 0)
- return (CVS_EX_PROTO);
- }
- }
-
- if (c->cmd_sendflags != NULL) {
- if ((ret = c->cmd_sendflags(root)) != 0)
- return (ret);
- }
-
- if (c->cmd_flags & CVS_CMD_NEEDLOG) {
- if (cvs_logmsg_send(root, cvs_msg) < 0)
- return (CVS_EX_PROTO);
- }
+ if (cmd->cmd_pre_exec != NULL) {
+ printf("[pre-exec]\n");
+ if ((ret = cmd->cmd_pre_exec(root)) != 0)
+ return (ret);
}
- /* if we are the version command, don't bother going
- * any further now, we did everything we had to.
- */
- if (cmd->cmd_op == CVS_OP_VERSION)
- return (0);
+ if (root->cr_method == CVS_METHOD_LOCAL)
+ ex_hdlr = cmd->cmd_exec_local;
+ else
+ ex_hdlr = cmd->cmd_exec_remote;
- if ((c->cmd_flags & CVS_CMD_ALLOWSPEC) && argc != 0) {
- cvs_files = cvs_file_getspec(argv, argc, c->file_flags,
- c->cmd_examine, NULL);
+ if (argc > 0) {
+ cvs_files = cvs_file_getspec(argv, argc, cmd->file_flags,
+ ex_hdlr, NULL);
} else {
- cvs_files = cvs_file_get(".", c->file_flags,
- c->cmd_examine, NULL);
+ cvs_files = cvs_file_get(".", cmd->file_flags,
+ ex_hdlr, NULL);
}
if (cvs_files == NULL)
return (CVS_EX_DATA);
+ if (cmd->cmd_post_exec != NULL) {
+ printf("[post-exec]\n");
+ if ((ret = cmd->cmd_post_exec(root)) != 0)
+ return (ret);
+ }
+
if (root->cr_method != CVS_METHOD_LOCAL) {
- if (c->cmd_flags & CVS_CMD_SENDDIR) {
+ if (cmd->cmd_flags & CVS_CMD_SENDDIR) {
if (cvs_senddir(root, cvs_files) < 0)
return (CVS_EX_PROTO);
}
- if (c->cmd_flags & CVS_CMD_SENDARGS2) {
+ if (cmd->cmd_flags & CVS_CMD_SENDARGS2) {
for (i = 0; i < argc; i++) {
if (cvs_sendarg(root, argv[i], 0) < 0)
return (CVS_EX_PROTO);
}
}
- if (cvs_sendreq(root, c->cmd_req,
+ if (cmd->cmd_req != CVS_REQ_NONE && cvs_sendreq(root, cmd->cmd_req,
(cmd->cmd_op == CVS_OP_INIT) ? root->cr_dir : NULL) < 0)
return (CVS_EX_PROTO);
}
+ if (cmd->cmd_cleanup != NULL)
+ (*cmd->cmd_cleanup)();
+
return (0);
}
diff --git a/usr.bin/cvs/commit.c b/usr.bin/cvs/commit.c
index 9ed4fc7f4ec..a4c1276be21 100644
--- a/usr.bin/cvs/commit.c
+++ b/usr.bin/cvs/commit.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: commit.c,v 1.33 2005/05/20 20:00:53 joris Exp $ */
+/* $OpenBSD: commit.c,v 1.34 2005/05/24 04:12:25 jfb Exp $ */
/*
* Copyright (c) 2004 Jean-Francois Brousseau <jfb@openbsd.org>
* All rights reserved.
@@ -41,42 +41,48 @@
#include "proto.h"
-int cvs_commit_prepare(CVSFILE *, void *);
-int cvs_commit_file(CVSFILE *, void *);
-int cvs_commit_options(char *, int, char **, int *);
-int cvs_commit_helper(void);
+static int cvs_commit_init (struct cvs_cmd *, int, char **, int *);
+static int cvs_commit_prepare (CVSFILE *, void *);
+static int cvs_commit_file (CVSFILE *, void *);
+static int cvs_commit_pre_exec(struct cvsroot *);
-struct cvs_cmd_info cvs_commit = {
- cvs_commit_options,
+struct cvs_cmd cvs_cmd_commit = {
+ CVS_OP_COMMIT, CVS_REQ_CI, "commit",
+ { "ci", "com" },
+ "Check files into the repository",
+ "[-flR] [-F logfile | -m msg] [-r rev] ...",
+ "F:flm:Rr:",
NULL,
+ CF_RECURSE | CF_IGNORE | CF_SORT,
+ cvs_commit_init,
+ cvs_commit_pre_exec,
cvs_commit_file,
NULL,
- cvs_commit_helper,
- CF_RECURSE | CF_IGNORE | CF_SORT,
- CVS_REQ_CI,
- CVS_CMD_ALLOWSPEC | CVS_CMD_NEEDLOG | CVS_CMD_SENDDIR | CVS_CMD_SENDARGS2
+ NULL,
+ NULL,
+ CVS_CMD_ALLOWSPEC | CVS_CMD_SENDARGS2
};
static char *mfile = NULL;
static char **commit_files = NULL;
static int commit_fcount = 0;
-int
-cvs_commit_options(char *opt, int argc, char **argv, int *arg)
+static int
+cvs_commit_init(struct cvs_cmd *cmd, int argc, char **argv, int *arg)
{
int ch;
- while ((ch = getopt(argc, argv, opt)) != -1) {
+ while ((ch = getopt(argc, argv, cmd->cmd_opts)) != -1) {
switch (ch) {
case 'F':
mfile = optarg;
break;
case 'f':
/* XXX half-implemented */
- cvs_commit.file_flags &= ~CF_RECURSE;
+ cmd->file_flags &= ~CF_RECURSE;
break;
case 'l':
- cvs_commit.file_flags &= ~CF_RECURSE;
+ cmd->file_flags &= ~CF_RECURSE;
break;
case 'm':
cvs_msg = strdup(optarg);
@@ -86,7 +92,7 @@ cvs_commit_options(char *opt, int argc, char **argv, int *arg)
}
break;
case 'R':
- cvs_commit.file_flags |= CF_RECURSE;
+ cmd->file_flags |= CF_RECURSE;
break;
default:
return (CVS_EX_USAGE);
@@ -110,7 +116,7 @@ cvs_commit_options(char *opt, int argc, char **argv, int *arg)
}
int
-cvs_commit_helper(void)
+cvs_commit_pre_exec(struct cvsroot *root)
{
struct cvs_flist cl;
CVSFILE *cfp;
diff --git a/usr.bin/cvs/cvs.1 b/usr.bin/cvs/cvs.1
index 60d197717a3..455ed1d1565 100644
--- a/usr.bin/cvs/cvs.1
+++ b/usr.bin/cvs/cvs.1
@@ -1,4 +1,4 @@
-.\" $OpenBSD: cvs.1,v 1.65 2005/05/23 21:01:11 joris Exp $
+.\" $OpenBSD: cvs.1,v 1.66 2005/05/24 04:12:25 jfb Exp $
.\"
.\" Copyright (c) 2004 Jean-Francois Brousseau <jfb@openbsd.org>
.\" Copyright (c) 2004, 2005 Xavier Santolaria <xsa@openbsd.org>
@@ -424,7 +424,8 @@ Show annotations as of revision
.El
.Pp
Aliases:
-.Ic ann .
+.Ic ann ,
+.Ic blame .
.It Xo Ic checkout
.Op Fl AcflNnPpRs
.Op Fl d Ar dir
diff --git a/usr.bin/cvs/cvs.c b/usr.bin/cvs/cvs.c
index 385a0e7a529..9873971df33 100644
--- a/usr.bin/cvs/cvs.c
+++ b/usr.bin/cvs/cvs.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: cvs.c,v 1.66 2005/05/23 18:10:34 joris Exp $ */
+/* $OpenBSD: cvs.c,v 1.67 2005/05/24 04:12:25 jfb Exp $ */
/*
* Copyright (c) 2004 Jean-Francois Brousseau <jfb@openbsd.org>
* All rights reserved.
@@ -73,231 +73,6 @@ CVSFILE *cvs_files;
static TAILQ_HEAD(, cvs_var) cvs_variables;
-/*
- * Command dispatch table
- * ----------------------
- *
- * The synopsis field should only contain the list of arguments that the
- * command supports, without the actual command's name.
- *
- * Command handlers are expected to return 0 if no error occurred, or one of
- * the CVS_EX_* error codes in case of an error. In case the error
- * returned is 1, the command's usage string is printed to standard
- * error before returning.
- */
-struct cvs_cmd cvs_cdt[] = {
- {
- CVS_OP_ADD, "add", { "ad", "new" }, &cvs_add,
- "[-k mode] [-m msg] file ...",
- "k:m:",
- "Add a new file/directory to the repository",
- NULL
- },
- {
- CVS_OP_ADMIN, "admin", { "adm", "rcs" }, &cvs_admin,
- "",
- "a:A:b::c:e::Ik:l::Lm:n:N:o:qs:t:u::U",
- "Administration front end for rcs",
- NULL
- },
- {
- CVS_OP_ANNOTATE, "annotate", { "ann" }, &cvs_annotate,
- "[-flR] [-D date | -r rev] ...",
- "D:flRr:",
- "Show last revision where each line was modified",
- NULL
- },
- {
- CVS_OP_CHECKOUT, "checkout", { "co", "get" }, &cvs_checkout,
- "[-AcflNnPpRs] [-D date | -r rev] [-d dir] [-j rev] [-k mode] "
- "[-t id] module ...",
- "AcD:d:fj:k:lNnPpRr:st:",
- "Checkout sources for editing",
- NULL
- },
- {
- CVS_OP_COMMIT, "commit", { "ci", "com" }, &cvs_commit,
- "[-flR] [-F logfile | -m msg] [-r rev] ...",
- "F:flm:Rr:",
- "Check files into the repository",
- NULL
- },
- {
- CVS_OP_DIFF, "diff", { "di", "dif" }, &cvs_diff,
- "[-cilNnpRu] [-D date] [-r rev] ...",
- "cD:ilNnpRr:u",
- "Show differences between revisions",
- NULL
- },
- {
- CVS_OP_EDIT, "edit", { }, NULL,
- "",
- "",
- "Get ready to edit a watched file",
- NULL
- },
- {
- CVS_OP_EDITORS, "editors", { }, NULL,
- "",
- "",
- "See who is editing a watched file",
- NULL
- },
- {
- CVS_OP_EXPORT, "export", { "ex", "exp" }, NULL,
- "",
- "",
- "Export sources from CVS, similar to checkout",
- NULL
- },
- {
- CVS_OP_HISTORY, "history", { "hi", "his" }, &cvs_history,
- "",
- "acelm:oTt:u:wx:z:",
- "Show repository access history",
- NULL
- },
- {
- CVS_OP_IMPORT, "import", { "im", "imp" }, &cvs_import,
- "[-d] [-b branch] [-I ign] [-k subst] [-m msg] "
- "repository vendor-tag release-tags ...",
- "b:dI:k:m:",
- "Import sources into CVS, using vendor branches",
- NULL
- },
- {
- CVS_OP_INIT, "init", { }, &cvs_init,
- "",
- "",
- "Create a CVS repository if it doesn't exist",
- NULL
- },
-#if defined(HAVE_KERBEROS)
- {
- "kserver", {}, NULL
- "",
- "",
- "Start a Kerberos authentication CVS server",
- NULL
- },
-#endif
- {
- CVS_OP_LOG, "log", { "lo" }, &cvs_getlog,
- "[-bhlNRt] [-d dates] [-r revisions] [-s states] [-w logins]",
- "bd:hlNRrs:tw",
- "Print out history information for files",
- NULL
- },
- {
- -1, "login", {}, NULL,
- "",
- "",
- "Prompt for password for authenticating server",
- NULL
- },
- {
- -1, "logout", {}, NULL,
- "",
- "",
- "Removes entry in .cvspass for remote repository",
- NULL
- },
- {
- CVS_OP_RDIFF, "rdiff", {}, NULL,
- "",
- "",
- "Create 'patch' format diffs between releases",
- NULL
- },
- {
- CVS_OP_RELEASE, "release", { "re", "rel" }, &cvs_release,
- "[-d] dir ...",
- "d",
- "Indicate that a Module is no longer in use",
- NULL
- },
- {
- CVS_OP_REMOVE, "remove", { "rm", "delete" }, &cvs_remove,
- "[-flR] [file ...]",
- "flR",
- "Remove an entry from the repository",
- NULL
- },
- {
- CVS_OP_RLOG, "rlog", {}, NULL,
- "",
- "",
- "Print out history information for a module",
- NULL
- },
- {
- CVS_OP_RTAG, "rtag", {}, NULL,
- "",
- "",
- "Add a symbolic tag to a module",
- NULL
- },
- {
- CVS_OP_SERVER, "server", {}, &cmd_server,
- "",
- "",
- "Server mode",
- NULL
- },
- {
- CVS_OP_STATUS, "status", { "st", "stat" }, &cvs_status,
- "[-lRv]",
- "lRv",
- "Display status information on checked out files",
- NULL
- },
- {
- CVS_OP_TAG, "tag", { "ta", "freeze" }, &cvs_tag,
- "[-bcdFflR] [-D date | -r rev] tagname ...",
- "bcD:dFflRr:",
- "Add a symbolic tag to checked out version of files",
- NULL
- },
- {
- CVS_OP_UNEDIT, "unedit", {}, NULL,
- "",
- "",
- "Undo an edit command",
- NULL
- },
- {
- CVS_OP_UPDATE, "update", { "up", "upd" }, &cvs_update,
- "[-ACdflPpR] [-D date | -r rev] [-I ign] [-j rev] [-k mode] "
- "[-t id] ...",
- "ACD:dflPpQqRr:",
- "Bring work tree in sync with repository",
- NULL
- },
- {
- CVS_OP_VERSION, "version", { "ve", "ver" }, &cvs_version,
- "", "",
- "Show current CVS version(s)",
- NULL
- },
- {
- CVS_OP_WATCH, "watch", {}, NULL,
- "",
- "",
- "Set watches",
- NULL
- },
- {
- CVS_OP_WATCHERS, "watchers", {}, NULL,
- "",
- "",
- "See who is watching a file",
- NULL
- },
-};
-
-#define CVS_NBCMD (sizeof(cvs_cdt)/sizeof(cvs_cdt[0]))
-
-
void usage (void);
static void cvs_read_rcfile (void);
@@ -390,15 +165,10 @@ main(int argc, char **argv)
if (cmdp == NULL) {
fprintf(stderr, "Unknown command: `%s'\n\n", cvs_command);
fprintf(stderr, "CVS commands are:\n");
- for (i = 0; i < (int)CVS_NBCMD; i++)
+ for (i = 0; cvs_cdt[i] != NULL; i++)
fprintf(stderr, "\t%-16s%s\n",
- cvs_cdt[i].cmd_name, cvs_cdt[i].cmd_descr);
- exit(1);
- }
-
- if (cmdp->cmd_info == NULL) {
- cvs_log(LP_ERR, "command `%s' not implemented", cvs_command);
- exit(1);
+ cvs_cdt[i]->cmd_name, cvs_cdt[i]->cmd_descr);
+ exit(CVS_EX_USAGE);
}
cvs_cmdop = cmdp->cmd_op;
@@ -446,8 +216,6 @@ main(int argc, char **argv)
break;
}
- if (cmdp->cmd_info->cmd_cleanup != NULL)
- cmdp->cmd_info->cmd_cleanup();
if (cvs_files != NULL)
cvs_file_free(cvs_files);
if (cvs_msg != NULL)
@@ -548,38 +316,6 @@ cvs_getopt(int argc, char **argv)
/*
- * cvs_findcmd()
- *
- * Find the entry in the command dispatch table whose name or one of its
- * aliases matches <cmd>.
- * Returns a pointer to the command entry on success, NULL on failure.
- */
-struct cvs_cmd*
-cvs_findcmd(const char *cmd)
-{
- u_int i, j;
- struct cvs_cmd *cmdp;
-
- cmdp = NULL;
-
- for (i = 0; (i < CVS_NBCMD) && (cmdp == NULL); i++) {
- if (strcmp(cmd, cvs_cdt[i].cmd_name) == 0)
- cmdp = &cvs_cdt[i];
- else {
- for (j = 0; j < CVS_CMD_MAXALIAS; j++) {
- if (strcmp(cmd, cvs_cdt[i].cmd_alias[j]) == 0) {
- cmdp = &cvs_cdt[i];
- break;
- }
- }
- }
- }
-
- return (cmdp);
-}
-
-
-/*
* cvs_read_rcfile()
*
* Read the CVS `.cvsrc' file in the user's home directory. If the file
diff --git a/usr.bin/cvs/cvs.h b/usr.bin/cvs/cvs.h
index 6955ccdbc51..c4418b7941f 100644
--- a/usr.bin/cvs/cvs.h
+++ b/usr.bin/cvs/cvs.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: cvs.h,v 1.57 2005/05/20 18:26:49 xsa Exp $ */
+/* $OpenBSD: cvs.h,v 1.58 2005/05/24 04:12:25 jfb Exp $ */
/*
* Copyright (c) 2004 Jean-Francois Brousseau <jfb@openbsd.org>
* All rights reserved.
@@ -35,8 +35,8 @@
#include "file.h"
#define CVS_VERSION_MAJOR 0
-#define CVS_VERSION_MINOR 2
-#define CVS_VERSION "OpenCVS 0.2"
+#define CVS_VERSION_MINOR 3
+#define CVS_VERSION "OpenCVS 0.3"
#define CVS_HIST_CACHE 128
@@ -134,50 +134,35 @@
#define CVS_PATH_ROOTSPEC CVS_PATH_CVSDIR "/Root"
#define CVS_PATH_REPOSITORY CVS_PATH_CVSDIR "/Repository"
-struct cvs_cmd_info {
- /* parses the options for the command */
- int (*cmd_options)(char *, int, char **, int *);
-
- /* send command specific flags (CVS_METHOD_REMOTE only) */
- int (*cmd_sendflags)(struct cvsroot *);
-
- /* callback to be used for cvs_file_examine() */
- int (*cmd_examine)(CVSFILE *, void *);
-
- /* called after everything is done */
- int (*cmd_cleanup)(void);
-
- /* helper function, gets called after cvs_file_get()
- * to do command specific operations if needed.
- */
- int (*cmd_helper)(void);
-
- /* flags for cvs_file_get() */
- int file_flags;
-
- /* number of request */
- int cmd_req;
-
- /* info on the command (see flags below) */
- int cmd_flags;
-};
/* flags for cmd_flags */
#define CVS_CMD_ALLOWSPEC 0x01
-#define CVS_CMD_NEEDLOG 0x02
#define CVS_CMD_SENDARGS1 0x04
#define CVS_CMD_SENDARGS2 0x08
#define CVS_CMD_SENDDIR 0x10
+
struct cvs_cmd {
- int cmd_op;
- char cmd_name[CVS_CMD_MAXNAMELEN];
- char cmd_alias[CVS_CMD_MAXALIAS][CVS_CMD_MAXNAMELEN];
- struct cvs_cmd_info *cmd_info;
+ int cmd_op;
+ int cmd_req;
+ char cmd_name[CVS_CMD_MAXNAMELEN];
+ char cmd_alias[CVS_CMD_MAXALIAS][CVS_CMD_MAXNAMELEN];
+ char cmd_descr[CVS_CMD_MAXDESCRLEN];
char *cmd_synopsis;
char *cmd_opts;
- char cmd_descr[CVS_CMD_MAXDESCRLEN];
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;
};
struct cvs_file;
@@ -324,39 +309,42 @@ extern CVSFILE *cvs_files;
#endif
-
-/* client command handlers */
-extern struct cvs_cmd_info cvs_add;
-extern struct cvs_cmd_info cvs_admin;
-extern struct cvs_cmd_info cvs_annotate;
-extern struct cvs_cmd_info cvs_checkout;
-extern struct cvs_cmd_info cvs_commit;
-extern struct cvs_cmd_info cvs_diff;
-extern struct cvs_cmd_info cvs_edit;
-extern struct cvs_cmd_info cvs_editors;
-extern struct cvs_cmd_info cvs_export;
-extern struct cvs_cmd_info cvs_getlog;
-extern struct cvs_cmd_info cvs_history;
-extern struct cvs_cmd_info cvs_import;
-extern struct cvs_cmd_info cvs_init;
-extern struct cvs_cmd_info cvs_rdiff;
-extern struct cvs_cmd_info cvs_release;
-extern struct cvs_cmd_info cvs_remove;
-extern struct cvs_cmd_info cvs_rlog;
-extern struct cvs_cmd_info cvs_rtag;
-extern struct cvs_cmd_info cmd_server;
-extern struct cvs_cmd_info cvs_status;
-extern struct cvs_cmd_info cvs_tag;
-extern struct cvs_cmd_info cvs_unedit;
-extern struct cvs_cmd_info cvs_update;
-extern struct cvs_cmd_info cvs_version;
-extern struct cvs_cmd_info cvs_watch;
-extern struct cvs_cmd_info cvs_watchers;
-
-struct cvs_cmd* cvs_findcmd (const char *);
-int cvs_startcmd (struct cvs_cmd *, int, char **);
-int cvs_server (int, char **);
-
+extern struct cvs_cmd *cvs_cdt[];
+
+extern struct cvs_cmd cvs_cmd_add;
+extern struct cvs_cmd cvs_cmd_admin;
+extern struct cvs_cmd cvs_cmd_annotate;
+extern struct cvs_cmd cvs_cmd_checkout;
+extern struct cvs_cmd cvs_cmd_commit;
+extern struct cvs_cmd cvs_cmd_diff;
+extern struct cvs_cmd cvs_cmd_edit;
+extern struct cvs_cmd cvs_cmd_editors;
+extern struct cvs_cmd cvs_cmd_export;
+extern struct cvs_cmd cvs_cmd_history;
+extern struct cvs_cmd cvs_cmd_import;
+extern struct cvs_cmd cvs_cmd_init;
+extern struct cvs_cmd cvs_cmd_log;
+extern struct cvs_cmd cvs_cmd_login;
+extern struct cvs_cmd cvs_cmd_logout;
+extern struct cvs_cmd cvs_cmd_rdiff;
+extern struct cvs_cmd cvs_cmd_release;
+extern struct cvs_cmd cvs_cmd_remove;
+extern struct cvs_cmd cvs_cmd_rlog;
+extern struct cvs_cmd cvs_cmd_rtag;
+extern struct cvs_cmd cvs_cmd_status;
+extern struct cvs_cmd cvs_cmd_tag;
+extern struct cvs_cmd cvs_cmd_update;
+extern struct cvs_cmd cvs_cmd_version;
+extern struct cvs_cmd cvs_cmd_server;
+extern struct cvs_cmd cvs_cmd_unedit;
+extern struct cvs_cmd cvs_cmd_watch;
+extern struct cvs_cmd cvs_cmd_watchers;
+
+
+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 **);
int cvs_var_set (const char *, const char *);
int cvs_var_unset (const char *);
diff --git a/usr.bin/cvs/diff.c b/usr.bin/cvs/diff.c
index 863ef2c04f9..1deb7336b16 100644
--- a/usr.bin/cvs/diff.c
+++ b/usr.bin/cvs/diff.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: diff.c,v 1.35 2005/05/22 17:48:54 jfb Exp $ */
+/* $OpenBSD: diff.c,v 1.36 2005/05/24 04:12:25 jfb Exp $ */
/*
* Copyright (C) Caldera International Inc. 2001-2002.
* All rights reserved.
@@ -206,11 +206,12 @@ struct diff_arg {
};
-int cvs_diff_options (char *, int, char **, int *);
+static int cvs_diff_init (struct cvs_cmd *, int, char **, int *);
+static int cvs_diff_remote (CVSFILE *, void *);
+static int cvs_diff_local (CVSFILE *, void *);
+static int cvs_diff_pre_exec (struct cvsroot *);
+static int cvs_diff_cleanup (void);
int cvs_diffreg (const char *, const char *);
-int cvs_diff_file (CVSFILE *, void *);
-int cvs_diff_sendflags (struct cvsroot *);
-int cvs_diff_cleanup (void);
static void output(const char *, FILE *, const char *, FILE *);
static void check(FILE *, FILE *);
@@ -253,7 +254,7 @@ static int *klist; /* will be overlaid on file[0] after class */
static int *member; /* will be overlaid on file[1] */
static int clen;
static int inifdef; /* whether or not we are in a #ifdef block */
-static int len[2];
+static int diff_len[2];
static int pref, suff; /* length of prefix and suffix */
static int slen[2];
static int anychange;
@@ -331,22 +332,47 @@ u_char cup2low[256] = {
0xfd, 0xfe, 0xff
};
-struct cvs_cmd_info cvs_diff = {
- cvs_diff_options,
- cvs_diff_sendflags,
- cvs_diff_file,
- cvs_diff_cleanup,
+
+struct cvs_cmd cvs_cmd_diff = {
+ CVS_OP_DIFF, CVS_REQ_DIFF, "diff",
+ { "di", "dif" },
+ "Show differences between revisions",
+ "[-cilNnpu] [-D date] [-r rev] ...",
+ "cD:ilNnpr:Ru",
+ NULL,
+ CF_RECURSE | CF_IGNORE | CF_SORT | CF_KNOWN,
+ cvs_diff_init,
+ cvs_diff_pre_exec,
+ cvs_diff_remote,
+ cvs_diff_local,
+ NULL,
+ cvs_diff_cleanup,
+ CVS_CMD_SENDARGS2 | CVS_CMD_ALLOWSPEC | CVS_CMD_SENDDIR
+};
+
+
+struct cvs_cmd cvs_cmd_rdiff = {
+ CVS_OP_RDIFF, CVS_REQ_DIFF, "rdiff",
+ { "di", "dif" },
+ "Create 'patch' format diffs between releases",
+ "",
+ "",
NULL,
CF_RECURSE | CF_IGNORE | CF_SORT | CF_KNOWN,
- CVS_REQ_DIFF,
+ cvs_diff_init,
+ cvs_diff_pre_exec,
+ cvs_diff_remote,
+ cvs_diff_local,
+ NULL,
+ cvs_diff_cleanup,
CVS_CMD_SENDARGS2 | CVS_CMD_ALLOWSPEC | CVS_CMD_SENDDIR
};
static struct diff_arg *dap = NULL;
static int recurse;
-int
-cvs_diff_options(char *opt, int argc, char **argv, int *arg)
+static int
+cvs_diff_init(struct cvs_cmd *cmd, int argc, char **argv, int *arg)
{
int ch;
@@ -356,7 +382,7 @@ cvs_diff_options(char *opt, int argc, char **argv, int *arg)
dap->date1 = dap->date2 = dap->rev1 = dap->rev2 = NULL;
strlcpy(diffargs, argv[0], sizeof(diffargs));
- while ((ch = getopt(argc, argv, opt)) != -1) {
+ while ((ch = getopt(argc, argv, cmd->cmd_opts)) != -1) {
switch (ch) {
case 'c':
strlcat(diffargs, " -c", sizeof(diffargs));
@@ -376,7 +402,7 @@ cvs_diff_options(char *opt, int argc, char **argv, int *arg)
case 'l':
strlcat(diffargs, " -l", sizeof(diffargs));
recurse = 0;
- cvs_diff.file_flags &= ~CF_RECURSE;
+ cvs_cmd_diff.file_flags &= ~CF_RECURSE;
break;
case 'i':
strlcat(diffargs, " -i", sizeof(diffargs));
@@ -408,7 +434,7 @@ cvs_diff_options(char *opt, int argc, char **argv, int *arg)
}
break;
case 'R':
- cvs_diff.file_flags |= CF_RECURSE;
+ cvs_cmd_diff.file_flags |= CF_RECURSE;
break;
case 'u':
strlcat(diffargs, " -u", sizeof(diffargs));
@@ -426,42 +452,46 @@ cvs_diff_options(char *opt, int argc, char **argv, int *arg)
int
cvs_diff_cleanup(void)
{
- if (dap != NULL)
+ if (dap != NULL) {
free(dap);
+ dap = NULL;
+ }
return (0);
}
/*
- * cvs_diff_sendflags()
+ * cvs_diff_pre_exec()
*
*/
int
-cvs_diff_sendflags(struct cvsroot *root)
+cvs_diff_pre_exec(struct cvsroot *root)
{
- /* send the flags */
- if (Nflag && (cvs_sendarg(root, "-N", 0) < 0))
- return (CVS_EX_PROTO);
- if (pflag && (cvs_sendarg(root, "-p", 0) < 0))
- return (CVS_EX_PROTO);
+ if (root->cr_method != CVS_METHOD_LOCAL) {
+ /* send the flags */
+ if (Nflag && (cvs_sendarg(root, "-N", 0) < 0))
+ return (CVS_EX_PROTO);
+ if (pflag && (cvs_sendarg(root, "-p", 0) < 0))
+ return (CVS_EX_PROTO);
- if (format == D_CONTEXT)
- cvs_sendarg(root, "-c", 0);
- else if (format == D_UNIFIED)
- cvs_sendarg(root, "-u", 0);
-
- if (dap->rev1 != NULL) {
- cvs_sendarg(root, "-r", 0);
- cvs_sendarg(root, dap->rev1, 0);
- } else if (dap->date1 != NULL) {
- cvs_sendarg(root, "-D", 0);
- cvs_sendarg(root, dap->date1, 0);
- }
- if (dap->rev2 != NULL) {
- cvs_sendarg(root, "-r", 0);
- cvs_sendarg(root, dap->rev2, 0);
- } else if (dap->date2 != NULL) {
- cvs_sendarg(root, "-D", 0);
- cvs_sendarg(root, dap->date2, 0);
+ if (format == D_CONTEXT)
+ cvs_sendarg(root, "-c", 0);
+ else if (format == D_UNIFIED)
+ cvs_sendarg(root, "-u", 0);
+
+ if (dap->rev1 != NULL) {
+ cvs_sendarg(root, "-r", 0);
+ cvs_sendarg(root, dap->rev1, 0);
+ } else if (dap->date1 != NULL) {
+ cvs_sendarg(root, "-D", 0);
+ cvs_sendarg(root, dap->date1, 0);
+ }
+ if (dap->rev2 != NULL) {
+ cvs_sendarg(root, "-r", 0);
+ cvs_sendarg(root, dap->rev2, 0);
+ } else if (dap->date2 != NULL) {
+ cvs_sendarg(root, "-D", 0);
+ cvs_sendarg(root, dap->date2, 0);
+ }
}
return (0);
@@ -473,16 +503,11 @@ cvs_diff_sendflags(struct cvsroot *root)
*
* Diff a single file.
*/
-int
-cvs_diff_file(struct cvs_file *cfp, void *arg)
+static int
+cvs_diff_remote(struct cvs_file *cfp, void *arg)
{
- int l;
- char *dir, *repo, buf[64];
- char fpath[MAXPATHLEN], dfpath[MAXPATHLEN], rcspath[MAXPATHLEN];
- char path_tmp1[MAXPATHLEN], path_tmp2[MAXPATHLEN];
- BUF *b1, *b2;
- RCSNUM *r1, *r2;
- RCSFILE *rf;
+ char *dir, *repo;
+ char fpath[MAXPATHLEN], dfpath[MAXPATHLEN];
struct cvsroot *root;
if (cfp->cf_type == DT_DIR) {
@@ -496,7 +521,7 @@ cvs_diff_file(struct cvs_file *cfp, void *arg)
if ((cfp->cf_parent == NULL) ||
(root != cfp->cf_parent->cf_root)) {
cvs_connect(root);
- cvs_diff_sendflags(root);
+ cvs_diff_pre_exec(root);
}
#endif
@@ -511,7 +536,6 @@ cvs_diff_file(struct cvs_file *cfp, void *arg)
return (0);
}
- rf = NULL;
diff_file = cvs_file_getpath(cfp, fpath, sizeof(fpath));
if (cfp->cf_parent != NULL) {
@@ -525,101 +549,128 @@ cvs_diff_file(struct cvs_file *cfp, void *arg)
}
if (cfp->cf_cvstat == CVS_FST_UNKNOWN) {
- if (root->cr_method == CVS_METHOD_LOCAL)
- cvs_log(LP_WARN, "I know nothing about %s", diff_file);
- else
- cvs_sendreq(root, CVS_REQ_QUESTIONABLE,
- CVS_FILE_NAME(cfp));
+ cvs_sendreq(root, CVS_REQ_QUESTIONABLE, cfp->cf_name);
return (0);
}
- if (root->cr_method != CVS_METHOD_LOCAL) {
- if (cvs_sendentry(root, cfp) < 0) {
- return (CVS_EX_PROTO);
- }
- }
+ if (cvs_sendentry(root, cfp) < 0)
+ return (CVS_EX_PROTO);
if (cfp->cf_cvstat == CVS_FST_UPTODATE) {
- if (root->cr_method != CVS_METHOD_LOCAL)
- cvs_sendreq(root, CVS_REQ_UNCHANGED,
- CVS_FILE_NAME(cfp));
+ cvs_sendreq(root, CVS_REQ_UNCHANGED, cfp->cf_name);
return (0);
}
/* at this point, the file is modified */
- if (root->cr_method != CVS_METHOD_LOCAL) {
- cvs_sendreq(root, CVS_REQ_MODIFIED, CVS_FILE_NAME(cfp));
- cvs_sendfile(root, diff_file);
- } else {
- l = snprintf(rcspath, sizeof(rcspath), "%s/%s/%s%s",
- root->cr_dir, repo, diff_file, RCS_FILE_EXT);
- if (l == -1 || l >= (int)sizeof(rcspath)) {
- errno = ENAMETOOLONG;
- cvs_log(LP_ERRNO, "%s", rcspath);
- return (CVS_EX_DATA);
- }
+ if ((cvs_sendreq(root, CVS_REQ_MODIFIED, cfp->cf_name) < 0) ||
+ (cvs_sendfile(root, diff_file) < 0))
+ return (CVS_EX_PROTO);
- rf = rcs_open(rcspath, RCS_READ);
- if (rf == NULL) {
- return (CVS_EX_DATA);
- }
+ return (0);
+}
- cvs_printf("Index: %s\n%s\nRCS file: %s\n", diff_file,
- RCS_DIFF_DIV, rcspath);
+static int
+cvs_diff_local(CVSFILE *cf, void *arg)
+{
+ int len;
+ char *repo, buf[64];
+ char fpath[MAXPATHLEN], rcspath[MAXPATHLEN];
+ char path_tmp1[MAXPATHLEN], path_tmp2[MAXPATHLEN];
+ BUF *b1, *b2;
+ RCSNUM *r1, *r2;
+ RCSFILE *rf;
+ struct cvsroot *root;
- if (dap->rev1 == NULL)
- r1 = cfp->cf_lrev;
- else {
- if ((r1 = rcsnum_parse(dap->rev1)) == NULL) {
- return (CVS_EX_DATA);
- }
- }
+ rf = NULL;
+ root = CVS_DIR_ROOT(cf);
+ repo = CVS_DIR_REPO(cf);
+ diff_file = cvs_file_getpath(cf, fpath, sizeof(fpath));
- cvs_printf("retrieving revision %s\n",
- rcsnum_tostr(r1, buf, sizeof(buf)));
- b1 = rcs_getrev(rf, r1);
+ if (cf->cf_type == DT_DIR) {
+ cvs_log(LP_INFO, "Diffing %s", fpath);
+ return (0);
+ }
- if (r1 != cfp->cf_lrev)
- rcsnum_free(r1);
+ if (cf->cf_cvstat == CVS_FST_LOST) {
+ cvs_log(LP_WARN, "cannot find file %s", cf->cf_name);
+ return (0);
+ }
- if (dap->rev2 != NULL) {
- cvs_printf("retrieving revision %s\n", dap->rev2);
- if ((r2 = rcsnum_parse(dap->rev2)) == NULL) {
- return (CVS_EX_DATA);
- }
- b2 = rcs_getrev(rf, r2);
- rcsnum_free(r2);
- } else {
- b2 = cvs_buf_load(diff_file, BUF_AUTOEXT);
- }
+ if (cf->cf_cvstat == CVS_FST_UNKNOWN) {
+ cvs_log(LP_WARN, "I know nothing about %s", diff_file);
+ return (0);
+ } else if (cf->cf_cvstat == CVS_FST_UPTODATE)
+ return (0);
- rcs_close(rf);
-
- printf("%s", diffargs);
- printf(" -r%s", buf);
- if (dap->rev2 != NULL)
- printf(" -r%s", dap->rev2);
- printf(" %s\n", diff_file);
- strlcpy(path_tmp1, "/tmp/diff1.XXXXXXXXXX", sizeof(path_tmp1));
- if (cvs_buf_write_stmp(b1, path_tmp1, 0600) == -1) {
- cvs_buf_free(b1);
- cvs_buf_free(b2);
+ /* at this point, the file is modified */
+ len = snprintf(rcspath, sizeof(rcspath), "%s/%s/%s%s",
+ root->cr_dir, repo, diff_file, RCS_FILE_EXT);
+ if (len == -1 || len >= (int)sizeof(rcspath)) {
+ errno = ENAMETOOLONG;
+ cvs_log(LP_ERRNO, "%s", rcspath);
+ return (CVS_EX_DATA);
+ }
+
+ rf = rcs_open(rcspath, RCS_READ);
+ if (rf == NULL) {
+ return (CVS_EX_DATA);
+ }
+
+ cvs_printf("Index: %s\n%s\nRCS file: %s\n", diff_file,
+ RCS_DIFF_DIV, rcspath);
+
+ if (dap->rev1 == NULL)
+ r1 = cf->cf_lrev;
+ else {
+ if ((r1 = rcsnum_parse(dap->rev1)) == NULL) {
return (CVS_EX_DATA);
}
- cvs_buf_free(b1);
+ }
+
+ cvs_printf("retrieving revision %s\n",
+ rcsnum_tostr(r1, buf, sizeof(buf)));
+ b1 = rcs_getrev(rf, r1);
+
+ if (r1 != cf->cf_lrev)
+ rcsnum_free(r1);
- strlcpy(path_tmp2, "/tmp/diff2.XXXXXXXXXX", sizeof(path_tmp2));
- if (cvs_buf_write_stmp(b2, path_tmp2, 0600) == -1) {
- cvs_buf_free(b2);
- (void)unlink(path_tmp1);
+ if (dap->rev2 != NULL) {
+ cvs_printf("retrieving revision %s\n", dap->rev2);
+ if ((r2 = rcsnum_parse(dap->rev2)) == NULL) {
return (CVS_EX_DATA);
}
+ b2 = rcs_getrev(rf, r2);
+ rcsnum_free(r2);
+ } else {
+ b2 = cvs_buf_load(diff_file, BUF_AUTOEXT);
+ }
+
+ rcs_close(rf);
+
+ printf("%s", diffargs);
+ printf(" -r%s", buf);
+ if (dap->rev2 != NULL)
+ printf(" -r%s", dap->rev2);
+ printf(" %s\n", diff_file);
+ strlcpy(path_tmp1, "/tmp/diff1.XXXXXXXXXX", sizeof(path_tmp1));
+ if (cvs_buf_write_stmp(b1, path_tmp1, 0600) == -1) {
+ cvs_buf_free(b1);
cvs_buf_free(b2);
+ return (CVS_EX_DATA);
+ }
+ cvs_buf_free(b1);
- cvs_diffreg(path_tmp1, path_tmp2);
+ strlcpy(path_tmp2, "/tmp/diff2.XXXXXXXXXX", sizeof(path_tmp2));
+ if (cvs_buf_write_stmp(b2, path_tmp2, 0600) == -1) {
+ cvs_buf_free(b2);
(void)unlink(path_tmp1);
- (void)unlink(path_tmp2);
+ return (CVS_EX_DATA);
}
+ cvs_buf_free(b2);
+
+ cvs_diffreg(path_tmp1, path_tmp2);
+ (void)unlink(path_tmp1);
+ (void)unlink(path_tmp2);
return (0);
}
@@ -711,13 +762,13 @@ cvs_diffreg(const char *file1, const char *file2)
free(member);
free(class);
- J = realloc(J, (len[0] + 2) * sizeof(int));
+ J = realloc(J, (diff_len[0] + 2) * sizeof(int));
unravel(klist[i]);
free(clist);
free(klist);
- ixold = realloc(ixold, (len[0] + 2) * sizeof(long));
- ixnew = realloc(ixnew, (len[1] + 2) * sizeof(long));
+ ixold = realloc(ixold, (diff_len[0] + 2) * sizeof(long));
+ ixnew = realloc(ixnew, (diff_len[1] + 2) * sizeof(long));
check(f1, f2);
output(file1, f1, file2, f2);
@@ -795,7 +846,7 @@ prepare(int i, FILE *fd, off_t filesize)
}
p[++j].value = h;
}
- len[i] = j;
+ diff_len[i] = j;
file[i] = p;
return (0);
@@ -806,17 +857,19 @@ prune(void)
{
int i, j;
- for (pref = 0; pref < len[0] && pref < len[1] &&
+ for (pref = 0; pref < diff_len[0] && pref < diff_len[1] &&
file[0][pref + 1].value == file[1][pref + 1].value;
pref++)
;
- for (suff = 0; suff < len[0] - pref && suff < len[1] - pref &&
- file[0][len[0] - suff].value == file[1][len[1] - suff].value;
+ for (suff = 0;
+ (suff < diff_len[0] - pref) && (suff < diff_len[1] - pref) &&
+ (file[0][diff_len[0] - suff].value ==
+ file[1][diff_len[1] - suff].value);
suff++)
;
for (j = 0; j < 2; j++) {
sfile[j] = file[j] + pref;
- slen[j] = len[j] - pref - suff;
+ slen[j] = diff_len[j] - pref - suff;
for (i = 0; i <= slen[j]; i++)
sfile[j][i].serial = i;
}
@@ -963,9 +1016,9 @@ unravel(int p)
struct cand *q;
int i;
- for (i = 0; i <= len[0]; i++)
+ for (i = 0; i <= diff_len[0]; i++)
J[i] = i <= pref ? i :
- i > len[0] - suff ? i + len[1] - len[0] : 0;
+ i > diff_len[0] - suff ? i + diff_len[1] - diff_len[0] : 0;
for (q = clist + p; q->y != 0; q = clist + q->pred)
J[q->x + pref] = q->y + pref;
}
@@ -988,7 +1041,7 @@ check(FILE *f1, FILE *f2)
ixold[0] = ixnew[0] = 0;
jackpot = 0;
ctold = ctnew = 0;
- for (i = 1; i <= len[0]; i++) {
+ for (i = 1; i <= diff_len[0]; i++) {
if (J[i] == 0) {
ixold[i] = ctold += skipline(f1);
continue;
@@ -1066,7 +1119,7 @@ check(FILE *f1, FILE *f2)
ixnew[j] = ctnew;
j++;
}
- for (; j <= len[1]; j++)
+ for (; j <= diff_len[1]; j++)
ixnew[j] = ctnew += skipline(f2);
/*
* if (jackpot)
@@ -1140,9 +1193,9 @@ output(const char *file1, FILE *f1, const char *file2, FILE *f2)
rewind(f1);
rewind(f2);
- m = len[0];
+ m = diff_len[0];
J[0] = 0;
- J[m + 1] = len[1] + 1;
+ J[m + 1] = diff_len[1] + 1;
for (i0 = 1; i0 <= m; i0 = i1 + 1) {
while (i0 <= m && J[i0] == J[i0 - 1] + 1)
i0++;
@@ -1155,7 +1208,7 @@ output(const char *file1, FILE *f1, const char *file2, FILE *f2)
change(file1, f1, file2, f2, i0, i1, j0, j1);
}
if (m == 0)
- change(file1, f1, file2, f2, 1, 0, 1, len[1]);
+ change(file1, f1, file2, f2, 1, 0, 1, diff_len[1]);
if (format == D_IFDEF) {
for (;;) {
#define c i0
@@ -1527,9 +1580,9 @@ dump_context_vec(FILE *f1, FILE *f2)
b = d = 0; /* gcc */
lowa = MAX(1, cvp->a - context);
- upb = MIN(len[0], context_vec_ptr->b + context);
+ upb = MIN(diff_len[0], context_vec_ptr->b + context);
lowc = MAX(1, cvp->c - context);
- upd = MIN(len[1], context_vec_ptr->d + context);
+ upd = MIN(diff_len[1], context_vec_ptr->d + context);
printf("***************");
if (pflag) {
@@ -1632,9 +1685,9 @@ dump_unified_vec(FILE *f1, FILE *f2)
b = d = 0; /* gcc */
lowa = MAX(1, cvp->a - context);
- upb = MIN(len[0], context_vec_ptr->b + context);
+ upb = MIN(diff_len[0], context_vec_ptr->b + context);
lowc = MAX(1, cvp->c - context);
- upd = MIN(len[1], context_vec_ptr->d + context);
+ upd = MIN(diff_len[1], context_vec_ptr->d + context);
fputs("@@ -", stdout);
uni_range(lowa, upb);
diff --git a/usr.bin/cvs/entries.c b/usr.bin/cvs/entries.c
index 8a989e8abfe..abd983ce057 100644
--- a/usr.bin/cvs/entries.c
+++ b/usr.bin/cvs/entries.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: entries.c,v 1.29 2005/05/19 21:45:45 jfb Exp $ */
+/* $OpenBSD: entries.c,v 1.30 2005/05/24 04:12:25 jfb Exp $ */
/*
* Copyright (c) 2004 Jean-Francois Brousseau <jfb@openbsd.org>
* All rights reserved.
@@ -382,7 +382,6 @@ cvs_ent_parse(const char *entry)
entp->ce_opts = fields[4];
entp->ce_tag = fields[5];
-
return (entp);
}
diff --git a/usr.bin/cvs/file.c b/usr.bin/cvs/file.c
index de3cbac2dc5..ae5d78294dd 100644
--- a/usr.bin/cvs/file.c
+++ b/usr.bin/cvs/file.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: file.c,v 1.76 2005/05/22 17:47:53 joris Exp $ */
+/* $OpenBSD: file.c,v 1.77 2005/05/24 04:12:25 jfb Exp $ */
/*
* Copyright (c) 2004 Jean-Francois Brousseau <jfb@openbsd.org>
* All rights reserved.
@@ -503,7 +503,7 @@ char*
cvs_file_getpath(CVSFILE *file, char *buf, size_t len)
{
u_int i;
- char *fp, *namevec[CVS_FILE_MAXDEPTH];
+ const char *fp, *namevec[CVS_FILE_MAXDEPTH];
CVSFILE *top;
buf[0] = '\0';
@@ -657,10 +657,6 @@ cvs_file_getdir(CVSFILE *cf, int flags, char *path, int (*cb)(CVSFILE *, void *)
}
while ((ent = readdir(dirp)) != NULL) {
- if (!strcmp(ent->d_name, ".") ||
- !strcmp(ent->d_name, ".."))
- continue;
-
if ((flags & CF_IGNORE) && cvs_file_chkign(ent->d_name))
continue;
@@ -838,6 +834,8 @@ cvs_file_free(CVSFILE *cf)
} else {
if (cf->cf_tag != NULL)
cvs_strfree(cf->cf_tag);
+ if (cf->cf_opts != NULL)
+ cvs_strfree(cf->cf_opts);
}
free(cf);
@@ -1047,11 +1045,21 @@ cvs_file_lget(const char *path, int flags, CVSFILE *parent, struct cvs_ent *ent)
cfp->cf_lrev = ent->ce_rev;
ent->ce_rev = NULL;
- if ((ent->ce_type == CVS_ENT_REG) &&
- (ent->ce_tag != NULL)) {
- if ((cfp->cf_tag = cvs_strdup(ent->ce_tag)) == NULL) {
- cvs_file_free(cfp);
- return (NULL);
+ if (ent->ce_type == CVS_ENT_FILE) {
+ if (ent->ce_tag[0] != '\0') {
+ cfp->cf_tag = cvs_strdup(ent->ce_tag);
+ if (cfp->cf_tag == NULL) {
+ cvs_file_free(cfp);
+ return (NULL);
+ }
+ }
+
+ if (ent->ce_opts[0] != '\0') {
+ cfp->cf_opts = cvs_strdup(ent->ce_opts);
+ if (cfp->cf_opts == NULL) {
+ cvs_file_free(cfp);
+ return (NULL);
+ }
}
}
}
diff --git a/usr.bin/cvs/file.h b/usr.bin/cvs/file.h
index f610ca3c93d..7e2a3d199c0 100644
--- a/usr.bin/cvs/file.h
+++ b/usr.bin/cvs/file.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: file.h,v 1.19 2005/05/20 05:13:44 joris Exp $ */
+/* $OpenBSD: file.h,v 1.20 2005/05/24 04:12:25 jfb Exp $ */
/*
* Copyright (c) 2004 Jean-Francois Brousseau <jfb@openbsd.org>
* All rights reserved.
@@ -75,7 +75,7 @@ SIMPLEQ_HEAD(cvs_flist, cvs_file);
typedef struct cvs_file {
struct cvs_file *cf_parent; /* parent directory (NULL if none) */
- char *cf_name;
+ const char *cf_name;
mode_t cf_mode;
u_int8_t cf_cvstat; /* cvs status of the file */
u_int8_t cf_type; /* uses values from dirent.h */
@@ -102,6 +102,7 @@ typedef struct cvs_file {
#define cf_mtime cf_td.cf_reg.cd_mtime
#define cf_lrev cf_td.cf_reg.cd_lrev
#define cf_tag cf_td.cf_reg.cd_tag
+#define cf_opts cf_td.cf_reg.cd_opts
/* only valid for directories */
#define cf_files cf_td.cf_dir.cd_files
@@ -133,10 +134,15 @@ CVSFILE* cvs_file_get (const char *, int, int (*)(CVSFILE *, void *), void *
CVSFILE* cvs_file_getspec (char **, int, int, int (*)(CVSFILE *, void *), void *);
CVSFILE* cvs_file_create (CVSFILE *, const char *, u_int, mode_t);
CVSFILE* cvs_file_copy (CVSFILE *);
-CVSFILE* cvs_file_find (CVSFILE *, const char *);
int cvs_file_attach (CVSFILE *, CVSFILE *);
-char* cvs_file_getpath (CVSFILE *, char *, size_t);
int cvs_file_examine (CVSFILE *, int (*)(CVSFILE *, void *), void *);
+
+int cvs_file_init (void);
+int cvs_file_ignore (const char *);
+int cvs_file_chkign (const char *);
+CVSFILE* cvs_file_load (const char *, int);
+CVSFILE* cvs_file_find (CVSFILE *, const char *);
+char* cvs_file_getpath (CVSFILE *, char *, size_t);
void cvs_file_free (CVSFILE *);
diff --git a/usr.bin/cvs/getlog.c b/usr.bin/cvs/getlog.c
index 39c2ff9bcba..e3600639611 100644
--- a/usr.bin/cvs/getlog.c
+++ b/usr.bin/cvs/getlog.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: getlog.c,v 1.28 2005/05/20 20:00:53 joris Exp $ */
+/* $OpenBSD: getlog.c,v 1.29 2005/05/24 04:12:25 jfb Exp $ */
/*
* Copyright (c) 2004 Jean-Francois Brousseau <jfb@openbsd.org>
* All rights reserved.
@@ -47,18 +47,43 @@
#define CVS_GETLOG_REVEND \
"============================================================================="
-static int cvs_getlog_remote (CVSFILE *, void *);
-static int cvs_getlog_local (CVSFILE *, void *);
-static int cvs_getlog_options(char *, int, char **, int *);
+static int cvs_getlog_remote (CVSFILE *, void *);
+static int cvs_getlog_local (CVSFILE *, void *);
+static int cvs_getlog_options(struct cvs_cmd *, int, char **, int *);
static int cvs_getlog_sendflags(struct cvsroot *);
-struct cvs_cmd_info cvs_getlog = {
+struct cvs_cmd cvs_cmd_log = {
+ CVS_OP_LOG, CVS_REQ_LOG, "log",
+ { "lo" },
+ "Print out history information for files",
+ "[-bhlNRt] [-d dates] [-r revisions] [-s states] [-w logins]",
+ "d:hlRr:",
+ NULL,
+ CF_RECURSE,
+ cvs_getlog_options,
+ NULL,
+ cvs_getlog_remote,
+ cvs_getlog_local,
+ NULL,
+ NULL,
+ CVS_CMD_SENDDIR | CVS_CMD_ALLOWSPEC | CVS_CMD_SENDARGS2
+};
+
+
+struct cvs_cmd cvs_cmd_rlog = {
+ CVS_OP_LOG, CVS_REQ_LOG, "log",
+ { "lo" },
+ "Print out history information for files",
+ "[-bhlNRt] [-d dates] [-r revisions] [-s states] [-w logins]",
+ "d:hlRr:",
+ NULL,
+ CF_RECURSE,
cvs_getlog_options,
cvs_getlog_sendflags,
cvs_getlog_remote,
- NULL, NULL,
- CF_IGNORE | CF_RECURSE,
- CVS_REQ_LOG,
+ cvs_getlog_local,
+ NULL,
+ NULL,
CVS_CMD_SENDDIR | CVS_CMD_ALLOWSPEC | CVS_CMD_SENDARGS2
};
@@ -68,11 +93,11 @@ static int log_lhonly = 0;
static int log_notags = 0;
static int
-cvs_getlog_options(char *opt, int argc, char **argv, int *arg)
+cvs_getlog_options(struct cvs_cmd *cmd, int argc, char **argv, int *arg)
{
int ch;
- while ((ch = getopt(argc, argv, opt)) != -1) {
+ while ((ch = getopt(argc, argv, cmd->cmd_opts)) != -1) {
switch (ch) {
case 'b':
break;
@@ -82,7 +107,7 @@ cvs_getlog_options(char *opt, int argc, char **argv, int *arg)
log_honly = 1;
break;
case 'l':
- cvs_getlog.file_flags &= ~CF_RECURSE;
+ cmd->file_flags &= ~CF_RECURSE;
break;
case 'N':
log_notags = 1;
diff --git a/usr.bin/cvs/history.c b/usr.bin/cvs/history.c
index 39ce1338838..87c7df6985c 100644
--- a/usr.bin/cvs/history.c
+++ b/usr.bin/cvs/history.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: history.c,v 1.13 2005/04/12 14:58:40 joris Exp $ */
+/* $OpenBSD: history.c,v 1.14 2005/05/24 04:12:25 jfb Exp $ */
/*
* Copyright (c) 2004 Jean-Francois Brousseau <jfb@openbsd.org>
* All rights reserved.
@@ -53,20 +53,26 @@
#define CVS_HF_EXCL (CVS_HF_C|CVS_HF_E|CVS_HF_M|CVS_HF_O|CVS_HF_T|CVS_HF_X)
-static void cvs_history_print (struct cvs_hent *);
-int cvs_history_options(char *, int, char **, int *);
-int cvs_history_sendflags(struct cvsroot *);
+static int cvs_history_init (struct cvs_cmd *, int, char **, int *);
+static void cvs_history_print (struct cvs_hent *);
+static int cvs_history_pre_exec (struct cvsroot *);
extern char *__progname;
-struct cvs_cmd_info cvs_history = {
- cvs_history_options,
- cvs_history_sendflags,
+struct cvs_cmd cvs_cmd_history = {
+ CVS_OP_HISTORY, CVS_REQ_HISTORY, "history",
+ { "hi", "his" },
+ "Show repository access history",
+ "",
+ "acelm:oTt:u:wx:z:",
+ NULL,
+ 0,
+ cvs_history_init,
+ cvs_history_pre_exec,
+ NULL,
NULL,
NULL,
NULL,
- 0,
- CVS_REQ_HISTORY,
CVS_CMD_SENDDIR
};
@@ -78,12 +84,12 @@ static u_int nbmod = 0;
static u_int rep = 0;
static char *modules[CVS_HISTORY_MAXMOD];
-int
-cvs_history_options(char *opt, int argc, char **argv, int *arg)
+static int
+cvs_history_init(struct cvs_cmd *cmd, int argc, char **argv, int *arg)
{
int ch;
- while ((ch = getopt(argc, argv, opt)) != -1) {
+ while ((ch = getopt(argc, argv, cmd->cmd_opts)) != -1) {
switch (ch) {
case 'a':
flags |= CVS_HF_A;
@@ -147,8 +153,8 @@ cvs_history_options(char *opt, int argc, char **argv, int *arg)
return (0);
}
-int
-cvs_history_sendflags(struct cvsroot *root)
+static int
+cvs_history_pre_exec(struct cvsroot *root)
{
if ((flags & CVS_HF_C) && (cvs_sendarg(root, "-c", 0) < 0))
diff --git a/usr.bin/cvs/import.c b/usr.bin/cvs/import.c
index 1b576804817..6fd94a8cdbc 100644
--- a/usr.bin/cvs/import.c
+++ b/usr.bin/cvs/import.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: import.c,v 1.14 2005/05/20 20:00:53 joris Exp $ */
+/* $OpenBSD: import.c,v 1.15 2005/05/24 04:12:25 jfb Exp $ */
/*
* Copyright (c) 2004 Joris Vink <joris@openbsd.org>
* All rights reserved.
@@ -25,10 +25,8 @@
*/
#include <sys/types.h>
-#include <sys/queue.h>
+#include <sys/stat.h>
-#include <err.h>
-#include <dirent.h>
#include <errno.h>
#include <stdio.h>
#include <stdlib.h>
@@ -43,31 +41,40 @@
#define CVS_IMPORT_DEFBRANCH "1.1.1"
-int cvs_import_options(char *, int, char **, int *);
-int cvs_import_sendflags(struct cvsroot *);
-int cvs_import_file(CVSFILE *, void *);
+static int cvs_import_init (struct cvs_cmd *, int, char **, int *);
+static int cvs_import_pre_exec (struct cvsroot *);
+static int cvs_import_remote (CVSFILE *, void *);
+static int cvs_import_local (CVSFILE *, void *);
static RCSNUM *bnum;
static char *branch, *module, *vendor, *release;
-struct cvs_cmd_info cvs_import = {
- cvs_import_options,
- cvs_import_sendflags,
- cvs_import_file,
- NULL, NULL,
+struct cvs_cmd cvs_cmd_import = {
+ CVS_OP_IMPORT, CVS_REQ_IMPORT, "import",
+ { "im", "imp" },
+ "Import sources into CVS, using vendor branches",
+ "[-d] [-b branch] [-I ign] [-k subst] [-m msg] repository "
+ "vendor-tag release-tags ...",
+ "b:dI:k:m:",
+ NULL,
CF_RECURSE | CF_IGNORE | CF_NOSYMS,
- CVS_REQ_IMPORT,
+ cvs_import_init,
+ cvs_import_pre_exec,
+ cvs_import_remote,
+ cvs_import_local,
+ NULL,
+ NULL,
CVS_CMD_SENDDIR
};
-int
-cvs_import_options(char *opt, int argc, char **argv, int *arg)
+static int
+cvs_import_init(struct cvs_cmd *cmd, int argc, char **argv, int *arg)
{
int ch;
branch = CVS_IMPORT_DEFBRANCH;
- while ((ch = getopt(argc, argv, opt)) != -1) {
+ while ((ch = getopt(argc, argv, cmd->cmd_opts)) != -1) {
switch (ch) {
case 'b':
branch = optarg;
@@ -103,92 +110,155 @@ cvs_import_options(char *opt, int argc, char **argv, int *arg)
argc -= optind;
argv += optind;
- *arg = optind;
- if (argc > 4)
+ if (argc != 3)
return (CVS_EX_USAGE);
module = argv[0];
vendor = argv[1];
release = argv[2];
+ *arg = optind + 3;
+
+ cvs_msg = "test\n";
+#if 0
if ((cvs_msg == NULL) &&
(cvs_msg = cvs_logmsg_get(NULL, NULL, NULL, NULL)) == NULL)
return (CVS_EX_DATA);
+#endif
return (0);
}
-int
-cvs_import_sendflags(struct cvsroot *root)
+static int
+cvs_import_pre_exec(struct cvsroot *root)
{
- if ((cvs_sendarg(root, "-b", 0) < 0) ||
- (cvs_sendarg(root, branch, 0) < 0) ||
- (cvs_logmsg_send(root, cvs_msg) < 0) ||
- (cvs_sendarg(root, module, 0) < 0) ||
- (cvs_sendarg(root, vendor, 0) < 0) ||
- (cvs_sendarg(root, release, 0) < 0))
- return (CVS_EX_PROTO);
+ char repodir[MAXPATHLEN];
+
+ if (root->cr_method == CVS_METHOD_LOCAL) {
+ snprintf(repodir, sizeof(repodir), "%s/%s", root->cr_dir,
+ module);
+ mkdir(repodir, 0700);
+ } else {
+ if ((cvs_sendarg(root, "-b", 0) < 0) ||
+ (cvs_sendarg(root, branch, 0) < 0) ||
+ (cvs_logmsg_send(root, cvs_msg) < 0) ||
+ (cvs_sendarg(root, module, 0) < 0) ||
+ (cvs_sendarg(root, vendor, 0) < 0) ||
+ (cvs_sendarg(root, release, 0) < 0))
+ return (CVS_EX_PROTO);
+ }
return (0);
}
/*
- * cvs_import_file()
+ * cvs_import_remote()
*
* Perform the import of a single file or directory.
*/
-int
-cvs_import_file(CVSFILE *cfp, void *arg)
+static int
+cvs_import_remote(CVSFILE *cf, void *arg)
{
- int l;
+ int len;
struct cvsroot *root;
char fpath[MAXPATHLEN], repodir[MAXPATHLEN];
char repo[MAXPATHLEN];
- root = CVS_DIR_ROOT(cfp);
- l = snprintf(repo, sizeof(repo), "%s/%s", root->cr_dir, module);
- if (l == -1 || l >= (int)sizeof(repo)) {
+ root = CVS_DIR_ROOT(cf);
+ len = snprintf(repo, sizeof(repo), "%s/%s", root->cr_dir, module);
+ if (len == -1 || len >= (int)sizeof(repo)) {
errno = ENAMETOOLONG;
cvs_log(LP_ERRNO, "%s", repo);
return (CVS_EX_DATA);
}
- cvs_file_getpath(cfp, fpath, sizeof(fpath));
- printf("Importing %s\n", fpath);
+ cvs_file_getpath(cf, fpath, sizeof(fpath));
- if (cfp->cf_type == DT_DIR) {
- if (!strcmp(CVS_FILE_NAME(cfp), "."))
+ if (cf->cf_type == DT_DIR) {
+ if (!strcmp(cf->cf_name, "."))
strlcpy(repodir, repo, sizeof(repodir));
else {
- l = snprintf(repodir, sizeof(repodir), "%s/%s",
+ len = snprintf(repodir, sizeof(repodir), "%s/%s",
repo, fpath);
- if (l == -1 || l >= (int)sizeof(repodir)) {
+ if (len == -1 || len >= (int)sizeof(repodir)) {
errno = ENAMETOOLONG;
cvs_log(LP_ERRNO, "%s", repodir);
return (CVS_EX_DATA);
}
}
- if (root->cr_method != CVS_METHOD_LOCAL) {
- if (cvs_sendreq(root, CVS_REQ_DIRECTORY, fpath) < 0)
- return (CVS_EX_PROTO);
- if (cvs_sendln(root, repodir) < 0)
- return (CVS_EX_PROTO);
- } else {
- /* create the directory */
+
+ if (cvs_sendreq(root, CVS_REQ_DIRECTORY, fpath) < 0)
+ return (CVS_EX_PROTO);
+ if (cvs_sendln(root, repodir) < 0)
+ return (CVS_EX_PROTO);
+ return (0);
+ }
+
+ if (cvs_sendreq(root, CVS_REQ_MODIFIED, cf->cf_name) < 0)
+ return (CVS_EX_PROTO);
+ if (cvs_sendfile(root, fpath) < 0)
+ return (CVS_EX_PROTO);
+
+ return (0);
+}
+
+
+/*
+ * cvs_import_local()
+ *
+ */
+static int
+cvs_import_local(CVSFILE *cf, void *arg)
+{
+ int len;
+ struct cvsroot *root;
+ char fpath[MAXPATHLEN], rpath[MAXPATHLEN], repo[MAXPATHLEN];
+ RCSFILE *rf;
+
+ root = CVS_DIR_ROOT(cf);
+ len = snprintf(repo, sizeof(repo), "%s/%s", root->cr_dir, module);
+ if (len == -1 || len >= (int)sizeof(repo)) {
+ errno = ENAMETOOLONG;
+ cvs_log(LP_ERRNO, "%s", repo);
+ return (CVS_EX_DATA);
+ }
+
+ cvs_file_getpath(cf, fpath, sizeof(fpath));
+
+ if (cf->cf_type == DT_DIR) {
+ if (!strcmp(cf->cf_name, "."))
+ strlcpy(rpath, repo, sizeof(rpath));
+ else {
+ len = snprintf(rpath, sizeof(rpath), "%s/%s",
+ repo, fpath);
+ if (len == -1 || len >= (int)sizeof(rpath)) {
+ errno = ENAMETOOLONG;
+ cvs_log(LP_ERRNO, "%s", rpath);
+ return (CVS_EX_DATA);
+ }
+
+ cvs_printf("Importing %s\n", rpath);
+ if (mkdir(rpath, 0700) == -1) {
+ cvs_log(LP_ERRNO, "failed to create %s",
+ rpath);
+ }
}
return (0);
}
- if (root->cr_method != CVS_METHOD_LOCAL) {
- if (cvs_sendreq(root, CVS_REQ_MODIFIED, CVS_FILE_NAME(cfp)) < 0)
- return (CVS_EX_PROTO);
- if (cvs_sendfile(root, fpath) < 0)
- return (CVS_EX_PROTO);
- } else {
- /* local import */
+ snprintf(rpath, sizeof(rpath), "%s/%s%s",
+ repo, fpath, RCS_FILE_EXT);
+
+ printf("importing file in %s\n", rpath);
+ cvs_printf("N %s\n", fpath);
+
+ rf = rcs_open(rpath, RCS_RDWR|RCS_CREATE);
+ if (rf == NULL) {
}
- return (0);
+ rcs_close(rf);
+
+ return (CVS_EX_OK);
}
diff --git a/usr.bin/cvs/init.c b/usr.bin/cvs/init.c
index 3a9ba588751..64cc876f29c 100644
--- a/usr.bin/cvs/init.c
+++ b/usr.bin/cvs/init.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: init.c,v 1.15 2005/04/16 20:05:05 xsa Exp $ */
+/* $OpenBSD: init.c,v 1.16 2005/05/24 04:12:25 jfb Exp $ */
/*
* Copyright (c) 2004 Jean-Francois Brousseau <jfb@openbsd.org>
* All rights reserved.
@@ -50,7 +50,6 @@ struct cvsroot_file {
mode_t cf_mode;
} cvsroot_files[] = {
{ CVS_PATH_ROOT, CFT_DIR, (S_IRWXU|S_IRGRP|S_IXGRP|S_IROTH|S_IXOTH) },
-
{ CVS_PATH_COMMITINFO, CFT_FILE, (S_IRUSR|S_IWUSR|S_IRGRP|S_IROTH) },
{ CVS_PATH_CONFIG, CFT_FILE, (S_IRUSR|S_IWUSR|S_IRGRP|S_IROTH) },
{ CVS_PATH_CVSIGNORE, CFT_FILE, (S_IRUSR|S_IWUSR|S_IRGRP|S_IROTH) },
@@ -67,11 +66,20 @@ struct cvsroot_file {
int cvs_init_local(struct cvsroot *);
-struct cvs_cmd_info cvs_init = {
+struct cvs_cmd cvs_cmd_init = {
+ CVS_OP_INIT, CVS_REQ_INIT, "init",
+ { },
+ "Create a CVS repository if it doesn't exist",
+ "",
+ "",
NULL,
- NULL, NULL, NULL, NULL,
0,
- CVS_REQ_INIT,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
0
};
diff --git a/usr.bin/cvs/release.c b/usr.bin/cvs/release.c
index ce6ee75b0ef..d1a39c034f8 100644
--- a/usr.bin/cvs/release.c
+++ b/usr.bin/cvs/release.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: release.c,v 1.6 2005/05/20 20:00:53 joris Exp $ */
+/* $OpenBSD: release.c,v 1.7 2005/05/24 04:12:25 jfb Exp $ */
/*
* Copyright (c) 2005 Xavier Santolaria <xsa@openbsd.org>
* All rights reserved.
@@ -42,29 +42,36 @@
extern char *__progname;
-static int cvs_release_options(char *, int, char **, int *);
-static int cvs_release_sendflags(struct cvsroot *);
-static int cvs_release_yesno(void);
-static int cvs_release_dir(CVSFILE *, void *);
-
-struct cvs_cmd_info cvs_release = {
- cvs_release_options,
- cvs_release_sendflags,
+static int cvs_release_init (struct cvs_cmd *, int, char **, int *);
+static int cvs_release_pre_exec (struct cvsroot *);
+static int cvs_release_yesno (void);
+static int cvs_release_dir (CVSFILE *, void *);
+
+struct cvs_cmd cvs_cmd_release = {
+ CVS_OP_RELEASE, CVS_REQ_RELEASE, "release",
+ { },
+ "Release",
+ "[-d]",
+ "d",
+ NULL,
+ 0,
+ cvs_release_init,
+ cvs_release_pre_exec,
+ cvs_release_dir,
cvs_release_dir,
- NULL, NULL,
- CF_IGNORE | CF_KNOWN | CF_NOFILES | CF_RECURSE,
- CVS_REQ_RELEASE,
+ NULL,
+ NULL,
CVS_CMD_SENDDIR | CVS_CMD_SENDARGS2 | CVS_CMD_ALLOWSPEC
};
static int dflag; /* -d option */
static int
-cvs_release_options(char *opt, int argc, char **argv, int *arg)
+cvs_release_init(struct cvs_cmd *cmd, int argc, char **argv, int *arg)
{
int ch;
- while ((ch = getopt(argc, argv, opt)) != -1) {
+ while ((ch = getopt(argc, argv, cmd->cmd_opts)) != -1) {
switch (ch) {
case 'd':
dflag = 1;
@@ -85,7 +92,7 @@ cvs_release_options(char *opt, int argc, char **argv, int *arg)
}
static int
-cvs_release_sendflags(struct cvsroot *root)
+cvs_release_pre_exec(struct cvsroot *root)
{
if (dflag && cvs_sendarg(root, "-d", 0) < 0)
return (CVS_EX_PROTO);
diff --git a/usr.bin/cvs/remove.c b/usr.bin/cvs/remove.c
index 44090d881e6..08c0c3c776a 100644
--- a/usr.bin/cvs/remove.c
+++ b/usr.bin/cvs/remove.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: remove.c,v 1.15 2005/05/20 20:00:53 joris Exp $ */
+/* $OpenBSD: remove.c,v 1.16 2005/05/24 04:12:25 jfb Exp $ */
/*
* Copyright (c) 2004 Jean-Francois Brousseau <jfb@openbsd.org>
* Copyright (c) 2004 Xavier Santolaria <xsa@openbsd.org>
@@ -42,36 +42,43 @@
extern char *__progname;
-static int cvs_remove_file(CVSFILE *, void *);
-static int cvs_remove_options(char *, int, char **, int *);
+static int cvs_remove_init (struct cvs_cmd *, int, char **, int *);
+static int cvs_remove_file (CVSFILE *, void *);
static int force_remove = 0; /* -f option */
-struct cvs_cmd_info cvs_remove = {
- cvs_remove_options,
+struct cvs_cmd cvs_cmd_remove = {
+ CVS_OP_REMOVE, CVS_REQ_REMOVE, "remove",
+ { "rm", "delete" },
+ "Remove an entry from the repository",
+ "[-flR] [file ...]",
+ "flR",
NULL,
- cvs_remove_file,
- NULL, NULL,
CF_IGNORE | CF_RECURSE,
- CVS_REQ_REMOVE,
+ cvs_remove_init,
+ NULL,
+ cvs_remove_file,
+ cvs_remove_file,
+ NULL,
+ NULL,
CVS_CMD_SENDDIR | CVS_CMD_SENDARGS2 | CVS_CMD_ALLOWSPEC
};
static int
-cvs_remove_options(char *opt, int argc, char **argv, int *arg)
+cvs_remove_init(struct cvs_cmd *cmd, int argc, char **argv, int *arg)
{
int ch;
- while ((ch = getopt(argc, argv, opt)) != -1) {
+ while ((ch = getopt(argc, argv, cmd->cmd_opts)) != -1) {
switch (ch) {
case 'f':
force_remove = 1;
break;
case 'l':
- cvs_remove.file_flags &= ~CF_RECURSE;
+ cmd->file_flags &= ~CF_RECURSE;
break;
case 'R':
- cvs_remove.file_flags |= CF_RECURSE;
+ cmd->file_flags |= CF_RECURSE;
break;
default:
return (CVS_EX_USAGE);
diff --git a/usr.bin/cvs/req.c b/usr.bin/cvs/req.c
index 367382a9440..d5074774665 100644
--- a/usr.bin/cvs/req.c
+++ b/usr.bin/cvs/req.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: req.c,v 1.14 2005/05/18 20:24:19 joris Exp $ */
+/* $OpenBSD: req.c,v 1.15 2005/05/24 04:12:25 jfb Exp $ */
/*
* Copyright (c) 2004 Jean-Francois Brousseau <jfb@openbsd.org>
* All rights reserved.
@@ -158,6 +158,8 @@ extern char cvs_server_tmpdir[MAXPATHLEN];
static char *cvs_req_args[CVS_PROTO_MAXARG];
static int cvs_req_nargs = 0;
+static CVSFILE *cvs_lastdir = NULL;
+
/*
* cvs_req_handle()
@@ -267,6 +269,7 @@ cvs_req_directory(int reqid, char *line)
{
int l;
char rdir[MAXPATHLEN];
+ CVSFILE *dirp;
if (cvs_getln(NULL, rdir, sizeof(rdir)) < 0)
return (-1);
@@ -308,10 +311,13 @@ static int
cvs_req_entry(int reqid, char *line)
{
struct cvs_ent *ent;
+ CVSFILE *cf;
if ((ent = cvs_ent_parse(line)) == NULL)
return (-1);
+ cf = cvs_file_create(NULL, ent->ce_name, DT_REG, 0644);
+
return (0);
}
@@ -541,26 +547,16 @@ static int
cvs_req_command(int reqid, char *line)
{
int ret;
+ struct cvs_cmd *cmdp;
- switch (reqid) {
- case CVS_REQ_VERSION:
- ret = cvs_sendresp(CVS_RESP_M, CVS_VERSION);
- break;
- case CVS_REQ_ADD:
- case CVS_REQ_ANNOTATE:
- case CVS_REQ_CO:
- case CVS_REQ_CI:
- case CVS_REQ_DIFF:
- case CVS_REQ_LOG:
- case CVS_REQ_REMOVE:
- case CVS_REQ_STATUS:
- case CVS_REQ_TAG:
- default:
- cvs_sendresp(CVS_RESP_E, "command not yet implemented");
+ cmdp = cvs_findcmdbyreq(reqid);
+ if (cmdp == NULL) {
cvs_sendresp(CVS_RESP_ERROR, NULL);
- return (0);
+ return (-1);
}
+ cvs_startcmd(cmdp, cvs_req_nargs, cvs_req_args);
+
if (ret == 0)
ret = cvs_sendresp(CVS_RESP_OK, NULL);
diff --git a/usr.bin/cvs/resp.c b/usr.bin/cvs/resp.c
index 86199ddd4de..d18e85bdb4d 100644
--- a/usr.bin/cvs/resp.c
+++ b/usr.bin/cvs/resp.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: resp.c,v 1.36 2005/05/24 03:06:16 jfb Exp $ */
+/* $OpenBSD: resp.c,v 1.37 2005/05/24 04:12:25 jfb Exp $ */
/*
* Copyright (c) 2004 Jean-Francois Brousseau <jfb@openbsd.org>
* All rights reserved.
@@ -50,10 +50,10 @@
#define STRIP_SLASH(p) \
do { \
- size_t len; \
- len = strlen(p); \
- while ((len > 0) && (p[len - 1] == '/')) \
- p[--len] = '\0'; \
+ size_t _slen; \
+ _slen = strlen(p); \
+ while ((_slen > 0) && (p[_slen - 1] == '/')) \
+ p[--_slen] = '\0'; \
} while (0)
diff --git a/usr.bin/cvs/server.c b/usr.bin/cvs/server.c
index 1ac0de6f16e..7b38cbbbbf1 100644
--- a/usr.bin/cvs/server.c
+++ b/usr.bin/cvs/server.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: server.c,v 1.16 2005/05/20 20:00:53 joris Exp $ */
+/* $OpenBSD: server.c,v 1.17 2005/05/24 04:12:25 jfb Exp $ */
/*
* Copyright (c) 2004 Jean-Francois Brousseau <jfb@openbsd.org>
* All rights reserved.
@@ -43,10 +43,19 @@
char **cvs_args;
u_int cvs_nbarg = 0;
u_int cvs_utf8ok = 0;
-u_int cvs_case = 0;
-
-struct cvs_cmd_info cmd_server = {
- NULL, NULL, NULL, NULL, NULL, 0, 0, 0 };
+u_int cvs_case = 0;
+
+struct cvs_cmd cvs_cmd_server = {
+ CVS_OP_SERVER, 0, "server",
+ { },
+ "Server mode",
+ "",
+ "",
+ NULL,
+ 0,
+ NULL, NULL, NULL, NULL, NULL, NULL,
+ 0
+};
char cvs_server_tmpdir[MAXPATHLEN];
diff --git a/usr.bin/cvs/status.c b/usr.bin/cvs/status.c
index 6c0cf14a37b..d5de376d334 100644
--- a/usr.bin/cvs/status.c
+++ b/usr.bin/cvs/status.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: status.c,v 1.21 2005/05/20 20:00:53 joris Exp $ */
+/* $OpenBSD: status.c,v 1.22 2005/05/24 04:12:25 jfb Exp $ */
/*
* Copyright (c) 2004 Jean-Francois Brousseau <jfb@openbsd.org>
* All rights reserved.
@@ -55,35 +55,42 @@ const char *cvs_statstr[] = {
};
-int cvs_status_remote (CVSFILE *, void *);
-int cvs_status_local (CVSFILE *, void *);
-int cvs_status_options (char *, int, char **, int *);
-int cvs_status_sendflags (struct cvsroot *);
+static int cvs_status_init (struct cvs_cmd *, int, char **, int *);
+static int cvs_status_remote (CVSFILE *, void *);
+static int cvs_status_local (CVSFILE *, void *);
+static int cvs_status_pre_exec (struct cvsroot *);
-struct cvs_cmd_info cvs_status = {
- cvs_status_options,
- cvs_status_sendflags,
- cvs_status_remote,
- NULL, NULL,
+struct cvs_cmd cvs_cmd_status = {
+ CVS_OP_STATUS, CVS_REQ_STATUS, "status",
+ { "st", "stat" },
+ "Display status information on checked out files",
+ "[-lRv]",
+ "lRv",
+ NULL,
CF_SORT | CF_IGNORE | CF_RECURSE,
- CVS_REQ_STATUS,
+ cvs_status_init,
+ cvs_status_pre_exec,
+ cvs_status_remote,
+ cvs_status_local,
+ NULL,
+ NULL,
CVS_CMD_ALLOWSPEC | CVS_CMD_SENDDIR | CVS_CMD_SENDARGS2
};
static int verbose = 0;
-int
-cvs_status_options(char *opt, int argc, char **argv, int *arg)
+static int
+cvs_status_init(struct cvs_cmd *cmd, int argc, char **argv, int *arg)
{
int ch;
- while ((ch = getopt(argc, argv, opt)) != -1) {
+ while ((ch = getopt(argc, argv, cmd->cmd_opts)) != -1) {
switch (ch) {
case 'l':
- cvs_status.file_flags &= ~CF_RECURSE;
+ cmd->file_flags &= ~CF_RECURSE;
break;
case 'R':
- cvs_status.file_flags |= CF_RECURSE;
+ cmd->file_flags |= CF_RECURSE;
break;
case 'v':
verbose = 1;
@@ -97,8 +104,8 @@ cvs_status_options(char *opt, int argc, char **argv, int *arg)
return (0);
}
-int
-cvs_status_sendflags(struct cvsroot *root)
+static int
+cvs_status_pre_exec(struct cvsroot *root)
{
if (verbose && (cvs_sendarg(root, "-v", 0) < 0))
return (CVS_EX_PROTO);
@@ -110,7 +117,7 @@ cvs_status_sendflags(struct cvsroot *root)
*
* Get the status of a single file.
*/
-int
+static int
cvs_status_remote(CVSFILE *cfp, void *arg)
{
int ret;
@@ -163,30 +170,32 @@ cvs_status_remote(CVSFILE *cfp, void *arg)
return (ret);
}
-int
-cvs_status_local(CVSFILE *cfp, void *arg)
+static int
+cvs_status_local(CVSFILE *cf, void *arg)
{
- int l;
+ int len;
+ size_t sz;
char *repo, buf[MAXNAMLEN], fpath[MAXPATHLEN], rcspath[MAXPATHLEN];
+ char datebuf[26];
RCSFILE *rf;
struct cvsroot *root;
- if (cfp->cf_type == DT_DIR)
+ if (cf->cf_type == DT_DIR)
return (0);
- root = CVS_DIR_ROOT(cfp);
- repo = CVS_DIR_REPO(cfp);
+ root = CVS_DIR_ROOT(cf);
+ repo = CVS_DIR_REPO(cf);
- cvs_file_getpath(cfp, fpath, sizeof(fpath));
+ cvs_file_getpath(cf, fpath, sizeof(fpath));
- if (cfp->cf_cvstat == CVS_FST_UNKNOWN) {
+ if (cf->cf_cvstat == CVS_FST_UNKNOWN) {
cvs_log(LP_WARN, "I know nothing about %s", fpath);
return (0);
}
- l = snprintf(rcspath, sizeof(rcspath), "%s/%s/%s%s",
- root->cr_dir, repo, CVS_FILE_NAME(cfp), RCS_FILE_EXT);
- if (l == -1 || l >= (int)sizeof(rcspath)) {
+ len = snprintf(rcspath, sizeof(rcspath), "%s/%s/%s%s",
+ root->cr_dir, repo, CVS_FILE_NAME(cf), RCS_FILE_EXT);
+ if (len == -1 || len >= (int)sizeof(rcspath)) {
errno = ENAMETOOLONG;
cvs_log(LP_ERRNO, "%s", rcspath);
return (CVS_EX_DATA);
@@ -197,28 +206,32 @@ cvs_status_local(CVSFILE *cfp, void *arg)
return (CVS_EX_DATA);
buf[0] = '\0';
- if (cfp->cf_cvstat == CVS_FST_LOST)
+ if (cf->cf_cvstat == CVS_FST_LOST)
strlcpy(buf, "No file ", sizeof(buf));
- strlcat(buf, CVS_FILE_NAME(cfp), sizeof(buf));
+ strlcat(buf, cf->cf_name, sizeof(buf));
cvs_printf(CVS_STATUS_SEP "\nFile: %-18sStatus: %s\n\n",
- buf, cvs_statstr[cfp->cf_cvstat]);
+ buf, cvs_statstr[cf->cf_cvstat]);
- if (cfp->cf_cvstat == CVS_FST_UNKNOWN) {
- snprintf(buf, sizeof(buf), "No entry for %s",
- CVS_FILE_NAME(cfp));
+ if (cf->cf_cvstat == CVS_FST_UNKNOWN) {
+ snprintf(buf, sizeof(buf), "No entry for %s", cf->cf_name);
} else {
+ ctime_r(&(cf->cf_mtime), datebuf);
+ sz = strlen(datebuf);
+ if ((sz > 0) && (datebuf[sz - 1] == '\n'))
+ datebuf[--sz] = '\0';
snprintf(buf, sizeof(buf), "%s %s",
- rcsnum_tostr(cfp->cf_lrev, buf, sizeof(buf)),
- "date here");
+ rcsnum_tostr(cf->cf_lrev, buf, sizeof(buf)), datebuf);
}
cvs_printf(" Working revision: %s\n", buf);
rcsnum_tostr(rf->rf_head, buf, sizeof(buf));
cvs_printf(" Repository revision: %s %s\n", buf, rcspath);
- cvs_printf(" Sticky Tag: %s\n", "(none)");
+ cvs_printf(" Sticky Tag: %s\n",
+ cf->cf_tag == NULL ? "(none)" : cf->cf_tag);
cvs_printf(" Sticky Date: %s\n", "(none)");
- cvs_printf(" Sticky Options: %s\n", "(none)");
+ cvs_printf(" Sticky Options: %s\n",
+ cf->cf_opts == NULL ? "(none)" : cf->cf_opts);
rcs_close(rf);
diff --git a/usr.bin/cvs/tag.c b/usr.bin/cvs/tag.c
index 8c6eb5eb376..c0b0502d3b3 100644
--- a/usr.bin/cvs/tag.c
+++ b/usr.bin/cvs/tag.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: tag.c,v 1.16 2005/05/20 20:00:53 joris Exp $ */
+/* $OpenBSD: tag.c,v 1.17 2005/05/24 04:12:25 jfb Exp $ */
/*
* Copyright (c) 2004 Jean-Francois Brousseau <jfb@openbsd.org>
* Copyright (c) 2004 Joris Vink <joris@openbsd.org>
@@ -37,10 +37,10 @@
#include "proto.h"
-static int cvs_tag_local (CVSFILE *, void *);
-static int cvs_tag_remote (CVSFILE *, void *);
-static int cvs_tag_options (char *, int, char **, int *);
-static int cvs_tag_sendflags (struct cvsroot *);
+static int cvs_tag_init (struct cvs_cmd *, int, char **, int *);
+static int cvs_tag_local (CVSFILE *, void *);
+static int cvs_tag_remote (CVSFILE *, void *);
+static int cvs_tag_pre_exec (struct cvsroot *);
static char *tag_name = NULL;
static char *tag_date = NULL;
@@ -49,24 +49,49 @@ static int tag_branch = 0;
static int tag_delete = 0;
static int tag_forcehead = 0;
-struct cvs_cmd_info cvs_tag = {
- cvs_tag_options,
- cvs_tag_sendflags,
- cvs_tag_remote,
- NULL, NULL,
+struct cvs_cmd cvs_cmd_tag = {
+ CVS_OP_TAG, CVS_REQ_TAG, "tag",
+ { "ta", "freeze" },
+ "Add a symbolic tag to checked out version of files",
+ "[-bcdFflR] [-D date | -r rev] tagname ...",
+ "bcD:dFflRr:",
+ NULL,
CF_SORT | CF_IGNORE | CF_RECURSE,
- CVS_REQ_TAG,
+ cvs_tag_init,
+ cvs_tag_pre_exec,
+ cvs_tag_remote,
+ cvs_tag_local,
+ NULL,
+ NULL,
+ CVS_CMD_ALLOWSPEC | CVS_CMD_SENDDIR
+};
+
+
+struct cvs_cmd cvs_cmd_rtag = {
+ CVS_OP_RTAG, CVS_REQ_TAG, "rtag",
+ { },
+ "Add a symbolic tag to a module",
+ "",
+ "",
+ NULL,
+ CF_SORT | CF_IGNORE | CF_RECURSE,
+ cvs_tag_init,
+ cvs_tag_pre_exec,
+ cvs_tag_remote,
+ cvs_tag_local,
+ NULL,
+ NULL,
CVS_CMD_ALLOWSPEC | CVS_CMD_SENDDIR
};
static int
-cvs_tag_options(char *opt, int argc, char **argv, int *arg)
+cvs_tag_init(struct cvs_cmd *cmd, int argc, char **argv, int *arg)
{
int ch;
tag_date = tag_oldname = NULL;
- while ((ch = getopt(argc, argv, opt)) != -1) {
+ while ((ch = getopt(argc, argv, cmd->cmd_opts)) != -1) {
switch (ch) {
case 'b':
tag_branch = 1;
@@ -81,7 +106,10 @@ cvs_tag_options(char *opt, int argc, char **argv, int *arg)
tag_date = optarg;
break;
case 'l':
- cvs_tag.file_flags &= ~CF_RECURSE;
+ cmd->file_flags &= ~CF_RECURSE;
+ break;
+ case 'R':
+ cmd->file_flags |= CF_RECURSE;
break;
case 'r':
tag_oldname = optarg;
@@ -131,29 +159,31 @@ cvs_tag_options(char *opt, int argc, char **argv, int *arg)
}
static int
-cvs_tag_sendflags(struct cvsroot *root)
+cvs_tag_pre_exec(struct cvsroot *root)
{
- if (tag_branch && (cvs_sendarg(root, "-b", 0) < 0))
- return (CVS_EX_PROTO);
-
- if (tag_delete && (cvs_sendarg(root, "-d", 0) < 0))
- return (CVS_EX_PROTO);
+ if (root->cr_method != CVS_METHOD_LOCAL) {
+ if (tag_branch && (cvs_sendarg(root, "-b", 0) < 0))
+ return (CVS_EX_PROTO);
- if (tag_oldname) {
- if ((cvs_sendarg(root, "-r", 0) < 0) ||
- (cvs_sendarg(root, tag_oldname, 0) < 0))
+ if (tag_delete && (cvs_sendarg(root, "-d", 0) < 0))
return (CVS_EX_PROTO);
- }
- if (tag_date) {
- if ((cvs_sendarg(root, "-D", 0) < 0) ||
- (cvs_sendarg(root, tag_date, 0) < 0))
+ if (tag_oldname) {
+ if ((cvs_sendarg(root, "-r", 0) < 0) ||
+ (cvs_sendarg(root, tag_oldname, 0) < 0))
+ return (CVS_EX_PROTO);
+ }
+
+ if (tag_date) {
+ if ((cvs_sendarg(root, "-D", 0) < 0) ||
+ (cvs_sendarg(root, tag_date, 0) < 0))
+ return (CVS_EX_PROTO);
+ }
+
+ if (cvs_sendarg(root, tag_name, 0) < 0)
return (CVS_EX_PROTO);
}
- if (cvs_sendarg(root, tag_name, 0) < 0)
- return (CVS_EX_PROTO);
-
return (0);
}
@@ -216,6 +246,11 @@ cvs_tag_local(CVSFILE *cf, void *arg)
cvs_file_getpath(cf, fpath, sizeof(fpath));
+ if (cf->cf_type == DT_DIR) {
+ cvs_log(LP_INFO, "Tagging %s", fpath);
+ return (CVS_EX_OK);
+ }
+
if (cf->cf_cvstat == CVS_FST_UNKNOWN) {
cvs_log(LP_WARN, "I know nothing about %s", fpath);
return (0);
@@ -223,6 +258,7 @@ cvs_tag_local(CVSFILE *cf, void *arg)
repo = CVS_DIR_REPO(cf);
root = CVS_DIR_ROOT(cf);
+ tag_rev = cf->cf_lrev;
len = snprintf(rcspath, sizeof(rcspath), "%s/%s/%s%s",
root->cr_dir, repo, cf->cf_name, RCS_FILE_EXT);
@@ -244,6 +280,8 @@ cvs_tag_local(CVSFILE *cf, void *arg)
rcs_errstr(rcs_errno));
}
+ cvs_printf("T %s\n", fpath);
+
rcs_close(rf);
return (0);
}
diff --git a/usr.bin/cvs/update.c b/usr.bin/cvs/update.c
index 06138063ff1..922d96305ad 100644
--- a/usr.bin/cvs/update.c
+++ b/usr.bin/cvs/update.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: update.c,v 1.28 2005/05/20 20:00:53 joris Exp $ */
+/* $OpenBSD: update.c,v 1.29 2005/05/24 04:12:25 jfb Exp $ */
/*
* Copyright (c) 2004 Jean-Francois Brousseau <jfb@openbsd.org>
* All rights reserved.
@@ -40,31 +40,40 @@
#include "proto.h"
+static int cvs_update_init (struct cvs_cmd *, int, char **, int *);
+static int cvs_update_pre_exec (struct cvsroot *);
static int cvs_update_remote (CVSFILE *, void *);
static int cvs_update_local (CVSFILE *, void *);
-static int cvs_update_options (char *, int, char **, int *);
-static int cvs_update_sendflags (struct cvsroot *);
-struct cvs_cmd_info cvs_update = {
- cvs_update_options,
- cvs_update_sendflags,
- cvs_update_remote,
- NULL, NULL,
+
+struct cvs_cmd cvs_cmd_update = {
+ CVS_OP_UPDATE, CVS_REQ_UPDATE, "update",
+ { "up", "upd" },
+ "Bring work tree in sync with repository",
+ "[-ACdflPpR] [-D date | -r rev] [-I ign] [-j rev] [-k mode] "
+ "[-t id] ...",
+ "ACD:dflPpQqRr:",
+ NULL,
CF_SORT | CF_RECURSE | CF_IGNORE | CF_KNOWN | CF_NOSYMS,
- CVS_REQ_UPDATE,
+ cvs_update_init,
+ cvs_update_pre_exec,
+ cvs_update_remote,
+ cvs_update_local,
+ NULL,
+ NULL,
CVS_CMD_ALLOWSPEC | CVS_CMD_SENDARGS2 | CVS_CMD_SENDDIR
};
static int Pflag, dflag, Aflag;
static int
-cvs_update_options(char *opt, int argc, char **argv, int *arg)
+cvs_update_init(struct cvs_cmd *cmd, int argc, char **argv, int *arg)
{
int ch;
Pflag = dflag = Aflag = 0;
- while ((ch = getopt(argc, argv, opt)) != -1) {
+ while ((ch = getopt(argc, argv, cmd->cmd_opts)) != -1) {
switch (ch) {
case 'A':
Aflag = 1;
@@ -77,7 +86,7 @@ cvs_update_options(char *opt, int argc, char **argv, int *arg)
case 'f':
break;
case 'l':
- cvs_update.file_flags &= ~CF_RECURSE;
+ cmd->file_flags &= ~CF_RECURSE;
break;
case 'P':
Pflag = 1;
@@ -89,7 +98,7 @@ cvs_update_options(char *opt, int argc, char **argv, int *arg)
case 'q':
break;
case 'R':
- cvs_update.file_flags |= CF_RECURSE;
+ cmd->file_flags |= CF_RECURSE;
break;
case 'r':
break;
@@ -103,7 +112,7 @@ cvs_update_options(char *opt, int argc, char **argv, int *arg)
}
static int
-cvs_update_sendflags(struct cvsroot *root)
+cvs_update_pre_exec(struct cvsroot *root)
{
if (Pflag && cvs_sendarg(root, "-P", 0) < 0)
return (CVS_EX_PROTO);
@@ -183,17 +192,19 @@ cvs_update_local(CVSFILE *cf, void *arg)
RCSFILE *rf;
struct cvsroot *root;
+ printf("cvs_update_local(%s)\n", cf->cf_name);
ret = 0;
rf = NULL;
root = CVS_DIR_ROOT(cf);
repo = CVS_DIR_REPO(cf);
+ cvs_file_getpath(cf, fpath, sizeof(fpath));
+
if (cf->cf_type == DT_DIR) {
+ cvs_log(LP_INFO, "Updating %s", fpath);
return (CVS_EX_OK);
}
- cvs_file_getpath(cf, fpath, sizeof(fpath));
-
if (cf->cf_cvstat == CVS_FST_UNKNOWN) {
cvs_printf("? %s\n", fpath);
return (0);
@@ -207,8 +218,10 @@ cvs_update_local(CVSFILE *cf, void *arg)
return (CVS_EX_DATA);
}
+ printf("opening %s\n", rcspath);
rf = rcs_open(rcspath, RCS_RDWR);
if (rf == NULL) {
+ printf("failed here?\n");
return (CVS_EX_DATA);
}
diff --git a/usr.bin/cvs/version.c b/usr.bin/cvs/version.c
index ac57ae10259..dd08e103227 100644
--- a/usr.bin/cvs/version.c
+++ b/usr.bin/cvs/version.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: version.c,v 1.10 2005/05/12 23:46:31 joris Exp $ */
+/* $OpenBSD: version.c,v 1.11 2005/05/24 04:12:25 jfb Exp $ */
/*
* Copyright (c) 2004 Jean-Francois Brousseau <jfb@openbsd.org>
* All rights reserved.
@@ -35,15 +35,26 @@
#include "cvs.h"
#include "proto.h"
-int cvs_version_sendflags(struct cvsroot *);
+static int cvs_version_sendflags (struct cvsroot *);
-struct cvs_cmd_info cvs_version = {
+struct cvs_cmd cvs_cmd_version = {
+ CVS_OP_VERSION, CVS_REQ_VERSION, "version",
+ { "ve", "ver" },
+ "Show current CVS version(s)",
+ "",
+ "",
+ NULL,
+ 0,
NULL,
cvs_version_sendflags,
- NULL, NULL, NULL, CF_NOFILES, 0, 0
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ 0
};
-int
+static int
cvs_version_sendflags(struct cvsroot *root)
{
if ((root != NULL) && (root->cr_method != CVS_METHOD_LOCAL))