From 2733782926e6d892eb37e48dbc233ca0c78dc452 Mon Sep 17 00:00:00 2001 From: Keith Packard Date: Sat, 5 Jul 2003 05:41:10 +0000 Subject: [PATCH] Add --watch option --- src/args.c | 5 +++++ src/args.h | 1 + src/grrobot.c | 13 ++++++++++--- 3 files changed, 16 insertions(+), 3 deletions(-) diff --git a/src/args.c b/src/args.c index 98aa80c..aee5e94 100644 --- a/src/args.c +++ b/src/args.c @@ -44,6 +44,7 @@ static struct argp_option options[] = { {"port", 'p', "PORT", 0, "Port of server"}, {"user", 'u', "USERNAME", 0, "Username for conection"}, {"game", 'g', "GAME", 0, "Game to join"}, + {"watch", 'w', 0, 0, "Watch instad of join"}, { 0 } }; @@ -65,6 +66,9 @@ parse_opt (int key, char *arg, struct argp_state *state) case 'g': args->game = arg; break; + case 'w': + args->watch = 1; + break; case ARGP_KEY_ARG: argp_usage (state); @@ -101,6 +105,7 @@ args_parse(args_t *args, int argc, char *argv[]) args->game = getenv ("RR_GAME"); if (args->game == NULL) args->game = ARGS_GAME_DEFAULT; + args->watch = 0; return argp_parse (&argp, argc, argv, 0, 0, args); } diff --git a/src/args.h b/src/args.h index 7799c48..423411a 100644 --- a/src/args.h +++ b/src/args.h @@ -44,6 +44,7 @@ typedef struct args char *port; char *user; char *game; + int watch; } args_t; error_t diff --git a/src/grrobot.c b/src/grrobot.c index 903a164..209c599 100644 --- a/src/grrobot.c +++ b/src/grrobot.c @@ -92,9 +92,16 @@ main (int argc, char **argv) return 1; } - status = rr_client_join (game.client, args.game); - if (status == RR_STATUS_NO_GAME) { - status = rr_client_new (game.client, args.game); + if (args.watch) { + status = rr_client_watch (game.client, args.game); + if (status == RR_STATUS_NO_GAME) { + fprintf (stderr, "No game %s to watch\n", args.game); + } + } else { + status = rr_client_join (game.client, args.game); + if (status == RR_STATUS_NO_GAME) { + status = rr_client_new (game.client, args.game); + } } game.board = rr_board_create (16, 16); -- 2.43.0