summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--usr.bin/cvs/cvs.h22
-rw-r--r--usr.bin/cvs/proto.c37
-rw-r--r--usr.bin/cvs/root.c4
-rw-r--r--usr.bin/cvs/version.c4
4 files changed, 52 insertions, 15 deletions
diff --git a/usr.bin/cvs/cvs.h b/usr.bin/cvs/cvs.h
index 44ea445c0f5..ed621c3064c 100644
--- a/usr.bin/cvs/cvs.h
+++ b/usr.bin/cvs/cvs.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: cvs.h,v 1.18 2004/07/30 23:13:24 jfb Exp $ */
+/* $OpenBSD: cvs.h,v 1.19 2004/08/02 22:45:57 jfb Exp $ */
/*
* Copyright (c) 2004 Jean-Francois Brousseau <jfb@openbsd.org>
* All rights reserved.
@@ -32,8 +32,11 @@
#include <dirent.h>
#include "rcs.h"
+#include "file.h"
-#define CVS_VERSION "OpenCVS 0.1"
+#define CVS_VERSION_MAJOR 0
+#define CVS_VERSION_MINOR 2
+#define CVS_VERSION "OpenCVS 0.2"
#define CVS_HIST_CACHE 128
@@ -44,7 +47,7 @@
/* operations */
-#define CVS_OP_ANY 0 /* all operations */
+#define CVS_OP_UNKNOWN 0
#define CVS_OP_ADD 1
#define CVS_OP_ANNOTATE 2
#define CVS_OP_CHECKOUT 3
@@ -61,6 +64,7 @@
#define CVS_OP_UPDATE 14
#define CVS_OP_VERSION 15
+#define CVS_OP_ANY 64 /* all operations */
@@ -112,13 +116,14 @@
struct cvs_file;
struct cvs_dir;
-
+struct cvs_flist;
struct cvs_op {
- u_int co_op;
- uid_t co_uid; /* user performing the operation */
- char *co_path; /* target path of the operation */
- char *co_tag; /* tag or branch, NULL if HEAD */
+ u_int co_op;
+ uid_t co_uid; /* user performing the operation */
+ char *co_tag; /* tag or branch, NULL if HEAD */
+ char *co_msg; /* message string (on commit or add) */
+ struct cvs_flist co_files;
};
@@ -137,6 +142,7 @@ struct cvsroot {
/* connection data */
FILE *cr_srvin;
FILE *cr_srvout;
+ char *cr_version; /* version of remote server */
};
diff --git a/usr.bin/cvs/proto.c b/usr.bin/cvs/proto.c
index 2d64c90562a..afd590a2cc3 100644
--- a/usr.bin/cvs/proto.c
+++ b/usr.bin/cvs/proto.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: proto.c,v 1.16 2004/08/02 17:16:08 jfb Exp $ */
+/* $OpenBSD: proto.c,v 1.17 2004/08/02 22:45:57 jfb Exp $ */
/*
* Copyright (c) 2004 Jean-Francois Brousseau <jfb@openbsd.org>
* All rights reserved.
@@ -193,6 +193,15 @@ struct cvs_resp {
{ CVS_RESP_TEMPLATE, "Template", cvs_resp_template },
};
+#define CVS_NBREQ (sizeof(cvs_requests)/sizeof(cvs_requests[0]))
+#define CVS_NBRESP (sizeof(cvs_responses)/sizeof(cvs_responses[0]))
+
+
+/*
+ * The MT command uses scoping to tag the data. Whenever we encouter a '+',
+ * we push the name of the tag on the stack, and we pop it when we encounter
+ * a '-' with the same name.
+ */
static char *cvs_mt_stack[CVS_MTSTK_MAXDEPTH];
static u_int cvs_mtstk_depth = 0;
@@ -200,16 +209,18 @@ static u_int cvs_mtstk_depth = 0;
static time_t cvs_modtime = 0;
-#define CVS_NBREQ (sizeof(cvs_requests)/sizeof(cvs_requests[0]))
-#define CVS_NBRESP (sizeof(cvs_responses)/sizeof(cvs_responses[0]))
-
/* mask of requets supported by server */
static u_char cvs_server_validreq[CVS_REQ_MAX + 1];
+/* last checksum received */
char *cvs_fcksum = NULL;
mode_t cvs_lastmode = 0;
+/* hack to receive the remote version without outputting it */
+static u_int cvs_version_sent = 0;
+
+
static char cvs_proto_buf[4096];
/*
@@ -227,6 +238,9 @@ static FILE *cvs_server_outlog = NULL;
* Open a client connection to the cvs server whose address is given in
* the <root> variable. The method used to connect depends on the
* setting of the CVS_RSH variable.
+ * Once the connection has been established, we first send the list of
+ * responses we support and request the list of supported requests from the
+ * server. Then, a version request is sent and various global flags are sent.
* Returns 0 on success, or -1 on failure.
*/
@@ -331,6 +345,9 @@ cvs_connect(struct cvsroot *root)
return (-1);
}
+ if (cvs_sendreq(root, CVS_REQ_VERSION, NULL) < 0)
+ cvs_log(LP_ERR, "failed to get remote version");
+
/* now share our global options with the server */
if (verbosity == 1)
cvs_sendreq(root, CVS_REQ_GLOBALOPT, "-q");
@@ -675,6 +692,15 @@ cvs_resp_m(struct cvsroot *root, int type, char *line)
fflush(stderr);
return (0);
case CVS_RESP_M:
+ if (cvs_version_sent) {
+ /*
+ * Instead of outputting the line, we save it as the
+ * remote server's version string.
+ */
+ cvs_version_sent = 0;
+ root->cr_version = strdup(line);
+ return (0);
+ }
stream = stdout;
break;
case CVS_RESP_E:
@@ -1316,6 +1342,9 @@ cvs_sendreq(struct cvsroot *root, u_int rid, const char *arg)
return (-1);
}
+ if (rid == CVS_REQ_VERSION)
+ cvs_version_sent = 1;
+
if (req->req_flags & CVS_REQF_RESP)
ret = cvs_getresp(root);
diff --git a/usr.bin/cvs/root.c b/usr.bin/cvs/root.c
index a4e58d37d9b..efadc8920b6 100644
--- a/usr.bin/cvs/root.c
+++ b/usr.bin/cvs/root.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: root.c,v 1.8 2004/07/30 01:49:24 jfb Exp $ */
+/* $OpenBSD: root.c,v 1.9 2004/08/02 22:45:57 jfb Exp $ */
/*
* Copyright (c) 2004 Jean-Francois Brousseau <jfb@openbsd.org>
* All rights reserved.
@@ -233,6 +233,8 @@ cvsroot_free(struct cvsroot *root)
free(root->cr_str);
if (root->cr_buf != NULL)
free(root->cr_buf);
+ if (root->cr_version != NULL)
+ free(root->cr_version);
free(root);
}
}
diff --git a/usr.bin/cvs/version.c b/usr.bin/cvs/version.c
index 38b5b76aaef..ce019a3df2d 100644
--- a/usr.bin/cvs/version.c
+++ b/usr.bin/cvs/version.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: version.c,v 1.4 2004/07/30 01:49:25 jfb Exp $ */
+/* $OpenBSD: version.c,v 1.5 2004/08/02 22:45:57 jfb Exp $ */
/*
* Copyright (c) 2004 Jean-Francois Brousseau <jfb@openbsd.org>
* All rights reserved.
@@ -55,8 +55,8 @@ cvs_version(int argc, char **argv)
if (cvs_connect(root) < 0)
return (1);
- printf("Server: ");
cvs_sendreq(root, CVS_REQ_VERSION, NULL);
+ printf("Server: %s\n", root->cr_version);
cvs_disconnect(root);
}