summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 3cf46d9)
raw | patch | inline | side by side (parent: 3cf46d9)
author | octo <octo> | |
Mon, 16 Jan 2006 20:49:10 +0000 (20:49 +0000) | ||
committer | octo <octo> | |
Mon, 16 Jan 2006 20:49:10 +0000 (20:49 +0000) |
Added config option `LogFile'
Removed the config options `Client', `Server' and `Local'
Removed the config options `Client', `Server' and `Local'
configure.in | patch | blob | history | |
src/collectd.c | patch | blob | history | |
src/configfile.c | patch | blob | history | |
src/configfile.h | patch | blob | history |
diff --git a/configure.in b/configure.in
index 1ae7ec2a648c64646206e0b1c1968a8874f5bb42..fcc40551ef008f0fe185f2d627ba18d2afb742eb 100644 (file)
--- a/configure.in
+++ b/configure.in
dnl Process this file with autoconf to produce a configure script.
-AC_INIT(collectd, 3.6.alpha1)
+AC_INIT(collectd, 3.6.alpha2)
AC_CONFIG_SRCDIR(src/collectd.c)
AC_CONFIG_HEADERS(src/config.h)
AM_INIT_AUTOMAKE(dist-bzip2)
diff --git a/src/collectd.c b/src/collectd.c
index 190e043a52649a2ae0105e899ad34b2996cf956c..aacc96e3d1de6c1f9b254454c90d9de7043e516f 100644 (file)
--- a/src/collectd.c
+++ b/src/collectd.c
} /* while (1) */
#if COLLECT_DEBUG
- if ((logfile = cf_get_mode_option ("LogFile")) != NULL)
+ if ((logfile = cf_get_option ("LogFile", LOGFILE)) != NULL)
DBG_STARTFILE (logfile, "Debug file opened.");
#endif
* Change directory. We do this _after_ reading the config and loading
* modules to relative paths work as expected.
*/
- if ((datadir = cf_get_mode_option ("DataDir")) == NULL)
+ if ((datadir = cf_get_option ("DataDir", PKGLOCALSTATEDIR)) == NULL)
{
fprintf (stderr, "Don't have a datadir to use. This should not happen. Ever.");
return (1);
sigChldAction.sa_handler = SIG_IGN;
sigaction (SIGCHLD, &sigChldAction, NULL);
- if ((pidfile = cf_get_mode_option ("PIDFile")) == NULL)
+ if ((pidfile = cf_get_option ("PIDFile", PIDFILE)) == NULL)
{
fprintf (stderr, "Cannot obtain pidfile. This shoud not happen. Ever.");
return (1);
diff --git a/src/configfile.c b/src/configfile.c
index 21fcc8d36012ba7a78f0bc26c4a7782337e5a3e7..ed8cb77e438138aa01044f063d5f64bb94914936 100644 (file)
--- a/src/configfile.c
+++ b/src/configfile.c
*/
static cf_mode_item_t cf_mode_list[] =
{
- {"Server", NULL, MODE_CLIENT },
- {"Port", NULL, MODE_CLIENT | MODE_SERVER },
- {"PIDFile", PIDFILE, MODE_CLIENT | MODE_SERVER | MODE_LOCAL},
- {"DataDir", PKGLOCALSTATEDIR, MODE_SERVER | MODE_LOCAL},
- {"LogFile", LOGFILE, MODE_SERVER | MODE_SERVER | MODE_LOCAL},
+ {"Server", NULL, MODE_CLIENT },
+ {"Port", NULL, MODE_CLIENT | MODE_SERVER },
+ {"PIDFile", NULL, MODE_CLIENT | MODE_SERVER | MODE_LOCAL},
+ {"DataDir", NULL, MODE_SERVER | MODE_LOCAL},
+ {"LogFile", NULL, MODE_SERVER | MODE_SERVER | MODE_LOCAL}
};
-static int cf_mode_num = 4;
+static int cf_mode_num = 5;
static int nesting_depth = 0;
static char *current_module = NULL;
/*
* Other query functions
*/
-char *cf_get_mode_option (const char *key)
+char *cf_get_option (const char *key, char *def)
{
int i;
if ((cf_mode_list[i].mode & operating_mode) == 0)
continue;
- if (strcasecmp (cf_mode_list[i].key, key) == 0)
+ if (strcasecmp (cf_mode_list[i].key, key) != 0)
+ continue;
+
+ if (cf_mode_list[i].value != NULL)
return (cf_mode_list[i].value);
+ return (def);
}
return (NULL);
return;
run_once = 1;
- lc_register_callback ("Client", SHORTOPT_NONE, LC_VAR_NONE,
- cf_callback_mode_switch, NULL);
- lc_register_callback ("Local", SHORTOPT_NONE, LC_VAR_NONE,
- cf_callback_mode_switch, NULL);
- lc_register_callback ("Server", SHORTOPT_NONE, LC_VAR_NONE,
- cf_callback_mode_switch, NULL);
-
lc_register_callback ("Mode", SHORTOPT_NONE, LC_VAR_STRING,
cf_callback_mode, NULL);
lc_register_callback ("Plugin", SHORTOPT_NONE, LC_VAR_SECTION,
for (i = 0; i < cf_mode_num; i++)
{
- char longvar[256];
cf_mode_item_t *item;
item = &cf_mode_list[i];
- if (snprintf (longvar, 256, "Mode.%s", item->key) >= 256)
- continue;
-
- lc_register_callback (longvar, SHORTOPT_NONE, LC_VAR_STRING,
+ lc_register_callback (item->key, SHORTOPT_NONE, LC_VAR_STRING,
cf_callback_mode_option, (void *) item);
}
}
diff --git a/src/configfile.h b/src/configfile.h
index e9d31104ee08f5de245edf1109eab53370dfc4bb..8a34e7e96f31f6b3358a5ab5b0ae1584b033cf7e 100644 (file)
--- a/src/configfile.h
+++ b/src/configfile.h
/*
* DESCRIPTION
- * `cf_get_mode_option' returns options from the <Mode> section(s).
+ * `cf_get_option' returns various general options.
*
* PARAMETERS
* `key' Name of the option to query.
+ * `def' Pointer to return as default value.
*
* RETURN VALUE
* The pointer returned is part of an internal structure and may not be
* changed. If the option is not found for whatever reason (wrong key, option
* not allowed for currently selected mode, ...) `NULL' is returned.
*/
-char *cf_get_mode_option (const char *key);
+char *cf_get_option (const char *key, char *def);
/*
* DESCRIPTION