pointscli no longer fails on success

This commit is contained in:
Neale Pickett 2012-06-13 11:11:26 -06:00
parent 77c940437c
commit ac038ac3f1
2 changed files with 33 additions and 30 deletions

View File

@ -7,38 +7,41 @@
int int
main(int argc, char *argv[]) main(int argc, char *argv[])
{ {
int points; int points;
int ret; int ret;
char comment[512]; char comment[512];
if (argc != 5) { if (argc != 5) {
fprintf(stderr, "Usage: pointscli TEAM CATEGORY POINTS 'COMMENT'\n"); fprintf(stderr,
return EX_USAGE; "Usage: pointscli TEAM CATEGORY POINTS 'COMMENT'\n");
} return EX_USAGE;
}
points = atoi(argv[3]); points = atoi(argv[3]);
if (0 == points) { if (0 == points) {
fprintf(stderr, "Error: award 0 points?\n"); fprintf(stderr, "Error: award 0 points?\n");
return EX_USAGE; return EX_USAGE;
} }
snprintf(comment, sizeof comment, "--%s", argv[4]); snprintf(comment, sizeof comment, "--%s", argv[4]);
ret = award_points(argv[1], argv[2], points, comment); ret = award_points(argv[1], argv[2], points, comment);
switch (ret) { switch (ret) {
case ERR_GENERAL: case 0:
perror("General error"); return 0;
return EX_UNAVAILABLE; case ERR_GENERAL:
case ERR_NOTEAM: perror("General error");
fprintf(stderr, "No such team\n"); return EX_UNAVAILABLE;
return EX_NOUSER; case ERR_NOTEAM:
case ERR_CLAIMED: fprintf(stderr, "No such team\n");
fprintf(stderr, "Duplicate entry\n"); return EX_NOUSER;
return EX_DATAERR; case ERR_CLAIMED:
default: fprintf(stderr, "Duplicate entry\n");
fprintf(stderr, "Error %d\n", ret); return EX_DATAERR;
return EX_SOFTWARE; default:
} fprintf(stderr, "Error %d\n", ret);
return EX_SOFTWARE;
}
return 0; return 0;
} }

View File

@ -116,7 +116,7 @@ EOD
fn=$BASE/$hash/$cat.$points fn=$BASE/$hash/$cat.$points
if log $hash | grep -Fxq "$cat $points"; then if log $hash | grep -Fxq "$cat $points"; then
echo "You've already received points for this answer." echo "You've already received points for this answer."
elif pointscli $hash $cat $points p2console; then elif /opt/p2/bin/pointscli $hash $cat $points p2console; then
echo "You get $points more points in the $cat category." echo "You get $points more points in the $cat category."
else else
echo "Error recording points. Tell the officials!" echo "Error recording points. Tell the officials!"