- int attributes = 0;
- enum query_type query = NONE;
- char result[1024] = "";
- char path[NAME_SIZE] = "";
- char name[NAME_SIZE] = "";
- char temp[NAME_SIZE];
- char *pos;
-
- /* get command line options */
+
+ static const struct option options[] = {
+ { "name", 1, NULL, 'n' },
+ { "path", 1, NULL, 'p' },
+ { "query", 1, NULL, 'q' },
+ { "attribute-walk", 0, NULL, 'a' },
+ { "export-db", 0, NULL, 'e' },
+ { "root", 0, NULL, 'r' },
+ { "version", 0, NULL, 1 }, /* -V outputs braindead format */
+ { "help", 0, NULL, 'h' },
+ {}
+ };
+
+ enum action_type {
+ ACTION_NONE,
+ ACTION_QUERY,
+ ACTION_ATTRIBUTE_WALK,
+ ACTION_ROOT,
+ } action = ACTION_NONE;
+
+ enum query_type {
+ QUERY_NONE,
+ QUERY_NAME,
+ QUERY_PATH,
+ QUERY_SYMLINK,
+ QUERY_ENV,
+ QUERY_ALL,
+ } query = QUERY_NONE;
+
+ char path[PATH_SIZE] = "";
+ char name[PATH_SIZE] = "";
+ struct name_entry *name_loop;
+ int rc = 0;
+
+ logging_init("udevinfo");
+ udev_config_init();
+ sysfs_init();
+
+ udev = udev_device_init(NULL);
+ if (udev == NULL) {
+ rc = 1;
+ goto exit;
+ }
+