]> skyeroc.xyz Git - dgamelaunch/commitdiff
Make bannerstrmangle able to handle arbitrarily long strings.
authorPasi Kallinen <paxed@alt.org>
Tue, 11 Oct 2011 18:05:11 +0000 (18:05 +0000)
committerPasi Kallinen <paxed@alt.org>
Tue, 11 Oct 2011 18:05:11 +0000 (18:05 +0000)
git-svn-id: svn://katsu.triplehelix.org/dgamelaunch/trunk@623 db0b04b0-f4d1-0310-9a6d-de3e77497b0e

TODO
dgamelaunch.c

diff --git a/TODO b/TODO
index f6a627ba04f0567c5f989e56460a01950d641595..38898c301dc2abe20d8601adc1fec2bcc0d17aa6 100644 (file)
--- a/TODO
+++ b/TODO
@@ -1,4 +1,6 @@
 
+-update dgamelaunch.8
+
 -occasionally dgl crashes, leaving the shmem semaphore in a state
  where the shmem block has to be freed.
 
@@ -19,8 +21,6 @@
  (needs some way to name the options given as keys... maybe another
  format for the keys that includes a string to be used as the name)
 
--document the exit (error) codes.
-
 -cursor keys are not restored after watching a game of
  curses-nethack.
 
@@ -126,8 +126,6 @@ or maybe add a new command '' set_charstrip "name" ''
 -configurable stuff: allowed chars in usernames,
  allow char stripping, ...
 
-- Flags for operators/staff/admins or (optionally) user-bans.
-
 - Localization of variables, code clean up
 
 - Use /var/run/nologin and/or dgl-specific nologin file
index 6f1c2de89f1263454e4dfd2ae75fd721dae71a90..f7b6f181655b1429c4519d7c7e2066632bcec496 100644 (file)
@@ -371,22 +371,21 @@ idle_alarm_reset(void)
 
 
 char *
-bannerstrmangle(char *buf, char *fromstr, char *tostr)
+bannerstrmangle(char *buf, char *bufnew, int buflen, char *fromstr, char *tostr)
 {
-    static char bufnew[81];
     char *loc;
     char *b = buf;
 
-    memset (bufnew, 0, 80);
+    memset (bufnew, 0, buflen);
 
     if (strstr(b, fromstr)) {
        int i = 0;
        while ((loc = strstr (b, fromstr)) != NULL) {
-           for (; i < 80; i++) {
+           for (; i < buflen; i++) {
                if (loc != b)
                    bufnew[i] = *(b++);
                else {
-                   strlcat (bufnew, tostr, 80);
+                   strlcat (bufnew, tostr, buflen);
                    b += strlen(fromstr);
                    i += strlen(tostr);
                    break;
@@ -398,9 +397,8 @@ bannerstrmangle(char *buf, char *fromstr, char *tostr)
        }
 
        if (*b)
-           strlcat(bufnew, b, 80);
-    } else strncpy(bufnew, buf, 80);
-
+           strlcat(bufnew, b, buflen);
+    } else strncpy(bufnew, buf, buflen);
     return bufnew;
 }
 
@@ -516,16 +514,17 @@ loadbanner (char *fname, struct dg_banner *ban)
              }
          }
       } else {
+         char tmpbufnew[80];
          struct dg_banner_var *bv = globalconfig.banner_var_list;
          while (bv) {
-             strncpy(bufnew, bannerstrmangle(bufnew, bv->name, bv->value), 80);
+             strncpy(bufnew, bannerstrmangle(bufnew, tmpbufnew, 80, bv->name, bv->value), 80);
              bv = bv->next;
          }
-         strncpy(bufnew, bannerstrmangle(bufnew, "$VERSION", PACKAGE_STRING), 80);
+         strncpy(bufnew, bannerstrmangle(bufnew, tmpbufnew, 80, "$VERSION", PACKAGE_STRING), 80);
          if (me && loggedin) {
-             strncpy(bufnew, bannerstrmangle(bufnew, "$USERNAME", me->username), 80);
+             strncpy(bufnew, bannerstrmangle(bufnew, tmpbufnew, 80, "$USERNAME", me->username), 80);
          } else {
-             strncpy(bufnew, bannerstrmangle(bufnew, "$USERNAME", "[Anonymous]"), 80);
+             strncpy(bufnew, bannerstrmangle(bufnew, tmpbufnew, 80, "$USERNAME", "[Anonymous]"), 80);
          }
          banner_addline(ban, bufnew);
       }