Merge branch 'collectd-4.9'
authorFlorian Forster <octo@leeloo.lan.home.verplant.org>
Mon, 15 Mar 2010 21:43:00 +0000 (22:43 +0100)
committerFlorian Forster <octo@leeloo.lan.home.verplant.org>
Mon, 15 Mar 2010 21:43:00 +0000 (22:43 +0100)
1  2 
configure.in
src/common.c
src/common.h
src/configfile.c

diff --combined configure.in
@@@ -931,6 -931,27 +931,27 @@@ if test "x$have_getmntent" = "xgen"; th
                  [Define if the function getmntent exists. It's the version from libgen.])
  fi
  
+ # Check for htonll
+ AC_MSG_CHECKING([if have htonll defined])
+     have_htonll="no"
+     AC_RUN_IFELSE([
+        AC_LANG_PROGRAM([
+ #include <sys/types.h>
+ #include <netinet/in.h>
+ #ifdef HAVE_INTTYPES_H
+ #include <inttypes.h> 
+ #endif
+        ], [
+           return htonll(0);
+        ])
+     ], [
+       have_htonll="yes"
+       AC_DEFINE(HAVE_HTONLL, 1, [Define if the function htonll exists.])
+     ])
+  
+ AC_MSG_RESULT([$have_htonll])
  # Check for structures
  AC_CHECK_MEMBERS([struct if_data.ifi_ibytes, struct if_data.ifi_opackets, struct if_data.ifi_ierrors],
        [AC_DEFINE(HAVE_STRUCT_IF_DATA, 1, [Define if struct if_data exists and is usable.])],
  if test "x$with_python" = "xyes"
  then
        AC_MSG_CHECKING([for Python CPPFLAGS])
 -      python_include_path=`echo "import distutils.sysconfig;print distutils.sysconfig.get_python_inc()" | "$with_python_prog" 2>&1`
 +      python_include_path=`echo "import distutils.sysconfig;import sys;sys.stdout.write(distutils.sysconfig.get_python_inc())" | "$with_python_prog" 2>&1`
        python_config_status=$?
  
        if test "$python_config_status" -ne 0 || test "x$python_include_path" = "x"
  if test "x$with_python" = "xyes"
  then
        AC_MSG_CHECKING([for Python LDFLAGS])
 -      python_library_path=`echo "import distutils.sysconfig;print distutils.sysconfig.get_config_vars(\"LIBDIR\").__getitem__(0)" | "$with_python_prog" 2>&1`
 +      python_library_path=`echo "import distutils.sysconfig;import sys;sys.stdout.write(distutils.sysconfig.get_config_vars(\"LIBDIR\").__getitem__(0))" | "$with_python_prog" 2>&1`
        python_config_status=$?
  
        if test "$python_config_status" -ne 0 || test "x$python_library_path" = "x"
  if test "x$with_python" = "xyes"
  then
        AC_MSG_CHECKING([for Python LIBS])
 -      python_library_flags=`echo "import distutils.sysconfig;print distutils.sysconfig.get_config_vars(\"BLDLIBRARY\").__getitem__(0)" | "$with_python_prog" 2>&1`
 +      python_library_flags=`echo "import distutils.sysconfig;import sys;sys.stdout.write(distutils.sysconfig.get_config_vars(\"BLDLIBRARY\").__getitem__(0))" | "$with_python_prog" 2>&1`
        python_config_status=$?
  
        if test "$python_config_status" -ne 0 || test "x$python_library_flags" = "x"
@@@ -3821,7 -3842,6 +3842,7 @@@ plugin_contextswitch="no
  plugin_cpu="no"
  plugin_cpufreq="no"
  plugin_curl_json="no"
 +plugin_curl_xml="no"
  plugin_df="no"
  plugin_disk="no"
  plugin_entropy="no"
        plugin_curl_json="yes"
  fi
  
 +if test "x$with_libcurl" = "xyes" && test "x$with_libxml2" = "xyes"
 +then
 +      plugin_curl_xml="yes"
 +fi
 +
  if test "x$have_processor_info" = "xyes"
  then
        plugin_cpu="yes"
@@@ -4119,7 -4134,6 +4140,7 @@@ AC_PLUGIN([cpu],         [$plugin_cpu]
  AC_PLUGIN([csv],         [yes],                [CSV output plugin])
  AC_PLUGIN([curl],        [$with_libcurl],      [CURL generic web statistics])
  AC_PLUGIN([curl_json],   [$plugin_curl_json],    [CouchDB statistics])
 +AC_PLUGIN([curl_xml],   [$plugin_curl_xml],    [CURL generic xml statistics])
  AC_PLUGIN([dbi],         [$with_libdbi],       [General database statistics])
  AC_PLUGIN([df],          [$plugin_df],         [Filesystem usage statistics])
  AC_PLUGIN([disk],        [$plugin_disk],       [Disk usage statistics])
@@@ -4430,7 -4444,6 +4451,7 @@@ Configuration
      csv . . . . . . . . . $enable_csv
      curl  . . . . . . . . $enable_curl
      curl_json . . . . . . $enable_curl_json
 +    curl_xml  . . . . . . $enable_curl_xml
      dbi . . . . . . . . . $enable_dbi
      df  . . . . . . . . . $enable_df
      disk  . . . . . . . . $enable_disk
diff --combined src/common.c
@@@ -668,6 -668,7 +668,7 @@@ long long get_kstat_value (kstat_t *ksp
  }
  #endif /* HAVE_LIBKSTAT */
  
+ #ifndef HAVE_HTONLL
  unsigned long long ntohll (unsigned long long n)
  {
  #if BYTE_ORDER == BIG_ENDIAN
@@@ -685,6 -686,7 +686,7 @@@ unsigned long long htonll (unsigned lon
        return (((unsigned long long) htonl (n)) << 32) + htonl (n >> 32);
  #endif
  } /* unsigned long long htonll */
+ #endif /* HAVE_HTONLL */
  
  #if FP_LAYOUT_NEED_NOTHING
  /* Well, we need nothing.. */
@@@ -1008,7 -1010,7 +1010,7 @@@ int notification_init (notification_t *
  } /* int notification_init */
  
  int walk_directory (const char *dir, dirwalk_callback_f callback,
 -              void *user_data)
 +              void *user_data, int include_hidden)
  {
        struct dirent *ent;
        DIR *dh;
        while ((ent = readdir (dh)) != NULL)
        {
                int status;
 -
 -              if (ent->d_name[0] == '.')
 -                      continue;
 +              
 +              if (include_hidden)
 +              {
 +                      if ((strcmp (".", ent->d_name) == 0)
 +                                      || (strcmp ("..", ent->d_name) == 0))
 +                              continue;
 +              }
 +              else /* if (!include_hidden) */
 +              {
 +                      if (ent->d_name[0]=='.')
 +                              continue;
 +              }
  
                status = (*callback) (dir, ent->d_name, user_data);
                if (status != 0)
@@@ -1142,21 -1135,3 +1144,21 @@@ int service_name_to_port_number (const 
                return (service_number);
        return (-1);
  } /* int service_name_to_port_number */
 +
 +int strtoderive (const char *string, derive_t *ret_value) /* {{{ */
 +{
 +      derive_t tmp;
 +      char *endptr;
 +
 +      if ((string == NULL) || (ret_value == NULL))
 +              return (EINVAL);
 +
 +      errno = 0;
 +      endptr = NULL;
 +      tmp = (derive_t) strtoll (string, &endptr, /* base = */ 0);
 +      if ((endptr == string) || (errno != 0))
 +              return (-1);
 +
 +      *ret_value = tmp;
 +      return (0);
 +} /* }}} int strtoderive */
diff --combined src/common.h
@@@ -236,8 -236,10 +236,10 @@@ int get_kstat (kstat_t **ksp_ptr, char 
  long long get_kstat_value (kstat_t *ksp, char *name);
  #endif
  
+ #ifndef HAVE_HTONLL
  unsigned long long ntohll (unsigned long long n);
  unsigned long long htonll (unsigned long long n);
+ #endif
  
  #if FP_LAYOUT_NEED_NOTHING
  # define ntohd(d) (d)
@@@ -280,7 -282,7 +282,7 @@@ int notification_init (notification_t *
  typedef int (*dirwalk_callback_f)(const char *dirname, const char *filename,
                void *user_data);
  int walk_directory (const char *dir, dirwalk_callback_f callback,
 -              void *user_data);
 +              void *user_data, int hidden);
  int read_file_contents (const char *filename, char *buf, int bufsize);
  
  counter_t counter_diff (counter_t old_value, counter_t new_value);
   * (in the range [1-65535]). Returns less than zero on error. */
  int service_name_to_port_number (const char *service_name);
  
 +int strtoderive (const char *string, derive_t *ret_value);
 +
  #endif /* COMMON_H */
diff --combined src/configfile.c
@@@ -575,14 -575,14 +575,14 @@@ static oconfig_item_t *cf_read_dir (con
                ERROR ("configfile: malloc failed.");
                return (NULL);
        }
-       memset (root, '\0', sizeof (oconfig_item_t));
+       memset (root, 0, sizeof (oconfig_item_t));
  
        while ((de = readdir (dh)) != NULL)
        {
                char   name[1024];
                char **tmp;
  
-               if ((de->d_name[0] == '.') || (de->d_name[0] == '\0'))
+               if ((de->d_name[0] == '.') || (de->d_name[0] == 0))
                        continue;
  
                status = ssnprintf (name, sizeof (name), "%s/%s",
                char *name = filenames[i];
  
                temp = cf_read_generic (name, depth);
-               if (temp == NULL) {
-                       int j;
-                       for (j = i; j < filenames_num; ++j)
-                               free (filenames[j]);
-                       free (filenames);
-                       oconfig_free (root);
-                       return (NULL);
+               if (temp == NULL)
+               {
+                       /* An error should already have been reported. */
+                       sfree (name);
+                       continue;
                }
  
                cf_ci_append_children (root, temp);
@@@ -959,45 -957,6 +957,45 @@@ int cf_util_get_string (const oconfig_i
        return (0);
  } /* }}} int cf_util_get_string */
  
 +/* Assures the config option is a string and copies it to the provided buffer.
 + * Assures null-termination. */
 +int cf_util_get_string_buffer (const oconfig_item_t *ci, char *buffer, /* {{{ */
 +              size_t buffer_size)
 +{
 +      if ((ci == NULL) || (buffer == NULL) || (buffer_size < 1))
 +              return (EINVAL);
 +
 +      if ((ci->values_num != 1) || (ci->values[0].type != OCONFIG_TYPE_STRING))
 +      {
 +              ERROR ("cf_util_get_string_buffer: The %s option requires "
 +                              "exactly one string argument.", ci->key);
 +              return (-1);
 +      }
 +
 +      strncpy (buffer, ci->values[0].value.string, buffer_size);
 +      buffer[buffer_size - 1] = 0;
 +
 +      return (0);
 +} /* }}} int cf_util_get_string_buffer */
 +
 +/* Assures the config option is a number and returns it as an int. */
 +int cf_util_get_int (const oconfig_item_t *ci, int *ret_value) /* {{{ */
 +{
 +      if ((ci == NULL) || (ret_value == NULL))
 +              return (EINVAL);
 +
 +      if ((ci->values_num != 1) || (ci->values[0].type != OCONFIG_TYPE_NUMBER))
 +      {
 +              ERROR ("cf_util_get_int: The %s option requires "
 +                              "exactly one numeric argument.", ci->key);
 +              return (-1);
 +      }
 +
 +      *ret_value = (int) ci->values[0].value.number;
 +
 +      return (0);
 +} /* }}} int cf_util_get_int */
 +
  int cf_util_get_boolean (const oconfig_item_t *ci, _Bool *ret_bool) /* {{{ */
  {
        if ((ci == NULL) || (ret_bool == NULL))
        if ((ci->values_num != 1) || (ci->values[0].type != OCONFIG_TYPE_BOOLEAN))
        {
                ERROR ("cf_util_get_boolean: The %s option requires "
 -                              "exactly one string argument.", ci->key);
 +                              "exactly one boolean argument.", ci->key);
                return (-1);
        }