blob: 67b35758ab0fa435c4c3303fefb9e479940d0de8 (
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
|
#include "hybbx/crdop.h"
#include <ctype.h>
#include <string.h>
static int str_ieq(const char *a, const char *b)
{
if (a == NULL || b == NULL) {
return 0;
}
while (*a != '\0' && *b != '\0') {
char ca = (char)(*a >= 'A' && *a <= 'Z' ? *a + 32 : *a);
char cb = (char)(*b >= 'A' && *b <= 'Z' ? *b + 32 : *b);
if (ca != cb) {
return 0;
}
a++;
b++;
}
return *a == '\0' && *b == '\0';
}
hybbx_crdop_radio_profile_t hybbx_crdop_profile_parse(const char *value)
{
if (value == NULL || value[0] == '\0') {
return HYBBX_CRDOP_PROFILE_AMATEUR;
}
if (str_ieq(value, "cb") || str_ieq(value, "11m") ||
str_ieq(value, "citizens_band")) {
return HYBBX_CRDOP_PROFILE_CB;
}
return HYBBX_CRDOP_PROFILE_AMATEUR;
}
const char *hybbx_crdop_profile_name(hybbx_crdop_radio_profile_t profile)
{
return profile == HYBBX_CRDOP_PROFILE_CB ? "cb" : "amateur";
}
const char *hybbx_crdop_default_arq_bandwidth(hybbx_crdop_radio_profile_t profile)
{
return profile == HYBBX_CRDOP_PROFILE_CB ? "500MAX" : "500MAX";
}
int hybbx_crdop_bandwidth_exceeds_cb(const char *arq_bandwidth)
{
const char *p;
unsigned n = 0;
if (arq_bandwidth == NULL || arq_bandwidth[0] == '\0') {
return 0;
}
p = arq_bandwidth;
while (*p >= '0' && *p <= '9') {
n = n * 10u + (unsigned)(*p - '0');
p++;
}
return n > 1000u;
}
|