summaryrefslogtreecommitdiff
path: root/src/basic/util.c
diff options
context:
space:
mode:
authorEvgeny Vereshchagin <evvers@ya.ru>2015-10-14 16:28:40 +0000
committerEvgeny Vereshchagin <evvers@ya.ru>2015-10-14 16:35:24 +0000
commitadb8ec96f2918fa7b39722ead6b2fe949fc3a7c5 (patch)
treedbef270f0250d5152b72c56f203deacc8e46da6b /src/basic/util.c
parent75d73dc9d08c39ca5e413e4045daf1de61ea7ee6 (diff)
util: add functions for validating syslog level and facility
Diffstat (limited to 'src/basic/util.c')
-rw-r--r--src/basic/util.c8
1 files changed, 8 insertions, 0 deletions
diff --git a/src/basic/util.c b/src/basic/util.c
index ca5e4befa0..8b896a2df3 100644
--- a/src/basic/util.c
+++ b/src/basic/util.c
@@ -3699,6 +3699,10 @@ static const char *const log_facility_unshifted_table[LOG_NFACILITIES] = {
DEFINE_STRING_TABLE_LOOKUP_WITH_FALLBACK(log_facility_unshifted, int, LOG_FAC(~0));
+bool log_facility_unshifted_is_valid(int facility) {
+ return facility >= 0 && facility <= LOG_FAC(~0);
+}
+
static const char *const log_level_table[] = {
[LOG_EMERG] = "emerg",
[LOG_ALERT] = "alert",
@@ -3712,6 +3716,10 @@ static const char *const log_level_table[] = {
DEFINE_STRING_TABLE_LOOKUP_WITH_FALLBACK(log_level, int, LOG_DEBUG);
+bool log_level_is_valid(int level) {
+ return level >= 0 && level <= LOG_DEBUG;
+}
+
static const char* const sched_policy_table[] = {
[SCHED_OTHER] = "other",
[SCHED_BATCH] = "batch",