*
* Copyright (c) 2005 SUSE Linux Products GmbH, Germany
*
- * Author:
- * Hannes Reinecke <hare@suse.de>
+ * Author: Hannes Reinecke <hare@suse.de>
*
- * 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 <http://www.gnu.org/licenses/>.
*/
#include <stdio.h>
};
struct udev *udev;
struct udev_device *dev = NULL;
- char syspath[UTIL_PATH_SIZE];
- const char *devpath;
static int export;
int retval = 0;
export = 1;
break;
case 'h':
- printf("Usage: usb_id [--usb-info] [--num-info] [--export] [--help] <devpath>\n"
+ printf("Usage: usb_id [--usb-info] [--num-info] [--export] [--help] [<devpath>]\n"
" --usb-info use usb strings instead\n"
" --num-info use numerical values\n"
" --export print values as environment keys\n"
}
}
- 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);