X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=blobdiff_plain;f=extras%2Fusb_id%2Fusb_id.c;h=3a7a0ffd496cb61130e85ff504fc9535d2ab8134;hb=e48e2912023b5600d291904b0f7b0017387e8cb2;hp=4679f94fde9b62ad8ee5671f04b69922dc2789c7;hpb=065db052211d3bf08d9b0f698a79a8798faf11d2;p=elogind.git diff --git a/extras/usb_id/usb_id.c b/extras/usb_id/usb_id.c index 4679f94fd..3a7a0ffd4 100644 --- a/extras/usb_id/usb_id.c +++ b/extras/usb_id/usb_id.c @@ -3,12 +3,20 @@ * * Copyright (c) 2005 SUSE Linux Products GmbH, Germany * - * Author: - * Hannes Reinecke + * Author: Hannes Reinecke * - * This program is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License as published by the - * Free Software Foundation version 2 of the License. + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . */ #include @@ -21,7 +29,8 @@ #include #include -#include "../../udev/udev.h" +#include "libudev.h" +#include "libudev-private.h" int debug; @@ -455,8 +464,6 @@ int main(int argc, char **argv) }; struct udev *udev; struct udev_device *dev = NULL; - char syspath[UTIL_PATH_SIZE]; - const char *devpath; static int export; int retval = 0; @@ -464,7 +471,7 @@ int main(int argc, char **argv) if (udev == NULL) goto exit; - logging_init("usb_id"); + udev_log_init("usb_id"); udev_set_log_fn(udev, log_fn); while (1) { @@ -491,29 +498,35 @@ int main(int argc, char **argv) export = 1; break; case 'h': - printf("Usage: usb_id [--usb-info] [--num-info] [--export] [--help] \n" + printf("Usage: usb_id [--usb-info] [--num-info] [--export] [--help] []\n" " --usb-info use usb strings instead\n" " --num-info use numerical values\n" " --export print values as environment keys\n" " --help print this help text\n\n"); - default: - retval = 1; goto exit; } } - devpath = argv[optind]; - if (devpath == NULL) { - fprintf(stderr, "No device specified\n"); - retval = 1; - goto exit; - } - - util_strscpyl(syspath, sizeof(syspath), udev_get_sys_path(udev), devpath, NULL); - dev = udev_device_new_from_syspath(udev, syspath); + dev = udev_device_new_from_environment(udev); if (dev == NULL) { - err(udev, "unable to access '%s'\n", devpath); - return 1; + char syspath[UTIL_PATH_SIZE]; + const char *devpath; + + devpath = argv[optind]; + if (devpath == NULL) { + fprintf(stderr, "missing device\n"); + retval = 1; + goto exit; + } + + util_strscpyl(syspath, sizeof(syspath), udev_get_sys_path(udev), devpath, NULL); + dev = udev_device_new_from_syspath(udev, syspath); + if (dev == NULL) { + err(udev, "unable to access '%s'\n", devpath); + retval = 1; + goto exit; + return 1; + } } retval = usb_id(dev); @@ -558,6 +571,6 @@ int main(int argc, char **argv) exit: udev_device_unref(dev); udev_unref(udev); - logging_close(); + udev_log_close(); return retval; }