summaryrefslogtreecommitdiff
path: root/src/shared
diff options
context:
space:
mode:
authorThomas Hindoe Paaboel Andersen <phomes@gmail.com>2013-02-12 21:47:37 +0100
committerLennart Poettering <lennart@poettering.net>2013-02-13 00:56:13 +0100
commitb43d1d01eabe2cbbf393e8f56b76e182c6069c4c (patch)
tree2c15db7971c0514f3e3f741b44fbe42bd7802fbd /src/shared
parent641906e9366891e0ad3e6e38b7396a427678c4cf (diff)
util: introduce strcaseeq/strncaseeq
Diffstat (limited to 'src/shared')
-rw-r--r--src/shared/calendarspec.c8
-rw-r--r--src/shared/util.c4
-rw-r--r--src/shared/util.h2
3 files changed, 8 insertions, 6 deletions
diff --git a/src/shared/calendarspec.c b/src/shared/calendarspec.c
index c2eae3f139..cc680779b5 100644
--- a/src/shared/calendarspec.c
+++ b/src/shared/calendarspec.c
@@ -653,7 +653,7 @@ int calendar_spec_from_string(const char *p, CalendarSpec **spec) {
if (!c)
return -ENOMEM;
- if (strcasecmp(p, "hourly") == 0) {
+ if (strcaseeq(p, "hourly")) {
r = const_chain(0, &c->minute);
if (r < 0)
goto fail;
@@ -661,7 +661,7 @@ int calendar_spec_from_string(const char *p, CalendarSpec **spec) {
if (r < 0)
goto fail;
- } else if (strcasecmp(p, "daily") == 0) {
+ } else if (strcaseeq(p, "daily")) {
r = const_chain(0, &c->hour);
if (r < 0)
goto fail;
@@ -672,7 +672,7 @@ int calendar_spec_from_string(const char *p, CalendarSpec **spec) {
if (r < 0)
goto fail;
- } else if (strcasecmp(p, "monthly") == 0) {
+ } else if (strcaseeq(p, "monthly")) {
r = const_chain(1, &c->day);
if (r < 0)
goto fail;
@@ -686,7 +686,7 @@ int calendar_spec_from_string(const char *p, CalendarSpec **spec) {
if (r < 0)
goto fail;
- } else if (strcasecmp(p, "weekly") == 0) {
+ } else if (strcaseeq(p, "weekly")) {
c->weekdays_bits = 1;
diff --git a/src/shared/util.c b/src/shared/util.c
index 8dceb82051..aa0532a2be 100644
--- a/src/shared/util.c
+++ b/src/shared/util.c
@@ -218,9 +218,9 @@ void close_many(const int fds[], unsigned n_fd) {
int parse_boolean(const char *v) {
assert(v);
- if (streq(v, "1") || v[0] == 'y' || v[0] == 'Y' || v[0] == 't' || v[0] == 'T' || !strcasecmp(v, "on"))
+ if (streq(v, "1") || v[0] == 'y' || v[0] == 'Y' || v[0] == 't' || v[0] == 'T' || strcaseeq(v, "on"))
return 1;
- else if (streq(v, "0") || v[0] == 'n' || v[0] == 'N' || v[0] == 'f' || v[0] == 'F' || !strcasecmp(v, "off"))
+ else if (streq(v, "0") || v[0] == 'n' || v[0] == 'N' || v[0] == 'f' || v[0] == 'F' || strcaseeq(v, "off"))
return 0;
return -EINVAL;
diff --git a/src/shared/util.h b/src/shared/util.h
index cd13457528..3ad90ddce4 100644
--- a/src/shared/util.h
+++ b/src/shared/util.h
@@ -65,6 +65,8 @@ size_t page_size(void);
#define streq(a,b) (strcmp((a),(b)) == 0)
#define strneq(a, b, n) (strncmp((a), (b), (n)) == 0)
+#define strcaseeq(a,b) (strcasecmp((a),(b)) == 0)
+#define strncaseeq(a, b, n) (strncasecmp((a), (b), (n)) == 0)
bool streq_ptr(const char *a, const char *b);