#include <getopt.h>
-#include "sd-hwdb.h"
-
-#include "alloc-util.h"
#include "hwdb-util.h"
-#include "string-util.h"
#include "udevadm.h"
#include "util.h"
static bool arg_update = false;
static bool arg_strict = false;
-static int hwdb_test(void) {
- _cleanup_(sd_hwdb_unrefp) sd_hwdb *hwdb = NULL;
- const char *key, *value;
- int r;
-
- r = sd_hwdb_new(&hwdb);
- if (r < 0)
- return r;
-
- SD_HWDB_FOREACH_PROPERTY(hwdb, arg_test, key, value)
- printf("%s=%s\n", key, value);
-
- return 0;
-}
-
static int help(void) {
printf("%s hwdb [OPTIONS]\n\n"
" -h --help Print this message\n"
arg_root = optarg;
break;
case 'V':
- return version();
+ return print_version();
case 'h':
return help();
case '?':
int hwdb_main(int argc, char *argv[], void *userdata) {
int r;
- log_set_max_level_realm(LOG_REALM_SYSTEMD, log_get_max_level());
-
r = parse_argv(argc, argv);
if (r <= 0)
return r;
- if (!arg_update && !arg_test) {
- log_error("Either --update or --test must be used.");
- return -EINVAL;
- }
+ if (!arg_update && !arg_test)
+ return log_error_errno(SYNTHETIC_ERRNO(EINVAL),
+ "Either --update or --test must be used.");
if (arg_update) {
r = hwdb_update(arg_root, arg_hwdb_bin_dir, arg_strict, true);
}
if (arg_test)
- return hwdb_test();
+ return hwdb_query(arg_test);
return 0;
}