[Olsr-cvs] olsrd-current/src olsrd_plugin.h, 1.3, 1.4 plugin_loader.c, 1.29, 1.30 plugin_util.c, 1.2, 1.3 plugin_util.h, 1.1, 1.2

Bernd Petrovitsch (spam-protected)
Sat Aug 25 21:48:44 CEST 2007


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

Modified Files:
	olsrd_plugin.h plugin_loader.c plugin_util.c plugin_util.h 
Log Message:
* Patch from Sven-Ola Tuecke to convert more plugins to the new interface.


Index: olsrd_plugin.h
===================================================================
RCS file: /cvsroot/olsrd/olsrd-current/src/olsrd_plugin.h,v
retrieving revision 1.3
retrieving revision 1.4
diff -C2 -d -r1.3 -r1.4
*** olsrd_plugin.h	15 Jul 2007 19:29:37 -0000	1.3
--- olsrd_plugin.h	25 Aug 2007 19:48:42 -0000	1.4
***************
*** 79,83 ****
  /* Interface version 5 */
  
! typedef int (*set_plugin_parameter)(const char *value, void *data);
  
  struct olsrd_plugin_parameters {
--- 79,83 ----
  /* Interface version 5 */
  
! typedef int (*set_plugin_parameter)(const char *value, void *data, unsigned int addon);
  
  struct olsrd_plugin_parameters {
***************
*** 85,88 ****
--- 85,89 ----
      set_plugin_parameter set_plugin_parameter;
      void *data;
+     unsigned int addon;
  };
  

Index: plugin_loader.c
===================================================================
RCS file: /cvsroot/olsrd/olsrd-current/src/plugin_loader.c,v
retrieving revision 1.29
retrieving revision 1.30
diff -C2 -d -r1.29 -r1.30
*** plugin_loader.c	1 Aug 2007 16:16:05 -0000	1.29
--- plugin_loader.c	25 Aug 2007 19:48:42 -0000	1.30
***************
*** 213,216 ****
--- 213,217 ----
          if(plugin->register_param == NULL) {
              OLSR_PRINTF(1, "FAILED: \"%s\"\n", dlerror());
+             return -1;
          } else {
              OLSR_PRINTF(1, "OK\n");
***************
*** 249,255 ****
              int rc = 0;
              for (i = 0; i < entry->plugin_parameters_size; i++) {
!                 if (strcasecmp(entry->plugin_parameters[i].name, params->key) == 0) {
                      /* we have found it! */
!                     rc = entry->plugin_parameters[i].set_plugin_parameter(params->value, entry->plugin_parameters[i].data);
                      if (rc != 0) {
                          fprintf(stderr, "\nFatal error in plugin parameter \"%s\"/\"%s\"\n", params->key, params->value);
--- 250,259 ----
              int rc = 0;
              for (i = 0; i < entry->plugin_parameters_size; i++) {
!                 if (0 == entry->plugin_parameters[i].name[0] ||
!                     0 == strcasecmp(entry->plugin_parameters[i].name, params->key))
!                 {
                      /* we have found it! */
!                     rc = entry->plugin_parameters[i].set_plugin_parameter(params->value, entry->plugin_parameters[i].data,
!                         0 == entry->plugin_parameters[i].name[0] ? (unsigned int)params->key : entry->plugin_parameters[i].addon);
                      if (rc != 0) {
                          fprintf(stderr, "\nFatal error in plugin parameter \"%s\"/\"%s\"\n", params->key, params->value);

Index: plugin_util.c
===================================================================
RCS file: /cvsroot/olsrd/olsrd-current/src/plugin_util.c,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** plugin_util.c	20 Jul 2007 12:25:56 -0000	1.2
--- plugin_util.c	25 Aug 2007 19:48:42 -0000	1.3
***************
*** 2,5 ****
--- 2,6 ----
   * The olsr.org Optimized Link-State Routing daemon(olsrd)
   * Copyright (c) 2007, Bernd Petrovitsch <(spam-protected)>
+  * Copyright (c) 2007, Sven-Ola <(spam-protected)>
   * All rights reserved.
   *
***************
*** 44,51 ****
  #include "defs.h"
  
! int set_plugin_port(const char *value, void *data)
  {
      char *endptr;
      const unsigned int port = strtoul(value, &endptr, 0);
      if (*endptr != '\0' || endptr == value) {
          OLSR_PRINTF(0, "Illegal port number \"%s\"", value);
--- 45,53 ----
  #include "defs.h"
  
! int set_plugin_port(const char *value, void *data, unsigned int addon)
  {
      char *endptr;
      const unsigned int port = strtoul(value, &endptr, 0);
+     if (addon) {}
      if (*endptr != '\0' || endptr == value) {
          OLSR_PRINTF(0, "Illegal port number \"%s\"", value);
***************
*** 66,73 ****
  }
  
! int set_plugin_ipaddress(const char *value, void *data)
  {
      char buf[INET6_ADDRSTRLEN];
      union olsr_ip_addr ip_addr;
      if (inet_pton(olsr_cnf->ip_version, value, &ip_addr) <= 0) {
          OLSR_PRINTF(0, "Illegal IP address \"%s\"", value);
--- 68,76 ----
  }
  
! int set_plugin_ipaddress(const char *value, void *data, unsigned int addon)
  {
      char buf[INET6_ADDRSTRLEN];
      union olsr_ip_addr ip_addr;
+     if (addon) {}
      if (inet_pton(olsr_cnf->ip_version, value, &ip_addr) <= 0) {
          OLSR_PRINTF(0, "Illegal IP address \"%s\"", value);
***************
*** 86,92 ****
  
  
! int set_boolean(const char *value, void *data)
  {
      int *v = data;
      if (strcasecmp (value, "yes") == 0) {
          *v = 1;
--- 89,96 ----
  
  
! int set_boolean(const char *value, void *data, unsigned int addon)
  {
      int *v = data;
+     if (addon) {}
      if (strcasecmp (value, "yes") == 0) {
          *v = 1;
***************
*** 99,102 ****
--- 103,141 ----
  }
  
+ int set_plugin_int(const char *value, void *data, unsigned int addon)
+ {
+     char *endptr;
+     const int theint = strtol(value, &endptr, 0);
+     if (addon) {}
+     if (*endptr != '\0' || endptr == value) {
+         OLSR_PRINTF(0, "Illegal int \"%s\"", value);
+         return 1;
+     }
+     if (data != NULL) {
+         int *v = data;
+         *v = theint;
+         OLSR_PRINTF(1, "%s int %d\n", "Got", theint);
+     } else {
+         OLSR_PRINTF(0, "%s int %d\n", "Ignored", theint);
+     }
+     return 0;
+ }
+ 
+ int set_plugin_string(const char *value, void *data, unsigned int addon)
+ {
+     if (data != NULL) {
+         char *v = data;
+         if (strlen(value) >= addon) {
+             OLSR_PRINTF(0, "String too long \"%s\"", value);
+             return 1;
+         }
+         strcpy(v, value);
+         OLSR_PRINTF(1, "%s string %s\n", "Got", value);
+     } else {
+         OLSR_PRINTF(0, "%s string %s\n", "Ignored", value);
+     }
+     return 0;
+ }
+ 
  /*
   * Local Variables:

Index: plugin_util.h
===================================================================
RCS file: /cvsroot/olsrd/olsrd-current/src/plugin_util.h,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** plugin_util.h	15 Jul 2007 17:46:46 -0000	1.1
--- plugin_util.h	25 Aug 2007 19:48:42 -0000	1.2
***************
*** 40,46 ****
  
  /* Common/utility functions for plugins */
! int set_plugin_port(const char *value, void *data);
! int set_plugin_ipaddress(const char *value, void *data);
! int set_boolean(const char *value, void *data);
  
  
--- 40,48 ----
  
  /* Common/utility functions for plugins */
! int set_plugin_port(const char *value, void *data, unsigned int);
! int set_plugin_ipaddress(const char *value, void *data, unsigned int);
! int set_boolean(const char *value, void *data, unsigned int);
! int set_plugin_int(const char *value, void *data, unsigned int);
! int set_plugin_string(const char *value, void *data, unsigned int);
  
  





More information about the Olsr-cvs mailing list