Remove NhExt stuff; no-one uses it
git-svn-id: svn://katsu.triplehelix.org/dgamelaunch/trunk@559 db0b04b0-f4d1-0310-9a6d-de3e77497b0e
This commit is contained in:
parent
f53dfb5c7b
commit
cb963b5da8
123
dgamelaunch.c
123
dgamelaunch.c
|
@ -200,24 +200,6 @@ gen_ttyrec_filename ()
|
||||||
|
|
||||||
/* ************************************************************* */
|
/* ************************************************************* */
|
||||||
|
|
||||||
char*
|
|
||||||
gen_nhext_filename ()
|
|
||||||
{
|
|
||||||
time_t rawtime;
|
|
||||||
struct tm *ptm;
|
|
||||||
char *nhext_filename = calloc(100, sizeof(char));
|
|
||||||
|
|
||||||
/* append time to filename */
|
|
||||||
time (&rawtime);
|
|
||||||
ptm = gmtime (&rawtime);
|
|
||||||
snprintf (nhext_filename, 100, "%04i-%02i-%02i.%02i:%02i:%02i.nhext",
|
|
||||||
ptm->tm_year + 1900, ptm->tm_mon + 1, ptm->tm_mday,
|
|
||||||
ptm->tm_hour, ptm->tm_min, ptm->tm_sec);
|
|
||||||
return nhext_filename;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* ************************************************************* */
|
|
||||||
|
|
||||||
char*
|
char*
|
||||||
gen_inprogress_lock (int game, pid_t pid, char* ttyrec_filename)
|
gen_inprogress_lock (int game, pid_t pid, char* ttyrec_filename)
|
||||||
{
|
{
|
||||||
|
@ -612,7 +594,6 @@ inprogressmenu (int gameid)
|
||||||
static dg_sortmode sortmode = NUM_SORTMODES;
|
static dg_sortmode sortmode = NUM_SORTMODES;
|
||||||
struct dg_game **games = NULL;
|
struct dg_game **games = NULL;
|
||||||
char ttyrecname[130], gametype[10], idletime[10];
|
char ttyrecname[130], gametype[10], idletime[10];
|
||||||
int *is_nhext;
|
|
||||||
sigset_t oldmask, toblock;
|
sigset_t oldmask, toblock;
|
||||||
int idx = -1;
|
int idx = -1;
|
||||||
int shm_idx = -1;
|
int shm_idx = -1;
|
||||||
|
@ -663,12 +644,6 @@ inprogressmenu (int gameid)
|
||||||
sortmode = globalconfig.sortmode;
|
sortmode = globalconfig.sortmode;
|
||||||
|
|
||||||
abs_max_height = strlen(selectorchars);
|
abs_max_height = strlen(selectorchars);
|
||||||
is_nhext = (int *)calloc(abs_max_height+1, sizeof(int));
|
|
||||||
|
|
||||||
if (!is_nhext) {
|
|
||||||
debug_write("could not calloc is_nhext");
|
|
||||||
graceful_exit(70);
|
|
||||||
}
|
|
||||||
|
|
||||||
shm_init(&shm_dg_data, &shm_dg_game);
|
shm_init(&shm_dg_data, &shm_dg_game);
|
||||||
|
|
||||||
|
@ -681,7 +656,6 @@ inprogressmenu (int gameid)
|
||||||
term_resize_check();
|
term_resize_check();
|
||||||
max_height = dgl_local_LINES - (top_banner_hei + btm_banner_hei) - 1;
|
max_height = dgl_local_LINES - (top_banner_hei + btm_banner_hei) - 1;
|
||||||
if (max_height < 2) {
|
if (max_height < 2) {
|
||||||
free(is_nhext);
|
|
||||||
free_populated_games(games, len);
|
free_populated_games(games, len);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -717,11 +691,6 @@ inprogressmenu (int gameid)
|
||||||
|
|
||||||
if (i + offset == selected) attron(selected_attr);
|
if (i + offset == selected) attron(selected_attr);
|
||||||
|
|
||||||
is_nhext[i] = !strcmp (games[i + offset]->ttyrec_fn + strlen (games[i + offset]->ttyrec_fn) - 6, ".nhext");
|
|
||||||
|
|
||||||
if (is_nhext[i])
|
|
||||||
strcpy (gametype, " NhExt");
|
|
||||||
else
|
|
||||||
snprintf (gametype, sizeof gametype, "%3dx%3d",
|
snprintf (gametype, sizeof gametype, "%3dx%3d",
|
||||||
games[i + offset]->ws_col, games[i + offset]->ws_row);
|
games[i + offset]->ws_col, games[i + offset]->ws_row);
|
||||||
|
|
||||||
|
@ -822,7 +791,6 @@ inprogressmenu (int gameid)
|
||||||
if (nmatches > 1)
|
if (nmatches > 1)
|
||||||
match = firstmatch;
|
match = firstmatch;
|
||||||
if (match > -1) {
|
if (match > -1) {
|
||||||
if (!strcmp(games[match]->ttyrec_fn + strlen (games[match]->ttyrec_fn) - 6, ".nhext")) break;
|
|
||||||
idx = match;
|
idx = match;
|
||||||
selected = idx;
|
selected = idx;
|
||||||
goto watchgame;
|
goto watchgame;
|
||||||
|
@ -844,7 +812,6 @@ inprogressmenu (int gameid)
|
||||||
|
|
||||||
case ERR:
|
case ERR:
|
||||||
case 'q': case 'Q':
|
case 'q': case 'Q':
|
||||||
if (is_nhext) free(is_nhext);
|
|
||||||
free_populated_games(games, len);
|
free_populated_games(games, len);
|
||||||
#ifdef USE_SHMEM
|
#ifdef USE_SHMEM
|
||||||
shmdt(shm_dg_data);
|
shmdt(shm_dg_data);
|
||||||
|
@ -881,9 +848,6 @@ inprogressmenu (int gameid)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (is_nhext[sidx]) /* Cannot watch NhExt game */
|
|
||||||
break;
|
|
||||||
|
|
||||||
idx = sidx + offset;
|
idx = sidx + offset;
|
||||||
if (require_enter) {
|
if (require_enter) {
|
||||||
if (selected == idx) selected = -1;
|
if (selected == idx) selected = -1;
|
||||||
|
@ -959,7 +923,6 @@ watchgame:
|
||||||
selectedgame = NULL;
|
selectedgame = NULL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (is_nhext) free(is_nhext);
|
|
||||||
free_populated_games(games, len);
|
free_populated_games(games, len);
|
||||||
#ifdef USE_SHMEM
|
#ifdef USE_SHMEM
|
||||||
shmdt(shm_dg_data);
|
shmdt(shm_dg_data);
|
||||||
|
@ -2247,66 +2210,6 @@ runmenuloop(struct dg_menu *menu)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int
|
|
||||||
authenticate ()
|
|
||||||
{
|
|
||||||
int i, len, me_index;
|
|
||||||
char user_buf[DGL_PLAYERNAMELEN+1], pw_buf[DGL_PASSWDLEN+1];
|
|
||||||
struct dg_game **games = NULL;
|
|
||||||
|
|
||||||
/* We use simple password authentication, rather than challenge/response. */
|
|
||||||
printf ("\n");
|
|
||||||
fflush(stdout);
|
|
||||||
|
|
||||||
fgets (user_buf, sizeof(user_buf), stdin);
|
|
||||||
len = strlen (user_buf);
|
|
||||||
if (user_buf[len - 1] == '\n')
|
|
||||||
user_buf[--len] = '\0';
|
|
||||||
else
|
|
||||||
{
|
|
||||||
fprintf (stderr, "Username too long (max %i chars).\n", DGL_PLAYERNAMELEN);
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
fgets (pw_buf, sizeof(pw_buf), stdin);
|
|
||||||
len = strlen (pw_buf);
|
|
||||||
if (pw_buf[len - 1] == '\n')
|
|
||||||
pw_buf[--len] = '\0';
|
|
||||||
else
|
|
||||||
{
|
|
||||||
fprintf (stderr, "Password too long (max %i chars).\n", DGL_PASSWDLEN);
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
{
|
|
||||||
struct dg_user *tmpme;
|
|
||||||
if ((tmpme = userexist(user_buf, 0))) {
|
|
||||||
me = cpy_me(tmpme);
|
|
||||||
if (passwordgood (pw_buf))
|
|
||||||
{
|
|
||||||
games = populate_games (-1, &len, me);
|
|
||||||
for (i = 0; i < len; i++)
|
|
||||||
if (!strcmp (games[i]->name, user_buf))
|
|
||||||
{
|
|
||||||
fprintf (stderr, "Game already in progress.\n");
|
|
||||||
free_populated_games(games, len);
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
win.ws_row = win.ws_col = 0;
|
|
||||||
gen_inprogress_lock (0, getppid (), gen_nhext_filename ());
|
|
||||||
free_populated_games(games, len);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
sleep (2);
|
|
||||||
fprintf (stderr, "Login failed.\n");
|
|
||||||
free_populated_games(games, len);
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
int
|
int
|
||||||
main (int argc, char** argv)
|
main (int argc, char** argv)
|
||||||
{
|
{
|
||||||
|
@ -2314,7 +2217,6 @@ main (int argc, char** argv)
|
||||||
char atrcfilename[81], *p, *auth = NULL;
|
char atrcfilename[81], *p, *auth = NULL;
|
||||||
unsigned int len;
|
unsigned int len;
|
||||||
int c, i;
|
int c, i;
|
||||||
int nhext = 0, nhauth = 0;
|
|
||||||
int userchoice;
|
int userchoice;
|
||||||
char *tmp;
|
char *tmp;
|
||||||
char *wall_email_str = NULL;
|
char *wall_email_str = NULL;
|
||||||
|
@ -2361,12 +2263,6 @@ main (int argc, char** argv)
|
||||||
case 'q':
|
case 'q':
|
||||||
silent = 1; break;
|
silent = 1; break;
|
||||||
|
|
||||||
case 'a':
|
|
||||||
nhauth = 1; break;
|
|
||||||
|
|
||||||
case 'e':
|
|
||||||
nhext = 1; break;
|
|
||||||
|
|
||||||
case 'f':
|
case 'f':
|
||||||
if (config)
|
if (config)
|
||||||
{
|
{
|
||||||
|
@ -2433,7 +2329,6 @@ main (int argc, char** argv)
|
||||||
}
|
}
|
||||||
|
|
||||||
/* get master tty just before chroot (lives in /dev) */
|
/* get master tty just before chroot (lives in /dev) */
|
||||||
if (!nhext && !nhauth)
|
|
||||||
ttyrec_getpty ();
|
ttyrec_getpty ();
|
||||||
|
|
||||||
#ifdef USE_RLIMIT
|
#ifdef USE_RLIMIT
|
||||||
|
@ -2508,30 +2403,12 @@ main (int argc, char** argv)
|
||||||
|
|
||||||
dgl_exec_cmdqueue(globalconfig.cmdqueue[DGLTIME_DGLSTART], 0, NULL);
|
dgl_exec_cmdqueue(globalconfig.cmdqueue[DGLTIME_DGLSTART], 0, NULL);
|
||||||
|
|
||||||
if (nhext)
|
|
||||||
{
|
|
||||||
char *myargv[3];
|
|
||||||
|
|
||||||
myargv[0] = myconfig[0]->game_path;
|
|
||||||
myargv[1] = "--proxy";
|
|
||||||
myargv[2] = 0;
|
|
||||||
|
|
||||||
execvp (myconfig[0]->game_path, myargv);
|
|
||||||
perror (myconfig[0]->game_path);
|
|
||||||
graceful_exit (1);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* simple login routine, uses ncurses */
|
/* simple login routine, uses ncurses */
|
||||||
if (readfile (0)) {
|
if (readfile (0)) {
|
||||||
debug_write("log in fail");
|
debug_write("log in fail");
|
||||||
graceful_exit (110);
|
graceful_exit (110);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (nhauth) {
|
|
||||||
debug_write("nhauth");
|
|
||||||
graceful_exit (authenticate ());
|
|
||||||
}
|
|
||||||
|
|
||||||
if (auth)
|
if (auth)
|
||||||
{
|
{
|
||||||
char *user, *pass, *p;
|
char *user, *pass, *p;
|
||||||
|
|
36
dgl-common.c
36
dgl-common.c
|
@ -501,7 +501,7 @@ free_populated_games(struct dg_game **games, int len)
|
||||||
struct dg_game **
|
struct dg_game **
|
||||||
populate_games (int xgame, int *l, struct dg_user *me)
|
populate_games (int xgame, int *l, struct dg_user *me)
|
||||||
{
|
{
|
||||||
int fd, len, n, is_nhext, pid;
|
int fd, len, n, pid;
|
||||||
DIR *pdir;
|
DIR *pdir;
|
||||||
struct dirent *pdirent;
|
struct dirent *pdirent;
|
||||||
struct stat pstat;
|
struct stat pstat;
|
||||||
|
@ -535,8 +535,6 @@ populate_games (int xgame, int *l, struct dg_user *me)
|
||||||
if (!strcmp (pdirent->d_name, ".") || !strcmp (pdirent->d_name, ".."))
|
if (!strcmp (pdirent->d_name, ".") || !strcmp (pdirent->d_name, ".."))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
is_nhext = !strcmp (pdirent->d_name + strlen (pdirent->d_name) - 6, ".nhext");
|
|
||||||
|
|
||||||
inprog = dgl_format_str(game, me, myconfig[game]->inprogressdir, NULL);
|
inprog = dgl_format_str(game, me, myconfig[game]->inprogressdir, NULL);
|
||||||
|
|
||||||
if (!inprog) continue;
|
if (!inprog) continue;
|
||||||
|
@ -547,11 +545,7 @@ populate_games (int xgame, int *l, struct dg_user *me)
|
||||||
/* O_RDWR here should be O_RDONLY, but we need to test for
|
/* O_RDWR here should be O_RDONLY, but we need to test for
|
||||||
* an exclusive lock */
|
* an exclusive lock */
|
||||||
fd = open (fullname, O_RDWR);
|
fd = open (fullname, O_RDWR);
|
||||||
if (fd >= 0 && (is_nhext || fcntl (fd, F_SETLK, &fl) == -1))
|
if (fd >= 0 && (fcntl (fd, F_SETLK, &fl) == -1))
|
||||||
{
|
|
||||||
|
|
||||||
/* stat to check idle status */
|
|
||||||
if (!is_nhext)
|
|
||||||
{
|
{
|
||||||
char *ttrecdir = NULL;
|
char *ttrecdir = NULL;
|
||||||
strncpy(playername, pdirent->d_name, DGL_PLAYERNAMELEN);
|
strncpy(playername, pdirent->d_name, DGL_PLAYERNAMELEN);
|
||||||
|
@ -569,8 +563,8 @@ populate_games (int xgame, int *l, struct dg_user *me)
|
||||||
ttrecdir = dgl_format_str(game, me, myconfig[game]->ttyrecdir, playername);
|
ttrecdir = dgl_format_str(game, me, myconfig[game]->ttyrecdir, playername);
|
||||||
if (!ttrecdir) continue;
|
if (!ttrecdir) continue;
|
||||||
snprintf (ttyrecname, 130, "%s%s", ttrecdir, replacestr);
|
snprintf (ttyrecname, 130, "%s%s", ttrecdir, replacestr);
|
||||||
}
|
|
||||||
if (is_nhext || !stat (ttyrecname, &pstat))
|
if (!stat (ttyrecname, &pstat))
|
||||||
{
|
{
|
||||||
/* now it's a valid game for sure */
|
/* now it's a valid game for sure */
|
||||||
games = realloc (games, sizeof (struct dg_game) * (len + 1));
|
games = realloc (games, sizeof (struct dg_game) * (len + 1));
|
||||||
|
@ -619,32 +613,14 @@ populate_games (int xgame, int *l, struct dg_user *me)
|
||||||
if (*p != '\0')
|
if (*p != '\0')
|
||||||
p++;
|
p++;
|
||||||
games[len]->ws_col = atoi(p);
|
games[len]->ws_col = atoi(p);
|
||||||
if (is_nhext)
|
|
||||||
{
|
if (games[len]->ws_row < 4 || games[len]->ws_col < 4) {
|
||||||
if (kill (pid, 0) != 0)
|
|
||||||
{
|
|
||||||
/* Dead game */
|
|
||||||
free (games[len]->ttyrec_fn);
|
|
||||||
free (games[len]->name);
|
|
||||||
free (games[len]->date);
|
|
||||||
free (games[len]->time);
|
|
||||||
free (games[len]);
|
|
||||||
unlink (fullname);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
len++;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
if (games[len]->ws_row < 4 || games[len]->ws_col < 4)
|
|
||||||
{
|
|
||||||
games[len]->ws_row = 24;
|
games[len]->ws_row = 24;
|
||||||
games[len]->ws_col = 80;
|
games[len]->ws_col = 80;
|
||||||
}
|
}
|
||||||
len++;
|
len++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
/* clean dead ones */
|
/* clean dead ones */
|
||||||
|
|
Loading…
Reference in New Issue