~ubuntu-branches/ubuntu/trusty/argyll/trusty-proposed

« back to all changes in this revision

Viewing changes to libusb1/examples/lsusb.c

  • Committer: Package Import Robot
  • Author(s): Artur Rona
  • Date: 2014-02-12 00:35:39 UTC
  • mfrom: (13.1.24 sid)
  • Revision ID: package-import@ubuntu.com-20140212003539-24tautzlitsiz61w
Tags: 1.5.1-5ubuntu1
* Merge from Debian unstable. (LP: #1275572) Remaining changes:
  - debian/control:
    + Build-depend on libtiff-dev rather than libtiff4-dev.
  - debian/control, debian/patches/06_fix_udev_rule.patch:
    + Fix udev rules to actually work; ENV{ACL_MANAGE} has
      stopped working ages ago, and with logind it's now the
      "uaccess" tag. Dropping also consolekit from Recommends.
  - debian/patches/drop-usb-db.patch:
    + Use hwdb builtin, instead of the obsolete usb-db
      in the udev rules.
* debian/patches/05_ftbfs-underlinkage.diff:
  - Dropped change, no needed anymore.
* Refresh the patches.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/*
2
 
 * libusb example program to list devices on the bus
3
 
 * Copyright (C) 2007 Daniel Drake <dsd@gentoo.org>
4
 
 *
5
 
 * This library is free software; you can redistribute it and/or
6
 
 * modify it under the terms of the GNU Lesser General Public
7
 
 * License as published by the Free Software Foundation; either
8
 
 * version 2.1 of the License, or (at your option) any later version.
9
 
 *
10
 
 * This library is distributed in the hope that it will be useful,
11
 
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12
 
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13
 
 * Lesser General Public License for more details.
14
 
 *
15
 
 * You should have received a copy of the GNU Lesser General Public
16
 
 * License along with this library; if not, write to the Free Software
17
 
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
18
 
 */
19
 
 
20
 
#include <stdio.h>
21
 
 
22
 
#include <libusb/libusb.h>
23
 
 
24
 
static void print_devs(libusb_device **devs)
25
 
{
26
 
        libusb_device *dev;
27
 
        int i = 0;
28
 
 
29
 
        while ((dev = devs[i++]) != NULL) {
30
 
                struct libusb_device_descriptor desc;
31
 
                int r = libusb_get_device_descriptor(dev, &desc);
32
 
                if (r < 0) {
33
 
                        fprintf(stderr, "failed to get device descriptor");
34
 
                        return;
35
 
                }
36
 
 
37
 
                printf("%04x:%04x (bus %d, device %d)\n",
38
 
                        desc.idVendor, desc.idProduct,
39
 
                        libusb_get_bus_number(dev), libusb_get_device_address(dev));
40
 
        }
41
 
}
42
 
 
43
 
int
44
 
#ifdef _MSC_VER
45
 
__cdecl
46
 
#endif
47
 
main(void)
48
 
{
49
 
        libusb_device **devs;
50
 
        int r;
51
 
        ssize_t cnt;
52
 
 
53
 
        r = libusb_init(NULL);
54
 
        if (r < 0)
55
 
                return r;
56
 
 
57
 
        cnt = libusb_get_device_list(NULL, &devs);
58
 
        if (cnt < 0)
59
 
                return (int) cnt;
60
 
 
61
 
        print_devs(devs);
62
 
        libusb_free_device_list(devs, 1);
63
 
 
64
 
        libusb_exit(NULL);
65
 
        return 0;
66
 
}
67