#include <unistd.h>
#include <syslog.h>
-#include "udev.h"
-#include "udev_version.h"
-
#undef info
#define info(format, arg...) \
do { \
} while (0)
#endif
+/* each program must declare this variable and function somewhere */
+extern unsigned char logname[42];
+extern int log_ok(void);
+
static void log_message (int level, const char *format, ...)
__attribute__ ((format (printf, 2, 3)));
static inline void log_message (int level, const char *format, ...)
{
va_list args;
- if (0 != strncmp(udev_log_str, UDEV_LOG_DEFAULT, BOOL_SIZE))
+ if (!log_ok())
return;
va_start(args, format);
va_end(args);
}
-/* each program must declare this variable somewhere */
-extern unsigned char logname[42];
-
#undef init_logging
static inline void init_logging(char *program_name)
{
char default_mode_str[MODE_SIZE];
char default_owner_str[OWNER_SIZE];
char default_group_str[GROUP_SIZE];
-char udev_log_str[BOOL_SIZE];
+int udev_log;
+static int string_is_true(char *str)
+{
+ if (strcasecmp(str, "true") == 0)
+ return 1;
+ if (strcasecmp(str, "yes") == 0)
+ return 1;
+ return 0;
+}
+
static void init_variables(void)
{
/* fill up the defaults.
strfieldcpy(udev_config_filename, UDEV_CONFIG_FILE);
strfieldcpy(udev_rules_filename, UDEV_RULES_FILE);
strfieldcpy(udev_permissions_filename, UDEV_PERMISSION_FILE);
- strfieldcpy(udev_log_str, UDEV_LOG_DEFAULT);
+ udev_log = string_is_true(UDEV_LOG_DEFAULT);
}
#define set_var(_name, _var) \
strncpy(_var, value, sizeof(_var)); \
}
+#define set_bool(_name, _var) \
+ if (strcasecmp(variable, _name) == 0) { \
+ dbg_parse("%s = '%s'", _name, value); \
+ _var = string_is_true(value); \
+ }
+
int parse_get_pair(char **orig_string, char **left, char **right)
{
char *temp;
set_var("default_mode", default_mode_str);
set_var("default_owner", default_owner_str);
set_var("default_group", default_group_str);
- set_var("udev_log", udev_log_str);
+ set_bool("udev_log", udev_log);
}
dbg_parse("%s:%d:%Zd: error parsing '%s'", udev_config_filename,
lineno, temp - line, temp);
dbg_parse("udev_db_filename = %s", udev_db_filename);
dbg_parse("udev_rules_filename = %s", udev_rules_filename);
dbg_parse("udev_permissions_filename = %s", udev_permissions_filename);
- dbg_parse("udev_log_str = %s", udev_log_str);
+ dbg_parse("udev_log = %d", udev_log);
parse_config_file();
dbg_parse("udev_root = %s", udev_root);
dbg_parse("udev_db_filename = %s", udev_db_filename);
dbg_parse("udev_rules_filename = %s", udev_rules_filename);
dbg_parse("udev_permissions_filename = %s", udev_permissions_filename);
- dbg_parse("udev_log_str = %s", udev_log_str);
+ dbg_parse("udev_log_str = %d", udev_log);
}
void udev_init_config(void)