summaryrefslogtreecommitdiff
path: root/src/util.h
diff options
context:
space:
mode:
authorMichal Schmidt <mschmidt@redhat.com>2011-09-23 09:39:40 +0200
committerMichal Schmidt <mschmidt@redhat.com>2011-09-23 10:30:19 +0200
commit4e240ab0c93f4d454b065eef7074132969ac6f16 (patch)
tree9b25619b52b70a6ac2c78b34aaeda998fe36deb7 /src/util.h
parent764e9b5f073e1d5216de150045ec85475835fe3c (diff)
util: improve signal_to_string, signal_from_string
signal_to_string: Produce names for SIGRTMIN+n. Never give an "n/a" result. In the worst case give the number itself as a string. signal_from_string: Parse "RTMIN+n". Parse any valid signal number.
Diffstat (limited to 'src/util.h')
-rw-r--r--src/util.h8
1 files changed, 5 insertions, 3 deletions
diff --git a/src/util.h b/src/util.h
index 3e1f46d826..e254bc7884 100644
--- a/src/util.h
+++ b/src/util.h
@@ -288,13 +288,13 @@ int make_null_stdio(void);
unsigned long long random_ull(void);
-#define DEFINE_STRING_TABLE_LOOKUP(name,type) \
- const char *name##_to_string(type i) { \
+#define __DEFINE_STRING_TABLE_LOOKUP(name,type,scope) \
+ scope const char *name##_to_string(type i) { \
if (i < 0 || i >= (type) ELEMENTSOF(name##_table)) \
return NULL; \
return name##_table[i]; \
} \
- type name##_from_string(const char *s) { \
+ scope type name##_from_string(const char *s) { \
type i; \
unsigned u = 0; \
assert(s); \
@@ -309,6 +309,8 @@ unsigned long long random_ull(void);
} \
struct __useless_struct_to_allow_trailing_semicolon__
+#define DEFINE_STRING_TABLE_LOOKUP(name,type) __DEFINE_STRING_TABLE_LOOKUP(name,type,)
+#define DEFINE_PRIVATE_STRING_TABLE_LOOKUP(name,type) __DEFINE_STRING_TABLE_LOOKUP(name,type,static)
int fd_nonblock(int fd, bool nonblock);
int fd_cloexec(int fd, bool cloexec);