bug-cvs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH] clarify global from_/to_server [2/2]


From: Alexey Mahotkin
Subject: [PATCH] clarify global from_/to_server [2/2]
Date: Fri, 02 May 2003 02:41:09 +0400
User-agent: Gnus/5.090006 (Oort Gnus v0.06) XEmacs/21.4 (Common Lisp, i386-debian-linux)

2003-05-02  Alexey Mahotkin <address@hidden>

Create send_to_server_via(), which takes buffer to send to as an
argument.  
send_to_server is now send_to_server_via(global_to_server).

Create read_line_via(), which takes buffers receive from and to send
to as arguments.  
read_line is now read_line_via(global_from_server, global_to_server).

Get rid of emotional comment (and the accompanying ugly code).  In
particular, rename lfrom_/lto_server to from_/to_server.


 src/client.c |   76 ++++++++++++++++++++++++++++++++---------------------------
 1 files changed, 42 insertions(+), 34 deletions(-)

--- ccvs/src/client.c~via_buffer        Fri May  2 02:05:14 2003
+++ ccvs-alexm/src/client.c     Fri May  2 02:27:41 2003
@@ -417,18 +417,20 @@ static struct buffer *global_from_server
  * Returns number of bytes read.
  */
 static int
-read_line (resultp)
+read_line_via (via_from_buffer, via_to_buffer, resultp)
+    struct buffer *via_from_buffer;
+    struct buffer *via_to_buffer;
     char **resultp;
 {
     int status;
     char *result;
     int len;
 
-    status = buf_flush (global_to_server, 1);
+    status = buf_flush (via_to_buffer, 1);
     if (status != 0)
        error (1, status, "writing to server");
 
-    status = buf_read_line (global_from_server, &result, &len);
+    status = buf_read_line (via_from_buffer, &result, &len);
     if (status != 0)
     {
        if (status == -1)
@@ -447,6 +449,14 @@ read_line (resultp)
     return len;
 }
 
+static int
+read_line (resultp)
+    char **resultp;
+{
+  return read_line_via (global_from_server, global_to_server, resultp);
+}
+
+
 #endif /* CLIENT_SUPPORT */
 
 
@@ -3034,13 +3044,14 @@ struct response responses[] =
 #ifdef CLIENT_SUPPORT
 
 /* 
- * If LEN is 0, then send_to_server() computes string's length itself.
+ * If LEN is 0, then send_to_server_via() computes string's length itself.
  *
  * Therefore, pass the real length when transmitting data that might
  * contain 0's.
  */
 void
-send_to_server (str, len)
+send_to_server_via (via_buffer, str, len)
+     struct buffer *via_buffer;
      char *str;
      size_t len;
 {
@@ -3049,7 +3060,7 @@ send_to_server (str, len)
     if (len == 0)
        len = strlen (str);
 
-    buf_output (global_to_server, str, len);
+    buf_output (via_buffer, str, len);
       
     /* There is no reason not to send data to the server, so do it
        whenever we've accumulated enough information in the buffer to
@@ -3059,13 +3070,22 @@ send_to_server (str, len)
     {
        int status;
 
-        status = buf_send_output (global_to_server);
+        status = buf_send_output (via_buffer);
        if (status != 0)
            error (1, status, "error writing to server");
        nbytes = 0;
     }
 }
 
+void
+send_to_server (str, len)
+     char *str;
+     size_t len;
+{
+  send_to_server_via (global_to_server, str, len);
+}
+
+
 /* Read up to LEN bytes from the server.  Returns actual number of
    bytes read, which will always be at least one; blocks if there is
    no data available at all.  Gives a fatal error on EOF or error.  */
@@ -3508,10 +3528,10 @@ connect_to_pserver (root, to_server_p, f
 
 
 static void
-auth_server (root, lto_server, lfrom_server, verify_only, do_gssapi, hostinfo)
+auth_server (root, to_server, from_server, verify_only, do_gssapi, hostinfo)
     cvsroot_t *root;
-    struct buffer *lto_server;
-    struct buffer *lfrom_server;
+    struct buffer *to_server;
+    struct buffer *from_server;
     int verify_only;
     int do_gssapi;
     struct hostent *hostinfo;
@@ -3519,23 +3539,11 @@ auth_server (root, lto_server, lfrom_ser
     char *username;                    /* the username we use to connect */
     char no_passwd = 0;                        /* gets set if no password 
found */
 
-    /* FIXME!!!!!!!!!!!!!!!!!!
-     *
-     * THIS IS REALLY UGLY!
-     *
-     * I'm setting the globals here so we can make calls to send_to_server &
-     * read_line.  This happens again _after_ we return if we're not in
-     * verify_only mode.  We should be relying on the values we passed in, but
-     * sent_to_server and read_line don't require an outside buf yet.
-     */
-    global_to_server = lto_server;
-    global_from_server = lfrom_server;
-
     /* Run the authorization mini-protocol before anything else. */
     if (do_gssapi)
     {
 # ifdef HAVE_GSSAPI
-       FILE *fp = stdio_buffer_get_file(lto_server);
+       FILE *fp = stdio_buffer_get_file(to_server);
        int fd = fp ? fileno(fp) : -1;
        struct stat s;
 
@@ -3585,20 +3593,20 @@ auth_server (root, lto_server, lfrom_ser
        }
 
        /* Announce that we're starting the authorization protocol. */
-       send_to_server(begin, 0);
-       send_to_server("\012", 1);
+       send_to_server_via(to_server, begin, 0);
+       send_to_server_via(to_server, "\012", 1);
 
        /* Send the data the server needs. */
-       send_to_server(root->directory, 0);
-       send_to_server("\012", 1);
-       send_to_server(username, 0);
-       send_to_server("\012", 1);
-       send_to_server(password, 0);
-       send_to_server("\012", 1);
+       send_to_server_via(to_server, root->directory, 0);
+       send_to_server_via(to_server, "\012", 1);
+       send_to_server_via(to_server, username, 0);
+       send_to_server_via(to_server, "\012", 1);
+       send_to_server_via(to_server, password, 0);
+       send_to_server_via(to_server, "\012", 1);
 
        /* Announce that we're ending the authorization protocol. */
-       send_to_server(end, 0);
-       send_to_server("\012", 1);
+       send_to_server_via(to_server, end, 0);
+       send_to_server_via(to_server, "\012", 1);
 
         /* Paranoia. */
         memset (password, 0, strlen (password));
@@ -3613,7 +3621,7 @@ auth_server (root, lto_server, lfrom_ser
        /* Loop, getting responses from the server.  */
        while (1)
        {
-           read_line (&read_buf);
+           read_line_via (from_server, to_server, &read_buf);
 
            if (strcmp (read_buf, "I HATE YOU") == 0)
            {

_


--alexm




reply via email to

[Prev in Thread] Current Thread [Next in Thread]