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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
|
/*
* Copyright (C) 2013 Kay Sievers
*
* kdbus is free software; you can redistribute it and/or modify it under
* the terms of the GNU Lesser General Public License as published by the
* Free Software Foundation; either version 2.1 of the License, or (at
* your option) any later version.
*/
#include <stdio.h>
#include <string.h>
#include <fcntl.h>
#include <stdlib.h>
#include <stddef.h>
#include <unistd.h>
#include <stdint.h>
#include <errno.h>
#include <sys/ioctl.h>
#include "kdbus-util.h"
#include "kdbus-enum.h"
struct kdbus_enum_table {
long long id;
const char *name;
};
#define TABLE(what) static struct kdbus_enum_table kdbus_table_##what[]
#define ENUM(_id) { .id=_id, .name=STRINGIFY(_id) }
#define LOOKUP(what) \
const char *enum_##what(long long id) { \
for (size_t i = 0; i < ELEMENTSOF(kdbus_table_##what); i++) \
if (id == kdbus_table_##what[i].id) \
return kdbus_table_##what[i].name; \
return "UNKNOWN"; \
}
TABLE(CMD) = {
ENUM(KDBUS_CMD_BUS_MAKE),
ENUM(KDBUS_CMD_NS_MAKE),
ENUM(KDBUS_CMD_EP_MAKE),
ENUM(KDBUS_CMD_HELLO),
ENUM(KDBUS_CMD_MSG_SEND),
ENUM(KDBUS_CMD_MSG_RECV),
ENUM(KDBUS_CMD_NAME_ACQUIRE),
ENUM(KDBUS_CMD_NAME_RELEASE),
ENUM(KDBUS_CMD_NAME_LIST),
ENUM(KDBUS_CMD_NAME_QUERY),
ENUM(KDBUS_CMD_MATCH_ADD),
ENUM(KDBUS_CMD_MATCH_REMOVE),
ENUM(KDBUS_CMD_MONITOR),
ENUM(KDBUS_CMD_EP_POLICY_SET),
};
LOOKUP(CMD);
TABLE(MSG) =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