1 /* SPDX-License-Identifier: LGPL-2.1+ */
3 This file is part of systemd.
5 Copyright 2013 Lennart Poettering
7 systemd is free software; you can redistribute it and/or modify it
8 under the terms of the GNU Lesser General Public License as published by
9 the Free Software Foundation; either version 2.1 of the License, or
10 (at your option) any later version.
12 systemd is distributed in the hope that it will be useful, but
13 WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 Lesser General Public License for more details.
17 You should have received a copy of the GNU Lesser General Public License
18 along with systemd; If not, see <http://www.gnu.org/licenses/>.
27 bool bus_type_is_valid(char c) {
28 static const char valid[] = {
39 SD_BUS_TYPE_OBJECT_PATH,
40 SD_BUS_TYPE_SIGNATURE,
44 SD_BUS_TYPE_DICT_ENTRY,
48 return !!memchr(valid, c, sizeof(valid));
51 #if 0 /// UNNEEDED by elogind
52 bool bus_type_is_valid_in_signature(char c) {
53 static const char valid[] = {
64 SD_BUS_TYPE_OBJECT_PATH,
65 SD_BUS_TYPE_SIGNATURE,
68 SD_BUS_TYPE_STRUCT_BEGIN,
69 SD_BUS_TYPE_STRUCT_END,
70 SD_BUS_TYPE_DICT_ENTRY_BEGIN,
71 SD_BUS_TYPE_DICT_ENTRY_END,
75 return !!memchr(valid, c, sizeof(valid));
79 bool bus_type_is_basic(char c) {
80 static const char valid[] = {
91 SD_BUS_TYPE_OBJECT_PATH,
92 SD_BUS_TYPE_SIGNATURE,
96 return !!memchr(valid, c, sizeof(valid));
99 bool bus_type_is_trivial(char c) {
100 static const char valid[] = {
112 return !!memchr(valid, c, sizeof(valid));
115 bool bus_type_is_container(char c) {
116 static const char valid[] = {
120 SD_BUS_TYPE_DICT_ENTRY
123 return !!memchr(valid, c, sizeof(valid));
126 int bus_type_get_alignment(char c) {
129 case SD_BUS_TYPE_BYTE:
130 case SD_BUS_TYPE_SIGNATURE:
131 case SD_BUS_TYPE_VARIANT:
134 case SD_BUS_TYPE_INT16:
135 case SD_BUS_TYPE_UINT16:
138 case SD_BUS_TYPE_BOOLEAN:
139 case SD_BUS_TYPE_INT32:
140 case SD_BUS_TYPE_UINT32:
141 case SD_BUS_TYPE_STRING:
142 case SD_BUS_TYPE_OBJECT_PATH:
143 case SD_BUS_TYPE_ARRAY:
144 case SD_BUS_TYPE_UNIX_FD:
147 case SD_BUS_TYPE_INT64:
148 case SD_BUS_TYPE_UINT64:
149 case SD_BUS_TYPE_DOUBLE:
150 case SD_BUS_TYPE_STRUCT:
151 case SD_BUS_TYPE_STRUCT_BEGIN:
152 case SD_BUS_TYPE_DICT_ENTRY:
153 case SD_BUS_TYPE_DICT_ENTRY_BEGIN:
160 int bus_type_get_size(char c) {
163 case SD_BUS_TYPE_BYTE:
166 case SD_BUS_TYPE_INT16:
167 case SD_BUS_TYPE_UINT16:
170 case SD_BUS_TYPE_BOOLEAN:
171 case SD_BUS_TYPE_INT32:
172 case SD_BUS_TYPE_UINT32:
173 case SD_BUS_TYPE_UNIX_FD:
176 case SD_BUS_TYPE_INT64:
177 case SD_BUS_TYPE_UINT64:
178 case SD_BUS_TYPE_DOUBLE: