chiark / gitweb /
Remove src/hostname
[elogind.git] / src / hwdb / hwdb.c
index 4fce30da05f11921d1decd211c33752330110084..446de3a2fc330f4f10d52fec816e5d376ee719ea 100644 (file)
@@ -18,7 +18,6 @@
 ***/
 
 #include <stdlib.h>
-#include <unistd.h>
 #include <getopt.h>
 #include <string.h>
 #include <ctype.h>
@@ -28,8 +27,8 @@
 #include "conf-files.h"
 #include "strv.h"
 #include "mkdir.h"
-#include "fileio.h"
 #include "verbs.h"
+#include "build.h"
 
 #include "hwdb-internal.h"
 #include "hwdb-util.h"
@@ -420,7 +419,7 @@ static int trie_store(struct trie *trie, const char *filename) {
         }
 
         log_debug("=== trie on-disk ===");
-        log_debug("size:             %8"PRIu64" bytes", size);
+        log_debug("size:             %8"PRIi64" bytes", size);
         log_debug("header:           %8zu bytes", sizeof(struct trie_header_f));
         log_debug("nodes:            %8"PRIu64" bytes (%8"PRIu64")",
                   t.nodes_count * sizeof(struct trie_node_f), t.nodes_count);
@@ -651,25 +650,28 @@ static int hwdb_update(int argc, char *argv[], void *userdata) {
 
 static void help(void) {
         printf("Usage: %s OPTIONS COMMAND\n\n"
-               "Options:\n"
-               "  --usr                generate in " UDEVLIBEXECDIR " instead of /etc/udev\n"
-               "  -r,--root=PATH       alternative root path in the filesystem\n"
-               "  -h,--help\n\n"
+               "Update or query the hardware database.\n\n"
+               "  -h --help            Show this help\n"
+               "     --version         Show package version\n"
+               "     --usr             Generate in " UDEVLIBEXECDIR " instead of /etc/udev\n"
+               "  -r --root=PATH       Alternative root path in the filesystem\n\n"
                "Commands:\n"
-               "  update               update the hwdb database\n"
-               "  query MODALIAS       query database and print result\n\n",
+               "  update               Update the hwdb database\n"
+               "  query MODALIAS       Query database and print result\n",
                program_invocation_short_name);
 }
 
 static int parse_argv(int argc, char *argv[]) {
         enum {
-                ARG_USR = 0x100,
+                ARG_VERSION = 0x100,
+                ARG_USR,
         };
 
         static const struct option options[] = {
-                { "usr",    no_argument,       NULL, ARG_USR },
-                { "root",   required_argument, NULL, 'r' },
-                { "help",   no_argument,       NULL, 'h' },
+                { "help",     no_argument,       NULL, 'h'         },
+                { "version",  no_argument,       NULL, ARG_VERSION },
+                { "usr",      no_argument,       NULL, ARG_USR     },
+                { "root",     required_argument, NULL, 'r'         },
                 {}
         };
 
@@ -680,17 +682,27 @@ static int parse_argv(int argc, char *argv[]) {
 
         while ((c = getopt_long(argc, argv, "ut:r:h", options, NULL)) >= 0) {
                 switch(c) {
+
+                case 'h':
+                        help();
+                        return 0;
+
+                case ARG_VERSION:
+                        puts(PACKAGE_STRING);
+                        puts(SYSTEMD_FEATURES);
+                        return 0;
+
                 case ARG_USR:
                         arg_hwdb_bin_dir = UDEVLIBEXECDIR;
                         break;
+
                 case 'r':
                         arg_root = optarg;
                         break;
-                case 'h':
-                        help();
-                        return 0;
+
                 case '?':
                         return -EINVAL;
+
                 default:
                         assert_not_reached("Unknown option");
                 }
@@ -702,7 +714,7 @@ static int parse_argv(int argc, char *argv[]) {
 static int hwdb_main(int argc, char *argv[]) {
         const Verb verbs[] = {
                 { "update", 1, 1, 0, hwdb_update },
-                { "query", 2, 2, 0, hwdb_query },
+                { "query",  2, 2, 0, hwdb_query  },
                 {},
         };