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
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
71
72
73
74
75
76
77
78
79
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
111
113
115
117
119
121
123
125
127
128
129
130
/* ... */
#include <stdlib.h>
#include <stdint.h>
#include <errno.h>
#include "libjaylink.h"
/* ... */
/* ... */
JAYLINK_API int jaylink_parse_serial_number(const char *str,
uint32_t *serial_number)
{
char *end_ptr;
unsigned long long tmp;
if (!str || !serial_number)
return JAYLINK_ERR_ARG;
errno = 0;
tmp = strtoull(str, &end_ptr, 10);
if (*end_ptr != '\0' || errno != 0 || tmp > UINT32_MAX)
return JAYLINK_ERR;
*serial_number = tmp;
return JAYLINK_OK;
}{ ... }
/* ... */
JAYLINK_API const char *jaylink_hardware_type_string(
enum jaylink_hardware_type type)
{
switch (type) {
case JAYLINK_HW_TYPE_JLINK:
return "J-Link";case JAYLINK_HW_TYPE_JLINK:
case JAYLINK_HW_TYPE_FLASHER:
return "Flasher";case JAYLINK_HW_TYPE_FLASHER:
case JAYLINK_HW_TYPE_JLINK_PRO:
return "J-Link PRO";case JAYLINK_HW_TYPE_JLINK_PRO:
default:
break;default
}switch (type) { ... }
return NULL;
}{ ... }
/* ... */
JAYLINK_API const char *jaylink_target_interface_string(
enum jaylink_target_interface iface)
{
switch (iface) {
case JAYLINK_TIF_JTAG:
return "JTAG";case JAYLINK_TIF_JTAG:
case JAYLINK_TIF_SWD:
return "SWD";case JAYLINK_TIF_SWD:
case JAYLINK_TIF_BDM3:
return "BDM3";case JAYLINK_TIF_BDM3:
case JAYLINK_TIF_FINE:
return "FINE";case JAYLINK_TIF_FINE:
case JAYLINK_TIF_2W_JTAG_PIC32:
return "2-wire JTAG for PIC32";case JAYLINK_TIF_2W_JTAG_PIC32:
case JAYLINK_TIF_SPI:
return "SPI";case JAYLINK_TIF_SPI:
case JAYLINK_TIF_C2:
return "C2";case JAYLINK_TIF_C2:
case JAYLINK_TIF_CJTAG:
return "cJTAG";case JAYLINK_TIF_CJTAG:
default:
break;default
}switch (iface) { ... }
return NULL;
}{ ... }