2010-09-03 21:00:02 -06:00
|
|
|
#include <stdio.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <sysexits.h>
|
2012-05-30 18:04:24 -06:00
|
|
|
#include <time.h>
|
2010-09-03 21:00:02 -06:00
|
|
|
#include "common.h"
|
|
|
|
|
|
|
|
int
|
|
|
|
main(int argc, char *argv[])
|
|
|
|
{
|
|
|
|
int points;
|
|
|
|
int ret;
|
2012-05-30 18:04:24 -06:00
|
|
|
char comment[512];
|
2010-09-03 21:00:02 -06:00
|
|
|
|
2012-05-30 18:04:24 -06:00
|
|
|
if (argc != 5) {
|
|
|
|
fprintf(stderr, "Usage: pointscli TEAM CATEGORY POINTS 'COMMENT'\n");
|
2010-09-03 21:00:02 -06:00
|
|
|
return EX_USAGE;
|
|
|
|
}
|
|
|
|
|
|
|
|
points = atoi(argv[3]);
|
|
|
|
if (0 == points) {
|
|
|
|
fprintf(stderr, "Error: award 0 points?\n");
|
|
|
|
return EX_USAGE;
|
|
|
|
}
|
|
|
|
|
2012-05-30 18:04:24 -06:00
|
|
|
snprintf(comment, sizeof comment, "--%s", argv[4]);
|
|
|
|
|
|
|
|
ret = award_points(argv[1], argv[2], points, comment);
|
2010-09-03 21:00:02 -06:00
|
|
|
switch (ret) {
|
2012-05-30 18:04:24 -06:00
|
|
|
case ERR_GENERAL:
|
|
|
|
perror("General error");
|
|
|
|
return EX_UNAVAILABLE;
|
|
|
|
case ERR_NOTEAM:
|
2010-09-03 21:00:02 -06:00
|
|
|
fprintf(stderr, "No such team\n");
|
|
|
|
return EX_NOUSER;
|
2012-05-30 18:04:24 -06:00
|
|
|
case ERR_CLAIMED:
|
|
|
|
fprintf(stderr, "Duplicate entry\n");
|
|
|
|
return EX_DATAERR;
|
|
|
|
default:
|
|
|
|
fprintf(stderr, "Error %d\n", ret);
|
|
|
|
return EX_SOFTWARE;
|
2010-09-03 21:00:02 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|