[Olsr-cvs] olsrd-current/lib/httpinfo/src olsrd_httpinfo.c, 1.54, 1.55

Andreas T�nnesen (spam-protected)
Fri Dec 16 16:16:44 CET 2005


Update of /cvsroot/olsrd/olsrd-current/lib/httpinfo/src
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv23717/src

Modified Files:
	olsrd_httpinfo.c 
Log Message:
Added patch from Sven-Ola

Index: olsrd_httpinfo.c
===================================================================
RCS file: /cvsroot/olsrd/olsrd-current/lib/httpinfo/src/olsrd_httpinfo.c,v
retrieving revision 1.54
retrieving revision 1.55
diff -C2 -d -r1.54 -r1.55
*** olsrd_httpinfo.c	10 Nov 2005 19:28:02 -0000	1.54
--- olsrd_httpinfo.c	16 Dec 2005 15:16:42 -0000	1.55
***************
*** 47,50 ****
--- 47,51 ----
  #include <string.h>
  #include <stdlib.h>
+ #include <stdarg.h>
  #include <unistd.h>
  #include <errno.h>
***************
*** 189,192 ****
--- 190,198 ----
  static int http_socket;
  
+ int netsprintf(char *str, const char* format, ...);
+ static int netsprintf_direct = 0;
+ static int netsprintf_error = 0;
+ #define sprintf netsprintf
+ #define NETDIRECT
  
  
***************
*** 466,469 ****
--- 472,480 ----
        if(tab_entries[i].filename)
  	{
+ #ifdef NETDIRECT
+ 	  netsprintf_error = 0;
+ 	  netsprintf_direct = 1;
+ 	  c = build_http_header(HTTP_OK, OLSR_TRUE, size, req, MAX_HTTPREQ_SIZE);
+ #endif
  	  y = 0;
  	  while(http_ok_head[y])
***************
*** 490,496 ****
--- 501,512 ----
  	    }  
  	  
+ #ifdef NETDIRECT
+ 	  netsprintf_direct = 1;
+ 	  goto close_connection;
+ #else
  	  c = build_http_header(HTTP_OK, OLSR_TRUE, size, req, MAX_HTTPREQ_SIZE);
  	  
  	  goto send_http_data;
+ #endif
  	}
        
***************
*** 581,585 ****
    if(size > 0)
      {
!       sprintf(tmp, "Content-length: %i\r\n", size);
        strcat(buf, tmp);
      }
--- 597,601 ----
    if(size > 0)
      {
!       snprintf(tmp, sizeof(tmp), "Content-length: %i\r\n", size);
        strcat(buf, tmp);
      }
***************
*** 1235,1239 ****
      {
        /* IPv6 */
!       sprintf(netmask, "%d", mask->v6);
        return netmask;
      }
--- 1251,1255 ----
      {
        /* IPv6 */
!       snprintf(netmask, sizeof(netmask), "%d", mask->v6);
        return netmask;
      }
***************
*** 1250,1251 ****
--- 1266,1293 ----
    return copyright_string;
  }
+ 
+ /*
+  * In a bigger mesh, there are probs with the fixed
+  * bufsize. Because the Content-Length header is
+  * optional, the sprintf() is changed to a more
+  * scalable solution here.
+  */
+  
+ int netsprintf(char *str, const char* format, ...)
+ {
+ 	va_list arg;
+ 	int rv;
+ 	va_start(arg, format);
+ 	rv = vsprintf(str, format, arg);
+ 	va_end(arg);
+ 	if (0 != netsprintf_direct) {
+ 		if (0 == netsprintf_error) {
+ 			if (0 > send(client_sockets[curr_clients], str, rv, 0)) {
+ 				olsr_printf(1, "(HTTPINFO) Failed sending data to client!\n");
+ 				netsprintf_error = 1;
+ 			}
+ 		}
+ 		return 0;
+ 	}
+ 	return rv;
+ }





More information about the Olsr-cvs mailing list