| 1 |
/* SPDX-License-Identifier: MIT-0 */ |
| 2 |
|
| 3 |
#define _GNU_SOURCE 1 |
| 4 |
#include <stdio.h> |
| 5 |
#include <stdint.h> |
| 6 |
#include <systemd/sd-hwdb.h> |
| 7 |
|
| 8 |
int print_usb_properties(uint16_t vid, uint16_t pid) { |
| 9 |
char match[128]; |
| 10 |
sd_hwdb *hwdb; |
| 11 |
const char *key, *value; |
| 12 |
int r; |
| 13 |
|
| 14 |
/* Match this USB vendor and product ID combination */ |
| 15 |
snprintf(match, sizeof match, "usb:v%04Xp%04X", vid, pid); |
| 16 |
|
| 17 |
r = sd_hwdb_new(&hwdb); |
| 18 |
if (r < 0) |
| 19 |
return r; |
| 20 |
|
| 21 |
SD_HWDB_FOREACH_PROPERTY(hwdb, match, key, value) |
| 22 |
printf("%s: \"%s\" → \"%s\"\n", match, key, value); |
| 23 |
|
| 24 |
sd_hwdb_unref(hwdb); |
| 25 |
return 0; |
| 26 |
} |
| 27 |
|
| 28 |
int main(int argc, char **argv) { |
| 29 |
print_usb_properties(0x046D, 0xC534); |
| 30 |
return 0; |
| 31 |
} |