From cb963b5da843aeb3e24a298359e4cb2eaf0d77b8 Mon Sep 17 00:00:00 2001 From: Pasi Kallinen Date: Sat, 8 May 2010 05:19:48 +0000 Subject: [PATCH] Remove NhExt stuff; no-one uses it git-svn-id: svn://katsu.triplehelix.org/dgamelaunch/trunk@559 db0b04b0-f4d1-0310-9a6d-de3e77497b0e --- dgamelaunch.c | 127 +------------------------------------------------- dgl-common.c | 44 ++++------------- 2 files changed, 12 insertions(+), 159 deletions(-) diff --git a/dgamelaunch.c b/dgamelaunch.c index cc5b764..d7e6b89 100644 --- a/dgamelaunch.c +++ b/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* gen_inprogress_lock (int game, pid_t pid, char* ttyrec_filename) { @@ -612,7 +594,6 @@ inprogressmenu (int gameid) static dg_sortmode sortmode = NUM_SORTMODES; struct dg_game **games = NULL; char ttyrecname[130], gametype[10], idletime[10]; - int *is_nhext; sigset_t oldmask, toblock; int idx = -1; int shm_idx = -1; @@ -663,12 +644,6 @@ inprogressmenu (int gameid) sortmode = globalconfig.sortmode; 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); @@ -681,7 +656,6 @@ inprogressmenu (int gameid) term_resize_check(); max_height = dgl_local_LINES - (top_banner_hei + btm_banner_hei) - 1; if (max_height < 2) { - free(is_nhext); free_populated_games(games, len); return; } @@ -717,12 +691,7 @@ inprogressmenu (int gameid) 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); { @@ -822,7 +791,6 @@ inprogressmenu (int gameid) if (nmatches > 1) match = firstmatch; if (match > -1) { - if (!strcmp(games[match]->ttyrec_fn + strlen (games[match]->ttyrec_fn) - 6, ".nhext")) break; idx = match; selected = idx; goto watchgame; @@ -844,7 +812,6 @@ inprogressmenu (int gameid) case ERR: case 'q': case 'Q': - if (is_nhext) free(is_nhext); free_populated_games(games, len); #ifdef USE_SHMEM shmdt(shm_dg_data); @@ -881,9 +848,6 @@ inprogressmenu (int gameid) break; } - if (is_nhext[sidx]) /* Cannot watch NhExt game */ - break; - idx = sidx + offset; if (require_enter) { if (selected == idx) selected = -1; @@ -959,7 +923,6 @@ watchgame: selectedgame = NULL; } } - if (is_nhext) free(is_nhext); free_populated_games(games, len); #ifdef USE_SHMEM 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 main (int argc, char** argv) { @@ -2314,7 +2217,6 @@ main (int argc, char** argv) char atrcfilename[81], *p, *auth = NULL; unsigned int len; int c, i; - int nhext = 0, nhauth = 0; int userchoice; char *tmp; char *wall_email_str = NULL; @@ -2361,12 +2263,6 @@ main (int argc, char** argv) case 'q': silent = 1; break; - case 'a': - nhauth = 1; break; - - case 'e': - nhext = 1; break; - case 'f': if (config) { @@ -2433,8 +2329,7 @@ main (int argc, char** argv) } /* get master tty just before chroot (lives in /dev) */ - if (!nhext && !nhauth) - ttyrec_getpty (); + ttyrec_getpty (); #ifdef USE_RLIMIT #ifdef USE_RLIMIT_CORE @@ -2508,30 +2403,12 @@ main (int argc, char** argv) 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 */ if (readfile (0)) { debug_write("log in fail"); graceful_exit (110); } - if (nhauth) { - debug_write("nhauth"); - graceful_exit (authenticate ()); - } - if (auth) { char *user, *pass, *p; diff --git a/dgl-common.c b/dgl-common.c index 1eb53ef..b1743a6 100644 --- a/dgl-common.c +++ b/dgl-common.c @@ -501,7 +501,7 @@ free_populated_games(struct dg_game **games, int len) struct dg_game ** populate_games (int xgame, int *l, struct dg_user *me) { - int fd, len, n, is_nhext, pid; + int fd, len, n, pid; DIR *pdir; struct dirent *pdirent; 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, "..")) continue; - is_nhext = !strcmp (pdirent->d_name + strlen (pdirent->d_name) - 6, ".nhext"); - inprog = dgl_format_str(game, me, myconfig[game]->inprogressdir, NULL); if (!inprog) continue; @@ -547,12 +545,8 @@ populate_games (int xgame, int *l, struct dg_user *me) /* O_RDWR here should be O_RDONLY, but we need to test for * an exclusive lock */ 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; strncpy(playername, pdirent->d_name, DGL_PLAYERNAMELEN); playername[DGL_PLAYERNAMELEN] = '\0'; @@ -569,8 +563,8 @@ populate_games (int xgame, int *l, struct dg_user *me) ttrecdir = dgl_format_str(game, me, myconfig[game]->ttyrecdir, playername); if (!ttrecdir) continue; 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 */ games = realloc (games, sizeof (struct dg_game) * (len + 1)); @@ -619,30 +613,12 @@ populate_games (int xgame, int *l, struct dg_user *me) if (*p != '\0') p++; games[len]->ws_col = atoi(p); - if (is_nhext) - { - 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_col = 80; - } - len++; - } + + if (games[len]->ws_row < 4 || games[len]->ws_col < 4) { + games[len]->ws_row = 24; + games[len]->ws_col = 80; + } + len++; } } else