From 7d8c71019c111134c15a7903ec9acfb5713755fe Mon Sep 17 00:00:00 2001 From: Mattias Andrée Date: Mon, 28 Dec 2015 22:45:45 +0100 Subject: partially implement satd-list, satd-rm, and satd-run MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Mattias Andrée --- src/satd-run.c | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) (limited to 'src/satd-run.c') diff --git a/src/satd-run.c b/src/satd-run.c index 7cccb57..36b66e2 100644 --- a/src/satd-run.c +++ b/src/satd-run.c @@ -39,6 +39,8 @@ main(int argc, char *argv[]) size_t n = 0; char *message = NULL; char **msg_argv = NULL; + char **arg; + int rc = 0; /* Receive and validate message. */ t (readall(SOCK_FILENO, &message, &n) || (n && message[n - 1])); @@ -48,7 +50,27 @@ main(int argc, char *argv[]) t (!msg_argv); } - return 0; + /* Perform action. */ + if (msg_argv) { + for (arg = msg_argv; *arg; arg++) + t (remove_job(*arg, 1) && errno); + } else { + for (;;) + if (remove_job(NULL, 1)) + t (errno); + } + +done: + /* Cleanup. */ + shutdown(SOCK_FILENO, SHUT_WR); + close(SOCK_FILENO); + free(msg_argv); + free(message); + return rc; fail: + if (send_string(SOCK_FILENO, STDERR_FILENO, argv[0], ": ", strerror(errno), "\n", NULL)) + perror(argv[0]); + rc = 1; + goto done; } -- cgit v1.2.3-70-g09d2