Add per-game "postcommand" hook, executed right after the game ends.
git-svn-id: svn://katsu.triplehelix.org/dgamelaunch/trunk@588 db0b04b0-f4d1-0310-9a6d-de3e77497b0e
This commit is contained in:
parent
61e3e65647
commit
b1e40ba5b7
7
TODO
7
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)
|
||||
|
|
1
config.l
1
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; }
|
||||
|
|
15
config.y
15
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 <s> TYPE_VALUE
|
||||
%token <i> 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 */
|
||||
|
|
|
@ -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 */
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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)
|
||||
#
|
||||
# <command> 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 "/"
|
||||
#}
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue