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