2 * Copyright (C) 2013-2015 Kay Sievers
4 * kdbus is free software; you can redistribute it and/or modify it under
5 * the terms of the GNU Lesser General Public License as published by the
6 * Free Software Foundation; either version 2.1 of the License, or (at
7 * your option) any later version.
19 #include "kdbus-util.h"
20 #include "kdbus-enum.h"
22 struct kdbus_enum_table {
27 #define TABLE(what) static struct kdbus_enum_table kdbus_table_##what[]
28 #define ENUM(_id) { .id = _id, .name = STRINGIFY(_id) }
29 #define LOOKUP(what) \
30 const char *enum_##what(long long id) \
32 for (size_t i = 0; i < ELEMENTSOF(kdbus_table_##what); i++) \
33 if (id == kdbus_table_##what[i].id) \
34 return kdbus_table_##what[i].name; \
39 ENUM(KDBUS_CMD_BUS_MAKE),
40 ENUM(KDBUS_CMD_ENDPOINT_MAKE),
41 ENUM(KDBUS_CMD_HELLO),
45 ENUM(KDBUS_CMD_NAME_RELEASE),
46 ENUM(KDBUS_CMD_CONN_INFO),
47 ENUM(KDBUS_CMD_MATCH_ADD),
48 ENUM(KDBUS_CMD_MATCH_REMOVE),
53 ENUM(_KDBUS_ITEM_NULL),
54 ENUM(KDBUS_ITEM_PAYLOAD_VEC),
55 ENUM(KDBUS_ITEM_PAYLOAD_OFF),
56 ENUM(KDBUS_ITEM_PAYLOAD_MEMFD),
58 ENUM(KDBUS_ITEM_BLOOM_PARAMETER),
59 ENUM(KDBUS_ITEM_BLOOM_FILTER),
60 ENUM(KDBUS_ITEM_DST_NAME),
61 ENUM(KDBUS_ITEM_MAKE_NAME),
62 ENUM(KDBUS_ITEM_ATTACH_FLAGS_SEND),
63 ENUM(KDBUS_ITEM_ATTACH_FLAGS_RECV),
65 ENUM(KDBUS_ITEM_NAME),
66 ENUM(KDBUS_ITEM_TIMESTAMP),
67 ENUM(KDBUS_ITEM_CREDS),
68 ENUM(KDBUS_ITEM_PIDS),
69 ENUM(KDBUS_ITEM_AUXGROUPS),
70 ENUM(KDBUS_ITEM_OWNED_NAME),
71 ENUM(KDBUS_ITEM_TID_COMM),
72 ENUM(KDBUS_ITEM_PID_COMM),
74 ENUM(KDBUS_ITEM_CMDLINE),
75 ENUM(KDBUS_ITEM_CGROUP),
76 ENUM(KDBUS_ITEM_CAPS),
77 ENUM(KDBUS_ITEM_SECLABEL),
78 ENUM(KDBUS_ITEM_AUDIT),
79 ENUM(KDBUS_ITEM_CONN_DESCRIPTION),
80 ENUM(KDBUS_ITEM_NAME_ADD),
81 ENUM(KDBUS_ITEM_NAME_REMOVE),
82 ENUM(KDBUS_ITEM_NAME_CHANGE),
83 ENUM(KDBUS_ITEM_ID_ADD),
84 ENUM(KDBUS_ITEM_ID_REMOVE),
85 ENUM(KDBUS_ITEM_REPLY_TIMEOUT),
86 ENUM(KDBUS_ITEM_REPLY_DEAD),
91 ENUM(KDBUS_PAYLOAD_KERNEL),
92 ENUM(KDBUS_PAYLOAD_DBUS),