[Olsr-cvs] olsrd-current/lib/httpinfo/src admin_interface.c, 1.7, 1.8 olsrd_httpinfo.c, 1.62, 1.63 olsrd_httpinfo.h, 1.28, 1.29 olsrd_plugin.c, 1.14, 1.15

Bernd Petrovitsch (spam-protected)
Fri Apr 20 16:06:20 CEST 2007


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

Modified Files:
	admin_interface.c olsrd_httpinfo.c olsrd_httpinfo.h 
	olsrd_plugin.c 
Log Message:
cleanup, 1. step (to get some local changes away):
* killed lots of warnings
* added __attribure__((unused)) and __attribure__((format(printf, ..., ...)))
* added "const"
* moved declarations of static functions into .c files
* added "static" declarations
* removed all "inline" declarations. Usually the compiler knows better anyways.
* removed emtpy "return" statements at the end of functions
* localized declarations
* avoided unnecessary data copies
* removed lots of empty lines
There is much more to do.



Index: olsrd_httpinfo.c
===================================================================
RCS file: /cvsroot/olsrd/olsrd-current/lib/httpinfo/src/olsrd_httpinfo.c,v
retrieving revision 1.62
retrieving revision 1.63
diff -C2 -d -r1.62 -r1.63
*** olsrd_httpinfo.c	2 Apr 2007 22:22:25 -0000	1.62
--- olsrd_httpinfo.c	20 Apr 2007 14:06:18 -0000	1.63
***************
*** 133,140 ****
  get_http_socket(int);
  
! int
! build_tabs(char *, int);
  
! void
  parse_http_request(int);
  
--- 133,140 ----
  get_http_socket(int);
[...1456 lines suppressed...]
+ #endif
+ 
+ static ssize_t writen(int fd, const void *buf, size_t count)
+ {
+     size_t bytes_left = count;
+     const char *p = buf;
+     while (bytes_left > 0) {
+         const ssize_t written = write(fd, p, bytes_left);
+         if (written == -1)  { /* error */
+             if (errno == EINTR ) {
+                 continue;
+             }
+             return -1;
+         }
+         /* We wrote something */
+         bytes_left -= written;
+         p += written;
+     }
+     return count;
+ }

Index: olsrd_httpinfo.h
===================================================================
RCS file: /cvsroot/olsrd/olsrd-current/lib/httpinfo/src/olsrd_httpinfo.h,v
retrieving revision 1.28
retrieving revision 1.29
diff -C2 -d -r1.28 -r1.29
*** olsrd_httpinfo.h	29 May 2005 12:47:41 -0000	1.28
--- olsrd_httpinfo.h	20 Apr 2007 14:06:18 -0000	1.29
***************
*** 83,89 ****
  
  char *
- olsr_ip_to_string(union olsr_ip_addr *);
- 
- char *
  olsr_netmask_to_string(union hna_netmask *);
  
--- 83,86 ----

Index: admin_interface.c
===================================================================
RCS file: /cvsroot/olsrd/olsrd-current/lib/httpinfo/src/admin_interface.c,v
retrieving revision 1.7
retrieving revision 1.8
diff -C2 -d -r1.7 -r1.8
*** admin_interface.c	18 Sep 2006 18:55:30 -0000	1.7
--- admin_interface.c	20 Apr 2007 14:06:18 -0000	1.8
***************
*** 46,63 ****
  
  
  #include "olsrd_httpinfo.h"
  #include "olsr_cfg.h"
  #include "admin_html.h"
  #include "admin_interface.h"
  #include <stdio.h>
  #include <string.h>
  #include <stdlib.h>
  
  extern int netsprintf(char *str, const char* format, ...);
  #define sprintf netsprintf
  #define NETDIRECT
  
  int
! build_admin_body(char *buf, olsr_u32_t bufsize)
  {
    int size = 0, i = 0;
--- 46,69 ----
  
  
+ #include "olsr.h"
  #include "olsrd_httpinfo.h"
  #include "olsr_cfg.h"
  #include "admin_html.h"
  #include "admin_interface.h"
+ #include "local_hna_set.h" /* add_local_hna4_entry() */
+ 
  #include <stdio.h>
  #include <string.h>
  #include <stdlib.h>
  
+ #if 0
  extern int netsprintf(char *str, const char* format, ...);
  #define sprintf netsprintf
  #define NETDIRECT
+ #endif
+ 
  
  int
! build_admin_body(char *buf, olsr_u32_t bufsize __attribute__((unused)))
  {
    int size = 0, i = 0;
***************
*** 65,69 ****
    while(admin_frame[i] && strcmp(admin_frame[i], "<!-- BASICSETTINGS -->\n"))
      {
!       size += sprintf(&buf[size], admin_frame[i]);
        i++;
      }
--- 71,75 ----
    while(admin_frame[i] && strcmp(admin_frame[i], "<!-- BASICSETTINGS -->\n"))
      {
!       size += snprintf(&buf[size], bufsize-size, admin_frame[i]);
        i++;
      }
***************
*** 73,133 ****
  
  
!   size += sprintf(&buf[size], "<tr>\n");
  
!   size += sprintf(&buf[size], admin_basic_setting_int,
  		  "Debug level:", "debug_level", 2, olsr_cnf->debug_level);
!   size += sprintf(&buf[size], admin_basic_setting_float,
  		  "Pollrate:", "pollrate", 4, olsr_cnf->pollrate);
!   size += sprintf(&buf[size], admin_basic_setting_string,
  		  "TOS:", "tos", 6, "TBD");
  
!   size += sprintf(&buf[size], "</tr>\n");
!   size += sprintf(&buf[size], "<tr>\n");
  
!   size += sprintf(&buf[size], admin_basic_setting_int,
  		  "TC redundancy:", "tc_redundancy", 1, olsr_cnf->tc_redundancy);
!   size += sprintf(&buf[size], admin_basic_setting_int,
  		  "MPR coverage:", "mpr_coverage", 1, olsr_cnf->mpr_coverage);
!   size += sprintf(&buf[size], admin_basic_setting_int,
  		  "Willingness:", "willingness", 1, olsr_cnf->willingness);
  
!   size += sprintf(&buf[size], "</tr>\n");
!   size += sprintf(&buf[size], "<tr>\n");
  
    if(olsr_cnf->use_hysteresis)
      {
!       size += sprintf(&buf[size], admin_basic_setting_float,
  		      "Hyst scaling:", "hyst_scaling", 4, olsr_cnf->hysteresis_param.scaling);
  
!       size += sprintf(&buf[size], admin_basic_setting_float,
  		      "Lower thr:", "hyst_lower", 4, olsr_cnf->hysteresis_param.thr_low);
!       size += sprintf(&buf[size], admin_basic_setting_float,
  		      "Upper thr:", "hyst_upper", 4, olsr_cnf->hysteresis_param.thr_high);
      }
    else
      {
!       size += sprintf(&buf[size], "<td>Hysteresis disabled</td>\n");
      }
  
!   size += sprintf(&buf[size], "</tr>\n");
!   size += sprintf(&buf[size], "<tr>\n");
    
    if(olsr_cnf->lq_level)
      {
!       size += sprintf(&buf[size], admin_basic_setting_int,
  		      "LQ level:", "lq_level", 1, olsr_cnf->lq_level);
!       size += sprintf(&buf[size], admin_basic_setting_int,
  		      "LQ winsize:", "lq_wsize", 2, olsr_cnf->lq_wsize);
      }
    else
      {
!       size += sprintf(&buf[size], "<td>LQ disabled</td>\n");
      }
  
  
!   size += sprintf(&buf[size], "</tr>\n");
!   size += sprintf(&buf[size], "<tr>\n");
  
!   size += sprintf(&buf[size], "</tr>\n");
    
    i++;
--- 79,139 ----
  
  
!   size += snprintf(&buf[size], bufsize-size, "<tr>\n");
  
!   size += snprintf(&buf[size], bufsize-size, admin_basic_setting_int,
  		  "Debug level:", "debug_level", 2, olsr_cnf->debug_level);
!   size += snprintf(&buf[size], bufsize-size, admin_basic_setting_float,
  		  "Pollrate:", "pollrate", 4, olsr_cnf->pollrate);
!   size += snprintf(&buf[size], bufsize-size, admin_basic_setting_string,
  		  "TOS:", "tos", 6, "TBD");
  
!   size += snprintf(&buf[size], bufsize-size, "</tr>\n");
!   size += snprintf(&buf[size], bufsize-size, "<tr>\n");
  
!   size += snprintf(&buf[size], bufsize-size, admin_basic_setting_int,
  		  "TC redundancy:", "tc_redundancy", 1, olsr_cnf->tc_redundancy);
!   size += snprintf(&buf[size], bufsize-size, admin_basic_setting_int,
  		  "MPR coverage:", "mpr_coverage", 1, olsr_cnf->mpr_coverage);
!   size += snprintf(&buf[size], bufsize-size, admin_basic_setting_int,
  		  "Willingness:", "willingness", 1, olsr_cnf->willingness);
  
!   size += snprintf(&buf[size], bufsize-size, "</tr>\n");
!   size += snprintf(&buf[size], bufsize-size, "<tr>\n");
  
    if(olsr_cnf->use_hysteresis)
      {
!       size += snprintf(&buf[size], bufsize-size, admin_basic_setting_float,
  		      "Hyst scaling:", "hyst_scaling", 4, olsr_cnf->hysteresis_param.scaling);
  
!       size += snprintf(&buf[size], bufsize-size, admin_basic_setting_float,
  		      "Lower thr:", "hyst_lower", 4, olsr_cnf->hysteresis_param.thr_low);
!       size += snprintf(&buf[size], bufsize-size, admin_basic_setting_float,
  		      "Upper thr:", "hyst_upper", 4, olsr_cnf->hysteresis_param.thr_high);
      }
    else
      {
!       size += snprintf(&buf[size], bufsize-size, "<td>Hysteresis disabled</td>\n");
      }
  
!   size += snprintf(&buf[size], bufsize-size, "</tr>\n");
!   size += snprintf(&buf[size], bufsize-size, "<tr>\n");
    
    if(olsr_cnf->lq_level)
      {
!       size += snprintf(&buf[size], bufsize-size, admin_basic_setting_int,
  		      "LQ level:", "lq_level", 1, olsr_cnf->lq_level);
!       size += snprintf(&buf[size], bufsize-size, admin_basic_setting_int,
  		      "LQ winsize:", "lq_wsize", 2, olsr_cnf->lq_wsize);
      }
    else
      {
!       size += snprintf(&buf[size], bufsize-size, "<td>LQ disabled</td>\n");
      }
  
  
!   size += snprintf(&buf[size], bufsize-size, "</tr>\n");
!   size += snprintf(&buf[size], bufsize-size, "<tr>\n");
  
!   size += snprintf(&buf[size], bufsize-size, "</tr>\n");
    
    i++;
***************
*** 135,139 ****
    while(admin_frame[i] && strcmp(admin_frame[i], "<!-- HNAENTRIES -->\n"))
      {
!       size += sprintf(&buf[size], admin_frame[i]);
        i++;
      }
--- 141,145 ----
    while(admin_frame[i] && strcmp(admin_frame[i], "<!-- HNAENTRIES -->\n"))
      {
!       size += snprintf(&buf[size], bufsize-size, admin_frame[i]);
        i++;
      }
***************
*** 150,154 ****
        for(hna4 = olsr_cnf->hna4_entries; hna4; hna4 = hna4->next)
  	{
! 	  size += sprintf(&buf[size], admin_frame[i], 
  			  olsr_ip_to_string((union olsr_ip_addr *)&hna4->net),
  			  olsr_ip_to_string((union olsr_ip_addr *)&hna4->netmask),
--- 156,160 ----
        for(hna4 = olsr_cnf->hna4_entries; hna4; hna4 = hna4->next)
  	{
! 	  size += snprintf(&buf[size], bufsize-size, admin_frame[i], 
  			  olsr_ip_to_string((union olsr_ip_addr *)&hna4->net),
  			  olsr_ip_to_string((union olsr_ip_addr *)&hna4->netmask),
***************
*** 163,167 ****
        for(hna6 = olsr_cnf->hna6_entries; hna6; hna6 = hna6->next)
  	{
! 	  size += sprintf(&buf[size], admin_frame[i], 
  			  olsr_ip_to_string((union olsr_ip_addr *)&hna6->net),
  			  "TBD"/*hna6->prefix_len*/);
--- 169,173 ----
        for(hna6 = olsr_cnf->hna6_entries; hna6; hna6 = hna6->next)
  	{
! 	  size += snprintf(&buf[size], bufsize-size, admin_frame[i], 
  			  olsr_ip_to_string((union olsr_ip_addr *)&hna6->net),
  			  "TBD"/*hna6->prefix_len*/);
***************
*** 173,177 ****
    while(admin_frame[i])
      {
!       size += sprintf(&buf[size], admin_frame[i]);
        i++;
      }
--- 179,183 ----
    while(admin_frame[i])
      {
!       size += snprintf(&buf[size], bufsize-size, admin_frame[i]);
        i++;
      }
***************
*** 335,339 ****
  	}
        add_local_hna4_entry((union olsr_ip_addr *)&curr_hna_net,
! 			   (union hna_netmask *)&in.s_addr);
        
        return 1;
--- 341,345 ----
  	}
        add_local_hna4_entry((union olsr_ip_addr *)&curr_hna_net,
! 			   (union olsr_ip_addr *)&in.s_addr);
        
        return 1;
***************
*** 367,371 ****
  
        remove_local_hna4_entry((union olsr_ip_addr *)&net.s_addr,
! 			      (union hna_netmask *)&mask.s_addr);
  
        return 1;
--- 373,377 ----
  
        remove_local_hna4_entry((union olsr_ip_addr *)&net.s_addr,
! 			      (union olsr_ip_addr *)&mask.s_addr);
  
        return 1;
***************
*** 379,386 ****
  
  int
! process_set_values(char *data, olsr_u32_t data_size, char *buf, olsr_u32_t bufsize)
  {
    int size = 0;
!   int i, val_start, key_start;
  
    printf("Dynamic Data: %s\n", data);
--- 385,393 ----
  
  int
! process_set_values(char *data, olsr_u32_t data_size, char *buf, olsr_u32_t bufsize __attribute__((unused)))
  {
    int size = 0;
!   int val_start, key_start;
!   olsr_u32_t i;
  
    printf("Dynamic Data: %s\n", data);
***************
*** 404,408 ****
  	  if(!process_param(&data[key_start], &data[val_start]))
  	    {
! 	      size += sprintf(&buf[size], "<h2>FAILED PROCESSING!</h2><br>Key: %s Value: %s<br>\n", 
  			      &data[key_start], &data[val_start]);
  	      return -1;
--- 411,415 ----
  	  if(!process_param(&data[key_start], &data[val_start]))
  	    {
! 	      size += snprintf(&buf[size], bufsize-size, "<h2>FAILED PROCESSING!</h2><br>Key: %s Value: %s<br>\n", 
  			      &data[key_start], &data[val_start]);
  	      return -1;
***************
*** 417,421 ****
    if(!process_param(&data[key_start], &data[val_start]))
      {
!       size += sprintf(&buf[size], "<b>FAILED PROCESSING!</b><br>Key: %s Value: %s<br>\n", 
  		      &data[key_start], &data[val_start]);
        return -1;
--- 424,428 ----
    if(!process_param(&data[key_start], &data[val_start]))
      {
!       size += snprintf(&buf[size], bufsize-size, "<b>FAILED PROCESSING!</b><br>Key: %s Value: %s<br>\n", 
  		      &data[key_start], &data[val_start]);
        return -1;
***************
*** 425,430 ****
  	 &data[key_start], &data[val_start]);
  
!   size += sprintf(&buf[size], "<h2>UPDATE SUCESSFULL!</h2><br>Press BACK and RELOAD in your browser to return to the plugin<br>\n</body>\n</html>\n");
!   size += sprintf(&buf[size], "\n</body>\n</html>\n");
  
    return size;
--- 432,437 ----
  	 &data[key_start], &data[val_start]);
  
!   size += snprintf(&buf[size], bufsize-size, "<h2>UPDATE SUCESSFULL!</h2><br>Press BACK and RELOAD in your browser to return to the plugin<br>\n</body>\n</html>\n");
!   size += snprintf(&buf[size], bufsize-size, "\n</body>\n</html>\n");
  
    return size;

Index: olsrd_plugin.c
===================================================================
RCS file: /cvsroot/olsrd/olsrd-current/lib/httpinfo/src/olsrd_plugin.c,v
retrieving revision 1.14
retrieving revision 1.15
diff -C2 -d -r1.14 -r1.15
*** olsrd_plugin.c	2 Apr 2007 22:22:26 -0000	1.14
--- olsrd_plugin.c	20 Apr 2007 14:06:18 -0000	1.15
***************
*** 71,75 ****
   */
  int 
! olsrd_plugin_interface_version()
  {
    return PLUGIN_INTERFACE_VERSION;
--- 71,75 ----
   */
  int 
! olsrd_plugin_interface_version(void)
  {
    return PLUGIN_INTERFACE_VERSION;
***************
*** 82,86 ****
   */
  static void
! my_init()
  {
    /* Print plugin info to stdout */
--- 82,86 ----
   */
  static void
! my_init(void)
  {
    /* Print plugin info to stdout */
***************
*** 94,98 ****
   */
  static void
! my_fini()
  {
  
--- 94,98 ----
   */
  static void
! my_fini(void)
  {
  





More information about the Olsr-cvs mailing list