]> git.ipfire.org Git - thirdparty/systemd.git/blame - man/hwdb-usb-device.c
update TODO
[thirdparty/systemd.git] / man / hwdb-usb-device.c
CommitLineData
1fe6d37e 1/* SPDX-License-Identifier: MIT-0 */
f4d74c61 2
32c4d2ba
ZJS
3#include <stdio.h>
4#include <stdint.h>
5#include <sd-hwdb.h>
6
7int print_usb_properties(uint16_t vid, uint16_t pid) {
e4193309 8 char match[STRLEN("usb:vp") + DECIMAL_STR_MAX(uint16_t) * 2];
32c4d2ba
ZJS
9 sd_hwdb *hwdb;
10 const char *key, *value;
11 int r;
12
13 /* Match this USB vendor and product ID combination */
e4193309 14 xsprintf(match, "usb:v%04Xp%04X", vid, pid);
32c4d2ba
ZJS
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
27int main(int argc, char **argv) {
28 print_usb_properties(0x046D, 0xC534);
29 return 0;
30}