From f97add9041c7cf330d2743b1dca9267676bdaa72 Mon Sep 17 00:00:00 2001 From: David Oberhollenzer Date: Sun, 25 Mar 2018 01:55:08 +0100 Subject: Add file with service enum conversion functions Signed-off-by: David Oberhollenzer --- lib/include/service.h | 8 ++++++++ lib/include/util.h | 7 +++++++ 2 files changed, 15 insertions(+) (limited to 'lib/include') diff --git a/lib/include/service.h b/lib/include/service.h index 6808bdd..dd7700c 100644 --- a/lib/include/service.h +++ b/lib/include/service.h @@ -91,5 +91,13 @@ void del_srv_list(service_list_t *list); */ service_t *srv_tsort(service_t *list); +const char *svc_type_to_string(int type); + +int svc_type_from_string(const char *type); + +const char *svc_target_to_string(int target); + +int svc_target_from_string(const char *target); + #endif /* SERVICE_H */ diff --git a/lib/include/util.h b/lib/include/util.h index ed5dac2..9ba9ffb 100644 --- a/lib/include/util.h +++ b/lib/include/util.h @@ -69,6 +69,13 @@ int splitkv(char *line, char **key, char **value); */ const enum_map_t *enum_by_name(const enum_map_t *map, const char *name); +/* + Search through an array of enum_map_t entries to resolve a numeric + value to a string name. The end of the map is indicated by a sentinel + entry with the name set to NULL. +*/ +const char *enum_to_name(const enum_map_t *map, int value); + /* Create a copy of the input string inp, but replace all occourances of % with argv[number] if the number is within the bounds -- cgit v1.2.3