Safer display in chat

This commit is contained in:
Michiel Broek 2006-03-06 20:30:09 +00:00
parent 49a8f5ed69
commit fa036b00b7
3 changed files with 16 additions and 7 deletions

View File

@ -29,6 +29,7 @@ v0.83.14 23-Feb-2006
mbmon: mbmon:
Better user input checking in chat. Better user input checking in chat.
Safer display in chat.
mbsetup: mbsetup:
Added archiver selection for nodes in node setup. Added archiver selection for nodes in node setup.

View File

@ -480,8 +480,8 @@ void Showline(int y, int x, char *msg)
int i, done = FALSE; int i, done = FALSE;
if (strlen(msg)) { if (strlen(msg)) {
mbse_locate(y, x);
if (msg[0] == '<') { if (msg[0] == '<') {
mbse_locate(y, x);
mbse_colour(LIGHTCYAN, BLACK); mbse_colour(LIGHTCYAN, BLACK);
putchar('<'); putchar('<');
mbse_colour(LIGHTBLUE, BLACK); mbse_colour(LIGHTBLUE, BLACK);
@ -504,10 +504,12 @@ void Showline(int y, int x, char *msg)
} else { } else {
mbse_colour(LIGHTMAGENTA, BLACK); mbse_colour(LIGHTMAGENTA, BLACK);
} }
mbse_mvprintw(y, x, msg); for (i = 0; i < strlen(msg); i++)
putchar(msg[i]);
} else { } else {
mbse_colour(GREEN, BLACK); mbse_colour(GREEN, BLACK);
mbse_mvprintw(y, x, msg); for (i = 0; i < strlen(msg); i++)
putchar(msg[i]);
} }
} }
} }
@ -537,7 +539,8 @@ void DispMsg(char *msg)
for (i = 0; i <= rsize; i++) { for (i = 0; i <= rsize; i++) {
mbse_locate(i+4,1); mbse_locate(i+4,1);
clrtoeol(); clrtoeol();
snprintf(rbuf[i], 81, "%s", rbuf[i+1]); strncpy(rbuf[i], rbuf[i+1], 81);
// snprintf(rbuf[i], 81, "%s", rbuf[i+1]);
Showline(i+4, 1, rbuf[i]); Showline(i+4, 1, rbuf[i]);
} }
} else { } else {

View File

@ -508,7 +508,7 @@ void chat_close_r(char *data, char *buf)
void chat_put_r(char *data, char *buf) void chat_put_r(char *data, char *buf)
{ {
char *p, *pid, *msg, *cmd, *mbuf, *flags, temp[81]; char *p, *q, *pid, *msg, *cmd, *mbuf, *flags, temp[81];
int first, count, owner = FALSE, found; int first, count, owner = FALSE, found;
usr_list *tmpu, *tmp; usr_list *tmpu, *tmp;
chn_list *tmpc; chn_list *tmpc;
@ -588,8 +588,13 @@ void chat_put_r(char *data, char *buf)
system_msg(tmpu->pid, mbuf); system_msg(tmpu->pid, mbuf);
} }
first = FALSE; first = FALSE;
snprintf(mbuf, 200, "%3d %-20s %-54s", tmpc->users, tmpc->name, tmpc->topic); q = calloc(81, sizeof(char));
system_msg(tmpu->pid, mbuf); snprintf(q, 81, "%3d %-20s ", tmpc->users, tmpc->name);
p = xstrcpy(q);
p = xstrcat(p, tmpc->topic);
system_msg(tmpu->pid, p);
free(p);
free(q);
} }
if (first) { if (first) {
snprintf(mbuf, 200, "No active channels to list"); snprintf(mbuf, 200, "No active channels to list");