From 196abe367c46cf3c2337b4b1da8bb2c084065c7d Mon Sep 17 00:00:00 2001 From: Mattias Andrée Date: Fri, 25 Dec 2015 22:06:56 +0100 Subject: satr run select jobs + satrm can remove multiple jobs MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Mattias Andrée --- src/satrm.c | 32 +++++++++++++++++++++++++++----- 1 file changed, 27 insertions(+), 5 deletions(-) (limited to 'src/satrm.c') diff --git a/src/satrm.c b/src/satrm.c index b3dafcd..8097b18 100644 --- a/src/satrm.c +++ b/src/satrm.c @@ -40,7 +40,7 @@ char *argv0 = "satrm"; static void usage(void) { - fprintf(stderr, "usage: %s JOB-ID\n", + fprintf(stderr, "usage: %s JOB-ID...\n", strrchr(argv0) ? (strrchr(argv0) + 1) : argv0); exit(2); } @@ -60,11 +60,33 @@ usage(void) int main(int argc, char *argv[]) { - if (argc > 0) argv0 = argv[0]; - if (argc != 2) usage(); + size_t n; + char *msg; + int i; - if (send_command(SAT_REMOVE, 0, argv[1])) - return errno ? (perror(argv0), 1) : 3; + if (argc > 0) argv0 = argv[0]; + if (argc < 2) usage(); + if (!strcmp(argv[1], "--") + argv++, argc--; + for (i = 1; i < argc; i++) + if (argv[i][0] == '-') + usage(); + + if (!(msg = malloc(n = measure_array(argv + 1)))) + goto fail; + store_array(msg, argv + 1); + + if (send_command(SAT_REMOVE, n, msg)) { + if (errno) + goto fail; + free(msg); + return 3; + } return 0; + +fail: + perror(*argv); + free(msg); + return 1; } -- cgit v1.2.3-70-g09d2