summaryrefslogtreecommitdiff
path: root/execute.c
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2010-04-10 17:46:41 +0200
committerLennart Poettering <lennart@poettering.net>2010-04-10 18:00:34 +0200
commit26fd040d4a8024f1777154c275796e235a0f7451 (patch)
tree2c9deb6cf572255c552f7ee2d7f94fcd87e61a00 /execute.c
parent1a63a750108b280070ed43e0dc02adb2c99c97cb (diff)
execute: introduce exec_command_set() for easy setting for command lines
Diffstat (limited to 'execute.c')
-rw-r--r--execute.c28
1 files changed, 28 insertions, 0 deletions
diff --git a/execute.c b/execute.c
index 46a9832081..6cf6615da4 100644
--- a/execute.c
+++ b/execute.c
@@ -1061,6 +1061,34 @@ void exec_command_append_list(ExecCommand **l, ExecCommand *e) {
*l = e;
}
+int exec_command_set(ExecCommand *c, const char *path, ...) {
+ va_list ap;
+ char **l, *p;
+
+ assert(c);
+ assert(path);
+
+ va_start(ap, path);
+ l = strv_new_ap(path, ap);
+ va_end(ap);
+
+ if (!l)
+ return -ENOMEM;
+
+ if (!(p = strdup(path))) {
+ strv_free(l);
+ return -ENOMEM;
+ }
+
+ free(c->path);
+ c->path = p;
+
+ strv_free(c->argv);
+ c->argv = l;
+
+ return 0;
+}
+
static const char* const exec_output_table[_EXEC_OUTPUT_MAX] = {
[EXEC_OUTPUT_CONSOLE] = "console",
[EXEC_OUTPUT_NULL] = "null",