Allow defining several game_args with one definition:

game_args = "goo", "bar", ..



git-svn-id: svn://katsu.triplehelix.org/dgamelaunch/trunk@396 db0b04b0-f4d1-0310-9a6d-de3e77497b0e
This commit is contained in:
Pasi Kallinen 2008-01-01 19:56:15 +00:00
parent 4f95c35047
commit 9ebb30b417
2 changed files with 46 additions and 52 deletions

View File

@ -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; }
;

View File

@ -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"