drop dependency on usb.ids

Also remove usb.ids from the repository. [Note that these were probably
never used by distributions regarless, as most distros ship the usb.ids
directly from upstream.]

Hardcode the usb-spec information that used to be in usb.ids,
but which was not moved to hwdb.

Increase the size of tha hash table from 16 to 512, though using a
hash at all is probably overkill at this point.

Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
Tom Gundersen 2013-09-04 14:47:08 +02:00 committed by Greg Kroah-Hartman
parent c6282a7a0e
commit 5d7ea40bc9
7 changed files with 1775 additions and 18559 deletions

View File

@ -20,6 +20,7 @@ lsusb_SOURCES = \
lsusb-t.c \
list.h \
names.c names.h \
usb-spec.h \
usbmisc.c usbmisc.h
lsusb_CPPFLAGS = \
@ -30,41 +31,17 @@ lsusb_LDADD = \
$(LIBUSB_LIBS) \
$(UDEV_LIBS)
if HAVE_ZLIB
lsusb_CPPFLAGS += -DHAVE_LIBZ
lsusb_LDADD += -lz
endif
man_MANS = \
lsusb.8 \
usb-devices.1
EXTRA_DIST = \
usb.ids \
update-usbids.sh.in \
lsusb.8.in \
usb-devices.1.in \
usb-devices \
lsusb.py \
usbutils.pc.in
if INSTALL_USBIDS
data_DATA += usb.ids
if HAVE_ZLIB
data_DATA += usb.ids.gz
endif
sbin_SCRIPTS += update-usbids.sh
usb.ids.gz: $(srcdir)/usb.ids
gzip -c -9 $< > $@
update-usbids.sh: $(srcdir)/update-usbids.sh.in
sed 's|@usbids@|$(datadir)/usb.ids|g' $< >$@
chmod 755 $@
endif
lsusb.8: $(srcdir)/lsusb.8.in
sed 's|VERSION|$(VERSION)|g;s|@usbids@|$(datadir)/usb.ids|g' $< >$@
@ -78,10 +55,8 @@ usbutils.pc: $(srcdir)/usbutils.pc.in
sed 's|@usbids@|$(datadir)/usb.ids|g;s|@VERSION[@]|$(VERSION)|g' $< >$@
DISTCLEANFILES = \
usb.ids.gz \
lsusb.8 \
usb-devices.1 \
update-usbids.sh \
usbutils.pc
distclean-local:

View File

@ -12,18 +12,6 @@ AC_SYS_LARGEFILE
AC_CHECK_HEADERS([byteswap.h])
AC_CHECK_FUNCS([nl_langinfo iconv])
AC_ARG_ENABLE(zlib,
AS_HELP_STRING(--disable-zlib,disable support for zlib))
HAVE_ZLIB=no
AS_IF([test "x$enable_zlib" != "xno"],
[AC_CHECK_LIB(z, inflateEnd, HAVE_ZLIB=yes)])
AM_CONDITIONAL(HAVE_ZLIB, [test "$HAVE_ZLIB" = "yes"])
AC_ARG_ENABLE(usbids,
AS_HELP_STRING(--disable-usbids, [disable installing usb.ids @<:@default=install@:>@]))
AM_CONDITIONAL([INSTALL_USBIDS], [test "x$enable_usbids" != "xno"])
PKG_CHECK_MODULES(LIBUSB, libusb-1.0 >= 1.0.0)
PKG_CHECK_MODULES(UDEV, libudev >= 196)

13
lsusb.c
View File

@ -4027,16 +4027,9 @@ int main(int argc, char *argv[])
/* by default, print names as well as numbers */
err = names_init(DATADIR "/usb.ids");
#ifdef HAVE_LIBZ
if (err != 0)
err = names_init(DATADIR "/usb.ids.gz");
#endif
if (err != 0)
fprintf(stderr, "%s: cannot open \"%s\", %s\n",
argv[0],
DATADIR "/usb.ids",
strerror(err));
if (names_init() < 0)
fprintf(stderr, "unable to initialize usb spec");
status = 0;
if (treemode) {

600
names.c
View File

@ -37,47 +37,13 @@
#include <libudev.h>
#ifdef HAVE_LIBZ
#include <zlib.h>
#define usb_file gzFile
#define usb_fopen(path, mode) gzopen(path, mode)
#define usb_fgets(s, size, stream) gzgets(stream, s, size)
#define usb_close(f) gzclose(f)
#else
#define usb_file FILE *
#define usb_fopen(path, mode) fopen(path, mode)
#define usb_fgets(s, size, stream) fgets(s, size, stream)
#define usb_close(f) fclose(f)
#endif
#include "usb-spec.h"
#include "names.h"
/* ---------------------------------------------------------------------- */
struct audioterminal {
struct audioterminal *next;
u_int16_t termt;
char name[1];
};
struct videoterminal {
struct videoterminal *next;
u_int16_t termt;
char name[1];
};
struct genericstrtable {
struct genericstrtable *next;
unsigned int num;
char name[1];
};
/* ---------------------------------------------------------------------- */
#define HASH1 0x10
#define HASH2 0x02
#define HASHSZ 16
#define HASHSZ 512
static unsigned int hashnum(unsigned int num)
{
@ -93,16 +59,16 @@ static unsigned int hashnum(unsigned int num)
static struct udev *udev = NULL;
static struct udev_hwdb *hwdb = NULL;
static struct audioterminal *audioterminals[HASHSZ] = { NULL, };
static struct videoterminal *videoterminals[HASHSZ] = { NULL, };
static struct genericstrtable *hiddescriptors[HASHSZ] = { NULL, };
static struct genericstrtable *reports[HASHSZ] = { NULL, };
static struct genericstrtable *huts[HASHSZ] = { NULL, };
static struct genericstrtable *biass[HASHSZ] = { NULL, };
static struct genericstrtable *physdess[HASHSZ] = { NULL, };
static struct genericstrtable *hutus[HASHSZ] = { NULL, };
static struct genericstrtable *langids[HASHSZ] = { NULL, };
static struct genericstrtable *countrycodes[HASHSZ] = { NULL, };
static struct audioterminal *audioterminals_hash[HASHSZ] = { NULL, };
static struct videoterminal *videoterminals_hash[HASHSZ] = { NULL, };
static struct genericstrtable *hiddescriptors_hash[HASHSZ] = { NULL, };
static struct genericstrtable *reports_hash[HASHSZ] = { NULL, };
static struct genericstrtable *huts_hash[HASHSZ] = { NULL, };
static struct genericstrtable *biass_hash[HASHSZ] = { NULL, };
static struct genericstrtable *physdess_hash[HASHSZ] = { NULL, };
static struct genericstrtable *hutus_hash[HASHSZ] = { NULL, };
static struct genericstrtable *langids_hash[HASHSZ] = { NULL, };
static struct genericstrtable *countrycodes_hash[HASHSZ] = { NULL, };
/* ---------------------------------------------------------------------- */
@ -119,42 +85,42 @@ static const char *names_genericstrtable(struct genericstrtable *t[HASHSZ],
const char *names_hid(u_int8_t hidd)
{
return names_genericstrtable(hiddescriptors, hidd);
return names_genericstrtable(hiddescriptors_hash, hidd);
}
const char *names_reporttag(u_int8_t rt)
{
return names_genericstrtable(reports, rt);
return names_genericstrtable(reports_hash, rt);
}
const char *names_huts(unsigned int data)
{
return names_genericstrtable(huts, data);
return names_genericstrtable(huts_hash, data);
}
const char *names_hutus(unsigned int data)
{
return names_genericstrtable(hutus, data);
return names_genericstrtable(hutus_hash, data);
}
const char *names_langid(u_int16_t langid)
{
return names_genericstrtable(langids, langid);
return names_genericstrtable(langids_hash, langid);
}
const char *names_physdes(u_int8_t ph)
{
return names_genericstrtable(physdess, ph);
return names_genericstrtable(physdess_hash, ph);
}
const char *names_bias(u_int8_t b)
{
return names_genericstrtable(biass, b);
return names_genericstrtable(biass_hash, b);
}
const char *names_countrycode(unsigned int countrycode)
{
return names_genericstrtable(countrycodes, countrycode);
return names_genericstrtable(countrycodes_hash, countrycode);
}
static const char *hwdb_get(const char *modalias, const char *key)
@ -212,7 +178,7 @@ const char *names_audioterminal(u_int16_t termt)
{
struct audioterminal *at;
at = audioterminals[hashnum(termt)];
at = audioterminals_hash[hashnum(termt)];
for (; at; at = at->next)
if (at->termt == termt)
return at->name;
@ -223,7 +189,7 @@ const char *names_videoterminal(u_int16_t termt)
{
struct videoterminal *vt;
vt = videoterminals[hashnum(termt)];
vt = videoterminals_hash[hashnum(termt)];
for (; vt; vt = vt->next)
if (vt->termt == termt)
return vt->name;
@ -282,446 +248,189 @@ int get_subclass_string(char *buf, size_t size, u_int8_t cls, u_int8_t subcls)
/* ---------------------------------------------------------------------- */
static int new_audioterminal(const char *name, u_int16_t termt)
static int hash_audioterminal(struct audioterminal *at)
{
struct audioterminal *at;
unsigned int h = hashnum(termt);
struct audioterminal *at_old;
unsigned int h = hashnum(at->termt);
at = audioterminals[h];
for (; at; at = at->next)
if (at->termt == termt)
for (at_old = audioterminals_hash[h]; at_old; at_old = at_old->next)
if (at_old->termt == at->termt)
return -1;
at = malloc(sizeof(struct audioterminal) + strlen(name));
if (!at)
return -1;
strcpy(at->name, name);
at->termt = termt;
at->next = audioterminals[h];
audioterminals[h] = at;
at->next = audioterminals_hash[h];
audioterminals_hash[h] = at;
return 0;
}
static int new_videoterminal(const char *name, u_int16_t termt)
static int hash_audioterminals(void)
{
struct videoterminal *vt;
unsigned int h = hashnum(termt);
int r = 0, i, k;
vt = videoterminals[h];
for (; vt; vt = vt->next)
if (vt->termt == termt)
for (i = 0; audioterminals[i].name; i++)
{
k = hash_audioterminal(&audioterminals[i]);
if (k < 0)
r = k;
}
return r;
}
static int hash_videoterminal(struct videoterminal *vt)
{
struct videoterminal *vt_old;
unsigned int h = hashnum(vt->termt);
for (vt_old = videoterminals_hash[h]; vt_old; vt_old = vt_old->next)
if (vt_old->termt == vt->termt)
return -1;
vt = malloc(sizeof(struct videoterminal) + strlen(name));
if (!vt)
return -1;
strcpy(vt->name, name);
vt->termt = termt;
vt->next = videoterminals[h];
videoterminals[h] = vt;
vt->next = videoterminals_hash[h];
videoterminals_hash[h] = vt;
return 0;
}
static int new_genericstrtable(struct genericstrtable *t[HASHSZ],
const char *name, unsigned int idx)
static int hash_videoterminals(void)
{
struct genericstrtable *g;
unsigned int h = hashnum(idx);
int r = 0, i, k;
for (g = t[h]; g; g = g->next)
if (g->num == idx)
for (i = 0; videoterminals[i].name; i++)
{
k = hash_videoterminal(&videoterminals[i]);
if (k < 0)
r = k;
}
return r;
}
static int hash_genericstrtable(struct genericstrtable *t[HASHSZ],
struct genericstrtable *g)
{
struct genericstrtable *g_old;
unsigned int h = hashnum(g->num);
for (g_old = t[h]; g_old; g_old = g_old->next)
if (g_old->num == g->num)
return -1;
g = malloc(sizeof(struct genericstrtable) + strlen(name));
if (!g)
return -1;
strcpy(g->name, name);
g->num = idx;
g->next = t[h];
t[h] = g;
return 0;
}
static int new_hid(const char *name, u_int8_t hidd)
{
return new_genericstrtable(hiddescriptors, name, hidd);
}
#define HASH_EACH(array, hash) \
for (i = 0; array[i].name; i++) { \
k = hash_genericstrtable(hash, &array[i]); \
if (k < 0) { \
r = k; \
}\
}
static int new_reporttag(const char *name, u_int8_t rt)
static int hash_tables(void)
{
return new_genericstrtable(reports, name, rt);
}
int r = 0, k, i;
static int new_huts(const char *name, unsigned int data)
{
return new_genericstrtable(huts, name, data);
}
k = hash_audioterminals();
if (k < 0)
r = k;
static int new_hutus(const char *name, unsigned int data)
{
return new_genericstrtable(hutus, name, data);
}
k = hash_videoterminals();
if (k < 0)
r = k;
static int new_langid(const char *name, u_int16_t langid)
{
return new_genericstrtable(langids, name, langid);
}
HASH_EACH(hiddescriptors, hiddescriptors_hash);
static int new_physdes(const char *name, u_int8_t ph)
{
return new_genericstrtable(physdess, name, ph);
}
static int new_bias(const char *name, u_int8_t b)
{
return new_genericstrtable(biass, name, b);
}
HASH_EACH(reports, reports_hash);
static int new_countrycode(const char *name, unsigned int countrycode)
{
return new_genericstrtable(countrycodes, name, countrycode);
HASH_EACH(huts, huts_hash);
HASH_EACH(hutus, hutus_hash);
HASH_EACH(langids, langids_hash);
HASH_EACH(physdess, physdess_hash);
HASH_EACH(biass, biass_hash);
HASH_EACH(countrycodes, countrycodes_hash);
return r;
}
/* ---------------------------------------------------------------------- */
static void free_audioterminal(void)
/*
static void print_tables(void)
{
struct audioterminal *cur, *tmp;
int i;
struct audioterminal *at;
struct videoterminal *vt;
struct genericstrtable *li;
struct genericstrtable *hu;
printf("--------------------------------------------\n");
printf("\t\t Audio Terminals\n");
printf("--------------------------------------------\n");
for (i = 0; i < HASHSZ; i++) {
cur = audioterminals[i];
audioterminals[i] = NULL;
while (cur) {
tmp = cur;
cur = cur->next;
free(tmp);
}
printf("hash: %d\n", i);
at = audioterminals_hash[i];
for (; at; at = at->next)
printf("\tentry: %s\n", at->name);
}
return;
}
static void free_videoterminal(void)
{
struct videoterminal *cur, *tmp;
int i;
printf("--------------------------------------------\n");
printf("\t\t Video Terminals\n");
printf("--------------------------------------------\n");
for (i = 0; i < HASHSZ; i++) {
cur = videoterminals[i];
videoterminals[i] = NULL;
while (cur) {
tmp = cur;
cur = cur->next;
free(tmp);
}
printf("hash: %d\n", i);
vt = videoterminals_hash[i];
for (; vt; vt = vt->next)
printf("\tentry: %s\n", vt->name);
}
}
static void _free_genericstrtable(struct genericstrtable *t[HASHSZ])
{
struct genericstrtable *cur, *tmp;
int i;
printf("--------------------------------------------\n");
printf("\t\t Languages\n");
printf("--------------------------------------------\n");
for (i = 0; i < HASHSZ; i++) {
cur = t[i];
t[i] = NULL;
while (cur) {
tmp = cur;
cur = cur->next;
free(tmp);
}
li = langids_hash[i];
if (li)
printf("hash: %d\n", i);
for (; li; li = li->next)
printf("\tid: %x, entry: %s\n", li->num, li->name);
}
}
static void free_genericstrtable(void)
{
_free_genericstrtable(hiddescriptors);
_free_genericstrtable(reports);
_free_genericstrtable(huts);
_free_genericstrtable(biass);
_free_genericstrtable(physdess);
_free_genericstrtable(hutus);
_free_genericstrtable(langids);
_free_genericstrtable(countrycodes);
}
printf("--------------------------------------------\n");
printf("\t\t Conutry Codes\n");
printf("--------------------------------------------\n");
#define DBG(x)
static void parse(usb_file f)
{
char buf[512], *cp;
unsigned int linectr = 0;
int lastvendor = -1;
int lastclass = -1;
int lastsubclass = -1;
int lasthut = -1;
int lastlang = -1;
unsigned int u;
while (usb_fgets(buf, sizeof(buf), f)) {
linectr++;
/* remove line ends */
cp = strchr(buf, 13);
if (cp)
*cp = 0;
cp = strchr(buf, 10);
if (cp)
*cp = 0;
if (buf[0] == '#' || !buf[0])
continue;
cp = buf;
if (buf[0] == 'P' && buf[1] == 'H' && buf[2] == 'Y' && buf[3] == 'S' && buf[4] == 'D' &&
buf[5] == 'E' && buf[6] == 'S' && /*isspace(buf[7])*/ buf[7] == ' ') {
cp = buf + 8;
while (isspace(*cp))
cp++;
if (!isxdigit(*cp)) {
fprintf(stderr, "Invalid Physdes type at line %u\n", linectr);
continue;
}
u = strtoul(cp, &cp, 16);
while (isspace(*cp))
cp++;
if (!*cp) {
fprintf(stderr, "Invalid Physdes type at line %u\n", linectr);
continue;
}
if (new_physdes(cp, u))
fprintf(stderr, "Duplicate Physdes type spec at line %u terminal type %04x %s\n", linectr, u, cp);
DBG(printf("line %5u physdes type %02x %s\n", linectr, u, cp));
continue;
}
if (buf[0] == 'P' && buf[1] == 'H' && buf[2] == 'Y' && /*isspace(buf[3])*/ buf[3] == ' ') {
cp = buf + 4;
while (isspace(*cp))
cp++;
if (!isxdigit(*cp)) {
fprintf(stderr, "Invalid PHY type at line %u\n", linectr);
continue;
}
u = strtoul(cp, &cp, 16);
while (isspace(*cp))
cp++;
if (!*cp) {
fprintf(stderr, "Invalid PHY type at line %u\n", linectr);
continue;
}
if (new_physdes(cp, u))
fprintf(stderr, "Duplicate PHY type spec at line %u terminal type %04x %s\n", linectr, u, cp);
DBG(printf("line %5u PHY type %02x %s\n", linectr, u, cp));
continue;
}
if (buf[0] == 'B' && buf[1] == 'I' && buf[2] == 'A' && buf[3] == 'S' && /*isspace(buf[4])*/ buf[4] == ' ') {
cp = buf + 5;
while (isspace(*cp))
cp++;
if (!isxdigit(*cp)) {
fprintf(stderr, "Invalid BIAS type at line %u\n", linectr);
continue;
}
u = strtoul(cp, &cp, 16);
while (isspace(*cp))
cp++;
if (!*cp) {
fprintf(stderr, "Invalid BIAS type at line %u\n", linectr);
continue;
}
if (new_bias(cp, u))
fprintf(stderr, "Duplicate BIAS type spec at line %u terminal type %04x %s\n", linectr, u, cp);
DBG(printf("line %5u BIAS type %02x %s\n", linectr, u, cp));
continue;
}
if (buf[0] == 'L' && /*isspace(buf[1])*/ buf[1] == ' ') {
cp = buf+2;
while (isspace(*cp))
cp++;
if (!isxdigit(*cp)) {
fprintf(stderr, "Invalid LANGID spec at line %u\n", linectr);
continue;
}
u = strtoul(cp, &cp, 16);
while (isspace(*cp))
cp++;
if (!*cp) {
fprintf(stderr, "Invalid LANGID spec at line %u\n", linectr);
continue;
}
if (new_langid(cp, u))
fprintf(stderr, "Duplicate LANGID spec at line %u language-id %04x %s\n", linectr, u, cp);
DBG(printf("line %5u LANGID %02x %s\n", linectr, u, cp));
lasthut = lastclass = lastvendor = lastsubclass = -1;
lastlang = u;
continue;
}
if (buf[0] == 'A' && buf[1] == 'T' && isspace(buf[2])) {
/* audio terminal type spec */
cp = buf+3;
while (isspace(*cp))
cp++;
if (!isxdigit(*cp)) {
fprintf(stderr, "Invalid audio terminal type at line %u\n", linectr);
continue;
}
u = strtoul(cp, &cp, 16);
while (isspace(*cp))
cp++;
if (!*cp) {
fprintf(stderr, "Invalid audio terminal type at line %u\n", linectr);
continue;
}
if (new_audioterminal(cp, u))
fprintf(stderr, "Duplicate audio terminal type spec at line %u terminal type %04x %s\n", linectr, u, cp);
DBG(printf("line %5u audio terminal type %02x %s\n", linectr, u, cp));
continue;
}
if (buf[0] == 'V' && buf[1] == 'T' && isspace(buf[2])) {
/* video terminal type spec */
cp = buf+3;
while (isspace(*cp))
cp++;
if (!isxdigit(*cp)) {
fprintf(stderr, "Invalid video terminal type at line %u\n", linectr);
continue;
}
u = strtoul(cp, &cp, 16);
while (isspace(*cp))
cp++;
if (!*cp) {
fprintf(stderr, "Invalid video terminal type at line %u\n", linectr);
continue;
}
if (new_videoterminal(cp, u))
fprintf(stderr, "Duplicate video terminal type spec at line %u terminal type %04x %s\n", linectr, u, cp);
DBG(printf("line %5u video terminal type %02x %s\n", linectr, u, cp));
continue;
}
if (buf[0] == 'H' && buf[1] == 'C' && buf[2] == 'C' && isspace(buf[3])) {
/* HID Descriptor bCountryCode */
cp = buf+3;
while (isspace(*cp))
cp++;
if (!isxdigit(*cp)) {
fprintf(stderr, "Invalid HID country code at line %u\n", linectr);
continue;
}
u = strtoul(cp, &cp, 10);
while (isspace(*cp))
cp++;
if (!*cp) {
fprintf(stderr, "Invalid HID country code at line %u\n", linectr);
continue;
}
if (new_countrycode(cp, u))
fprintf(stderr, "Duplicate HID country code at line %u country %02u %s\n", linectr, u, cp);
DBG(printf("line %5u keyboard country code %02u %s\n", linectr, u, cp));
continue;
}
if (buf[0] == '\t' && isxdigit(buf[1])) {
/* product or subclass spec */
u = strtoul(buf+1, &cp, 16);
while (isspace(*cp))
cp++;
if (!*cp) {
fprintf(stderr, "Invalid product/subclass spec at line %u\n", linectr);
continue;
}
if (lasthut != -1) {
if (new_hutus(cp, (lasthut << 16)+u))
fprintf(stderr, "Duplicate HUT Usage Spec at line %u\n", linectr);
continue;
}
if (lastlang != -1) {
if (new_langid(cp, lastlang+(u<<10)))
fprintf(stderr, "Duplicate LANGID Usage Spec at line %u\n", linectr);
continue;
}
fprintf(stderr, "Product/Subclass spec without prior Vendor/Class spec at line %u\n", linectr);
continue;
}
if (buf[0] == 'H' && buf[1] == 'I' && buf[2] == 'D' && /*isspace(buf[3])*/ buf[3] == ' ') {
cp = buf + 4;
while (isspace(*cp))
cp++;
if (!isxdigit(*cp)) {
fprintf(stderr, "Invalid HID type at line %u\n", linectr);
continue;
}
u = strtoul(cp, &cp, 16);
while (isspace(*cp))
cp++;
if (!*cp) {
fprintf(stderr, "Invalid HID type at line %u\n", linectr);
continue;
}
if (new_hid(cp, u))
fprintf(stderr, "Duplicate HID type spec at line %u terminal type %04x %s\n", linectr, u, cp);
DBG(printf("line %5u HID type %02x %s\n", linectr, u, cp));
continue;
}
if (buf[0] == 'H' && buf[1] == 'U' && buf[2] == 'T' && /*isspace(buf[3])*/ buf[3] == ' ') {
cp = buf + 4;
while (isspace(*cp))
cp++;
if (!isxdigit(*cp)) {
fprintf(stderr, "Invalid HUT type at line %u\n", linectr);
continue;
}
u = strtoul(cp, &cp, 16);
while (isspace(*cp))
cp++;
if (!*cp) {
fprintf(stderr, "Invalid HUT type at line %u\n", linectr);
continue;
}
if (new_huts(cp, u))
fprintf(stderr, "Duplicate HUT type spec at line %u terminal type %04x %s\n", linectr, u, cp);
lastlang = lastclass = lastvendor = lastsubclass = -1;
lasthut = u;
DBG(printf("line %5u HUT type %02x %s\n", linectr, u, cp));
continue;
}
if (buf[0] == 'R' && buf[1] == ' ') {
cp = buf + 2;
while (isspace(*cp))
cp++;
if (!isxdigit(*cp)) {
fprintf(stderr, "Invalid Report type at line %u\n", linectr);
continue;
}
u = strtoul(cp, &cp, 16);
while (isspace(*cp))
cp++;
if (!*cp) {
fprintf(stderr, "Invalid Report type at line %u\n", linectr);
continue;
}
if (new_reporttag(cp, u))
fprintf(stderr, "Duplicate Report type spec at line %u terminal type %04x %s\n", linectr, u, cp);
DBG(printf("line %5u Report type %02x %s\n", linectr, u, cp));
continue;
}
fprintf(stderr, "Unknown line at line %u\n", linectr);
for (i = 0; i < HASHSZ; i++) {
hu = countrycodes_hash[i];
if (hu)
printf("hash: %d\n", i);
for (; hu; hu = hu->next)
printf("\tid: %x, entry: %s\n", hu->num, hu->name);
}
printf("--------------------------------------------\n");
}
*/
/* ---------------------------------------------------------------------- */
int names_init(char *n)
int names_init(void)
{
usb_file f;
int r = 0;
f = usb_fopen(n, "r");
if (!f)
r = errno;
parse(f);
usb_close(f);
int r;
udev = udev_new();
hwdb = udev_hwdb_new(udev);
if (!udev)
r = -1;
else {
hwdb = udev_hwdb_new(udev);
if (!hwdb)
r = -1;
}
r = hash_tables();
return r;
}
@ -730,7 +439,4 @@ void names_exit(void)
{
hwdb = udev_hwdb_unref(hwdb);
udev = udev_unref(udev);
free_audioterminal();
free_videoterminal();
free_genericstrtable();
}

View File

@ -49,7 +49,7 @@ extern int get_product_string(char *buf, size_t size, u_int16_t vid, u_int16_t p
extern int get_class_string(char *buf, size_t size, u_int8_t cls);
extern int get_subclass_string(char *buf, size_t size, u_int8_t cls, u_int8_t subcls);
extern int names_init(char *n);
extern int names_init(void);
extern void names_exit(void);
/* ---------------------------------------------------------------------- */

1617
usb-spec.h Normal file

File diff suppressed because it is too large Load Diff

18063
usb.ids

File diff suppressed because it is too large Load Diff