mirror of
https://github.com/paxed/dgamelaunch.git
synced 2025-07-29 00:25:03 +02:00
Make bannerstrmangle able to handle arbitrarily long strings.
git-svn-id: svn://katsu.triplehelix.org/dgamelaunch/trunk@623 db0b04b0-f4d1-0310-9a6d-de3e77497b0e
This commit is contained in:
parent
6e6d773dd1
commit
5a0c90fa0f
6
TODO
6
TODO
@ -1,4 +1,6 @@
|
|||||||
|
|
||||||
|
-update dgamelaunch.8
|
||||||
|
|
||||||
-occasionally dgl crashes, leaving the shmem semaphore in a state
|
-occasionally dgl crashes, leaving the shmem semaphore in a state
|
||||||
where the shmem block has to be freed.
|
where the shmem block has to be freed.
|
||||||
|
|
||||||
@ -19,8 +21,6 @@
|
|||||||
(needs some way to name the options given as keys... maybe another
|
(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)
|
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
|
-cursor keys are not restored after watching a game of
|
||||||
curses-nethack.
|
curses-nethack.
|
||||||
|
|
||||||
@ -126,8 +126,6 @@ or maybe add a new command '' set_charstrip "name" ''
|
|||||||
-configurable stuff: allowed chars in usernames,
|
-configurable stuff: allowed chars in usernames,
|
||||||
allow char stripping, ...
|
allow char stripping, ...
|
||||||
|
|
||||||
- Flags for operators/staff/admins or (optionally) user-bans.
|
|
||||||
|
|
||||||
- Localization of variables, code clean up
|
- Localization of variables, code clean up
|
||||||
|
|
||||||
- Use /var/run/nologin and/or dgl-specific nologin file
|
- Use /var/run/nologin and/or dgl-specific nologin file
|
||||||
|
@ -371,22 +371,21 @@ idle_alarm_reset(void)
|
|||||||
|
|
||||||
|
|
||||||
char *
|
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 *loc;
|
||||||
char *b = buf;
|
char *b = buf;
|
||||||
|
|
||||||
memset (bufnew, 0, 80);
|
memset (bufnew, 0, buflen);
|
||||||
|
|
||||||
if (strstr(b, fromstr)) {
|
if (strstr(b, fromstr)) {
|
||||||
int i = 0;
|
int i = 0;
|
||||||
while ((loc = strstr (b, fromstr)) != NULL) {
|
while ((loc = strstr (b, fromstr)) != NULL) {
|
||||||
for (; i < 80; i++) {
|
for (; i < buflen; i++) {
|
||||||
if (loc != b)
|
if (loc != b)
|
||||||
bufnew[i] = *(b++);
|
bufnew[i] = *(b++);
|
||||||
else {
|
else {
|
||||||
strlcat (bufnew, tostr, 80);
|
strlcat (bufnew, tostr, buflen);
|
||||||
b += strlen(fromstr);
|
b += strlen(fromstr);
|
||||||
i += strlen(tostr);
|
i += strlen(tostr);
|
||||||
break;
|
break;
|
||||||
@ -398,9 +397,8 @@ bannerstrmangle(char *buf, char *fromstr, char *tostr)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (*b)
|
if (*b)
|
||||||
strlcat(bufnew, b, 80);
|
strlcat(bufnew, b, buflen);
|
||||||
} else strncpy(bufnew, buf, 80);
|
} else strncpy(bufnew, buf, buflen);
|
||||||
|
|
||||||
return bufnew;
|
return bufnew;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -516,16 +514,17 @@ loadbanner (char *fname, struct dg_banner *ban)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
char tmpbufnew[80];
|
||||||
struct dg_banner_var *bv = globalconfig.banner_var_list;
|
struct dg_banner_var *bv = globalconfig.banner_var_list;
|
||||||
while (bv) {
|
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;
|
bv = bv->next;
|
||||||
}
|
}
|
||||||
strncpy(bufnew, bannerstrmangle(bufnew, "$VERSION", PACKAGE_STRING), 80);
|
strncpy(bufnew, bannerstrmangle(bufnew, tmpbufnew, 80, "$VERSION", PACKAGE_STRING), 80);
|
||||||
if (me && loggedin) {
|
if (me && loggedin) {
|
||||||
strncpy(bufnew, bannerstrmangle(bufnew, "$USERNAME", me->username), 80);
|
strncpy(bufnew, bannerstrmangle(bufnew, tmpbufnew, 80, "$USERNAME", me->username), 80);
|
||||||
} else {
|
} else {
|
||||||
strncpy(bufnew, bannerstrmangle(bufnew, "$USERNAME", "[Anonymous]"), 80);
|
strncpy(bufnew, bannerstrmangle(bufnew, tmpbufnew, 80, "$USERNAME", "[Anonymous]"), 80);
|
||||||
}
|
}
|
||||||
banner_addline(ban, bufnew);
|
banner_addline(ban, bufnew);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user