diff --git a/dgamelaunch.h b/dgamelaunch.h index 23a54f5..a74f59d 100644 --- a/dgamelaunch.h +++ b/dgamelaunch.h @@ -262,6 +262,8 @@ extern mode_t default_fmode; extern int dgl_local_COLS; extern int dgl_local_LINES; +extern char last_ttyrec[512]; + /* dgamelaunch.c */ extern void create_config(void); extern void ttyrec_getmaster(void); diff --git a/dgl-common.c b/dgl-common.c index 0b197f6..eee4d5a 100644 --- a/dgl-common.c +++ b/dgl-common.c @@ -107,6 +107,7 @@ dgl_find_menu(char *menuname) * %r == chroot (string) (aka "dglroot" config var) * %g == game name * %s == short game name + * %t == ttyrec file (full path&name) of the last game played. */ char * dgl_format_str(int game, struct dg_user *me, char *str, char *plrname) @@ -160,6 +161,11 @@ dgl_format_str(int game, struct dg_user *me, char *str, char *plrname) while (*p != '\0') p++; break; + case 't': + snprintf (p, end + 1 - p, "%s", last_ttyrec); + while (*p != '\0') + p++; + break; default: *p = *f; if (p < end) diff --git a/examples/dgamelaunch.conf b/examples/dgamelaunch.conf index 374502c..4f9cd9e 100644 --- a/examples/dgamelaunch.conf +++ b/examples/dgamelaunch.conf @@ -137,6 +137,7 @@ lockfile = "/dgl-lock" # %u = shed_uid, as defined above, but numeric # %g = game name, if user has selected a game. # %s = short game name, if user has selected a game. +# %t = ttyrec path & filename of the last game played. # # eg. commands[login] = mkdir "foo", unlink "bar", setenv "Z" "foo" # diff --git a/ttyrec.c b/ttyrec.c index 720589d..4ed7e4d 100644 --- a/ttyrec.c +++ b/ttyrec.c @@ -87,6 +87,8 @@ int master; struct termios tt; struct winsize win; +char last_ttyrec[512] = { '\0' }; + int ancient_encoding = 0; void @@ -160,6 +162,8 @@ ttyrec_main (int game, char *username, char *ttyrec_path, char* ttyrec_filename) if (ancient_encoding == -1) query_encoding(game, username); + snprintf(last_ttyrec, 512, "%s", dirname); + atexit(&remove_ipfile); if ((fscript = fopen (dirname, "w")) == NULL) {