summaryrefslogtreecommitdiff
path: root/src/shared/util.c
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2012-10-19 04:52:51 +0200
committerLennart Poettering <lennart@poettering.net>2012-10-19 04:53:46 +0200
commit8c7c140fcab0592735d22168657a143969a4c2bf (patch)
treed9094779472102860625180329e3b1ac9b324e9b /src/shared/util.c
parent857a493d55f94731394e4d9f61ffce661858e9a0 (diff)
util: change endswith() to return a pointer to the suffix
Diffstat (limited to 'src/shared/util.c')
-rw-r--r--src/shared/util.c11
1 files changed, 7 insertions, 4 deletions
diff --git a/src/shared/util.c b/src/shared/util.c
index ef30cb2dab..42a2e27308 100644
--- a/src/shared/util.c
+++ b/src/shared/util.c
@@ -195,7 +195,7 @@ struct timeval *timeval_store(struct timeval *tv, usec_t u) {
return tv;
}
-bool endswith(const char *s, const char *postfix) {
+char* endswith(const char *s, const char *postfix) {
size_t sl, pl;
assert(s);
@@ -205,12 +205,15 @@ bool endswith(const char *s, const char *postfix) {
pl = strlen(postfix);
if (pl == 0)
- return true;
+ return (char*) s + sl;
if (sl < pl)
- return false;
+ return NULL;
+
+ if (memcmp(s + sl - pl, postfix, pl) != 0)
+ return NULL;
- return memcmp(s + sl - pl, postfix, pl) == 0;
+ return (char*) s + sl - pl;
}
bool startswith(const char *s, const char *prefix) {