blob: 783d22c9a379363e3b6d67e68fd5ad1861ff9c97 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
|
/*
* Copyright (c) 2018 Yubico AB. All rights reserved.
* Use of this source code is governed by a BSD-style
* license that can be found in the LICENSE file.
*/
#include <string.h>
#include "fido.h"
fido_dev_info_t *
fido_dev_info_new(size_t n)
{
return (calloc(n, sizeof(fido_dev_info_t)));
}
void
fido_dev_info_free(fido_dev_info_t **devlist_p, size_t n)
{
fido_dev_info_t *devlist;
if (devlist_p == NULL || (devlist = *devlist_p) == NULL)
return;
for (size_t i = 0; i < n; i++) {
const fido_dev_info_t *di = &devlist[i];
free(di->path);
free(di->manufacturer);
free(di->product);
}
free(devlist);
*devlist_p = NULL;
}
const fido_dev_info_t *
fido_dev_info_ptr(const fido_dev_info_t *devlist, size_t i)
{
return (&devlist[i]);
}
const char *
fido_dev_info_path(const fido_dev_info_t *di)
{
return (di->path);
}
int16_t
fido_dev_info_vendor(const fido_dev_info_t *di)
{
return (di->vendor_id);
}
int16_t
fido_dev_info_product(const fido_dev_info_t *di)
{
return (di->product_id);
}
const char *
fido_dev_info_manufacturer_string(const fido_dev_info_t *di)
{
return (di->manufacturer);
}
const char *
fido_dev_info_product_string(const fido_dev_info_t *di)
{
return (di->product);
}
|