summaryrefslogtreecommitdiff
path: root/src/shared/strv.c
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2014-07-02 12:23:36 +0200
committerLennart Poettering <lennart@poettering.net>2014-07-02 12:23:36 +0200
commit9a00f57a5ba7ed431e6bac8d8b36518708503b4e (patch)
treee548891199d5ff830aa74f40cd23e63660dec41a /src/shared/strv.c
parentcd4ba18a849dc82735b3787cf99bd3fdc404d5ae (diff)
path: add new "systemd-path" utility for querying paths described in file-hierarchy(7)
This new tool is based on "sd-path", a new (so far unexported) API for libsystemd, that can hopefully grow into a workable API covering /opt and more one day.
Diffstat (limited to 'src/shared/strv.c')
-rw-r--r--src/shared/strv.c34
1 files changed, 34 insertions, 0 deletions
diff --git a/src/shared/strv.c b/src/shared/strv.c
index 1ef0b26a25..b4c476eff2 100644
--- a/src/shared/strv.c
+++ b/src/shared/strv.c
@@ -378,6 +378,30 @@ int strv_push(char ***l, char *value) {
return 0;
}
+int strv_push_prepend(char ***l, char *value) {
+ char **c;
+ unsigned n, i;
+
+ if (!value)
+ return 0;
+
+ n = strv_length(*l);
+ c = new(char*, n + 2);
+ if (!c)
+ return -ENOMEM;
+
+ for (i = 0; i < n; i++)
+ c[i+1] = (*l)[i];
+
+ c[0] = value;
+ c[n+1] = NULL;
+
+ free(*l);
+ *l = c;
+
+ return 0;
+}
+
int strv_consume(char ***l, char *value) {
int r;
@@ -388,6 +412,16 @@ int strv_consume(char ***l, char *value) {
return r;
}
+int strv_consume_prepend(char ***l, char *value) {
+ int r;
+
+ r = strv_push_prepend(l, value);
+ if (r < 0)
+ free(value);
+
+ return r;
+}
+
int strv_extend(char ***l, const char *value) {
char *v;