changeset 4745:7ee0bb1b2d97 HEAD

Changed ips_count to unsigned int in net_gethostbyname(). Also removed duplicated API comments from network.c.
author Timo Sirainen <tss@iki.fi>
date Sat, 04 Nov 2006 20:45:01 +0200
parents 757f5dce4f21
children 5b92d300941f
files src/lib/network.c src/lib/network.h src/master/main.c
diffstat 3 files changed, 6 insertions(+), 19 deletions(-) [+]
line wrap: on
line diff
--- a/src/lib/network.c	Sat Nov 04 20:43:26 2006 +0200
+++ b/src/lib/network.c	Sat Nov 04 20:45:01 2006 +0200
@@ -102,7 +102,6 @@
 	return 0;
 }
 
-/* Connect to socket with ip address */
 int net_connect_ip(const struct ip_addr *ip, unsigned int port,
 		   const struct ip_addr *my_ip)
 {
@@ -190,14 +189,12 @@
 	return fd;
 }
 
-/* Disconnect socket */
 void net_disconnect(int fd)
 {
 	if (close(fd) < 0)
 		i_error("net_disconnect() failed: %m");
 }
 
-/* Set socket blocking/nonblocking */
 void net_set_nonblock(int fd, bool nonblock)
 {
 	if (fd_set_nonblock(fd, nonblock) < 0)
@@ -234,8 +231,6 @@
 #endif
 }
 
-/* Listen for connections on a socket. if `my_ip' is NULL, listen in any
-   address. */
 int net_listen(const struct ip_addr *my_ip, unsigned int *port, int backlog)
 {
 	union sockaddr_union so;
@@ -340,7 +335,6 @@
 	return -1;
 }
 
-/* Accept a connection on a socket */
 int net_accept(int fd, struct ip_addr *addr, unsigned int *port)
 {
 	union sockaddr_union so;
@@ -366,7 +360,6 @@
 	return ret;
 }
 
-/* Read data from socket, return number of bytes read, -1 = error */
 ssize_t net_receive(int fd, void *buf, size_t len)
 {
 	ssize_t ret;
@@ -395,7 +388,6 @@
 	return ret;
 }
 
-/* Transmit data, return number of bytes sent, -1 = error */
 ssize_t net_transmit(int fd, const void *data, size_t len)
 {
         ssize_t ret;
@@ -414,9 +406,8 @@
         return ret;
 }
 
-/* Get IP addresses for host. ips contains ips_count of IPs, they don't need
-   to be free'd. Returns 0 = ok, others = error code for net_gethosterror() */
-int net_gethostbyname(const char *addr, struct ip_addr **ips, int *ips_count)
+int net_gethostbyname(const char *addr, struct ip_addr **ips,
+		      unsigned int *ips_count)
 {
 	/* @UNSAFE */
 #ifdef HAVE_IPV6
@@ -489,7 +480,6 @@
 	return 0;
 }
 
-/* Get socket address/port */
 int net_getsockname(int fd, struct ip_addr *addr, unsigned int *port)
 {
 	union sockaddr_union so;
@@ -590,7 +580,6 @@
 #endif
 }
 
-/* Get socket error */
 int net_geterror(int fd)
 {
 	int data;
@@ -602,7 +591,6 @@
 	return data;
 }
 
-/* get error of net_gethostname() */
 const char *net_gethosterror(int error)
 {
 #ifdef HAVE_IPV6
@@ -631,8 +619,6 @@
 #endif
 }
 
-/* return TRUE if host lookup failed because it didn't exist (ie. not
-   some error with name server) */
 int net_hosterror_notfound(int error)
 {
 #ifdef HAVE_IPV6
@@ -646,7 +632,6 @@
 #endif
 }
 
-/* Get name of TCP service */
 const char *net_getservbyport(unsigned short port)
 {
 	struct servent *entry;
--- a/src/lib/network.h	Sat Nov 04 20:43:26 2006 +0200
+++ b/src/lib/network.h	Sat Nov 04 20:45:01 2006 +0200
@@ -77,7 +77,8 @@
 
 /* Get IP addresses for host. ips contains ips_count of IPs, they don't need
    to be free'd. Returns 0 = ok, others = error code for net_gethosterror() */
-int net_gethostbyname(const char *addr, struct ip_addr **ips, int *ips_count);
+int net_gethostbyname(const char *addr, struct ip_addr **ips,
+		      unsigned int *ips_count);
 /* get error of net_gethostname() */
 const char *net_gethosterror(int error);
 /* return TRUE if host lookup failed because it didn't exist (ie. not
--- a/src/master/main.c	Sat Nov 04 20:43:26 2006 +0200
+++ b/src/master/main.c	Sat Nov 04 20:45:01 2006 +0200
@@ -252,7 +252,8 @@
 {
 	struct ip_addr *ip_list;
 	const char *p;
-	int ret, ips_count;
+	unsigned int ips_count;
+	int ret;
 
 	if (*name == '\0') {
                 /* defaults to "*" or "[::]" */