summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--usr.bin/cvs/add.c10
-rw-r--r--usr.bin/cvs/admin.c60
-rw-r--r--usr.bin/cvs/annotate.c14
-rw-r--r--usr.bin/cvs/checkout.c18
-rw-r--r--usr.bin/cvs/cmd.c4
-rw-r--r--usr.bin/cvs/commit.c22
-rw-r--r--usr.bin/cvs/cvs.c27
-rw-r--r--usr.bin/cvs/cvs.h7
-rw-r--r--usr.bin/cvs/diff.c26
-rw-r--r--usr.bin/cvs/getlog.c8
-rw-r--r--usr.bin/cvs/history.c18
-rw-r--r--usr.bin/cvs/import.c20
-rw-r--r--usr.bin/cvs/init.c8
-rw-r--r--usr.bin/cvs/remove.c10
-rw-r--r--usr.bin/cvs/server.c8
-rw-r--r--usr.bin/cvs/status.c10
-rw-r--r--usr.bin/cvs/tag.c24
-rw-r--r--usr.bin/cvs/update.c8
18 files changed, 163 insertions, 139 deletions
diff --git a/usr.bin/cvs/add.c b/usr.bin/cvs/add.c
index ec1d35c98d6..33152ae090d 100644
--- a/usr.bin/cvs/add.c
+++ b/usr.bin/cvs/add.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: add.c,v 1.18 2005/04/11 18:02:58 joris Exp $ */
+/* $OpenBSD: add.c,v 1.19 2005/04/12 14:58:40 joris Exp $ */
/*
* Copyright (c) 2004 Jean-Francois Brousseau <jfb@openbsd.org>
* All rights reserved.
@@ -73,17 +73,17 @@ cvs_add_options(char *opt, int argc, char **argv, int *arg)
cvs_log(LP_ERR,
"invalid RCS keyword expansion mode");
rcs_kflag_usage();
- return (1);
+ return (CVS_EX_USAGE);
}
break;
case 'm':
if ((cvs_msg = strdup(optarg)) == NULL) {
cvs_log(LP_ERRNO, "failed to copy message");
- return (-1);
+ return (CVS_EX_DATA);
}
break;
default:
- return (1);
+ return (CVS_EX_USAGE);
}
}
@@ -100,7 +100,7 @@ cvs_add_sendflags(struct cvsroot *root)
strlcpy(buf, "-k", sizeof(buf));
strlcat(buf, koptstr, sizeof(buf));
if (cvs_sendarg(root, buf, 0) < 0)
- return (-1);
+ return (CVS_EX_PROTO);
}
return (0);
diff --git a/usr.bin/cvs/admin.c b/usr.bin/cvs/admin.c
index 2dbb5ac447f..43ff574a26b 100644
--- a/usr.bin/cvs/admin.c
+++ b/usr.bin/cvs/admin.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: admin.c,v 1.10 2005/04/11 18:02:58 joris Exp $ */
+/* $OpenBSD: admin.c,v 1.11 2005/04/12 14:58:40 joris Exp $ */
/*
* Copyright (c) 2004 Jean-Francois Brousseau <jfb@openbsd.org>
* Copyright (c) 2005 Joris Vink <joris@openbsd.org>
@@ -110,7 +110,7 @@ cvs_admin_options(char *opt, int argc, char **argv, int *arg)
cvs_log(LP_ERR,
"invalid RCS keyword expansion mode");
rcs_kflag_usage();
- return (1);
+ return (CVS_EX_USAGE);
}
break;
case 'l':
@@ -150,7 +150,7 @@ cvs_admin_options(char *opt, int argc, char **argv, int *arg)
strictlock |= LOCK_REMOVE;
break;
default:
- return (1);
+ return (CVS_EX_USAGE);
}
}
@@ -160,14 +160,14 @@ cvs_admin_options(char *opt, int argc, char **argv, int *arg)
/* do some sanity checking on the arguments */
if ((strictlock & LOCK_SET) && (strictlock & LOCK_REMOVE)) {
cvs_log(LP_ERR, "-L and -U are incompatible");
- return (-1);
+ return (CVS_EX_USAGE);
}
if (lockrev_arg != NULL) {
if ((rcs = rcsnum_parse(lockrev_arg)) == NULL) {
cvs_log(LP_ERR, "%s is not a numeric branch",
lockrev_arg);
- return (1);
+ return (CVS_EX_USAGE);
}
rcsnum_free(rcs);
}
@@ -176,7 +176,7 @@ cvs_admin_options(char *opt, int argc, char **argv, int *arg)
if ((rcs = rcsnum_parse(unlockrev_arg)) == NULL) {
cvs_log(LP_ERR, "%s is not a numeric branch",
unlockrev_arg);
- return (-1);
+ return (CVS_EX_USAGE);
}
rcsnum_free(rcs);
}
@@ -184,13 +184,13 @@ cvs_admin_options(char *opt, int argc, char **argv, int *arg)
if (replace_msg != NULL) {
if ((q = strchr(replace_msg, ':')) == NULL) {
cvs_log(LP_ERR, "invalid option for -m");
- return (1);
+ return (CVS_EX_USAGE);
}
*q = '\0';
if ((rcs = rcsnum_parse(replace_msg)) == NULL) {
cvs_log(LP_ERR, "%s is not a numeric revision",
replace_msg);
- return (-1);
+ return (CVS_EX_USAGE);
}
rcsnum_free(rcs);
*q = ':';
@@ -205,84 +205,84 @@ cvs_admin_sendflags(struct cvsroot *root)
{
if ((alist != NULL) && ((cvs_sendarg(root, "-a", 0) < 0) ||
(cvs_sendarg(root, alist, 0) < 0)))
- return (-1);
+ return (CVS_EX_PROTO);
if ((userfile != NULL) && ((cvs_sendarg(root, "-A", 0) < 0) ||
(cvs_sendarg(root, userfile, 0) < 0)))
- return (-1);
+ return (CVS_EX_PROTO);
if (runflags & FLAG_BRANCH) {
if (cvs_sendarg(root, "-b", 0) < 0)
- return (-1);
+ return (CVS_EX_PROTO);
if ((branch_arg != NULL) &&
(cvs_sendarg(root, branch_arg, 0) < 0))
- return (-1);
+ return (CVS_EX_PROTO);
}
if ((comment != NULL) && ((cvs_sendarg(root, "-c", 0) < 0) ||
(cvs_sendarg(root, comment, 0) < 0)))
- return (-1);
+ return (CVS_EX_PROTO);
if (runflags & FLAG_DELUSER) {
if (cvs_sendarg(root, "-e", 0) < 0)
- return (-1);
+ return (CVS_EX_PROTO);
if ((elist != NULL) &&
(cvs_sendarg(root, elist, 0) < 0))
- return (-1);
+ return (CVS_EX_PROTO);
}
if (runflags & FLAG_INTERACTIVE) {
if (cvs_sendarg(root, "-I", 0) < 0)
- return (-1);
+ return (CVS_EX_PROTO);
}
if ((subst != NULL) && ((cvs_sendarg(root, "-k", 0) < 0) ||
(cvs_sendarg(root, subst, 0) < 0)))
- return (-1);
+ return (CVS_EX_PROTO);
if (lockrev & LOCK_SET) {
if (cvs_sendarg(root, "-l", 0) < 0)
- return (-1);
+ return (CVS_EX_PROTO);
if ((lockrev_arg != NULL) &&
(cvs_sendarg(root, lockrev_arg, 0) < 0))
- return (-1);
+ return (CVS_EX_PROTO);
}
if ((strictlock & LOCK_SET) &&
(cvs_sendarg(root, "-L", 0) < 0))
- return (-1);
+ return (CVS_EX_PROTO);
if ((replace_msg != NULL) && ((cvs_sendarg(root, "-m", 0) < 0)
|| (cvs_sendarg(root, replace_msg, 0) < 0)))
- return (-1);
+ return (CVS_EX_PROTO);
if ((ntag != NULL) && ((cvs_sendarg(root, "-n", 0) < 0) ||
(cvs_sendarg(root, ntag, 0) < 0)))
- return (-1);
+ return (CVS_EX_PROTO);
if ((Ntag != NULL) && ((cvs_sendarg(root, "-N", 0) < 0) ||
(cvs_sendarg(root, Ntag, 0) < 0)))
- return (-1);
+ return (CVS_EX_PROTO);
if ((range != NULL) && ((cvs_sendarg(root, "-o", 0) < 0) ||
(cvs_sendarg(root, range, 0) < 0)))
- return (-1);
+ return (CVS_EX_PROTO);
if ((state != NULL) && ((cvs_sendarg(root, "-s", 0) < 0) ||
(cvs_sendarg(root, state, 0) < 0)))
- return (-1);
+ return (CVS_EX_PROTO);
if (lockrev & LOCK_REMOVE) {
if (cvs_sendarg(root, "-u", 0) < 0)
- return (-1);
+ return (CVS_EX_PROTO);
if ((unlockrev_arg != NULL) &&
(cvs_sendarg(root, unlockrev_arg, 0) < 0))
- return (-1);
+ return (CVS_EX_PROTO);
}
if ((strictlock & LOCK_REMOVE) &&
(cvs_sendarg(root, "-U", 0) < 0))
- return (-1);
+ return (CVS_EX_PROTO);
return (0);
}
@@ -324,7 +324,7 @@ cvs_admin_file(CVSFILE *cfp, void *arg)
if (root->cr_method != CVS_METHOD_LOCAL) {
if ((entp != NULL) && (cvs_sendentry(root, entp) < 0)) {
cvs_ent_free(entp);
- return (-1);
+ return (CVS_EX_PROTO);
}
switch (cfp->cf_cvstat) {
@@ -357,7 +357,7 @@ cvs_admin_file(CVSFILE *cfp, void *arg)
if (rf == NULL) {
if (entp != NULL)
cvs_ent_free(entp);
- return (-1);
+ return (CVS_EX_DATA);
}
rcs_close(rf);
diff --git a/usr.bin/cvs/annotate.c b/usr.bin/cvs/annotate.c
index da523cc2e2f..66c0322e78b 100644
--- a/usr.bin/cvs/annotate.c
+++ b/usr.bin/cvs/annotate.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: annotate.c,v 1.8 2005/04/11 18:02:58 joris Exp $ */
+/* $OpenBSD: annotate.c,v 1.9 2005/04/12 14:58:40 joris Exp $ */
/*
* Copyright (c) 2004 Jean-Francois Brousseau <jfb@openbsd.org>
* All rights reserved.
@@ -85,14 +85,14 @@ cvs_annotate_options(char *opt, int argc, char **argv, int *arg)
rev = optarg;
break;
default:
- return (1);
+ return (CVS_EX_USAGE);
}
}
if ((date != NULL) && (rev != NULL)) {
cvs_log(LP_ERR,
"the -D and -d arguments are mutually exclusive");
- return (1);
+ return (CVS_EX_USAGE);
}
*arg = optind;
@@ -103,18 +103,18 @@ int
cvs_annotate_sendflags(struct cvsroot *root)
{
if (usehead && (cvs_sendarg(root, "-f", 0) < 0))
- return (-1);
+ return (CVS_EX_PROTO);
if (rev != NULL) {
if ((cvs_sendarg(root, "-r", 0) < 0) ||
(cvs_sendarg(root, rev, 0) < 0))
- return (-1);
+ return (CVS_EX_PROTO);
}
if (date != NULL) {
if ((cvs_sendarg(root, "-D", 0) < 0) ||
(cvs_sendarg(root, date, 0) < 0))
- return (-1);
+ return (CVS_EX_PROTO);
}
return (0);
@@ -154,7 +154,7 @@ cvs_annotate_file(CVSFILE *cf, void *arg)
if (root->cr_method != CVS_METHOD_LOCAL) {
if ((entp != NULL) && (cvs_sendentry(root, entp) < 0)) {
cvs_ent_free(entp);
- return (-1);
+ return (CVS_EX_PROTO);
}
switch (cf->cf_cvstat) {
diff --git a/usr.bin/cvs/checkout.c b/usr.bin/cvs/checkout.c
index 3a7a7262785..0ca9bae9490 100644
--- a/usr.bin/cvs/checkout.c
+++ b/usr.bin/cvs/checkout.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: checkout.c,v 1.17 2005/04/11 18:02:58 joris Exp $ */
+/* $OpenBSD: checkout.c,v 1.18 2005/04/12 14:58:40 joris Exp $ */
/*
* Copyright (c) 2004 Jean-Francois Brousseau <jfb@openbsd.org>
* All rights reserved.
@@ -89,7 +89,7 @@ cvs_checkout_options(char *opt, int argc, char **argv, int *arg)
cvs_log(LP_ERR,
"invalid RCS keyword expansion mode");
rcs_kflag_usage();
- return (1);
+ return (CVS_EX_USAGE);
}
break;
case 'r':
@@ -102,7 +102,7 @@ cvs_checkout_options(char *opt, int argc, char **argv, int *arg)
rcsid = optarg;
break;
default:
- return (1);
+ return (CVS_EX_USAGE);
}
}
@@ -112,12 +112,12 @@ cvs_checkout_options(char *opt, int argc, char **argv, int *arg)
if (!statmod && (argc == 0)) {
cvs_log(LP_ERR,
"must specify at least one module or directory");
- return (1);
+ return (CVS_EX_USAGE);
}
if (statmod && (argc > 0)) {
cvs_log(LP_ERR, "-c and -s must not get any arguments");
- return (1);
+ return (CVS_EX_USAGE);
}
*arg = optind;
@@ -128,21 +128,21 @@ int
cvs_checkout_sendflags(struct cvsroot *root)
{
if (cvs_senddir(root, cvs_files) < 0)
- return (-1);
+ return (CVS_EX_PROTO);
if (cvs_sendreq(root, CVS_REQ_XPANDMOD, NULL) < 0)
cvs_log(LP_ERR, "failed to expand module");
/* XXX not too sure why we have to send this arg */
if (cvs_sendarg(root, "-N", 0) < 0)
- return (-1);
+ return (CVS_EX_PROTO);
if ((statmod == CVS_LISTMOD) &&
(cvs_sendarg(root, "-c", 0) < 0))
- return (-1);
+ return (CVS_EX_PROTO);
if ((statmod == CVS_STATMOD) &&
(cvs_sendarg(root, "-s", 0) < 0))
- return (-1);
+ return (CVS_EX_PROTO);
return (0);
}
diff --git a/usr.bin/cvs/cmd.c b/usr.bin/cvs/cmd.c
index f06bea6579a..ece600cdce3 100644
--- a/usr.bin/cvs/cmd.c
+++ b/usr.bin/cvs/cmd.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: cmd.c,v 1.9 2005/04/11 18:02:58 joris Exp $ */
+/* $OpenBSD: cmd.c,v 1.10 2005/04/12 14:58:40 joris Exp $ */
/*
* Copyright (c) 2005 Joris Vink <joris@openbsd.org>
* All rights reserved.
@@ -98,7 +98,7 @@ cvs_startcmd(struct cvs_cmd *cmd, int argc, char **argv)
}
if (c->cmd_sendflags != NULL) {
- if ((ret = c->cmd_sendflags(root)) < 0)
+ if ((ret = c->cmd_sendflags(root)) != 0)
return (ret);
}
diff --git a/usr.bin/cvs/commit.c b/usr.bin/cvs/commit.c
index ee831a586b2..ea7c55a74e0 100644
--- a/usr.bin/cvs/commit.c
+++ b/usr.bin/cvs/commit.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: commit.c,v 1.22 2005/04/11 18:02:58 joris Exp $ */
+/* $OpenBSD: commit.c,v 1.23 2005/04/12 14:58:40 joris Exp $ */
/*
* Copyright (c) 2004 Jean-Francois Brousseau <jfb@openbsd.org>
* All rights reserved.
@@ -80,24 +80,24 @@ cvs_commit_options(char *opt, int argc, char **argv, int *arg)
cvs_msg = strdup(optarg);
if (cvs_msg == NULL) {
cvs_log(LP_ERRNO, "failed to copy message");
- return (-1);
+ return (CVS_EX_USAGE);
}
break;
case 'R':
cvs_commit.file_flags |= CF_RECURSE;
break;
default:
- return (1);
+ return (CVS_EX_USAGE);
}
}
if ((cvs_msg != NULL) && (mfile != NULL)) {
cvs_log(LP_ERR, "the -F and -m flags are mutually exclusive");
- return (1);
+ return (CVS_EX_USAGE);
}
if ((mfile != NULL) && (cvs_msg = cvs_logmsg_open(mfile)) == NULL)
- return (-1);
+ return (CVS_EX_DATA);
*arg = optind;
return (0);
@@ -125,7 +125,7 @@ cvs_commit_helper(void)
}
if (cvs_msg == NULL)
- return (-1);
+ return (CVS_EX_DATA);
return (0);
}
@@ -145,7 +145,7 @@ cvs_commit_prepare(CVSFILE *cf, void *arg)
if ((cf->cf_type == DT_REG) && (cf->cf_cvstat == CVS_FST_MODIFIED)) {
copy = cvs_file_copy(cf);
if (copy == NULL)
- return (-1);
+ return (CVS_EX_DATA);
TAILQ_INSERT_TAIL(clp, copy, cf_list);
}
@@ -189,25 +189,25 @@ cvs_commit_file(CVSFILE *cf, void *arg)
entp = cvs_ent_getent(fpath);
if (entp == NULL)
- return (-1);
+ return (CVS_EX_DATA);
if ((cf->cf_cvstat == CVS_FST_ADDED) ||
(cf->cf_cvstat == CVS_FST_MODIFIED)) {
if (root->cr_method != CVS_METHOD_LOCAL) {
if (cvs_sendentry(root, entp) < 0) {
cvs_ent_free(entp);
- return (-1);
+ return (CVS_EX_PROTO);
}
if (cvs_sendreq(root, CVS_REQ_MODIFIED,
CVS_FILE_NAME(cf)) < 0) {
cvs_ent_free(entp);
- return (-1);
+ return (CVS_EX_PROTO);
}
if (cvs_sendfile(root, fpath) < 0) {
cvs_ent_free(entp);
- return (-1);
+ return (CVS_EX_PROTO);
}
}
}
diff --git a/usr.bin/cvs/cvs.c b/usr.bin/cvs/cvs.c
index 87395a29a73..30045990316 100644
--- a/usr.bin/cvs/cvs.c
+++ b/usr.bin/cvs/cvs.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: cvs.c,v 1.50 2005/04/11 18:02:58 joris Exp $ */
+/* $OpenBSD: cvs.c,v 1.51 2005/04/12 14:58:40 joris Exp $ */
/*
* Copyright (c) 2004 Jean-Francois Brousseau <jfb@openbsd.org>
* All rights reserved.
@@ -421,11 +421,30 @@ main(int argc, char **argv)
cmd_argv[cmd_argc++] = argv[ret];
ret = cvs_startcmd(cmdp, cmd_argc, cmd_argv);
- if (ret == 1) {
- fprintf(stderr, "Usage: %s %s %s\n", __progname, cvs_command,
- cmdp->cmd_synopsis);
+ if (ret > 0)
+ fprintf(stderr, "%s [%s aborted]: ", __progname, cvs_command);
+
+ switch (ret) {
+ case CVS_EX_USAGE:
+ fprintf(stderr, "Usage: %s", cmdp->cmd_synopsis);
+ break;
+ case CVS_EX_DATA:
+ fprintf(stderr, "internal data error");
+ break;
+ case CVS_EX_PROTO:
+ fprintf(stderr, "protocol error");
+ break;
+ case CVS_EX_FILE:
+ fprintf(stderr, "an operation on a file or directory failed");
+ break;
+ default:
+ fprintf(stderr, "unknown error");
+ break;
}
+ if (ret > 0)
+ fprintf(stderr, "\n");
+
if (cmdp->cmd_info->cmd_cleanup != NULL)
cmdp->cmd_info->cmd_cleanup();
if (cvs_files != NULL)
diff --git a/usr.bin/cvs/cvs.h b/usr.bin/cvs/cvs.h
index ca32c7a177a..a19045ecf94 100644
--- a/usr.bin/cvs/cvs.h
+++ b/usr.bin/cvs/cvs.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: cvs.h,v 1.49 2005/04/06 16:35:25 jfb Exp $ */
+/* $OpenBSD: cvs.h,v 1.50 2005/04/12 14:58:40 joris Exp $ */
/*
* Copyright (c) 2004 Jean-Francois Brousseau <jfb@openbsd.org>
* All rights reserved.
@@ -45,6 +45,11 @@
#define CVS_CKSUM_LEN 33 /* length of a CVS checksum string */
+/* error codes */
+#define CVS_EX_USAGE 1
+#define CVS_EX_DATA 2
+#define CVS_EX_PROTO 3
+#define CVS_EX_FILE 4
/* operations */
#define CVS_OP_UNKNOWN 0
diff --git a/usr.bin/cvs/diff.c b/usr.bin/cvs/diff.c
index 78192ead103..659dbecda44 100644
--- a/usr.bin/cvs/diff.c
+++ b/usr.bin/cvs/diff.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: diff.c,v 1.27 2005/04/11 18:02:58 joris Exp $ */
+/* $OpenBSD: diff.c,v 1.28 2005/04/12 14:58:40 joris Exp $ */
/*
* Copyright (C) Caldera International Inc. 2001-2002.
* All rights reserved.
@@ -358,7 +358,7 @@ cvs_diff_options(char *opt, int argc, char **argv, int *arg)
dap = (struct diff_arg *)malloc(sizeof(*dap));
if (dap == NULL)
- return (-1);
+ return (CVS_EX_DATA);
dap->date1 = dap->date2 = dap->rev1 = dap->rev2 = NULL;
strlcpy(diffargs, argv[0], sizeof(diffargs));
@@ -406,7 +406,7 @@ cvs_diff_options(char *opt, int argc, char **argv, int *arg)
cvs_log(LP_ERR,
"no more than two revisions/dates can "
"be specified");
- return (1);
+ return (CVS_EX_USAGE);
}
break;
case 'u':
@@ -414,7 +414,7 @@ cvs_diff_options(char *opt, int argc, char **argv, int *arg)
format = D_UNIFIED;
break;
default:
- return (1);
+ return (CVS_EX_USAGE);
}
}
@@ -439,9 +439,9 @@ cvs_diff_sendflags(struct cvsroot *root)
{
/* send the flags */
if (Nflag && (cvs_sendarg(root, "-N", 0) < 0))
- return (-1);
+ return (CVS_EX_PROTO);
if (pflag && (cvs_sendarg(root, "-p", 0) < 0))
- return (-1);
+ return (CVS_EX_PROTO);
if (format == D_CONTEXT)
cvs_sendarg(root, "-c", 0);
@@ -534,12 +534,12 @@ cvs_diff_file(struct cvs_file *cfp, void *arg)
entp = cvs_ent_getent(diff_file);
if (entp == NULL)
- return (-1);
+ return (CVS_EX_DATA);
if (root->cr_method != CVS_METHOD_LOCAL) {
if (cvs_sendentry(root, entp) < 0) {
cvs_ent_free(entp);
- return (-1);
+ return (CVS_EX_PROTO);
}
}
@@ -562,7 +562,7 @@ cvs_diff_file(struct cvs_file *cfp, void *arg)
rf = rcs_open(rcspath, RCS_READ);
if (rf == NULL) {
cvs_ent_free(entp);
- return (-1);
+ return (CVS_EX_DATA);
}
cvs_printf("Index: %s\n%s\nRCS file: %s\n", diff_file,
@@ -573,7 +573,7 @@ cvs_diff_file(struct cvs_file *cfp, void *arg)
else {
if ((r1 = rcsnum_parse(dap->rev1)) == NULL) {
cvs_ent_free(entp);
- return (-1);
+ return (CVS_EX_DATA);
}
}
@@ -588,7 +588,7 @@ cvs_diff_file(struct cvs_file *cfp, void *arg)
cvs_printf("retrieving revision %s\n", dap->rev2);
if ((r2 = rcsnum_parse(dap->rev2)) == NULL) {
cvs_ent_free(entp);
- return (-1);
+ return (CVS_EX_DATA);
}
b2 = rcs_getrev(rf, r2);
rcsnum_free(r2);
@@ -607,7 +607,7 @@ cvs_diff_file(struct cvs_file *cfp, void *arg)
if (cvs_buf_write_stmp(b1, path_tmp1, 0600) == -1) {
cvs_buf_free(b1);
cvs_buf_free(b2);
- return (-1);
+ return (CVS_EX_DATA);
}
cvs_buf_free(b1);
@@ -615,7 +615,7 @@ cvs_diff_file(struct cvs_file *cfp, void *arg)
if (cvs_buf_write_stmp(b2, path_tmp2, 0600) == -1) {
cvs_buf_free(b2);
(void)unlink(path_tmp1);
- return (-1);
+ return (CVS_EX_DATA);
}
cvs_buf_free(b2);
diff --git a/usr.bin/cvs/getlog.c b/usr.bin/cvs/getlog.c
index 9d302c150b7..06a40c8d93c 100644
--- a/usr.bin/cvs/getlog.c
+++ b/usr.bin/cvs/getlog.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: getlog.c,v 1.18 2005/04/11 18:02:58 joris Exp $ */
+/* $OpenBSD: getlog.c,v 1.19 2005/04/12 14:58:40 joris Exp $ */
/*
* Copyright (c) 2004 Jean-Francois Brousseau <jfb@openbsd.org>
* All rights reserved.
@@ -88,7 +88,7 @@ cvs_getlog_options(char *opt, int argc, char **argv, int *arg)
case 'r':
break;
default:
- return (1);
+ return (CVS_EX_USAGE);
}
}
@@ -134,7 +134,7 @@ cvs_getlog_file(CVSFILE *cf, void *arg)
if (root->cr_method != CVS_METHOD_LOCAL) {
if ((entp != NULL) && (cvs_sendentry(root, entp) < 0)) {
cvs_ent_free(entp);
- return (-1);
+ return (CVS_EX_PROTO);
}
switch (cf->cf_cvstat) {
@@ -167,7 +167,7 @@ cvs_getlog_file(CVSFILE *cf, void *arg)
if (rf == NULL) {
if (entp != NULL)
cvs_ent_free(entp);
- return (-1);
+ return (CVS_EX_DATA);
}
rcs_close(rf);
diff --git a/usr.bin/cvs/history.c b/usr.bin/cvs/history.c
index 7ee0c78ea0f..39ce1338838 100644
--- a/usr.bin/cvs/history.c
+++ b/usr.bin/cvs/history.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: history.c,v 1.12 2005/04/11 18:02:58 joris Exp $ */
+/* $OpenBSD: history.c,v 1.13 2005/04/12 14:58:40 joris Exp $ */
/*
* Copyright (c) 2004 Jean-Francois Brousseau <jfb@openbsd.org>
* All rights reserved.
@@ -104,7 +104,7 @@ cvs_history_options(char *opt, int argc, char **argv, int *arg)
flags |= CVS_HF_M;
if (nbmod == CVS_HISTORY_MAXMOD) {
cvs_log(LP_ERR, "too many `-m' options");
- return (1);
+ return (CVS_EX_USAGE);
}
modules[nbmod++] = optarg;
break;
@@ -132,14 +132,14 @@ cvs_history_options(char *opt, int argc, char **argv, int *arg)
zone = optarg;
break;
default:
- return (1);
+ return (CVS_EX_USAGE);
}
}
if (rep > 1) {
cvs_log(LP_ERR,
"Only one report type allowed from: \"-Tcomxe\"");
- return (1);
+ return (CVS_EX_USAGE);
} else if (rep == 0)
flags |= CVS_HF_O; /* use -o as default */
@@ -152,26 +152,26 @@ cvs_history_sendflags(struct cvsroot *root)
{
if ((flags & CVS_HF_C) && (cvs_sendarg(root, "-c", 0) < 0))
- return (-1);
+ return (CVS_EX_PROTO);
if ((flags & CVS_HF_O) && (cvs_sendarg(root, "-o", 0) < 0))
- return (-1);
+ return (CVS_EX_PROTO);
if (tag != NULL) {
if ((cvs_sendarg(root, "-t", 0) < 0) ||
(cvs_sendarg(root, tag, 0) < 0))
- return (-1);
+ return (CVS_EX_PROTO);
}
if (user != NULL) {
if ((cvs_sendarg(root, "-u", 0) < 0) ||
(cvs_sendarg(root, user, 0) < 0))
- return (-1);
+ return (CVS_EX_PROTO);
}
if ((cvs_sendarg(root, "-z", 0) < 0) ||
(cvs_sendarg(root, zone, 0) < 0))
- return (-1);
+ return (CVS_EX_PROTO);
return (0);
}
diff --git a/usr.bin/cvs/import.c b/usr.bin/cvs/import.c
index 3ce3b51d09f..3b097c89350 100644
--- a/usr.bin/cvs/import.c
+++ b/usr.bin/cvs/import.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: import.c,v 1.10 2005/04/11 18:02:58 joris Exp $ */
+/* $OpenBSD: import.c,v 1.11 2005/04/12 14:58:40 joris Exp $ */
/*
* Copyright (c) 2004 Joris Vink <joris@openbsd.org>
* All rights reserved.
@@ -72,7 +72,7 @@ cvs_import_options(char *opt, int argc, char **argv, int *arg)
if ((bnum = rcsnum_parse(branch)) == NULL) {
cvs_log(LP_ERR, "%s is not a numeric branch",
branch);
- return (1);
+ return (CVS_EX_USAGE);
}
rcsnum_free(bnum);
break;
@@ -82,7 +82,7 @@ cvs_import_options(char *opt, int argc, char **argv, int *arg)
if (cvs_file_ignore(optarg) < 0) {
cvs_log(LP_ERR, "failed to add `%s' to list "
"of ignore patterns", optarg);
- return (1);
+ return (CVS_EX_USAGE);
}
break;
case 'k':
@@ -91,11 +91,11 @@ cvs_import_options(char *opt, int argc, char **argv, int *arg)
cvs_msg = strdup(optarg);
if (cvs_msg == NULL) {
cvs_log(LP_ERRNO, "failed to copy message");
- return (-1);
+ return (CVS_EX_DATA);
}
break;
default:
- return (1);
+ return (CVS_EX_USAGE);
}
}
@@ -104,7 +104,7 @@ cvs_import_options(char *opt, int argc, char **argv, int *arg)
*arg = optind;
if (argc > 4)
- return (1);
+ return (CVS_EX_USAGE);
module = argv[0];
vendor = argv[1];
@@ -112,7 +112,7 @@ cvs_import_options(char *opt, int argc, char **argv, int *arg)
if ((cvs_msg == NULL) &&
(cvs_msg = cvs_logmsg_get(NULL, NULL, NULL, NULL)) == NULL)
- return (-1);
+ return (CVS_EX_DATA);
return (0);
}
@@ -127,7 +127,7 @@ cvs_import_sendflags(struct cvsroot *root)
(cvs_sendarg(root, module, 0) < 0) ||
(cvs_sendarg(root, vendor, 0) < 0) ||
(cvs_sendarg(root, release, 0) < 0))
- return (-1);
+ return (CVS_EX_PROTO);
return (0);
}
@@ -169,9 +169,9 @@ cvs_import_file(CVSFILE *cfp, void *arg)
if (root->cr_method != CVS_METHOD_LOCAL) {
if (cvs_sendreq(root, CVS_REQ_MODIFIED, CVS_FILE_NAME(cfp)) < 0)
- return (-1);
+ return (CVS_EX_PROTO);
if (cvs_sendfile(root, fpath) < 0)
- return (-1);
+ return (CVS_EX_PROTO);
} else {
/* local import */
}
diff --git a/usr.bin/cvs/init.c b/usr.bin/cvs/init.c
index 0496bdfc609..59946c39c7c 100644
--- a/usr.bin/cvs/init.c
+++ b/usr.bin/cvs/init.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: init.c,v 1.13 2005/04/03 17:32:50 xsa Exp $ */
+/* $OpenBSD: init.c,v 1.14 2005/04/12 14:58:40 joris Exp $ */
/*
* Copyright (c) 2004 Jean-Francois Brousseau <jfb@openbsd.org>
* All rights reserved.
@@ -97,7 +97,7 @@ cvs_init_local(struct cvsroot *root)
if (mkdir(path, cvsroot_files[i].cf_mode) == -1) {
cvs_log(LP_ERRNO, "failed to create `%s'",
path);
- return (-1);
+ return (CVS_EX_FILE);
}
} else if (cvsroot_files[i].cf_type == CFT_FILE) {
fd = open(path, O_WRONLY|O_CREAT|O_EXCL,
@@ -105,7 +105,7 @@ cvs_init_local(struct cvsroot *root)
if (fd == -1) {
cvs_log(LP_ERRNO, "failed to create `%s'",
path);
- return (-1);
+ return (CVS_EX_FILE);
}
(void)close(fd);
@@ -113,7 +113,7 @@ cvs_init_local(struct cvsroot *root)
strlcat(path, RCS_FILE_EXT, sizeof(path));
rfp = rcs_open(path, RCS_WRITE|RCS_CREATE, 0640);
if (rfp == NULL) {
- return (-1);
+ return (CVS_EX_DATA);
}
rcs_close(rfp);
diff --git a/usr.bin/cvs/remove.c b/usr.bin/cvs/remove.c
index 69c7358ef4e..7cb42b8144b 100644
--- a/usr.bin/cvs/remove.c
+++ b/usr.bin/cvs/remove.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: remove.c,v 1.6 2005/04/11 18:02:58 joris Exp $ */
+/* $OpenBSD: remove.c,v 1.7 2005/04/12 14:58:40 joris Exp $ */
/*
* Copyright (c) 2004 Jean-Francois Brousseau <jfb@openbsd.org>
* Copyright (c) 2004 Xavier Santolaria <xsa@openbsd.org>
@@ -73,7 +73,7 @@ cvs_remove_options(char *opt, int argc, char **argv, int *arg)
case 'R':
break;
default:
- return (1);
+ return (CVS_EX_USAGE);
}
}
@@ -81,7 +81,7 @@ cvs_remove_options(char *opt, int argc, char **argv, int *arg)
argv += optind;
if (argc == 0)
- return (1);
+ return (CVS_EX_USAGE);
*arg = optind;
return (0);
@@ -118,7 +118,7 @@ cvs_remove_file(CVSFILE *cf, void *arg)
entfile = cvs_ent_open(dirname(fpath), O_RDWR);
if (entfile == NULL) {
cvs_log(LP_ERR, "failed to remove `%s'", fpath);
- return (-1);
+ return (CVS_EX_FILE);
}
ent = cvs_ent_get(entfile, CVS_FILE_NAME(cf));
@@ -132,7 +132,7 @@ cvs_remove_file(CVSFILE *cf, void *arg)
if((unlink(fpath) == -1) && (errno != ENOENT)) {
cvs_log(LP_ERRNO, "failed to unlink `%s'",
fpath);
- return (-1);
+ return (CVS_EX_FILE);
}
}
diff --git a/usr.bin/cvs/server.c b/usr.bin/cvs/server.c
index ae6ff6f0fd7..9f0442b428a 100644
--- a/usr.bin/cvs/server.c
+++ b/usr.bin/cvs/server.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: server.c,v 1.12 2005/04/11 18:02:58 joris Exp $ */
+/* $OpenBSD: server.c,v 1.13 2005/04/12 14:58:40 joris Exp $ */
/*
* Copyright (c) 2004 Jean-Francois Brousseau <jfb@openbsd.org>
* All rights reserved.
@@ -65,7 +65,7 @@ cvs_server(int argc, char **argv)
char reqbuf[512];
if (argc != 1) {
- return (1);
+ return (CVS_EX_USAGE);
}
/* make sure standard in and standard out are line-buffered */
@@ -77,7 +77,7 @@ cvs_server(int argc, char **argv)
if (feof(stdin))
break;
else if (ferror(stdin))
- return (-1);
+ return (CVS_EX_DATA);
}
len = strlen(reqbuf);
@@ -85,7 +85,7 @@ cvs_server(int argc, char **argv)
continue;
else if (reqbuf[len - 1] != '\n') {
cvs_log(LP_ERR, "truncated request");
- return (-1);
+ return (CVS_EX_PROTO);
}
reqbuf[--len] = '\0';
diff --git a/usr.bin/cvs/status.c b/usr.bin/cvs/status.c
index 911a6b29097..b0ea48ef2b6 100644
--- a/usr.bin/cvs/status.c
+++ b/usr.bin/cvs/status.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: status.c,v 1.13 2005/04/11 18:02:58 joris Exp $ */
+/* $OpenBSD: status.c,v 1.14 2005/04/12 14:58:40 joris Exp $ */
/*
* Copyright (c) 2004 Jean-Francois Brousseau <jfb@openbsd.org>
* All rights reserved.
@@ -83,7 +83,7 @@ cvs_status_options(char *opt, int argc, char **argv, int *arg)
verbose = 1;
break;
default:
- return (1);
+ return (CVS_EX_USAGE);
}
}
@@ -95,7 +95,7 @@ int
cvs_status_sendflags(struct cvsroot *root)
{
if (verbose && (cvs_sendarg(root, "-v", 0) < 0))
- return (-1);
+ return (CVS_EX_PROTO);
return (0);
}
@@ -136,7 +136,7 @@ cvs_status_file(CVSFILE *cfp, void *arg)
if (root->cr_method != CVS_METHOD_LOCAL) {
if ((entp != NULL) && (cvs_sendentry(root, entp) < 0)) {
cvs_ent_free(entp);
- return (-1);
+ return (CVS_EX_PROTO);
}
switch (cfp->cf_cvstat) {
@@ -169,7 +169,7 @@ cvs_status_file(CVSFILE *cfp, void *arg)
if (rf == NULL) {
if (entp != NULL)
cvs_ent_free(entp);
- return (-1);
+ return (CVS_EX_DATA);
}
rcs_close(rf);
diff --git a/usr.bin/cvs/tag.c b/usr.bin/cvs/tag.c
index a80a8950128..964edcb2bd4 100644
--- a/usr.bin/cvs/tag.c
+++ b/usr.bin/cvs/tag.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: tag.c,v 1.10 2005/04/11 18:02:58 joris Exp $ */
+/* $OpenBSD: tag.c,v 1.11 2005/04/12 14:58:40 joris Exp $ */
/*
* Copyright (c) 2004 Jean-Francois Brousseau <jfb@openbsd.org>
* Copyright (c) 2004 Joris Vink <joris@openbsd.org>
@@ -83,7 +83,7 @@ cvs_tag_options(char *opt, int argc, char **argv, int *arg)
old_tag = optarg;
break;
default:
- return (1);
+ return (CVS_EX_USAGE);
}
}
@@ -92,7 +92,7 @@ cvs_tag_options(char *opt, int argc, char **argv, int *arg)
argv += optind;
if (argc == 0) {
- return (1);
+ return (CVS_EX_USAGE);
} else {
tag = argv[0];
argc--;
@@ -113,7 +113,7 @@ cvs_tag_options(char *opt, int argc, char **argv, int *arg)
if (old_tag != NULL && date != NULL) {
cvs_log(LP_ERROR, "-r and -D options are mutually exclusive");
- return (-1);
+ return (CVS_EX_USAGE);
}
return (0);
@@ -123,25 +123,25 @@ int
cvs_tag_sendflags(struct cvsroot *root)
{
if (branch && (cvs_sendarg(root, "-b", 0) < 0))
- return (-1);
+ return (CVS_EX_PROTO);
if (delete && (cvs_sendarg(root, "-d", 0) < 0))
- return (-1);
+ return (CVS_EX_PROTO);
if (old_tag) {
if ((cvs_sendarg(root, "-r", 0) < 0) ||
(cvs_sendarg(root, old_tag, 0) < 0))
- return (-1);
+ return (CVS_EX_PROTO);
}
if (date) {
if ((cvs_sendarg(root, "-D", 0) < 0) ||
(cvs_sendarg(root, date, 0) < 0))
- return (-1);
+ return (CVS_EX_PROTO);
}
if (cvs_sendarg(root, tag, 0) < 0)
- return (-1);
+ return (CVS_EX_PROTO);
return (0);
}
@@ -167,7 +167,7 @@ cvs_tag_file(CVSFILE *cfp, void *arg)
if ((root->cr_method != CVS_METHOD_LOCAL) && (cfp->cf_type == DT_DIR)) {
if (cvs_senddir(root, cfp) < 0)
- return (-1);
+ return (CVS_EX_PROTO);
return (0);
}
@@ -177,7 +177,7 @@ cvs_tag_file(CVSFILE *cfp, void *arg)
if (root->cr_method != CVS_METHOD_LOCAL) {
if ((entp != NULL) && (cvs_sendentry(root, entp) < 0)) {
cvs_ent_free(entp);
- return (-1);
+ return (CVS_EX_PROTO);
}
switch (cfp->cf_cvstat) {
@@ -213,7 +213,7 @@ cvs_tag_file(CVSFILE *cfp, void *arg)
if (rf == NULL) {
if (entp != NULL)
cvs_ent_free(entp);
- return (-1);
+ return (CVS_EX_DATA);
}
rcs_close(rf);
diff --git a/usr.bin/cvs/update.c b/usr.bin/cvs/update.c
index eded1d2be6d..9556277ddcf 100644
--- a/usr.bin/cvs/update.c
+++ b/usr.bin/cvs/update.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: update.c,v 1.20 2005/04/11 18:02:58 joris Exp $ */
+/* $OpenBSD: update.c,v 1.21 2005/04/12 14:58:40 joris Exp $ */
/*
* Copyright (c) 2004 Jean-Francois Brousseau <jfb@openbsd.org>
* All rights reserved.
@@ -81,7 +81,7 @@ cvs_update_options(char *opt, int argc, char **argv, int *arg)
case 'r':
break;
default:
- return (1);
+ return (CVS_EX_USAGE);
}
}
@@ -129,7 +129,7 @@ cvs_update_file(CVSFILE *cf, void *arg)
if (root->cr_method != CVS_METHOD_LOCAL) {
if ((entp != NULL) && (cvs_sendentry(root, entp) < 0)) {
cvs_ent_free(entp);
- return (-1);
+ return (CVS_EX_PROTO);
}
switch (cf->cf_cvstat) {
@@ -160,7 +160,7 @@ cvs_update_file(CVSFILE *cf, void *arg)
rf = rcs_open(rcspath, RCS_READ);
if (rf == NULL) {
cvs_ent_free(entp);
- return (-1);
+ return (CVS_EX_DATA);
}
rcs_close(rf);