From 513073a32c848c34c824fc98182274adff6ed79a Mon Sep 17 00:00:00 2001 From: Eric House Date: Wed, 2 May 2012 19:33:03 -0700 Subject: [PATCH] add optional --rack-header and --rack-footer params that take strings and use them to bracket output. --- xwords4/linux/linuxmain.c | 10 ++++++++++ xwords4/linux/main.h | 2 ++ xwords4/linux/mvcount.c | 12 +++++++++++- 3 files changed, 23 insertions(+), 1 deletion(-) diff --git a/xwords4/linux/linuxmain.c b/xwords4/linux/linuxmain.c index a3383e047..b24000787 100644 --- a/xwords4/linux/linuxmain.c +++ b/xwords4/linux/linuxmain.c @@ -278,6 +278,8 @@ typedef enum { ,CMD_RACKPIPE ,CMD_RACKSTRING ,CMD_RACKLIMIT + ,CMD_RACKHEADER + ,CMD_RACKFOOTER ,CMD_HIDEVALUES ,CMD_SKIPCONFIRM ,CMD_VERTICALSCORE @@ -354,6 +356,8 @@ static CmdInfoRec CmdInfoRecs[] = { ,{ CMD_RACKPIPE, true, "rack-pipe", "pipe to listen on for new racks" } ,{ CMD_RACKSTRING, true, "rack", "single rack to generate moves for" } ,{ CMD_RACKLIMIT, true, "max-words", "max # of moves to print per rack" } + ,{ CMD_RACKHEADER, true, "rack-header", "printed before each set of rack results" } + ,{ CMD_RACKFOOTER, true, "rack-footer", "printed after each set of rack result" } ,{ CMD_HIDEVALUES, false, "hide-values", "show letters, not nums, on tiles" } ,{ CMD_SKIPCONFIRM, false, "skip-confirm", "don't confirm before commit" } ,{ CMD_VERTICALSCORE, false, "vertical", "scoreboard is vertical" } @@ -1161,6 +1165,12 @@ main( int argc, char** argv ) case CMD_RACKLIMIT: mainParams.rackLimit = atoi(optarg); break; + case CMD_RACKHEADER: + mainParams.rackHeader = optarg; + break; + case CMD_RACKFOOTER: + mainParams.rackFooter = optarg; + break; #ifdef XWFEATURE_BLUETOOTH case CMD_BTADDR: diff --git a/xwords4/linux/main.h b/xwords4/linux/main.h index a92ac0054..746900af5 100644 --- a/xwords4/linux/main.h +++ b/xwords4/linux/main.h @@ -85,6 +85,8 @@ typedef struct LaunchParams { char* rackPipe; char* rackString; XP_U32 rackLimit; + char* rackHeader; + char* rackFooter; #endif DeviceRole serverRole; diff --git a/xwords4/linux/mvcount.c b/xwords4/linux/mvcount.c index a232910a0..450240932 100644 --- a/xwords4/linux/mvcount.c +++ b/xwords4/linux/mvcount.c @@ -103,11 +103,16 @@ static void printSaved( MvCntGlobals* globals ) { int ii; - XP_U32 limit = globals->cGlobals.params->rackLimit; + const LaunchParams* params = globals->cGlobals.params; + XP_U32 limit = params->rackLimit; if ( limit == 0 || limit > PREPROD_LIMIT ) { limit = PREPROD_LIMIT; } + if ( !!params->rackHeader ) { + fprintf( stdout, "%s\n", params->rackHeader ); + } + GArray* move_array = globals->move_array; for ( ii = 0; ii < move_array->len; ++ii ) { gchar* str = g_array_index( move_array, gchar*, ii ); @@ -119,6 +124,11 @@ printSaved( MvCntGlobals* globals ) } g_free( str ); } + + if ( !!params->rackFooter ) { + fprintf( stdout, "%s\n", params->rackFooter ); + } + (void)g_array_free( move_array, TRUE ); globals->move_array = NULL; }