[Olsr-cvs] olsrd-current/src/cfgparser olsrd_conf.c,1.56,1.57

Bernd Petrovitsch (spam-protected)
Wed Oct 24 15:46:38 CEST 2007


Update of /cvsroot/olsrd/olsrd-current/src/cfgparser
In directory sc8-pr-cvs3.sourceforge.net:/tmp/cvs-serv16018/src/cfgparser

Modified Files:
	olsrd_conf.c 
Log Message:
* cleanup: use for() instead of while to save lots of lines - and minor other stuff

Index: olsrd_conf.c
===================================================================
RCS file: /cvsroot/olsrd/olsrd-current/src/cfgparser/olsrd_conf.c,v
retrieving revision 1.56
retrieving revision 1.57
diff -C2 -d -r1.56 -r1.57
*** olsrd_conf.c	22 Oct 2007 21:02:49 -0000	1.56
--- olsrd_conf.c	24 Oct 2007 13:46:36 -0000	1.57
***************
*** 51,54 ****
--- 51,55 ----
  
  #include "olsrd_conf.h"
+ #include "olsr_cfg.h"
  
  
***************
*** 56,60 ****
  extern int yyparse(void);
  
! static char copyright_string[] = "The olsr.org Optimized Link-State Routing daemon(olsrd) Copyright (c) 2004, Andreas Tønnesen((spam-protected)) All rights reserved.";
  
  #ifdef MAKEBIN
--- 57,61 ----
  extern int yyparse(void);
  
! static char copyright_string[] __attribute__((unused)) = "The olsr.org Optimized Link-State Routing daemon(olsrd) Copyright (c) 2004, Andreas Tønnesen((spam-protected)) All rights reserved.";
  
  #ifdef MAKEBIN
***************
*** 101,115 ****
  olsrd_parse_cnf(const char *filename)
  {
!   struct olsr_if *in, *new_ifqueue, *in_tmp;
! 
!   /* Stop the compiler from complaining */
!   (void)strlen(copyright_string);
  
!   cnf = malloc(sizeof(struct olsrd_config));
!   if (cnf == NULL)
!     {
!       fprintf(stderr, "Out of memory %s\n", __func__);
!       return NULL;
!     }
  
    set_default_cnf(cnf);
--- 102,113 ----
  olsrd_parse_cnf(const char *filename)
  {
!   struct olsr_if *in, *new_ifqueue;
!   int rc;
  
!   struct olsrd_config *cnf = malloc(sizeof(struct olsrd_config));
!   if (cnf == NULL) {
!     fprintf(stderr, "Out of memory %s\n", __func__);
!     return NULL;
!   }
  
    set_default_cnf(cnf);
***************
*** 118,140 ****
  
    yyin = fopen(filename, "r");
!   
!   if (yyin == NULL)
!     {
!       fprintf(stderr, "Cannot open configuration file '%s': %s.\n",
! 	      filename, strerror(errno));
!       free(cnf);
!       return NULL;
!     }
  
    current_line = 1;
! 
!   if (yyparse() != 0)
!     {
!       fclose(yyin);
!       olsrd_free_cnf(cnf);
!       return NULL;
!     }
!   
    fclose(yyin);
  
    /* Reverse the queue (added by user request) */
--- 116,133 ----
  
    yyin = fopen(filename, "r");
!   if (yyin == NULL) {
!     fprintf(stderr, "Cannot open configuration file '%s': %s.\n",
!             filename, strerror(errno));
!     free(cnf);
!     return NULL;
!   }
  
    current_line = 1;
!   rc = yyparse();
    fclose(yyin);
+   if (rc != 0) {
+     olsrd_free_cnf(cnf);
+     return NULL;
+   }
  
    /* Reverse the queue (added by user request) */
***************
*** 142,168 ****
    new_ifqueue = NULL;
  
!   while(in)
!     {
!       in_tmp = in; 
!       in = in->next;
  
!       in_tmp->next = new_ifqueue;
!       new_ifqueue = in_tmp;
!     }
  
    cnf->interfaces = new_ifqueue;
  
!   in = cnf->interfaces;
! 
!   while(in)
!     {
        /* set various stuff */
        in->configured = OLSR_FALSE;
        in->interf = NULL;
        in->host_emul = OLSR_FALSE;
!       in = in->next;
!     }
! 
! 
    return cnf;
  }
--- 135,154 ----
    new_ifqueue = NULL;
  
!   while(in) {
!     struct olsr_if *in_tmp = in; 
!     in = in->next;
  
!     in_tmp->next = new_ifqueue;
!     new_ifqueue = in_tmp;
!   }
  
    cnf->interfaces = new_ifqueue;
  
!   for (in = cnf->interfaces; in != NULL; in = in->next) {
        /* set various stuff */
        in->configured = OLSR_FALSE;
        in->interf = NULL;
        in->host_emul = OLSR_FALSE;
!   }
    return cnf;
  }





More information about the Olsr-cvs mailing list