From 30b8e72afa22a7ff5a72370e4dc0cfbe0a329ada Mon Sep 17 00:00:00 2001 From: Guillaume Cottenceau Date: Mon, 10 Sep 2001 22:11:45 +0000 Subject: add "-v" and "-f" options to lspcidrake for (v)erbose mode and (f)ull probe --- ldetect.spec | 8 ++++++-- lspcidrake.c | 45 ++++++++++++++++++++++++++++++++++++++++++--- 2 files changed, 48 insertions(+), 5 deletions(-) diff --git a/ldetect.spec b/ldetect.spec index 3bed138..fc2feee 100644 --- a/ldetect.spec +++ b/ldetect.spec @@ -1,7 +1,7 @@ # !! DON'T MODIFY HERE, MODIFY IN THE CVS !! %define name ldetect -%define version 0.2.3 -%define release 14mdk +%define version 0.2.4 +%define release 1mdk Name: %{name} Version: %{version} @@ -53,6 +53,10 @@ rm -rf $RPM_BUILD_ROOT %{_libdir}/* %changelog +* Tue Sep 11 2001 Guillaume Cottenceau 0.2.4-1mdk +- add "-v" and "-f" options to lspcidrake for (v)erbose mode and (f)ull + probe + * Wed Aug 29 2001 Pixel 0.2.3-14mdk - fix when 2 similar devices are there diff --git a/lspcidrake.c b/lspcidrake.c index 4bb987f..b17d184 100644 --- a/lspcidrake.c +++ b/lspcidrake.c @@ -3,15 +3,41 @@ #include #include "libldetect.h" +int verboze = 0; +int full_probe = 0; + +void usage(void) { + printf("usage: lspcidrake [-v] [-f]\n"); + exit(0); +} + +void print_name(struct pciusb_entry e) { + printf("%-16s: ", e.module ? e.module : "unknown"); + if (e.text) + printf(e.text); + else + printf("unknown (%04x/%04x/%04x/%04x)", e.vendor, e.device, e.subvendor, e.subdevice); +} + +void print_id(struct pciusb_entry e) { + if (verboze && e.text) { + printf(" (vendor:%04x device:%04x", e.vendor, e.device); + if (e.subvendor != 0xffff || e.subdevice != 0xffff) + printf(" subv:%04x subd:%04x", e.subvendor, e.subdevice); + printf(")"); + } +} + void pci_printit(struct pciusb_entries entries) { int i; for (i = 0; i < entries.nb; i++) { struct pciusb_entry e = entries.entries[i]; - printf("%-16s: %s", e.module ? e.module : "unknown", e.text); + print_name(e); if (e.class) { const char *class = pci_class2text(e.class); if (strcmp(class, "NOT_DEFINED") != 0) printf(" [%s]", class); } + print_id(e); printf("\n"); } } @@ -20,15 +46,28 @@ void usb_printit(struct pciusb_entries entries) { int i; for (i = 0; i < entries.nb; i++) { struct pciusb_entry e = entries.entries[i]; - printf("%-16s: %s", e.module ? e.module : "unknown", e.text); + print_name(e); if (e.class) printf(" [%s]", usb_class2text(e.class)); + print_id(e); printf("\n"); } } int main(int argc, char **argv) { + char ** ptr = argv; + while (ptr && *ptr) { + if (!strcmp(*ptr, "-h") || !strcmp(*ptr, "--help")) + usage(); + if (!strcmp(*ptr, "-v")) { + verboze = 1; + full_probe = 1; + } + if (!strcmp(*ptr, "-f")) + full_probe = 1; + ptr++; + } { - struct pciusb_entries entries = pci_probe(0); + struct pciusb_entries entries = pci_probe(full_probe); pci_printit(entries); pciusb_free(entries); } -- cgit v1.2.1