FreeCalypso > hg > fc-usbser-tools
view libuwrap/find_busdev.c @ 105:1e820ed0904e
Installed-binaries: list of binaries installed by this package
I am establishing a new convention for all FreeCalypso tools, across
different packages and source repositories: each FC tools package
will have a file name Installed-binaries listing all user-invokable
binaries that package installs in /opt/freecalypso/bin. These files
are to serve as an aid to users and distro package maintainers who
prefer to not add /opt/freecalypso/bin to their PATH. The alternative
to adding this directory to PATH is to create a symlink for every
installed binary in some standard location such as /usr/bin or
/usr/local/bin, pointing to the actual binary in /opt/freecalypso/bin;
having a list of all FC-installed binaries in a standardized format
will allow this process to be automated.
author | Mychaela Falconia <falcon@freecalypso.org> |
---|---|
date | Fri, 29 Sep 2023 19:42:53 +0000 |
parents | fd3fcba5a8ac |
children |
line wrap: on
line source
/* * In this module we implement the function that locates a USB device * by bus and device number/filename strings. */ #include <stdio.h> #include <stdlib.h> #include <string.h> #include <strings.h> #include <usb.h> #include "find_dev.h" #include "prelim_init.h" struct usb_device * find_usbdev_by_busdev(const char *bus_dev_spec) { const char *slash; unsigned bus_name_len; struct usb_bus *bus; struct usb_device *dev; slash = index(bus_dev_spec, '/'); if (!slash) { fprintf(stderr, "error: bus/dev path expected, but no slash found\n"); exit(1); } bus_name_len = slash - bus_dev_spec; libusb_prelim_init(); for (bus = usb_get_busses(); bus; bus = bus->next) { if (strlen(bus->dirname) != bus_name_len) continue; if (strncmp(bus->dirname, bus_dev_spec, bus_name_len)) continue; for (dev = bus->devices; dev; dev = dev->next) { if (!strcmp(dev->filename, slash + 1)) return dev; } } return 0; }