Hi!
On Tue, Aug 08, 2006 at 06:36:30PM +0200, Aurelien Jarno wrote:
> On Tue, Aug 08, 2006 at 02:22:24PM +0200, Thomas Sailer wrote:
> > On Sun, 2006-08-06 at 14:10 -0700, Randy.Dunlap wrote:
> >
> > > It was just posted to the linux-pci m-l on Aug-04 and has not
> > > been acted on.
> >
> > I'm a bit worried that just storing a gzipped file as usb.ids will
> > confuse users. Storing it as usb.ids.gz would make it more clear that it
> > is a compressed file, but would require usbutils to probe for both
> > usb.ids and usb.ids.gz. What is the stance pciutils takes on that issue?
> >
>
> I have just check the patch for pciutils, it uses pci.ids.gz, but only
> probes for pci.ids.gz (and not pci.ids) when gzip support is activated.
>
> I will redo my patch to support both usb.ids and usb.ids.gz when gzip
> support is activated. Please expect a few days for that, it will depends
> if I am able to easily get an Internet connection in the next few days.
>
Please find attached a new version of the patch. It now checks for
./usb.ids.gz, ./usb.ids, @datadir@/usb.ids.gz and @datadir@/usb.ids (in that
order) when gzip support is activated, and for ./usb.ids and
datadir/usb.ids when gzip support is not activated.
I have changed USBIDS_FILE into USBIDS_DIR, so that the name of the file
can be passed in the .c file.
BTW, I am wondering about checking for ./usb.ids{,.gz}. I understand it
is very useful for debugging purpose while developing, but I am not
really sure it is useful in the final version that are in the
distributions. It just opens the usb.ids file of the current directory,
which can be for example an old version downloaded to /tmp. If a user
don't know about this feature (and even if it is written in the doc,
he/she won't read it), he/she could have unexpected result. Well that's
just my opinion.
Bye,
Aurelien
--
.''`. Aurelien Jarno | GPG: 1024D/F1BCDB73
: :' : Debian developer | Electrical Engineer
`. `' [EMAIL PROTECTED] | [EMAIL PROTECTED]
`- people.debian.org/~aurel32 | www.aurel32.net
diff -Nurd usbutils-0.72.orig/configure.in usbutils-0.72/configure.in
--- usbutils-0.72.orig/configure.in 2006-02-19 01:14:41.000000000 +0100
+++ usbutils-0.72/configure.in 2006-08-08 22:28:24.000000000 +0200
@@ -34,6 +34,25 @@
AC_CHECK_LIB(usb, usb_get_string_simple, ,
[AC_MSG_ERROR(get libusb 0.1.8 or newer)])
+
+dnl zlib on enabled by default (if found)
+USE_ZLIB=yes
+AC_ARG_ENABLE(zlib,
+ AC_HELP_STRING([--disable-zlib],
+ [disable support for zlib]),
+ [
+ if eval "test x$enable_zlib = xno"; then
+ USE_ZLIB=
+ fi
+ ])
+if test "$USE_ZLIB" = "yes" ; then
+ AC_CHECK_LIB(z, inflateEnd)
+ if test "${ac_cv_lib_z_inflateEnd}" = "yes" ; then
+ HAVE_ZLIB="yes"
+ fi
+fi
+AM_CONDITIONAL(HAVE_ZLIB, test x$HAVE_ZLIB = xyes)
+
#AC_ARG_ENABLE(usbmodules,
# [ --enable-usbmodules build usbmodules (for Linux 2.4)],
# [ case "${enableval}" in
diff -Nurd usbutils-0.72.orig/lsusb.c usbutils-0.72/lsusb.c
--- usbutils-0.72.orig/lsusb.c 2006-02-14 05:25:33.000000000 +0100
+++ usbutils-0.72/lsusb.c 2006-08-12 22:35:37.000000000 +0200
@@ -2823,14 +2823,29 @@
}
/* by default, print names as well as numbers */
+#ifdef HAVE_LIBZ
+ if ((err = names_init("./usb.ids.gz")) != 0) {
+ if ((err = names_init("./usb.ids")) != 0) {
+ if ((err = names_init(USBIDS_DIR"/usb.ids.gz")) != 0) {
+ if ((err = names_init(USBIDS_DIR"/usb.ids.gz"))
!= 0) {
+ fprintf(stderr, "%s: cannot open
\"%s\", %s\n",
+ argv[0],
+ USBIDS_DIR"/usb.ids.gz",
+ strerror(err));
+ }
+ }
+ }
+ }
+#else
if ((err = names_init("./usb.ids")) != 0) {
- if ((err = names_init(USBIDS_FILE)) != 0) {
+ if ((err = names_init(USBIDS_DIR"/usb.ids")) != 0) {
fprintf(stderr, "%s: cannot open \"%s\", %s\n",
argv[0],
- USBIDS_FILE,
+ USBIDS_DIR"/usb.ids",
strerror(err));
}
}
+#endif
status = 0;
usb_init();
diff -Nurd usbutils-0.72.orig/Makefile.am usbutils-0.72/Makefile.am
--- usbutils-0.72.orig/Makefile.am 2006-02-19 00:48:13.000000000 +0100
+++ usbutils-0.72/Makefile.am 2006-08-12 22:37:45.000000000 +0200
@@ -1,6 +1,6 @@
# Process this file with 'automake' to create 'Makefile.in'
-AM_CPPFLAGS = -DUSBIDS_FILE='"@datadir@/usb.ids"'
+AM_CPPFLAGS = -DUSBIDS_DIR='"@datadir@"'
AM_CFLAGS = -Wall -W -Wunused
@@ -11,10 +11,20 @@
devtree.c devtree.h list.h \
usbmisc.c usbmisc.h
-data_DATA = usb.ids
-
man_MANS = lsusb.8
+install-data-local:
+ $(mkinstalldirs) $(DESTDIR)$(datadir)
+if HAVE_ZLIB
+ gzip -c -9 $(srcdir)/usb.ids > $(DESTDIR)$(datadir)/usb.ids.gz
+else
+ $(INSTALL_DATA) $(srcdir)/usb.ids $(DESTDIR)$(datadir)/usb.ids
+endif
+
+uninstall-local:
+ rm -f $(DESTDIR)$(datadir)/usb.ids $(DESTDIR)$(datadir)/usb.ids.gz
+ rmdir -p --ignore-fail-on-non-empty $(DESTDIR)$(datadir) >/dev/null 2>&1
+
# usbmodules is needed only with 2.4 based hotplugging, and is OBSOLETE
# EXTRA_PROGRAMS = usbmodules
@@ -27,4 +37,4 @@
# man_MANS += usbmodules.8
#endif
-EXTRA_DIST = $(man_MANS) $(data_DATA) update-usbids.sh
+EXTRA_DIST = $(man_MANS) usb.ids update-usbids.sh
diff -Nurd usbutils-0.72.orig/names.c usbutils-0.72/names.c
--- usbutils-0.72.orig/names.c 2005-10-22 07:59:50.000000000 +0200
+++ usbutils-0.72/names.c 2006-08-08 22:33:59.000000000 +0200
@@ -38,6 +38,19 @@
#include "config.h"
#endif
+#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 "names.h"
@@ -454,14 +467,14 @@
#define DBG(x)
-static void parse(FILE *f)
+static void parse(usb_file f)
{
char buf[512], *cp;
unsigned int linectr = 0;
int lastvendor = -1, lastclass = -1, lastsubclass = -1, lasthut=-1,
lastlang=-1;
unsigned int u;
- while (fgets(buf, sizeof(buf), f)) {
+ while (usb_fgets(buf, sizeof(buf), f)) {
linectr++;
/* remove line ends */
if ((cp = strchr(buf, 13)))
@@ -785,12 +798,12 @@
int names_init(char *n)
{
- FILE *f;
+ usb_file f;
- if (!(f = fopen(n, "r"))) {
+ if (!(f = usb_fopen(n, "r"))) {
return errno;
}
parse(f);
- fclose(f);
+ usb_close(f);
return 0;
}
-------------------------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________
linux-usb-devel@lists.sourceforge.net
To unsubscribe, use the last form field at:
https://lists.sourceforge.net/lists/listinfo/linux-usb-devel