Fixed small bbs problem, started chat protocol

This commit is contained in:
Michiel Broek 2003-03-19 22:45:46 +00:00
parent f5a9861ead
commit 0fc8c478f4
12 changed files with 791 additions and 680 deletions

View File

@ -43,8 +43,24 @@ v0.37.2 23-Feb-2003.
Added menu 320, toggle Offline Reader Extended Info. Added menu 320, toggle Offline Reader Extended Info.
Added new control code: control-U + 8, this displays YES or NO Added new control code: control-U + 8, this displays YES or NO
for the new Extended Info setting. for the new Extended Info setting.
The display file functio now displays the ^U8 code. The display file function now displays the ^U8 code.
Added support for door32.sys dropfile. Added support for door32.sys dropfile.
Fixed user idle logoff when new mailcheck took too long.
Added email reply when reading new (e)mail.
With the CIPM and CSPM mbtask commands added the parameter for
the chat channel.
mbmon:
Reports sysop available or left the system when mbmon starts
or stops.
mbtask:
Safer logging of user log messages.
The CSPM command has an extra channel parameter.
The CIPM reply has an extra channel parameter.
In personal message text the text after a ; character is not
ignored anymore.
Added CSYS command to report if sysop is available.
lang: lang:
Changed language prompts 15 and 16. Changed language prompts 15 and 16.

5
TODO
View File

@ -22,7 +22,7 @@ mbsebbs:
N: Implement session and time/day limits. N: Implement session and time/day limits.
N: Display textfiles and archives. N: Display archives.
L: Better word wrapping or paragraph justification in editor. L: Better word wrapping or paragraph justification in editor.
@ -30,9 +30,6 @@ mbsebbs:
N: OLR, implement file requests. N: OLR, implement file requests.
N: If a new mailcheck takes longer then the idle timeout, the user is
disconnected as soon as the mailcheck is ready.
N: Only count posted messages in local mail areas. N: Only count posted messages in local mail areas.
L: ChangeHandle, allow own unix name as handle. L: ChangeHandle, allow own unix name as handle.

View File

@ -41,12 +41,18 @@ extern int bbs_free;
static void die(int onsig) static void die(int onsig)
{ {
char buf[128];
signal(onsig, SIG_IGN); signal(onsig, SIG_IGN);
screen_stop(); screen_stop();
if (onsig && (onsig <= NSIG)) if (onsig && (onsig <= NSIG))
Syslog('?', "Finished on signal %s", SigName[onsig]); Syslog('?', "Finished on signal %s", SigName[onsig]);
else else
Syslog(' ', "Normally finished"); Syslog(' ', "Normally finished");
sprintf(buf, "CSYS:1,0;");
if (socket_send(buf) == 0)
sprintf(buf, "%s", socket_receive());
ExitClient(0); ExitClient(0);
} }
@ -414,6 +420,7 @@ void soft_info(void)
int main(int argc, char *argv[]) int main(int argc, char *argv[])
{ {
struct passwd *pw; struct passwd *pw;
char buf[128];
#ifdef MEMWATCH #ifdef MEMWATCH
mwInit(); mwInit();
@ -427,6 +434,13 @@ int main(int argc, char *argv[])
Syslog(' ', "Started by %s", pw->pw_name); Syslog(' ', "Started by %s", pw->pw_name);
bbs_free = FALSE; bbs_free = FALSE;
/*
* Report sysop available for chat
*/
sprintf(buf, "CSYS:1,1;");
if (socket_send(buf) == 0)
sprintf(buf, "%s", socket_receive());
/* /*
* Setup several signals so when the program terminate's it * Setup several signals so when the program terminate's it

View File

@ -4,7 +4,7 @@
* Purpose ...............: Internet email * Purpose ...............: Internet email
* *
***************************************************************************** *****************************************************************************
* Copyright (C) 1997-2002 * Copyright (C) 1997-2003
* *
* Michiel Broek FIDO: 2:280/2802 * Michiel Broek FIDO: 2:280/2802
* Beekmansbos 10 * Beekmansbos 10
@ -65,7 +65,6 @@ extern int LC_Wrote;
int HasNoEmail(void); int HasNoEmail(void);
int Export_a_Email(unsigned long); int Export_a_Email(unsigned long);
int EmailPanel(void); int EmailPanel(void);
void Reply_Email(int);
int Save_Email(int); int Save_Email(int);

View File

@ -1,10 +1,13 @@
#ifndef _EMAIL_H #ifndef _EMAIL_H
#define _EMAIL_H #define _EMAIL_H
/* $Id$ */
void ShowEmailHdr(void); void ShowEmailHdr(void);
int Read_a_Email(unsigned long); int Read_a_Email(unsigned long);
void Read_Email(void); void Read_Email(void);
void Write_Email(void); void Write_Email(void);
void Reply_Email(int);
void QuickScan_Email(void); void QuickScan_Email(void);
void Trash_Email(void); void Trash_Email(void);
void Choose_Mailbox(char *); void Choose_Mailbox(char *);

View File

@ -2084,11 +2084,8 @@ int CheckUser(char *To)
void CheckMail() void CheckMail()
{ {
FILE *pMsgArea, *Tmp; FILE *pMsgArea, *Tmp;
int x, Found = 0; int x, Found = 0, Color, Count = 0, Reading, OldMsgArea;
int Color, Count = 0, Reading; char *temp, *sFileName;
int OldMsgArea;
char *temp;
char *sFileName;
unsigned long i, Start; unsigned long i, Start;
typedef struct _Mailrec { typedef struct _Mailrec {
long Area; long Area;
@ -2197,7 +2194,11 @@ void CheckMail()
printf("\r%6s %-40s", temp, sMsgAreaDesc); printf("\r%6s %-40s", temp, sMsgAreaDesc);
fflush(stdout); fflush(stdout);
Count = 0; Count = 0;
/*
* Refresh timers
*/
Nopper(); Nopper();
alarm_on();
if (Msg_Open(sMsgAreaBase)) { if (Msg_Open(sMsgAreaBase)) {
/* /*
@ -2276,6 +2277,7 @@ void CheckMail()
if (x == Keystroke(218, 0)) { if (x == Keystroke(218, 0)) {
Syslog('m', " Reply!"); Syslog('m', " Reply!");
if (Mail.Area == -1) { if (Mail.Area == -1) {
Reply_Email(TRUE);
} else { } else {
Reply_Msg(TRUE); Reply_Msg(TRUE);
} }

View File

@ -65,12 +65,16 @@ void Check_PM(void)
if (strncmp(buf, "100:0;", 6) == 0) if (strncmp(buf, "100:0;", 6) == 0)
return; return;
strcpy(resp, strtok(buf, ":")); strcpy(resp, strtok(buf, ":")); /* Should be 100 */
strcpy(resp, strtok(NULL, ",")); strcpy(resp, strtok(NULL, ",")); /* Should be 3 */
strcpy(resp, strtok(NULL, ",")); /* Should be channel -1 */
strncpy(resp, strtok(NULL, ","), 36); /* From Name */
colour(CYAN, BLACK); colour(CYAN, BLACK);
/* ** Message ** from */ /* ** Message ** from */
printf("\n\n\007%s %s:\n", (char *)Language(434), strtok(NULL, ",")); printf("\n\n\007%s %s:\n", (char *)Language(434), resp);
printf("%s\n", strtok(NULL, ";")); strncpy(resp, strtok(NULL, "\0"), 80); /* The real message */
resp[strlen(resp)-1] = '\0';
printf("%s\n", resp);
Pause(); Pause();
} }
} }

View File

@ -315,11 +315,11 @@ void SendOnlineMsg(char *OpData)
if ((strcmp(String, "")) != 0) { if ((strcmp(String, "")) != 0) {
buf[0] = '\0'; buf[0] = '\0';
if ((strcasecmp(OpData, "/H") == 0) && strlen(exitinfo.sHandle)) if ((strcasecmp(OpData, "/H") == 0) && strlen(exitinfo.sHandle))
sprintf(buf, "CSPM:3,%s,%s,%s;", exitinfo.sHandle, User, String); sprintf(buf, "CSPM:4,-1,%s,%s,%s;", exitinfo.sHandle, User, String);
else if (strcasecmp(OpData, "/U") == 0) else if (strcasecmp(OpData, "/U") == 0)
sprintf(buf, "CSPM:3,%s,%s,%s;", exitinfo.Name, User, String); sprintf(buf, "CSPM:4,-1,%s,%s,%s;", exitinfo.Name, User, String);
else else
sprintf(buf, "CSPM:3,%s,%s,%s;", exitinfo.sUserName, User, String); sprintf(buf, "CSPM:4,-1,%s,%s,%s;", exitinfo.sUserName, User, String);
if (socket_send(buf) == 0) { if (socket_send(buf) == 0) {
strcpy(buf, socket_receive()); strcpy(buf, socket_receive());

View File

@ -241,8 +241,12 @@ char *exe_cmd(char *in)
/* /*
* The chat commands * The chat commands
* *
* CIPM:1,pid; (Is personal message present) * Used channels: -1 Personal messages between ordinary users.
* 100:2,fromname,message; * 0 Sysop/user chat
* 1..99 Chatting channels
*
* CIPM:1,pid; (Is personal/chat message present)
* 100:3,channel,fromname,message;
* 100:0; * 100:0;
*/ */
if (strncmp(cmd, "CIPM", 4) == 0) { if (strncmp(cmd, "CIPM", 4) == 0) {
@ -250,8 +254,8 @@ char *exe_cmd(char *in)
} }
/* /*
* CSPM:3,fromuser,touser,text; (Send personal message). * CSPM:3,channel,fromuser,touser,text; (Send personal/chat message).
* 100:1,n; n: 0=oke, 1=donotdisturb 2=buffer full 3=error * 100:1,n; n: 1=donotdisturb 2=buffer full 3=error
* 100:0; * 100:0;
*/ */
if (strncmp(cmd, "CSPM", 4) == 0) { if (strncmp(cmd, "CSPM", 4) == 0) {
@ -262,6 +266,17 @@ char *exe_cmd(char *in)
return obuf; return obuf;
} }
/*
* CSYS:1,1; Sysop available for chat (from mbmon)
* CSYS:1,0; Sysop goes away (from mbmon)
* 100:0; Allways Ok.
*/
if (strncmp(cmd, "CSYS", 4) == 0) {
reg_sysop(token);
return obuf;
}
/* /*
* The G(lobal) commands. * The G(lobal) commands.
* *

View File

@ -4,7 +4,7 @@
* Purpose ...............: Buffers for registration information. * Purpose ...............: Buffers for registration information.
* *
***************************************************************************** *****************************************************************************
* Copyright (C) 1997-2001 * Copyright (C) 1997-2003
* *
* Michiel Broek FIDO: 2:280/2802 * Michiel Broek FIDO: 2:280/2802
* Beekmansbos 10 * Beekmansbos 10
@ -38,6 +38,7 @@
extern reg_info reginfo[MAXCLIENT]; /* Array with clients */ extern reg_info reginfo[MAXCLIENT]; /* Array with clients */
static int entrypos = 0; /* Status pointer */ static int entrypos = 0; /* Status pointer */
static int mailers = 0; /* Registered mailers */ static int mailers = 0; /* Registered mailers */
static int sysop_present = 0; /* Sysop present */
int ipmailers = 0; /* TCP/IP mail sessions */ int ipmailers = 0; /* TCP/IP mail sessions */
@ -96,6 +97,7 @@ int reg_newcon(char *data)
reginfo[retval].started = time(NULL); reginfo[retval].started = time(NULL);
reginfo[retval].lastcon = time(NULL); reginfo[retval].lastcon = time(NULL);
reginfo[retval].altime = 600; reginfo[retval].altime = 600;
reginfo[retval].channel = -1; /* Default chat channel */
/* /*
* Everyone says do not disturb, unless the flag * Everyone says do not disturb, unless the flag
@ -155,6 +157,9 @@ void reg_check(void)
ipmailers--; ipmailers--;
Syslog('?', "Stale registration found for pid %d (%s), mailers now %d, TCP/IP now %d", Syslog('?', "Stale registration found for pid %d (%s), mailers now %d, TCP/IP now %d",
reginfo[i].pid, reginfo[i].prg, mailers, ipmailers); reginfo[i].pid, reginfo[i].prg, mailers, ipmailers);
// FIXME: If this was a moderators chat channel, kill the whole channel
memset(&reginfo[i], 0, sizeof(reg_info)); memset(&reginfo[i], 0, sizeof(reg_info));
stat_dec_clients(); stat_dec_clients();
} }
@ -349,6 +354,21 @@ int reg_user(char *data)
/*
* Register sysop available for chat
*/
int reg_sysop(char *data)
{
char *cnt;
cnt = strtok(data, ",");
sysop_present = atoi(strtok(NULL, ";"));
Syslog('+', "Sysop present for chat: %s", sysop_present ? "True":"False");
return 0;
}
/* /*
* Check for personal message * Check for personal message
*/ */
@ -359,7 +379,6 @@ char *reg_ipm(char *data)
int rec; int rec;
buf[0] = '\0'; buf[0] = '\0';
sprintf(buf, "100:0;"); sprintf(buf, "100:0;");
cnt = strtok(data, ","); cnt = strtok(data, ",");
pid = strtok(NULL, ";"); pid = strtok(NULL, ";");
@ -368,18 +387,21 @@ char *reg_ipm(char *data)
return buf; return buf;
reginfo[rec].lastcon = time(NULL); reginfo[rec].lastcon = time(NULL);
if (!reginfo[rec].ismsg) if (!reginfo[rec].ismsg || (reginfo[rec].channel != -1))
return buf; return buf;
buf[0] = '\0'; buf[0] = '\0';
sprintf(buf, "100:2,%s,%s;", reginfo[rec].fname[reginfo[rec].ptr_out], reginfo[rec].msg[reginfo[rec].ptr_out]); sprintf(buf, "100:3,%d,%s,%s;", reginfo[rec].channel,
reginfo[rec].fname[reginfo[rec].ptr_out], reginfo[rec].msg[reginfo[rec].ptr_out]);
if (reginfo[rec].ptr_out < RB) if (reginfo[rec].ptr_out < RB)
reginfo[rec].ptr_out++; reginfo[rec].ptr_out++;
else else
reginfo[rec].ptr_out = 0; reginfo[rec].ptr_out = 0;
if (reginfo[rec].ptr_out == reginfo[rec].ptr_in) if (reginfo[rec].ptr_out == reginfo[rec].ptr_in)
reginfo[rec].ismsg = FALSE; reginfo[rec].ismsg = FALSE;
Syslog('+', "reg_ipm: in=%d out=%d ismsg=%d", reginfo[rec].ptr_in, reginfo[rec].ptr_out, reginfo[rec].ismsg);
Syslog('+', "reg_ipm: ch=%d in=%d out=%d ismsg=%d", reginfo[rec].channel,
reginfo[rec].ptr_in, reginfo[rec].ptr_out, reginfo[rec].ismsg);
return buf; return buf;
} }
@ -392,15 +414,22 @@ char *reg_ipm(char *data)
int reg_spm(char *data) int reg_spm(char *data)
{ {
char *cnt, *from, *too, *txt; char *cnt, *from, *too, *txt;
int i; int ch, i;
cnt = strtok(data, ","); cnt = strtok(data, ",");
ch = atoi(strtok(NULL, ","));
from = strtok(NULL, ","); from = strtok(NULL, ",");
too = strtok(NULL, ","); too = strtok(NULL, ",");
txt = strtok(NULL, ";"); txt = strtok(NULL, "\0");
txt[strlen(txt)-1] = '\0';
for (i = 1; i < MAXCLIENT; i++) { Syslog('-', "SIPM:%s,%d,%s,%s,%s;", cnt, ch, from, too, txt);
if (reginfo[i].pid && (strcasecmp(reginfo[i].uname, too) == 0)) {
for (i = 0; i < MAXCLIENT; i++) {
/*
* Personal messages and sysop/user chat messages.
*/
if (reginfo[i].pid && (strcasecmp(reginfo[i].uname, too) == 0) && ((ch == -1) || (ch == 0)) && (ch == reginfo[i].channel)) {
/* /*
* If the in and out pointers are the same and the * If the in and out pointers are the same and the
* message present flag is still set, then this user * message present flag is still set, then this user
@ -411,9 +440,9 @@ int reg_spm(char *data)
} }
/* /*
* If user has the "do not distrurb" flag set. * If user has the "do not distrurb" flag set, but the sysop ignore's this.
*/ */
if (reginfo[i].silent) { if (reginfo[i].silent && (ch == -1)) {
return 1; return 1;
} }
@ -427,15 +456,34 @@ int reg_spm(char *data)
else else
reginfo[i].ptr_in = 0; reginfo[i].ptr_in = 0;
reginfo[i].ismsg = TRUE; reginfo[i].ismsg = TRUE;
Syslog('+', "reg_spm: in=%d out=%d ismsg=%d", reginfo[i].ptr_in, reginfo[i].ptr_out, reginfo[i].ismsg); Syslog('+', "reg_spm: in=%d out=%d ismsg=%d", reginfo[i].ptr_in, reginfo[i].ptr_out, reginfo[i].ismsg);
return 0; return 0;
} }
}
/* /*
* User not found * Chat messages, they are send to each user that is chatting in the right channel.
*/ */
return 3; if (reginfo[i].pid && reginfo[i].chatting && reginfo[i].channel == ch) {
if (reginfo[i].ismsg && (reginfo[i].ptr_in == reginfo[i].ptr_out)) {
Syslog('!', "reg_spm: buffer full for %s", reginfo[i].uname);
} else {
strncpy((char *)&reginfo[i].fname[reginfo[i].ptr_in], from, 35);
strncpy((char *)&reginfo[i].msg[reginfo[i].ptr_in], txt, 80);
if (reginfo[i].ptr_in < RB)
reginfo[i].ptr_in++;
else
reginfo[i].ptr_in = 0;
reginfo[i].ismsg = TRUE;
Syslog('+', "reg_spm: user=%s in=%d out=%d ismsg=%d", reginfo[i].uname, reginfo[i].ptr_in,
reginfo[i].ptr_out, reginfo[i].ismsg);
}
}
}
if ((ch == -1) || (ch == 0))
return 3; // Error
return 0; // Ok
} }

View File

@ -26,16 +26,21 @@ typedef struct _reg_info {
unsigned chatting : 1; /* User is chatting */ unsigned chatting : 1; /* User is chatting */
unsigned ismsg : 1; /* Message waiting */ unsigned ismsg : 1; /* Message waiting */
unsigned istcp : 1; /* Is a TCP/IP session */ unsigned istcp : 1; /* Is a TCP/IP session */
unsigned paging : 1; /* Is paging sysop */
unsigned haspaged : 1; /* Has paged sysop */
unsigned moderator : 1; /* Is channel moderator */
int channel; /* Chat channel */ int channel; /* Chat channel */
int ptr_in; /* Input buffer pointer */ int ptr_in; /* Input buffer pointer */
int ptr_out; /* Output buffer ptr */ int ptr_out; /* Output buffer ptr */
char fname[RB][36]; /* Message from user */ char fname[RB][36]; /* Message from user */
char msg[RB][81]; /* The message itself */ char msg[RB][81]; /* The message itself */
char reason[81]; /* Chat reason */
char chname[21]; /* Short channel name */
char chsubj[61]; /* Channel subject */
} reg_info; } reg_info;
void reg_init(void);
int reg_newcon(char *); int reg_newcon(char *);
int reg_closecon(char *); int reg_closecon(char *);
void reg_check(void); void reg_check(void);
@ -50,6 +55,7 @@ char *reg_ipm(char *);
int reg_spm(char *); int reg_spm(char *);
char *reg_fre(void); char *reg_fre(void);
char *get_reginfo(int); char *get_reginfo(int);
int reg_sysop(char *);
#endif #endif

View File

@ -159,7 +159,7 @@ void Syslog(int grade, const char *format, ...)
*/ */
int ulog(char *fn, char *grade, char *prname, char *prpid, char *format) int ulog(char *fn, char *grade, char *prname, char *prpid, char *format)
{ {
int oldmask; int i, oldmask;
FILE *log; FILE *log;
oldmask = umask(066); oldmask = umask(066);
@ -172,10 +172,17 @@ int ulog(char *fn, char *grade, char *prname, char *prpid, char *format)
} }
fprintf(log, "%s %s %s[%s] ", grade, date(), prname, prpid); fprintf(log, "%s %s %s[%s] ", grade, date(), prname, prpid);
fwrite(format, strlen(format), 1, log); for (i = 0; i < strlen(format); i++) {
fprintf(log, "\n"); if (iscntrl(format[i])) {
fputc('^', log);
fputc(format[i] + 64, log);
} else {
fputc(format[i], log);
}
}
fputc('\n', log);
fflush(log); fflush(log);
if (fclose(log) != 0) { if (fclose(log) != 0) {
oserr = errno; oserr = errno;
Syslog('!', "$Cannot close user logfile %s", fn); Syslog('!', "$Cannot close user logfile %s", fn);