summaryrefslogtreecommitdiffstats
path: root/perl-install/c/stuff.xs.pl
diff options
context:
space:
mode:
Diffstat (limited to 'perl-install/c/stuff.xs.pl')
-rwxr-xr-xperl-install/c/stuff.xs.pl49
1 files changed, 31 insertions, 18 deletions
diff --git a/perl-install/c/stuff.xs.pl b/perl-install/c/stuff.xs.pl
index 4b80a862f..245746821 100755
--- a/perl-install/c/stuff.xs.pl
+++ b/perl-install/c/stuff.xs.pl
@@ -95,6 +95,18 @@ void log_perror(const char *msg) {
log_message("%s: %s", msg, strerror(errno));
}
+HV* common_pciusb_hash_init(struct pciusb_entry *e) {
+ HV *rh = (HV *)sv_2mortal((SV *)newHV());
+ hv_store(rh, "vendor", 6, newSViv(e->vendor), 0);
+ hv_store(rh, "subvendor", 9, newSViv(e->subvendor), 0);
+ hv_store(rh, "id", 2, newSViv(e->device), 0);
+ hv_store(rh, "subid", 5, newSViv(e->subdevice), 0);
+ hv_store(rh, "driver", 6, newSVpv(e->module ? e->module : "unknown", 0), 0);
+ hv_store(rh, "description", 11, newSVpv(e->text, 0), 0);
+ hv_store(rh, "pci_bus", 7, newSViv(e->pci_bus), 0);
+ hv_store(rh, "pci_device", 10, newSViv(e->pci_device), 0);
+ return rh;
+}
';
@@ -166,7 +178,7 @@ init_setlocale()
setlocale(LC_NUMERIC, "C"); /* otherwise eval "1.5" returns 1 in fr_FR for example */
char *
-setlocale(category, locale = 0)
+setlocale(category, locale = NULL)
int category
char * locale
@@ -261,19 +273,20 @@ get_pci_description(int vendor_id,int device_id)
void
pci_probe()
PPCODE:
- //proc_pci_path = "/tmp/pci";
struct pciusb_entries entries = pci_probe();
- char buf[2048];
int i;
EXTEND(SP, entries.nb);
for (i = 0; i < entries.nb; i++) {
struct pciusb_entry *e = &entries.entries[i];
- snprintf(buf, sizeof(buf), "%04x\t%04x\t%04x\t%04x\t%d\t%d\t%d\t%d\t%d\t%d\t%s\t%s\t%s\t%s",
- e->vendor, e->device, e->subvendor, e->subdevice, e->pci_domain, e->pci_bus,
- e->pci_device, e->pci_function, e->pci_revision, e->is_pciexpress,
- pci_class2text(e->class_id), e->class, e->module ? e->module : "unknown", e->text);
- PUSHs(sv_2mortal(newSVpv(buf, 0)));
+ HV * rh = common_pciusb_hash_init(e);
+ hv_store(rh, "pci_domain", 10, newSViv(e->pci_domain), 0);
+ hv_store(rh, "pci_function", 12, newSViv(e->pci_function), 0);
+ hv_store(rh, "pci_revision", 12, newSViv(e->pci_revision), 0);
+ hv_store(rh, "is_pciexpress", 13, newSViv(e->is_pciexpress), 0);
+ hv_store(rh, "nice_media_type", 15, newSVpv(e->class, 0), 0);
+ hv_store(rh, "media_type", 10, newSVpv(pci_class2text(e->class_id), 0), 0);
+ PUSHs(newRV((SV *)rh));
}
pciusb_free(&entries);
@@ -288,11 +301,11 @@ usb_probe()
for (i = 0; i < entries.nb; i++) {
struct pciusb_entry *e = &entries.entries[i];
struct usb_class_text class_text = usb_class2text(e->class_id);
- snprintf(buf, sizeof(buf), "%04x\t%04x\t%s|%s|%s\t%s\t%s\t%d\t%d\t%d",
- e->vendor, e->device, class_text.usb_class_text, class_text.usb_sub_text,
- class_text.usb_prot_text, e->module ? e->module : "unknown", e->text,
- e->pci_bus, e->pci_device, e->usb_port);
- PUSHs(sv_2mortal(newSVpv(buf, 0)));
+ snprintf(buf, sizeof(buf), "%s|%s|%s", class_text.usb_class_text, class_text.usb_sub_text, class_text.usb_prot_text);
+ HV * rh = common_pciusb_hash_init(e);
+ hv_store(rh, "usb_port", 8, newSViv(e->usb_port), 0);
+ hv_store(rh, "media_type", 10, newSVpv(buf, 0), 0);
+ PUSHs(newRV((SV *)rh));
}
pciusb_free(&entries);
@@ -303,14 +316,14 @@ dmi_probe()
//dmidecode_file = "../../soft/ldetect-lst/test/dmidecode.Laptop.Sony-Vaio-GRX316MP";
struct dmi_entries entries = dmi_probe();
- char buf[2048];
int i;
EXTEND(SP, entries.nb);
for (i = 0; i < entries.nb; i++) {
- snprintf(buf, sizeof(buf), "%s\t%s",
- entries.entries[i].module, entries.entries[i].constraints);
- PUSHs(sv_2mortal(newSVpv(buf, 0)));
+ HV * rh = (HV *)sv_2mortal((SV *)newHV());
+ hv_store(rh, "driver", 6, newSVpv(entries.entries[i].module, 0), 0);
+ hv_store(rh, "description", 11, newSVpv(entries.entries[i].constraints, 0), 0);
+ PUSHs(newRV((SV *)rh));
}
dmi_entries_free(entries);
@@ -510,7 +523,7 @@ EVIocGBitKey (char *file)
fd = open (file, O_RDONLY);
if (fd < 0) {
- perror("Cannot open /dev/input/eventX");
+ warn("Cannot open %s: %s\n", file, strerror(errno));
return;
}