summaryrefslogtreecommitdiffstats
path: root/lspcidrake.c
diff options
context:
space:
mode:
authorGuillaume Cottenceau <gc@mandriva.com>2001-09-10 22:11:45 +0000
committerGuillaume Cottenceau <gc@mandriva.com>2001-09-10 22:11:45 +0000
commit30b8e72afa22a7ff5a72370e4dc0cfbe0a329ada (patch)
tree707457fa3183ceaaf46699b6e2ded1623a734e64 /lspcidrake.c
parentd08f86da74f77533e48d79f3d3f14144583d8b5a (diff)
downloadldetect-30b8e72afa22a7ff5a72370e4dc0cfbe0a329ada.tar
ldetect-30b8e72afa22a7ff5a72370e4dc0cfbe0a329ada.tar.gz
ldetect-30b8e72afa22a7ff5a72370e4dc0cfbe0a329ada.tar.bz2
ldetect-30b8e72afa22a7ff5a72370e4dc0cfbe0a329ada.tar.xz
ldetect-30b8e72afa22a7ff5a72370e4dc0cfbe0a329ada.zip
add "-v" and "-f" options to lspcidrake for (v)erbose mode and (f)ull probe
Diffstat (limited to 'lspcidrake.c')
-rw-r--r--lspcidrake.c45
1 files changed, 42 insertions, 3 deletions
diff --git a/lspcidrake.c b/lspcidrake.c
index 4bb987f..b17d184 100644
--- a/lspcidrake.c
+++ b/lspcidrake.c
@@ -3,15 +3,41 @@
#include <string.h>
#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);
}