summaryrefslogtreecommitdiff
path: root/src/v4l_id/v4l_id.c
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2015-01-07 16:53:15 -0500
committerAnthony G. Basile <blueness@gentoo.org>2015-01-07 16:53:15 -0500
commit81ce2af261245727ee92ba1e0070571028602e12 (patch)
treee3819dcbf70bca63eedd25e69d5d2175bc9fd16b /src/v4l_id/v4l_id.c
parent2ce4bb9f127e3e57494b29310e08dbb226de70cd (diff)
udevadm,..: make --help output of udev tools more like the output of the various other tools
Signed-off-by: Anthony G. Basile <blueness@gentoo.org>
Diffstat (limited to 'src/v4l_id/v4l_id.c')
-rw-r--r--src/v4l_id/v4l_id.c19
1 files changed, 11 insertions, 8 deletions
diff --git a/src/v4l_id/v4l_id.c b/src/v4l_id/v4l_id.c
index 08d3efa857..0ebe434639 100644
--- a/src/v4l_id/v4l_id.c
+++ b/src/v4l_id/v4l_id.c
@@ -26,17 +26,18 @@
#include <sys/ioctl.h>
#include <linux/videodev2.h>
-int main (int argc, char *argv[])
-{
+#include "util.h"
+
+int main(int argc, char *argv[]) {
static const struct option options[] = {
{ "help", no_argument, NULL, 'h' },
{}
};
- int fd;
+ _cleanup_close_ int fd = -1;
char *device;
struct v4l2_capability v2cap;
- while (1) {
+ for (;;) {
int option;
option = getopt_long(argc, argv, "h", options, NULL);
@@ -45,7 +46,10 @@ int main (int argc, char *argv[])
switch (option) {
case 'h':
- printf("Usage: v4l_id [-h,--help] <device file>\n\n");
+ printf("%s [-h,--help] <device file>\n\n"
+ "Video4Linux device identification.\n\n"
+ " -h Print this message\n"
+ , program_invocation_short_name);
return 0;
default:
return 1;
@@ -55,11 +59,11 @@ int main (int argc, char *argv[])
if (device == NULL)
return 2;
- fd = open (device, O_RDONLY);
+ fd = open(device, O_RDONLY);
if (fd < 0)
return 3;
- if (ioctl (fd, VIDIOC_QUERYCAP, &v2cap) == 0) {
+ if (ioctl(fd, VIDIOC_QUERYCAP, &v2cap) == 0) {
printf("ID_V4L_VERSION=2\n");
printf("ID_V4L_PRODUCT=%s\n", v2cap.card);
printf("ID_V4L_CAPABILITIES=:");
@@ -78,6 +82,5 @@ int main (int argc, char *argv[])
printf("\n");
}
- close (fd);
return 0;
}