Add %t string formatting, for the TTYREC of the last played game. (Edoardo Spadolini <kerio00@gmail.com>)

git-svn-id: svn://katsu.triplehelix.org/dgamelaunch/trunk@612 db0b04b0-f4d1-0310-9a6d-de3e77497b0e
This commit is contained in:
Pasi Kallinen 2011-10-07 14:41:21 +00:00
parent 3c51941256
commit 78e94fa5de
4 changed files with 13 additions and 0 deletions

View File

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

View File

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

View File

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

View File

@ -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)
{