blob: 982bdb754898091d7b401bd9573fe70a20d243d7 (
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
|
/*
* 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 <stdarg.h>
#include <stdio.h>
#include <stdlib.h>
#include "fido.h"
#ifndef FIDO_NO_DIAGNOSTIC
#ifndef TLS
#define TLS
#endif
static TLS int logging;
void
fido_log_init(void)
{
logging = 1;
}
void
fido_log_xxd(const void *buf, size_t count)
{
const uint8_t *ptr = buf;
size_t i;
if (!logging)
return;
fprintf(stderr, " ");
for (i = 0; i < count; i++) {
fprintf(stderr, "%02x ", *ptr++);
if ((i + 1) % 16 == 0 && i + 1 < count)
fprintf(stderr, "\n ");
}
fprintf(stderr, "\n");
fflush(stderr);
}
void
fido_log_debug(const char *fmt, ...)
{
va_list ap;
if (!logging)
return;
va_start(ap, fmt);
vfprintf(stderr, fmt, ap);
va_end(ap);
fprintf(stderr, "\n");
fflush(stderr);
}
#endif /* !FIDO_NO_DIAGNOSTIC */
|