From: Pasi Kallinen Date: Sun, 6 Apr 2008 11:21:29 +0000 (+0000) Subject: Add $SERVERID and server_id stuff so admin can change the server ID (url, telnet... X-Git-Tag: v1.6.1-roc-dev~264 X-Git-Url: https://skyeroc.xyz/gitweb/?a=commitdiff_plain;h=db5bcbaf85ed3e4eac59a702bcb7d491ee32f79f;p=dgamelaunch Add $SERVERID and server_id stuff so admin can change the server ID (url, telnet address, whatever) simply by editing one line in the config file. git-svn-id: svn://katsu.triplehelix.org/dgamelaunch/trunk@444 db0b04b0-f4d1-0310-9a6d-de3e77497b0e --- diff --git a/config.l b/config.l index f632c52..e4f71b7 100644 --- a/config.l +++ b/config.l @@ -83,6 +83,7 @@ cursor { return TYPE_CURSOR; } "inprogressdir" { return TYPE_PATH_INPROGRESS; } "game_args" { return TYPE_GAME_ARGS; } "rc_fmt" { return TYPE_RC_FMT; } +server_id { return TYPE_SERVER_ID; } sortmode { return TYPE_WATCH_SORTMODE; } commands { return TYPE_CMDQUEUE; } yes { yylval.i = 1; return TYPE_BOOL; } diff --git a/config.y b/config.y index 973b933..7750514 100644 --- a/config.y +++ b/config.y @@ -34,7 +34,7 @@ static const char* lookup_token (int t); } %token TYPE_SUSER TYPE_SGROUP TYPE_SGID TYPE_SUID TYPE_MAX TYPE_MAXNICKLEN -%token TYPE_GAME_SHORT_NAME TYPE_WATCH_SORTMODE +%token TYPE_GAME_SHORT_NAME TYPE_WATCH_SORTMODE TYPE_SERVER_ID %token TYPE_ALLOW_REGISTRATION %token TYPE_PATH_GAME TYPE_NAME_GAME TYPE_PATH_DGLDIR TYPE_PATH_SPOOL %token TYPE_PATH_BANNER TYPE_PATH_CANNED TYPE_PATH_CHROOT @@ -170,6 +170,11 @@ KeyPair: TYPE_CMDQUEUE '[' TYPE_CMDQUEUENAME ']' } break; + case TYPE_SERVER_ID: + if (globalconfig.server_id) free(globalconfig.server_id); + globalconfig.server_id = strdup($3); + break; + case TYPE_PATH_DGLDIR: if (globalconfig.dglroot) free(globalconfig.dglroot); globalconfig.dglroot = strdup($3); @@ -526,6 +531,7 @@ KeyType : TYPE_SUSER { $$ = TYPE_SUSER; } | TYPE_PATH_INPROGRESS { $$ = TYPE_PATH_INPROGRESS; } | TYPE_RC_FMT { $$ = TYPE_RC_FMT; } | TYPE_WATCH_SORTMODE { $$ = TYPE_WATCH_SORTMODE; } + | TYPE_SERVER_ID { $$ = TYPE_SERVER_ID; } ; %% @@ -553,6 +559,7 @@ const char* lookup_token (int t) case TYPE_GAME_ARGS: return "game_args"; case TYPE_RC_FMT: return "rc_fmt"; case TYPE_WATCH_SORTMODE: return "sortmode"; + case TYPE_SERVER_ID: return "server_id"; default: abort(); } } diff --git a/dgamelaunch.c b/dgamelaunch.c index b2bd6f0..c43e8a5 100644 --- a/dgamelaunch.c +++ b/dgamelaunch.c @@ -323,8 +323,11 @@ loadbanner (char *fname, struct dg_banner *ban) strncpy(bufnew, buf, 80); strncpy(bufnew, bannerstrmangle(bufnew, "$VERSION", PACKAGE_STRING), 80); + strncpy(bufnew, bannerstrmangle(bufnew, "$SERVERID", globalconfig.server_id ? globalconfig.server_id : ""), 80); if (me && loggedin) { strncpy(bufnew, bannerstrmangle(bufnew, "$USERNAME", me->username), 80); + } else { + strncpy(bufnew, bannerstrmangle(bufnew, "$USERNAME", "[Anonymous]"), 80); } ban->lines[ban->len - 1] = strdup(bufnew); diff --git a/dgamelaunch.h b/dgamelaunch.h index 8970919..29afbfd 100644 --- a/dgamelaunch.h +++ b/dgamelaunch.h @@ -111,6 +111,7 @@ struct dg_globalconfig char* lockfile; int allow_registration; /* allow registering new nicks */ int sortmode; /* default watching-screen sortmode */ + char *server_id; /* string for the server name or whatever */ struct dg_cmdpart *cmdqueue[NUM_DGLTIMES]; diff --git a/dgl-common.c b/dgl-common.c index efd648d..96c3dba 100644 --- a/dgl-common.c +++ b/dgl-common.c @@ -527,6 +527,7 @@ create_config () if (!globalconfig.allow_registration) globalconfig.allow_registration = 1; globalconfig.menulist = NULL; + globalconfig.server_id = NULL; globalconfig.sortmode = SORTMODE_NONE; diff --git a/examples/dgamelaunch.conf b/examples/dgamelaunch.conf index d89a198..dfc009a 100644 --- a/examples/dgamelaunch.conf +++ b/examples/dgamelaunch.conf @@ -29,9 +29,14 @@ chroot_path = "/var/lib/dgamelaunch/" # From inside the jail, dgamelaunch's working directory for rcfiles/ttyrec/etc dglroot = "/dgldir/" +# Server ID string +server_id = "nethack.alt.org - http://nethack.alt.org/" + # From inside the jail, location of a banner file, the topmost line will be # shown in submenus that cannot be defined separately. -# string $VERSION will be replaced with "dgamelaunch v" + dgl version number. +# Some string substitution is done for the file: +# $VERSION replaced with "dgamelaunch v" + dgl version number. +# $SERVERID replaced with the server_id string, as defined above. banner = "/dgl-banner" # The following two options are fairly insecure. They will force us to @@ -110,8 +115,7 @@ commands[register] = mkdir "%rttyrec/%n" # define the main menus. you _must_ define "mainmenu_anon" # and "mainmenu_user". -# $VERSION will be replaced with dgl version string, as -# in the bannerfile above. +# $VERSION and $SERVERID will be replaced, as per the bannerfile above. # first, the menu shown to anonymous user: menu["mainmenu_anon"] { bannerfile = "dgl_menu_main_anon.txt"