* net: constify buffer argument of send_to(); #include stdlib.h; fixed comment
authorUrban Wallasch <urban.wallasch@freenet.de>
Fri, 25 Oct 2019 15:32:08 +0000 (17:32 +0200)
committerUrban Wallasch <urban.wallasch@freenet.de>
Fri, 25 Oct 2019 15:32:08 +0000 (17:32 +0200)
net/net.c
net/net.h

index 0b048bfa0c2688dafda403a1e19c401293d4c12a..296155eaabd8da32bb40710ffaad79b0fd08272e 100644 (file)
--- a/net/net.c
+++ b/net/net.c
@@ -14,6 +14,7 @@
 
 #include <errno.h>
 #include <stdio.h>
+#include <stdlib.h>
 #include <string.h>
 #include <unistd.h>
 #include <poll.h>
@@ -37,7 +38,6 @@
 #endif
 
 #ifdef NET_ERR
-#include <stdlib.h>
 
 /* Log helper function: create "host:port" string from socket address: */
 static char *addr2str(const struct sockaddr *addr, socklen_t addrlen,
@@ -354,7 +354,7 @@ ssize_t recvfrom_tm(int fd, void *buf, size_t len, int flags,
 }
 
 /* Write to socket or file descriptor: */
-ssize_t sendto_tm(int fd, void *buf, size_t len, int flags,
+ssize_t sendto_tm(int fd, const void *buf, size_t len, int flags,
                   const struct sockaddr *addr, socklen_t alen, int timeout) {
     ssize_t r;
     struct pollfd pfd;
index 0a793fe1924a8305fde066f0be2489ee246735eb..a57f50bfc1e50d08e84fc0b9dadf4f357e0f9278 100644 (file)
--- a/net/net.h
+++ b/net/net.h
@@ -27,6 +27,8 @@
  * send_tm
  * write_tm        - functions and macros to write with timeout
  *
+ * sendfile_tm     - copy data from one file descriptor to another
+ *
  */
 
 #ifndef NET_H_
@@ -217,7 +219,7 @@ extern ssize_t recvfrom_tm(int fd, void *buf, size_t len, int flags,
  * flags, addr and alen are ignored, and performance may be slightly
  * inferior compared to a plain write() call.
  */
-extern ssize_t sendto_tm(int fd, void *buf, size_t len, int flags,
+extern ssize_t sendto_tm(int fd, const void *buf, size_t len, int flags,
                const struct sockaddr *addr, socklen_t alen, int timeout);
 /*
  * Shorthand macros to closely match send() and write() prototypes: