summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoris Vink <joris@cvs.openbsd.org>2005-07-08 16:03:39 +0000
committerJoris Vink <joris@cvs.openbsd.org>2005-07-08 16:03:39 +0000
commitf227138c04a54112f0cf39ea40a28cd58ab74db9 (patch)
tree1df74c6090c093885e390637756557b68431f9f6
parent3bf2d53b7c866803b60d9ad8f6d8198e0c3db81d (diff)
split local and remote function handlers from each other.
-rw-r--r--usr.bin/cvs/add.c37
-rw-r--r--usr.bin/cvs/remove.c82
2 files changed, 60 insertions, 59 deletions
diff --git a/usr.bin/cvs/add.c b/usr.bin/cvs/add.c
index b6e0a0ca5d5..b181bf5aab1 100644
--- a/usr.bin/cvs/add.c
+++ b/usr.bin/cvs/add.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: add.c,v 1.21 2005/05/24 04:12:25 jfb Exp $ */
+/* $OpenBSD: add.c,v 1.22 2005/07/08 16:03:38 joris Exp $ */
/*
* Copyright (c) 2004 Jean-Francois Brousseau <jfb@openbsd.org>
* All rights reserved.
@@ -40,7 +40,8 @@
extern char *__progname;
-static int cvs_add_file(CVSFILE *, void *);
+static int cvs_add_remote(CVSFILE *, void *);
+static int cvs_add_local(CVSFILE *, void *);
static int cvs_add_init(struct cvs_cmd *, int, char **, int *);
static int cvs_add_pre_exec(struct cvsroot *);
@@ -54,8 +55,8 @@ struct cvs_cmd cvs_cmd_add = {
0,
cvs_add_init,
cvs_add_pre_exec,
- cvs_add_file,
- cvs_add_file,
+ cvs_add_remote,
+ cvs_add_local,
NULL,
NULL,
CVS_CMD_ALLOWSPEC | CVS_CMD_SENDDIR | CVS_CMD_SENDARGS2
@@ -115,7 +116,7 @@ cvs_add_pre_exec(struct cvsroot *root)
}
static int
-cvs_add_file(CVSFILE *cf, void *arg)
+cvs_add_remote(CVSFILE *cf, void *arg)
{
int ret;
struct cvsroot *root;
@@ -124,25 +125,25 @@ cvs_add_file(CVSFILE *cf, void *arg)
root = CVS_DIR_ROOT(cf);
if (cf->cf_type == DT_DIR) {
- if (root->cr_method != CVS_METHOD_LOCAL)
- ret = cvs_senddir(root, cf);
-
+ ret = cvs_senddir(root, cf);
if (ret == -1)
ret = CVS_EX_PROTO;
-
return (ret);
}
- if (root->cr_method != CVS_METHOD_LOCAL) {
- if (cf->cf_cvstat == CVS_FST_UNKNOWN)
- ret = cvs_sendreq(root, CVS_REQ_ISMODIFIED,
- cf->cf_name);
- } else {
- cvs_log(LP_INFO, "scheduling file `%s' for addition",
+ if (cf->cf_cvstat == CVS_FST_UNKNOWN)
+ ret = cvs_sendreq(root, CVS_REQ_ISMODIFIED,
cf->cf_name);
- cvs_log(LP_INFO, "use `%s commit' to add this file permanently",
- __progname);
- }
return (ret);
}
+
+static
+int cvs_add_local(CVSFILE *cf, void *arg)
+{
+ cvs_log(LP_INFO, "scheduling file `%s' for addition", cf->cf_name);
+ cvs_log(LP_INFO, "use `%s commit' to add this file permanently",
+ __progname);
+
+ return (0);
+}
diff --git a/usr.bin/cvs/remove.c b/usr.bin/cvs/remove.c
index 4b4b053a3fc..a000098199f 100644
--- a/usr.bin/cvs/remove.c
+++ b/usr.bin/cvs/remove.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: remove.c,v 1.17 2005/07/07 14:27:57 joris Exp $ */
+/* $OpenBSD: remove.c,v 1.18 2005/07/08 16:03:38 joris Exp $ */
/*
* Copyright (c) 2004 Jean-Francois Brousseau <jfb@openbsd.org>
* Copyright (c) 2004 Xavier Santolaria <xsa@openbsd.org>
@@ -43,7 +43,8 @@ extern char *__progname;
static int cvs_remove_init (struct cvs_cmd *, int, char **, int *);
-static int cvs_remove_file (CVSFILE *, void *);
+static int cvs_remove_remote (CVSFILE *, void *);
+static int cvs_remove_local (CVSFILE *, void *);
static int force_remove = 0; /* -f option */
@@ -57,8 +58,8 @@ struct cvs_cmd cvs_cmd_remove = {
CF_IGNORE | CF_RECURSE,
cvs_remove_init,
NULL,
- cvs_remove_file,
- cvs_remove_file,
+ cvs_remove_remote,
+ cvs_remove_local,
NULL,
NULL,
CVS_CMD_SENDDIR | CVS_CMD_SENDARGS2 | CVS_CMD_ALLOWSPEC
@@ -94,7 +95,7 @@ cvs_remove_init(struct cvs_cmd *cmd, int argc, char **argv, int *arg)
static int
-cvs_remove_file(CVSFILE *cf, void *arg)
+cvs_remove_remote(CVSFILE *cf, void *arg)
{
int ret;
char fpath[MAXPATHLEN];
@@ -104,51 +105,50 @@ cvs_remove_file(CVSFILE *cf, void *arg)
root = CVS_DIR_ROOT(cf);
if (cf->cf_type == DT_DIR) {
- if (root->cr_method != CVS_METHOD_LOCAL) {
- if (cf->cf_cvstat == CVS_FST_UNKNOWN)
- ret = cvs_sendreq(root, CVS_REQ_QUESTIONABLE,
- CVS_FILE_NAME(cf));
- else
- ret = cvs_senddir(root, cf);
-
- if (ret == -1)
- ret = CVS_EX_PROTO;
- }
-
+ if (cf->cf_cvstat == CVS_FST_UNKNOWN)
+ ret = cvs_sendreq(root, CVS_REQ_QUESTIONABLE,
+ CVS_FILE_NAME(cf));
+ else
+ ret = cvs_senddir(root, cf);
+
+ if (ret == -1)
+ ret = CVS_EX_PROTO;
return (ret);
}
cvs_file_getpath(cf, fpath, sizeof(fpath));
- if (root->cr_method != CVS_METHOD_LOCAL) {
- /* if -f option is used, physically remove the file */
- if ((force_remove == 1) && !cvs_noexec) {
- if((unlink(fpath) == -1) && (errno != ENOENT)) {
- cvs_log(LP_ERRNO,
- "failed to unlink `%s'", fpath);
- return (CVS_EX_FILE);
- }
+ /* if -f option is used, physically remove the file */
+ if ((force_remove == 1) && !cvs_noexec) {
+ if((unlink(fpath) == -1) && (errno != ENOENT)) {
+ cvs_log(LP_ERRNO,
+ "failed to unlink `%s'", fpath);
+ return (CVS_EX_FILE);
}
+ }
- if (cvs_sendentry(root, cf) < 0)
- return (CVS_EX_PROTO);
-
- if (cf->cf_cvstat != CVS_FST_LOST && force_remove != 1) {
- if (cvs_sendreq(root, CVS_REQ_MODIFIED,
- CVS_FILE_NAME(cf)) < 0) {
- return (CVS_EX_PROTO);
- }
+ if (cvs_sendentry(root, cf) < 0)
+ return (CVS_EX_PROTO);
- if (cvs_sendfile(root, fpath) < 0)
- return (CVS_EX_PROTO);
+ if (cf->cf_cvstat != CVS_FST_LOST && force_remove != 1) {
+ if (cvs_sendreq(root, CVS_REQ_MODIFIED,
+ CVS_FILE_NAME(cf)) < 0) {
+ return (CVS_EX_PROTO);
}
- } else {
- cvs_log(LP_INFO, "scheduling file `%s' for removal",
- CVS_FILE_NAME(cf));
- cvs_log(LP_INFO,
- "use `%s commit' to remove this file permanently",
- __progname);
+
+ if (cvs_sendfile(root, fpath) < 0)
+ return (CVS_EX_PROTO);
}
- return (ret);
+ return (0);
+}
+
+static int
+cvs_remove_local(CVSFILE *cf, void *arg)
+{
+ cvs_log(LP_INFO, "scheduling file `%s' for removal", cf->cf_name);
+ cvs_log(LP_INFO, "use `%s commit' to remove this file permanently",
+ __progname);
+
+ return (0);
}