test-libudev.c | test-libudev.c | |||
---|---|---|---|---|
/*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/ | ||||
/*** | /*** | |||
This file is part of systemd. | This file is part of systemd. | |||
Copyright 2008-2012 Kay Sievers <kay@vrfy.org> | Copyright 2008-2012 Kay Sievers <kay@vrfy.org> | |||
systemd is free software; you can redistribute it and/or modify it | systemd is free software; you can redistribute it and/or modify it | |||
under the terms of the GNU Lesser General Public License as published by | under the terms of the GNU Lesser General Public License as published by | |||
the Free Software Foundation; either version 2.1 of the License, or | the Free Software Foundation; either version 2.1 of the License, or | |||
(at your option) any later version. | (at your option) any later version. | |||
skipping to change at line 27 | skipping to change at line 28 | |||
along with systemd; If not, see <http://www.gnu.org/licenses/>. | along with systemd; If not, see <http://www.gnu.org/licenses/>. | |||
***/ | ***/ | |||
#include <stdio.h> | #include <stdio.h> | |||
#include <stdarg.h> | #include <stdarg.h> | |||
#include <stdlib.h> | #include <stdlib.h> | |||
#include <unistd.h> | #include <unistd.h> | |||
#include <errno.h> | #include <errno.h> | |||
#include <string.h> | #include <string.h> | |||
#include <getopt.h> | #include <getopt.h> | |||
#include <syslog.h> | ||||
#include <fcntl.h> | #include <fcntl.h> | |||
#include <sys/epoll.h> | #include <sys/epoll.h> | |||
#include "libudev.h" | #include "libudev.h" | |||
#include "udev-util.h" | #include "udev-util.h" | |||
#include "util.h" | #include "util.h" | |||
#define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0])) | #define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0])) | |||
_printf_(6,0) | _printf_(6,0) | |||
skipping to change at line 426 | skipping to change at line 426 | |||
{ "syspath", required_argument, NULL, 'p' }, | { "syspath", required_argument, NULL, 'p' }, | |||
{ "subsystem", required_argument, NULL, 's' }, | { "subsystem", required_argument, NULL, 's' }, | |||
{ "debug", no_argument, NULL, 'd' }, | { "debug", no_argument, NULL, 'd' }, | |||
{ "help", no_argument, NULL, 'h' }, | { "help", no_argument, NULL, 'h' }, | |||
{ "version", no_argument, NULL, 'V' }, | { "version", no_argument, NULL, 'V' }, | |||
{} | {} | |||
}; | }; | |||
const char *syspath = "/devices/virtual/mem/null"; | const char *syspath = "/devices/virtual/mem/null"; | |||
const char *subsystem = NULL; | const char *subsystem = NULL; | |||
char path[1024]; | char path[1024]; | |||
int c; | ||||
udev = udev_new(); | udev = udev_new(); | |||
printf("context: %p\n", udev); | printf("context: %p\n", udev); | |||
if (udev == NULL) { | if (udev == NULL) { | |||
printf("no context\n"); | printf("no context\n"); | |||
return 1; | return 1; | |||
} | } | |||
udev_set_log_fn(udev, log_fn); | udev_set_log_fn(udev, log_fn); | |||
printf("set log: %p\n", log_fn); | printf("set log: %p\n", log_fn); | |||
for (;;) { | while ((c = getopt_long(argc, argv, "p:s:dhV", options, NULL)) >= 0 | |||
int option; | ) | |||
switch (c) { | ||||
option = getopt_long(argc, argv, "+p:s:dhV", options, NULL) | ||||
; | ||||
if (option == -1) | ||||
break; | ||||
switch (option) { | ||||
case 'p': | case 'p': | |||
syspath = optarg; | syspath = optarg; | |||
break; | break; | |||
case 's': | case 's': | |||
subsystem = optarg; | subsystem = optarg; | |||
break; | break; | |||
case 'd': | case 'd': | |||
if (udev_get_log_priority(udev) < LOG_INFO) | if (udev_get_log_priority(udev) < LOG_INFO) | |||
udev_set_log_priority(udev, LOG_INFO); | udev_set_log_priority(udev, LOG_INFO); | |||
break; | break; | |||
case 'h': | case 'h': | |||
printf("--debug --syspath= --subsystem= --help\n"); | printf("--debug --syspath= --subsystem= --help\n"); | |||
goto out; | goto out; | |||
case 'V': | case 'V': | |||
printf("%s\n", VERSION); | printf("%s\n", VERSION); | |||
goto out; | goto out; | |||
default: | ||||
case '?': | ||||
goto out; | goto out; | |||
default: | ||||
assert_not_reached("Unhandled option code."); | ||||
} | } | |||
} | ||||
/* add sys path if needed */ | /* add sys path if needed */ | |||
if (!startswith(syspath, "/sys")) { | if (!startswith(syspath, "/sys")) { | |||
snprintf(path, sizeof(path), "/sys/%s", syspath); | snprintf(path, sizeof(path), "/sys/%s", syspath); | |||
syspath = path; | syspath = path; | |||
} | } | |||
test_device(udev, syspath); | test_device(udev, syspath); | |||
test_device_devnum(udev); | test_device_devnum(udev); | |||
test_device_subsys_name(udev); | test_device_subsys_name(udev); | |||
End of changes. 12 change blocks. | ||||
11 lines changed or deleted | 14 lines changed or added | |||
This html diff was produced by rfcdiff 1.41. The latest version is available from http://tools.ietf.org/tools/rfcdiff/ |