summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 232d518)
raw | patch | inline | side by side (parent: 232d518)
author | Florian Forster <octo@leeloo.lan.home.verplant.org> | |
Tue, 27 Mar 2007 15:24:21 +0000 (17:24 +0200) | ||
committer | Florian Forster <octo@leeloo.lan.home.verplant.org> | |
Tue, 27 Mar 2007 15:24:21 +0000 (17:24 +0200) |
src/unixsock.c | patch | blob | history |
diff --git a/src/unixsock.c b/src/unixsock.c
index 95ccb9da38cb3f266df901bb4781ca8c0269fa44..75f3117e1e54136f2be78d2037df7c1d9316874a 100644 (file)
--- a/src/unixsock.c
+++ b/src/unixsock.c
return (vc);
} /* value_cache_t *cache_search */
-static int cache_alloc_name (char *ret, int ret_len,
- const char *hostname,
- const char *plugin, const char *plugin_instance,
- const char *type, const char *type_instance)
-{
- int status;
-
- assert (plugin != NULL);
- assert (type != NULL);
-
- if ((plugin_instance == NULL) || (strlen (plugin_instance) == 0))
- {
- if ((type_instance == NULL) || (strlen (type_instance) == 0))
- status = snprintf (ret, ret_len, "%s/%s/%s",
- hostname, plugin, type);
- else
- status = snprintf (ret, ret_len, "%s/%s/%s-%s",
- hostname, plugin, type, type_instance);
- }
- else
- {
- if ((type_instance == NULL) || (strlen (type_instance) == 0))
- status = snprintf (ret, ret_len, "%s/%s-%s/%s",
- hostname, plugin, plugin_instance, type);
- else
- status = snprintf (ret, ret_len, "%s/%s-%s/%s-%s",
- hostname, plugin, plugin_instance, type, type_instance);
- }
-
- if ((status < 1) || (status >= ret_len))
- return (-1);
- return (0);
-} /* int cache_alloc_name */
-
static int cache_insert (const data_set_t *ds, const value_list_t *vl)
{
/* We're called from `cache_update' so we don't need to lock the mutex */
return (-1);
}
- if (cache_alloc_name (vc->name, sizeof (vc->name),
- vl->host, vl->plugin, vl->plugin_instance,
- ds->type, vl->type_instance) != 0)
+ if (FORMAT_VL (vc->name, sizeof (vc->name), vl, ds))
{
pthread_mutex_unlock (&cache_lock);
- ERROR ("unixsock plugin: cache_alloc_name failed.");
+ ERROR ("unixsock plugin: FORMAT_VL failed.");
free (vc->counter);
free (vc->gauge);
free (vc);
value_cache_t *vc;
int i;
- if (cache_alloc_name (name, sizeof (name),
- vl->host,
- vl->plugin, vl->plugin_instance,
- ds->type, vl->type_instance) != 0)
+ if (FORMAT_VL (name, sizeof (name), vl, ds) != 0)
return (-1);
pthread_mutex_lock (&cache_lock);
return (-1);
}
- status = cache_alloc_name (name, sizeof (name),
+ status = format_name (name, sizeof (name),
hostname, plugin, plugin_instance, type, type_instance);
/* FIXME: Send some response */
if (status != 0)