projects
/
collectd.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
command parser: Add a vector-based interface.
[collectd.git]
/
src
/
ascent.c
diff --git
a/src/ascent.c
b/src/ascent.c
index
11175af
..
16568e6
100644
(file)
--- a/
src/ascent.c
+++ b/
src/ascent.c
@@
-25,14
+25,14
@@
**/
#include "collectd.h"
**/
#include "collectd.h"
+
#include "common.h"
#include "plugin.h"
#include "common.h"
#include "plugin.h"
-#include "configfile.h"
#include <curl/curl.h>
#include <libxml/parser.h>
#include <curl/curl.h>
#include <libxml/parser.h>
-static char *races_list[] = /* {{{ */
+static c
onst c
har *races_list[] = /* {{{ */
{
NULL,
"Human", /* 1 */
{
NULL,
"Human", /* 1 */
@@
-49,7
+49,7
@@
static char *races_list[] = /* {{{ */
}; /* }}} */
#define RACES_LIST_LENGTH STATIC_ARRAY_SIZE (races_list)
}; /* }}} */
#define RACES_LIST_LENGTH STATIC_ARRAY_SIZE (races_list)
-static char *classes_list[] = /* {{{ */
+static c
onst c
har *classes_list[] = /* {{{ */
{
NULL,
"Warrior", /* 1 */
{
NULL,
"Warrior", /* 1 */
@@
-66,7
+66,7
@@
static char *classes_list[] = /* {{{ */
}; /* }}} */
#define CLASSES_LIST_LENGTH STATIC_ARRAY_SIZE (classes_list)
}; /* }}} */
#define CLASSES_LIST_LENGTH STATIC_ARRAY_SIZE (classes_list)
-static char *genders_list[] = /* {{{ */
+static c
onst c
har *genders_list[] = /* {{{ */
{
"Male",
"Female"
{
"Male",
"Female"
@@
-126,12
+126,9
@@
static int config_keys_num = STATIC_ARRAY_SIZE (config_keys);
static int ascent_submit_gauge (const char *plugin_instance, /* {{{ */
const char *type, const char *type_instance, gauge_t value)
{
static int ascent_submit_gauge (const char *plugin_instance, /* {{{ */
const char *type, const char *type_instance, gauge_t value)
{
- value_t values[1];
value_list_t vl = VALUE_LIST_INIT;
value_list_t vl = VALUE_LIST_INIT;
- values[0].gauge = value;
-
- vl.values = values;
+ vl.values = &(value_t) { .gauge = value };
vl.values_len = 1;
sstrncpy (vl.host, hostname_g, sizeof (vl.host));
sstrncpy (vl.plugin, "ascent", sizeof (vl.plugin));
vl.values_len = 1;
sstrncpy (vl.host, hostname_g, sizeof (vl.host));
sstrncpy (vl.plugin, "ascent", sizeof (vl.plugin));
@@
-154,14
+151,14
@@
static size_t ascent_curl_callback (void *buf, size_t size, size_t nmemb, /* {{{
{
size_t len = size * nmemb;
{
size_t len = size * nmemb;
- if (len
<
= 0)
+ if (len
=
= 0)
return (len);
if ((ascent_buffer_fill + len) >= ascent_buffer_size)
{
char *temp;
return (len);
if ((ascent_buffer_fill + len) >= ascent_buffer_size)
{
char *temp;
- temp =
(char *)
realloc (ascent_buffer,
+ temp = realloc (ascent_buffer,
ascent_buffer_fill + len + 1);
if (temp == NULL)
{
ascent_buffer_fill + len + 1);
if (temp == NULL)
{
@@
-181,20
+178,19
@@
static size_t ascent_curl_callback (void *buf, size_t size, size_t nmemb, /* {{{
static int ascent_submit_players (player_stats_t *ps) /* {{{ */
{
static int ascent_submit_players (player_stats_t *ps) /* {{{ */
{
- size_t i;
gauge_t value;
gauge_t value;
- for (i = 0; i < RACES_LIST_LENGTH; i++)
+ for (
size_t
i = 0; i < RACES_LIST_LENGTH; i++)
if (races_list[i] != NULL)
ascent_submit_gauge ("by-race", "players", races_list[i],
(gauge_t) ps->races[i]);
if (races_list[i] != NULL)
ascent_submit_gauge ("by-race", "players", races_list[i],
(gauge_t) ps->races[i]);
- for (i = 0; i < CLASSES_LIST_LENGTH; i++)
+ for (
size_t
i = 0; i < CLASSES_LIST_LENGTH; i++)
if (classes_list[i] != NULL)
ascent_submit_gauge ("by-class", "players", classes_list[i],
(gauge_t) ps->classes[i]);
if (classes_list[i] != NULL)
ascent_submit_gauge ("by-class", "players", classes_list[i],
(gauge_t) ps->classes[i]);
- for (i = 0; i < GENDERS_LIST_LENGTH; i++)
+ for (
size_t
i = 0; i < GENDERS_LIST_LENGTH; i++)
if (genders_list[i] != NULL)
ascent_submit_gauge ("by-gender", "players", genders_list[i],
(gauge_t) ps->genders[i]);
if (genders_list[i] != NULL)
ascent_submit_gauge ("by-gender", "players", genders_list[i],
(gauge_t) ps->genders[i]);
@@
-328,9
+324,7
@@
static int ascent_xml_read_int (xmlDoc *doc, xmlNode *node, /* {{{ */
static int ascent_xml_sessions_plr (xmlDoc *doc, xmlNode *node, /* {{{ */
player_info_t *pi)
{
static int ascent_xml_sessions_plr (xmlDoc *doc, xmlNode *node, /* {{{ */
player_info_t *pi)
{
- xmlNode *child;
-
- for (child = node->xmlChildrenNode; child != NULL; child = child->next)
+ for (xmlNode *child = node->xmlChildrenNode; child != NULL; child = child->next)
{
if ((xmlStrcmp ((const xmlChar *) "comment", child->name) == 0)
|| (xmlStrcmp ((const xmlChar *) "text", child->name) == 0))
{
if ((xmlStrcmp ((const xmlChar *) "comment", child->name) == 0)
|| (xmlStrcmp ((const xmlChar *) "text", child->name) == 0))
@@
-364,12
+358,11
@@
static int ascent_xml_sessions_plr (xmlDoc *doc, xmlNode *node, /* {{{ */
static int ascent_xml_sessions (xmlDoc *doc, xmlNode *node) /* {{{ */
{
static int ascent_xml_sessions (xmlDoc *doc, xmlNode *node) /* {{{ */
{
- xmlNode *child;
- player_stats_t ps;
+ player_stats_t ps = {
+ .level_sum = 0
+ };
- memset (&ps, 0, sizeof (ps));
-
- for (child = node->xmlChildrenNode; child != NULL; child = child->next)
+ for (xmlNode *child = node->xmlChildrenNode; child != NULL; child = child->next)
{
if ((xmlStrcmp ((const xmlChar *) "comment", child->name) == 0)
|| (xmlStrcmp ((const xmlChar *) "text", child->name) == 0))
{
if ((xmlStrcmp ((const xmlChar *) "comment", child->name) == 0)
|| (xmlStrcmp ((const xmlChar *) "text", child->name) == 0))
@@
-396,9
+389,7
@@
static int ascent_xml_sessions (xmlDoc *doc, xmlNode *node) /* {{{ */
static int ascent_xml_status (xmlDoc *doc, xmlNode *node) /* {{{ */
{
static int ascent_xml_status (xmlDoc *doc, xmlNode *node) /* {{{ */
{
- xmlNode *child;
-
- for (child = node->xmlChildrenNode; child != NULL; child = child->next)
+ for (xmlNode *child = node->xmlChildrenNode; child != NULL; child = child->next)
{
if ((xmlStrcmp ((const xmlChar *) "comment", child->name) == 0)
|| (xmlStrcmp ((const xmlChar *) "text", child->name) == 0))
{
if ((xmlStrcmp ((const xmlChar *) "comment", child->name) == 0)
|| (xmlStrcmp ((const xmlChar *) "text", child->name) == 0))
@@
-438,7
+429,6
@@
static int ascent_xml (const char *data) /* {{{ */
{
xmlDoc *doc;
xmlNode *cur;
{
xmlDoc *doc;
xmlNode *cur;
- xmlNode *child;
#if 0
doc = xmlParseMemory (data, strlen (data),
#if 0
doc = xmlParseMemory (data, strlen (data),
@@
-469,7
+459,7
@@
static int ascent_xml (const char *data) /* {{{ */
return (-1);
}
return (-1);
}
- for (child = cur->xmlChildrenNode; child != NULL; child = child->next)
+ for (
xmlNode *
child = cur->xmlChildrenNode; child != NULL; child = child->next)
{
if ((xmlStrcmp ((const xmlChar *) "comment", child->name) == 0)
|| (xmlStrcmp ((const xmlChar *) "text", child->name) == 0))
{
if ((xmlStrcmp ((const xmlChar *) "comment", child->name) == 0)
|| (xmlStrcmp ((const xmlChar *) "text", child->name) == 0))
@@
-594,8
+584,7
@@
static int ascent_init (void) /* {{{ */
if (timeout != NULL)
curl_easy_setopt (curl, CURLOPT_TIMEOUT_MS, atol(timeout));
else
if (timeout != NULL)
curl_easy_setopt (curl, CURLOPT_TIMEOUT_MS, atol(timeout));
else
- curl_easy_setopt (curl, CURLOPT_TIMEOUT_MS,
- CDTIME_T_TO_MS(plugin_get_interval()));
+ curl_easy_setopt (curl, CURLOPT_TIMEOUT_MS, (long) CDTIME_T_TO_MS(plugin_get_interval()));
#endif
return (0);
#endif
return (0);