diff --git a/src/configfile.c b/src/configfile.c
index 91bef48cd076c281e436ee430718620c87db0669..40b46fab2d9fb160639ddf24956fd8263c60ade8 100644 (file)
--- a/src/configfile.c
+++ b/src/configfile.c
/**
* collectd - src/configfile.c
/**
* collectd - src/configfile.c
- * Copyright (C) 2005 Florian octo Forster
+ * Copyright (C) 2005,2006 Florian octo Forster
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the
#define ERR_NEEDS_ARG "Section `%s' needs an argument.\n"
#define ERR_NEEDS_SECTION "`%s' can only be used within a section.\n"
#define ERR_NEEDS_ARG "Section `%s' needs an argument.\n"
#define ERR_NEEDS_SECTION "`%s' can only be used within a section.\n"
+#define ESCAPE_NULL(str) ((str) == NULL ? "(null)" : (str))
+
+#define DEBUG_CALLBACK(shortvar, var, arguments, value) \
+ DBG("shortvar = %s, var = %s, arguments = %s, value = %s, ...", \
+ ESCAPE_NULL(shortvar), \
+ ESCAPE_NULL(var), \
+ ESCAPE_NULL(arguments), \
+ ESCAPE_NULL(value))
+
extern int operating_mode;
typedef struct cf_callback
extern int operating_mode;
typedef struct cf_callback
@@ -102,7 +111,10 @@ static int cf_dispatch (char *type, const char *orig_key, const char *orig_value
int ret;
int i;
int ret;
int i;
- DBG ("type = %s, key = %s, value = %s", type, orig_key, orig_value);
+ DBG ("type = %s, key = %s, value = %s",
+ ESCAPE_NULL(type),
+ ESCAPE_NULL(orig_key),
+ ESCAPE_NULL(orig_value));
if ((cf_cb = cf_search (type)) == NULL)
{
if ((cf_cb = cf_search (type)) == NULL)
{
}
else
{
}
else
{
- DBG ("Key was truncated: `%s'", keys[i]);
+ DBG ("Key was truncated: `%s'", ESCAPE_NULL(keys[i]));
}
}
}
}
}
}
const char *arguments, const char *value, lc_flags_t flags,
void *extra)
{
const char *arguments, const char *value, lc_flags_t flags,
void *extra)
{
- DBG ("shortvar = %s, var = %s, arguments = %s, value = %s, ...",
- shortvar, var, arguments, value);
+ DEBUG_CALLBACK (shortvar, var, arguments, value);
if (strcasecmp (value, "Client") == 0)
operating_mode = MODE_CLIENT;
if (strcasecmp (value, "Client") == 0)
operating_mode = MODE_CLIENT;
operating_mode = MODE_SERVER;
else if (strcasecmp (value, "Local") == 0)
operating_mode = MODE_LOCAL;
operating_mode = MODE_SERVER;
else if (strcasecmp (value, "Local") == 0)
operating_mode = MODE_LOCAL;
+#else /* !HAVE_LIBRRD */
+ else if (strcasecmp (value, "Server") == 0)
+ {
+ fprintf (stderr, "Invalid mode `Server': "
+ "You need to link against librrd for this "
+ "mode to be available.\n");
+ syslog (LOG_ERR, "Invalid mode `Server': "
+ "You need to link against librrd for this "
+ "mode to be available.");
+ return (LC_CBRET_ERROR);
+ }
+ else if (strcasecmp (value, "Local") == 0)
+ {
+ fprintf (stderr, "Invalid mode `Local': "
+ "You need to link against librrd for this "
+ "mode to be available.\n");
+ syslog (LOG_ERR, "Invalid mode `Local': "
+ "You need to link against librrd for this "
+ "mode to be available.");
+ return (LC_CBRET_ERROR);
+ }
#endif
else if (strcasecmp (value, "Log") == 0)
operating_mode = MODE_LOG;
#endif
else if (strcasecmp (value, "Log") == 0)
operating_mode = MODE_LOG;
const char *arguments, const char *value, lc_flags_t flags,
void *extra)
{
const char *arguments, const char *value, lc_flags_t flags,
void *extra)
{
- DBG ("shortvar = %s, var = %s, arguments = %s, value = %s, ...",
- shortvar, var, arguments, value);
+ DEBUG_CALLBACK (shortvar, var, arguments, value);
plugin_set_dir (value);
plugin_set_dir (value);
{
cf_mode_item_t *item;
{
cf_mode_item_t *item;
- DBG ("shortvar = %s, var = %s, arguments = %s, value = %s, ...",
- shortvar, var, arguments, value);
+ DEBUG_CALLBACK (shortvar, var, arguments, value);
if (extra == NULL)
{
if (extra == NULL)
{
const char *arguments, const char *value, lc_flags_t flags,
void *extra)
{
const char *arguments, const char *value, lc_flags_t flags,
void *extra)
{
- DBG ("shortvar = %s, var = %s, arguments = %s, value = %s, ...",
- shortvar, var, arguments, value);
+ DEBUG_CALLBACK (shortvar, var, arguments, value);
if (plugin_load (value))
syslog (LOG_ERR, "plugin_load (%s): failed to load plugin", value);
if (plugin_load (value))
syslog (LOG_ERR, "plugin_load (%s): failed to load plugin", value);
char *node;
char *service = NET_DEFAULT_PORT;
char *node;
char *service = NET_DEFAULT_PORT;
- DBG ("shortvar = %s, var = %s, arguments = %s, value = %s, ...",
- shortvar, var, arguments, value);
+ DEBUG_CALLBACK (shortvar, var, arguments, value);
buffer = strdup (value);
if (buffer == NULL)
buffer = strdup (value);
if (buffer == NULL)
const char *arguments, const char *value, lc_flags_t flags,
void *extra)
{
const char *arguments, const char *value, lc_flags_t flags,
void *extra)
{
- DBG ("shortvar = %s, var = %s, arguments = %s, value = %s, ...",
- shortvar, var, arguments, value);
+ DEBUG_CALLBACK (shortvar, var, arguments, value);
if (flags == LC_FLAGS_SECTIONSTART)
{
if (flags == LC_FLAGS_SECTIONSTART)
{
const char *arguments, const char *value, lc_flags_t flags,
void *extra)
{
const char *arguments, const char *value, lc_flags_t flags,
void *extra)
{
- DBG ("shortvar = %s, var = %s, arguments = %s, value = %s, ...",
- shortvar, var, arguments, value);
+ DEBUG_CALLBACK (shortvar, var, arguments, value);
if ((nesting_depth == 0) || (current_module == NULL))
{
if ((nesting_depth == 0) || (current_module == NULL))
{