summaryrefslogtreecommitdiff
path: root/util.c
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2010-01-26 07:02:51 +0100
committerLennart Poettering <lennart@poettering.net>2010-01-26 07:02:51 +0100
commit44d8db9e5aa86165c97289f6c78a7e42bac78362 (patch)
treedc17149a1d8286eea1fb40b101ca2706a5427dc0 /util.c
parent75787bb7136e064ee623aaee00ec76a7f024c91a (diff)
downloadsystemd-44d8db9e5aa86165c97289f6c78a7e42bac78362.tar.gz
various cleanups
Diffstat (limited to 'util.c')
-rw-r--r--util.c30
1 files changed, 25 insertions, 5 deletions
diff --git a/util.c b/util.c
index 2e310f9f68..b4b07e9d1b 100644
--- a/util.c
+++ b/util.c
@@ -100,9 +100,9 @@ int close_nointr(int fd) {
int parse_boolean(const char *v) {
assert(v);
- if (!strcmp(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' || !strcasecmp(v, "on"))
return 1;
- else if (!strcmp(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' || !strcasecmp(v, "off"))
return 0;
return -EINVAL;
@@ -216,9 +216,6 @@ int safe_atolli(const char *s, long long int *ret_lli) {
return 0;
}
-/* What is interpreted as whitespace? */
-#define WHITESPACE " \t\n"
-
/* Split a string into words. */
char *split_spaces(const char *c, size_t *l, char **state) {
char *current;
@@ -266,6 +263,9 @@ char *split_quoted(const char *c, size_t *l, char **state) {
*state = current+*l;
}
+ /* FIXME: Cannot deal with strings that have spaces AND ticks
+ * in them */
+
return (char*) current;
}
@@ -382,3 +382,23 @@ finish:
fclose(f);
return r;
}
+
+char *strappend(const char *s, const char *suffix) {
+ size_t a, b;
+ char *r;
+
+ assert(s);
+ assert(suffix);
+
+ a = strlen(s);
+ b = strlen(suffix);
+
+ if (!(r = new(char, a+b+1)))
+ return NULL;
+
+ memcpy(r, s, a);
+ memcpy(r+a, suffix, b);
+ r[a+b] = 0;
+
+ return r;
+}