1
0
mirror of https://github.com/systemd/systemd synced 2026-03-19 19:44:48 +01:00

Compare commits

..

No commits in common. "f29a0b3151abbdc9d6160bd84e2ee8d7fcaf6506" and "f5530c10b87c465db44dc1d562872bd31fa5f212" have entirely different histories.

197 changed files with 789 additions and 483 deletions

View File

@ -20,7 +20,7 @@ jobs:
- id: metadata - id: metadata
name: Gather Pull Request Metadata name: Gather Pull Request Metadata
uses: redhat-plumbers-in-action/gather-pull-request-metadata@b3dbc3f843e8343dbcb2af5bffba72c974d3a07a uses: redhat-plumbers-in-action/gather-pull-request-metadata@5da2967931dd7c4b9ccd22f49b045e2c1f05165b
- name: Upload Pull Request Metadata artifact - name: Upload Pull Request Metadata artifact
uses: actions/upload-artifact@5d5d22a31266ced268874388b861e4b58bb5c2f3 uses: actions/upload-artifact@5d5d22a31266ced268874388b861e4b58bb5c2f3

View File

@ -34,7 +34,7 @@ jobs:
if: github.event_name == 'pull_request' if: github.event_name == 'pull_request'
- name: Label PR based on policy in labeler.yml - name: Label PR based on policy in labeler.yml
uses: actions/labeler@634933edcd8ababfe52f92936142cc22ac488b1b uses: actions/labeler@8558fd74291d67161a8a78ce36a881fa63b766a9
if: startsWith(github.event_name, 'pull_request') && github.base_ref == 'main' && github.event.action != 'closed' if: startsWith(github.event_name, 'pull_request') && github.base_ref == 'main' && github.event.action != 'closed'
with: with:
repo-token: "${{ secrets.GITHUB_TOKEN }}" repo-token: "${{ secrets.GITHUB_TOKEN }}"

View File

@ -1,6 +1,5 @@
meson==1.10.0 \ meson==1.9.1 \
--hash=sha256:4b27aafce281e652dcb437b28007457411245d975c48b5db3a797d3e93ae1585 \ --hash=sha256:f824ab770c041a202f532f69e114c971918ed2daff7ea56583d80642564598d0
--hash=sha256:8071860c1f46a75ea34801490fd1c445c9d75147a65508cd3a10366a7006cc1c
ninja==1.11.1.4 \ ninja==1.11.1.4 \
--hash=sha256:055f386fb550c2c9d6157e45e20a84d29c47968876b9c5794ae2aec46f952306 \ --hash=sha256:055f386fb550c2c9d6157e45e20a84d29c47968876b9c5794ae2aec46f952306 \
--hash=sha256:096487995473320de7f65d622c3f1d16c3ad174797602218ca8c967f51ec38a0 \ --hash=sha256:096487995473320de7f65d622c3f1d16c3ad174797602218ca8c967f51ec38a0 \

View File

@ -41,9 +41,7 @@
# PROXIMITY_NEAR_LEVEL=<value> # PROXIMITY_NEAR_LEVEL=<value>
# #
# where <matrix> is a mount-matrix in the format specified in the IIO # where <matrix> is a mount-matrix in the format specified in the IIO
# subsystem[1]. The default, when unset, is the one defined by the ACPI # subsystem[1]. The default, when unset, is equivalent to:
# found in /sys/bus/iio/devices/iio\:deviceXXX/in_mount_matrix or, in
# absence of it, is equivalent to:
# ACCEL_MOUNT_MATRIX=1, 0, 0; 0, 1, 0; 0, 0, 1 # ACCEL_MOUNT_MATRIX=1, 0, 0; 0, 1, 0; 0, 0, 1
# eg. the identity matrix, # eg. the identity matrix,
# and <value> is an integer value above or equal to which an object is # and <value> is an integer value above or equal to which an object is
@ -762,11 +760,6 @@ sensor:modalias:acpi:BMA250E*:dmi:bvnLENOVO:*:pvrLenovoMIIX3-1030:*
sensor:modalias:acpi:SMO8500*:dmi:bvnLENOVO:*:pvrLenovoMIIX3-830:* sensor:modalias:acpi:SMO8500*:dmi:bvnLENOVO:*:pvrLenovoMIIX3-830:*
ACCEL_MOUNT_MATRIX=-1, 0, 0; 0, 1, 0; 0, 0, 1 ACCEL_MOUNT_MATRIX=-1, 0, 0; 0, 1, 0; 0, 0, 1
# IdeaPad D330-10IGM (both 81H3 and 81MD product names)
# ACPI in_mount_matrix is 0, -1, 0; 1, 0, 0; 0, 0, 1, but the correct one is identity matrix.
sensor:modalias:acpi:BOSC0200*:dmi:*:svnLENOVO:*:pvrLenovoideapadD330-10IGM:*
ACCEL_MOUNT_MATRIX=1, 0, 0; 0, 1, 0; 0, 0, 1
# IdeaPad Miix 300 # IdeaPad Miix 300
sensor:modalias:acpi:SMO8500*:dmi:bvnLENOVO:*:pvrMIIX300-*:* sensor:modalias:acpi:SMO8500*:dmi:bvnLENOVO:*:pvrMIIX300-*:*
ACCEL_MOUNT_MATRIX=0, -1, 0; -1, 0, 0; 0, 0, 1 ACCEL_MOUNT_MATRIX=0, -1, 0; -1, 0, 0; 0, 0, 1

View File

@ -19,4 +19,5 @@ int verify_prepare_filename(const char *filename, char **ret);
int verify_executable(Unit *u, const ExecCommand *exec, const char *root); 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); int verify_units(char **filenames, RuntimeScope scope, bool check_man, bool run_generators, RecursiveErrors recursive_errors, const char *root);
DECLARE_STRING_TABLE_LOOKUP(recursive_errors, RecursiveErrors); const char* recursive_errors_to_string(RecursiveErrors i) _const_;
RecursiveErrors recursive_errors_from_string(const char *s) _pure_;

View File

@ -13,7 +13,8 @@ typedef enum ColorMode {
_COLOR_MODE_INVALID = -EINVAL, _COLOR_MODE_INVALID = -EINVAL,
} ColorMode; } ColorMode;
DECLARE_STRING_TABLE_LOOKUP(color_mode, ColorMode); const char* color_mode_to_string(ColorMode m) _const_;
ColorMode color_mode_from_string(const char *s) _pure_;
ColorMode get_color_mode(void); ColorMode get_color_mode(void);
static inline bool colors_enabled(void) { static inline bool colors_enabled(void) {

View File

@ -242,4 +242,5 @@ Architecture uname_architecture(void);
# error "Please register your architecture here!" # error "Please register your architecture here!"
#endif #endif
DECLARE_STRING_TABLE_LOOKUP(architecture, Architecture); const char* architecture_to_string(Architecture a) _const_;
Architecture architecture_from_string(const char *s) _pure_;

View File

@ -17,7 +17,6 @@
#include "assert-util.h" /* IWYU pragma: export */ #include "assert-util.h" /* IWYU pragma: export */
#include "cleanup-util.h" /* IWYU pragma: export */ #include "cleanup-util.h" /* IWYU pragma: export */
#include "macro.h" /* IWYU pragma: export */ #include "macro.h" /* IWYU pragma: export */
#include "string-table-fundamental.h" /* IWYU pragma: export */
/* Generic types */ /* Generic types */

View File

@ -95,7 +95,8 @@ typedef enum CGroupIOLimitType {
extern const uint64_t cgroup_io_limit_defaults[_CGROUP_IO_LIMIT_TYPE_MAX]; extern const uint64_t cgroup_io_limit_defaults[_CGROUP_IO_LIMIT_TYPE_MAX];
DECLARE_STRING_TABLE_LOOKUP(cgroup_io_limit_type, CGroupIOLimitType); const char* cgroup_io_limit_type_to_string(CGroupIOLimitType t) _const_;
CGroupIOLimitType cgroup_io_limit_type_from_string(const char *s) _pure_;
void cgroup_io_limits_list(void); void cgroup_io_limits_list(void);
/* Special values for the io.bfq.weight attribute */ /* Special values for the io.bfq.weight attribute */
@ -242,7 +243,8 @@ int cg_mask_to_string(CGroupMask mask, char **ret);
bool cg_kill_supported(void); bool cg_kill_supported(void);
DECLARE_STRING_TABLE_LOOKUP(cgroup_controller, CGroupController); const char* cgroup_controller_to_string(CGroupController c) _const_;
CGroupController cgroup_controller_from_string(const char *s) _pure_;
typedef enum ManagedOOMMode { typedef enum ManagedOOMMode {
MANAGED_OOM_AUTO, MANAGED_OOM_AUTO,
@ -251,7 +253,8 @@ typedef enum ManagedOOMMode {
_MANAGED_OOM_MODE_INVALID = -EINVAL, _MANAGED_OOM_MODE_INVALID = -EINVAL,
} ManagedOOMMode; } ManagedOOMMode;
DECLARE_STRING_TABLE_LOOKUP(managed_oom_mode, ManagedOOMMode); const char* managed_oom_mode_to_string(ManagedOOMMode m) _const_;
ManagedOOMMode managed_oom_mode_from_string(const char *s) _pure_;
typedef enum ManagedOOMPreference { typedef enum ManagedOOMPreference {
MANAGED_OOM_PREFERENCE_NONE = 0, MANAGED_OOM_PREFERENCE_NONE = 0,
@ -261,4 +264,5 @@ typedef enum ManagedOOMPreference {
_MANAGED_OOM_PREFERENCE_INVALID = -EINVAL, _MANAGED_OOM_PREFERENCE_INVALID = -EINVAL,
} ManagedOOMPreference; } ManagedOOMPreference;
DECLARE_STRING_TABLE_LOOKUP(managed_oom_preference, ManagedOOMPreference); const char* managed_oom_preference_to_string(ManagedOOMPreference a) _const_;
ManagedOOMPreference managed_oom_preference_from_string(const char *s) _pure_;

View File

@ -74,16 +74,6 @@ typedef void* (*mfree_func_t)(void *p);
DEFINE_TRIVIAL_REF_FUNC(type, name); \ DEFINE_TRIVIAL_REF_FUNC(type, name); \
DEFINE_TRIVIAL_UNREF_FUNC(type, name, free_func); DEFINE_TRIVIAL_UNREF_FUNC(type, name, free_func);
#define DECLARE_TRIVIAL_REF_FUNC(type, name) \
type* name##_ref(type *p)
#define DECLARE_TRIVIAL_UNREF_FUNC(type, name) \
type* name##_unref(type *p)
#define DECLARE_TRIVIAL_REF_UNREF_FUNC(type, name) \
DECLARE_TRIVIAL_REF_FUNC(type, name); \
DECLARE_TRIVIAL_UNREF_FUNC(type, name)
#define DEFINE_PRIVATE_TRIVIAL_REF_UNREF_FUNC(type, name, free_func) \ #define DEFINE_PRIVATE_TRIVIAL_REF_UNREF_FUNC(type, name, free_func) \
DEFINE_PRIVATE_TRIVIAL_REF_FUNC(type, name); \ DEFINE_PRIVATE_TRIVIAL_REF_FUNC(type, name); \
DEFINE_PRIVATE_TRIVIAL_UNREF_FUNC(type, name, free_func); DEFINE_PRIVATE_TRIVIAL_UNREF_FUNC(type, name, free_func);

View File

@ -12,8 +12,10 @@ typedef enum Compression {
_COMPRESSION_INVALID = -EINVAL, _COMPRESSION_INVALID = -EINVAL,
} Compression; } Compression;
DECLARE_STRING_TABLE_LOOKUP(compression, Compression); const char* compression_to_string(Compression compression) _const_;
DECLARE_STRING_TABLE_LOOKUP(compression_lowercase, Compression); 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_;
bool compression_supported(Compression c); bool compression_supported(Compression c);

View File

@ -20,4 +20,5 @@ typedef enum ConfidentialVirtualization {
ConfidentialVirtualization detect_confidential_virtualization(void); ConfidentialVirtualization detect_confidential_virtualization(void);
DECLARE_STRING_TABLE_LOOKUP(confidential_virtualization, ConfidentialVirtualization); const char* confidential_virtualization_to_string(ConfidentialVirtualization v) _const_;
ConfidentialVirtualization confidential_virtualization_from_string(const char *s) _pure_;

View File

@ -36,7 +36,8 @@ int locale_is_installed(const char *name);
bool is_locale_utf8(void); bool is_locale_utf8(void);
DECLARE_STRING_TABLE_LOOKUP(locale_variable, LocaleVariable); const char* locale_variable_to_string(LocaleVariable i) _const_;
LocaleVariable locale_variable_from_string(const char *s) _pure_;
static inline void freelocalep(locale_t *p) { static inline void freelocalep(locale_t *p) {
if (*p == (locale_t) 0) if (*p == (locale_t) 0)

View File

@ -57,7 +57,8 @@ LogContext* log_context_new_iov(struct iovec *input_iovec, size_t n_input_iovec,
LogContext* log_context_new_strv_consume(char **fields); LogContext* log_context_new_strv_consume(char **fields);
LogContext* log_context_new_iov_consume(struct iovec *input_iovec, size_t n_input_iovec); LogContext* log_context_new_iov_consume(struct iovec *input_iovec, size_t n_input_iovec);
DECLARE_TRIVIAL_REF_UNREF_FUNC(LogContext, log_context); LogContext *log_context_ref(LogContext *c);
LogContext *log_context_unref(LogContext *c);
DEFINE_TRIVIAL_CLEANUP_FUNC(LogContext*, log_context_unref); DEFINE_TRIVIAL_CLEANUP_FUNC(LogContext*, log_context_unref);

View File

@ -40,7 +40,8 @@ static inline void clear_log_syntax_callback(dummy_t *dummy) {
set_log_syntax_callback(/* cb= */ NULL, /* userdata= */ NULL); set_log_syntax_callback(/* cb= */ NULL, /* userdata= */ NULL);
} }
DECLARE_STRING_TABLE_LOOKUP(log_target, LogTarget); const char* log_target_to_string(LogTarget target) _const_;
LogTarget log_target_from_string(const char *s) _pure_;
void log_set_target(LogTarget target); void log_set_target(LogTarget target);
void log_set_target_and_open(LogTarget target); void log_set_target_and_open(LogTarget target);
int log_set_target_from_string(const char *e); int log_set_target_from_string(const char *e);

View File

@ -14,7 +14,8 @@ typedef enum ImageClass {
_IMAGE_CLASS_INVALID = -EINVAL, _IMAGE_CLASS_INVALID = -EINVAL,
} ImageClass; } ImageClass;
DECLARE_STRING_TABLE_LOOKUP(image_class, ImageClass); const char* image_class_to_string(ImageClass cl) _const_;
ImageClass image_class_from_string(const char *s) _pure_;
/* The *_extension_release flavours will look for /usr/lib/extension-release/extension-release.NAME /* 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 * for sysext images and for /etc/extension-release.d/extension-release.NAME for confext images

View File

@ -107,8 +107,11 @@ const char* personality_to_string(unsigned long);
int safe_personality(unsigned long p); int safe_personality(unsigned long p);
int opinionated_personality(unsigned long *ret); int opinionated_personality(unsigned long *ret);
DECLARE_STRING_TABLE_LOOKUP(sigchld_code, int); const char* sigchld_code_to_string(int i) _const_;
DECLARE_STRING_TABLE_LOOKUP_WITH_FALLBACK(sched_policy, int); 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);
static inline pid_t PTR_TO_PID(const void *p) { static inline pid_t PTR_TO_PID(const void *p) {
return (pid_t) ((uintptr_t) p); return (pid_t) ((uintptr_t) p);

View File

@ -7,7 +7,8 @@
#define _RLIMIT_MAX RLIMIT_NLIMITS #define _RLIMIT_MAX RLIMIT_NLIMITS
DECLARE_STRING_TABLE_LOOKUP(rlimit, int); const char* rlimit_to_string(int i) _const_;
int rlimit_from_string(const char *s) _pure_;
int rlimit_from_string_harder(const char *s) _pure_; int rlimit_from_string_harder(const char *s) _pure_;
void rlimits_list(const char *prefix); void rlimits_list(const char *prefix);

View File

@ -11,8 +11,10 @@ typedef enum RuntimeScope {
_RUNTIME_SCOPE_INVALID = -EINVAL, _RUNTIME_SCOPE_INVALID = -EINVAL,
} RuntimeScope; } RuntimeScope;
DECLARE_STRING_TABLE_LOOKUP(runtime_scope, RuntimeScope); const char* runtime_scope_to_string(RuntimeScope scope) _const_;
DECLARE_STRING_TABLE_LOOKUP_TO_STRING(runtime_scope_cmdline_option, RuntimeScope); RuntimeScope runtime_scope_from_string(const char *s) _const_;
const char* runtime_scope_cmdline_option_to_string(RuntimeScope scope) _const_;
static inline mode_t runtime_scope_to_socket_mode(RuntimeScope scope) { 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 /* Returns the right socket mode to use for binding AF_UNIX sockets intended for the specified

View File

@ -31,7 +31,8 @@ int sigset_add_many_internal(sigset_t *ss, ...);
int sigprocmask_many_internal(int how, sigset_t *ret_old_mask, ...); int sigprocmask_many_internal(int how, sigset_t *ret_old_mask, ...);
#define sigprocmask_many(...) sigprocmask_many_internal(__VA_ARGS__, -1) #define sigprocmask_many(...) sigprocmask_many_internal(__VA_ARGS__, -1)
DECLARE_STRING_TABLE_LOOKUP(signal, int); const char* signal_to_string(int signo) _const_;
int signal_from_string(const char *s) _pure_;
void nop_signal_handler(int sig); void nop_signal_handler(int sig);

View File

@ -55,7 +55,8 @@ typedef struct SocketAddress {
#define socket_address_family(a) ((a)->sockaddr.sa.sa_family) #define socket_address_family(a) ((a)->sockaddr.sa.sa_family)
DECLARE_STRING_TABLE_LOOKUP(socket_address_type, int); const char* socket_address_type_to_string(int t) _const_;
int socket_address_type_from_string(const char *s) _pure_;
int sockaddr_un_unlink(const struct sockaddr_un *sa); int sockaddr_un_unlink(const struct sockaddr_un *sa);
@ -86,7 +87,8 @@ int getsockname_pretty(int fd, char **ret);
int socknameinfo_pretty(const struct sockaddr *sa, socklen_t salen, char **_ret); int socknameinfo_pretty(const struct sockaddr *sa, socklen_t salen, char **_ret);
DECLARE_STRING_TABLE_LOOKUP_WITH_FALLBACK(netlink_family, int); int netlink_family_to_string_alloc(int i, char **ret);
int netlink_family_from_string(const char *s) _pure_;
bool sockaddr_equal(const union sockaddr_union *a, const union sockaddr_union *b); bool sockaddr_equal(const union sockaddr_union *a, const union sockaddr_union *b);
@ -99,7 +101,8 @@ static inline int fd_increase_rxbuf(int fd, size_t n) {
return fd_set_rcvbuf(fd, n, true); return fd_set_rcvbuf(fd, n, true);
} }
DECLARE_STRING_TABLE_LOOKUP_WITH_FALLBACK(ip_tos, int); int ip_tos_to_string_alloc(int i, char **ret);
int ip_tos_from_string(const char *s);
typedef enum { typedef enum {
IFNAME_VALID_ALTERNATIVE = 1 << 0, /* Allow "altnames" too */ IFNAME_VALID_ALTERNATIVE = 1 << 0, /* Allow "altnames" too */

View File

@ -97,7 +97,8 @@ void inode_hash_func(const struct stat *q, struct siphash *state);
int inode_compare_func(const struct stat *a, const struct stat *b); int inode_compare_func(const struct stat *a, const struct stat *b);
extern const struct hash_ops inode_hash_ops; extern const struct hash_ops inode_hash_ops;
DECLARE_STRING_TABLE_LOOKUP(inode_type, mode_t); const char* inode_type_to_string(mode_t m) _const_;
mode_t inode_type_from_string(const char *s) _pure_;
/* Macros that check whether the stat/statx structures have been initialized already. For "struct stat" we /* 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 * use a check for .st_dev being non-zero, since the kernel unconditionally fills that in, mapping the file

View File

@ -3,10 +3,12 @@
#include "basic-forward.h" #include "basic-forward.h"
DECLARE_STRING_TABLE_LOOKUP_WITH_FALLBACK(log_facility_unshifted, int); int log_facility_unshifted_to_string_alloc(int i, char **ret);
int log_facility_unshifted_from_string(const char *s);
bool log_facility_unshifted_is_valid(int faciliy); bool log_facility_unshifted_is_valid(int faciliy);
DECLARE_STRING_TABLE_LOOKUP_WITH_FALLBACK(log_level, int); int log_level_to_string_alloc(int i, char **ret);
int log_level_from_string(const char *s);
bool log_level_is_valid(int level); bool log_level_is_valid(int level);
int syslog_parse_priority(const char **p, int *priority, bool with_facility); int syslog_parse_priority(const char **p, int *priority, bool with_facility);

View File

@ -232,4 +232,5 @@ int usleep_safe(usec_t usec);
int time_change_fd(void); int time_change_fd(void);
DECLARE_STRING_TABLE_LOOKUP(timestamp_style, TimestampStyle); const char* timestamp_style_to_string(TimestampStyle t) _const_;
TimestampStyle timestamp_style_from_string(const char *s) _pure_;

View File

@ -313,47 +313,67 @@ int unit_name_from_dbus_path(const char *path, char **name);
const char* unit_dbus_interface_from_type(UnitType t); const char* unit_dbus_interface_from_type(UnitType t);
const char* unit_dbus_interface_from_name(const char *name); const char* unit_dbus_interface_from_name(const char *name);
DECLARE_STRING_TABLE_LOOKUP(unit_type, UnitType); const char* unit_type_to_string(UnitType i) _const_;
UnitType unit_type_from_string(const char *s) _pure_;
void unit_types_list(void); void unit_types_list(void);
DECLARE_STRING_TABLE_LOOKUP(unit_load_state, UnitLoadState); 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_active_state, UnitActiveState); const char* unit_active_state_to_string(UnitActiveState i) _const_;
UnitActiveState unit_active_state_from_string(const char *s) _pure_;
DECLARE_STRING_TABLE_LOOKUP(freezer_state, FreezerState); const char* freezer_state_to_string(FreezerState i) _const_;
FreezerState freezer_state_from_string(const char *s) _pure_;
FreezerState freezer_state_finish(FreezerState state) _const_; FreezerState freezer_state_finish(FreezerState state) _const_;
FreezerState freezer_state_objective(FreezerState state) _const_; FreezerState freezer_state_objective(FreezerState state) _const_;
DECLARE_STRING_TABLE_LOOKUP(unit_marker, UnitMarker); const char* unit_marker_to_string(UnitMarker m) _const_;
UnitMarker unit_marker_from_string(const char *s) _pure_;
DECLARE_STRING_TABLE_LOOKUP(automount_state, AutomountState); const char* automount_state_to_string(AutomountState i) _const_;
AutomountState automount_state_from_string(const char *s) _pure_;
DECLARE_STRING_TABLE_LOOKUP(device_state, DeviceState); const char* device_state_to_string(DeviceState i) _const_;
DeviceState device_state_from_string(const char *s) _pure_;
DECLARE_STRING_TABLE_LOOKUP(mount_state, MountState); const char* mount_state_to_string(MountState i) _const_;
MountState mount_state_from_string(const char *s) _pure_;
DECLARE_STRING_TABLE_LOOKUP(path_state, PathState); const char* path_state_to_string(PathState i) _const_;
PathState path_state_from_string(const char *s) _pure_;
DECLARE_STRING_TABLE_LOOKUP(scope_state, ScopeState); const char* scope_state_to_string(ScopeState i) _const_;
ScopeState scope_state_from_string(const char *s) _pure_;
DECLARE_STRING_TABLE_LOOKUP(service_state, ServiceState); const char* service_state_to_string(ServiceState i) _const_;
ServiceState service_state_from_string(const char *s) _pure_;
DECLARE_STRING_TABLE_LOOKUP(slice_state, SliceState); const char* slice_state_to_string(SliceState i) _const_;
SliceState slice_state_from_string(const char *s) _pure_;
DECLARE_STRING_TABLE_LOOKUP(socket_state, SocketState); const char* socket_state_to_string(SocketState i) _const_;
SocketState socket_state_from_string(const char *s) _pure_;
DECLARE_STRING_TABLE_LOOKUP(swap_state, SwapState); const char* swap_state_to_string(SwapState i) _const_;
SwapState swap_state_from_string(const char *s) _pure_;
DECLARE_STRING_TABLE_LOOKUP(target_state, TargetState); const char* target_state_to_string(TargetState i) _const_;
TargetState target_state_from_string(const char *s) _pure_;
DECLARE_STRING_TABLE_LOOKUP(timer_state, TimerState); const char* timer_state_to_string(TimerState i) _const_;
TimerState timer_state_from_string(const char *s) _pure_;
DECLARE_STRING_TABLE_LOOKUP(unit_dependency, UnitDependency); const char* unit_dependency_to_string(UnitDependency i) _const_;
UnitDependency unit_dependency_from_string(const char *s) _pure_;
DECLARE_STRING_TABLE_LOOKUP(notify_access, NotifyAccess); const char* notify_access_to_string(NotifyAccess i) _const_;
NotifyAccess notify_access_from_string(const char *s) _pure_;
DECLARE_STRING_TABLE_LOOKUP(job_mode, JobMode); const char* job_mode_to_string(JobMode t) _const_;
JobMode job_mode_from_string(const char *s) _pure_;
DECLARE_STRING_TABLE_LOOKUP(exec_directory_type, ExecDirectoryType); const char* exec_directory_type_to_string(ExecDirectoryType i) _const_;
ExecDirectoryType exec_directory_type_from_string(const char *s) _pure_;
Glyph unit_active_state_to_glyph(UnitActiveState state); Glyph unit_active_state_to_glyph(UnitActiveState state);

View File

@ -62,5 +62,6 @@ Virtualization detect_virtualization(void);
int running_in_userns(void); int running_in_userns(void);
int running_in_chroot(void); int running_in_chroot(void);
DECLARE_STRING_TABLE_LOOKUP(virtualization, Virtualization); const char* virtualization_to_string(Virtualization v) _const_;
Virtualization virtualization_from_string(const char *s) _pure_;
bool has_cpu_with_flag(const char *flag); bool has_cpu_with_flag(const char *flag);

View File

@ -34,7 +34,8 @@ typedef enum LogLevel {
_LOG_INVALID = -1, _LOG_INVALID = -1,
} LogLevel; } LogLevel;
DECLARE_STRING_TABLE_LOOKUP(log_level, LogLevel); LogLevel log_level_from_string(const char *s) _pure_;
const char* log_level_to_string(LogLevel l) _const_;
LogLevel log_get_max_level(void) _pure_; LogLevel log_get_max_level(void) _pure_;
int log_set_max_level(LogLevel level); int log_set_max_level(LogLevel level);

View File

@ -13,7 +13,6 @@
#include "cleanup-fundamental.h" /* IWYU pragma: export */ #include "cleanup-fundamental.h" /* IWYU pragma: export */
#include "efi-fundamental.h" /* IWYU pragma: export */ #include "efi-fundamental.h" /* IWYU pragma: export */
#include "macro-fundamental.h" /* IWYU pragma: export */ #include "macro-fundamental.h" /* IWYU pragma: export */
#include "string-table-fundamental.h" /* IWYU pragma: export */
#if SD_BOOT #if SD_BOOT
/* uchar.h/wchar.h are not suitable for freestanding environments. */ /* uchar.h/wchar.h are not suitable for freestanding environments. */

View File

@ -41,5 +41,5 @@ void install_security_override(security_validator_t validator, const void *valid
void uninstall_security_override(void); void uninstall_security_override(void);
bool security_override_available(void); bool security_override_available(void);
DECLARE_STRING_TABLE_LOOKUP_TO_STRING(secure_boot_enroll, secure_boot_enroll); const char* secure_boot_enroll_to_string(secure_boot_enroll e) _const_;
DECLARE_STRING_TABLE_LOOKUP_TO_STRING(secure_boot_enroll_action, secure_boot_enroll_action); const char* secure_boot_enroll_action_to_string(secure_boot_enroll_action e) _const_;

View File

@ -38,6 +38,7 @@ typedef struct Automount {
extern const UnitVTable automount_vtable; extern const UnitVTable automount_vtable;
DECLARE_STRING_TABLE_LOOKUP(automount_result, AutomountResult); const char* automount_result_to_string(AutomountResult i) _const_;
AutomountResult automount_result_from_string(const char *s) _pure_;
DEFINE_CAST(AUTOMOUNT, Automount); DEFINE_CAST(AUTOMOUNT, Automount);

View File

@ -450,7 +450,8 @@ void unit_invalidate_cgroup_bpf_firewall(Unit *u);
void manager_invalidate_startup_units(Manager *m); void manager_invalidate_startup_units(Manager *m);
DECLARE_STRING_TABLE_LOOKUP(cgroup_device_policy, CGroupDevicePolicy); const char* cgroup_device_policy_to_string(CGroupDevicePolicy i) _const_;
CGroupDevicePolicy cgroup_device_policy_from_string(const char *s) _pure_;
void unit_cgroup_catchup(Unit *u); void unit_cgroup_catchup(Unit *u);
@ -460,7 +461,8 @@ int unit_get_cpuset(Unit *u, CPUSet *cpus, const char *name);
int unit_cgroup_freezer_action(Unit *u, FreezerAction action); int unit_cgroup_freezer_action(Unit *u, FreezerAction action);
DECLARE_STRING_TABLE_LOOKUP(freezer_action, FreezerAction); const char* freezer_action_to_string(FreezerAction a) _const_;
FreezerAction freezer_action_from_string(const char *s) _pure_;
CGroupRuntime* cgroup_runtime_new(void); CGroupRuntime* cgroup_runtime_new(void);
CGroupRuntime* cgroup_runtime_free(CGroupRuntime *crt); CGroupRuntime* cgroup_runtime_free(CGroupRuntime *crt);
@ -469,14 +471,20 @@ DEFINE_TRIVIAL_CLEANUP_FUNC(CGroupRuntime*, cgroup_runtime_free);
int cgroup_runtime_serialize(Unit *u, FILE *f, FDSet *fds); 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); int cgroup_runtime_deserialize_one(Unit *u, const char *key, const char *value, FDSet *fds);
DECLARE_STRING_TABLE_LOOKUP(cgroup_pressure_watch, CGroupPressureWatch); 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_device_permissions, CGroupDevicePermissions); 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_ip_accounting_metric, CGroupIPAccountingMetric); 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_io_accounting_metric, CGroupIOAccountingMetric); 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_effective_limit_type, CGroupLimitType); 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_memory_accounting_metric, CGroupMemoryAccountingMetric); const char* cgroup_memory_accounting_metric_to_string(CGroupMemoryAccountingMetric m) _const_;
CGroupMemoryAccountingMetric cgroup_memory_accounting_metric_from_string(const char *s) _pure_;

View File

@ -11,7 +11,8 @@ typedef enum CrashAction {
_CRASH_ACTION_INVALID = -EINVAL, _CRASH_ACTION_INVALID = -EINVAL,
} CrashAction; } CrashAction;
DECLARE_STRING_TABLE_LOOKUP(crash_action, CrashAction); const char* crash_action_to_string(CrashAction action);
CrashAction crash_action_from_string(const char *s);
_noreturn_ void freeze_or_exit_or_reboot(void); _noreturn_ void freeze_or_exit_or_reboot(void);
void install_crash_handler(void); void install_crash_handler(void);

View File

@ -145,6 +145,44 @@ static int dynamic_user_acquire(Manager *m, const char *name, DynamicUser** ret)
return 1; return 1;
} }
static int make_uid_symlinks(uid_t uid, const char *name, bool b) {
char path1[STRLEN("/run/systemd/dynamic-uid/direct:") + DECIMAL_STR_MAX(uid_t) + 1];
const char *path2;
int r = 0, k;
/* Add direct additional symlinks for direct lookups of dynamic UIDs and their names by userspace code. The
* only reason we have this is because dbus-daemon cannot use D-Bus for resolving users and groups (since it
* would be its own client then). We hence keep these world-readable symlinks in place, so that the
* unprivileged dbus user can read the mappings when it needs them via these symlinks instead of having to go
* via the bus. Ideally, we'd use the lock files we keep for this anyway, but we can't since we use BSD locks
* on them and as those may be taken by any user with read access we can't make them world-readable. */
xsprintf(path1, "/run/systemd/dynamic-uid/direct:" UID_FMT, uid);
if (unlink(path1) < 0 && errno != ENOENT)
r = -errno;
if (b && symlink(name, path1) < 0) {
k = log_warning_errno(errno, "Failed to symlink \"%s\": %m", path1);
if (r == 0)
r = k;
}
path2 = strjoina("/run/systemd/dynamic-uid/direct:", name);
if (unlink(path2) < 0 && errno != ENOENT) {
k = -errno;
if (r == 0)
r = k;
}
if (b && symlink(path1 + STRLEN("/run/systemd/dynamic-uid/direct:"), path2) < 0) {
k = log_warning_errno(errno, "Failed to symlink \"%s\": %m", path2);
if (r == 0)
r = k;
}
return r;
}
static int pick_uid(char **suggested_paths, const char *name, uid_t *ret_uid) { static int pick_uid(char **suggested_paths, const char *name, uid_t *ret_uid) {
/* Find a suitable free UID. We use the following strategy to find a suitable UID: /* Find a suitable free UID. We use the following strategy to find a suitable UID:
@ -277,6 +315,7 @@ static int pick_uid(char **suggested_paths, const char *name, uid_t *ret_uid) {
} }
(void) ftruncate(lock_fd, l); (void) ftruncate(lock_fd, l);
(void) make_uid_symlinks(candidate, name, true); /* also add direct lookup symlinks */
*ret_uid = candidate; *ret_uid = candidate;
return TAKE_FD(lock_fd); return TAKE_FD(lock_fd);
@ -320,7 +359,7 @@ static int dynamic_user_push(DynamicUser *d, uid_t uid, int lock_fd) {
return send_one_fd_iov(d->storage_socket[1], lock_fd, &iov, 1, MSG_DONTWAIT); return send_one_fd_iov(d->storage_socket[1], lock_fd, &iov, 1, MSG_DONTWAIT);
} }
static void unlink_uid_lock(int lock_fd, uid_t uid) { static void unlink_uid_lock(int lock_fd, uid_t uid, const char *name) {
char lock_path[STRLEN("/run/systemd/dynamic-uid/") + DECIMAL_STR_MAX(uid_t) + 1]; char lock_path[STRLEN("/run/systemd/dynamic-uid/") + DECIMAL_STR_MAX(uid_t) + 1];
if (lock_fd < 0) if (lock_fd < 0)
@ -328,6 +367,8 @@ static void unlink_uid_lock(int lock_fd, uid_t uid) {
xsprintf(lock_path, "/run/systemd/dynamic-uid/" UID_FMT, uid); xsprintf(lock_path, "/run/systemd/dynamic-uid/" UID_FMT, uid);
(void) unlink(lock_path); (void) unlink(lock_path);
(void) make_uid_symlinks(uid, name, false); /* remove direct lookup symlinks */
} }
static int dynamic_user_realize( static int dynamic_user_realize(
@ -415,7 +456,7 @@ static int dynamic_user_realize(
/* So, we found a working UID/lock combination. Let's see if we actually still need it. */ /* So, we found a working UID/lock combination. Let's see if we actually still need it. */
r = posix_lock(d->storage_socket[0], LOCK_EX); r = posix_lock(d->storage_socket[0], LOCK_EX);
if (r < 0) { if (r < 0) {
unlink_uid_lock(uid_lock_fd, num); unlink_uid_lock(uid_lock_fd, num, d->name);
return r; return r;
} }
@ -423,14 +464,14 @@ static int dynamic_user_realize(
if (r < 0) { if (r < 0) {
if (r != -EAGAIN) { if (r != -EAGAIN) {
/* OK, something bad happened, let's get rid of the bits we acquired. */ /* OK, something bad happened, let's get rid of the bits we acquired. */
unlink_uid_lock(uid_lock_fd, num); unlink_uid_lock(uid_lock_fd, num, d->name);
return r; return r;
} }
} else { } else {
/* Hmm, so as it appears there's now something stored in the storage socket. /* Hmm, so as it appears there's now something stored in the storage socket.
* Throw away what we acquired, and use what's stored now. */ * Throw away what we acquired, and use what's stored now. */
unlink_uid_lock(uid_lock_fd, num); unlink_uid_lock(uid_lock_fd, num, d->name);
safe_close(uid_lock_fd); safe_close(uid_lock_fd);
num = new_uid; num = new_uid;
@ -529,7 +570,7 @@ static int dynamic_user_close(DynamicUser *d) {
return r; return r;
/* This dynamic user was realized and dynamically allocated. In this case, let's remove the lock file. */ /* This dynamic user was realized and dynamically allocated. In this case, let's remove the lock file. */
unlink_uid_lock(lock_fd, uid); unlink_uid_lock(lock_fd, uid, d->name);
return 1; return 1;
} }

View File

@ -44,4 +44,4 @@ void dynamic_creds_close(DynamicCreds *creds);
DEFINE_TRIVIAL_CLEANUP_FUNC(DynamicCreds*, dynamic_creds_unref); DEFINE_TRIVIAL_CLEANUP_FUNC(DynamicCreds*, dynamic_creds_unref);
DEFINE_TRIVIAL_CLEANUP_FUNC(DynamicCreds*, dynamic_creds_destroy); DEFINE_TRIVIAL_CLEANUP_FUNC(DynamicCreds*, dynamic_creds_destroy);
DECLARE_TRIVIAL_REF_FUNC(DynamicUser, dynamic_user); DynamicUser *dynamic_user_ref(DynamicUser *user);

View File

@ -40,6 +40,7 @@ void emergency_action(
int exit_status, int exit_status,
const char *reason); const char *reason);
DECLARE_STRING_TABLE_LOOKUP(emergency_action, EmergencyAction); const char* emergency_action_to_string(EmergencyAction i) _const_;
EmergencyAction emergency_action_from_string(const char *s) _pure_;
int parse_emergency_action(const char *value, RuntimeScope runtime_scope, EmergencyAction *ret); int parse_emergency_action(const char *value, RuntimeScope runtime_scope, EmergencyAction *ret);

View File

@ -569,7 +569,7 @@ void exec_status_reset(ExecStatus *s);
int exec_shared_runtime_acquire(Manager *m, const ExecContext *c, const char *id, bool create, ExecSharedRuntime **ret); int exec_shared_runtime_acquire(Manager *m, const ExecContext *c, const char *id, bool create, ExecSharedRuntime **ret);
ExecSharedRuntime *exec_shared_runtime_destroy(ExecSharedRuntime *r); ExecSharedRuntime *exec_shared_runtime_destroy(ExecSharedRuntime *r);
DECLARE_TRIVIAL_UNREF_FUNC(ExecSharedRuntime, exec_shared_runtime); ExecSharedRuntime *exec_shared_runtime_unref(ExecSharedRuntime *r);
DEFINE_TRIVIAL_CLEANUP_FUNC(ExecSharedRuntime*, exec_shared_runtime_unref); DEFINE_TRIVIAL_CLEANUP_FUNC(ExecSharedRuntime*, exec_shared_runtime_unref);
int exec_shared_runtime_serialize(const Manager *m, FILE *f, FDSet *fds); int exec_shared_runtime_serialize(const Manager *m, FILE *f, FDSet *fds);
@ -597,23 +597,31 @@ int exec_directory_add(ExecDirectory *d, const char *path, const char *symlink,
void exec_directory_sort(ExecDirectory *d); void exec_directory_sort(ExecDirectory *d);
bool exec_directory_is_private(const ExecContext *context, ExecDirectoryType type); bool exec_directory_is_private(const ExecContext *context, ExecDirectoryType type);
DECLARE_STRING_TABLE_LOOKUP_FROM_STRING(exec_clean_mask, ExecCleanMask); ExecCleanMask exec_clean_mask_from_string(const char *s);
DECLARE_STRING_TABLE_LOOKUP(exec_output, ExecOutput); const char* exec_output_to_string(ExecOutput i) _const_;
ExecOutput exec_output_from_string(const char *s) _pure_;
DECLARE_STRING_TABLE_LOOKUP(exec_input, ExecInput); const char* exec_input_to_string(ExecInput i) _const_;
ExecInput exec_input_from_string(const char *s) _pure_;
DECLARE_STRING_TABLE_LOOKUP(exec_utmp_mode, ExecUtmpMode); 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_preserve_mode, ExecPreserveMode); 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_keyring_mode, ExecKeyringMode); 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_directory_type_symlink, ExecDirectoryType); 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_mode, 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_resource_type, ExecDirectoryType); const char* exec_resource_type_to_string(ExecDirectoryType i) _const_;
ExecDirectoryType exec_resource_type_from_string(const char *s) _pure_;
bool exec_needs_mount_namespace(const ExecContext *context, const ExecParameters *params, const ExecRuntime *runtime); bool exec_needs_mount_namespace(const ExecContext *context, const ExecParameters *params, const ExecRuntime *runtime);
bool exec_needs_network_namespace(const ExecContext *context); bool exec_needs_network_namespace(const ExecContext *context);

View File

@ -209,11 +209,14 @@ void job_add_to_gc_queue(Job *j);
int job_get_before(Job *j, Job*** ret); int job_get_before(Job *j, Job*** ret);
int job_get_after(Job *j, Job*** ret); int job_get_after(Job *j, Job*** ret);
DECLARE_STRING_TABLE_LOOKUP(job_type, JobType); const char* job_type_to_string(JobType t) _const_;
JobType job_type_from_string(const char *s) _pure_;
DECLARE_STRING_TABLE_LOOKUP(job_state, JobState); const char* job_state_to_string(JobState t) _const_;
JobState job_state_from_string(const char *s) _pure_;
DECLARE_STRING_TABLE_LOOKUP(job_result, JobResult); const char* job_result_to_string(JobResult t) _const_;
JobResult job_result_from_string(const char *s) _pure_;
const char* job_type_to_access_method(JobType t); const char* job_type_to_access_method(JobType t);

View File

@ -40,9 +40,11 @@ typedef enum KillWhom {
void kill_context_init(KillContext *c); void kill_context_init(KillContext *c);
void kill_context_dump(KillContext *c, FILE *f, const char *prefix); void kill_context_dump(KillContext *c, FILE *f, const char *prefix);
DECLARE_STRING_TABLE_LOOKUP(kill_mode, KillMode); const char* kill_mode_to_string(KillMode k) _const_;
KillMode kill_mode_from_string(const char *s) _pure_;
DECLARE_STRING_TABLE_LOOKUP(kill_whom, KillWhom); const char* kill_whom_to_string(KillWhom k) _const_;
KillWhom kill_whom_from_string(const char *s) _pure_;
static inline int restart_kill_signal(const KillContext *c) { static inline int restart_kill_signal(const KillContext *c) {
if (c->restart_kill_signal != 0) if (c->restart_kill_signal != 0)

View File

@ -625,11 +625,14 @@ void manager_restore_original_log_target(Manager *m);
const char* manager_get_confirm_spawn(Manager *m); const char* manager_get_confirm_spawn(Manager *m);
void manager_disable_confirm_spawn(void); void manager_disable_confirm_spawn(void);
DECLARE_STRING_TABLE_LOOKUP(manager_state, ManagerState); const char* manager_state_to_string(ManagerState m) _const_;
ManagerState manager_state_from_string(const char *s) _pure_;
DECLARE_STRING_TABLE_LOOKUP(manager_objective, ManagerObjective); const char* manager_objective_to_string(ManagerObjective m) _const_;
ManagerObjective manager_objective_from_string(const char *s) _pure_;
DECLARE_STRING_TABLE_LOOKUP(manager_timestamp, ManagerTimestamp); const char* manager_timestamp_to_string(ManagerTimestamp m) _const_;
ManagerTimestamp manager_timestamp_from_string(const char *s) _pure_;
ManagerTimestamp manager_timestamp_initrd_mangle(ManagerTimestamp s); ManagerTimestamp manager_timestamp_initrd_mangle(ManagerTimestamp s);
usec_t manager_get_watchdog(Manager *m, WatchdogType t); usec_t manager_get_watchdog(Manager *m, WatchdogType t);

View File

@ -99,8 +99,10 @@ char* mount_get_what_escaped(const Mount *m);
char* mount_get_options_escaped(const Mount *m); char* mount_get_options_escaped(const Mount *m);
const char* mount_get_fstype(const Mount *m); const char* mount_get_fstype(const Mount *m);
DECLARE_STRING_TABLE_LOOKUP(mount_exec_command, MountExecCommand); 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_result, MountResult); const char* mount_result_to_string(MountResult i) _const_;
MountResult mount_result_from_string(const char *s) _pure_;
DEFINE_CAST(MOUNT, Mount); DEFINE_CAST(MOUNT, Mount);

View File

@ -221,25 +221,35 @@ int setup_tmp_dirs(
int setup_shareable_ns(int ns_storage_socket[static 2], unsigned long nsflag); 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); int open_shareable_ns_path(int netns_storage_socket[static 2], const char *path, unsigned long nsflag);
DECLARE_STRING_TABLE_LOOKUP(protect_home, ProtectHome); const char* protect_home_to_string(ProtectHome p) _const_;
ProtectHome protect_home_from_string(const char *s) _pure_;
DECLARE_STRING_TABLE_LOOKUP(protect_hostname, ProtectHostname); const char* protect_hostname_to_string(ProtectHostname p) _const_;
ProtectHostname protect_hostname_from_string(const char *s) _pure_;
DECLARE_STRING_TABLE_LOOKUP(protect_system, ProtectSystem); const char* protect_system_to_string(ProtectSystem p) _const_;
ProtectSystem protect_system_from_string(const char *s) _pure_;
DECLARE_STRING_TABLE_LOOKUP(protect_proc, ProtectProc); const char* protect_proc_to_string(ProtectProc i) _const_;
ProtectProc protect_proc_from_string(const char *s) _pure_;
DECLARE_STRING_TABLE_LOOKUP(proc_subset, ProcSubset); const char* proc_subset_to_string(ProcSubset i) _const_;
ProcSubset proc_subset_from_string(const char *s) _pure_;
DECLARE_STRING_TABLE_LOOKUP(private_bpf, PrivateBPF); const char* private_bpf_to_string(PrivateBPF i) _const_;
PrivateBPF private_bpf_from_string(const char *s) _pure_;
DECLARE_STRING_TABLE_LOOKUP(bpf_delegate_cmd, uint64_t); 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_map_type, 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_prog_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_attach_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_;
char* bpf_delegate_to_string(uint64_t u, const char * (*parser)(uint64_t) _const_); 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 *)); int bpf_delegate_from_string(const char *s, uint64_t *ret, uint64_t (*parser)(const char *));
@ -276,13 +286,17 @@ static inline char * bpf_delegate_attachments_to_string(uint64_t u) {
return bpf_delegate_to_string(u, bpf_delegate_attach_type_to_string); return bpf_delegate_to_string(u, bpf_delegate_attach_type_to_string);
} }
DECLARE_STRING_TABLE_LOOKUP(private_tmp, PrivateTmp); const char* private_tmp_to_string(PrivateTmp i) _const_;
PrivateTmp private_tmp_from_string(const char *s) _pure_;
DECLARE_STRING_TABLE_LOOKUP(private_users, PrivateUsers); const char* private_users_to_string(PrivateUsers i) _const_;
PrivateUsers private_users_from_string(const char *s) _pure_;
DECLARE_STRING_TABLE_LOOKUP(protect_control_groups, ProtectControlGroups); const char* protect_control_groups_to_string(ProtectControlGroups i) _const_;
ProtectControlGroups protect_control_groups_from_string(const char *s) _pure_;
DECLARE_STRING_TABLE_LOOKUP(private_pids, PrivatePIDs); const char* private_pids_to_string(PrivatePIDs i) _const_;
PrivatePIDs private_pids_from_string(const char *s) _pure_;
void bind_mount_free_many(BindMount *b, size_t n); void bind_mount_free_many(BindMount *b, size_t n);
int bind_mount_add(BindMount **b, size_t *n, const BindMount *item); int bind_mount_add(BindMount **b, size_t *n, const BindMount *item);

View File

@ -76,9 +76,11 @@ void path_free_specs(Path *p);
extern const UnitVTable path_vtable; extern const UnitVTable path_vtable;
extern const ActivationDetailsVTable activation_details_path_vtable; extern const ActivationDetailsVTable activation_details_path_vtable;
DECLARE_STRING_TABLE_LOOKUP(path_type, PathType); const char* path_type_to_string(PathType i) _const_;
PathType path_type_from_string(const char *s) _pure_;
DECLARE_STRING_TABLE_LOOKUP(path_result, PathResult); const char* path_result_to_string(PathResult i) _const_;
PathResult path_result_from_string(const char *s) _pure_;
DEFINE_CAST(PATH, Path); DEFINE_CAST(PATH, Path);
DEFINE_ACTIVATION_DETAILS_CAST(ACTIVATION_DETAILS_PATH, ActivationDetailsPath, PATH); DEFINE_ACTIVATION_DETAILS_CAST(ACTIVATION_DETAILS_PATH, ActivationDetailsPath, PATH);

View File

@ -46,6 +46,7 @@ extern const UnitVTable scope_vtable;
int scope_abandon(Scope *s); int scope_abandon(Scope *s);
DECLARE_STRING_TABLE_LOOKUP(scope_result, ScopeResult); const char* scope_result_to_string(ScopeResult i) _const_;
ScopeResult scope_result_from_string(const char *s) _pure_;
DEFINE_CAST(SCOPE, Scope); DEFINE_CAST(SCOPE, Scope);

View File

@ -270,23 +270,32 @@ usec_t service_restart_usec_next(const Service *s) _pure_;
int service_determine_exec_selinux_label(Service *s, char **ret); int service_determine_exec_selinux_label(Service *s, char **ret);
DECLARE_STRING_TABLE_LOOKUP(service_restart, ServiceRestart); const char* service_restart_to_string(ServiceRestart i) _const_;
ServiceRestart service_restart_from_string(const char *s) _pure_;
DECLARE_STRING_TABLE_LOOKUP(service_restart_mode, ServiceRestartMode); 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_type, ServiceType); const char* service_type_to_string(ServiceType i) _const_;
ServiceType service_type_from_string(const char *s) _pure_;
DECLARE_STRING_TABLE_LOOKUP(service_exit_type, ServiceExitType); 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_exec_command, ServiceExecCommand); 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_ex_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(notify_state, NotifyState); const char* notify_state_to_string(NotifyState i) _const_;
NotifyState notify_state_from_string(const char *s) _pure_;
DECLARE_STRING_TABLE_LOOKUP(service_result, ServiceResult); const char* service_result_to_string(ServiceResult i) _const_;
ServiceResult service_result_from_string(const char *s) _pure_;
DECLARE_STRING_TABLE_LOOKUP(service_timeout_failure_mode, ServiceTimeoutFailureMode); const char* service_timeout_failure_mode_to_string(ServiceTimeoutFailureMode i) _const_;
ServiceTimeoutFailureMode service_timeout_failure_mode_from_string(const char *s) _pure_;
DEFINE_CAST(SERVICE, Service); DEFINE_CAST(SERVICE, Service);

View File

@ -31,10 +31,12 @@ typedef enum StatusUnitFormat {
static inline bool show_status_on(ShowStatus s) { static inline bool show_status_on(ShowStatus s) {
return IN_SET(s, SHOW_STATUS_TEMPORARY, SHOW_STATUS_YES); return IN_SET(s, SHOW_STATUS_TEMPORARY, SHOW_STATUS_YES);
} }
DECLARE_STRING_TABLE_LOOKUP(show_status, ShowStatus); ShowStatus show_status_from_string(const char *s) _const_;
const char* show_status_to_string(ShowStatus s) _pure_;
int parse_show_status(const char *s, ShowStatus *ret); int parse_show_status(const char *s, ShowStatus *ret);
DECLARE_STRING_TABLE_LOOKUP(status_unit_format, StatusUnitFormat); StatusUnitFormat status_unit_format_from_string(const char *s) _const_;
const char* status_unit_format_to_string(StatusUnitFormat s) _pure_;
int status_vprintf(const char *status, ShowStatusFlags flags, const char *format, va_list ap) _printf_(3,0); 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); int status_printf(const char *status, ShowStatusFlags flags, const char *format, ...) _printf_(3,4);

View File

@ -204,16 +204,20 @@ const char* socket_fdname(Socket *s);
extern const UnitVTable socket_vtable; extern const UnitVTable socket_vtable;
DECLARE_STRING_TABLE_LOOKUP(socket_exec_command, SocketExecCommand); 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_result, SocketResult); const char* socket_result_to_string(SocketResult i) _const_;
SocketResult socket_result_from_string(const char *s) _pure_;
const char* socket_port_type_to_string(SocketPort *p) _pure_; const char* socket_port_type_to_string(SocketPort *p) _pure_;
SocketType socket_port_type_from_string(const char *s) _pure_; SocketType socket_port_type_from_string(const char *s) _pure_;
DECLARE_STRING_TABLE_LOOKUP(socket_timestamping, SocketTimestamping); const char* socket_timestamping_to_string(SocketTimestamping p) _const_;
SocketTimestamping socket_timestamping_from_string(const char *s) _pure_;
SocketTimestamping socket_timestamping_from_string_harder(const char *s) _pure_; SocketTimestamping socket_timestamping_from_string_harder(const char *s) _pure_;
DECLARE_STRING_TABLE_LOOKUP(socket_defer_trigger, SocketDeferTrigger); const char* socket_defer_trigger_to_string(SocketDeferTrigger i) _const_;
SocketDeferTrigger socket_defer_trigger_from_string(const char *s) _pure_;
DEFINE_CAST(SOCKET, Socket); DEFINE_CAST(SOCKET, Socket);

View File

@ -94,8 +94,10 @@ int swap_process_device_remove(Manager *m, sd_device *dev);
int swap_get_priority(const Swap *s); int swap_get_priority(const Swap *s);
const char* swap_get_options(const Swap *s); const char* swap_get_options(const Swap *s);
DECLARE_STRING_TABLE_LOOKUP(swap_exec_command, SwapExecCommand); 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_result, SwapResult); const char* swap_result_to_string(SwapResult i) _const_;
SwapResult swap_result_from_string(const char *s) _pure_;
DEFINE_CAST(SWAP, Swap); DEFINE_CAST(SWAP, Swap);

View File

@ -78,11 +78,13 @@ void timer_free_values(Timer *t);
extern const UnitVTable timer_vtable; extern const UnitVTable timer_vtable;
extern const ActivationDetailsVTable activation_details_timer_vtable; extern const ActivationDetailsVTable activation_details_timer_vtable;
DECLARE_STRING_TABLE_LOOKUP(timer_base, TimerBase); const char* timer_base_to_string(TimerBase i) _const_;
TimerBase timer_base_from_string(const char *s) _pure_;
char* timer_base_to_usec_string(TimerBase i); char* timer_base_to_usec_string(TimerBase i);
DECLARE_STRING_TABLE_LOOKUP(timer_result, TimerResult); const char* timer_result_to_string(TimerResult i) _const_;
TimerResult timer_result_from_string(const char *s) _pure_;
DEFINE_CAST(TIMER, Timer); DEFINE_CAST(TIMER, Timer);
DEFINE_ACTIVATION_DETAILS_CAST(ACTIVATION_DETAILS_TIMER, ActivationDetailsTimer, TIMER); DEFINE_ACTIVATION_DETAILS_CAST(ACTIVATION_DETAILS_TIMER, ActivationDetailsTimer, TIMER);

View File

@ -1087,10 +1087,12 @@ int unit_compare_priority(Unit *a, Unit *b);
const char* unit_log_field(const Unit *u); const char* unit_log_field(const Unit *u);
const char* unit_invocation_log_field(const Unit *u); const char* unit_invocation_log_field(const Unit *u);
DECLARE_STRING_TABLE_LOOKUP(unit_mount_dependency_type, UnitMountDependencyType); UnitMountDependencyType unit_mount_dependency_type_from_string(const char *s) _const_;
const char* unit_mount_dependency_type_to_string(UnitMountDependencyType t) _const_;
UnitDependency unit_mount_dependency_type_to_dependency_type(UnitMountDependencyType t) _pure_; UnitDependency unit_mount_dependency_type_to_dependency_type(UnitMountDependencyType t) _pure_;
DECLARE_STRING_TABLE_LOOKUP(oom_policy, OOMPolicy); const char* oom_policy_to_string(OOMPolicy i) _const_;
OOMPolicy oom_policy_from_string(const char *s) _pure_;
/* Macros which append UNIT= or USER_UNIT= to the message */ /* Macros which append UNIT= or USER_UNIT= to the message */
@ -1166,7 +1168,8 @@ DECLARE_STRING_TABLE_LOOKUP(oom_policy, OOMPolicy);
#define LOG_UNIT_ID(unit) LOG_ITEM("%s%s", unit_log_field((unit)), (unit)->id) #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) #define LOG_UNIT_INVOCATION_ID(unit) LOG_ITEM("%s%s", unit_invocation_log_field((unit)), (unit)->invocation_id_string)
DECLARE_STRING_TABLE_LOOKUP(collect_mode, CollectMode); const char* collect_mode_to_string(CollectMode m) _const_;
CollectMode collect_mode_from_string(const char *s) _pure_;
typedef struct UnitForEachDependencyData { typedef struct UnitForEachDependencyData {
/* Stores state for the FOREACH macro below for iterating through all deps that have any of the /* Stores state for the FOREACH macro below for iterating through all deps that have any of the

View File

@ -30,5 +30,8 @@ typedef enum WipeScope {
_WIPE_SCOPE_INVALID = -EINVAL, _WIPE_SCOPE_INVALID = -EINVAL,
} WipeScope; } WipeScope;
DECLARE_STRING_TABLE_LOOKUP(enroll_type, EnrollType); const char* enroll_type_to_string(EnrollType t);
DECLARE_STRING_TABLE_LOOKUP(luks2_token_type, EnrollType); 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);

View File

@ -1,21 +0,0 @@
/* 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)

View File

@ -230,4 +230,5 @@ bool home_shall_rebalance(Home *h);
bool home_is_busy(Home *h); bool home_is_busy(Home *h);
DECLARE_STRING_TABLE_LOOKUP(home_state, HomeState); const char* home_state_to_string(HomeState state);
HomeState home_state_from_string(const char *s);

View File

@ -48,7 +48,8 @@ typedef struct Operation {
} Operation; } Operation;
Operation *operation_new(OperationType type, sd_bus_message *m); Operation *operation_new(OperationType type, sd_bus_message *m);
DECLARE_TRIVIAL_REF_UNREF_FUNC(Operation, operation); Operation *operation_ref(Operation *operation);
Operation *operation_unref(Operation *operation);
DEFINE_TRIVIAL_CLEANUP_FUNC(Operation*, operation_unref); DEFINE_TRIVIAL_CLEANUP_FUNC(Operation*, operation_unref);

View File

@ -51,4 +51,5 @@ int import_compress_init(ImportCompress *c, ImportCompressType t);
int import_compress(ImportCompress *c, const void *data, size_t size, void **buffer, size_t *buffer_size, size_t *buffer_allocated); 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); int import_compress_finish(ImportCompress *c, void **buffer, size_t *buffer_size, size_t *buffer_allocated);
DECLARE_STRING_TABLE_LOOKUP(import_compress_type, ImportCompressType); const char* import_compress_type_to_string(ImportCompressType t) _const_;
ImportCompressType import_compress_type_from_string(const char *s) _pure_;

View File

@ -20,7 +20,8 @@ typedef struct Writer {
} Writer; } Writer;
int writer_new(RemoteServer *server, Writer **ret); int writer_new(RemoteServer *server, Writer **ret);
DECLARE_TRIVIAL_REF_UNREF_FUNC(Writer, writer); Writer* writer_ref(Writer *w);
Writer* writer_unref(Writer *w);
DEFINE_TRIVIAL_CLEANUP_FUNC(Writer*, writer_unref); DEFINE_TRIVIAL_CLEANUP_FUNC(Writer*, writer_unref);

View File

@ -99,9 +99,11 @@ int manager_dispatch_reload_signal(sd_event_source *s, const struct signalfd_sig
/* Defined in generated journald-gperf.c */ /* Defined in generated journald-gperf.c */
const struct ConfigPerfItem* journald_gperf_lookup(const char *str, GPERF_LEN_TYPE length); const struct ConfigPerfItem* journald_gperf_lookup(const char *str, GPERF_LEN_TYPE length);
DECLARE_STRING_TABLE_LOOKUP(storage, Storage); const char* storage_to_string(Storage s) _const_;
Storage storage_from_string(const char *s) _pure_;
DECLARE_STRING_TABLE_LOOKUP(split_mode, SplitMode); const char* split_mode_to_string(SplitMode s) _const_;
SplitMode split_mode_from_string(const char *s) _pure_;
CONFIG_PARSER_PROTOTYPE(config_parse_storage); CONFIG_PARSER_PROTOTYPE(config_parse_storage);
CONFIG_PARSER_PROTOTYPE(config_parse_line_max); CONFIG_PARSER_PROTOTYPE(config_parse_line_max);

View File

@ -20,7 +20,7 @@ typedef enum DHCPState {
_DHCP_STATE_INVALID = -EINVAL, _DHCP_STATE_INVALID = -EINVAL,
} DHCPState; } DHCPState;
DECLARE_STRING_TABLE_LOOKUP_TO_STRING(dhcp_state, DHCPState); const char* dhcp_state_to_string(DHCPState s) _const_;
typedef struct sd_dhcp_client sd_dhcp_client; typedef struct sd_dhcp_client sd_dhcp_client;

View File

@ -76,7 +76,7 @@ static inline bool duid_data_size_is_valid(size_t size) {
return size >= MIN_DUID_DATA_LEN && size <= MAX_DUID_DATA_LEN; return size >= MIN_DUID_DATA_LEN && size <= MAX_DUID_DATA_LEN;
} }
DECLARE_STRING_TABLE_LOOKUP_TO_STRING(duid_type, DUIDType); const char* duid_type_to_string(DUIDType t) _const_;
int dhcp_duid_to_string_internal(uint16_t type, const void *data, size_t data_size, char **ret); int dhcp_duid_to_string_internal(uint16_t type, const void *data, size_t data_size, char **ret);
int dhcp_identifier_set_iaid( int dhcp_identifier_set_iaid(

View File

@ -150,7 +150,9 @@ typedef enum DHCP6FQDNFlag {
DHCP6_FQDN_FLAG_N = 1 << 2, DHCP6_FQDN_FLAG_N = 1 << 2,
} DHCP6FQDNFlag; } DHCP6FQDNFlag;
DECLARE_STRING_TABLE_LOOKUP_TO_STRING(dhcp6_state, DHCP6State); const char* dhcp6_state_to_string(DHCP6State s) _const_;
DECLARE_STRING_TABLE_LOOKUP(dhcp6_message_type, DHCP6MessageType); const char* dhcp6_message_type_to_string(DHCP6MessageType s) _const_;
DECLARE_STRING_TABLE_LOOKUP(dhcp6_message_status, DHCP6Status); 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_;
int dhcp6_message_status_to_errno(DHCP6Status s); int dhcp6_message_status_to_errno(DHCP6Status s);

View File

@ -33,7 +33,8 @@ struct sd_lldp_rx {
struct ether_addr filter_address; struct ether_addr filter_address;
}; };
DECLARE_STRING_TABLE_LOOKUP(lldp_rx_event, sd_lldp_rx_event_t); 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_;
int lldp_rx_build_neighbors_json(sd_lldp_rx *lldp_rx, sd_json_variant **ret); int lldp_rx_build_neighbors_json(sd_lldp_rx *lldp_rx, sd_json_variant **ret);

View File

@ -42,7 +42,8 @@ typedef struct sd_ndisc {
void *userdata; void *userdata;
} sd_ndisc; } sd_ndisc;
DECLARE_STRING_TABLE_LOOKUP(ndisc_event, sd_ndisc_event_t); const char* ndisc_event_to_string(sd_ndisc_event_t e) _const_;
sd_ndisc_event_t ndisc_event_from_string(const char *s) _pure_;
#define log_ndisc_errno(ndisc, error, fmt, ...) \ #define log_ndisc_errno(ndisc, error, fmt, ...) \
log_interface_prefix_full_errno( \ log_interface_prefix_full_errno( \

View File

@ -34,4 +34,4 @@ sd_ndisc_router* ndisc_router_new(ICMP6Packet *packet);
int ndisc_router_parse(sd_ndisc *nd, sd_ndisc_router *rt); int ndisc_router_parse(sd_ndisc *nd, sd_ndisc_router *rt);
int ndisc_router_flags_to_string(uint64_t flags, char **ret); int ndisc_router_flags_to_string(uint64_t flags, char **ret);
DECLARE_STRING_TABLE_LOOKUP_TO_STRING(ndisc_router_preference, int); const char* ndisc_router_preference_to_string(int s) _const_;

View File

@ -72,4 +72,5 @@ static inline int device_read_db(sd_device *device) {
int device_read_uevent_file(sd_device *device); int device_read_uevent_file(sd_device *device);
int device_set_action(sd_device *device, sd_device_action_t a); int device_set_action(sd_device *device, sd_device_action_t a);
DECLARE_STRING_TABLE_LOOKUP(device_action, sd_device_action_t); sd_device_action_t device_action_from_string(const char *s) _pure_;
const char* device_action_to_string(sd_device_action_t a) _const_;

View File

@ -5,7 +5,8 @@
#include "sd-forward.h" #include "sd-forward.h"
DECLARE_STRING_TABLE_LOOKUP(audit_type, int); const char* audit_type_to_string(int type);
int audit_type_from_string(const char *s);
/* This is inspired by DNS TYPEnnn formatting */ /* This is inspired by DNS TYPEnnn formatting */
#define audit_type_name_alloca(type) \ #define audit_type_name_alloca(type) \

View File

@ -335,7 +335,7 @@ uint64_t journal_file_hash_data(JournalFile *f, const void *data, size_t sz);
bool journal_field_valid(const char *p, size_t l, bool allow_protected); bool journal_field_valid(const char *p, size_t l, bool allow_protected);
DECLARE_STRING_TABLE_LOOKUP_TO_STRING(journal_object_type, ObjectType); const char* journal_object_type_to_string(ObjectType type) _const_;
static inline Compression COMPRESSION_FROM_OBJECT(const Object *o) { static inline Compression COMPRESSION_FROM_OBJECT(const Object *o) {
assert(o); assert(o);

View File

@ -29,7 +29,8 @@ static inline MMapCacheCategory type_to_category(ObjectType type) {
} }
MMapCache* mmap_cache_new(void); MMapCache* mmap_cache_new(void);
DECLARE_TRIVIAL_REF_UNREF_FUNC(MMapCache, mmap_cache); MMapCache* mmap_cache_ref(MMapCache *m);
MMapCache* mmap_cache_unref(MMapCache *m);
DEFINE_TRIVIAL_CLEANUP_FUNC(MMapCache*, mmap_cache_unref); DEFINE_TRIVIAL_CLEANUP_FUNC(MMapCache*, mmap_cache_unref);
int mmap_cache_fd_get( int mmap_cache_fd_get(

View File

@ -73,15 +73,20 @@ typedef enum LinkOnlineState {
_LINK_ONLINE_STATE_INVALID = -EINVAL, _LINK_ONLINE_STATE_INVALID = -EINVAL,
} LinkOnlineState; } LinkOnlineState;
DECLARE_STRING_TABLE_LOOKUP(link_operstate, LinkOperationalState); const char* link_operstate_to_string(LinkOperationalState s) _const_;
LinkOperationalState link_operstate_from_string(const char *s) _pure_;
DECLARE_STRING_TABLE_LOOKUP(link_carrier_state, LinkCarrierState); 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_required_address_family, AddressFamily); 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_address_state, LinkAddressState); 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_online_state, LinkOnlineState); const char* link_online_state_to_string(LinkOnlineState s) _const_;
LinkOnlineState link_online_state_from_string(const char *s) _pure_;
typedef struct LinkOperationalStateRange { typedef struct LinkOperationalStateRange {
LinkOperationalState min; LinkOperationalState min;

View File

@ -77,8 +77,10 @@ int manager_handle_action(
bool is_edge, bool is_edge,
const char *action_seat); const char *action_seat);
DECLARE_STRING_TABLE_LOOKUP_TO_STRING(handle_action_verb, HandleAction); const char* handle_action_verb_to_string(HandleAction h) _const_;
DECLARE_STRING_TABLE_LOOKUP(handle_action, HandleAction);
const char* handle_action_to_string(HandleAction h) _const_;
HandleAction handle_action_from_string(const char *s) _pure_;
const HandleActionData* handle_action_lookup(HandleAction action); const HandleActionData* handle_action_lookup(HandleAction action);

View File

@ -87,4 +87,5 @@ static inline bool inhibit_what_is_valid(InhibitWhat w) {
const char* inhibit_what_to_string(InhibitWhat w); const char* inhibit_what_to_string(InhibitWhat w);
int inhibit_what_from_string(const char *s); int inhibit_what_from_string(const char *s);
DECLARE_STRING_TABLE_LOOKUP(inhibit_mode, InhibitMode); const char* inhibit_mode_to_string(InhibitMode k);
InhibitMode inhibit_mode_from_string(const char *s);

View File

@ -196,15 +196,20 @@ int session_kill(Session *s, KillWhom whom, int signo, sd_bus_error *error);
SessionState session_get_state(Session *s); SessionState session_get_state(Session *s);
DECLARE_STRING_TABLE_LOOKUP(session_state, SessionState); const char* session_state_to_string(SessionState t) _const_;
SessionState session_state_from_string(const char *s) _pure_;
DECLARE_STRING_TABLE_LOOKUP(session_type, SessionType); const char* session_type_to_string(SessionType t) _const_;
SessionType session_type_from_string(const char *s) _pure_;
DECLARE_STRING_TABLE_LOOKUP(session_class, SessionClass); const char* session_class_to_string(SessionClass t) _const_;
SessionClass session_class_from_string(const char *s) _pure_;
DECLARE_STRING_TABLE_LOOKUP(kill_whom, KillWhom); const char* kill_whom_to_string(KillWhom k) _const_;
KillWhom kill_whom_from_string(const char *s) _pure_;
DECLARE_STRING_TABLE_LOOKUP(tty_validity, TTYValidity); const char* tty_validity_to_string(TTYValidity t) _const_;
TTYValidity tty_validity_from_string(const char *s) _pure_;
void session_leave_vt(Session *s); void session_leave_vt(Session *s);

View File

@ -83,8 +83,10 @@ int user_check_linger_file(const User *u);
void user_elect_display(User *u); void user_elect_display(User *u);
void user_update_last_session_timer(User *u); void user_update_last_session_timer(User *u);
DECLARE_STRING_TABLE_LOOKUP(user_state, UserState); const char* user_state_to_string(UserState s) _const_;
UserState user_state_from_string(const char *s) _pure_;
DECLARE_STRING_TABLE_LOOKUP(user_gc_mode, UserGCMode); const char* user_gc_mode_to_string(UserGCMode m) _const_;
UserGCMode user_gc_mode_from_string(const char *s) _pure_;
CONFIG_PARSER_PROTOTYPE(config_parse_compat_user_tasks_max); CONFIG_PARSER_PROTOTYPE(config_parse_compat_user_tasks_max);

View File

@ -10,7 +10,8 @@ typedef enum ImageCleanPoolMode {
_IMAGE_CLEAN_POOL_INVALID = -EINVAL, _IMAGE_CLEAN_POOL_INVALID = -EINVAL,
} ImageCleanPoolMode; } ImageCleanPoolMode;
DECLARE_STRING_TABLE_LOOKUP(image_clean_pool_mode, ImageCleanPoolMode); ImageCleanPoolMode image_clean_pool_mode_from_string(const char *s) _pure_;
const char* image_clean_pool_mode_to_string(ImageCleanPoolMode mode) _const_;
int image_clean_pool_operation(Manager *manager, ImageCleanPoolMode mode, Operation **ret_operation); 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); int clean_pool_read_first_entry(FILE *file, int child_error, sd_bus_error *error);

View File

@ -107,11 +107,14 @@ void machine_release_unit(Machine *m);
MachineState machine_get_state(Machine *m); MachineState machine_get_state(Machine *m);
DECLARE_STRING_TABLE_LOOKUP(machine_class, MachineClass); const char* machine_class_to_string(MachineClass t) _const_;
MachineClass machine_class_from_string(const char *s) _pure_;
DECLARE_STRING_TABLE_LOOKUP(machine_state, MachineState); const char* machine_state_to_string(MachineState t) _const_;
MachineState machine_state_from_string(const char *s) _pure_;
DECLARE_STRING_TABLE_LOOKUP(kill_whom, KillWhom); const char* kill_whom_to_string(KillWhom k) _const_;
KillWhom kill_whom_from_string(const char *s) _pure_;
int machine_openpt(Machine *m, int flags, char **ret_peer); int machine_openpt(Machine *m, int flags, char **ret_peer);
int machine_start_getty(Machine *m, const char *ptmx_name, sd_bus_error *error); int machine_start_getty(Machine *m, const char *ptmx_name, sd_bus_error *error);
@ -146,7 +149,8 @@ typedef enum AcquireMetadata {
_ACQUIRE_METADATA_INVALID = -EINVAL, _ACQUIRE_METADATA_INVALID = -EINVAL,
} AcquireMetadata; } AcquireMetadata;
DECLARE_STRING_TABLE_LOOKUP(acquire_metadata, AcquireMetadata); AcquireMetadata acquire_metadata_from_string(const char *s) _pure_;
const char* acquire_metadata_to_string(AcquireMetadata am) _const_;
inline static bool should_acquire_metadata(AcquireMetadata am) { inline static bool should_acquire_metadata(AcquireMetadata am) {
return am == ACQUIRE_METADATA_YES || am == ACQUIRE_METADATA_GRACEFUL; return am == ACQUIRE_METADATA_YES || am == ACQUIRE_METADATA_GRACEFUL;
} }

View File

@ -2,8 +2,8 @@
* Copyright © 2020 VMware, Inc. */ * Copyright © 2020 VMware, Inc. */
#pragma once #pragma once
#include "netdev.h"
#include "shared-forward.h" #include "shared-forward.h"
#include "netdev.h"
typedef enum BareUDPProtocol { typedef enum BareUDPProtocol {
BARE_UDP_PROTOCOL_IPV4 = ETH_P_IP, BARE_UDP_PROTOCOL_IPV4 = ETH_P_IP,
@ -25,6 +25,7 @@ typedef struct BareUDP {
DEFINE_NETDEV_CAST(BAREUDP, BareUDP); DEFINE_NETDEV_CAST(BAREUDP, BareUDP);
extern const NetDevVTable bare_udp_vtable; extern const NetDevVTable bare_udp_vtable;
DECLARE_STRING_TABLE_LOOKUP(bare_udp_protocol, BareUDPProtocol); const char* bare_udp_protocol_to_string(BareUDPProtocol d) _const_;
BareUDPProtocol bare_udp_protocol_from_string(const char *s) _pure_;
CONFIG_PARSER_PROTOTYPE(config_parse_bare_udp_iftype); CONFIG_PARSER_PROTOTYPE(config_parse_bare_udp_iftype);

View File

@ -1,8 +1,8 @@
/* SPDX-License-Identifier: LGPL-2.1-or-later */ /* SPDX-License-Identifier: LGPL-2.1-or-later */
#pragma once #pragma once
#include "netdev.h"
#include "shared-forward.h" #include "shared-forward.h"
#include "netdev.h"
#define LINK_BRIDGE_PORT_PRIORITY_INVALID 128U #define LINK_BRIDGE_PORT_PRIORITY_INVALID 128U
#define LINK_BRIDGE_PORT_PRIORITY_MAX 63U #define LINK_BRIDGE_PORT_PRIORITY_MAX 63U
@ -41,7 +41,8 @@ typedef enum MulticastRouter {
DEFINE_NETDEV_CAST(BRIDGE, Bridge); DEFINE_NETDEV_CAST(BRIDGE, Bridge);
extern const NetDevVTable bridge_vtable; extern const NetDevVTable bridge_vtable;
DECLARE_STRING_TABLE_LOOKUP(multicast_router, MulticastRouter); const char* multicast_router_to_string(MulticastRouter i) _const_;
MulticastRouter multicast_router_from_string(const char *s) _pure_;
CONFIG_PARSER_PROTOTYPE(config_parse_multicast_router); CONFIG_PARSER_PROTOTYPE(config_parse_multicast_router);
CONFIG_PARSER_PROTOTYPE(config_parse_bridge_igmp_version); CONFIG_PARSER_PROTOTYPE(config_parse_bridge_igmp_version);

View File

@ -4,8 +4,8 @@
#include <linux/fou.h> #include <linux/fou.h>
#include "in-addr-util.h" #include "in-addr-util.h"
#include "netdev.h"
#include "shared-forward.h" #include "shared-forward.h"
#include "netdev.h"
typedef enum FooOverUDPEncapType { typedef enum FooOverUDPEncapType {
NETDEV_FOO_OVER_UDP_ENCAP_UNSPEC = FOU_ENCAP_UNSPEC, NETDEV_FOO_OVER_UDP_ENCAP_UNSPEC = FOU_ENCAP_UNSPEC,
@ -34,7 +34,8 @@ typedef struct FouTunnel {
DEFINE_NETDEV_CAST(FOU, FouTunnel); DEFINE_NETDEV_CAST(FOU, FouTunnel);
extern const NetDevVTable foutnl_vtable; extern const NetDevVTable foutnl_vtable;
DECLARE_STRING_TABLE_LOOKUP(fou_encap_type, FooOverUDPEncapType); const char* fou_encap_type_to_string(FooOverUDPEncapType d) _const_;
FooOverUDPEncapType fou_encap_type_from_string(const char *s) _pure_;
CONFIG_PARSER_PROTOTYPE(config_parse_fou_encap_type); CONFIG_PARSER_PROTOTYPE(config_parse_fou_encap_type);
CONFIG_PARSER_PROTOTYPE(config_parse_fou_tunnel_address); CONFIG_PARSER_PROTOTYPE(config_parse_fou_tunnel_address);

View File

@ -3,9 +3,9 @@
#include <linux/if_link.h> #include <linux/if_link.h>
#include "shared-forward.h"
#include "in-addr-util.h" #include "in-addr-util.h"
#include "netdev.h" #include "netdev.h"
#include "shared-forward.h"
#define GENEVE_VID_MAX (1u << 24) - 1 #define GENEVE_VID_MAX (1u << 24) - 1
@ -44,7 +44,8 @@ typedef struct Geneve {
DEFINE_NETDEV_CAST(GENEVE, Geneve); DEFINE_NETDEV_CAST(GENEVE, Geneve);
extern const NetDevVTable geneve_vtable; extern const NetDevVTable geneve_vtable;
DECLARE_STRING_TABLE_LOOKUP(geneve_df, GeneveDF); const char* geneve_df_to_string(GeneveDF d) _const_;
GeneveDF geneve_df_from_string(const char *s) _pure_;
CONFIG_PARSER_PROTOTYPE(config_parse_geneve_vni); CONFIG_PARSER_PROTOTYPE(config_parse_geneve_vni);
CONFIG_PARSER_PROTOTYPE(config_parse_geneve_address); CONFIG_PARSER_PROTOTYPE(config_parse_geneve_address);

View File

@ -23,6 +23,6 @@ typedef struct Hsr {
DEFINE_NETDEV_CAST(HSR, Hsr); DEFINE_NETDEV_CAST(HSR, Hsr);
extern const NetDevVTable hsr_vtable; extern const NetDevVTable hsr_vtable;
DECLARE_STRING_TABLE_LOOKUP_FROM_STRING(hsr_protocol, HsrProtocol); HsrProtocol hsr_protocol_from_string(const char *s) _pure_;
CONFIG_PARSER_PROTOTYPE(config_parse_hsr_protocol); CONFIG_PARSER_PROTOTYPE(config_parse_hsr_protocol);

View File

@ -14,7 +14,8 @@ typedef enum NetDevLocalAddressType {
_NETDEV_LOCAL_ADDRESS_TYPE_INVALID = -EINVAL, _NETDEV_LOCAL_ADDRESS_TYPE_INVALID = -EINVAL,
} NetDevLocalAddressType; } NetDevLocalAddressType;
DECLARE_STRING_TABLE_LOOKUP(netdev_local_address_type, NetDevLocalAddressType); const char* netdev_local_address_type_to_string(NetDevLocalAddressType t) _const_;
NetDevLocalAddressType netdev_local_address_type_from_string(const char *s) _pure_;
int link_get_local_address( int link_get_local_address(
Link *link, Link *link,

View File

@ -227,7 +227,8 @@ void netdev_drop(NetDev *netdev);
void netdev_enter_failed(NetDev *netdev); void netdev_enter_failed(NetDev *netdev);
int netdev_enter_ready(NetDev *netdev); int netdev_enter_ready(NetDev *netdev);
DECLARE_TRIVIAL_REF_UNREF_FUNC(NetDev, netdev); NetDev* netdev_unref(NetDev *netdev);
NetDev* netdev_ref(NetDev *netdev);
DEFINE_TRIVIAL_DESTRUCTOR(netdev_destroy_callback, NetDev, netdev_unref); DEFINE_TRIVIAL_DESTRUCTOR(netdev_destroy_callback, NetDev, netdev_unref);
DEFINE_TRIVIAL_CLEANUP_FUNC(NetDev*, netdev_unref); DEFINE_TRIVIAL_CLEANUP_FUNC(NetDev*, netdev_unref);
@ -241,7 +242,8 @@ int netdev_generate_hw_addr(NetDev *netdev, Link *parent, const char *name,
bool netdev_needs_reconfigure(NetDev *netdev, NetDevLocalAddressType type); bool netdev_needs_reconfigure(NetDev *netdev, NetDevLocalAddressType type);
int link_request_stacked_netdev(Link *link, NetDev *netdev); int link_request_stacked_netdev(Link *link, NetDev *netdev);
DECLARE_STRING_TABLE_LOOKUP(netdev_kind, NetDevKind); const char* netdev_kind_to_string(NetDevKind d) _const_;
NetDevKind netdev_kind_from_string(const char *s) _pure_;
static inline NetDevCreateType netdev_get_create_type(NetDev *netdev) { static inline NetDevCreateType netdev_get_create_type(NetDev *netdev) {
assert(netdev); assert(netdev);

View File

@ -1,10 +1,10 @@
/* SPDX-License-Identifier: LGPL-2.1-or-later */ /* SPDX-License-Identifier: LGPL-2.1-or-later */
#pragma once #pragma once
#include "shared-forward.h"
#include "fou-tunnel.h" #include "fou-tunnel.h"
#include "netdev.h" #include "netdev.h"
#include "networkd-link.h" #include "networkd-link.h"
#include "shared-forward.h"
/* For IFLA_IPTUN_PROTO attribute */ /* For IFLA_IPTUN_PROTO attribute */
typedef enum TunnelMode { typedef enum TunnelMode {
@ -122,7 +122,8 @@ extern const NetDevVTable ip6gretap_vtable;
extern const NetDevVTable ip6tnl_vtable; extern const NetDevVTable ip6tnl_vtable;
extern const NetDevVTable erspan_vtable; extern const NetDevVTable erspan_vtable;
DECLARE_STRING_TABLE_LOOKUP(tunnel_mode, TunnelMode); const char* tunnel_mode_to_string(TunnelMode d) _const_;
TunnelMode tunnel_mode_from_string(const char *s) _pure_;
CONFIG_PARSER_PROTOTYPE(config_parse_tunnel_mode); CONFIG_PARSER_PROTOTYPE(config_parse_tunnel_mode);
CONFIG_PARSER_PROTOTYPE(config_parse_tunnel_local_address); CONFIG_PARSER_PROTOTYPE(config_parse_tunnel_local_address);

View File

@ -65,7 +65,8 @@ typedef struct VxLan {
DEFINE_NETDEV_CAST(VXLAN, VxLan); DEFINE_NETDEV_CAST(VXLAN, VxLan);
extern const NetDevVTable vxlan_vtable; extern const NetDevVTable vxlan_vtable;
DECLARE_STRING_TABLE_LOOKUP(df, VxLanDF); const char* df_to_string(VxLanDF d) _const_;
VxLanDF df_from_string(const char *s) _pure_;
CONFIG_PARSER_PROTOTYPE(config_parse_vxlan_address); CONFIG_PARSER_PROTOTYPE(config_parse_vxlan_address);
CONFIG_PARSER_PROTOTYPE(config_parse_port_range); CONFIG_PARSER_PROTOTYPE(config_parse_port_range);

View File

@ -3,7 +3,8 @@
#include "networkd-forward.h" #include "networkd-forward.h"
DECLARE_TRIVIAL_REF_UNREF_FUNC(IPv6Token, ipv6_token); IPv6Token* ipv6_token_ref(IPv6Token *token);
IPv6Token* ipv6_token_unref(IPv6Token *token);
int dhcp_pd_generate_addresses(Link *link, const struct in6_addr *prefix, Hashmap **ret); int dhcp_pd_generate_addresses(Link *link, const struct in6_addr *prefix, Hashmap **ret);
int ndisc_generate_addresses(Link *link, const struct in6_addr *prefix, uint8_t prefixlen, Hashmap **ret); int ndisc_generate_addresses(Link *link, const struct in6_addr *prefix, uint8_t prefixlen, Hashmap **ret);

View File

@ -87,7 +87,8 @@ extern const struct hash_ops address_hash_ops;
bool address_can_update(const Address *existing, const Address *requesting); bool address_can_update(const Address *existing, const Address *requesting);
DECLARE_TRIVIAL_REF_UNREF_FUNC(Address, address); Address* address_ref(Address *address);
Address* address_unref(Address *address);
int address_new(Address **ret); int address_new(Address **ret);
int address_new_static(Network *network, const char *filename, unsigned section_line, Address **ret); int address_new_static(Network *network, const char *filename, unsigned section_line, Address **ret);

View File

@ -73,7 +73,8 @@ static inline bool in6_prefix_is_filtered(const struct in6_addr *prefix, uint8_t
int link_get_captive_portal(Link *link, const char **ret); int link_get_captive_portal(Link *link, const char **ret);
DECLARE_STRING_TABLE_LOOKUP(dhcp_option_data_type, DHCPOptionDataType); const char* dhcp_option_data_type_to_string(DHCPOptionDataType d) _const_;
DHCPOptionDataType dhcp_option_data_type_from_string(const char *s) _pure_;
CONFIG_PARSER_PROTOTYPE(config_parse_dhcp); CONFIG_PARSER_PROTOTYPE(config_parse_dhcp);
CONFIG_PARSER_PROTOTYPE(config_parse_dhcp_route_metric); CONFIG_PARSER_PROTOTYPE(config_parse_dhcp_route_metric);

View File

@ -26,4 +26,5 @@ CONFIG_PARSER_PROTOTYPE(config_parse_dhcp6_pd_prefix_hint);
CONFIG_PARSER_PROTOTYPE(config_parse_dhcp6_mud_url); CONFIG_PARSER_PROTOTYPE(config_parse_dhcp6_mud_url);
CONFIG_PARSER_PROTOTYPE(config_parse_dhcp6_client_start_mode); CONFIG_PARSER_PROTOTYPE(config_parse_dhcp6_client_start_mode);
DECLARE_STRING_TABLE_LOOKUP(dhcp6_client_start_mode, DHCP6ClientStartMode); const char* dhcp6_client_start_mode_to_string(DHCP6ClientStartMode i) _const_;
DHCP6ClientStartMode dhcp6_client_start_mode_from_string(const char *s) _pure_;

View File

@ -16,7 +16,8 @@ UseDomains link_get_use_domains(Link *link, NetworkConfigSource proto);
bool link_get_use_dns(Link *link, NetworkConfigSource proto); bool link_get_use_dns(Link *link, NetworkConfigSource proto);
bool link_get_use_dnr(Link *link, NetworkConfigSource proto); bool link_get_use_dnr(Link *link, NetworkConfigSource proto);
DECLARE_STRING_TABLE_LOOKUP(use_domains, UseDomains); const char* use_domains_to_string(UseDomains p) _const_;
UseDomains use_domains_from_string(const char *s) _pure_;
CONFIG_PARSER_PROTOTYPE(config_parse_domains); CONFIG_PARSER_PROTOTYPE(config_parse_domains);
CONFIG_PARSER_PROTOTYPE(config_parse_dns); CONFIG_PARSER_PROTOTYPE(config_parse_dns);

View File

@ -24,6 +24,7 @@ int link_update_ipv6ll_addrgen_mode(Link *link, sd_netlink_message *message);
int link_set_ipv6ll_stable_secret(Link *link); int link_set_ipv6ll_stable_secret(Link *link);
int link_set_ipv6ll_addrgen_mode(Link *link, IPv6LinkLocalAddressGenMode mode); int link_set_ipv6ll_addrgen_mode(Link *link, IPv6LinkLocalAddressGenMode mode);
DECLARE_STRING_TABLE_LOOKUP(ipv6_link_local_address_gen_mode, IPv6LinkLocalAddressGenMode); 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_;
CONFIG_PARSER_PROTOTYPE(config_parse_ipv6_link_local_address_gen_mode); CONFIG_PARSER_PROTOTYPE(config_parse_ipv6_link_local_address_gen_mode);

View File

@ -207,7 +207,8 @@ bool link_is_ready_to_configure_by_name(Manager *manager, const char *name, bool
void link_ntp_settings_clear(Link *link); void link_ntp_settings_clear(Link *link);
void link_dns_settings_clear(Link *link); void link_dns_settings_clear(Link *link);
DECLARE_TRIVIAL_REF_UNREF_FUNC(Link, link); Link* link_unref(Link *link);
Link* link_ref(Link *link);
DEFINE_TRIVIAL_CLEANUP_FUNC(Link*, link_unref); DEFINE_TRIVIAL_CLEANUP_FUNC(Link*, link_unref);
DEFINE_TRIVIAL_DESTRUCTOR(link_netlink_destroy_callback, Link, link_unref); DEFINE_TRIVIAL_DESTRUCTOR(link_netlink_destroy_callback, Link, link_unref);
@ -235,7 +236,8 @@ bool link_has_ipv6_connectivity(Link *link);
int link_stop_engines(Link *link, bool may_keep_dynamic); int link_stop_engines(Link *link, bool may_keep_dynamic);
DECLARE_STRING_TABLE_LOOKUP(link_state, LinkState); const char* link_state_to_string(LinkState s) _const_;
LinkState link_state_from_string(const char *s) _pure_;
int link_request_stacked_netdevs(Link *link, NetDevLocalAddressType type); int link_request_stacked_netdevs(Link *link, NetDevLocalAddressType type);
@ -250,8 +252,8 @@ int link_check_initialized(Link *link);
int manager_udev_process_link(Manager *m, sd_device *device, sd_device_action_t action); 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 manager_rtnl_process_link(sd_netlink *rtnl, sd_netlink_message *message, Manager *m);
DECLARE_STRING_TABLE_LOOKUP_TO_STRING_FALLBACK(link_flags, uint32_t); int link_flags_to_string_alloc(uint32_t flags, char **ret);
DECLARE_STRING_TABLE_LOOKUP_TO_STRING(kernel_operstate, int); const char* kernel_operstate_to_string(int t) _const_;
void link_required_operstate_for_online(Link *link, LinkOperationalStateRange *ret); void link_required_operstate_for_online(Link *link, LinkOperationalStateRange *ret);
AddressFamily link_required_family_for_online(Link *link); AddressFamily link_required_family_for_online(Link *link);

View File

@ -13,6 +13,7 @@ typedef enum LLDPMode {
int link_lldp_rx_configure(Link *link); int link_lldp_rx_configure(Link *link);
DECLARE_STRING_TABLE_LOOKUP(lldp_mode, LLDPMode); const char* lldp_mode_to_string(LLDPMode m) _const_;
LLDPMode lldp_mode_from_string(const char *s) _pure_;
CONFIG_PARSER_PROTOTYPE(config_parse_lldp_mode); CONFIG_PARSER_PROTOTYPE(config_parse_lldp_mode);

View File

@ -19,7 +19,8 @@ typedef struct Neighbor {
struct hw_addr_data ll_addr; struct hw_addr_data ll_addr;
} Neighbor; } Neighbor;
DECLARE_TRIVIAL_REF_UNREF_FUNC(Neighbor, neighbor); Neighbor* neighbor_ref(Neighbor *neighbor);
Neighbor* neighbor_unref(Neighbor *neighbor);
int neighbor_get(Link *link, const Neighbor *in, Neighbor **ret); int neighbor_get(Link *link, const Neighbor *in, Neighbor **ret);
int neighbor_remove(Neighbor *neighbor, Link *link); int neighbor_remove(Neighbor *neighbor, Link *link);

View File

@ -416,7 +416,8 @@ typedef struct Network {
char **ntp; char **ntp;
} Network; } Network;
DECLARE_TRIVIAL_REF_UNREF_FUNC(Network, network); Network *network_ref(Network *network);
Network *network_unref(Network *network);
DEFINE_TRIVIAL_CLEANUP_FUNC(Network*, network_unref); DEFINE_TRIVIAL_CLEANUP_FUNC(Network*, network_unref);
int network_load(Manager *manager, OrderedHashmap **ret); int network_load(Manager *manager, OrderedHashmap **ret);
@ -442,6 +443,8 @@ CONFIG_PARSER_PROTOTYPE(config_parse_ignore_carrier_loss);
const struct ConfigPerfItem* network_network_gperf_lookup(const char *str, GPERF_LEN_TYPE length); const struct ConfigPerfItem* network_network_gperf_lookup(const char *str, GPERF_LEN_TYPE length);
DECLARE_STRING_TABLE_LOOKUP(keep_configuration, KeepConfiguration); const char* keep_configuration_to_string(KeepConfiguration i) _const_;
KeepConfiguration keep_configuration_from_string(const char *s) _pure_;
DECLARE_STRING_TABLE_LOOKUP(activation_policy, ActivationPolicy); const char* activation_policy_to_string(ActivationPolicy i) _const_;
ActivationPolicy activation_policy_from_string(const char *s) _pure_;

View File

@ -83,7 +83,8 @@ typedef struct Request {
bool waiting_reply; bool waiting_reply;
} Request; } Request;
DECLARE_TRIVIAL_REF_UNREF_FUNC(Request, request); Request *request_ref(Request *req);
Request *request_unref(Request *req);
DEFINE_TRIVIAL_CLEANUP_FUNC(Request*, request_unref); DEFINE_TRIVIAL_CLEANUP_FUNC(Request*, request_unref);
void request_detach(Request *req); void request_detach(Request *req);
@ -150,7 +151,7 @@ static inline int link_queue_request(
int manager_process_requests(Manager *manager); int manager_process_requests(Manager *manager);
int request_call_netlink_async(sd_netlink *nl, sd_netlink_message *m, Request *req); int request_call_netlink_async(sd_netlink *nl, sd_netlink_message *m, Request *req);
DECLARE_STRING_TABLE_LOOKUP_TO_STRING(request_type, RequestType); const char* request_type_to_string(RequestType t) _const_;
typedef struct RemoveRequest RemoveRequest; typedef struct RemoveRequest RemoveRequest;
typedef int (*remove_request_netlink_handler_t)(sd_netlink *nl, sd_netlink_message *m, RemoveRequest *req); typedef int (*remove_request_netlink_handler_t)(sd_netlink *nl, sd_netlink_message *m, RemoveRequest *req);

View File

@ -56,7 +56,8 @@ int radv_add_prefix(Link *link, const struct in6_addr *prefix, uint8_t prefix_le
int link_request_radv(Link *link); int link_request_radv(Link *link);
int link_drop_radv_config(Link *link, Network *network); int link_drop_radv_config(Link *link, Network *network);
DECLARE_STRING_TABLE_LOOKUP(radv_prefix_delegation, RADVPrefixDelegation); const char* radv_prefix_delegation_to_string(RADVPrefixDelegation i) _const_;
RADVPrefixDelegation radv_prefix_delegation_from_string(const char *s) _pure_;
CONFIG_PARSER_PROTOTYPE(config_parse_router_prefix_delegation); CONFIG_PARSER_PROTOTYPE(config_parse_router_prefix_delegation);
CONFIG_PARSER_PROTOTYPE(config_parse_router_lifetime); CONFIG_PARSER_PROTOTYPE(config_parse_router_lifetime);

View File

@ -31,17 +31,18 @@ int manager_address_is_reachable(
const union in_addr_union *prefsrc, /* optional */ const union in_addr_union *prefsrc, /* optional */
Address **ret); Address **ret);
DECLARE_STRING_TABLE_LOOKUP(route_type, int); int route_type_from_string(const char *s) _pure_;
const char* route_type_to_string(int t) _const_;
DECLARE_STRING_TABLE_LOOKUP_FROM_STRING(route_scope, int); int route_scope_from_string(const char *s);
DECLARE_STRING_TABLE_LOOKUP_TO_STRING_FALLBACK(route_scope, int); int route_scope_to_string_alloc(int t, char **ret);
DECLARE_STRING_TABLE_LOOKUP_FROM_STRING(route_protocol, int); int route_protocol_from_string(const char *s);
DECLARE_STRING_TABLE_LOOKUP_TO_STRING_FALLBACK(route_protocol, int); int route_protocol_to_string_alloc(int t, char **ret);
DECLARE_STRING_TABLE_LOOKUP_FROM_STRING(route_protocol_full, int); int route_protocol_full_from_string(const char *s);
DECLARE_STRING_TABLE_LOOKUP_TO_STRING_FALLBACK(route_protocol_full, int); int route_protocol_full_to_string_alloc(int t, char **ret);
DECLARE_STRING_TABLE_LOOKUP_TO_STRING_FALLBACK(route_flags, uint32_t); int route_flags_to_string_alloc(uint32_t flags, char **ret);
int manager_get_route_table_from_string(const Manager *m, const char *s, uint32_t *ret); 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); int manager_get_route_table_to_string(const Manager *m, uint32_t table, bool append_num, char **ret);

View File

@ -74,7 +74,8 @@ void log_route_debug(const Route *route, const char *str, Manager *manager);
extern const struct hash_ops route_hash_ops; extern const struct hash_ops route_hash_ops;
extern const struct hash_ops route_hash_ops_unref; extern const struct hash_ops route_hash_ops_unref;
DECLARE_TRIVIAL_REF_UNREF_FUNC(Route, route); Route* route_ref(Route *route);
Route* route_unref(Route *route);
DEFINE_SECTION_CLEANUP_FUNCTIONS(Route, route_unref); DEFINE_SECTION_CLEANUP_FUNCTIONS(Route, route_unref);
void route_detach(Route *route); void route_detach(Route *route);

View File

@ -46,9 +46,11 @@ typedef struct RoutingPolicyRule {
struct fib_rule_port_range dport; /* FRA_DPORT_RANGE */ struct fib_rule_port_range dport; /* FRA_DPORT_RANGE */
} RoutingPolicyRule; } RoutingPolicyRule;
DECLARE_STRING_TABLE_LOOKUP(fr_act_type, int); int fr_act_type_from_string(const char *s) _pure_;
const char* fr_act_type_to_string(int t) _const_;
DECLARE_TRIVIAL_REF_UNREF_FUNC(RoutingPolicyRule, routing_policy_rule); RoutingPolicyRule* routing_policy_rule_ref(RoutingPolicyRule *rule);
RoutingPolicyRule* routing_policy_rule_unref(RoutingPolicyRule *rule);
void network_drop_invalid_routing_policy_rules(Network *network); void network_drop_invalid_routing_policy_rules(Network *network);

View File

@ -39,9 +39,11 @@ int link_set_sysctl(Link *link);
int link_set_ipv6_mtu(Link *link, int log_level); int link_set_ipv6_mtu(Link *link, int log_level);
int link_set_ipv6_mtu_async(Link *link); int link_set_ipv6_mtu_async(Link *link);
DECLARE_STRING_TABLE_LOOKUP(ipv6_privacy_extensions, IPv6PrivacyExtensions); const char* ipv6_privacy_extensions_to_string(IPv6PrivacyExtensions i) _const_;
IPv6PrivacyExtensions ipv6_privacy_extensions_from_string(const char *s) _pure_;
DECLARE_STRING_TABLE_LOOKUP(ip_reverse_path_filter, IPReversePathFilter); const char* ip_reverse_path_filter_to_string(IPReversePathFilter i) _const_;
IPReversePathFilter ip_reverse_path_filter_from_string(const char *s) _pure_;
CONFIG_PARSER_PROTOTYPE(config_parse_ipv6_privacy_extensions); CONFIG_PARSER_PROTOTYPE(config_parse_ipv6_privacy_extensions);
CONFIG_PARSER_PROTOTYPE(config_parse_ip_reverse_path_filter); CONFIG_PARSER_PROTOTYPE(config_parse_ip_reverse_path_filter);
@ -57,6 +59,7 @@ typedef enum IPv4ForceIgmpVersion {
_IPV4_FORCE_IGMP_VERSION_INVALID = -EINVAL, _IPV4_FORCE_IGMP_VERSION_INVALID = -EINVAL,
} IPv4ForceIgmpVersion; } IPv4ForceIgmpVersion;
DECLARE_STRING_TABLE_LOOKUP(ipv4_force_igmp_version, IPv4ForceIgmpVersion); const char* ipv4_force_igmp_version_to_string(IPv4ForceIgmpVersion i) _const_;
IPv4ForceIgmpVersion ipv4_force_igmp_version_from_string(const char *s) _pure_;
CONFIG_PARSER_PROTOTYPE(config_parse_ipv4_force_igmp_version); CONFIG_PARSER_PROTOTYPE(config_parse_ipv4_force_igmp_version);

View File

@ -47,9 +47,10 @@ CONFIG_PARSER_PROTOTYPE(config_parse_link_local_address_family);
CONFIG_PARSER_PROTOTYPE(config_parse_ip_masquerade); CONFIG_PARSER_PROTOTYPE(config_parse_ip_masquerade);
CONFIG_PARSER_PROTOTYPE(config_parse_mud_url); CONFIG_PARSER_PROTOTYPE(config_parse_mud_url);
DECLARE_STRING_TABLE_LOOKUP(network_config_source, NetworkConfigSource); const char* network_config_source_to_string(NetworkConfigSource s) _const_;
NetworkConfigSource network_config_source_from_string(const char* s) _pure_;
DECLARE_STRING_TABLE_LOOKUP_TO_STRING_FALLBACK(network_config_state, NetworkConfigState); int network_config_state_to_string_alloc(NetworkConfigState s, char **ret);
#define DEFINE_NETWORK_CONFIG_STATE_FUNCTIONS(type, name) \ #define DEFINE_NETWORK_CONFIG_STATE_FUNCTIONS(type, name) \
static inline void name##_update_state( \ static inline void name##_update_state( \
@ -123,19 +124,24 @@ DECLARE_STRING_TABLE_LOOKUP_TO_STRING_FALLBACK(network_config_state, NetworkConf
0); \ 0); \
} }
DECLARE_STRING_TABLE_LOOKUP(address_family, AddressFamily); const char* address_family_to_string(AddressFamily b) _const_;
AddressFamily address_family_from_string(const char *s) _pure_;
DECLARE_STRING_TABLE_LOOKUP_FROM_STRING(link_local_address_family, AddressFamily); AddressFamily link_local_address_family_from_string(const char *s) _pure_;
DECLARE_STRING_TABLE_LOOKUP(routing_policy_rule_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(nexthop_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(duplicate_address_detection_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_FROM_STRING(dhcp_deprecated_address_family, AddressFamily); AddressFamily dhcp_deprecated_address_family_from_string(const char *s) _pure_;
DECLARE_STRING_TABLE_LOOKUP(dhcp_lease_server_type, sd_dhcp_lease_server_type_t); 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_;
bool link_should_mark_config(Link *link, bool only_static, NetworkConfigSource source, uint8_t protocol); bool link_should_mark_config(Link *link, bool only_static, NetworkConfigSource source, uint8_t protocol);

View File

@ -74,7 +74,8 @@ extern const QDiscVTable * const qdisc_vtable[_QDISC_KIND_MAX];
DEFINE_NETWORK_CONFIG_STATE_FUNCTIONS(QDisc, qdisc); DEFINE_NETWORK_CONFIG_STATE_FUNCTIONS(QDisc, qdisc);
DECLARE_TRIVIAL_REF_UNREF_FUNC(QDisc, qdisc); QDisc* qdisc_ref(QDisc *qdisc);
QDisc* qdisc_unref(QDisc *qdisc);
int qdisc_new_static(QDiscKind kind, Network *network, const char *filename, unsigned section_line, QDisc **ret); int qdisc_new_static(QDiscKind kind, Network *network, const char *filename, unsigned section_line, QDisc **ret);
void qdisc_mark_recursive(QDisc *qdisc); void qdisc_mark_recursive(QDisc *qdisc);

Some files were not shown because too many files have changed in this diff Show More