Added width marker for chat input and fixed linelength
This commit is contained in:
parent
8338e5fdaf
commit
807a6b8f5d
@ -19,9 +19,11 @@ v0.83.11 28-Jan-2006
|
||||
mbmon:
|
||||
In chat beeps are heared for system messages.
|
||||
Removed most debug logging in chat.
|
||||
Added width marker for chat input and fixed linelength.
|
||||
|
||||
mbsebbs:
|
||||
Removed most debug logging in chat.
|
||||
Added width marker for chat input and fixed linelength.
|
||||
|
||||
|
||||
v0.83.10 25-Jan-2006 - 28-Jan-2006
|
||||
|
@ -46,7 +46,7 @@ extern pid_t mypid;
|
||||
struct sysconfig CFG;
|
||||
|
||||
|
||||
char rbuf[50][80]; /* Chat receive buffer */ /* FIXME: must be a dynamic buffer */
|
||||
char rbuf[50][81]; /* Chat receive buffer */ /* FIXME: must be a dynamic buffer */
|
||||
int rpointer = 0; /* Chat receive pointer */
|
||||
int rsize = 5; /* Chat receive size */
|
||||
|
||||
@ -528,7 +528,7 @@ void DispMsg(char *msg)
|
||||
if ((msg[0] == '*') && (msg[1] != '*'))
|
||||
putchar('\007');
|
||||
|
||||
strncpy(rbuf[rpointer], msg, 80);
|
||||
strncpy(rbuf[rpointer], msg, 81);
|
||||
Showline(4+rpointer, 1, rbuf[rpointer]);
|
||||
if (rpointer == rsize) {
|
||||
/*
|
||||
@ -537,7 +537,7 @@ void DispMsg(char *msg)
|
||||
for (i = 0; i <= rsize; i++) {
|
||||
mbse_locate(i+4,1);
|
||||
clrtoeol();
|
||||
snprintf(rbuf[i], 80, "%s", rbuf[i+1]);
|
||||
snprintf(rbuf[i], 81, "%s", rbuf[i+1]);
|
||||
Showline(i+4, 1, rbuf[i]);
|
||||
}
|
||||
} else {
|
||||
@ -554,7 +554,7 @@ void DispMsg(char *msg)
|
||||
*/
|
||||
void Chat(int sysop)
|
||||
{
|
||||
int curpos = 0, stop = FALSE, data, rc;
|
||||
int curpos = 0, width, stop = FALSE, data, rc;
|
||||
unsigned char ch = 0;
|
||||
char sbuf[81], resp[128], *sysop_name, *name;
|
||||
static char buf[200];
|
||||
@ -565,14 +565,13 @@ void Chat(int sysop)
|
||||
|
||||
sysop_name = xstrcpy(clencode(CFG.sysop_name));
|
||||
name = xstrcpy(clencode(CFG.sysop));
|
||||
width = cols - (strlen(name) + 3);
|
||||
snprintf(buf, 200, "CCON,4,%d,%s,%s,%s;", mypid, sysop_name, name, sysop ? "1":"0");
|
||||
free(sysop_name);
|
||||
free(name);
|
||||
// Syslog('-', "> %s", buf);
|
||||
|
||||
if (socket_send(buf) == 0) {
|
||||
strcpy(buf, socket_receive());
|
||||
// Syslog('-', "< %s", buf);
|
||||
if (strncmp(buf, "200:1,", 6) == 0) {
|
||||
set_color(LIGHTRED, BLACK);
|
||||
mbse_mvprintw(4, 1, (char *)"Add \"fido 60179/udp # Chatserver\" to /etc/services");
|
||||
@ -592,6 +591,7 @@ void Chat(int sysop)
|
||||
|
||||
set_color(WHITE, BLACK);
|
||||
mbse_mvprintw(rows - 1, 1, ">");
|
||||
mbse_mvprintw(rows - 1, width + 2, "<");
|
||||
memset(&sbuf, 0, sizeof(sbuf));
|
||||
memset(&rbuf, 0, sizeof(rbuf));
|
||||
|
||||
@ -605,8 +605,6 @@ void Chat(int sysop)
|
||||
}
|
||||
}
|
||||
|
||||
// Syslog('-', "Start loop");
|
||||
|
||||
while (stop == FALSE) {
|
||||
|
||||
/*
|
||||
@ -619,14 +617,12 @@ void Chat(int sysop)
|
||||
memset(&buf, 0, sizeof(buf));
|
||||
strncpy(buf, socket_receive(), sizeof(buf)-1);
|
||||
if (strncmp(buf, "100:2,", 6) == 0) {
|
||||
// Syslog('-', "> CGET:1,%d;", mypid);
|
||||
// Syslog('-', "< %s", buf);
|
||||
strncpy(resp, strtok(buf, ":"), 10); /* Should be 100 */
|
||||
strncpy(resp, strtok(NULL, ","), 5); /* Should be 2 */
|
||||
strncpy(resp, strtok(NULL, ","), 5); /* 1= fatal error */
|
||||
rc = atoi(resp);
|
||||
memset(&resp, 0, sizeof(resp));
|
||||
strncpy(resp, cldecode(strtok(NULL, ";")), 80); /* The message */
|
||||
strncpy(resp, cldecode(strtok(NULL, ";")), 81); /* The message */
|
||||
DispMsg(resp);
|
||||
if (rc == 1) {
|
||||
Syslog('+', "Chat server error: %s", resp);
|
||||
@ -653,7 +649,7 @@ void Chat(int sysop)
|
||||
ch = testkey(rows -1, curpos + 2);
|
||||
if (isprint(ch)) {
|
||||
set_color(CYAN, BLACK);
|
||||
if (curpos < 77) {
|
||||
if (curpos < width) {
|
||||
putchar(ch);
|
||||
fflush(stdout);
|
||||
sbuf[curpos] = ch;
|
||||
@ -672,16 +668,14 @@ void Chat(int sysop)
|
||||
}
|
||||
} else if ((ch == '\r') && curpos) {
|
||||
snprintf(buf, 200, "CPUT:2,%d,%s;", mypid, clencode(sbuf));
|
||||
// Syslog('-', "> %s", buf);
|
||||
if (socket_send(buf) == 0) {
|
||||
strcpy(buf, socket_receive());
|
||||
// Syslog('-', "< %s", buf);
|
||||
if (strncmp(buf, "100:2,", 6) == 0) {
|
||||
strncpy(resp, strtok(buf, ":"), 10); /* Should be 100 */
|
||||
strncpy(resp, strtok(NULL, ","), 5); /* Should be 2 */
|
||||
strncpy(resp, strtok(NULL, ","), 5); /* 1= fatal error, end chat */
|
||||
rc = atoi(resp);
|
||||
strncpy(resp, cldecode(strtok(NULL, ";")), 80); /* The message */
|
||||
strncpy(resp, cldecode(strtok(NULL, ";")), 81); /* The message */
|
||||
DispMsg(resp);
|
||||
if (rc == 1) {
|
||||
Syslog('+', "Chat server error: %s", resp);
|
||||
@ -695,6 +689,7 @@ void Chat(int sysop)
|
||||
clrtoeol();
|
||||
set_color(WHITE, BLACK);
|
||||
mbse_mvprintw(rows - 1, 1, ">");
|
||||
mbse_mvprintw(rows - 1, width + 2, "<");
|
||||
}
|
||||
}
|
||||
|
||||
@ -707,8 +702,6 @@ void Chat(int sysop)
|
||||
if (socket_send(buf) == 0) {
|
||||
strncpy(buf, socket_receive(), sizeof(buf)-1);
|
||||
if (strncmp(buf, "100:2,", 6) == 0) {
|
||||
// Syslog('-', "> CGET:1,%d;", mypid);
|
||||
// Syslog('-', "< %s", buf);
|
||||
strncpy(resp, strtok(buf, ":"), 10); /* Should be 100 */
|
||||
strncpy(resp, strtok(NULL, ","), 5); /* Should be 2 */
|
||||
strncpy(resp, strtok(NULL, ","), 5); /* 1= fatal error */
|
||||
@ -730,10 +723,8 @@ void Chat(int sysop)
|
||||
* Close server connection
|
||||
*/
|
||||
snprintf(buf, 200, "CCLO,1,%d;", mypid);
|
||||
// Syslog('-', "> %s", buf);
|
||||
if (socket_send(buf) == 0) {
|
||||
strcpy(buf, socket_receive());
|
||||
// Syslog('-', "< %s", buf);
|
||||
}
|
||||
sleep(1);
|
||||
}
|
||||
|
@ -176,7 +176,7 @@ void clrtoeol(void)
|
||||
*/
|
||||
void Chat(char *username, char *channel)
|
||||
{
|
||||
int curpos = 0, stop = FALSE, data, rc;
|
||||
int width, curpos = 0, stop = FALSE, data, rc;
|
||||
unsigned char ch;
|
||||
char sbuf[81], resp[128], *name, *mname;
|
||||
static char buf[200];
|
||||
@ -220,19 +220,17 @@ void Chat(char *username, char *channel)
|
||||
clear();
|
||||
locate(1, 1);
|
||||
colour(WHITE, BLUE);
|
||||
clrtoeol();
|
||||
snprintf(buf, 200, "%-*s", cols -1, " MBSE BBS Chat Server");
|
||||
snprintf(buf, 200, "%-*s", cols, " MBSE BBS Chat Server");
|
||||
mvprintw(1, 1, buf);
|
||||
|
||||
mname = xstrcpy(clencode(exitinfo.sUserName));
|
||||
name = xstrcpy(clencode(exitinfo.Name));
|
||||
width = cols - (strlen(name) + 3);
|
||||
snprintf(buf, 200, "CCON,4,%d,%s,%s,0;", mypid, mname, name);
|
||||
free(mname);
|
||||
free(name);
|
||||
// Syslog('c', "> %s", buf);
|
||||
if (socket_send(buf) == 0) {
|
||||
strncpy(buf, socket_receive(), sizeof(buf)-1);
|
||||
// Syslog('c', "< %s", buf);
|
||||
if (strncmp(buf, "200:1,", 6) == 0) {
|
||||
Syslog('!', "Chatsever is not available");
|
||||
colour(LIGHTRED, BLACK);
|
||||
@ -246,14 +244,15 @@ void Chat(char *username, char *channel)
|
||||
|
||||
locate(rows - 2, 1);
|
||||
colour(WHITE, BLUE);
|
||||
clrtoeol();
|
||||
snprintf(buf, 200, "%-*s", cols -1, " Chat, type \"/EXIT\" to exit or \"/HELP\" for help");
|
||||
snprintf(buf, 200, "%-*s", cols, " Chat, type \"/EXIT\" to exit or \"/HELP\" for help");
|
||||
mvprintw(rows - 2, 1, buf);
|
||||
|
||||
colour(LIGHTGRAY, BLACK);
|
||||
colour(WHITE, BLACK);
|
||||
mvprintw(rows - 1, 1, ">");
|
||||
mvprintw(rows - 1, width + 2, "<");
|
||||
memset(&sbuf, 0, sizeof(sbuf));
|
||||
memset(&rbuf, 0, sizeof(rbuf));
|
||||
colour(LIGHTGRAY, BLACK);
|
||||
|
||||
/*
|
||||
* If username and channelname are given, send the /nick and /join
|
||||
@ -268,7 +267,6 @@ void Chat(char *username, char *channel)
|
||||
strcpy(buf, socket_receive());
|
||||
}
|
||||
|
||||
// Syslog('c', "Start loop");
|
||||
chatting = TRUE;
|
||||
|
||||
while (stop == FALSE) {
|
||||
@ -282,8 +280,6 @@ void Chat(char *username, char *channel)
|
||||
if (socket_send(buf) == 0) {
|
||||
strncpy(buf, socket_receive(), sizeof(buf)-1);
|
||||
if (strncmp(buf, "100:2,", 6) == 0) {
|
||||
// Syslog('c', "> CGET:1,%d;", mypid);
|
||||
// Syslog('c', "< %s", buf);
|
||||
strncpy(resp, strtok(buf, ":"), 10); /* Should be 100 */
|
||||
strncpy(resp, strtok(NULL, ","), 5); /* Should be 2 */
|
||||
strncpy(resp, strtok(NULL, ","), 5); /* 1= fatal, chat ended */
|
||||
@ -322,7 +318,7 @@ void Chat(char *username, char *channel)
|
||||
/* if KEY_DEL isprint, do no output again */
|
||||
} else if (isprint(ch) || traduce(&ch)) {
|
||||
alarm_on();
|
||||
if (curpos < 77) {
|
||||
if (curpos < width) {
|
||||
PUTCHAR(ch);
|
||||
sbuf[curpos] = ch;
|
||||
curpos++;
|
||||
@ -332,10 +328,8 @@ void Chat(char *username, char *channel)
|
||||
} else if ((ch == '\r') && curpos) {
|
||||
alarm_on();
|
||||
snprintf(buf, 200, "CPUT:2,%d,%s;", mypid, clencode(sbuf));
|
||||
// Syslog('c', "> %s", clencode(buf));
|
||||
if (socket_send(buf) == 0) {
|
||||
strcpy(buf, socket_receive());
|
||||
// Syslog('c', "< %s", buf);
|
||||
if (strncmp(buf, "100:2,", 6) == 0) {
|
||||
strncpy(resp, strtok(buf, ":"), 10); /* Should be 100 */
|
||||
strncpy(resp, strtok(NULL, ","), 5); /* Should be 2 */
|
||||
@ -353,7 +347,10 @@ void Chat(char *username, char *channel)
|
||||
memset(&sbuf, 0, sizeof(sbuf));
|
||||
locate(rows - 1, 2);
|
||||
clrtoeol();
|
||||
colour(WHITE, BLACK);
|
||||
mvprintw(rows - 1, 1, ">");
|
||||
mvprintw(rows - 1, width + 2, "<");
|
||||
colour(LIGHTGRAY, BLACK);
|
||||
}
|
||||
}
|
||||
chatting = FALSE;
|
||||
@ -367,8 +364,6 @@ void Chat(char *username, char *channel)
|
||||
if (socket_send(buf) == 0) {
|
||||
strncpy(buf, socket_receive(), sizeof(buf)-1);
|
||||
if (strncmp(buf, "100:2,", 6) == 0) {
|
||||
// Syslog('c', "> CGET:1,%d;", mypid);
|
||||
// Syslog('c', "< %s", buf);
|
||||
strncpy(resp, strtok(buf, ":"), 10); /* Should be 100 */
|
||||
strncpy(resp, strtok(NULL, ","), 5); /* Should be 2 */
|
||||
strncpy(resp, strtok(NULL, ","), 5); /* 1= fatal error */
|
||||
@ -404,10 +399,8 @@ void Chat(char *username, char *channel)
|
||||
* Close server connection
|
||||
*/
|
||||
snprintf(buf, 200, "CCLO,1,%d;", mypid);
|
||||
// Syslog('c', "> %s", buf);
|
||||
if (socket_send(buf) == 0) {
|
||||
strcpy(buf, socket_receive());
|
||||
// Syslog('c', "< %s", buf);
|
||||
}
|
||||
sleep(2);
|
||||
clear();
|
||||
|
@ -4,7 +4,7 @@
|
||||
* Purpose ...............: Input functions, also for some utils.
|
||||
*
|
||||
*****************************************************************************
|
||||
* Copyright (C) 1997-2005
|
||||
* Copyright (C) 1997-2006
|
||||
*
|
||||
* Michiel Broek FIDO: 2:280/2802
|
||||
* Beekmansbos 10
|
||||
@ -50,6 +50,10 @@ void CheckScreen(void)
|
||||
struct winsize ws;
|
||||
|
||||
if (ioctl(1, TIOCGWINSZ, &ws) != -1 && (ws.ws_col > 0) && (ws.ws_row > 0)) {
|
||||
if (ws.ws_col != 80)
|
||||
ws.ws_col = 80;
|
||||
if (ws.ws_row < 24)
|
||||
ws.ws_row = 24;
|
||||
if ((ws.ws_col != cols) || (ws.ws_row != rows)) {
|
||||
cols = ws.ws_col;
|
||||
rows = ws.ws_row;
|
||||
|
@ -110,7 +110,7 @@ int main(int argc, char **argv)
|
||||
if (getenv("LINES") != NULL) {
|
||||
rows = atoi(getenv("LINES"));
|
||||
} else {
|
||||
Syslog('b', "Could net get screensize from environment too");
|
||||
Syslog('b', "Could not get screensize from environment too");
|
||||
}
|
||||
/* use linux/vt.h + ioctl VT_RESIZE */
|
||||
}
|
||||
@ -195,6 +195,12 @@ int main(int argc, char **argv)
|
||||
poutCR(YELLOW, BLACK, temp);
|
||||
pout(WHITE, BLACK, (char *)COPYRIGHT);
|
||||
|
||||
/*
|
||||
* Use 80 wide screens
|
||||
*/
|
||||
if (cols > 80)
|
||||
cols = 80;
|
||||
|
||||
/*
|
||||
* Check and report screens that are too small
|
||||
*/
|
||||
|
@ -376,13 +376,13 @@ void chat_cleanuser(pid_t pid)
|
||||
*/
|
||||
void chat_msg(char *channel, char *nick, char *msg)
|
||||
{
|
||||
char buf[79];
|
||||
char buf[81];
|
||||
usr_list *tmpu;
|
||||
|
||||
if (nick == NULL)
|
||||
snprintf(buf, 79, "%s", msg);
|
||||
snprintf(buf, 81, "%s", msg);
|
||||
else
|
||||
snprintf(buf, 79, "<%s> %s", nick, msg);
|
||||
snprintf(buf, 81, "<%s> %s", nick, msg);
|
||||
Chatlog((char *)"+", channel, buf);
|
||||
|
||||
for (tmpu = users; tmpu; tmpu = tmpu->next) {
|
||||
@ -721,6 +721,10 @@ void chat_put_r(char *data, char *buf)
|
||||
goto ack;
|
||||
} else {
|
||||
chat_msg(tmpu->channel, tmpu->nick, msg);
|
||||
/*
|
||||
* Send message to all links but not the #sysop channel
|
||||
*/
|
||||
if (strcmp(tmpu->channel, "#sysop"))
|
||||
send_all("PRIVMSG %s <%s> %s\r\n", tmpu->channel, tmpu->nick, msg);
|
||||
}
|
||||
goto ack;
|
||||
|
Reference in New Issue
Block a user