diff --git a/TODO b/TODO index 3f48f08..1217da7 100644 --- a/TODO +++ b/TODO @@ -1,4 +1,11 @@ + +[22:45] < kerio> paxed: dgamelaunch bug! :D - you *need* a file called dgamelaunch in the root of the jail - + otherwise the shared memory craps out +[22:48] < kerio> anyway, /dgldir/shmkey would've been better + + + -when no banner file given, try to make a banner automagically? (needs some way to name the options given as keys... maybe another format for the keys that includes a string to be used as the name) diff --git a/config.l b/config.l index 2978834..a7d05b4 100644 --- a/config.l +++ b/config.l @@ -89,6 +89,7 @@ cursor { return TYPE_CURSOR; } server_id { return TYPE_SERVER_ID; } sortmode { return TYPE_WATCH_SORTMODE; } commands { return TYPE_CMDQUEUE; } +postcommands { return TYPE_POSTCMDQUEUE; } yes { yylval.i = 1; return TYPE_BOOL; } no { yylval.i = 0; return TYPE_BOOL; } dglstart { yylval.i = DGLTIME_DGLSTART; return TYPE_CMDQUEUENAME; } diff --git a/config.y b/config.y index 77d8b13..f2c2588 100644 --- a/config.y +++ b/config.y @@ -41,6 +41,7 @@ static const char* lookup_token (int t); %token TYPE_PATH_PASSWD TYPE_PATH_LOCKFILE TYPE_PATH_TTYREC %token TYPE_MALSTRING TYPE_PATH_INPROGRESS TYPE_GAME_ARGS TYPE_RC_FMT %token TYPE_CMDQUEUE TYPE_DEFINE_MENU TYPE_BANNER_FILE TYPE_CURSOR +%token TYPE_POSTCMDQUEUE %token TYPE_MAX_IDLE_TIME TYPE_MENU_MAX_IDLE_TIME %token TYPE_VALUE %token TYPE_NUMBER TYPE_CMDQUEUENAME @@ -356,6 +357,20 @@ game_definition : TYPE_CMDQUEUE myconfig[ncnf]->cmdqueue = curr_cmdqueue; curr_cmdqueue = NULL; } + | TYPE_POSTCMDQUEUE + { + if (myconfig[ncnf]->postcmdqueue) { + fprintf(stderr, "%s:%d: postcommand queue defined twice, bailing out\n", + config, line); + exit(1); + } + } + '=' cmdlist + { + myconfig[ncnf]->postcmdqueue = curr_cmdqueue; + curr_cmdqueue = NULL; + } + | TYPE_GAME_ARGS '=' game_args_list { /* nothing */ diff --git a/dgamelaunch.h b/dgamelaunch.h index 8932b6e..4be7815 100644 --- a/dgamelaunch.h +++ b/dgamelaunch.h @@ -49,9 +49,56 @@ typedef enum NUM_DGLTIMES } dglcmd_times; +typedef enum +{ + DGLCMD_NONE = 0, + DGLCMD_MKDIR, /* mkdir foo */ + DGLCMD_CHDIR, /* chdir foo */ + DGLCMD_IF_NX_CP, /* ifnxcp foo bar */ + DGLCMD_CP, /* cp foo bar */ + DGLCMD_UNLINK, /* unlink foo */ + DGLCMD_EXEC, /* exec foo bar */ + DGLCMD_SETENV, /* setenv foo bar */ + DGLCMD_WATCH_MENU, /* watch_menu */ + DGLCMD_LOGIN, /* ask_login */ + DGLCMD_REGISTER, /* ask_register */ + DGLCMD_QUIT, /* quit */ + DGLCMD_CHMAIL, /* chmail */ + DGLCMD_CHPASSWD, /* chpasswd */ + DGLCMD_PLAYGAME, /* play_game "foo" */ + DGLCMD_SUBMENU, /* submenu "foo" */ + DGLCMD_RETURN /* return */ +} dglcmd_actions; + +typedef enum +{ + SORTMODE_NONE = 0, + SORTMODE_USERNAME, + SORTMODE_GAMENUM, + SORTMODE_WINDOWSIZE, + SORTMODE_STARTTIME, + SORTMODE_IDLETIME, +#ifdef USE_SHMEM + SORTMODE_WATCHERS, +#endif + NUM_SORTMODES +} dg_sortmode; + +static const char *SORTMODE_NAME[NUM_SORTMODES] = { + "Unsorted", + "Username", + "Game", + "Windowsize", + "Starttime", + "Idletime", +#ifdef USE_SHMEM + "Watchers", +#endif +}; + struct dg_cmdpart { - dglcmd_times cmd; + dglcmd_actions cmd; char *param1; char *param2; struct dg_cmdpart *next; @@ -140,6 +187,7 @@ struct dg_config char **bin_args; /* args for game binary */ char *rc_fmt; struct dg_cmdpart *cmdqueue; + struct dg_cmdpart *postcmdqueue; int max_idle_time; }; @@ -166,52 +214,6 @@ struct dg_globalconfig int menu_max_idle_time; }; -typedef enum -{ - DGLCMD_NONE = 0, - DGLCMD_MKDIR, /* mkdir foo */ - DGLCMD_CHDIR, /* chdir foo */ - DGLCMD_IF_NX_CP, /* ifnxcp foo bar */ - DGLCMD_CP, /* cp foo bar */ - DGLCMD_UNLINK, /* unlink foo */ - DGLCMD_EXEC, /* exec foo bar */ - DGLCMD_SETENV, /* setenv foo bar */ - DGLCMD_WATCH_MENU, /* watch_menu */ - DGLCMD_LOGIN, /* ask_login */ - DGLCMD_REGISTER, /* ask_register */ - DGLCMD_QUIT, /* quit */ - DGLCMD_CHMAIL, /* chmail */ - DGLCMD_CHPASSWD, /* chpasswd */ - DGLCMD_PLAYGAME, /* play_game "foo" */ - DGLCMD_SUBMENU, /* submenu "foo" */ - DGLCMD_RETURN /* return */ -} dglcmd_actions; - -typedef enum -{ - SORTMODE_NONE = 0, - SORTMODE_USERNAME, - SORTMODE_GAMENUM, - SORTMODE_WINDOWSIZE, - SORTMODE_STARTTIME, - SORTMODE_IDLETIME, -#ifdef USE_SHMEM - SORTMODE_WATCHERS, -#endif - NUM_SORTMODES -} dg_sortmode; - -static const char *SORTMODE_NAME[NUM_SORTMODES] = { - "Unsorted", - "Username", - "Game", - "Windowsize", - "Starttime", - "Idletime", -#ifdef USE_SHMEM - "Watchers", -#endif -}; /* Global variables */ diff --git a/dgl-common.c b/dgl-common.c index 15aca76..c91de48 100644 --- a/dgl-common.c +++ b/dgl-common.c @@ -46,6 +46,7 @@ struct dg_config defconfig = { /* bin_args = */ NULL, /* rc_fmt = */ "%rrcfiles/%n.nethackrc", /* [dglroot]rcfiles/[username].nethackrc */ /* cmdqueue = */ NULL, + /* postcmdqueue = */ NULL, /* max_idle_time = */ 0 }; @@ -365,6 +366,8 @@ dgl_exec_cmdqueue(struct dg_cmdpart *queue, int game, struct dg_user *me) signal (SIGTERM, catch_sighup); signal(SIGWINCH, sigwinch_func); + dgl_exec_cmdqueue(myconfig[userchoice]->postcmdqueue, userchoice, me); + dgl_exec_cmdqueue(globalconfig.cmdqueue[DGLTIME_GAMEEND], userchoice, me); setproctitle ("%s", me->username); diff --git a/examples/dgamelaunch.conf b/examples/dgamelaunch.conf index a6028bd..ee8fc38 100644 --- a/examples/dgamelaunch.conf +++ b/examples/dgamelaunch.conf @@ -81,6 +81,7 @@ lockfile = "/dgl-lock" # login = when user has logged in # register = right after a new user is registered # gamestart = just before a game is started +# gameend = after a game ends (see also per-game "postcommand" define) # # is: # mkdir "foo" = create a directory "foo" @@ -211,6 +212,10 @@ menu["watchmenu_help"] { # # We can also define per-game commands, that are executed # # when the game starts: # # commands = chdir "/dgldir", mkdir "foo_%u_%g" +# +# # We can also define per-game commands executed after the game ends, +# # but before commands[gameend] +# postcommands = chdir "/" #}