aboutsummaryrefslogtreecommitdiffstats
path: root/src/satr.c
diff options
context:
space:
mode:
authorMattias Andrée <maandree@member.fsf.org>2015-12-25 22:06:56 +0100
committerMattias Andrée <maandree@member.fsf.org>2015-12-25 22:06:56 +0100
commit196abe367c46cf3c2337b4b1da8bb2c084065c7d (patch)
tree1c55433b9195b6c398ab3ab26a867d0b794ed806 /src/satr.c
parentimprove send_command (diff)
downloadsat-196abe367c46cf3c2337b4b1da8bb2c084065c7d.tar.gz
sat-196abe367c46cf3c2337b4b1da8bb2c084065c7d.tar.bz2
sat-196abe367c46cf3c2337b4b1da8bb2c084065c7d.tar.xz
satr run select jobs + satrm can remove multiple jobs
Signed-off-by: Mattias Andrée <maandree@member.fsf.org>
Diffstat (limited to 'src/satr.c')
-rw-r--r--src/satr.c32
1 files changed, 28 insertions, 4 deletions
diff --git a/src/satr.c b/src/satr.c
index df85ee2..b3ebd62 100644
--- a/src/satr.c
+++ b/src/satr.c
@@ -40,7 +40,7 @@ char *argv0 = "satr";
static void
usage(void)
{
- fprintf(stderr, "usage: %s\n",
+ fprintf(stderr, "usage: %s [JOB-ID]...\n",
strrchr(argv0) ? (strrchr(argv0) + 1) : argv0);
exit(2);
}
@@ -59,11 +59,35 @@ usage(void)
int
main(int argc, char *argv[])
{
+ size_t n = 0;
+ char *msg = NULL;
+ int i;
+
if (argc > 0) argv0 = argv[0];
- if (argc > 1) usage(); /* TODO possibility to select job */
+ if (argc < 2)
+ goto run;
+ 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_RUN, 0, NULL))
- return errno ? (perror(argv0), 1) : 3;
+run:
+ if (send_command(SAT_RUN, n, msg)) {
+ if (errno)
+ goto fail;
+ free(msg);
+ return 3;
+ }
return 0;
+
+fail:
+ perror(*argv);
+ free(msg);
+ return 1;
}