unixsock plugin: Moved the `parse_identifier' code to `common.c'
[collectd.git] / src / unixsock.c
index 9793659..215abdd 100644 (file)
@@ -84,52 +84,6 @@ static unsigned int     cache_oldest = UINT_MAX;
 /*
  * Functions
  */
-static int parse_identifier (char *str, char **ret_host,
-               char **ret_plugin, char **ret_plugin_instance,
-               char **ret_type, char **ret_type_instance)
-{
-       char *hostname = NULL;
-       char *plugin = NULL;
-       char *plugin_instance = NULL;
-       char *type = NULL;
-       char *type_instance = NULL;
-
-       hostname = str;
-       if (hostname == NULL)
-               return (-1);
-
-       plugin = strchr (hostname, '/');
-       if (plugin == NULL)
-               return (-1);
-       *plugin = '\0'; plugin++;
-
-       type = strchr (plugin, '/');
-       if (type == NULL)
-               return (-1);
-       *type = '\0'; type++;
-
-       plugin_instance = strchr (plugin, '-');
-       if (plugin_instance != NULL)
-       {
-               *plugin_instance = '\0';
-               plugin_instance++;
-       }
-
-       type_instance = strchr (type, '-');
-       if (type_instance != NULL)
-       {
-               *type_instance = '\0';
-               type_instance++;
-       }
-
-       *ret_host = hostname;
-       *ret_plugin = plugin;
-       *ret_plugin_instance = plugin_instance;
-       *ret_type = type;
-       *ret_type_instance = type_instance;
-       return (0);
-} /* int parse_identifier */
-
 static value_cache_t *cache_search (const char *name)
 {
        value_cache_t *vc;
@@ -568,12 +522,12 @@ static int us_handle_putval (FILE *fh, char **fields, int fields_num)
                return (-1);
        }
 
-       if ((strlen (hostname) > sizeof (vl.host))
-                       || (strlen (plugin) > sizeof (vl.plugin))
+       if ((strlen (hostname) >= sizeof (vl.host))
+                       || (strlen (plugin) >= sizeof (vl.plugin))
                        || ((plugin_instance != NULL)
-                               && (strlen (plugin_instance) > sizeof (vl.plugin_instance)))
+                               && (strlen (plugin_instance) >= sizeof (vl.plugin_instance)))
                        || ((type_instance != NULL)
-                               && (strlen (type_instance) > sizeof (vl.type_instance))))
+                               && (strlen (type_instance) >= sizeof (vl.type_instance))))
        {
                fprintf (fh, "-1 Identifier too long.");
                return (-1);