#include "libudev.h"
#include "libudev-private.h"
-static bool debug;
-
-_printf_(6,0)
-static void log_fn(struct udev *udev, int priority,
- const char *file, int line, const char *fn,
- const char *format, va_list args)
-{
- if (debug) {
- fprintf(stderr, "%s: ", fn);
- vfprintf(stderr, format, args);
- } else {
- vsyslog(priority, format, args);
- }
-}
-
/* device info */
static unsigned int cd_cd_rom;
static unsigned int cd_cd_r;
switch (feature) {
case 0x00:
log_debug("GET CONFIGURATION: feature 'profiles', with %i entries", features[i+3] / 4);
- feature_profiles(udev, &features[i]+4, features[i+3]);
+ feature_profiles(udev, &features[i]+4, MIN(features[i+3], len - i - 4));
break;
default:
log_debug("GET CONFIGURATION: feature 0x%04x <ignored>, with 0x%02x bytes", feature, features[i+3]);
int cnt;
int rc = 0;
+ log_parse_environment();
+ log_open();
+
udev = udev_new();
if (udev == NULL)
goto exit;
- log_open();
- udev_set_log_fn(udev, log_fn);
-
while (1) {
int option;
eject = true;
break;
case 'd':
- debug = true;
+ log_set_target(LOG_TARGET_CONSOLE);
log_set_max_level(LOG_DEBUG);
- udev_set_log_priority(udev, LOG_DEBUG);
+ log_open();
break;
case 'h':
printf("Usage: cdrom_id [options] <device>\n"
goto exit;
}
- srand((unsigned int)getpid());
+ initialize_srand();
for (cnt = 20; cnt > 0; cnt--) {
struct timespec duration;