aboutsummaryrefslogtreecommitdiffstats
path: root/src/satrm.c
diff options
context:
space:
mode:
authorMattias Andrée <maandree@member.fsf.org>2015-12-28 01:43:39 +0100
committerMattias Andrée <maandree@member.fsf.org>2015-12-28 01:43:39 +0100
commit0de4466f7cefb55584b24589acaca2284fea8d24 (patch)
tree3097f66bc66a0e132902243bc6ef97f699a56710 /src/satrm.c
parentthe socket shall be opened on fd 3 (you will see why later) (diff)
downloadsat-0de4466f7cefb55584b24589acaca2284fea8d24.tar.gz
sat-0de4466f7cefb55584b24589acaca2284fea8d24.tar.bz2
sat-0de4466f7cefb55584b24589acaca2284fea8d24.tar.xz
fix errors and tidy up
Signed-off-by: Mattias Andrée <maandree@member.fsf.org>
Diffstat (limited to '')
-rw-r--r--src/satrm.c50
1 files changed, 7 insertions, 43 deletions
diff --git a/src/satrm.c b/src/satrm.c
index 28bea0b..0a9eccf 100644
--- a/src/satrm.c
+++ b/src/satrm.c
@@ -19,35 +19,17 @@
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE.
*/
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <errno.h>
-
#include "client.h"
+#include "common.h"
-/**
- * The name of the process.
- */
-char *argv0 = "satrm";
+COMMAND("satrm")
+USAGE("JOB-ID...")
/**
- * Print usage information.
- */
-static void
-usage(void)
-{
- fprintf(stderr, "usage: %s JOB-ID...\n",
- strrchr(argv0) ? (strrchr(argv0) + 1) : argv0);
- exit(2);
-}
-
-
-/**
* Remove a job from the queue of jobs.
*
* @param argc Should be 2.
@@ -63,31 +45,13 @@ main(int argc, char *argv[])
{
size_t n;
char *msg;
- int i;
if (argc > 0) argv0 = argv[0];
if (argc < 2) usage();
- if (!strcmp(argv[1], "--")
- argv++, argc--;
- for (i = 1; i < argc; i++)
- if (strchr("-", 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;
+ NO_OPTIONS;
+ CONSTRUCT_MESSAGE;
+ SEND(SAT_REMOVE, n, msg));
+ END(msg);
}