diff --git a/config.y b/config.y index acf98ad..09e9446 100644 --- a/config.y +++ b/config.y @@ -229,7 +229,6 @@ KeyPair: TYPE_CMDQUEUE '[' TYPE_CMDQUEUENAME ']' } }; - game_definition : TYPE_CMDQUEUE { if (myconfig[ncnf]->cmdqueue) { @@ -242,6 +241,10 @@ game_definition : TYPE_CMDQUEUE { myconfig[ncnf]->cmdqueue = curr_cmdqueue; } + | TYPE_GAME_ARGS '=' game_args_list + { + /* nothing */ + } | KeyType '=' TYPE_VALUE { switch ( $1 ) { @@ -280,24 +283,6 @@ game_definition : TYPE_CMDQUEUE myconfig[ncnf]->inprogressdir = strdup($3); break; - case TYPE_GAME_ARGS: - { - char **tmpargs; - if (myconfig[ncnf]->bin_args) { - myconfig[ncnf]->num_args++; - tmpargs = calloc((myconfig[ncnf]->num_args+1), sizeof(char *)); - memcpy(tmpargs, myconfig[ncnf]->bin_args, (myconfig[ncnf]->num_args * sizeof(char *))); - free(myconfig[ncnf]->bin_args); - myconfig[ncnf]->bin_args = tmpargs; - } else { - myconfig[ncnf]->num_args = 1; - myconfig[ncnf]->bin_args = calloc(2, sizeof(char *)); - } - myconfig[ncnf]->bin_args[(myconfig[ncnf]->num_args)-1] = strdup($3); - myconfig[ncnf]->bin_args[(myconfig[ncnf]->num_args)] = 0; - } - break; - default: fprintf(stderr, "%s:%d: token does not belong into game definition, bailing out\n", config, line); @@ -306,8 +291,30 @@ game_definition : TYPE_CMDQUEUE } ; -game_definitions : game_definitions game_definition - | game_definition +game_arg : TYPE_VALUE + { + char **tmpargs; + if (myconfig[ncnf]->bin_args) { + myconfig[ncnf]->num_args++; + tmpargs = calloc((myconfig[ncnf]->num_args+1), sizeof(char *)); + memcpy(tmpargs, myconfig[ncnf]->bin_args, (myconfig[ncnf]->num_args * sizeof(char *))); + free(myconfig[ncnf]->bin_args); + myconfig[ncnf]->bin_args = tmpargs; + } else { + myconfig[ncnf]->num_args = 1; + myconfig[ncnf]->bin_args = calloc(2, sizeof(char *)); + } + myconfig[ncnf]->bin_args[(myconfig[ncnf]->num_args)-1] = strdup($1); + myconfig[ncnf]->bin_args[(myconfig[ncnf]->num_args)] = 0; + } + ; + +game_args_list : game_arg + | game_arg ',' game_args_list + ; + +game_definitions : game_definition + | game_definition game_definitions ; definegame : TYPE_DEFINE_GAME '{' @@ -388,7 +395,6 @@ KeyType : TYPE_SUSER { $$ = TYPE_SUSER; } | TYPE_PATH_PASSWD { $$ = TYPE_PATH_PASSWD; } | TYPE_PATH_LOCKFILE { $$ = TYPE_PATH_LOCKFILE; } | TYPE_PATH_INPROGRESS { $$ = TYPE_PATH_INPROGRESS; } - | TYPE_GAME_ARGS { $$ = TYPE_GAME_ARGS; } | TYPE_RC_FMT { $$ = TYPE_RC_FMT; } ; diff --git a/examples/dgamelaunch.conf b/examples/dgamelaunch.conf index f080b69..3a6a8c9 100644 --- a/examples/dgamelaunch.conf +++ b/examples/dgamelaunch.conf @@ -95,11 +95,11 @@ game_name = "NetHack stub" short_name = "NHstb" # arguments for when we exec the binary -game_args = "/bin/nethackstub" -game_args = "foo" -game_args = "user:%n" -game_args = "shed_uid:%u" -game_args = "bar" +game_args = "/bin/nethackstub", + "foo", + "user:%n", + "shed_uid:%u", + "bar" # From inside the jail, where dgamelaunch should put mail - should match up with # NetHack settings. @@ -130,9 +130,7 @@ game_path = "/bin/nethack" game_name = "NetHack 3.4.3" short_name = "NH343" -game_args = "/bin/nethack" -game_args = "-u" -game_args = "%n" +game_args = "/bin/nethack", "-u", "%n" spooldir = "/var/mail/" rc_template = "/dgl-default-rcfile" @@ -166,17 +164,12 @@ game_name = "Crawl Stone Soup 0.1.7" short_name = "Cr017" -game_args = "/bin/crawlss017" -game_args = "-name" -game_args = "%n" -game_args = "-dir" -game_args = "/crawlss017/" -game_args = "-rc" -game_args = "%rrcfiles/%n.crawlrc" -game_args = "-morgue" -game_args = "/crawlss017/morgues/" -game_args = "-macro" -game_args = "/crawlss017/macros/%n.macro" +game_args = "/bin/crawlss017", + "-name", "%n", + "-dir", "/crawlss017/", + "-rc", "%rrcfiles/%n.crawlrc", + "-morgue", "/crawlss017/morgues/", + "-macro", "/crawlss017/macros/%n.macro" rc_template = "/dgl-default-rcfile.crawl" @@ -197,17 +190,12 @@ game_name = "Crawl Stone Soup 0.2.0" short_name = "Cr020" -game_args = "/bin/crawlss020" -game_args = "-name" -game_args = "%n" -game_args = "-dir" -game_args = "/crawlss020/" -game_args = "-rc" -game_args = "/crawlss020/plr/%n/%n.crawlrc" -game_args = "-morgue" -game_args = "/crawlss020/plr/%n/" -game_args = "-macro" -game_args = "/crawlss020/plr/%n/" +game_args = "/bin/crawlss020", + "-name", "%n", + "-dir", "/crawlss020/", + "-rc", "/crawlss020/plr/%n/%n.crawlrc", + "-morgue", "/crawlss020/plr/%n/", + "-macro", "/crawlss020/plr/%n/" rc_template = "/dgl-default-rcfile.crawl" rc_fmt = "/crawlss020/plr/%n/%n.crawlrc"