int verify_executable(Unit *u, const ExecCommand *exec, const char *root);
int verify_units(char **filenames, RuntimeScope scope, bool check_man, bool run_generators, RecursiveErrors recursive_errors, const char *root);
-const char* recursive_errors_to_string(RecursiveErrors i) _const_;
-RecursiveErrors recursive_errors_from_string(const char *s) _pure_;
+DECLARE_STRING_TABLE_LOOKUP(recursive_errors, RecursiveErrors);
_COLOR_MODE_INVALID = -EINVAL,
} ColorMode;
-const char* color_mode_to_string(ColorMode m) _const_;
-ColorMode color_mode_from_string(const char *s) _pure_;
+DECLARE_STRING_TABLE_LOOKUP(color_mode, ColorMode);
ColorMode get_color_mode(void);
static inline bool colors_enabled(void) {
# error "Please register your architecture here!"
#endif
-const char* architecture_to_string(Architecture a) _const_;
-Architecture architecture_from_string(const char *s) _pure_;
+DECLARE_STRING_TABLE_LOOKUP(architecture, Architecture);
/* IWYU pragma: always_keep */
-#include <errno.h> /* IWYU pragma: export */
-#include <inttypes.h> /* IWYU pragma: export */
-#include <limits.h> /* IWYU pragma: export */
-#include <paths.h> /* IWYU pragma: export */
-#include <stdarg.h> /* IWYU pragma: export */
-#include <stdbool.h> /* IWYU pragma: export */
-#include <stddef.h> /* IWYU pragma: export */
-#include <stdint.h> /* IWYU pragma: export */
-#include <sys/types.h> /* IWYU pragma: export */
-#include <uchar.h> /* IWYU pragma: export */
-
-#include "assert-util.h" /* IWYU pragma: export */
-#include "cleanup-util.h" /* IWYU pragma: export */
-#include "macro.h" /* IWYU pragma: export */
+#include <errno.h> /* IWYU pragma: export */
+#include <inttypes.h> /* IWYU pragma: export */
+#include <limits.h> /* IWYU pragma: export */
+#include <paths.h> /* IWYU pragma: export */
+#include <stdarg.h> /* IWYU pragma: export */
+#include <stdbool.h> /* IWYU pragma: export */
+#include <stddef.h> /* IWYU pragma: export */
+#include <stdint.h> /* IWYU pragma: export */
+#include <sys/types.h> /* IWYU pragma: export */
+#include <uchar.h> /* IWYU pragma: export */
+
+#include "assert-util.h" /* IWYU pragma: export */
+#include "cleanup-util.h" /* IWYU pragma: export */
+#include "macro.h" /* IWYU pragma: export */
+#include "string-table-fundamental.h" /* IWYU pragma: export */
/* Generic types */
extern const uint64_t cgroup_io_limit_defaults[_CGROUP_IO_LIMIT_TYPE_MAX];
-const char* cgroup_io_limit_type_to_string(CGroupIOLimitType t) _const_;
-CGroupIOLimitType cgroup_io_limit_type_from_string(const char *s) _pure_;
+DECLARE_STRING_TABLE_LOOKUP(cgroup_io_limit_type, CGroupIOLimitType);
void cgroup_io_limits_list(void);
/* Special values for the io.bfq.weight attribute */
bool cg_kill_supported(void);
-const char* cgroup_controller_to_string(CGroupController c) _const_;
-CGroupController cgroup_controller_from_string(const char *s) _pure_;
+DECLARE_STRING_TABLE_LOOKUP(cgroup_controller, CGroupController);
typedef enum ManagedOOMMode {
MANAGED_OOM_AUTO,
_MANAGED_OOM_MODE_INVALID = -EINVAL,
} ManagedOOMMode;
-const char* managed_oom_mode_to_string(ManagedOOMMode m) _const_;
-ManagedOOMMode managed_oom_mode_from_string(const char *s) _pure_;
+DECLARE_STRING_TABLE_LOOKUP(managed_oom_mode, ManagedOOMMode);
typedef enum ManagedOOMPreference {
MANAGED_OOM_PREFERENCE_NONE = 0,
_MANAGED_OOM_PREFERENCE_INVALID = -EINVAL,
} ManagedOOMPreference;
-const char* managed_oom_preference_to_string(ManagedOOMPreference a) _const_;
-ManagedOOMPreference managed_oom_preference_from_string(const char *s) _pure_;
+DECLARE_STRING_TABLE_LOOKUP(managed_oom_preference, ManagedOOMPreference);
_COMPRESSION_INVALID = -EINVAL,
} Compression;
-const char* compression_to_string(Compression compression) _const_;
-Compression compression_from_string(const char *s) _pure_;
-const char* compression_lowercase_to_string(Compression compression) _const_;
-Compression compression_lowercase_from_string(const char *s) _pure_;
+DECLARE_STRING_TABLE_LOOKUP(compression, Compression);
+DECLARE_STRING_TABLE_LOOKUP(compression_lowercase, Compression);
bool compression_supported(Compression c);
ConfidentialVirtualization detect_confidential_virtualization(void);
-const char* confidential_virtualization_to_string(ConfidentialVirtualization v) _const_;
-ConfidentialVirtualization confidential_virtualization_from_string(const char *s) _pure_;
+DECLARE_STRING_TABLE_LOOKUP(confidential_virtualization, ConfidentialVirtualization);
bool is_locale_utf8(void);
-const char* locale_variable_to_string(LocaleVariable i) _const_;
-LocaleVariable locale_variable_from_string(const char *s) _pure_;
+DECLARE_STRING_TABLE_LOOKUP(locale_variable, LocaleVariable);
static inline void freelocalep(locale_t *p) {
if (*p == (locale_t) 0)
set_log_syntax_callback(/* cb= */ NULL, /* userdata= */ NULL);
}
-const char* log_target_to_string(LogTarget target) _const_;
-LogTarget log_target_from_string(const char *s) _pure_;
+DECLARE_STRING_TABLE_LOOKUP(log_target, LogTarget);
void log_set_target(LogTarget target);
void log_set_target_and_open(LogTarget target);
int log_set_target_from_string(const char *e);
_IMAGE_CLASS_INVALID = -EINVAL,
} ImageClass;
-const char* image_class_to_string(ImageClass cl) _const_;
-ImageClass image_class_from_string(const char *s) _pure_;
+DECLARE_STRING_TABLE_LOOKUP(image_class, ImageClass);
/* The *_extension_release flavours will look for /usr/lib/extension-release/extension-release.NAME
* for sysext images and for /etc/extension-release.d/extension-release.NAME for confext images
int safe_personality(unsigned long p);
int opinionated_personality(unsigned long *ret);
-const char* sigchld_code_to_string(int i) _const_;
-int sigchld_code_from_string(const char *s) _pure_;
-
-int sched_policy_to_string_alloc(int i, char **ret);
-int sched_policy_from_string(const char *s);
+DECLARE_STRING_TABLE_LOOKUP(sigchld_code, int);
+DECLARE_STRING_TABLE_LOOKUP_WITH_FALLBACK(sched_policy, int);
static inline pid_t PTR_TO_PID(const void *p) {
return (pid_t) ((uintptr_t) p);
#define _RLIMIT_MAX RLIMIT_NLIMITS
-const char* rlimit_to_string(int i) _const_;
-int rlimit_from_string(const char *s) _pure_;
+DECLARE_STRING_TABLE_LOOKUP(rlimit, int);
int rlimit_from_string_harder(const char *s) _pure_;
void rlimits_list(const char *prefix);
_RUNTIME_SCOPE_INVALID = -EINVAL,
} RuntimeScope;
-const char* runtime_scope_to_string(RuntimeScope scope) _const_;
-RuntimeScope runtime_scope_from_string(const char *s) _const_;
-
-const char* runtime_scope_cmdline_option_to_string(RuntimeScope scope) _const_;
+DECLARE_STRING_TABLE_LOOKUP(runtime_scope, RuntimeScope);
+DECLARE_STRING_TABLE_LOOKUP_TO_STRING(runtime_scope_cmdline_option, RuntimeScope);
static inline mode_t runtime_scope_to_socket_mode(RuntimeScope scope) {
/* Returns the right socket mode to use for binding AF_UNIX sockets intended for the specified
int sigprocmask_many_internal(int how, sigset_t *ret_old_mask, ...);
#define sigprocmask_many(...) sigprocmask_many_internal(__VA_ARGS__, -1)
-const char* signal_to_string(int signo) _const_;
-int signal_from_string(const char *s) _pure_;
+DECLARE_STRING_TABLE_LOOKUP(signal, int);
void nop_signal_handler(int sig);
#define socket_address_family(a) ((a)->sockaddr.sa.sa_family)
-const char* socket_address_type_to_string(int t) _const_;
-int socket_address_type_from_string(const char *s) _pure_;
+DECLARE_STRING_TABLE_LOOKUP(socket_address_type, int);
int sockaddr_un_unlink(const struct sockaddr_un *sa);
int socknameinfo_pretty(const struct sockaddr *sa, socklen_t salen, char **_ret);
-int netlink_family_to_string_alloc(int i, char **ret);
-int netlink_family_from_string(const char *s) _pure_;
+DECLARE_STRING_TABLE_LOOKUP_WITH_FALLBACK(netlink_family, int);
bool sockaddr_equal(const union sockaddr_union *a, const union sockaddr_union *b);
return fd_set_rcvbuf(fd, n, true);
}
-int ip_tos_to_string_alloc(int i, char **ret);
-int ip_tos_from_string(const char *s);
+DECLARE_STRING_TABLE_LOOKUP_WITH_FALLBACK(ip_tos, int);
typedef enum {
IFNAME_VALID_ALTERNATIVE = 1 << 0, /* Allow "altnames" too */
int inode_compare_func(const struct stat *a, const struct stat *b);
extern const struct hash_ops inode_hash_ops;
-const char* inode_type_to_string(mode_t m) _const_;
-mode_t inode_type_from_string(const char *s) _pure_;
+DECLARE_STRING_TABLE_LOOKUP(inode_type, mode_t);
/* Macros that check whether the stat/statx structures have been initialized already. For "struct stat" we
* use a check for .st_dev being non-zero, since the kernel unconditionally fills that in, mapping the file
#include "basic-forward.h"
-int log_facility_unshifted_to_string_alloc(int i, char **ret);
-int log_facility_unshifted_from_string(const char *s);
+DECLARE_STRING_TABLE_LOOKUP_WITH_FALLBACK(log_facility_unshifted, int);
bool log_facility_unshifted_is_valid(int faciliy);
-int log_level_to_string_alloc(int i, char **ret);
-int log_level_from_string(const char *s);
+DECLARE_STRING_TABLE_LOOKUP_WITH_FALLBACK(log_level, int);
bool log_level_is_valid(int level);
int syslog_parse_priority(const char **p, int *priority, bool with_facility);
int time_change_fd(void);
-const char* timestamp_style_to_string(TimestampStyle t) _const_;
-TimestampStyle timestamp_style_from_string(const char *s) _pure_;
+DECLARE_STRING_TABLE_LOOKUP(timestamp_style, TimestampStyle);
const char* unit_dbus_interface_from_type(UnitType t);
const char* unit_dbus_interface_from_name(const char *name);
-const char* unit_type_to_string(UnitType i) _const_;
-UnitType unit_type_from_string(const char *s) _pure_;
+DECLARE_STRING_TABLE_LOOKUP(unit_type, UnitType);
void unit_types_list(void);
-const char* unit_load_state_to_string(UnitLoadState i) _const_;
-UnitLoadState unit_load_state_from_string(const char *s) _pure_;
+DECLARE_STRING_TABLE_LOOKUP(unit_load_state, UnitLoadState);
-const char* unit_active_state_to_string(UnitActiveState i) _const_;
-UnitActiveState unit_active_state_from_string(const char *s) _pure_;
+DECLARE_STRING_TABLE_LOOKUP(unit_active_state, UnitActiveState);
-const char* freezer_state_to_string(FreezerState i) _const_;
-FreezerState freezer_state_from_string(const char *s) _pure_;
+DECLARE_STRING_TABLE_LOOKUP(freezer_state, FreezerState);
FreezerState freezer_state_finish(FreezerState state) _const_;
FreezerState freezer_state_objective(FreezerState state) _const_;
-const char* unit_marker_to_string(UnitMarker m) _const_;
-UnitMarker unit_marker_from_string(const char *s) _pure_;
+DECLARE_STRING_TABLE_LOOKUP(unit_marker, UnitMarker);
-const char* automount_state_to_string(AutomountState i) _const_;
-AutomountState automount_state_from_string(const char *s) _pure_;
+DECLARE_STRING_TABLE_LOOKUP(automount_state, AutomountState);
-const char* device_state_to_string(DeviceState i) _const_;
-DeviceState device_state_from_string(const char *s) _pure_;
+DECLARE_STRING_TABLE_LOOKUP(device_state, DeviceState);
-const char* mount_state_to_string(MountState i) _const_;
-MountState mount_state_from_string(const char *s) _pure_;
+DECLARE_STRING_TABLE_LOOKUP(mount_state, MountState);
-const char* path_state_to_string(PathState i) _const_;
-PathState path_state_from_string(const char *s) _pure_;
+DECLARE_STRING_TABLE_LOOKUP(path_state, PathState);
-const char* scope_state_to_string(ScopeState i) _const_;
-ScopeState scope_state_from_string(const char *s) _pure_;
+DECLARE_STRING_TABLE_LOOKUP(scope_state, ScopeState);
-const char* service_state_to_string(ServiceState i) _const_;
-ServiceState service_state_from_string(const char *s) _pure_;
+DECLARE_STRING_TABLE_LOOKUP(service_state, ServiceState);
-const char* slice_state_to_string(SliceState i) _const_;
-SliceState slice_state_from_string(const char *s) _pure_;
+DECLARE_STRING_TABLE_LOOKUP(slice_state, SliceState);
-const char* socket_state_to_string(SocketState i) _const_;
-SocketState socket_state_from_string(const char *s) _pure_;
+DECLARE_STRING_TABLE_LOOKUP(socket_state, SocketState);
-const char* swap_state_to_string(SwapState i) _const_;
-SwapState swap_state_from_string(const char *s) _pure_;
+DECLARE_STRING_TABLE_LOOKUP(swap_state, SwapState);
-const char* target_state_to_string(TargetState i) _const_;
-TargetState target_state_from_string(const char *s) _pure_;
+DECLARE_STRING_TABLE_LOOKUP(target_state, TargetState);
-const char* timer_state_to_string(TimerState i) _const_;
-TimerState timer_state_from_string(const char *s) _pure_;
+DECLARE_STRING_TABLE_LOOKUP(timer_state, TimerState);
-const char* unit_dependency_to_string(UnitDependency i) _const_;
-UnitDependency unit_dependency_from_string(const char *s) _pure_;
+DECLARE_STRING_TABLE_LOOKUP(unit_dependency, UnitDependency);
-const char* notify_access_to_string(NotifyAccess i) _const_;
-NotifyAccess notify_access_from_string(const char *s) _pure_;
+DECLARE_STRING_TABLE_LOOKUP(notify_access, NotifyAccess);
-const char* job_mode_to_string(JobMode t) _const_;
-JobMode job_mode_from_string(const char *s) _pure_;
+DECLARE_STRING_TABLE_LOOKUP(job_mode, JobMode);
-const char* exec_directory_type_to_string(ExecDirectoryType i) _const_;
-ExecDirectoryType exec_directory_type_from_string(const char *s) _pure_;
+DECLARE_STRING_TABLE_LOOKUP(exec_directory_type, ExecDirectoryType);
Glyph unit_active_state_to_glyph(UnitActiveState state);
int running_in_userns(void);
int running_in_chroot(void);
-const char* virtualization_to_string(Virtualization v) _const_;
-Virtualization virtualization_from_string(const char *s) _pure_;
+DECLARE_STRING_TABLE_LOOKUP(virtualization, Virtualization);
bool has_cpu_with_flag(const char *flag);
_LOG_INVALID = -1,
} LogLevel;
-LogLevel log_level_from_string(const char *s) _pure_;
-const char* log_level_to_string(LogLevel l) _const_;
+DECLARE_STRING_TABLE_LOOKUP(log_level, LogLevel);
LogLevel log_get_max_level(void) _pure_;
int log_set_max_level(LogLevel level);
#include "cleanup-fundamental.h" /* IWYU pragma: export */
#include "efi-fundamental.h" /* IWYU pragma: export */
#include "macro-fundamental.h" /* IWYU pragma: export */
+#include "string-table-fundamental.h" /* IWYU pragma: export */
#if SD_BOOT
/* uchar.h/wchar.h are not suitable for freestanding environments. */
void uninstall_security_override(void);
bool security_override_available(void);
-const char* secure_boot_enroll_to_string(secure_boot_enroll e) _const_;
-const char* secure_boot_enroll_action_to_string(secure_boot_enroll_action e) _const_;
+DECLARE_STRING_TABLE_LOOKUP_TO_STRING(secure_boot_enroll, secure_boot_enroll);
+DECLARE_STRING_TABLE_LOOKUP_TO_STRING(secure_boot_enroll_action, secure_boot_enroll_action);
extern const UnitVTable automount_vtable;
-const char* automount_result_to_string(AutomountResult i) _const_;
-AutomountResult automount_result_from_string(const char *s) _pure_;
+DECLARE_STRING_TABLE_LOOKUP(automount_result, AutomountResult);
DEFINE_CAST(AUTOMOUNT, Automount);
void manager_invalidate_startup_units(Manager *m);
-const char* cgroup_device_policy_to_string(CGroupDevicePolicy i) _const_;
-CGroupDevicePolicy cgroup_device_policy_from_string(const char *s) _pure_;
+DECLARE_STRING_TABLE_LOOKUP(cgroup_device_policy, CGroupDevicePolicy);
void unit_cgroup_catchup(Unit *u);
int unit_cgroup_freezer_action(Unit *u, FreezerAction action);
-const char* freezer_action_to_string(FreezerAction a) _const_;
-FreezerAction freezer_action_from_string(const char *s) _pure_;
+DECLARE_STRING_TABLE_LOOKUP(freezer_action, FreezerAction);
CGroupRuntime* cgroup_runtime_new(void);
CGroupRuntime* cgroup_runtime_free(CGroupRuntime *crt);
int cgroup_runtime_serialize(Unit *u, FILE *f, FDSet *fds);
int cgroup_runtime_deserialize_one(Unit *u, const char *key, const char *value, FDSet *fds);
-const char* cgroup_pressure_watch_to_string(CGroupPressureWatch a) _const_;
-CGroupPressureWatch cgroup_pressure_watch_from_string(const char *s) _pure_;
+DECLARE_STRING_TABLE_LOOKUP(cgroup_pressure_watch, CGroupPressureWatch);
-const char* cgroup_device_permissions_to_string(CGroupDevicePermissions p) _const_;
-CGroupDevicePermissions cgroup_device_permissions_from_string(const char *s) _pure_;
+DECLARE_STRING_TABLE_LOOKUP(cgroup_device_permissions, CGroupDevicePermissions);
-const char* cgroup_ip_accounting_metric_to_string(CGroupIPAccountingMetric m) _const_;
-CGroupIPAccountingMetric cgroup_ip_accounting_metric_from_string(const char *s) _pure_;
+DECLARE_STRING_TABLE_LOOKUP(cgroup_ip_accounting_metric, CGroupIPAccountingMetric);
-const char* cgroup_io_accounting_metric_to_string(CGroupIOAccountingMetric m) _const_;
-CGroupIOAccountingMetric cgroup_io_accounting_metric_from_string(const char *s) _pure_;
+DECLARE_STRING_TABLE_LOOKUP(cgroup_io_accounting_metric, CGroupIOAccountingMetric);
-const char* cgroup_effective_limit_type_to_string(CGroupLimitType m) _const_;
-CGroupLimitType cgroup_effective_limit_type_from_string(const char *s) _pure_;
+DECLARE_STRING_TABLE_LOOKUP(cgroup_effective_limit_type, CGroupLimitType);
-const char* cgroup_memory_accounting_metric_to_string(CGroupMemoryAccountingMetric m) _const_;
-CGroupMemoryAccountingMetric cgroup_memory_accounting_metric_from_string(const char *s) _pure_;
+DECLARE_STRING_TABLE_LOOKUP(cgroup_memory_accounting_metric, CGroupMemoryAccountingMetric);
_CRASH_ACTION_INVALID = -EINVAL,
} CrashAction;
-const char* crash_action_to_string(CrashAction action);
-CrashAction crash_action_from_string(const char *s);
+DECLARE_STRING_TABLE_LOOKUP(crash_action, CrashAction);
_noreturn_ void freeze_or_exit_or_reboot(void);
void install_crash_handler(void);
int exit_status,
const char *reason);
-const char* emergency_action_to_string(EmergencyAction i) _const_;
-EmergencyAction emergency_action_from_string(const char *s) _pure_;
+DECLARE_STRING_TABLE_LOOKUP(emergency_action, EmergencyAction);
int parse_emergency_action(const char *value, RuntimeScope runtime_scope, EmergencyAction *ret);
void exec_directory_sort(ExecDirectory *d);
bool exec_directory_is_private(const ExecContext *context, ExecDirectoryType type);
-ExecCleanMask exec_clean_mask_from_string(const char *s);
+DECLARE_STRING_TABLE_LOOKUP_FROM_STRING(exec_clean_mask, ExecCleanMask);
-const char* exec_output_to_string(ExecOutput i) _const_;
-ExecOutput exec_output_from_string(const char *s) _pure_;
+DECLARE_STRING_TABLE_LOOKUP(exec_output, ExecOutput);
-const char* exec_input_to_string(ExecInput i) _const_;
-ExecInput exec_input_from_string(const char *s) _pure_;
+DECLARE_STRING_TABLE_LOOKUP(exec_input, ExecInput);
-const char* exec_utmp_mode_to_string(ExecUtmpMode i) _const_;
-ExecUtmpMode exec_utmp_mode_from_string(const char *s) _pure_;
+DECLARE_STRING_TABLE_LOOKUP(exec_utmp_mode, ExecUtmpMode);
-const char* exec_preserve_mode_to_string(ExecPreserveMode i) _const_;
-ExecPreserveMode exec_preserve_mode_from_string(const char *s) _pure_;
+DECLARE_STRING_TABLE_LOOKUP(exec_preserve_mode, ExecPreserveMode);
-const char* exec_keyring_mode_to_string(ExecKeyringMode i) _const_;
-ExecKeyringMode exec_keyring_mode_from_string(const char *s) _pure_;
+DECLARE_STRING_TABLE_LOOKUP(exec_keyring_mode, ExecKeyringMode);
-const char* exec_directory_type_symlink_to_string(ExecDirectoryType i) _const_;
-ExecDirectoryType exec_directory_type_symlink_from_string(const char *s) _pure_;
+DECLARE_STRING_TABLE_LOOKUP(exec_directory_type_symlink, ExecDirectoryType);
-const char* exec_directory_type_mode_to_string(ExecDirectoryType i) _const_;
-ExecDirectoryType exec_directory_type_mode_from_string(const char *s) _pure_;
+DECLARE_STRING_TABLE_LOOKUP(exec_directory_type_mode, ExecDirectoryType);
-const char* exec_resource_type_to_string(ExecDirectoryType i) _const_;
-ExecDirectoryType exec_resource_type_from_string(const char *s) _pure_;
+DECLARE_STRING_TABLE_LOOKUP(exec_resource_type, ExecDirectoryType);
bool exec_needs_mount_namespace(const ExecContext *context, const ExecParameters *params, const ExecRuntime *runtime);
bool exec_needs_network_namespace(const ExecContext *context);
int job_get_before(Job *j, Job*** ret);
int job_get_after(Job *j, Job*** ret);
-const char* job_type_to_string(JobType t) _const_;
-JobType job_type_from_string(const char *s) _pure_;
+DECLARE_STRING_TABLE_LOOKUP(job_type, JobType);
-const char* job_state_to_string(JobState t) _const_;
-JobState job_state_from_string(const char *s) _pure_;
+DECLARE_STRING_TABLE_LOOKUP(job_state, JobState);
-const char* job_result_to_string(JobResult t) _const_;
-JobResult job_result_from_string(const char *s) _pure_;
+DECLARE_STRING_TABLE_LOOKUP(job_result, JobResult);
const char* job_type_to_access_method(JobType t);
void kill_context_init(KillContext *c);
void kill_context_dump(KillContext *c, FILE *f, const char *prefix);
-const char* kill_mode_to_string(KillMode k) _const_;
-KillMode kill_mode_from_string(const char *s) _pure_;
+DECLARE_STRING_TABLE_LOOKUP(kill_mode, KillMode);
-const char* kill_whom_to_string(KillWhom k) _const_;
-KillWhom kill_whom_from_string(const char *s) _pure_;
+DECLARE_STRING_TABLE_LOOKUP(kill_whom, KillWhom);
static inline int restart_kill_signal(const KillContext *c) {
if (c->restart_kill_signal != 0)
const char* manager_get_confirm_spawn(Manager *m);
void manager_disable_confirm_spawn(void);
-const char* manager_state_to_string(ManagerState m) _const_;
-ManagerState manager_state_from_string(const char *s) _pure_;
+DECLARE_STRING_TABLE_LOOKUP(manager_state, ManagerState);
-const char* manager_objective_to_string(ManagerObjective m) _const_;
-ManagerObjective manager_objective_from_string(const char *s) _pure_;
+DECLARE_STRING_TABLE_LOOKUP(manager_objective, ManagerObjective);
-const char* manager_timestamp_to_string(ManagerTimestamp m) _const_;
-ManagerTimestamp manager_timestamp_from_string(const char *s) _pure_;
+DECLARE_STRING_TABLE_LOOKUP(manager_timestamp, ManagerTimestamp);
ManagerTimestamp manager_timestamp_initrd_mangle(ManagerTimestamp s);
usec_t manager_get_watchdog(Manager *m, WatchdogType t);
char* mount_get_options_escaped(const Mount *m);
const char* mount_get_fstype(const Mount *m);
-const char* mount_exec_command_to_string(MountExecCommand i) _const_;
-MountExecCommand mount_exec_command_from_string(const char *s) _pure_;
+DECLARE_STRING_TABLE_LOOKUP(mount_exec_command, MountExecCommand);
-const char* mount_result_to_string(MountResult i) _const_;
-MountResult mount_result_from_string(const char *s) _pure_;
+DECLARE_STRING_TABLE_LOOKUP(mount_result, MountResult);
DEFINE_CAST(MOUNT, Mount);
int setup_shareable_ns(int ns_storage_socket[static 2], unsigned long nsflag);
int open_shareable_ns_path(int netns_storage_socket[static 2], const char *path, unsigned long nsflag);
-const char* protect_home_to_string(ProtectHome p) _const_;
-ProtectHome protect_home_from_string(const char *s) _pure_;
+DECLARE_STRING_TABLE_LOOKUP(protect_home, ProtectHome);
-const char* protect_hostname_to_string(ProtectHostname p) _const_;
-ProtectHostname protect_hostname_from_string(const char *s) _pure_;
+DECLARE_STRING_TABLE_LOOKUP(protect_hostname, ProtectHostname);
-const char* protect_system_to_string(ProtectSystem p) _const_;
-ProtectSystem protect_system_from_string(const char *s) _pure_;
+DECLARE_STRING_TABLE_LOOKUP(protect_system, ProtectSystem);
-const char* protect_proc_to_string(ProtectProc i) _const_;
-ProtectProc protect_proc_from_string(const char *s) _pure_;
+DECLARE_STRING_TABLE_LOOKUP(protect_proc, ProtectProc);
-const char* proc_subset_to_string(ProcSubset i) _const_;
-ProcSubset proc_subset_from_string(const char *s) _pure_;
+DECLARE_STRING_TABLE_LOOKUP(proc_subset, ProcSubset);
-const char* private_bpf_to_string(PrivateBPF i) _const_;
-PrivateBPF private_bpf_from_string(const char *s) _pure_;
+DECLARE_STRING_TABLE_LOOKUP(private_bpf, PrivateBPF);
-const char* bpf_delegate_cmd_to_string(uint64_t u) _const_;
-uint64_t bpf_delegate_cmd_from_string(const char *s) _pure_;
+DECLARE_STRING_TABLE_LOOKUP(bpf_delegate_cmd, uint64_t);
-const char* bpf_delegate_map_type_to_string(uint64_t u) _const_;
-uint64_t bpf_delegate_map_type_from_string(const char *s) _pure_;
+DECLARE_STRING_TABLE_LOOKUP(bpf_delegate_map_type, uint64_t);
-const char* bpf_delegate_prog_type_to_string(uint64_t u) _const_;
-uint64_t bpf_delegate_prog_type_from_string(const char *s) _pure_;
+DECLARE_STRING_TABLE_LOOKUP(bpf_delegate_prog_type, uint64_t);
-const char* bpf_delegate_attach_type_to_string(uint64_t u) _const_;
-uint64_t bpf_delegate_attach_type_from_string(const char *s) _pure_;
+DECLARE_STRING_TABLE_LOOKUP(bpf_delegate_attach_type, uint64_t);
char* bpf_delegate_to_string(uint64_t u, const char * (*parser)(uint64_t) _const_);
int bpf_delegate_from_string(const char *s, uint64_t *ret, uint64_t (*parser)(const char *));
return bpf_delegate_to_string(u, bpf_delegate_attach_type_to_string);
}
-const char* private_tmp_to_string(PrivateTmp i) _const_;
-PrivateTmp private_tmp_from_string(const char *s) _pure_;
+DECLARE_STRING_TABLE_LOOKUP(private_tmp, PrivateTmp);
-const char* private_users_to_string(PrivateUsers i) _const_;
-PrivateUsers private_users_from_string(const char *s) _pure_;
+DECLARE_STRING_TABLE_LOOKUP(private_users, PrivateUsers);
-const char* protect_control_groups_to_string(ProtectControlGroups i) _const_;
-ProtectControlGroups protect_control_groups_from_string(const char *s) _pure_;
+DECLARE_STRING_TABLE_LOOKUP(protect_control_groups, ProtectControlGroups);
-const char* private_pids_to_string(PrivatePIDs i) _const_;
-PrivatePIDs private_pids_from_string(const char *s) _pure_;
+DECLARE_STRING_TABLE_LOOKUP(private_pids, PrivatePIDs);
void bind_mount_free_many(BindMount *b, size_t n);
int bind_mount_add(BindMount **b, size_t *n, const BindMount *item);
extern const UnitVTable path_vtable;
extern const ActivationDetailsVTable activation_details_path_vtable;
-const char* path_type_to_string(PathType i) _const_;
-PathType path_type_from_string(const char *s) _pure_;
+DECLARE_STRING_TABLE_LOOKUP(path_type, PathType);
-const char* path_result_to_string(PathResult i) _const_;
-PathResult path_result_from_string(const char *s) _pure_;
+DECLARE_STRING_TABLE_LOOKUP(path_result, PathResult);
DEFINE_CAST(PATH, Path);
DEFINE_ACTIVATION_DETAILS_CAST(ACTIVATION_DETAILS_PATH, ActivationDetailsPath, PATH);
int scope_abandon(Scope *s);
-const char* scope_result_to_string(ScopeResult i) _const_;
-ScopeResult scope_result_from_string(const char *s) _pure_;
+DECLARE_STRING_TABLE_LOOKUP(scope_result, ScopeResult);
DEFINE_CAST(SCOPE, Scope);
int service_determine_exec_selinux_label(Service *s, char **ret);
-const char* service_restart_to_string(ServiceRestart i) _const_;
-ServiceRestart service_restart_from_string(const char *s) _pure_;
+DECLARE_STRING_TABLE_LOOKUP(service_restart, ServiceRestart);
-const char* service_restart_mode_to_string(ServiceRestartMode i) _const_;
-ServiceRestartMode service_restart_mode_from_string(const char *s) _pure_;
+DECLARE_STRING_TABLE_LOOKUP(service_restart_mode, ServiceRestartMode);
-const char* service_type_to_string(ServiceType i) _const_;
-ServiceType service_type_from_string(const char *s) _pure_;
+DECLARE_STRING_TABLE_LOOKUP(service_type, ServiceType);
-const char* service_exit_type_to_string(ServiceExitType i) _const_;
-ServiceExitType service_exit_type_from_string(const char *s) _pure_;
+DECLARE_STRING_TABLE_LOOKUP(service_exit_type, ServiceExitType);
-const char* service_exec_command_to_string(ServiceExecCommand i) _const_;
-ServiceExecCommand service_exec_command_from_string(const char *s) _pure_;
+DECLARE_STRING_TABLE_LOOKUP(service_exec_command, ServiceExecCommand);
-const char* service_exec_ex_command_to_string(ServiceExecCommand i) _const_;
-ServiceExecCommand service_exec_ex_command_from_string(const char *s) _pure_;
+DECLARE_STRING_TABLE_LOOKUP(service_exec_ex_command, ServiceExecCommand);
-const char* notify_state_to_string(NotifyState i) _const_;
-NotifyState notify_state_from_string(const char *s) _pure_;
+DECLARE_STRING_TABLE_LOOKUP(notify_state, NotifyState);
-const char* service_result_to_string(ServiceResult i) _const_;
-ServiceResult service_result_from_string(const char *s) _pure_;
+DECLARE_STRING_TABLE_LOOKUP(service_result, ServiceResult);
-const char* service_timeout_failure_mode_to_string(ServiceTimeoutFailureMode i) _const_;
-ServiceTimeoutFailureMode service_timeout_failure_mode_from_string(const char *s) _pure_;
+DECLARE_STRING_TABLE_LOOKUP(service_timeout_failure_mode, ServiceTimeoutFailureMode);
DEFINE_CAST(SERVICE, Service);
static inline bool show_status_on(ShowStatus s) {
return IN_SET(s, SHOW_STATUS_TEMPORARY, SHOW_STATUS_YES);
}
-ShowStatus show_status_from_string(const char *s) _const_;
-const char* show_status_to_string(ShowStatus s) _pure_;
+DECLARE_STRING_TABLE_LOOKUP(show_status, ShowStatus);
int parse_show_status(const char *s, ShowStatus *ret);
-StatusUnitFormat status_unit_format_from_string(const char *s) _const_;
-const char* status_unit_format_to_string(StatusUnitFormat s) _pure_;
+DECLARE_STRING_TABLE_LOOKUP(status_unit_format, StatusUnitFormat);
int status_vprintf(const char *status, ShowStatusFlags flags, const char *format, va_list ap) _printf_(3,0);
int status_printf(const char *status, ShowStatusFlags flags, const char *format, ...) _printf_(3,4);
extern const UnitVTable socket_vtable;
-const char* socket_exec_command_to_string(SocketExecCommand i) _const_;
-SocketExecCommand socket_exec_command_from_string(const char *s) _pure_;
+DECLARE_STRING_TABLE_LOOKUP(socket_exec_command, SocketExecCommand);
-const char* socket_result_to_string(SocketResult i) _const_;
-SocketResult socket_result_from_string(const char *s) _pure_;
+DECLARE_STRING_TABLE_LOOKUP(socket_result, SocketResult);
const char* socket_port_type_to_string(SocketPort *p) _pure_;
SocketType socket_port_type_from_string(const char *s) _pure_;
-const char* socket_timestamping_to_string(SocketTimestamping p) _const_;
-SocketTimestamping socket_timestamping_from_string(const char *s) _pure_;
+DECLARE_STRING_TABLE_LOOKUP(socket_timestamping, SocketTimestamping);
SocketTimestamping socket_timestamping_from_string_harder(const char *s) _pure_;
-const char* socket_defer_trigger_to_string(SocketDeferTrigger i) _const_;
-SocketDeferTrigger socket_defer_trigger_from_string(const char *s) _pure_;
+DECLARE_STRING_TABLE_LOOKUP(socket_defer_trigger, SocketDeferTrigger);
DEFINE_CAST(SOCKET, Socket);
int swap_get_priority(const Swap *s);
const char* swap_get_options(const Swap *s);
-const char* swap_exec_command_to_string(SwapExecCommand i) _const_;
-SwapExecCommand swap_exec_command_from_string(const char *s) _pure_;
+DECLARE_STRING_TABLE_LOOKUP(swap_exec_command, SwapExecCommand);
-const char* swap_result_to_string(SwapResult i) _const_;
-SwapResult swap_result_from_string(const char *s) _pure_;
+DECLARE_STRING_TABLE_LOOKUP(swap_result, SwapResult);
DEFINE_CAST(SWAP, Swap);
extern const UnitVTable timer_vtable;
extern const ActivationDetailsVTable activation_details_timer_vtable;
-const char* timer_base_to_string(TimerBase i) _const_;
-TimerBase timer_base_from_string(const char *s) _pure_;
+DECLARE_STRING_TABLE_LOOKUP(timer_base, TimerBase);
char* timer_base_to_usec_string(TimerBase i);
-const char* timer_result_to_string(TimerResult i) _const_;
-TimerResult timer_result_from_string(const char *s) _pure_;
+DECLARE_STRING_TABLE_LOOKUP(timer_result, TimerResult);
DEFINE_CAST(TIMER, Timer);
DEFINE_ACTIVATION_DETAILS_CAST(ACTIVATION_DETAILS_TIMER, ActivationDetailsTimer, TIMER);
const char* unit_log_field(const Unit *u);
const char* unit_invocation_log_field(const Unit *u);
-UnitMountDependencyType unit_mount_dependency_type_from_string(const char *s) _const_;
-const char* unit_mount_dependency_type_to_string(UnitMountDependencyType t) _const_;
+DECLARE_STRING_TABLE_LOOKUP(unit_mount_dependency_type, UnitMountDependencyType);
UnitDependency unit_mount_dependency_type_to_dependency_type(UnitMountDependencyType t) _pure_;
-const char* oom_policy_to_string(OOMPolicy i) _const_;
-OOMPolicy oom_policy_from_string(const char *s) _pure_;
+DECLARE_STRING_TABLE_LOOKUP(oom_policy, OOMPolicy);
/* Macros which append UNIT= or USER_UNIT= to the message */
#define LOG_UNIT_ID(unit) LOG_ITEM("%s%s", unit_log_field((unit)), (unit)->id)
#define LOG_UNIT_INVOCATION_ID(unit) LOG_ITEM("%s%s", unit_invocation_log_field((unit)), (unit)->invocation_id_string)
-const char* collect_mode_to_string(CollectMode m) _const_;
-CollectMode collect_mode_from_string(const char *s) _pure_;
+DECLARE_STRING_TABLE_LOOKUP(collect_mode, CollectMode);
typedef struct UnitForEachDependencyData {
/* Stores state for the FOREACH macro below for iterating through all deps that have any of the
_WIPE_SCOPE_INVALID = -EINVAL,
} WipeScope;
-const char* enroll_type_to_string(EnrollType t);
-EnrollType enroll_type_from_string(const char *s);
-
-const char* luks2_token_type_to_string(EnrollType t);
-EnrollType luks2_token_type_from_string(const char *s);
+DECLARE_STRING_TABLE_LOOKUP(enroll_type, EnrollType);
+DECLARE_STRING_TABLE_LOOKUP(luks2_token_type, EnrollType);
--- /dev/null
+/* SPDX-License-Identifier: LGPL-2.1-or-later */
+#pragma once
+
+#include "macro-fundamental.h"
+
+#define DECLARE_STRING_TABLE_LOOKUP_TO_STRING(name, type) \
+ const char* name##_to_string(type i) _const_
+
+#define DECLARE_STRING_TABLE_LOOKUP_FROM_STRING(name, type) \
+ type name##_from_string(const char *s) _pure_
+
+#define DECLARE_STRING_TABLE_LOOKUP(name, type) \
+ DECLARE_STRING_TABLE_LOOKUP_TO_STRING(name, type); \
+ DECLARE_STRING_TABLE_LOOKUP_FROM_STRING(name, type)
+
+#define DECLARE_STRING_TABLE_LOOKUP_TO_STRING_FALLBACK(name, type) \
+ int name##_to_string_alloc(type i, char **ret)
+
+#define DECLARE_STRING_TABLE_LOOKUP_WITH_FALLBACK(name, type) \
+ DECLARE_STRING_TABLE_LOOKUP_TO_STRING_FALLBACK(name, type); \
+ DECLARE_STRING_TABLE_LOOKUP_FROM_STRING(name, type)
bool home_is_busy(Home *h);
-const char* home_state_to_string(HomeState state);
-HomeState home_state_from_string(const char *s);
+DECLARE_STRING_TABLE_LOOKUP(home_state, HomeState);
int import_compress(ImportCompress *c, const void *data, size_t size, void **buffer, size_t *buffer_size, size_t *buffer_allocated);
int import_compress_finish(ImportCompress *c, void **buffer, size_t *buffer_size, size_t *buffer_allocated);
-const char* import_compress_type_to_string(ImportCompressType t) _const_;
-ImportCompressType import_compress_type_from_string(const char *s) _pure_;
+DECLARE_STRING_TABLE_LOOKUP(import_compress_type, ImportCompressType);
/* Defined in generated journald-gperf.c */
const struct ConfigPerfItem* journald_gperf_lookup(const char *str, GPERF_LEN_TYPE length);
-const char* storage_to_string(Storage s) _const_;
-Storage storage_from_string(const char *s) _pure_;
+DECLARE_STRING_TABLE_LOOKUP(storage, Storage);
-const char* split_mode_to_string(SplitMode s) _const_;
-SplitMode split_mode_from_string(const char *s) _pure_;
+DECLARE_STRING_TABLE_LOOKUP(split_mode, SplitMode);
CONFIG_PARSER_PROTOTYPE(config_parse_storage);
CONFIG_PARSER_PROTOTYPE(config_parse_line_max);
_DHCP_STATE_INVALID = -EINVAL,
} DHCPState;
-const char* dhcp_state_to_string(DHCPState s) _const_;
+DECLARE_STRING_TABLE_LOOKUP_TO_STRING(dhcp_state, DHCPState);
typedef struct sd_dhcp_client sd_dhcp_client;
return size >= MIN_DUID_DATA_LEN && size <= MAX_DUID_DATA_LEN;
}
-const char* duid_type_to_string(DUIDType t) _const_;
+DECLARE_STRING_TABLE_LOOKUP_TO_STRING(duid_type, DUIDType);
int dhcp_duid_to_string_internal(uint16_t type, const void *data, size_t data_size, char **ret);
int dhcp_identifier_set_iaid(
DHCP6_FQDN_FLAG_N = 1 << 2,
} DHCP6FQDNFlag;
-const char* dhcp6_state_to_string(DHCP6State s) _const_;
-const char* dhcp6_message_type_to_string(DHCP6MessageType s) _const_;
-DHCP6MessageType dhcp6_message_type_from_string(const char *s) _pure_;
-const char* dhcp6_message_status_to_string(DHCP6Status s) _const_;
-DHCP6Status dhcp6_message_status_from_string(const char *s) _pure_;
+DECLARE_STRING_TABLE_LOOKUP_TO_STRING(dhcp6_state, DHCP6State);
+DECLARE_STRING_TABLE_LOOKUP(dhcp6_message_type, DHCP6MessageType);
+DECLARE_STRING_TABLE_LOOKUP(dhcp6_message_status, DHCP6Status);
int dhcp6_message_status_to_errno(DHCP6Status s);
struct ether_addr filter_address;
};
-const char* lldp_rx_event_to_string(sd_lldp_rx_event_t e) _const_;
-sd_lldp_rx_event_t lldp_rx_event_from_string(const char *s) _pure_;
+DECLARE_STRING_TABLE_LOOKUP(lldp_rx_event, sd_lldp_rx_event_t);
int lldp_rx_build_neighbors_json(sd_lldp_rx *lldp_rx, sd_json_variant **ret);
void *userdata;
} sd_ndisc;
-const char* ndisc_event_to_string(sd_ndisc_event_t e) _const_;
-sd_ndisc_event_t ndisc_event_from_string(const char *s) _pure_;
+DECLARE_STRING_TABLE_LOOKUP(ndisc_event, sd_ndisc_event_t);
#define log_ndisc_errno(ndisc, error, fmt, ...) \
log_interface_prefix_full_errno( \
int ndisc_router_parse(sd_ndisc *nd, sd_ndisc_router *rt);
int ndisc_router_flags_to_string(uint64_t flags, char **ret);
-const char* ndisc_router_preference_to_string(int s) _const_;
+DECLARE_STRING_TABLE_LOOKUP_TO_STRING(ndisc_router_preference, int);
int device_read_uevent_file(sd_device *device);
int device_set_action(sd_device *device, sd_device_action_t a);
-sd_device_action_t device_action_from_string(const char *s) _pure_;
-const char* device_action_to_string(sd_device_action_t a) _const_;
+DECLARE_STRING_TABLE_LOOKUP(device_action, sd_device_action_t);
#include "sd-forward.h"
-const char* audit_type_to_string(int type);
-int audit_type_from_string(const char *s);
+DECLARE_STRING_TABLE_LOOKUP(audit_type, int);
/* This is inspired by DNS TYPEnnn formatting */
#define audit_type_name_alloca(type) \
bool journal_field_valid(const char *p, size_t l, bool allow_protected);
-const char* journal_object_type_to_string(ObjectType type) _const_;
+DECLARE_STRING_TABLE_LOOKUP_TO_STRING(journal_object_type, ObjectType);
static inline Compression COMPRESSION_FROM_OBJECT(const Object *o) {
assert(o);
_LINK_ONLINE_STATE_INVALID = -EINVAL,
} LinkOnlineState;
-const char* link_operstate_to_string(LinkOperationalState s) _const_;
-LinkOperationalState link_operstate_from_string(const char *s) _pure_;
+DECLARE_STRING_TABLE_LOOKUP(link_operstate, LinkOperationalState);
-const char* link_carrier_state_to_string(LinkCarrierState s) _const_;
-LinkCarrierState link_carrier_state_from_string(const char *s) _pure_;
+DECLARE_STRING_TABLE_LOOKUP(link_carrier_state, LinkCarrierState);
-const char* link_required_address_family_to_string(AddressFamily s) _const_;
-AddressFamily link_required_address_family_from_string(const char *s) _pure_;
+DECLARE_STRING_TABLE_LOOKUP(link_required_address_family, AddressFamily);
-const char* link_address_state_to_string(LinkAddressState s) _const_;
-LinkAddressState link_address_state_from_string(const char *s) _pure_;
+DECLARE_STRING_TABLE_LOOKUP(link_address_state, LinkAddressState);
-const char* link_online_state_to_string(LinkOnlineState s) _const_;
-LinkOnlineState link_online_state_from_string(const char *s) _pure_;
+DECLARE_STRING_TABLE_LOOKUP(link_online_state, LinkOnlineState);
typedef struct LinkOperationalStateRange {
LinkOperationalState min;
bool is_edge,
const char *action_seat);
-const char* handle_action_verb_to_string(HandleAction h) _const_;
-
-const char* handle_action_to_string(HandleAction h) _const_;
-HandleAction handle_action_from_string(const char *s) _pure_;
+DECLARE_STRING_TABLE_LOOKUP_TO_STRING(handle_action_verb, HandleAction);
+DECLARE_STRING_TABLE_LOOKUP(handle_action, HandleAction);
const HandleActionData* handle_action_lookup(HandleAction action);
const char* inhibit_what_to_string(InhibitWhat w);
int inhibit_what_from_string(const char *s);
-const char* inhibit_mode_to_string(InhibitMode k);
-InhibitMode inhibit_mode_from_string(const char *s);
+DECLARE_STRING_TABLE_LOOKUP(inhibit_mode, InhibitMode);
SessionState session_get_state(Session *s);
-const char* session_state_to_string(SessionState t) _const_;
-SessionState session_state_from_string(const char *s) _pure_;
+DECLARE_STRING_TABLE_LOOKUP(session_state, SessionState);
-const char* session_type_to_string(SessionType t) _const_;
-SessionType session_type_from_string(const char *s) _pure_;
+DECLARE_STRING_TABLE_LOOKUP(session_type, SessionType);
-const char* session_class_to_string(SessionClass t) _const_;
-SessionClass session_class_from_string(const char *s) _pure_;
+DECLARE_STRING_TABLE_LOOKUP(session_class, SessionClass);
-const char* kill_whom_to_string(KillWhom k) _const_;
-KillWhom kill_whom_from_string(const char *s) _pure_;
+DECLARE_STRING_TABLE_LOOKUP(kill_whom, KillWhom);
-const char* tty_validity_to_string(TTYValidity t) _const_;
-TTYValidity tty_validity_from_string(const char *s) _pure_;
+DECLARE_STRING_TABLE_LOOKUP(tty_validity, TTYValidity);
void session_leave_vt(Session *s);
void user_elect_display(User *u);
void user_update_last_session_timer(User *u);
-const char* user_state_to_string(UserState s) _const_;
-UserState user_state_from_string(const char *s) _pure_;
+DECLARE_STRING_TABLE_LOOKUP(user_state, UserState);
-const char* user_gc_mode_to_string(UserGCMode m) _const_;
-UserGCMode user_gc_mode_from_string(const char *s) _pure_;
+DECLARE_STRING_TABLE_LOOKUP(user_gc_mode, UserGCMode);
CONFIG_PARSER_PROTOTYPE(config_parse_compat_user_tasks_max);
_IMAGE_CLEAN_POOL_INVALID = -EINVAL,
} ImageCleanPoolMode;
-ImageCleanPoolMode image_clean_pool_mode_from_string(const char *s) _pure_;
-const char* image_clean_pool_mode_to_string(ImageCleanPoolMode mode) _const_;
+DECLARE_STRING_TABLE_LOOKUP(image_clean_pool_mode, ImageCleanPoolMode);
int image_clean_pool_operation(Manager *manager, ImageCleanPoolMode mode, Operation **ret_operation);
int clean_pool_read_first_entry(FILE *file, int child_error, sd_bus_error *error);
MachineState machine_get_state(Machine *m);
-const char* machine_class_to_string(MachineClass t) _const_;
-MachineClass machine_class_from_string(const char *s) _pure_;
+DECLARE_STRING_TABLE_LOOKUP(machine_class, MachineClass);
-const char* machine_state_to_string(MachineState t) _const_;
-MachineState machine_state_from_string(const char *s) _pure_;
+DECLARE_STRING_TABLE_LOOKUP(machine_state, MachineState);
-const char* kill_whom_to_string(KillWhom k) _const_;
-KillWhom kill_whom_from_string(const char *s) _pure_;
+DECLARE_STRING_TABLE_LOOKUP(kill_whom, KillWhom);
int machine_openpt(Machine *m, int flags, char **ret_peer);
int machine_start_getty(Machine *m, const char *ptmx_name, sd_bus_error *error);
_ACQUIRE_METADATA_INVALID = -EINVAL,
} AcquireMetadata;
-AcquireMetadata acquire_metadata_from_string(const char *s) _pure_;
-const char* acquire_metadata_to_string(AcquireMetadata am) _const_;
+DECLARE_STRING_TABLE_LOOKUP(acquire_metadata, AcquireMetadata);
inline static bool should_acquire_metadata(AcquireMetadata am) {
return am == ACQUIRE_METADATA_YES || am == ACQUIRE_METADATA_GRACEFUL;
}
* Copyright © 2020 VMware, Inc. */
#pragma once
-#include "shared-forward.h"
#include "netdev.h"
+#include "shared-forward.h"
typedef enum BareUDPProtocol {
BARE_UDP_PROTOCOL_IPV4 = ETH_P_IP,
DEFINE_NETDEV_CAST(BAREUDP, BareUDP);
extern const NetDevVTable bare_udp_vtable;
-const char* bare_udp_protocol_to_string(BareUDPProtocol d) _const_;
-BareUDPProtocol bare_udp_protocol_from_string(const char *s) _pure_;
+DECLARE_STRING_TABLE_LOOKUP(bare_udp_protocol, BareUDPProtocol);
CONFIG_PARSER_PROTOTYPE(config_parse_bare_udp_iftype);
/* SPDX-License-Identifier: LGPL-2.1-or-later */
#pragma once
-#include "shared-forward.h"
#include "netdev.h"
+#include "shared-forward.h"
#define LINK_BRIDGE_PORT_PRIORITY_INVALID 128U
#define LINK_BRIDGE_PORT_PRIORITY_MAX 63U
DEFINE_NETDEV_CAST(BRIDGE, Bridge);
extern const NetDevVTable bridge_vtable;
-const char* multicast_router_to_string(MulticastRouter i) _const_;
-MulticastRouter multicast_router_from_string(const char *s) _pure_;
+DECLARE_STRING_TABLE_LOOKUP(multicast_router, MulticastRouter);
CONFIG_PARSER_PROTOTYPE(config_parse_multicast_router);
CONFIG_PARSER_PROTOTYPE(config_parse_bridge_igmp_version);
#include <linux/fou.h>
#include "in-addr-util.h"
-#include "shared-forward.h"
#include "netdev.h"
+#include "shared-forward.h"
typedef enum FooOverUDPEncapType {
NETDEV_FOO_OVER_UDP_ENCAP_UNSPEC = FOU_ENCAP_UNSPEC,
DEFINE_NETDEV_CAST(FOU, FouTunnel);
extern const NetDevVTable foutnl_vtable;
-const char* fou_encap_type_to_string(FooOverUDPEncapType d) _const_;
-FooOverUDPEncapType fou_encap_type_from_string(const char *s) _pure_;
+DECLARE_STRING_TABLE_LOOKUP(fou_encap_type, FooOverUDPEncapType);
CONFIG_PARSER_PROTOTYPE(config_parse_fou_encap_type);
CONFIG_PARSER_PROTOTYPE(config_parse_fou_tunnel_address);
#include <linux/if_link.h>
-#include "shared-forward.h"
#include "in-addr-util.h"
#include "netdev.h"
+#include "shared-forward.h"
#define GENEVE_VID_MAX (1u << 24) - 1
DEFINE_NETDEV_CAST(GENEVE, Geneve);
extern const NetDevVTable geneve_vtable;
-const char* geneve_df_to_string(GeneveDF d) _const_;
-GeneveDF geneve_df_from_string(const char *s) _pure_;
+DECLARE_STRING_TABLE_LOOKUP(geneve_df, GeneveDF);
CONFIG_PARSER_PROTOTYPE(config_parse_geneve_vni);
CONFIG_PARSER_PROTOTYPE(config_parse_geneve_address);
DEFINE_NETDEV_CAST(HSR, Hsr);
extern const NetDevVTable hsr_vtable;
-HsrProtocol hsr_protocol_from_string(const char *s) _pure_;
+DECLARE_STRING_TABLE_LOOKUP_FROM_STRING(hsr_protocol, HsrProtocol);
CONFIG_PARSER_PROTOTYPE(config_parse_hsr_protocol);
_NETDEV_LOCAL_ADDRESS_TYPE_INVALID = -EINVAL,
} NetDevLocalAddressType;
-const char* netdev_local_address_type_to_string(NetDevLocalAddressType t) _const_;
-NetDevLocalAddressType netdev_local_address_type_from_string(const char *s) _pure_;
+DECLARE_STRING_TABLE_LOOKUP(netdev_local_address_type, NetDevLocalAddressType);
int link_get_local_address(
Link *link,
bool netdev_needs_reconfigure(NetDev *netdev, NetDevLocalAddressType type);
int link_request_stacked_netdev(Link *link, NetDev *netdev);
-const char* netdev_kind_to_string(NetDevKind d) _const_;
-NetDevKind netdev_kind_from_string(const char *s) _pure_;
+DECLARE_STRING_TABLE_LOOKUP(netdev_kind, NetDevKind);
static inline NetDevCreateType netdev_get_create_type(NetDev *netdev) {
assert(netdev);
/* SPDX-License-Identifier: LGPL-2.1-or-later */
#pragma once
-#include "shared-forward.h"
#include "fou-tunnel.h"
#include "netdev.h"
#include "networkd-link.h"
+#include "shared-forward.h"
/* For IFLA_IPTUN_PROTO attribute */
typedef enum TunnelMode {
extern const NetDevVTable ip6tnl_vtable;
extern const NetDevVTable erspan_vtable;
-const char* tunnel_mode_to_string(TunnelMode d) _const_;
-TunnelMode tunnel_mode_from_string(const char *s) _pure_;
+DECLARE_STRING_TABLE_LOOKUP(tunnel_mode, TunnelMode);
CONFIG_PARSER_PROTOTYPE(config_parse_tunnel_mode);
CONFIG_PARSER_PROTOTYPE(config_parse_tunnel_local_address);
DEFINE_NETDEV_CAST(VXLAN, VxLan);
extern const NetDevVTable vxlan_vtable;
-const char* df_to_string(VxLanDF d) _const_;
-VxLanDF df_from_string(const char *s) _pure_;
+DECLARE_STRING_TABLE_LOOKUP(df, VxLanDF);
CONFIG_PARSER_PROTOTYPE(config_parse_vxlan_address);
CONFIG_PARSER_PROTOTYPE(config_parse_port_range);
int link_get_captive_portal(Link *link, const char **ret);
-const char* dhcp_option_data_type_to_string(DHCPOptionDataType d) _const_;
-DHCPOptionDataType dhcp_option_data_type_from_string(const char *s) _pure_;
+DECLARE_STRING_TABLE_LOOKUP(dhcp_option_data_type, DHCPOptionDataType);
CONFIG_PARSER_PROTOTYPE(config_parse_dhcp);
CONFIG_PARSER_PROTOTYPE(config_parse_dhcp_route_metric);
CONFIG_PARSER_PROTOTYPE(config_parse_dhcp6_mud_url);
CONFIG_PARSER_PROTOTYPE(config_parse_dhcp6_client_start_mode);
-const char* dhcp6_client_start_mode_to_string(DHCP6ClientStartMode i) _const_;
-DHCP6ClientStartMode dhcp6_client_start_mode_from_string(const char *s) _pure_;
+DECLARE_STRING_TABLE_LOOKUP(dhcp6_client_start_mode, DHCP6ClientStartMode);
bool link_get_use_dns(Link *link, NetworkConfigSource proto);
bool link_get_use_dnr(Link *link, NetworkConfigSource proto);
-const char* use_domains_to_string(UseDomains p) _const_;
-UseDomains use_domains_from_string(const char *s) _pure_;
+DECLARE_STRING_TABLE_LOOKUP(use_domains, UseDomains);
CONFIG_PARSER_PROTOTYPE(config_parse_domains);
CONFIG_PARSER_PROTOTYPE(config_parse_dns);
int link_set_ipv6ll_stable_secret(Link *link);
int link_set_ipv6ll_addrgen_mode(Link *link, IPv6LinkLocalAddressGenMode mode);
-const char* ipv6_link_local_address_gen_mode_to_string(IPv6LinkLocalAddressGenMode s) _const_;
-IPv6LinkLocalAddressGenMode ipv6_link_local_address_gen_mode_from_string(const char *s) _pure_;
+DECLARE_STRING_TABLE_LOOKUP(ipv6_link_local_address_gen_mode, IPv6LinkLocalAddressGenMode);
CONFIG_PARSER_PROTOTYPE(config_parse_ipv6_link_local_address_gen_mode);
int link_stop_engines(Link *link, bool may_keep_dynamic);
-const char* link_state_to_string(LinkState s) _const_;
-LinkState link_state_from_string(const char *s) _pure_;
+DECLARE_STRING_TABLE_LOOKUP(link_state, LinkState);
int link_request_stacked_netdevs(Link *link, NetDevLocalAddressType type);
int manager_udev_process_link(Manager *m, sd_device *device, sd_device_action_t action);
int manager_rtnl_process_link(sd_netlink *rtnl, sd_netlink_message *message, Manager *m);
-int link_flags_to_string_alloc(uint32_t flags, char **ret);
-const char* kernel_operstate_to_string(int t) _const_;
+DECLARE_STRING_TABLE_LOOKUP_TO_STRING_FALLBACK(link_flags, uint32_t);
+DECLARE_STRING_TABLE_LOOKUP_TO_STRING(kernel_operstate, int);
void link_required_operstate_for_online(Link *link, LinkOperationalStateRange *ret);
AddressFamily link_required_family_for_online(Link *link);
int link_lldp_rx_configure(Link *link);
-const char* lldp_mode_to_string(LLDPMode m) _const_;
-LLDPMode lldp_mode_from_string(const char *s) _pure_;
+DECLARE_STRING_TABLE_LOOKUP(lldp_mode, LLDPMode);
CONFIG_PARSER_PROTOTYPE(config_parse_lldp_mode);
const struct ConfigPerfItem* network_network_gperf_lookup(const char *str, GPERF_LEN_TYPE length);
-const char* keep_configuration_to_string(KeepConfiguration i) _const_;
-KeepConfiguration keep_configuration_from_string(const char *s) _pure_;
+DECLARE_STRING_TABLE_LOOKUP(keep_configuration, KeepConfiguration);
-const char* activation_policy_to_string(ActivationPolicy i) _const_;
-ActivationPolicy activation_policy_from_string(const char *s) _pure_;
+DECLARE_STRING_TABLE_LOOKUP(activation_policy, ActivationPolicy);
int manager_process_requests(Manager *manager);
int request_call_netlink_async(sd_netlink *nl, sd_netlink_message *m, Request *req);
-const char* request_type_to_string(RequestType t) _const_;
+DECLARE_STRING_TABLE_LOOKUP_TO_STRING(request_type, RequestType);
typedef struct RemoveRequest RemoveRequest;
typedef int (*remove_request_netlink_handler_t)(sd_netlink *nl, sd_netlink_message *m, RemoveRequest *req);
int link_request_radv(Link *link);
int link_drop_radv_config(Link *link, Network *network);
-const char* radv_prefix_delegation_to_string(RADVPrefixDelegation i) _const_;
-RADVPrefixDelegation radv_prefix_delegation_from_string(const char *s) _pure_;
+DECLARE_STRING_TABLE_LOOKUP(radv_prefix_delegation, RADVPrefixDelegation);
CONFIG_PARSER_PROTOTYPE(config_parse_router_prefix_delegation);
CONFIG_PARSER_PROTOTYPE(config_parse_router_lifetime);
const union in_addr_union *prefsrc, /* optional */
Address **ret);
-int route_type_from_string(const char *s) _pure_;
-const char* route_type_to_string(int t) _const_;
+DECLARE_STRING_TABLE_LOOKUP(route_type, int);
-int route_scope_from_string(const char *s);
-int route_scope_to_string_alloc(int t, char **ret);
+DECLARE_STRING_TABLE_LOOKUP_FROM_STRING(route_scope, int);
+DECLARE_STRING_TABLE_LOOKUP_TO_STRING_FALLBACK(route_scope, int);
-int route_protocol_from_string(const char *s);
-int route_protocol_to_string_alloc(int t, char **ret);
-int route_protocol_full_from_string(const char *s);
-int route_protocol_full_to_string_alloc(int t, char **ret);
+DECLARE_STRING_TABLE_LOOKUP_FROM_STRING(route_protocol, int);
+DECLARE_STRING_TABLE_LOOKUP_TO_STRING_FALLBACK(route_protocol, int);
+DECLARE_STRING_TABLE_LOOKUP_FROM_STRING(route_protocol_full, int);
+DECLARE_STRING_TABLE_LOOKUP_TO_STRING_FALLBACK(route_protocol_full, int);
-int route_flags_to_string_alloc(uint32_t flags, char **ret);
+DECLARE_STRING_TABLE_LOOKUP_TO_STRING_FALLBACK(route_flags, uint32_t);
int manager_get_route_table_from_string(const Manager *m, const char *s, uint32_t *ret);
int manager_get_route_table_to_string(const Manager *m, uint32_t table, bool append_num, char **ret);
struct fib_rule_port_range dport; /* FRA_DPORT_RANGE */
} RoutingPolicyRule;
-int fr_act_type_from_string(const char *s) _pure_;
-const char* fr_act_type_to_string(int t) _const_;
+DECLARE_STRING_TABLE_LOOKUP(fr_act_type, int);
DECLARE_TRIVIAL_REF_UNREF_FUNC(RoutingPolicyRule, routing_policy_rule);
int link_set_ipv6_mtu(Link *link, int log_level);
int link_set_ipv6_mtu_async(Link *link);
-const char* ipv6_privacy_extensions_to_string(IPv6PrivacyExtensions i) _const_;
-IPv6PrivacyExtensions ipv6_privacy_extensions_from_string(const char *s) _pure_;
+DECLARE_STRING_TABLE_LOOKUP(ipv6_privacy_extensions, IPv6PrivacyExtensions);
-const char* ip_reverse_path_filter_to_string(IPReversePathFilter i) _const_;
-IPReversePathFilter ip_reverse_path_filter_from_string(const char *s) _pure_;
+DECLARE_STRING_TABLE_LOOKUP(ip_reverse_path_filter, IPReversePathFilter);
CONFIG_PARSER_PROTOTYPE(config_parse_ipv6_privacy_extensions);
CONFIG_PARSER_PROTOTYPE(config_parse_ip_reverse_path_filter);
_IPV4_FORCE_IGMP_VERSION_INVALID = -EINVAL,
} IPv4ForceIgmpVersion;
-const char* ipv4_force_igmp_version_to_string(IPv4ForceIgmpVersion i) _const_;
-IPv4ForceIgmpVersion ipv4_force_igmp_version_from_string(const char *s) _pure_;
+DECLARE_STRING_TABLE_LOOKUP(ipv4_force_igmp_version, IPv4ForceIgmpVersion);
CONFIG_PARSER_PROTOTYPE(config_parse_ipv4_force_igmp_version);
CONFIG_PARSER_PROTOTYPE(config_parse_ip_masquerade);
CONFIG_PARSER_PROTOTYPE(config_parse_mud_url);
-const char* network_config_source_to_string(NetworkConfigSource s) _const_;
-NetworkConfigSource network_config_source_from_string(const char* s) _pure_;
+DECLARE_STRING_TABLE_LOOKUP(network_config_source, NetworkConfigSource);
-int network_config_state_to_string_alloc(NetworkConfigState s, char **ret);
+DECLARE_STRING_TABLE_LOOKUP_TO_STRING_FALLBACK(network_config_state, NetworkConfigState);
#define DEFINE_NETWORK_CONFIG_STATE_FUNCTIONS(type, name) \
static inline void name##_update_state( \
0); \
}
-const char* address_family_to_string(AddressFamily b) _const_;
-AddressFamily address_family_from_string(const char *s) _pure_;
+DECLARE_STRING_TABLE_LOOKUP(address_family, AddressFamily);
-AddressFamily link_local_address_family_from_string(const char *s) _pure_;
+DECLARE_STRING_TABLE_LOOKUP_FROM_STRING(link_local_address_family, AddressFamily);
-const char* routing_policy_rule_address_family_to_string(AddressFamily b) _const_;
-AddressFamily routing_policy_rule_address_family_from_string(const char *s) _pure_;
+DECLARE_STRING_TABLE_LOOKUP(routing_policy_rule_address_family, AddressFamily);
-const char* nexthop_address_family_to_string(AddressFamily b) _const_;
-AddressFamily nexthop_address_family_from_string(const char *s) _pure_;
+DECLARE_STRING_TABLE_LOOKUP(nexthop_address_family, AddressFamily);
-const char* duplicate_address_detection_address_family_to_string(AddressFamily b) _const_;
-AddressFamily duplicate_address_detection_address_family_from_string(const char *s) _pure_;
+DECLARE_STRING_TABLE_LOOKUP(duplicate_address_detection_address_family, AddressFamily);
-AddressFamily dhcp_deprecated_address_family_from_string(const char *s) _pure_;
+DECLARE_STRING_TABLE_LOOKUP_FROM_STRING(dhcp_deprecated_address_family, AddressFamily);
-const char* dhcp_lease_server_type_to_string(sd_dhcp_lease_server_type_t t) _const_;
-sd_dhcp_lease_server_type_t dhcp_lease_server_type_from_string(const char *s) _pure_;
+DECLARE_STRING_TABLE_LOOKUP(dhcp_lease_server_type, sd_dhcp_lease_server_type_t);
bool link_should_mark_config(Link *link, bool only_static, NetworkConfigSource source, uint8_t protocol);
#include "capability-util.h"
#include "conf-parser-forward.h"
#include "cpu-set-util.h"
-#include "shared-forward.h"
#include "rlimit-util.h"
#include "seccomp-util.h"
+#include "shared-forward.h"
#include "volatile-util.h"
typedef struct CustomMount CustomMount;
CONFIG_PARSER_PROTOTYPE(config_parse_bind_user);
CONFIG_PARSER_PROTOTYPE(config_parse_bind_user_shell);
-const char* resolv_conf_mode_to_string(ResolvConfMode a) _const_;
-ResolvConfMode resolv_conf_mode_from_string(const char *s) _pure_;
+DECLARE_STRING_TABLE_LOOKUP(resolv_conf_mode, ResolvConfMode);
-const char* timezone_mode_to_string(TimezoneMode a) _const_;
-TimezoneMode timezone_mode_from_string(const char *s) _pure_;
+DECLARE_STRING_TABLE_LOOKUP(timezone_mode, TimezoneMode);
-const char* console_mode_to_string(ConsoleMode m) _const_;
-ConsoleMode console_mode_from_string(const char *s) _pure_;
+DECLARE_STRING_TABLE_LOOKUP(console_mode, ConsoleMode);
-const char* user_namespace_ownership_to_string(UserNamespaceOwnership a) _const_;
-UserNamespaceOwnership user_namespace_ownership_from_string(const char *s) _pure_;
+DECLARE_STRING_TABLE_LOOKUP(user_namespace_ownership, UserNamespaceOwnership);
int parse_link_journal(const char *s, LinkJournal *ret_mode, bool *ret_try);
/* SPDX-License-Identifier: LGPL-2.1-or-later */
#pragma once
-#include "shared-forward.h"
#include "runtime-scope.h"
+#include "shared-forward.h"
#include "string-util.h"
typedef struct PortableMetadata {
void portable_changes_free(PortableChange *changes, size_t n_changes);
-const char* portable_change_type_to_string(int t) _const_;
-int portable_change_type_from_string(const char *s) _pure_;
+DECLARE_STRING_TABLE_LOOKUP(portable_change_type, int);
-const char* portable_state_to_string(PortableState t) _const_;
-PortableState portable_state_from_string(const char *s) _pure_;
+DECLARE_STRING_TABLE_LOOKUP(portable_state, PortableState);
int dnssec_test_positive_wildcard(DnsAnswer *a, const char *name, const char *source, const char *zone, bool *authenticated);
-const char* dnssec_result_to_string(DnssecResult m) _const_;
-DnssecResult dnssec_result_from_string(const char *s) _pure_;
+DECLARE_STRING_TABLE_LOOKUP(dnssec_result, DnssecResult);
-const char* dnssec_verdict_to_string(DnssecVerdict m) _const_;
-DnssecVerdict dnssec_verdict_from_string(const char *s) _pure_;
+DECLARE_STRING_TABLE_LOOKUP(dnssec_verdict, DnssecVerdict);
int dns_type_suitable_for_protocol(uint16_t type, DnsProtocol protocol);
int dns_question_types_suitable_for_protocol(DnsQuestion *q, DnsProtocol protocol);
-const char* dns_scope_origin_to_string(DnsScopeOrigin origin) _const_;
-DnsScopeOrigin dns_scope_origin_from_string(const char *s) _pure_;
+DECLARE_STRING_TABLE_LOOKUP(dns_scope_origin, DnsScopeOrigin);
_DNS_SERVER_TYPE_INVALID = -EINVAL,
} DnsServerType;
-const char* dns_server_type_to_string(DnsServerType i) _const_;
-DnsServerType dns_server_type_from_string(const char *s) _pure_;
+DECLARE_STRING_TABLE_LOOKUP(dns_server_type, DnsServerType);
typedef enum DnsServerFeatureLevel {
DNS_SERVER_FEATURE_LEVEL_TCP,
#define DNS_SERVER_FEATURE_LEVEL_IS_DNSSEC(x) ((x) >= DNS_SERVER_FEATURE_LEVEL_DO)
#define DNS_SERVER_FEATURE_LEVEL_IS_UDP(x) IN_SET(x, DNS_SERVER_FEATURE_LEVEL_UDP, DNS_SERVER_FEATURE_LEVEL_EDNS0, DNS_SERVER_FEATURE_LEVEL_DO)
-const char* dns_server_feature_level_to_string(DnsServerFeatureLevel i) _const_;
-DnsServerFeatureLevel dns_server_feature_level_from_string(const char *s) _pure_;
+DECLARE_STRING_TABLE_LOOKUP(dns_server_feature_level, DnsServerFeatureLevel);
typedef struct DnsServer {
Manager *manager;
void manager_dns_stub_stop(Manager *m);
int manager_dns_stub_start(Manager *m);
-const char* dns_stub_listener_mode_to_string(DnsStubListenerMode p) _const_;
-DnsStubListenerMode dns_stub_listener_mode_from_string(const char *s) _pure_;
+DECLARE_STRING_TABLE_LOOKUP(dns_stub_listener_mode, DnsStubListenerMode);
}
}
-const char* dns_transaction_state_to_string(DnsTransactionState p) _const_;
-DnsTransactionState dns_transaction_state_from_string(const char *s) _pure_;
+DECLARE_STRING_TABLE_LOOKUP(dns_transaction_state, DnsTransactionState);
-const char* dns_transaction_source_to_string(DnsTransactionSource p) _const_;
-DnsTransactionSource dns_transaction_source_from_string(const char *s) _pure_;
+DECLARE_STRING_TABLE_LOOKUP(dns_transaction_source, DnsTransactionSource);
int resolv_conf_mode(void);
-const char* resolv_conf_mode_to_string(ResolvConfMode m) _const_;
-ResolvConfMode resolv_conf_mode_from_string(const char *s) _pure_;
+DECLARE_STRING_TABLE_LOOKUP(resolv_conf_mode, ResolvConfMode);
_NETDEV_BOND_PRIMARY_RESELECT_INVALID = -EINVAL,
} BondPrimaryReselect;
-const char* bond_mode_to_string(BondMode d) _const_;
-BondMode bond_mode_from_string(const char *s) _pure_;
+DECLARE_STRING_TABLE_LOOKUP(bond_mode, BondMode);
-const char* bond_xmit_hash_policy_to_string(BondXmitHashPolicy d) _const_;
-BondXmitHashPolicy bond_xmit_hash_policy_from_string(const char *s) _pure_;
+DECLARE_STRING_TABLE_LOOKUP(bond_xmit_hash_policy, BondXmitHashPolicy);
-const char* bond_lacp_rate_to_string(BondLacpRate d) _const_;
-BondLacpRate bond_lacp_rate_from_string(const char *s) _pure_;
+DECLARE_STRING_TABLE_LOOKUP(bond_lacp_rate, BondLacpRate);
-const char* bond_fail_over_mac_to_string(BondFailOverMac d) _const_;
-BondFailOverMac bond_fail_over_mac_from_string(const char *s) _pure_;
+DECLARE_STRING_TABLE_LOOKUP(bond_fail_over_mac, BondFailOverMac);
-const char* bond_ad_select_to_string(BondAdSelect d) _const_;
-BondAdSelect bond_ad_select_from_string(const char *s) _pure_;
+DECLARE_STRING_TABLE_LOOKUP(bond_ad_select, BondAdSelect);
-const char* bond_arp_validate_to_string(BondArpValidate d) _const_;
-BondArpValidate bond_arp_validate_from_string(const char *s) _pure_;
+DECLARE_STRING_TABLE_LOOKUP(bond_arp_validate, BondArpValidate);
-const char* bond_arp_all_targets_to_string(BondArpAllTargets d) _const_;
-BondArpAllTargets bond_arp_all_targets_from_string(const char *s) _pure_;
+DECLARE_STRING_TABLE_LOOKUP(bond_arp_all_targets, BondArpAllTargets);
-const char* bond_primary_reselect_to_string(BondPrimaryReselect d) _const_;
-BondPrimaryReselect bond_primary_reselect_from_string(const char *s) _pure_;
+DECLARE_STRING_TABLE_LOOKUP(bond_primary_reselect, BondPrimaryReselect);
int parse_boot_entry_token_type(const char *s, BootEntryTokenType *type, char **token);
-const char* boot_entry_token_type_to_string(BootEntryTokenType t);
+DECLARE_STRING_TABLE_LOOKUP_TO_STRING(boot_entry_token_type, BootEntryTokenType);
.selected_entry = -1, \
}
-const char* boot_entry_type_description_to_string(BootEntryType) _const_;
-const char* boot_entry_type_to_string(BootEntryType) _const_;
-BootEntryType boot_entry_type_from_string(const char *s) _pure_;
+DECLARE_STRING_TABLE_LOOKUP_TO_STRING(boot_entry_type_description, BootEntryType);
+DECLARE_STRING_TABLE_LOOKUP(boot_entry_type, BootEntryType);
-const char* boot_entry_source_description_to_string(BootEntrySource) _const_;
-const char* boot_entry_source_to_string(BootEntrySource) _const_;
+DECLARE_STRING_TABLE_LOOKUP_TO_STRING(boot_entry_source_description, BootEntrySource);
+DECLARE_STRING_TABLE_LOOKUP_TO_STRING(boot_entry_source, BootEntrySource);
BootEntry* boot_config_find_entry(BootConfig *config, const char *id);
int bpf_map_update_element(int fd, const void *key, void *value);
int bpf_map_lookup_element(int fd, const void *key, void *value);
-int bpf_cgroup_attach_type_from_string(const char *str) _pure_;
-const char* bpf_cgroup_attach_type_to_string(int attach_type) _const_;
+DECLARE_STRING_TABLE_LOOKUP(bpf_cgroup_attach_type, int);
DEFINE_TRIVIAL_CLEANUP_FUNC(BPFProgram*, bpf_program_free);
_NETDEV_BRIDGE_STATE_INVALID = -EINVAL,
} BridgeState;
-const char* bridge_state_to_string(BridgeState d) _const_;
-BridgeState bridge_state_from_string(const char *s) _pure_;
+DECLARE_STRING_TABLE_LOOKUP(bridge_state, BridgeState);
_EXEC_DIRECTORY_FLAGS_INVALID = -EINVAL,
} ExecDirectoryFlags;
-ExecDirectoryFlags exec_directory_flags_from_string(const char *s) _pure_;
+DECLARE_STRING_TABLE_LOOKUP_FROM_STRING(exec_directory_flags, ExecDirectoryFlags);
typedef struct UnitInfo {
const char *machine;
int bus_get_instance_id(sd_bus *bus, sd_id128_t *ret);
-const char* bus_transport_to_string(BusTransport transport) _const_;
+DECLARE_STRING_TABLE_LOOKUP_TO_STRING(bus_transport, BusTransport);
void condition_dump(Condition *c, FILE *f, const char *prefix, condition_to_string_t to_string);
void condition_dump_list(Condition *first, FILE *f, const char *prefix, condition_to_string_t to_string);
-const char* condition_type_to_string(ConditionType t) _const_;
-ConditionType condition_type_from_string(const char *s) _pure_;
+DECLARE_STRING_TABLE_LOOKUP(condition_type, ConditionType);
void condition_types_list(void);
-const char* assert_type_to_string(ConditionType t) _const_;
-ConditionType assert_type_from_string(const char *s) _pure_;
+DECLARE_STRING_TABLE_LOOKUP(assert_type, ConditionType);
void assert_types_list(void);
-const char* condition_result_to_string(ConditionResult r) _const_;
-ConditionResult condition_result_from_string(const char *s) _pure_;
+DECLARE_STRING_TABLE_LOOKUP(condition_result, ConditionResult);
static inline bool condition_takes_path(ConditionType t) {
return IN_SET(t,
int set_dumpable(SuidDumpMode mode);
-const char* coredump_filter_to_string(CoredumpFilter i) _const_;
-CoredumpFilter coredump_filter_from_string(const char *s) _pure_;
+DECLARE_STRING_TABLE_LOOKUP(coredump_filter, CoredumpFilter);
int coredump_filter_mask_from_string(const char *s, uint64_t *ret);
int parse_auxv(int log_level,
int image_clone(Image *i, const char *new_name, bool read_only, RuntimeScope scope);
int image_read_only(Image *i, bool b, RuntimeScope scope);
-const char* image_type_to_string(ImageType t) _const_;
-ImageType image_type_from_string(const char *s) _pure_;
+DECLARE_STRING_TABLE_LOOKUP(image_type, ImageType);
int image_path_lock(RuntimeScope scope, const char *path, int operation, LockFile *global, LockFile *local);
int image_name_lock(RuntimeScope scope, const char *name, int operation, LockFile *ret);
_DNS_EDE_RCODE_INVALID = -EINVAL,
};
-const char* dns_rcode_to_string(int i) _const_;
-int dns_rcode_from_string(const char *s) _pure_;
+DECLARE_STRING_TABLE_LOOKUP(dns_rcode, int);
const char* format_dns_rcode(int i, char buf[static DECIMAL_STR_MAX(int)]);
#define FORMAT_DNS_RCODE(i) format_dns_rcode(i, (char [DECIMAL_STR_MAX(int)]) {})
-const char* dns_ede_rcode_to_string(int i) _const_;
+DECLARE_STRING_TABLE_LOOKUP_TO_STRING(dns_ede_rcode, int);
const char* format_dns_ede_rcode(int i, char buf[static DECIMAL_STR_MAX(int)]);
#define FORMAT_DNS_EDE_RCODE(i) format_dns_ede_rcode(i, (char [DECIMAL_STR_MAX(int)]) {})
-const char* dns_protocol_to_string(DnsProtocol p) _const_;
-DnsProtocol dns_protocol_from_string(const char *s) _pure_;
+DECLARE_STRING_TABLE_LOOKUP(dns_protocol, DnsProtocol);
#define LLMNR_MULTICAST_IPV4_ADDRESS ((struct in_addr) { .s_addr = htobe32(224U << 24 | 252U) })
#define LLMNR_MULTICAST_IPV6_ADDRESS ((struct in6_addr) { .s6_addr = { 0xFF, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x03 } })
DNS_SVC_PARAM_KEY_INVALID = 65535 /* RFC 9460 */
};
-const char* dns_svc_param_key_to_string(int i) _const_;
+DECLARE_STRING_TABLE_LOOKUP_TO_STRING(dns_svc_param_key, int);
const char* format_dns_svc_param_key(uint16_t i, char buf[static DECIMAL_STR_MAX(uint16_t)+3]);
#define FORMAT_DNS_SVC_PARAM_KEY(i) format_dns_svc_param_key(i, (char [DECIMAL_STR_MAX(uint16_t)+3]) {})
extern const struct hash_ops dns_resource_record_hash_ops;
extern const struct hash_ops dns_resource_record_hash_ops_by_key;
-int dnssec_algorithm_to_string_alloc(int i, char **ret);
-int dnssec_algorithm_from_string(const char *s) _pure_;
+DECLARE_STRING_TABLE_LOOKUP_WITH_FALLBACK(dnssec_algorithm, int);
-int dnssec_digest_to_string_alloc(int i, char **ret);
-int dnssec_digest_from_string(const char *s) _pure_;
+DECLARE_STRING_TABLE_LOOKUP_WITH_FALLBACK(dnssec_digest, int);
-int sshfp_algorithm_to_string_alloc(int i, char **ret);
-int sshfp_algorithm_from_string(const char *s) _pure_;
+DECLARE_STRING_TABLE_LOOKUP_WITH_FALLBACK(sshfp_algorithm, int);
-int sshfp_key_type_to_string_alloc(int i, char **ret);
-int sshfp_key_type_from_string(const char *s) _pure_;
+DECLARE_STRING_TABLE_LOOKUP_WITH_FALLBACK(sshfp_key_type, int);
int dns_json_dispatch_resource_key(const char *name, sd_json_variant *variant, sd_json_dispatch_flags_t flags, void *userdata);
bool dns_class_is_valid_rr(uint16_t class);
/* TYPE?? follows http://tools.ietf.org/html/rfc3597#section-5 */
-const char* dns_type_to_string(int type);
-int dns_type_from_string(const char *s);
+DECLARE_STRING_TABLE_LOOKUP(dns_type, int);
-const char* dns_class_to_string(uint16_t class);
-int dns_class_from_string(const char *s);
+DECLARE_STRING_TABLE_LOOKUP_TO_STRING(dns_class, uint16_t);
+DECLARE_STRING_TABLE_LOOKUP_FROM_STRING(dns_class, int);
/* https://tools.ietf.org/html/draft-ietf-dane-protocol-23#section-7.2 */
-const char* tlsa_cert_usage_to_string(uint8_t cert_usage);
+DECLARE_STRING_TABLE_LOOKUP_TO_STRING(tlsa_cert_usage, uint8_t);
/* https://tools.ietf.org/html/draft-ietf-dane-protocol-23#section-7.3 */
-const char* tlsa_selector_to_string(uint8_t selector);
+DECLARE_STRING_TABLE_LOOKUP_TO_STRING(tlsa_selector, uint8_t);
/* https://tools.ietf.org/html/draft-ietf-dane-protocol-23#section-7.4 */
-const char* tlsa_matching_type_to_string(uint8_t selector);
+DECLARE_STRING_TABLE_LOOKUP_TO_STRING(tlsa_matching_type, uint8_t);
/* https://tools.ietf.org/html/rfc6844#section-5.1 */
#define CAA_FLAG_CRITICAL (1u << 7)
usec_t tx_lpi_timer_usec,
uint32_t advertise);
-const char* duplex_to_string(Duplex d) _const_;
-Duplex duplex_from_string(const char *s) _pure_;
+DECLARE_STRING_TABLE_LOOKUP(duplex, Duplex);
-int wol_options_to_string_alloc(uint32_t opts, char **ret);
+DECLARE_STRING_TABLE_LOOKUP_TO_STRING_FALLBACK(wol_options, uint32_t);
-const char* port_to_string(NetDevPort port) _const_;
-NetDevPort port_from_string(const char *s) _pure_;
+DECLARE_STRING_TABLE_LOOKUP(port, NetDevPort);
-const char* mdi_to_string(int mdi) _const_;
+DECLARE_STRING_TABLE_LOOKUP_TO_STRING(mdi, int);
-const char* ethtool_link_mode_bit_to_string(enum ethtool_link_mode_bit_indices val) _const_;
-enum ethtool_link_mode_bit_indices ethtool_link_mode_bit_from_string(const char *str) _pure_;
+DECLARE_STRING_TABLE_LOOKUP(ethtool_link_mode_bit, enum ethtool_link_mode_bit_indices);
CONFIG_PARSER_PROTOTYPE(config_parse_duplex);
CONFIG_PARSER_PROTOTYPE(config_parse_wol);
int exec_command_flags_from_strv(char * const *ex_opts, ExecCommandFlags *ret);
int exec_command_flags_to_strv(ExecCommandFlags flags, char ***ret);
-const char* exec_command_flags_to_string(ExecCommandFlags i);
-ExecCommandFlags exec_command_flags_from_string(const char *s);
+DECLARE_STRING_TABLE_LOOKUP(exec_command_flags, ExecCommandFlags);
int fexecve_or_execve(int executable_fd, const char *executable, char *const argv[], char *const envp[]);
const char* exit_status_to_string(int code, ExitStatusClass class) _const_;
const char* exit_status_class(int code) _const_;
-int exit_status_from_string(const char *s) _pure_;
+DECLARE_STRING_TABLE_LOOKUP_FROM_STRING(exit_status, int);
typedef struct ExitStatusMapping {
const char *name;
FactoryResetMode factory_reset_mode(void);
-const char* factory_reset_mode_to_string(FactoryResetMode) _const_;
-FactoryResetMode factory_reset_mode_from_string(const char *s) _pure_;
+DECLARE_STRING_TABLE_LOOKUP(factory_reset_mode, FactoryResetMode);
void nft_set_context_clear(NFTSetContext *s);
int nft_set_context_dup(const NFTSetContext *src, NFTSetContext *dst);
-const char* nfproto_to_string(int i) _const_;
-int nfproto_from_string(const char *s) _pure_;
+DECLARE_STRING_TABLE_LOOKUP(nfproto, int);
-const char* nft_set_source_to_string(int i) _const_;
-int nft_set_source_from_string(const char *s) _pure_;
+DECLARE_STRING_TABLE_LOOKUP(nft_set_source, int);
int nft_set_element_modify_iprange(
sd_netlink *nfnl,
_NETDEV_GENEVE_DF_INVALID = -EINVAL,
} GeneveDF;
-const char* geneve_df_to_string(GeneveDF d) _const_;
-GeneveDF geneve_df_from_string(const char *s) _pure_;
+DECLARE_STRING_TABLE_LOOKUP(geneve_df, GeneveDF);
return partition_verity_to_data(d) >= 0;
}
-const char* partition_designator_to_string(PartitionDesignator d) _const_;
-PartitionDesignator partition_designator_from_string(const char *s) _pure_;
+DECLARE_STRING_TABLE_LOOKUP(partition_designator, PartitionDesignator);
-const char* partition_mountpoint_to_string(PartitionDesignator d) _const_;
+DECLARE_STRING_TABLE_LOOKUP_TO_STRING(partition_mountpoint, PartitionDesignator);
-const char* gpt_partition_type_uuid_to_string(sd_id128_t id) _const_;
+DECLARE_STRING_TABLE_LOOKUP_TO_STRING(gpt_partition_type_uuid, sd_id128_t);
const char* gpt_partition_type_uuid_to_string_harder(
sd_id128_t id,
char buffer[static SD_ID128_UUID_STRING_MAX]);
_HOSTNAME_INVALID = -EINVAL,
} HostnameSource;
-const char* hostname_source_to_string(HostnameSource source) _const_;
-HostnameSource hostname_source_from_string(const char *str) _pure_;
+DECLARE_STRING_TABLE_LOOKUP(hostname_source, HostnameSource);
int sethostname_idempotent(const char *s);
return import_url_change_suffix(url, 0, suffix, ret);
}
-const char* import_type_to_string(ImportType v) _const_;
-ImportType import_type_from_string(const char *s) _pure_;
+DECLARE_STRING_TABLE_LOOKUP(import_type, ImportType);
-const char* import_verify_to_string(ImportVerify v) _const_;
-ImportVerify import_verify_from_string(const char *s) _pure_;
+DECLARE_STRING_TABLE_LOOKUP(import_verify, ImportVerify);
int tar_strip_suffixes(const char *name, char **ret);
int raw_strip_suffixes(const char *name, char **ret);
/* SPDX-License-Identifier: LGPL-2.1-or-later */
#pragma once
-#include "shared-forward.h"
#include "runtime-scope.h"
+#include "shared-forward.h"
#include "unit-file.h"
typedef enum UnitFilePresetMode {
_PRESET_ACTION_ERRNO_MAX = -ERRNO_MAX, /* Ensure this type covers the whole negative errno range */
} PresetAction;
-const char* preset_action_past_tense_to_string(PresetAction action);
+DECLARE_STRING_TABLE_LOOKUP_TO_STRING(preset_action_past_tense, PresetAction);
void unit_file_presets_done(UnitFilePresets *p);
PresetAction unit_file_query_preset(RuntimeScope scope, const char *root_dir, const char *name, UnitFilePresets *cached);
-const char* unit_file_state_to_string(UnitFileState s) _const_;
-UnitFileState unit_file_state_from_string(const char *s) _pure_;
+DECLARE_STRING_TABLE_LOOKUP(unit_file_state, UnitFileState);
/* from_string conversion is unreliable because of the overlap between -EPERM and -1 for error. */
-const char* install_change_type_to_string(InstallChangeType t) _const_;
-InstallChangeType install_change_type_from_string(const char *s) _pure_;
+DECLARE_STRING_TABLE_LOOKUP(install_change_type, InstallChangeType);
-const char* unit_file_preset_mode_to_string(UnitFilePresetMode m) _const_;
-UnitFilePresetMode unit_file_preset_mode_from_string(const char *s) _pure_;
+DECLARE_STRING_TABLE_LOOKUP(unit_file_preset_mode, UnitFilePresetMode);
return IOPRIO_PRIO_VALUE_HINT(class, IOPRIO_PRIO_LEVEL(data), IOPRIO_PRIO_HINT(data));
}
-int ioprio_class_to_string_alloc(int i, char **ret);
-int ioprio_class_from_string(const char *s);
+DECLARE_STRING_TABLE_LOOKUP_WITH_FALLBACK(ioprio_class, int);
static inline bool ioprio_class_is_valid(int i) {
return IN_SET(i, IOPRIO_CLASS_NONE, IOPRIO_CLASS_RT, IOPRIO_CLASS_BE, IOPRIO_CLASS_IDLE);
_NETDEV_IPVLAN_FLAGS_INVALID = -EINVAL,
} IPVlanFlags;
-const char* ipvlan_mode_to_string(IPVlanMode d) _const_;
-IPVlanMode ipvlan_mode_from_string(const char *s) _pure_;
+DECLARE_STRING_TABLE_LOOKUP(ipvlan_mode, IPVlanMode);
-const char* ipvlan_flags_to_string(IPVlanFlags d) _const_;
-IPVlanFlags ipvlan_flags_from_string(const char *s) _pure_;
+DECLARE_STRING_TABLE_LOOKUP(ipvlan_flags, IPVlanFlags);
_KERNEL_IMAGE_TYPE_INVALID = -EINVAL,
} KernelImageType;
-const char* kernel_image_type_to_string(KernelImageType t) _const_;
+DECLARE_STRING_TABLE_LOOKUP_TO_STRING(kernel_image_type, KernelImageType);
int inspect_kernel(
int dir_fd,
_NETDEV_MACVLAN_MODE_INVALID = -EINVAL,
} MacVlanMode;
-const char* macvlan_mode_to_string(MacVlanMode d) _const_;
-MacVlanMode macvlan_mode_from_string(const char *s) _pure_;
+DECLARE_STRING_TABLE_LOOKUP(macvlan_mode, MacVlanMode);
_NAMEPOLICY_INVALID = -EINVAL,
} NamePolicy;
-const char* name_policy_to_string(NamePolicy p) _const_;
-NamePolicy name_policy_from_string(const char *s) _pure_;
+DECLARE_STRING_TABLE_LOOKUP(name_policy, NamePolicy);
-const char* alternative_names_policy_to_string(NamePolicy p) _const_;
-NamePolicy alternative_names_policy_from_string(const char *s) _pure_;
+DECLARE_STRING_TABLE_LOOKUP(alternative_names_policy, NamePolicy);
int device_get_sysattr_int_filtered(sd_device *device, const char *sysattr, int *ret_value);
int device_get_sysattr_unsigned_filtered(sd_device *device, const char *sysattr, unsigned *ret_value);
struct ether_addr mac;
} SRIOV;
-const char* sr_iov_attribute_to_string(SRIOVAttribute a) _const_;
+DECLARE_STRING_TABLE_LOOKUP_TO_STRING(sr_iov_attribute, SRIOVAttribute);
void sr_iov_hash_func(const SRIOV *sr_iov, struct siphash *state);
int sr_iov_compare_func(const SRIOV *s1, const SRIOV *s2);
int numa_mask_add_all(CPUSet *mask);
-const char* mpol_to_string(int i) _const_;
-int mpol_from_string(const char *s) _pure_;
+DECLARE_STRING_TABLE_LOOKUP(mpol, int);
LIST_CLEAR(open_files, *ASSERT_PTR(head), open_file_free);
}
-const char* open_file_flags_to_string(OpenFileFlag t) _const_;
-OpenFileFlag open_file_flags_from_string(const char *s) _pure_;
+DECLARE_STRING_TABLE_LOOKUP(open_file_flags, OpenFileFlag);
sd_json_format_flags_t output_mode_to_json_format_flags(OutputMode m);
-const char* output_mode_to_string(OutputMode m) _const_;
-OutputMode output_mode_from_string(const char *s) _pure_;
+DECLARE_STRING_TABLE_LOOKUP(output_mode, OutputMode);
CONFIG_PARSER_PROTOTYPE(config_parse_dns_over_tls_mode);
CONFIG_PARSER_PROTOTYPE(config_parse_dns_cache_mode);
-const char* resolve_support_to_string(ResolveSupport p) _const_;
-ResolveSupport resolve_support_from_string(const char *s) _pure_;
+DECLARE_STRING_TABLE_LOOKUP(resolve_support, ResolveSupport);
-const char* dnssec_mode_to_string(DnssecMode p) _const_;
-DnssecMode dnssec_mode_from_string(const char *s) _pure_;
+DECLARE_STRING_TABLE_LOOKUP(dnssec_mode, DnssecMode);
-const char* dns_over_tls_mode_to_string(DnsOverTlsMode p) _const_;
-DnsOverTlsMode dns_over_tls_mode_from_string(const char *s) _pure_;
+DECLARE_STRING_TABLE_LOOKUP(dns_over_tls_mode, DnsOverTlsMode);
bool dns_server_address_valid(int family, const union in_addr_union *sa);
-const char* dns_cache_mode_to_string(DnsCacheMode p) _const_;
-DnsCacheMode dns_cache_mode_from_string(const char *s) _pure_;
+DECLARE_STRING_TABLE_LOOKUP(dns_cache_mode, DnsCacheMode);
/* A resolv.conf file containing the DNS server and domain data we learnt from uplink, i.e. the full uplink data */
#define PRIVATE_UPLINK_RESOLV_CONF "/run/systemd/resolve/resolv.conf"
int dlopen_libseccomp(void);
-const char* seccomp_arch_to_string(uint32_t c);
+DECLARE_STRING_TABLE_LOOKUP_TO_STRING(seccomp_arch, uint32_t);
int seccomp_arch_from_string(const char *n, uint32_t *ret);
int seccomp_init_for_arch(scmp_filter_ctx *ret, uint32_t arch, uint32_t default_action);
bool seccomp_errno_or_action_is_valid(int n) _const_;
int seccomp_parse_errno_or_action(const char *p) _pure_;
-const char* seccomp_errno_or_action_to_string(int num) _const_;
+DECLARE_STRING_TABLE_LOOKUP_TO_STRING(seccomp_errno_or_action, int);
#include "shared-forward.h"
int secure_bits_to_strv(int i, char ***ret);
-int secure_bits_to_string_alloc(int i, char **ret);
-int secure_bits_from_string(const char *s);
+DECLARE_STRING_TABLE_LOOKUP_WITH_FALLBACK(secure_bits, int);
static inline bool secure_bits_is_valid(int i) {
return ((SECURE_ALL_BITS | SECURE_ALL_LOCKS) & i) == i;
_SLEEP_OPERATION_INVALID = -EINVAL,
} SleepOperation;
-const char* sleep_operation_to_string(SleepOperation s) _const_;
-SleepOperation sleep_operation_from_string(const char *s) _pure_;
+DECLARE_STRING_TABLE_LOOKUP(sleep_operation, SleepOperation);
static inline bool SLEEP_OPERATION_IS_HIBERNATION(SleepOperation operation) {
return IN_SET(operation, SLEEP_HIBERNATE, SLEEP_HYBRID_SLEEP);
_SOCKET_ADDRESS_BIND_IPV6_ONLY_INVALID = -EINVAL,
} SocketAddressBindIPv6Only;
-const char* socket_address_bind_ipv6_only_to_string(SocketAddressBindIPv6Only b) _const_;
-SocketAddressBindIPv6Only socket_address_bind_ipv6_only_from_string(const char *s) _pure_;
-SocketAddressBindIPv6Only socket_address_bind_ipv6_only_or_bool_from_string(const char *s) _pure_;
+DECLARE_STRING_TABLE_LOOKUP(socket_address_bind_ipv6_only, SocketAddressBindIPv6Only);
+DECLARE_STRING_TABLE_LOOKUP_FROM_STRING(socket_address_bind_ipv6_only_or_bool, SocketAddressBindIPv6Only);
int socket_address_listen(
const SocketAddress *a,
#define LOAD_OPTIONS_EVENT_TAG_ID UINT32_C(0x8F3B22ED)
#endif
-const char* tpm2_log_event_type_to_string(uint32_t type) _const_;
+DECLARE_STRING_TABLE_LOOKUP_TO_STRING(tpm2_log_event_type, uint32_t);
#if HAVE_TPM2
#pragma once
#include "bitfield.h"
-#include "shared-forward.h"
#include "openssl-util.h"
+#include "shared-forward.h"
typedef enum TPM2Flags {
TPM2_FLAGS_USE_PIN = 1 << 0,
_TPM2_USERSPACE_EVENT_TYPE_INVALID = -EINVAL,
} Tpm2UserspaceEventType;
-const char* tpm2_userspace_event_type_to_string(Tpm2UserspaceEventType type) _const_;
-Tpm2UserspaceEventType tpm2_userspace_event_type_from_string(const char *s) _pure_;
+DECLARE_STRING_TABLE_LOOKUP(tpm2_userspace_event_type, Tpm2UserspaceEventType);
int tpm2_pcr_extend_bytes(Tpm2Context *c, char **banks, unsigned pcr_index, const struct iovec *data, const struct iovec *secret, Tpm2UserspaceEventType event, const char *description);
int tpm2_nvpcr_get_index(const char *name, uint32_t *ret);
_TPM2_PCR_INDEX_INVALID = -EINVAL,
};
-int tpm2_pcr_index_from_string(const char *s) _pure_;
-const char* tpm2_pcr_index_to_string(int pcr) _const_;
+DECLARE_STRING_TABLE_LOOKUP(tpm2_pcr_index, int);
/* The first and last NV index handle that is not registered to any company, as per TCG's "Registry of
* Reserved TPM 2.0 Handles and Localities", section 2.2.2. */
int json_dispatch_dispositions_mask(const char *name, sd_json_variant *variant, sd_json_dispatch_flags_t flags, void *userdata);
-const char* user_storage_to_string(UserStorage t) _const_;
-UserStorage user_storage_from_string(const char *s) _pure_;
+DECLARE_STRING_TABLE_LOOKUP(user_storage, UserStorage);
-const char* user_disposition_to_string(UserDisposition t) _const_;
-UserDisposition user_disposition_from_string(const char *s) _pure_;
+DECLARE_STRING_TABLE_LOOKUP(user_disposition, UserDisposition);
-const char* auto_resize_mode_to_string(AutoResizeMode m) _const_;
-AutoResizeMode auto_resize_mode_from_string(const char *s) _pure_;
+DECLARE_STRING_TABLE_LOOKUP(auto_resize_mode, AutoResizeMode);
_VOLATILE_MODE_INVALID = -EINVAL,
} VolatileMode;
-VolatileMode volatile_mode_from_string(const char *s);
-const char* volatile_mode_to_string(VolatileMode m);
+DECLARE_STRING_TABLE_LOOKUP(volatile_mode, VolatileMode);
int query_volatile_mode(VolatileMode *ret);
int wifi_get_interface(sd_netlink *genl, int ifindex, enum nl80211_iftype *ret_iftype, char **ret_ssid);
int wifi_get_station(sd_netlink *genl, int ifindex, struct ether_addr *ret_bssid);
-const char* nl80211_iftype_to_string(enum nl80211_iftype iftype) _const_;
-enum nl80211_iftype nl80211_iftype_from_string(const char *s) _pure_;
-const char* nl80211_cmd_to_string(int cmd) _const_;
+DECLARE_STRING_TABLE_LOOKUP(nl80211_iftype, enum nl80211_iftype);
+DECLARE_STRING_TABLE_LOOKUP_TO_STRING(nl80211_cmd, int);
int resource_resolve_path(Resource *rr, const char *root, const char *relative_to_directory, const char *node);
-ResourceType resource_type_from_string(const char *s) _pure_;
-const char* resource_type_to_string(ResourceType t) _const_;
-
-PathRelativeTo path_relative_to_from_string(const char *s) _pure_;
-const char* path_relative_to_to_string(PathRelativeTo r) _const_;
+DECLARE_STRING_TABLE_LOOKUP(resource_type, ResourceType);
+DECLARE_STRING_TABLE_LOOKUP(path_relative_to, PathRelativeTo);
int link_get_config(LinkConfigContext *ctx, Link *link);
int link_apply_config(LinkConfigContext *ctx, Link *link);
-const char* mac_address_policy_to_string(MACAddressPolicy p) _const_;
-MACAddressPolicy mac_address_policy_from_string(const char *s) _pure_;
+DECLARE_STRING_TABLE_LOOKUP(mac_address_policy, MACAddressPolicy);
/* gperf lookup function */
const struct ConfigPerfItem* link_config_gperf_lookup(const char *str, GPERF_LEN_TYPE length);
int udev_rules_apply_to_event(UdevRules *rules, UdevEvent *event);
int udev_rules_apply_static_dev_perms(UdevRules *rules);
-ResolveNameTiming resolve_name_timing_from_string(const char *s) _pure_;
-const char* resolve_name_timing_to_string(ResolveNameTiming i) _const_;
+DECLARE_STRING_TABLE_LOOKUP(resolve_name_timing, ResolveNameTiming);
_SETTING_FORCE_ENUM_WIDTH = UINT64_MAX
} SettingsMask;
-const char* console_mode_to_string(ConsoleMode m) _const_;
-ConsoleMode console_mode_from_string(const char *s) _pure_;
+DECLARE_STRING_TABLE_LOOKUP(console_mode, ConsoleMode);
[NETWORK_STACK_NONE] = "none",
};
-const char* network_stack_to_string(NetworkStack type) _const_;
-NetworkStack network_stack_from_string(const char *s) _pure_;
+DECLARE_STRING_TABLE_LOOKUP(network_stack, NetworkStack);
int qemu_check_kvm_support(void);
int qemu_check_vsock_support(void);