Fixed small bbs problem, started chat protocol
This commit is contained in:
parent
f5a9861ead
commit
0fc8c478f4
18
ChangeLog
18
ChangeLog
@ -43,8 +43,24 @@ v0.37.2 23-Feb-2003.
|
||||
Added menu 320, toggle Offline Reader Extended Info.
|
||||
Added new control code: control-U + 8, this displays YES or NO
|
||||
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.
|
||||
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:
|
||||
Changed language prompts 15 and 16.
|
||||
|
5
TODO
5
TODO
@ -22,7 +22,7 @@ mbsebbs:
|
||||
|
||||
N: Implement session and time/day limits.
|
||||
|
||||
N: Display textfiles and archives.
|
||||
N: Display archives.
|
||||
|
||||
L: Better word wrapping or paragraph justification in editor.
|
||||
|
||||
@ -30,9 +30,6 @@ mbsebbs:
|
||||
|
||||
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.
|
||||
|
||||
L: ChangeHandle, allow own unix name as handle.
|
||||
|
@ -41,12 +41,18 @@ extern int bbs_free;
|
||||
|
||||
static void die(int onsig)
|
||||
{
|
||||
char buf[128];
|
||||
|
||||
signal(onsig, SIG_IGN);
|
||||
screen_stop();
|
||||
if (onsig && (onsig <= NSIG))
|
||||
Syslog('?', "Finished on signal %s", SigName[onsig]);
|
||||
else
|
||||
Syslog(' ', "Normally finished");
|
||||
|
||||
sprintf(buf, "CSYS:1,0;");
|
||||
if (socket_send(buf) == 0)
|
||||
sprintf(buf, "%s", socket_receive());
|
||||
ExitClient(0);
|
||||
}
|
||||
|
||||
@ -414,6 +420,7 @@ void soft_info(void)
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
struct passwd *pw;
|
||||
char buf[128];
|
||||
|
||||
#ifdef MEMWATCH
|
||||
mwInit();
|
||||
@ -427,6 +434,13 @@ int main(int argc, char *argv[])
|
||||
Syslog(' ', "Started by %s", pw->pw_name);
|
||||
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
|
||||
|
@ -4,7 +4,7 @@
|
||||
* Purpose ...............: Internet email
|
||||
*
|
||||
*****************************************************************************
|
||||
* Copyright (C) 1997-2002
|
||||
* Copyright (C) 1997-2003
|
||||
*
|
||||
* Michiel Broek FIDO: 2:280/2802
|
||||
* Beekmansbos 10
|
||||
@ -65,7 +65,6 @@ extern int LC_Wrote;
|
||||
int HasNoEmail(void);
|
||||
int Export_a_Email(unsigned long);
|
||||
int EmailPanel(void);
|
||||
void Reply_Email(int);
|
||||
int Save_Email(int);
|
||||
|
||||
|
||||
|
@ -1,10 +1,13 @@
|
||||
#ifndef _EMAIL_H
|
||||
#define _EMAIL_H
|
||||
|
||||
/* $Id$ */
|
||||
|
||||
void ShowEmailHdr(void);
|
||||
int Read_a_Email(unsigned long);
|
||||
void Read_Email(void);
|
||||
void Write_Email(void);
|
||||
void Reply_Email(int);
|
||||
void QuickScan_Email(void);
|
||||
void Trash_Email(void);
|
||||
void Choose_Mailbox(char *);
|
||||
|
@ -2084,11 +2084,8 @@ int CheckUser(char *To)
|
||||
void CheckMail()
|
||||
{
|
||||
FILE *pMsgArea, *Tmp;
|
||||
int x, Found = 0;
|
||||
int Color, Count = 0, Reading;
|
||||
int OldMsgArea;
|
||||
char *temp;
|
||||
char *sFileName;
|
||||
int x, Found = 0, Color, Count = 0, Reading, OldMsgArea;
|
||||
char *temp, *sFileName;
|
||||
unsigned long i, Start;
|
||||
typedef struct _Mailrec {
|
||||
long Area;
|
||||
@ -2197,7 +2194,11 @@ void CheckMail()
|
||||
printf("\r%6s %-40s", temp, sMsgAreaDesc);
|
||||
fflush(stdout);
|
||||
Count = 0;
|
||||
/*
|
||||
* Refresh timers
|
||||
*/
|
||||
Nopper();
|
||||
alarm_on();
|
||||
|
||||
if (Msg_Open(sMsgAreaBase)) {
|
||||
/*
|
||||
@ -2276,6 +2277,7 @@ void CheckMail()
|
||||
if (x == Keystroke(218, 0)) {
|
||||
Syslog('m', " Reply!");
|
||||
if (Mail.Area == -1) {
|
||||
Reply_Email(TRUE);
|
||||
} else {
|
||||
Reply_Msg(TRUE);
|
||||
}
|
||||
|
@ -65,12 +65,16 @@ void Check_PM(void)
|
||||
if (strncmp(buf, "100:0;", 6) == 0)
|
||||
return;
|
||||
|
||||
strcpy(resp, strtok(buf, ":"));
|
||||
strcpy(resp, strtok(NULL, ","));
|
||||
strcpy(resp, strtok(buf, ":")); /* Should be 100 */
|
||||
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);
|
||||
/* ** Message ** from */
|
||||
printf("\n\n\007%s %s:\n", (char *)Language(434), strtok(NULL, ","));
|
||||
printf("%s\n", strtok(NULL, ";"));
|
||||
printf("\n\n\007%s %s:\n", (char *)Language(434), resp);
|
||||
strncpy(resp, strtok(NULL, "\0"), 80); /* The real message */
|
||||
resp[strlen(resp)-1] = '\0';
|
||||
printf("%s\n", resp);
|
||||
Pause();
|
||||
}
|
||||
}
|
||||
|
@ -315,11 +315,11 @@ void SendOnlineMsg(char *OpData)
|
||||
if ((strcmp(String, "")) != 0) {
|
||||
buf[0] = '\0';
|
||||
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)
|
||||
sprintf(buf, "CSPM:3,%s,%s,%s;", exitinfo.Name, User, String);
|
||||
sprintf(buf, "CSPM:4,-1,%s,%s,%s;", exitinfo.Name, User, String);
|
||||
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) {
|
||||
strcpy(buf, socket_receive());
|
||||
|
@ -241,8 +241,12 @@ char *exe_cmd(char *in)
|
||||
/*
|
||||
* The chat commands
|
||||
*
|
||||
* CIPM:1,pid; (Is personal message present)
|
||||
* 100:2,fromname,message;
|
||||
* Used channels: -1 Personal messages between ordinary users.
|
||||
* 0 Sysop/user chat
|
||||
* 1..99 Chatting channels
|
||||
*
|
||||
* CIPM:1,pid; (Is personal/chat message present)
|
||||
* 100:3,channel,fromname,message;
|
||||
* 100:0;
|
||||
*/
|
||||
if (strncmp(cmd, "CIPM", 4) == 0) {
|
||||
@ -250,8 +254,8 @@ char *exe_cmd(char *in)
|
||||
}
|
||||
|
||||
/*
|
||||
* CSPM:3,fromuser,touser,text; (Send personal message).
|
||||
* 100:1,n; n: 0=oke, 1=donotdisturb 2=buffer full 3=error
|
||||
* CSPM:3,channel,fromuser,touser,text; (Send personal/chat message).
|
||||
* 100:1,n; n: 1=donotdisturb 2=buffer full 3=error
|
||||
* 100:0;
|
||||
*/
|
||||
if (strncmp(cmd, "CSPM", 4) == 0) {
|
||||
@ -262,6 +266,17 @@ char *exe_cmd(char *in)
|
||||
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.
|
||||
*
|
||||
|
@ -4,7 +4,7 @@
|
||||
* Purpose ...............: Buffers for registration information.
|
||||
*
|
||||
*****************************************************************************
|
||||
* Copyright (C) 1997-2001
|
||||
* Copyright (C) 1997-2003
|
||||
*
|
||||
* Michiel Broek FIDO: 2:280/2802
|
||||
* Beekmansbos 10
|
||||
@ -38,6 +38,7 @@
|
||||
extern reg_info reginfo[MAXCLIENT]; /* Array with clients */
|
||||
static int entrypos = 0; /* Status pointer */
|
||||
static int mailers = 0; /* Registered mailers */
|
||||
static int sysop_present = 0; /* Sysop present */
|
||||
int ipmailers = 0; /* TCP/IP mail sessions */
|
||||
|
||||
|
||||
@ -96,6 +97,7 @@ int reg_newcon(char *data)
|
||||
reginfo[retval].started = time(NULL);
|
||||
reginfo[retval].lastcon = time(NULL);
|
||||
reginfo[retval].altime = 600;
|
||||
reginfo[retval].channel = -1; /* Default chat channel */
|
||||
|
||||
/*
|
||||
* Everyone says do not disturb, unless the flag
|
||||
@ -155,6 +157,9 @@ void reg_check(void)
|
||||
ipmailers--;
|
||||
Syslog('?', "Stale registration found for pid %d (%s), mailers now %d, TCP/IP now %d",
|
||||
reginfo[i].pid, reginfo[i].prg, mailers, ipmailers);
|
||||
|
||||
// FIXME: If this was a moderators chat channel, kill the whole channel
|
||||
|
||||
memset(®info[i], 0, sizeof(reg_info));
|
||||
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
|
||||
*/
|
||||
@ -359,7 +379,6 @@ char *reg_ipm(char *data)
|
||||
int rec;
|
||||
|
||||
buf[0] = '\0';
|
||||
|
||||
sprintf(buf, "100:0;");
|
||||
cnt = strtok(data, ",");
|
||||
pid = strtok(NULL, ";");
|
||||
@ -368,18 +387,21 @@ char *reg_ipm(char *data)
|
||||
return buf;
|
||||
|
||||
reginfo[rec].lastcon = time(NULL);
|
||||
if (!reginfo[rec].ismsg)
|
||||
if (!reginfo[rec].ismsg || (reginfo[rec].channel != -1))
|
||||
return buf;
|
||||
|
||||
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)
|
||||
reginfo[rec].ptr_out++;
|
||||
else
|
||||
reginfo[rec].ptr_out = 0;
|
||||
if (reginfo[rec].ptr_out == reginfo[rec].ptr_in)
|
||||
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;
|
||||
}
|
||||
@ -392,15 +414,22 @@ char *reg_ipm(char *data)
|
||||
int reg_spm(char *data)
|
||||
{
|
||||
char *cnt, *from, *too, *txt;
|
||||
int i;
|
||||
int ch, i;
|
||||
|
||||
cnt = strtok(data, ",");
|
||||
ch = atoi(strtok(NULL, ","));
|
||||
from = strtok(NULL, ",");
|
||||
too = strtok(NULL, ",");
|
||||
txt = strtok(NULL, ";");
|
||||
txt = strtok(NULL, "\0");
|
||||
txt[strlen(txt)-1] = '\0';
|
||||
|
||||
for (i = 1; i < MAXCLIENT; i++) {
|
||||
if (reginfo[i].pid && (strcasecmp(reginfo[i].uname, too) == 0)) {
|
||||
Syslog('-', "SIPM:%s,%d,%s,%s,%s;", cnt, ch, from, too, txt);
|
||||
|
||||
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
|
||||
* 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;
|
||||
}
|
||||
|
||||
@ -427,15 +456,34 @@ int reg_spm(char *data)
|
||||
else
|
||||
reginfo[i].ptr_in = 0;
|
||||
reginfo[i].ismsg = TRUE;
|
||||
|
||||
Syslog('+', "reg_spm: in=%d out=%d ismsg=%d", reginfo[i].ptr_in, reginfo[i].ptr_out, reginfo[i].ismsg);
|
||||
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 *)®info[i].fname[reginfo[i].ptr_in], from, 35);
|
||||
strncpy((char *)®info[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
|
||||
}
|
||||
|
||||
|
||||
|
@ -26,16 +26,21 @@ typedef struct _reg_info {
|
||||
unsigned chatting : 1; /* User is chatting */
|
||||
unsigned ismsg : 1; /* Message waiting */
|
||||
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 ptr_in; /* Input buffer pointer */
|
||||
int ptr_out; /* Output buffer ptr */
|
||||
char fname[RB][36]; /* Message from user */
|
||||
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;
|
||||
|
||||
|
||||
|
||||
void reg_init(void);
|
||||
int reg_newcon(char *);
|
||||
int reg_closecon(char *);
|
||||
void reg_check(void);
|
||||
@ -50,6 +55,7 @@ char *reg_ipm(char *);
|
||||
int reg_spm(char *);
|
||||
char *reg_fre(void);
|
||||
char *get_reginfo(int);
|
||||
int reg_sysop(char *);
|
||||
|
||||
#endif
|
||||
|
||||
|
@ -159,7 +159,7 @@ void Syslog(int grade, const char *format, ...)
|
||||
*/
|
||||
int ulog(char *fn, char *grade, char *prname, char *prpid, char *format)
|
||||
{
|
||||
int oldmask;
|
||||
int i, oldmask;
|
||||
FILE *log;
|
||||
|
||||
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);
|
||||
fwrite(format, strlen(format), 1, log);
|
||||
fprintf(log, "\n");
|
||||
|
||||
for (i = 0; i < strlen(format); i++) {
|
||||
if (iscntrl(format[i])) {
|
||||
fputc('^', log);
|
||||
fputc(format[i] + 64, log);
|
||||
} else {
|
||||
fputc(format[i], log);
|
||||
}
|
||||
}
|
||||
fputc('\n', log);
|
||||
fflush(log);
|
||||
|
||||
if (fclose(log) != 0) {
|
||||
oserr = errno;
|
||||
Syslog('!', "$Cannot close user logfile %s", fn);
|
||||
|
Reference in New Issue
Block a user