summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: da9559c)
raw | patch | inline | side by side (parent: da9559c)
author | Pavel Rochnyack <pavel2000@ngs.ru> | |
Wed, 24 Feb 2016 13:20:27 +0000 (20:20 +0700) | ||
committer | Pavel Rochnyack <pavel2000@ngs.ru> | |
Sat, 30 Sep 2017 10:25:49 +0000 (17:25 +0700) |
src/curl_xml.c | patch | blob | history |
diff --git a/src/curl_xml.c b/src/curl_xml.c
index e83de73ea6c07cefe0595af6342417a61bc86d48..074a2d199999ae1c60f12775fa5267a253d12e74 100644 (file)
--- a/src/curl_xml.c
+++ b/src/curl_xml.c
struct cx_s /* {{{ */
{
char *instance;
+ char *plugin_name;
char *host;
char *url;
sfree(db->buffer);
sfree(db->instance);
+ sfree(db->plugin_name);
sfree(db->host);
sfree(db->url);
sfree(db);
} /* }}} void cx_free */
-static const char *cx_host(cx_t *db) /* {{{ */
+static const char *cx_host(const cx_t *db) /* {{{ */
{
if (db->host == NULL)
return hostname_g;
return 0;
} /* }}} int cx_handle_instance_xpath */
-static int cx_handle_base_xpath(char const *plugin_instance, /* {{{ */
- char const *host, xmlXPathContextPtr xpath_ctx,
+static int cx_handle_base_xpath(const cx_t *db, /* {{{ */
+ xmlXPathContextPtr xpath_ctx,
const data_set_t *ds, char *base_xpath,
cx_xpath_t *xpath) {
int total_nodes;
/* set the values for the value_list */
vl.values_len = ds->ds_num;
sstrncpy(vl.type, xpath->type, sizeof(vl.type));
- sstrncpy(vl.plugin, "curl_xml", sizeof(vl.plugin));
- sstrncpy(vl.host, host, sizeof(vl.host));
- if (plugin_instance != NULL)
- sstrncpy(vl.plugin_instance, plugin_instance, sizeof(vl.plugin_instance));
+ sstrncpy(vl.plugin, (db->plugin_name != NULL) ? db->plugin_name : "curl_xml",
+ sizeof(vl.plugin));
+ sstrncpy(vl.host, cx_host(db), sizeof(vl.host));
+ if (db->instance != NULL)
+ sstrncpy(vl.plugin_instance, db->instance, sizeof(vl.plugin_instance));
for (int i = 0; i < total_nodes; i++) {
int status;
ds = plugin_get_ds(xpath->type);
if ((cx_check_type(ds, xpath) == 0) &&
- (cx_handle_base_xpath(db->instance, cx_host(db), xpath_ctx, ds, le->key,
- xpath) == 0))
+ (cx_handle_base_xpath(db, xpath_ctx, ds, le->key, xpath) == 0))
status = 0; /* we got atleast one success */
le = le->next;
if (strcasecmp("Instance", child->key) == 0)
status = cf_util_get_string(child, &db->instance);
+ else if (strcasecmp("PluginName", child->key) == 0)
+ status = cf_util_get_string(child, &db->plugin_name);
else if (strcasecmp("Host", child->key) == 0)
status = cf_util_get_string(child, &db->host);
else if (strcasecmp("User", child->key) == 0)