[ds6-devel] nc6/src io_stream.c,1.4,1.5 misc.c,1.8,1.9 misc.h,1.9,1.10 network.c,1.15,1.16 parser.c,1.12,1.13 readwrite.c,1.15,1.16

mauro@deepspace6.net mauro@deepspace6.net
Tue Dec 24 20:20:33 2002


Update of /cvs/nc6/src

Modified Files:
	io_stream.c misc.c misc.h network.c parser.c readwrite.c 
Log Message:
finished reworking the code layout

Index: io_stream.c
===================================================================
RCS file: /cvs/nc6/src/io_stream.c,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -d -r1.4 -r1.5
--- io_stream.c	24 Dec 2002 20:08:43 -0000	1.4
+++ io_stream.c	24 Dec 2002 20:20:31 -0000	1.5
@@ -38,7 +38,7 @@
 
 void io_stream_init(io_stream *ios)
 {
-	assert(ios);
+	assert(ios != NULL);
 
 	ios->fd_in = -1;
 	ios->fd_out = -1;
@@ -51,7 +51,7 @@
 
 void io_stream_destroy(io_stream *ios)
 {
-	assert(ios);
+	assert(ios != NULL);
 	ios_shutdown(ios, SHUT_RDWR);
 }
 
@@ -59,7 +59,7 @@
 
 void ios_assign_socket(io_stream *ios, int fd, int socktype)
 {
-	assert(ios);
+	assert(ios != NULL);
 	assert(fd >= 0);
 
 	/* nonblock(fd); */
@@ -72,7 +72,7 @@
 
 void ios_assign_stdio(io_stream *ios)
 {
-	assert(ios);
+	assert(ios != NULL);
 
 	if ((ios->fd_in  = dup(STDIN_FILENO)) < 0) 
 		fatal("error in duplicating stdin file descriptor: %s", 
@@ -92,12 +92,11 @@
 
 void ios_shutdown(io_stream* ios, int how)
 {
-	assert(ios);
+	assert(ios != NULL);
 
 	if (how == SHUT_RDWR) {
 		/* close both the input and the output */
-		if (ios->fd_in != -1)
-		{
+		if (ios->fd_in != -1) {
 			close(ios->fd_in);
 			/* record the read shutdown time */
 			gettimeofday(&(ios->read_closed), NULL);
@@ -138,8 +137,8 @@
 {
 	struct timeval now;
 
-	assert(ios);
-	assert(tv);
+	assert(ios != NULL);
+	assert(tv != NULL);
 
 	/* no timeout if read is still open or hold time is infinite */
 	if (is_read_open(ios) || ios->hold_time < 0)
Index: misc.c
===================================================================
RCS file: /cvs/nc6/src/misc.c,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -d -r1.8 -r1.9
--- misc.c	24 Dec 2002 20:08:43 -0000	1.8
+++ misc.c	24 Dec 2002 20:20:31 -0000	1.9
@@ -86,6 +86,7 @@
 char *xstrdup(const char *str)
 {
 	register char *nstr = (char*)xmalloc(strlen(str));
+	/* we should use srtlcpy here instead of strcpy */
 	strcpy(nstr, str);
 	return nstr;
 }
Index: misc.h
===================================================================
RCS file: /cvs/nc6/src/misc.h,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -d -r1.9 -r1.10
--- misc.h	24 Dec 2002 14:54:00 -0000	1.9
+++ misc.h	24 Dec 2002 20:20:31 -0000	1.10
@@ -30,7 +30,7 @@
 #undef  MIN
 #define MIN(a,b) (((a)<(b))?(a):(b))
 
-#undef XOR
+#undef  XOR
 #define XOR(a,b) (((a)||(b)) && !((a)&&(b)))
 
 typedef enum { FALSE = 0, TRUE = 1 } bool;
Index: network.c
===================================================================
RCS file: /cvs/nc6/src/network.c,v
retrieving revision 1.15
retrieving revision 1.16
diff -u -d -r1.15 -r1.16
--- network.c	24 Dec 2002 20:08:43 -0000	1.15
+++ network.c	24 Dec 2002 20:20:31 -0000	1.16
@@ -44,8 +44,7 @@
  * ipv6 addresses to the start of the getaddrinfo results.
  */
 #ifdef ENABLE_IPV6
-inline
-static struct addrinfo* order_ipv6_first(struct addrinfo *ai)
+inline static struct addrinfo* order_ipv6_first(struct addrinfo *ai)
 {
 	struct addrinfo* ptr;
 	struct addrinfo* lastv6 = NULL;
@@ -87,8 +86,7 @@
  * used - resulting in a failure when trying to create the socket.
  * This function checks for all the different error codes that indicate this
  * situation */
-inline
-static bool unsupported_sock_error(int err)
+inline static bool unsupported_sock_error(int err)
 {
 	return (err == EPFNOSUPPORT ||
 	        err == EAFNOSUPPORT ||
@@ -160,8 +158,8 @@
 
 		/* get the numeric name for this destination as a string */
 		err = getnameinfo(ptr->ai_addr, ptr->ai_addrlen,
-		        hbuf_num, sizeof(hbuf_num), sbuf_num, 
-		        sizeof(sbuf_num), NI_NUMERICHOST | NI_NUMERICSERV);
+		                  hbuf_num, sizeof(hbuf_num), sbuf_num, 
+		                  sizeof(sbuf_num), NI_NUMERICHOST | NI_NUMERICSERV);
 
 		/* this should never happen */
 		if (err != 0)
@@ -173,12 +171,12 @@
 		{
 			/* get the real name for this destination as a string */
 			err = getnameinfo(ptr->ai_addr, ptr->ai_addrlen,
-					hbuf_rev, sizeof(hbuf_rev), sbuf_rev, 
-					sizeof(sbuf_rev), 0);
+			                  hbuf_rev, sizeof(hbuf_rev), sbuf_rev, 
+			                  sizeof(sbuf_rev), 0);
 
 			if (err != 0)
 				warn("inverse lookup failed for %s: %s",
-					 hbuf_num, gai_strerror(err));
+				     hbuf_num, gai_strerror(err));
 		} else {
 			err = 1;
 		}
@@ -209,8 +207,7 @@
 #endif 
 
 		/* setup local source address and/or service */
-		if (local->address != NULL || local->service != NULL)
-		{
+		if (local->address != NULL || local->service != NULL) {
 			struct addrinfo *src_res = NULL, *src_ptr;
 		
 			/* setup hints structure to be passed to getaddrinfo */
@@ -227,7 +224,7 @@
 			err = getaddrinfo(local->address, local->service, &hints, &src_res);
 			if (err != 0)
 				fatal("forward host lookup failed for source address %s: %s",
-				     local->address, gai_strerror(err));
+				      local->address, gai_strerror(err));
 
 			/* check the results of getaddrinfo */
 			assert(src_res != NULL);
@@ -246,9 +243,9 @@
 				
 				if (is_flag_set(VERBOSE_MODE) == TRUE) {
 					warn("bind to source addr/port failed "
-						 "when connecting %s [%s] %s (%s): %s",
-						 hbuf_rev, hbuf_num, sbuf_num, sbuf_rev,
-						 strerror(errno));
+				             "when connecting %s [%s] %s (%s): %s",
+					     hbuf_rev, hbuf_num, sbuf_num, sbuf_rev,
+					     strerror(errno));
 				}
 				freeaddrinfo(src_res);
 				close(fd);
@@ -264,7 +261,7 @@
 		if (err != 0) {
 			if (is_flag_set(VERBOSE_MODE) == TRUE) {
 				warn("%s [%s] %s (%s): %s",
-				    hbuf_rev, hbuf_num, sbuf_num, sbuf_rev, strerror(errno));
+				     hbuf_rev, hbuf_num, sbuf_num, sbuf_rev, strerror(errno));
 			}
 			close(fd);
 			fd = -1;
@@ -293,7 +290,7 @@
 
 	if (is_flag_set(VERY_VERBOSE_MODE) == TRUE) {
 		warn("using %s socket",
[...139 lines suppressed...]
Index: parser.c
===================================================================
RCS file: /cvs/nc6/src/parser.c,v
retrieving revision 1.12
retrieving revision 1.13
diff -u -d -r1.12 -r1.13
--- parser.c	24 Dec 2002 20:08:43 -0000	1.12
+++ parser.c	24 Dec 2002 20:20:31 -0000	1.13
@@ -37,7 +37,7 @@
 static unsigned long flags_mask;
 static void set_flag(unsigned long mask);
 static void parse_and_set_timeouts(const char *str,
-		connection_attributes *attrs);
+                                   connection_attributes *attrs);
 static void print_usage(FILE *fp);
 
 
@@ -144,14 +144,12 @@
 
 	/* sanity check */
 	if (attrs->remote_address.address != NULL &&
-		strlen(attrs->remote_address.address) == 0)
-	{
+		strlen(attrs->remote_address.address) == 0) {
 		attrs->remote_address.address = NULL;
 	}
 
 	if (attrs->remote_address.service != NULL &&
-		strlen(attrs->remote_address.service) == 0)
-	{
+		strlen(attrs->remote_address.service) == 0) {
 		attrs->remote_address.service = NULL;
 	}
 
@@ -171,8 +169,7 @@
 		}
 		
 		if (attrs->remote_address.address == NULL ||
-		    attrs->remote_address.service == NULL)
-		{
+		    attrs->remote_address.service == NULL) {
 			warn("you must specify the address/port couple of the remote endpoint");
 			print_usage(stderr);
 			exit(EXIT_FAILURE);
@@ -219,11 +216,11 @@
 	if ((s = strchr(str, ':')) != NULL) {
 		*s++ = '\0';
 		ios_set_hold_timeout(&(attrs->remote_stream),
-		      (s[0] == '-')? -1 : safe_atoi(s));
+		                     (s[0] == '-')? -1 : safe_atoi(s));
 	}
 
 	ios_set_hold_timeout(&(attrs->local_stream),
-	      (str[0] == '-')? -1 : safe_atoi(str));
+	                     (str[0] == '-')? -1 : safe_atoi(str));
 }
 
 
Index: readwrite.c
===================================================================
RCS file: /cvs/nc6/src/readwrite.c,v
retrieving revision 1.15
retrieving revision 1.16
diff -u -d -r1.15 -r1.16
--- readwrite.c	24 Dec 2002 20:08:43 -0000	1.15
+++ readwrite.c	24 Dec 2002 20:20:31 -0000	1.16
@@ -132,16 +132,16 @@
 		/* sanity checks */
 		/* writefd should be set iff the buffer contains data */
 		assert(XOR(is_empty(buf1) == TRUE,
-		    is_write_open(ios2) && FD_ISSET(ios_writefd(ios2), &write_fdset)));
+		       is_write_open(ios2) && FD_ISSET(ios_writefd(ios2), &write_fdset)));
 		assert(XOR((is_empty(buf2) == TRUE),
-		    is_write_open(ios1) && FD_ISSET(ios_writefd(ios1), &write_fdset)));
+		       is_write_open(ios1) && FD_ISSET(ios_writefd(ios1), &write_fdset)));
 		/* readfd should be set (or closed) iff the buffer is not full
 		 * or tbuf1 is in use and it still contains data */
 		assert(XOR(
-		    (tbuf1 && tbuf1_bytes > 0) || (!tbuf1 && is_full(buf1) == TRUE),
-		    !is_read_open(ios1) || FD_ISSET(ios_readfd(ios1), &read_fdset)));
+		       (tbuf1 && tbuf1_bytes > 0) || (!tbuf1 && is_full(buf1) == TRUE),
+		       !is_read_open(ios1) || FD_ISSET(ios_readfd(ios1), &read_fdset)));
 		assert(XOR(is_full(buf2) == TRUE,
-		    !is_read_open(ios2) || FD_ISSET(ios_readfd(ios2), &read_fdset)));
+		       !is_read_open(ios2) || FD_ISSET(ios_readfd(ios2), &read_fdset)));
 		/* if tbuf1 is not being used, tbuf1_bytes must be 0 */
 		assert(tbuf1 || tbuf1_bytes == 0);
 
@@ -219,8 +219,7 @@
 				 * OR if reading straight to buf1 and it's full,
 				 * then suspend further reading */
 				if ((tbuf1 && tbuf1_bytes > 0) ||
-				    (!tbuf1 && is_full(buf1) == TRUE))
-				{
+				    (!tbuf1 && is_full(buf1) == TRUE)) {
 					FD_CLR(ios_readfd(ios1), &read_fdset);
 				}
 				    



More information about the ds6-devel mailing list