changeset 393:318a71f4f57f

Rename some internal variables and add new buffer pointer one.
author Matti Hamalainen <ccr@tnsp.org>
date Thu, 24 May 2012 04:33:21 +0300
parents a21cc444d800
children cabf2233ea39
files libnnchat.c libnnchat.h
diffstat 2 files changed, 11 insertions(+), 11 deletions(-) [+]
line wrap: on
line diff
--- a/libnnchat.c	Thu May 24 00:56:15 2012 +0300
+++ b/libnnchat.c	Thu May 24 04:33:21 2012 +0300
@@ -358,11 +358,12 @@
 {
     if (conn != NULL)
     {
-        conn->ptr = conn->buf;
-        conn->got = conn->total = 0;
+        conn->got_ptr = conn->buf;
+        conn->got_bytes = conn->total_bytes = 0;
     }
 }
 
+
 int nn_conn_pull(nn_conn_t *conn)
 {
     int result;
@@ -389,14 +390,14 @@
     }
     else if (FD_ISSET(conn->socket, &tmpfds))
     {
-        conn->got = recv(conn->socket, conn->ptr, NN_CONNBUF_SIZE - conn->total, 0);
-        if (conn->got < 0)
+        conn->got_bytes = recv(conn->socket, conn->got_ptr, NN_CONNBUF_SIZE - conn->total_bytes, 0);
+        if (conn->got_bytes < 0)
         {
             conn->err = nn_get_socket_errno();
             nn_conn_err(conn, "Error in recv: %d, %s\n", conn->err, nn_get_socket_errstr(conn->err));
             return -2;
         }
-        else if (conn->got == 0)
+        else if (conn->got_bytes == 0)
         {
             nn_conn_err(conn, "Server closed connection.\n");
             conn->status = NN_CONN_CLOSED;
@@ -404,9 +405,8 @@
         }
         else
         {
-            /* Handle protocol data */
-            conn->total += conn->got;
-            conn->ptr += conn->got;
+            conn->total_bytes += conn->got_bytes;
+            conn->got_ptr += conn->got_bytes;
             return 0;
         }
     }
@@ -414,6 +414,7 @@
     return 1;
 }
 
+
 BOOL nn_conn_check(nn_conn_t *conn)
 {
     if (conn == NULL)
@@ -423,7 +424,6 @@
 }
 
 
-
 BOOL nn_network_init(void)
 {
 #ifdef __WIN32
--- a/libnnchat.h	Thu May 24 00:56:15 2012 +0300
+++ b/libnnchat.h	Thu May 24 04:33:21 2012 +0300
@@ -100,8 +100,8 @@
     int status;
 
     char buf[NN_CONNBUF_SIZE + 16];
-    char *ptr;
-    ssize_t got, total;
+    char *ptr, *got_ptr;
+    ssize_t got_bytes, total_bytes;
 } nn_conn_t;