From 86cc9c3524413cb04c0e667627dadbbecd9e6736 Mon Sep 17 00:00:00 2001 From: Neale Pickett Date: Wed, 13 Jun 2012 11:11:26 -0600 Subject: [PATCH] pointscli no longer fails on success --- packages/00common/src/pointscli.c | 61 ++++++++++++++++--------------- packages/p2/bin/p2console | 2 +- 2 files changed, 33 insertions(+), 30 deletions(-) diff --git a/packages/00common/src/pointscli.c b/packages/00common/src/pointscli.c index c2841ff..5d4185d 100644 --- a/packages/00common/src/pointscli.c +++ b/packages/00common/src/pointscli.c @@ -7,38 +7,41 @@ int main(int argc, char *argv[]) { - int points; - int ret; - char comment[512]; + int points; + int ret; + char comment[512]; - if (argc != 5) { - fprintf(stderr, "Usage: pointscli TEAM CATEGORY POINTS 'COMMENT'\n"); - return EX_USAGE; - } + if (argc != 5) { + fprintf(stderr, + "Usage: pointscli TEAM CATEGORY POINTS 'COMMENT'\n"); + return EX_USAGE; + } - points = atoi(argv[3]); - if (0 == points) { - fprintf(stderr, "Error: award 0 points?\n"); - return EX_USAGE; - } + points = atoi(argv[3]); + if (0 == points) { + fprintf(stderr, "Error: award 0 points?\n"); + 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); - switch (ret) { - case ERR_GENERAL: - perror("General error"); - return EX_UNAVAILABLE; - case ERR_NOTEAM: - fprintf(stderr, "No such team\n"); - return EX_NOUSER; - case ERR_CLAIMED: - fprintf(stderr, "Duplicate entry\n"); - return EX_DATAERR; - default: - fprintf(stderr, "Error %d\n", ret); - return EX_SOFTWARE; - } + ret = award_points(argv[1], argv[2], points, comment); + switch (ret) { + case 0: + return 0; + case ERR_GENERAL: + perror("General error"); + return EX_UNAVAILABLE; + case ERR_NOTEAM: + fprintf(stderr, "No such team\n"); + return EX_NOUSER; + case ERR_CLAIMED: + fprintf(stderr, "Duplicate entry\n"); + return EX_DATAERR; + default: + fprintf(stderr, "Error %d\n", ret); + return EX_SOFTWARE; + } - return 0; + return 0; } diff --git a/packages/p2/bin/p2console b/packages/p2/bin/p2console index 8a2d6e5..6b82bfa 100755 --- a/packages/p2/bin/p2console +++ b/packages/p2/bin/p2console @@ -116,7 +116,7 @@ EOD fn=$BASE/$hash/$cat.$points if log $hash | grep -Fxq "$cat $points"; then 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." else echo "Error recording points. Tell the officials!"