-
Notifications
You must be signed in to change notification settings - Fork 79
/
channel_subsystem.c
49 lines (38 loc) · 1.06 KB
/
channel_subsystem.c
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
/*
20150114
20241209 - reformated using clang-format
Jan Mojzis
Public domain.
*/
#include "str.h"
#include "log.h"
#include "e.h"
#include "channel.h"
static long long channel_subsystem_pos = 0;
static const char *channel_subsystem[CHANNEL_SUBSYSTEM_MAX] = {0};
int channel_subsystem_add(const char *x) {
if (channel_subsystem_pos >= CHANNEL_SUBSYSTEM_MAX) return 0;
channel_subsystem[channel_subsystem_pos++] = x;
return 1;
}
const char *channel_subsystem_get(const char *x) {
long long len, i;
if (!x) return 0;
len = str_len(x);
for (i = 0; i < CHANNEL_SUBSYSTEM_MAX; ++i) {
if (!channel_subsystem[i]) break;
if (str_start(channel_subsystem[i], x)) {
if (channel_subsystem[i][len] == '=') {
return channel_subsystem[i] + len + 1;
}
}
}
return 0;
}
void channel_subsystem_log(void) {
long long i;
for (i = 0; i < CHANNEL_SUBSYSTEM_MAX; ++i) {
if (!channel_subsystem[i]) break;
log_d3("subsystem: ", channel_subsystem[i], " registered");
}
}