diff options
author | 2004-07-28 01:53:28 +0000 | |
---|---|---|
committer | 2004-07-28 01:53:28 +0000 | |
commit | 0d5dc07bf859f9573dec5f3e3eb0fcc132b05f9a (patch) | |
tree | 57da3d7897166bacfab57aa16b6dfc1cafb9d48f | |
parent | Add a newline at the end of the strings put in CVS/Root and (diff) | |
download | wireguard-openbsd-0d5dc07bf859f9573dec5f3e3eb0fcc132b05f9a.tar.xz wireguard-openbsd-0d5dc07bf859f9573dec5f3e3eb0fcc132b05f9a.zip |
* prepare for an overhaul of the connection code by adding a cvsroot
parameter to the cvs_client_connect() and cvs_client_disconnect()
functions, so we rely less and less on a global variable
-rw-r--r-- | usr.bin/cvs/client.c | 17 | ||||
-rw-r--r-- | usr.bin/cvs/cvs.h | 12 |
2 files changed, 19 insertions, 10 deletions
diff --git a/usr.bin/cvs/client.c b/usr.bin/cvs/client.c index 8b0451bc9cd..ba1d9d91591 100644 --- a/usr.bin/cvs/client.c +++ b/usr.bin/cvs/client.c @@ -1,4 +1,4 @@ -/* $OpenBSD: client.c,v 1.3 2004/07/27 13:08:23 jfb Exp $ */ +/* $OpenBSD: client.c,v 1.4 2004/07/28 01:53:28 jfb Exp $ */ /* * Copyright (c) 2004 Jean-Francois Brousseau <jfb@openbsd.org> * All rights reserved. @@ -78,12 +78,13 @@ static char cvs_client_buf[4096]; * cvs_client_connect() * * Open a client connection to the cvs server whose address is given in - * the global <cvs_root> variable. The method used to connect depends on the + * the <root> variable. The method used to connect depends on the * setting of the CVS_RSH variable. + * Returns 0 on success, or -1 on failure. */ int -cvs_client_connect(void) +cvs_client_connect(struct cvsroot *root) { int argc, infd[2], outfd[2]; pid_t pid; @@ -121,9 +122,9 @@ cvs_client_connect(void) argc = 0; argv[argc++] = cvs_rsh; - if (cvs_root->cr_user != NULL) { + if (root->cr_user != NULL) { argv[argc++] = "-l"; - argv[argc++] = cvs_root->cr_user; + argv[argc++] = root->cr_user; } @@ -131,7 +132,7 @@ cvs_client_connect(void) if (cvs_server_cmd == NULL) cvs_server_cmd = "cvs"; - argv[argc++] = cvs_root->cr_host; + argv[argc++] = root->cr_host; argv[argc++] = cvs_server_cmd; argv[argc++] = "server"; argv[argc] = NULL; @@ -156,6 +157,8 @@ cvs_client_connect(void) cvs_log(LP_ERRNO, "failed to create pipe stream"); return (-1); } + root->cr_srvin = cvs_server_in; + root->cr_srvout = cvs_server_out; /* make the streams line-buffered */ setvbuf(cvs_server_in, NULL, _IOLBF, 0); @@ -183,7 +186,7 @@ cvs_client_connect(void) */ void -cvs_client_disconnect(void) +cvs_client_disconnect(struct cvsroot *root) { cvs_log(LP_DEBUG, "closing client connection"); (void)fclose(cvs_server_in); diff --git a/usr.bin/cvs/cvs.h b/usr.bin/cvs/cvs.h index 4694917354e..99c43f018d0 100644 --- a/usr.bin/cvs/cvs.h +++ b/usr.bin/cvs/cvs.h @@ -1,4 +1,4 @@ -/* $OpenBSD: cvs.h,v 1.10 2004/07/27 12:01:58 jfb Exp $ */ +/* $OpenBSD: cvs.h,v 1.11 2004/07/28 01:53:29 jfb Exp $ */ /* * Copyright (c) 2004 Jean-Francois Brousseau <jfb@openbsd.org> * All rights reserved. @@ -230,6 +230,7 @@ struct cvs_op { struct cvsroot { + char *cr_str; u_int cr_method; char *cr_buf; char *cr_user; @@ -237,6 +238,11 @@ struct cvsroot { char *cr_host; char *cr_dir; u_int cr_port; + u_int cr_ref; + + /* connection data */ + FILE *cr_srvin; + FILE *cr_srvout; }; @@ -383,8 +389,8 @@ int cvs_recvfile (const char *); /* from client.c */ -int cvs_client_connect (void); -void cvs_client_disconnect (void); +int cvs_client_connect (struct cvsroot *); +void cvs_client_disconnect (struct cvsroot *); int cvs_client_sendreq (u_int, const char *, int); int cvs_client_sendarg (const char *, int); int cvs_client_sendln (const char *); |