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