]> git.tuebingen.mpg.de Git - paraslash.git/blobdiff - net.c
Get rid of E_RECV.
[paraslash.git] / net.c
diff --git a/net.c b/net.c
index 0e41be1c3fa804c772f4547a16ac68ec8b42e262..2991b6db5c42b58c0028c371890739323662bba7 100644 (file)
--- a/net.c
+++ b/net.c
@@ -6,8 +6,8 @@
 
 /** \file net.c networking-related helper functions */
 
-#include "error.h"
 #include "para.h"
+#include "error.h"
 #include "net.h"
 #include "string.h"
 
@@ -120,7 +120,7 @@ static int sendall(int fd, const char *buf, size_t *len)
                total += n;
                bytesleft -= n;
                if (total < *len)
-                       PARA_DEBUG_LOG("short write (%zd byte(s) left)",
+                       PARA_DEBUG_LOG("short write (%zd byte(s) left)\n",
                                *len - total);
        }
        *len = total; /* return number actually sent here */
@@ -203,12 +203,10 @@ __printf_2_3 int send_va_buffer(int fd, const char *fmt, ...)
  * \param buf the buffer to write the decrypted data to
  * \param size the size of \a buf
  *
- * Receive at most \a size bytes from filedescriptor fd. If encryption is
+ * Receive at most \a size bytes from file descriptor \a fd. If encryption is
  * available, decrypt the received buffer.
  *
- * \return The number of bytes received on success. On receive errors, -E_RECV
- * is returned. On crypt errors, the corresponding crypt error number is
- * returned.
+ * \return The number of bytes received on success, negative on errors.
  *
  * \sa recv(2)
  */
@@ -232,7 +230,7 @@ __must_check int recv_bin_buffer(int fd, char *buf, size_t size)
        } else
                n = recv(fd, buf, size, 0);
        if (n == -1)
-               n = -E_RECV;
+               return -ERRNO_TO_PARA_ERROR(errno);
        return n;
 }
 
@@ -254,8 +252,7 @@ int recv_buffer(int fd, char *buf, size_t size)
 {
        int n;
 
-       if (!size)
-               return -E_RECV;
+       assert(size);
        n = recv_bin_buffer(fd, buf, size - 1);
        if (n >= 0)
                buf[n] = '\0';
@@ -284,14 +281,16 @@ int get_host_info(char *host, struct hostent **ret)
 }
 
 /**
- * a wrapper around socket(2)
+ * A wrapper around socket(2).
  *
- * Create an IPv4 socket for sequenced, reliable, two-way, connection-based
- * byte streams.
+ * \param domain The communication domain that selects the protocol family.
  *
  * \return The socket fd on success, -E_SOCKET on errors.
  *
- * \sa socket(2)
+ * Create an IPv4 socket for sequenced, reliable, two-way, connection-based
+ * byte streams.
+ *
+ * \sa socket(2).
  */
 int get_stream_socket(int domain)
 {