X-Git-Url: https://git.octo.it/?a=blobdiff_plain;f=src%2Fcurl_xml.c;h=0bed05a5fb50140595bf3dd2396a43de359a720f;hb=733fc645b6389d1f42aef8f1c1631f1db7d58196;hp=f5a29b0fa80bdeb225f0f89c60103f3db705716b;hpb=dc415e502ffa5845e3c30ae8160e72934f0c725d;p=collectd.git diff --git a/src/curl_xml.c b/src/curl_xml.c index f5a29b0f..0bed05a5 100644 --- a/src/curl_xml.c +++ b/src/curl_xml.c @@ -79,9 +79,9 @@ struct cx_s /* {{{ */ char *user; char *pass; char *credentials; - _Bool digest; - _Bool verify_peer; - _Bool verify_host; + bool digest; + bool verify_peer; + bool verify_host; char *cacert; char *post_body; int timeout; @@ -240,8 +240,8 @@ static int cx_check_type(const data_set_t *ds, cx_xpath_t *xpath) /* {{{ */ } if (ds->ds_num != xpath->values_len) { - WARNING("curl_xml plugin: DataSet `%s' requires %zu values, but config " - "talks about %zu", + WARNING("curl_xml plugin: DataSet `%s' requires %" PRIsz + " values, but config talks about %" PRIsz, xpath->type, ds->ds_num, xpath->values_len); return -1; } @@ -276,6 +276,9 @@ static int cx_if_not_text_node(xmlNodePtr node) /* {{{ */ return -1; } /* }}} cx_if_not_text_node */ +/* + * Returned value should be freed with xmlFree(). + */ static char *cx_get_text_node_value(xmlXPathContextPtr xpath_ctx, /* {{{ */ char *expr, const char *from_option) { xmlXPathObjectPtr values_node_obj = cx_evaluate_xpath(xpath_ctx, expr); @@ -353,7 +356,7 @@ static int cx_handle_single_value_xpath(xmlXPathContextPtr xpath_ctx, /* {{{ */ /* endptr = */ NULL); } - sfree(node_value); + xmlFree(node_value); /* We have reached here which means that * we have got something to work */ @@ -397,7 +400,7 @@ static int cx_handle_instance_xpath(xmlXPathContextPtr xpath_ctx, /* {{{ */ else sstrncpy(vl->type_instance, node_value, sizeof(vl->type_instance)); - sfree(node_value); + xmlFree(node_value); } else if (xpath->instance_prefix != NULL) sstrncpy(vl->type_instance, xpath->instance_prefix, sizeof(vl->type_instance)); @@ -411,7 +414,7 @@ static int cx_handle_instance_xpath(xmlXPathContextPtr xpath_ctx, /* {{{ */ return -1; sstrncpy(vl->plugin_instance, node_value, sizeof(vl->plugin_instance)); - sfree(node_value); + xmlFree(node_value); } return 0; @@ -820,6 +823,8 @@ static int cx_config_add_url(oconfig_item_t *ci) /* {{{ */ return status; } + cdtime_t interval = 0; + /* Fill the `cx_t' structure.. */ for (int i = 0; i < ci->children_num; i++) { oconfig_item_t *child = ci->children + i; @@ -850,6 +855,8 @@ static int cx_config_add_url(oconfig_item_t *ci) /* {{{ */ status = cf_util_get_string(child, &db->post_body); else if (strcasecmp("Namespace", child->key) == 0) status = cx_config_add_namespace(db, child); + else if (strcasecmp("Interval", child->key) == 0) + status = cf_util_get_cdtime(child, &interval); else if (strcasecmp("Timeout", child->key) == 0) status = cf_util_get_int(child, &db->timeout); else if (strcasecmp("Statistics", child->key) == 0) { @@ -888,7 +895,7 @@ static int cx_config_add_url(oconfig_item_t *ci) /* {{{ */ char *cb_name = ssnprintf_alloc("curl_xml-%s-%s", db->instance, db->url); plugin_register_complex_read(/* group = */ "curl_xml", cb_name, cx_read, - /* interval = */ 0, + /* interval = */ interval, &(user_data_t){ .data = db, .free_func = cx_free, });