Re: [linux-usb-devel] [PATCH] Support for gzipped usb.ids files

2006-08-22 Thread Randy.Dunlap
On Mon, 14 Aug 2006 15:22:10 +0200 Aurelien Jarno wrote:

 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.

Hi,

1.  Makefile.am still uses USBIDS_FILE instead of USBIDS_DIR.
(easy to fix)

2.  lsusb.c and names.c check for #ifdef HAVE_LIBZ.
What sets that for .c compiles?
What do I need to have installed to get HAVE_LIBZ set?
I'm pretty sure that I have it installed but I'm not seeing
HAVE_LIBZ being defined.  (I have zlib  zlib-devel,
both 32-bit and 64-bit versions.)

I want to test the new code in both cases but can't do that yet.

Thanks,
---
~Randy

-
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=lnkkid=120709bid=263057dat=121642
___
linux-usb-devel@lists.sourceforge.net
To unsubscribe, use the last form field at:
https://lists.sourceforge.net/lists/listinfo/linux-usb-devel


Re: [linux-usb-devel] [PATCH] Support for gzipped usb.ids files

2006-08-14 Thread Aurelien Jarno
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.0 +0100
+++ usbutils-0.72/configure.in  2006-08-08 22:28:24.0 +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.0 +0100
+++ usbutils-0.72/lsusb.c   2006-08-12 22:35:37.0 +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.0 +0100
+++ usbutils-0.72/Makefile.am   2006-08-12 22:37:45.0 +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
-
 

Re: [linux-usb-devel] [PATCH] Support for gzipped usb.ids files

2006-08-08 Thread Thomas Sailer
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?

Tom



-
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=lnkkid=120709bid=263057dat=121642
___
linux-usb-devel@lists.sourceforge.net
To unsubscribe, use the last form field at:
https://lists.sourceforge.net/lists/listinfo/linux-usb-devel


Re: [linux-usb-devel] [PATCH] Support for gzipped usb.ids files

2006-08-08 Thread Randy.Dunlap
On Tue, 08 Aug 2006 14:22:24 +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?

Hi Tom,
The proposed pciutils code looks for pci.ids.gz for the gzipped file.
I agree, if gzipped, it should be .gz.

---
~Randy

-
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=lnkkid=120709bid=263057dat=121642
___
linux-usb-devel@lists.sourceforge.net
To unsubscribe, use the last form field at:
https://lists.sourceforge.net/lists/listinfo/linux-usb-devel


Re: [linux-usb-devel] [PATCH] Support for gzipped usb.ids files

2006-08-08 Thread Aurelien Jarno
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.

Bye,
Aurelien

-- 
  .''`.  Aurelien Jarno | GPG: 1024D/F1BCDB73
 : :' :  Debian developer   | Electrical Engineer
 `. `'   [EMAIL PROTECTED] | [EMAIL PROTECTED]
   `-people.debian.org/~aurel32 | www.aurel32.net

-
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=lnkkid=120709bid=263057dat=121642
___
linux-usb-devel@lists.sourceforge.net
To unsubscribe, use the last form field at:
https://lists.sourceforge.net/lists/listinfo/linux-usb-devel


Re: [linux-usb-devel] [PATCH] Support for gzipped usb.ids files

2006-08-06 Thread Aurelien Jarno
On Sat, Aug 05, 2006 at 04:02:39PM -0700, David Brownell wrote:
 There seems to be a missing install gzipped usb.ids file step
 for make install ...

Oops, you are right. Please find attached a new version of the patch.

 Are pciutils going to install compressed pci.ids?

Actually the idea of the compressed usb.ids has been given to me by the
Debian maintainer of pciutils. The current version of pciutils in Debian
already deals with compressed pci.ids, but I don't know if the patch has
been merged upstream yet.

Bye,
Aurelien

-- 
  .''`.  Aurelien Jarno | GPG: 1024D/F1BCDB73
 : :' :  Debian developer   | Electrical Engineer
 `. `'   [EMAIL PROTECTED] | [EMAIL PROTECTED]
   `-people.debian.org/~aurel32 | www.aurel32.net
--- usbutils-0.72.orig/configure.in
+++ usbutils-0.72/configure.in
@@ -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
--- usbutils-0.72.orig/Makefile.am
+++ usbutils-0.72/Makefile.am
@@ -11,10 +11,16 @@
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 -n -9 $(srcdir)/usb.ids  $(DESTDIR)$(datadir)/usb.ids
+else
+   $(INSTALL_DATA) $(srcdir)/usb.ids $(DESTDIR)$(datadir)/usb.ids
+endif
+
 # usbmodules is needed only with 2.4 based hotplugging, and is OBSOLETE 
 
 # EXTRA_PROGRAMS = usbmodules
@@ -27,4 +33,4 @@
 #man_MANS += usbmodules.8
 #endif
 
-EXTRA_DIST = $(man_MANS) $(data_DATA) update-usbids.sh
+EXTRA_DIST = $(man_MANS) usb.ids update-usbids.sh
--- usbutils-0.72.orig/names.c
+++ usbutils-0.72/names.c
@@ -38,6 +38,19 @@
 #include config.h
 #endif
 
+#ifdef HAVE_LIBZ
+#include zlib.h
+#definemy_file gzFile
+#definemy_fopen(path, mode)gzopen(path, mode)
+#definemy_fgets(s, size, stream)   gzgets(stream, s, size)
+#definemy_close(f) gzclose(f)
+#else
+#definemy_file FILE*
+#definemy_fopen(path, mode)fopen(path, mode)
+#definemy_fgets(s, size, stream)   fgets(s, size, stream)
+#definemy_close(f) fclose(f)
+#endif
+
 #include names.h
 
 
@@ -454,14 +467,14 @@
 
 #define DBG(x) 
 
-static void parse(FILE *f)
+static void parse(my_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 (my_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;
+   my_file f;

-   if (!(f = fopen(n, r))) {
+   if (!(f = my_fopen(n, r))) {
return errno;
}
parse(f);
-   fclose(f);
+   my_close(f);
return 0;
 }
-
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT  business topics through brief surveys -- and earn cash
http://www.techsay.com/default.php?page=join.phpp=sourceforgeCID=DEVDEV___
linux-usb-devel@lists.sourceforge.net
To unsubscribe, use the last form field at:
https://lists.sourceforge.net/lists/listinfo/linux-usb-devel


Re: [linux-usb-devel] [PATCH] Support for gzipped usb.ids files

2006-08-06 Thread Randy.Dunlap
On Sun, 6 Aug 2006 17:08:34 +0200 Aurelien Jarno wrote:

 On Sat, Aug 05, 2006 at 04:02:39PM -0700, David Brownell wrote:
  There seems to be a missing install gzipped usb.ids file step
  for make install ...
 
 Oops, you are right. Please find attached a new version of the patch.
 
  Are pciutils going to install compressed pci.ids?
 
 Actually the idea of the compressed usb.ids has been given to me by the
 Debian maintainer of pciutils. The current version of pciutils in Debian
 already deals with compressed pci.ids, but I don't know if the patch has
 been merged upstream yet.

It was just posted to the linux-pci m-l on Aug-04 and has not
been acted on.

---
~Randy

-
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT  business topics through brief surveys -- and earn cash
http://www.techsay.com/default.php?page=join.phpp=sourceforgeCID=DEVDEV
___
linux-usb-devel@lists.sourceforge.net
To unsubscribe, use the last form field at:
https://lists.sourceforge.net/lists/listinfo/linux-usb-devel


Re: [linux-usb-devel] [PATCH] Support for gzipped usb.ids files

2006-08-05 Thread Aurelien Jarno
[Note to [EMAIL PROTECTED] subscribers: This mail concerns
a patch to add support for gzipped usb.ids file to usbutils. The first
iteration has been done privately with Thomas Sailer]


 Hi Aurelien,
Hi!

 in principle ok with me, but I find the ifdef's sprinkled around in the
 file slightly disgusting. Can you reduce the ifdef orgy by refactoring
 parse_file (move the contents of the while-fgets loop into another
 function, and then have two parse_file's, one for zipped, and one for
 plain files)? 

I have tried to do that, however it is not possible easily as there is a
lot of call to continue inside the while loop. I have instead use 
#define directives to select the normal or the gzip function. This 
results in only one #ifdef. You will find the new patch attached. I hope
you will like this solution :)

 And can the zippedness of the input file be
 autodetected? That would allow distributions for a smoother upgrade path
 (in fedora, f.e., the usb.ids file and usbutils are separate packages,
 so autodetecting the file type would decouple updating both packages).

This is already the case when compiled with gzip support. Actually this
is a feature of the zlib library, that can open normal file using the 
gz* functions when the gzip header is not found.

 And can you please post your message(s) also to [EMAIL PROTECTED]

Done with this mail :-)

Bye,
Aurelien

-- 
  .''`.  Aurelien Jarno | GPG: 1024D/F1BCDB73
 : :' :  Debian developer   | Electrical Engineer
 `. `'   [EMAIL PROTECTED] | [EMAIL PROTECTED]
   `-people.debian.org/~aurel32 | www.aurel32.net
--- usbutils-0.72.orig/configure.in
+++ usbutils-0.72/configure.in
@@ -34,6 +34,24 @@
 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
+
 #AC_ARG_ENABLE(usbmodules,
 #  [  --enable-usbmodules build usbmodules (for Linux 2.4)],
 #  [ case ${enableval} in
--- usbutils-0.72.orig/names.c
+++ usbutils-0.72/names.c
@@ -38,6 +38,19 @@
 #include config.h
 #endif
 
+#ifdef HAVE_LIBZ
+#include zlib.h
+#definemy_file gzFile
+#definemy_fopen(path, mode)gzopen(path, mode)
+#definemy_fgets(s, size, stream)   gzgets(stream, s, size)
+#definemy_close(f) gzclose(f)
+#else
+#definemy_file FILE*
+#definemy_fopen(path, mode)fopen(path, mode)
+#definemy_fgets(s, size, stream)   fgets(s, size, stream)
+#definemy_close(f) fclose(f)
+#endif
+
 #include names.h
 
 
@@ -454,14 +467,14 @@
 
 #define DBG(x) 
 
-static void parse(FILE *f)
+static void parse(my_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 (my_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;
+   my_file f;

-   if (!(f = fopen(n, r))) {
+   if (!(f = my_fopen(n, r))) {
return errno;
}
parse(f);
-   fclose(f);
+   my_close(f);
return 0;
 }
-
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT  business topics through brief surveys -- and earn cash
http://www.techsay.com/default.php?page=join.phpp=sourceforgeCID=DEVDEV___
linux-usb-devel@lists.sourceforge.net
To unsubscribe, use the last form field at:
https://lists.sourceforge.net/lists/listinfo/linux-usb-devel


Re: [linux-usb-devel] [PATCH] Support for gzipped usb.ids files

2006-08-05 Thread David Brownell
There seems to be a missing install gzipped usb.ids file step
for make install ...

Are pciutils going to install compressed pci.ids?

So long as the distros include versions of VIM and less that 
understand gzip, this seems ok to me.

- Dave

-
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT  business topics through brief surveys -- and earn cash
http://www.techsay.com/default.php?page=join.phpp=sourceforgeCID=DEVDEV
___
linux-usb-devel@lists.sourceforge.net
To unsubscribe, use the last form field at:
https://lists.sourceforge.net/lists/listinfo/linux-usb-devel