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.
|
||||
|
136
mbmon/mbmon.c
136
mbmon/mbmon.c
@ -41,13 +41,19 @@ extern int bbs_free;
|
||||
|
||||
static void die(int onsig)
|
||||
{
|
||||
signal(onsig, SIG_IGN);
|
||||
screen_stop();
|
||||
if (onsig && (onsig <= NSIG))
|
||||
Syslog('?', "Finished on signal %s", SigName[onsig]);
|
||||
else
|
||||
Syslog(' ', "Normally finished");
|
||||
ExitClient(0);
|
||||
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);
|
||||
}
|
||||
|
||||
|
||||
@ -413,70 +419,78 @@ void soft_info(void)
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
struct passwd *pw;
|
||||
struct passwd *pw;
|
||||
char buf[128];
|
||||
|
||||
#ifdef MEMWATCH
|
||||
mwInit();
|
||||
mwInit();
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Find out who is on the keyboard or automated the keyboard.
|
||||
*/
|
||||
pw = getpwuid(getuid());
|
||||
InitClient(pw->pw_name);
|
||||
Syslog(' ', "Started by %s", pw->pw_name);
|
||||
bbs_free = FALSE;
|
||||
/*
|
||||
* Find out who is on the keyboard or automated the keyboard.
|
||||
*/
|
||||
pw = getpwuid(getuid());
|
||||
InitClient(pw->pw_name);
|
||||
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
|
||||
* will properly close.
|
||||
*/
|
||||
signal(SIGINT, (void (*))die);
|
||||
signal(SIGBUS, (void (*))die);
|
||||
signal(SIGSEGV,(void (*))die);
|
||||
signal(SIGTERM,(void (*))die);
|
||||
signal(SIGKILL,(void (*))die);
|
||||
/*
|
||||
* Setup several signals so when the program terminate's it
|
||||
* will properly close.
|
||||
*/
|
||||
signal(SIGINT, (void (*))die);
|
||||
signal(SIGBUS, (void (*))die);
|
||||
signal(SIGSEGV,(void (*))die);
|
||||
signal(SIGTERM,(void (*))die);
|
||||
signal(SIGKILL,(void (*))die);
|
||||
|
||||
screen_start((char *)"MBmon");
|
||||
screen_start((char *)"MBmon");
|
||||
|
||||
for (;;) {
|
||||
for (;;) {
|
||||
|
||||
IsDoing("Browsing Menu");
|
||||
clr_index();
|
||||
set_color(WHITE, BLACK);
|
||||
mvprintw( 5, 6, "0. MBSE BBS MONITOR");
|
||||
set_color(CYAN, BLACK);
|
||||
mvprintw( 7, 6, "1. View Server Clients");
|
||||
mvprintw( 8, 6, "2. View Server Statistics");
|
||||
mvprintw( 9, 6, "3. View Filesystem Usage");
|
||||
mvprintw(10, 6, "4. View BBS System Information");
|
||||
mvprintw(11, 6, "5. View BBS Lastcallers List");
|
||||
mvprintw(12, 6, "6. View Software Information");
|
||||
IsDoing("Browsing Menu");
|
||||
clr_index();
|
||||
set_color(WHITE, BLACK);
|
||||
mvprintw( 5, 6, "0. MBSE BBS MONITOR");
|
||||
set_color(CYAN, BLACK);
|
||||
mvprintw( 7, 6, "1. View Server Clients");
|
||||
mvprintw( 8, 6, "2. View Server Statistics");
|
||||
mvprintw( 9, 6, "3. View Filesystem Usage");
|
||||
mvprintw(10, 6, "4. View BBS System Information");
|
||||
mvprintw(11, 6, "5. View BBS Lastcallers List");
|
||||
mvprintw(12, 6, "6. View Software Information");
|
||||
|
||||
switch(select_menu(6)) {
|
||||
case 0:
|
||||
die(0);
|
||||
break;
|
||||
case 1:
|
||||
system_moni();
|
||||
break;
|
||||
case 2:
|
||||
system_stat();
|
||||
break;
|
||||
case 3:
|
||||
disk_stat();
|
||||
break;
|
||||
case 4:
|
||||
ShowSysinfo();
|
||||
break;
|
||||
case 5:
|
||||
ShowLastcaller();
|
||||
break;
|
||||
case 6:
|
||||
soft_info();
|
||||
break;
|
||||
}
|
||||
switch(select_menu(6)) {
|
||||
case 0:
|
||||
die(0);
|
||||
break;
|
||||
case 1:
|
||||
system_moni();
|
||||
break;
|
||||
case 2:
|
||||
system_stat();
|
||||
break;
|
||||
case 3:
|
||||
disk_stat();
|
||||
break;
|
||||
case 4:
|
||||
ShowSysinfo();
|
||||
break;
|
||||
case 5:
|
||||
ShowLastcaller();
|
||||
break;
|
||||
case 6:
|
||||
soft_info();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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 *);
|
||||
|
398
mbsebbs/mail.c
398
mbsebbs/mail.c
@ -2083,227 +2083,229 @@ int CheckUser(char *To)
|
||||
*/
|
||||
void CheckMail()
|
||||
{
|
||||
FILE *pMsgArea, *Tmp;
|
||||
int x, Found = 0;
|
||||
int Color, Count = 0, Reading;
|
||||
int OldMsgArea;
|
||||
char *temp;
|
||||
char *sFileName;
|
||||
unsigned long i, Start;
|
||||
typedef struct _Mailrec {
|
||||
long Area;
|
||||
unsigned long Msg;
|
||||
} _Mail;
|
||||
_Mail Mail;
|
||||
lastread LR;
|
||||
FILE *pMsgArea, *Tmp;
|
||||
int x, Found = 0, Color, Count = 0, Reading, OldMsgArea;
|
||||
char *temp, *sFileName;
|
||||
unsigned long i, Start;
|
||||
typedef struct _Mailrec {
|
||||
long Area;
|
||||
unsigned long Msg;
|
||||
} _Mail;
|
||||
_Mail Mail;
|
||||
lastread LR;
|
||||
|
||||
OldMsgArea = iMsgAreaNumber;
|
||||
iMsgAreaNumber = 0;
|
||||
Syslog('+', "Start checking for new mail");
|
||||
OldMsgArea = iMsgAreaNumber;
|
||||
iMsgAreaNumber = 0;
|
||||
Syslog('+', "Start checking for new mail");
|
||||
|
||||
clear();
|
||||
/* Checking your mail box ... */
|
||||
language(LIGHTGREEN, BLACK, 150);
|
||||
Enter(2);
|
||||
Color = LIGHTBLUE;
|
||||
clear();
|
||||
/* Checking your mail box ... */
|
||||
language(LIGHTGREEN, BLACK, 150);
|
||||
Enter(2);
|
||||
Color = LIGHTBLUE;
|
||||
fflush(stdout);
|
||||
|
||||
/*
|
||||
* Open temporary file
|
||||
*/
|
||||
if ((Tmp = tmpfile()) == NULL) {
|
||||
WriteError("$unable to open temporary file");
|
||||
return;
|
||||
}
|
||||
|
||||
/*
|
||||
* First check the e-mail mailbox
|
||||
*/
|
||||
temp = calloc(PATH_MAX, sizeof(char));
|
||||
if (exitinfo.Email && strlen(exitinfo.Password)) {
|
||||
check_popmail(exitinfo.Name, exitinfo.Password);
|
||||
colour(Color++, BLACK);
|
||||
printf("\re-mail Private e-mail mailbox");
|
||||
fflush(stdout);
|
||||
Count = 0;
|
||||
sprintf(temp, "%s/%s/mailbox", CFG.bbs_usersdir, exitinfo.Name);
|
||||
SetEmailArea((char *)"mailbox");
|
||||
if (Msg_Open(temp)) {
|
||||
/*
|
||||
* Check lastread pointer, if none found start
|
||||
* at the begin of the messagebase.
|
||||
*/
|
||||
LR.UserID = grecno;
|
||||
if (Msg_GetLastRead(&LR))
|
||||
Start = LR.HighReadMsg + 1;
|
||||
else
|
||||
Start = EmailBase.Lowest;
|
||||
|
||||
/*
|
||||
* Open temporary file
|
||||
*/
|
||||
if ((Tmp = tmpfile()) == NULL) {
|
||||
WriteError("$unable to open temporary file");
|
||||
return;
|
||||
}
|
||||
|
||||
/*
|
||||
* First check the e-mail mailbox
|
||||
*/
|
||||
temp = calloc(PATH_MAX, sizeof(char));
|
||||
if (exitinfo.Email && strlen(exitinfo.Password)) {
|
||||
check_popmail(exitinfo.Name, exitinfo.Password);
|
||||
colour(Color++, BLACK);
|
||||
printf("\re-mail Private e-mail mailbox");
|
||||
fflush(stdout);
|
||||
Count = 0;
|
||||
sprintf(temp, "%s/%s/mailbox", CFG.bbs_usersdir, exitinfo.Name);
|
||||
SetEmailArea((char *)"mailbox");
|
||||
if (Msg_Open(temp)) {
|
||||
for (i = Start; i <= EmailBase.Highest; i++) {
|
||||
if (Msg_ReadHeader(i)) {
|
||||
/*
|
||||
* Only check the received status of the email. The mail
|
||||
* may not be direct addressed to this user (aliases database)
|
||||
* but if it is in his mailbox it is always for the user.
|
||||
*/
|
||||
if (!Msg.Received) {
|
||||
/*
|
||||
* Check lastread pointer, if none found start
|
||||
* at the begin of the messagebase.
|
||||
* Store area and message number in temporary file.
|
||||
*/
|
||||
LR.UserID = grecno;
|
||||
if (Msg_GetLastRead(&LR))
|
||||
Start = LR.HighReadMsg + 1;
|
||||
else
|
||||
Start = EmailBase.Lowest;
|
||||
|
||||
for (i = Start; i <= EmailBase.Highest; i++) {
|
||||
if (Msg_ReadHeader(i)) {
|
||||
/*
|
||||
* Only check the received status of the email. The mail
|
||||
* may not be direct addressed to this user (aliases database)
|
||||
* but if it is in his mailbox it is always for the user.
|
||||
*/
|
||||
if (!Msg.Received) {
|
||||
/*
|
||||
* Store area and message number in temporary file.
|
||||
*/
|
||||
Mail.Area = -1; /* Means e-mail mailbox */
|
||||
Mail.Msg = Msg.Id + EmailBase.Lowest -1;
|
||||
fwrite(&Mail, sizeof(Mail), 1, Tmp);
|
||||
Count++;
|
||||
Found++;
|
||||
}
|
||||
}
|
||||
}
|
||||
Msg_Close();
|
||||
}
|
||||
if (Count) {
|
||||
colour(CFG.TextColourF, CFG.TextColourB);
|
||||
/* messages in */
|
||||
printf("\n\n%d %s private e-mail mailbox\n\n", Count, (char *)Language(213));
|
||||
Syslog('m', " %d messages in private e-mail mailbox", Count);
|
||||
Mail.Area = -1; /* Means e-mail mailbox */
|
||||
Mail.Msg = Msg.Id + EmailBase.Lowest -1;
|
||||
fwrite(&Mail, sizeof(Mail), 1, Tmp);
|
||||
Count++;
|
||||
Found++;
|
||||
}
|
||||
}
|
||||
}
|
||||
Msg_Close();
|
||||
}
|
||||
|
||||
/*
|
||||
* Open the message base configuration
|
||||
*/
|
||||
sFileName = calloc(PATH_MAX, sizeof(char));
|
||||
sprintf(sFileName,"%s/etc/mareas.data", getenv("MBSE_ROOT"));
|
||||
if((pMsgArea = fopen(sFileName, "r+")) == NULL) {
|
||||
WriteError("$Can't open: %s", sFileName);
|
||||
free(temp);
|
||||
free(sFileName);
|
||||
return;
|
||||
if (Count) {
|
||||
colour(CFG.TextColourF, CFG.TextColourB);
|
||||
/* messages in */
|
||||
printf("\n\n%d %s private e-mail mailbox\n\n", Count, (char *)Language(213));
|
||||
Syslog('m', " %d messages in private e-mail mailbox", Count);
|
||||
}
|
||||
fread(&msgshdr, sizeof(msgshdr), 1, pMsgArea);
|
||||
}
|
||||
|
||||
/*
|
||||
* Check all normal areas one by one
|
||||
*/
|
||||
while (fread(&msgs, msgshdr.recsize, 1, pMsgArea) == 1) {
|
||||
fseek(pMsgArea, msgshdr.syssize, SEEK_CUR);
|
||||
if ((msgs.Active) && (exitinfo.Security.level >= msgs.RDSec.level)) {
|
||||
SetMsgArea(iMsgAreaNumber);
|
||||
sprintf(temp, "%d", iMsgAreaNumber + 1);
|
||||
colour(Color, 0);
|
||||
if (Color < WHITE)
|
||||
Color++;
|
||||
else
|
||||
Color = LIGHTBLUE;
|
||||
printf("\r%6s %-40s", temp, sMsgAreaDesc);
|
||||
fflush(stdout);
|
||||
Count = 0;
|
||||
Nopper();
|
||||
/*
|
||||
* Open the message base configuration
|
||||
*/
|
||||
sFileName = calloc(PATH_MAX, sizeof(char));
|
||||
sprintf(sFileName,"%s/etc/mareas.data", getenv("MBSE_ROOT"));
|
||||
if((pMsgArea = fopen(sFileName, "r+")) == NULL) {
|
||||
WriteError("$Can't open: %s", sFileName);
|
||||
free(temp);
|
||||
free(sFileName);
|
||||
return;
|
||||
}
|
||||
fread(&msgshdr, sizeof(msgshdr), 1, pMsgArea);
|
||||
|
||||
if (Msg_Open(sMsgAreaBase)) {
|
||||
/*
|
||||
* Check lastread pointer, if none found start
|
||||
* at the begin of the messagebase.
|
||||
*/
|
||||
LR.UserID = grecno;
|
||||
if (Msg_GetLastRead(&LR))
|
||||
Start = LR.HighReadMsg + 1;
|
||||
else
|
||||
Start = MsgBase.Lowest;
|
||||
/*
|
||||
* Check all normal areas one by one
|
||||
*/
|
||||
while (fread(&msgs, msgshdr.recsize, 1, pMsgArea) == 1) {
|
||||
fseek(pMsgArea, msgshdr.syssize, SEEK_CUR);
|
||||
if ((msgs.Active) && (exitinfo.Security.level >= msgs.RDSec.level)) {
|
||||
SetMsgArea(iMsgAreaNumber);
|
||||
sprintf(temp, "%d", iMsgAreaNumber + 1);
|
||||
colour(Color, 0);
|
||||
if (Color < WHITE)
|
||||
Color++;
|
||||
else
|
||||
Color = LIGHTBLUE;
|
||||
printf("\r%6s %-40s", temp, sMsgAreaDesc);
|
||||
fflush(stdout);
|
||||
Count = 0;
|
||||
/*
|
||||
* Refresh timers
|
||||
*/
|
||||
Nopper();
|
||||
alarm_on();
|
||||
|
||||
for (i = Start; i <= MsgBase.Highest; i++) {
|
||||
if (Msg_ReadHeader(i)) {
|
||||
if ((!Msg.Received) && (IsMe(Msg.To))) {
|
||||
/*
|
||||
* Store area and message number
|
||||
* in temporary file.
|
||||
*/
|
||||
Mail.Area = iMsgAreaNumber;
|
||||
Mail.Msg = Msg.Id + MsgBase.Lowest -1;
|
||||
fwrite(&Mail, sizeof(Mail), 1, Tmp);
|
||||
Count++;
|
||||
Found++;
|
||||
}
|
||||
}
|
||||
}
|
||||
Msg_Close();
|
||||
}
|
||||
if (Count) {
|
||||
colour(CFG.TextColourF, CFG.TextColourB);
|
||||
/* messages in */
|
||||
printf("\n\n%d %s %s\n\n", Count, (char *)Language(213), sMsgAreaDesc);
|
||||
Syslog('m', " %d messages in %s", Count, sMsgAreaDesc);
|
||||
if (Msg_Open(sMsgAreaBase)) {
|
||||
/*
|
||||
* Check lastread pointer, if none found start
|
||||
* at the begin of the messagebase.
|
||||
*/
|
||||
LR.UserID = grecno;
|
||||
if (Msg_GetLastRead(&LR))
|
||||
Start = LR.HighReadMsg + 1;
|
||||
else
|
||||
Start = MsgBase.Lowest;
|
||||
|
||||
for (i = Start; i <= MsgBase.Highest; i++) {
|
||||
if (Msg_ReadHeader(i)) {
|
||||
if ((!Msg.Received) && (IsMe(Msg.To))) {
|
||||
/*
|
||||
* Store area and message number
|
||||
* in temporary file.
|
||||
*/
|
||||
Mail.Area = iMsgAreaNumber;
|
||||
Mail.Msg = Msg.Id + MsgBase.Lowest -1;
|
||||
fwrite(&Mail, sizeof(Mail), 1, Tmp);
|
||||
Count++;
|
||||
Found++;
|
||||
}
|
||||
}
|
||||
}
|
||||
iMsgAreaNumber++;
|
||||
Msg_Close();
|
||||
}
|
||||
if (Count) {
|
||||
colour(CFG.TextColourF, CFG.TextColourB);
|
||||
/* messages in */
|
||||
printf("\n\n%d %s %s\n\n", Count, (char *)Language(213), sMsgAreaDesc);
|
||||
Syslog('m', " %d messages in %s", Count, sMsgAreaDesc);
|
||||
}
|
||||
}
|
||||
iMsgAreaNumber++;
|
||||
}
|
||||
|
||||
fclose(pMsgArea);
|
||||
putchar('\r');
|
||||
for (i = 0; i < 48; i++)
|
||||
putchar(' ');
|
||||
putchar('\r');
|
||||
fclose(pMsgArea);
|
||||
putchar('\r');
|
||||
for (i = 0; i < 48; i++)
|
||||
putchar(' ');
|
||||
putchar('\r');
|
||||
|
||||
if (Found) {
|
||||
colour(YELLOW, BLACK);
|
||||
/* You have messages, read your mail now? [Y/n]: */
|
||||
printf("\n%s%d %s", (char *) Language(142), Found, (char *) Language(143));
|
||||
colour(CFG.InputColourF, CFG.InputColourB);
|
||||
if (Found) {
|
||||
colour(YELLOW, BLACK);
|
||||
/* You have messages, read your mail now? [Y/n]: */
|
||||
printf("\n%s%d %s", (char *) Language(142), Found, (char *) Language(143));
|
||||
colour(CFG.InputColourF, CFG.InputColourB);
|
||||
fflush(stdout);
|
||||
fflush(stdin);
|
||||
alarm_on();
|
||||
|
||||
if (toupper(Getone()) != Keystroke(143,1)) {
|
||||
rewind(Tmp);
|
||||
Reading = TRUE;
|
||||
|
||||
while ((Reading) && (fread(&Mail, sizeof(Mail), 1, Tmp) == 1)) {
|
||||
if (Mail.Area == -1) {
|
||||
/*
|
||||
* Private e-mail
|
||||
*/
|
||||
Read_a_Email(Mail.Msg);
|
||||
} else {
|
||||
SetMsgArea(Mail.Area);
|
||||
Read_a_Msg(Mail.Msg, FALSE);
|
||||
}
|
||||
/* (R)eply, (N)ext, (Q)uit */
|
||||
pout(CFG.CRColourF, CFG.CRColourB, (char *)Language(218));
|
||||
fflush(stdout);
|
||||
fflush(stdin);
|
||||
alarm_on();
|
||||
x = toupper(Getone());
|
||||
|
||||
if (toupper(Getone()) != Keystroke(143,1)) {
|
||||
rewind(Tmp);
|
||||
Reading = TRUE;
|
||||
|
||||
while ((Reading) && (fread(&Mail, sizeof(Mail), 1, Tmp) == 1)) {
|
||||
if (Mail.Area == -1) {
|
||||
/*
|
||||
* Private e-mail
|
||||
*/
|
||||
Read_a_Email(Mail.Msg);
|
||||
} else {
|
||||
SetMsgArea(Mail.Area);
|
||||
Read_a_Msg(Mail.Msg, FALSE);
|
||||
}
|
||||
/* (R)eply, (N)ext, (Q)uit */
|
||||
pout(CFG.CRColourF, CFG.CRColourB, (char *)Language(218));
|
||||
fflush(stdout);
|
||||
fflush(stdin);
|
||||
alarm_on();
|
||||
x = toupper(Getone());
|
||||
|
||||
if (x == Keystroke(218, 0)) {
|
||||
Syslog('m', " Reply!");
|
||||
if (Mail.Area == -1) {
|
||||
} else {
|
||||
Reply_Msg(TRUE);
|
||||
}
|
||||
}
|
||||
if (x == Keystroke(218, 2)) {
|
||||
Syslog('m', " Quit check for new mail");
|
||||
iMsgAreaNumber = OldMsgArea;
|
||||
fclose(Tmp);
|
||||
SetMsgArea(OldMsgArea);
|
||||
printf("\n\n");
|
||||
free(temp);
|
||||
free(sFileName);
|
||||
return;
|
||||
}
|
||||
}
|
||||
if (x == Keystroke(218, 0)) {
|
||||
Syslog('m', " Reply!");
|
||||
if (Mail.Area == -1) {
|
||||
Reply_Email(TRUE);
|
||||
} else {
|
||||
Reply_Msg(TRUE);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
language(LIGHTRED, BLACK, 144);
|
||||
Enter(1);
|
||||
sleep(3);
|
||||
} /* if (Found) */
|
||||
if (x == Keystroke(218, 2)) {
|
||||
Syslog('m', " Quit check for new mail");
|
||||
iMsgAreaNumber = OldMsgArea;
|
||||
fclose(Tmp);
|
||||
SetMsgArea(OldMsgArea);
|
||||
printf("\n\n");
|
||||
free(temp);
|
||||
free(sFileName);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
language(LIGHTRED, BLACK, 144);
|
||||
Enter(1);
|
||||
sleep(3);
|
||||
} /* if (Found) */
|
||||
|
||||
iMsgAreaNumber = OldMsgArea;
|
||||
fclose(Tmp);
|
||||
SetMsgArea(OldMsgArea);
|
||||
printf("\n\n");
|
||||
free(temp);
|
||||
free(sFileName);
|
||||
iMsgAreaNumber = OldMsgArea;
|
||||
fclose(Tmp);
|
||||
SetMsgArea(OldMsgArea);
|
||||
printf("\n\n");
|
||||
free(temp);
|
||||
free(sFileName);
|
||||
}
|
||||
|
||||
|
||||
|
@ -56,23 +56,27 @@ extern pid_t mypid; /* Pid of this program */
|
||||
void Check_PM(void);
|
||||
void Check_PM(void)
|
||||
{
|
||||
static char buf[128];
|
||||
char resp[128];
|
||||
static char buf[128];
|
||||
char resp[128];
|
||||
|
||||
sprintf(buf, "CIPM:1,%d;", mypid);
|
||||
if (socket_send(buf) == 0) {
|
||||
strcpy(buf, socket_receive());
|
||||
if (strncmp(buf, "100:0;", 6) == 0)
|
||||
return;
|
||||
sprintf(buf, "CIPM:1,%d;", mypid);
|
||||
if (socket_send(buf) == 0) {
|
||||
strcpy(buf, socket_receive());
|
||||
if (strncmp(buf, "100:0;", 6) == 0)
|
||||
return;
|
||||
|
||||
strcpy(resp, strtok(buf, ":"));
|
||||
strcpy(resp, strtok(NULL, ","));
|
||||
colour(CYAN, BLACK);
|
||||
/* ** Message ** from */
|
||||
printf("\n\n\007%s %s:\n", (char *)Language(434), strtok(NULL, ","));
|
||||
printf("%s\n", strtok(NULL, ";"));
|
||||
Pause();
|
||||
}
|
||||
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), 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());
|
||||
|
@ -77,276 +77,291 @@ int userlog(char *param)
|
||||
char *exe_cmd(char *);
|
||||
char *exe_cmd(char *in)
|
||||
{
|
||||
static char obuf[SS_BUFSIZE];
|
||||
static char ibuf[SS_BUFSIZE];
|
||||
static char cmd[4];
|
||||
static char token[SS_BUFSIZE];
|
||||
static char ebuf[19];
|
||||
static char *cnt, var1[16];
|
||||
int result;
|
||||
static char obuf[SS_BUFSIZE];
|
||||
static char ibuf[SS_BUFSIZE];
|
||||
static char cmd[4];
|
||||
static char token[SS_BUFSIZE];
|
||||
static char ebuf[19];
|
||||
static char *cnt, var1[16];
|
||||
int result;
|
||||
|
||||
strcpy(ibuf, in);
|
||||
strncpy(cmd, ibuf, 4);
|
||||
token[0] = '\0';
|
||||
strcpy(ebuf, "200:1,Syntax error;");
|
||||
strcpy(ibuf, in);
|
||||
strncpy(cmd, ibuf, 4);
|
||||
token[0] = '\0';
|
||||
strcpy(ebuf, "200:1,Syntax error;");
|
||||
|
||||
/*
|
||||
* Split the commandline after the colon so we can give the
|
||||
* options directly to the actual functions. Also set a default
|
||||
* and most used answer.
|
||||
*/
|
||||
strcpy(token, &ibuf[5]);
|
||||
strcpy(obuf, "100:0;");
|
||||
/*
|
||||
* Split the commandline after the colon so we can give the
|
||||
* options directly to the actual functions. Also set a default
|
||||
* and most used answer.
|
||||
*/
|
||||
strcpy(token, &ibuf[5]);
|
||||
strcpy(obuf, "100:0;");
|
||||
|
||||
|
||||
/*
|
||||
* The A(counting) commands.
|
||||
*
|
||||
* AINI:5,pid,tty,user,program,city;
|
||||
* 100:0;
|
||||
* 200:1,Syntax Error;
|
||||
*/
|
||||
if (strncmp(cmd, "AINI", 4) == 0) {
|
||||
if (reg_newcon(token) != -1)
|
||||
return obuf;
|
||||
else {
|
||||
stat_inc_serr();
|
||||
return ebuf;
|
||||
}
|
||||
/*
|
||||
* The A(counting) commands.
|
||||
*
|
||||
* AINI:5,pid,tty,user,program,city;
|
||||
* 100:0;
|
||||
* 200:1,Syntax Error;
|
||||
*/
|
||||
if (strncmp(cmd, "AINI", 4) == 0) {
|
||||
if (reg_newcon(token) != -1)
|
||||
return obuf;
|
||||
else {
|
||||
stat_inc_serr();
|
||||
return ebuf;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* ACLO:1,pid;
|
||||
* 107:0;
|
||||
* 200:1,Syntax Error;
|
||||
*/
|
||||
if (strncmp(cmd ,"ACLO", 4) == 0) {
|
||||
if (reg_closecon(token) == 0) {
|
||||
strcpy(obuf, "107:0;");
|
||||
return obuf;
|
||||
} else {
|
||||
stat_inc_serr();
|
||||
return ebuf;
|
||||
}
|
||||
/*
|
||||
* ACLO:1,pid;
|
||||
* 107:0;
|
||||
* 200:1,Syntax Error;
|
||||
*/
|
||||
if (strncmp(cmd ,"ACLO", 4) == 0) {
|
||||
if (reg_closecon(token) == 0) {
|
||||
strcpy(obuf, "107:0;");
|
||||
return obuf;
|
||||
} else {
|
||||
stat_inc_serr();
|
||||
return ebuf;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* ADOI:2,pid,doing;
|
||||
* 100:0;
|
||||
* 200:1,Syntax Error;
|
||||
*/
|
||||
if (strncmp(cmd, "ADOI", 4) == 0) {
|
||||
if (reg_doing(token) == 0)
|
||||
return obuf;
|
||||
else {
|
||||
stat_inc_serr();
|
||||
return ebuf;
|
||||
}
|
||||
/*
|
||||
* ADOI:2,pid,doing;
|
||||
* 100:0;
|
||||
* 200:1,Syntax Error;
|
||||
*/
|
||||
if (strncmp(cmd, "ADOI", 4) == 0) {
|
||||
if (reg_doing(token) == 0)
|
||||
return obuf;
|
||||
else {
|
||||
stat_inc_serr();
|
||||
return ebuf;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* ATCP:1,pid;
|
||||
* 100:0;
|
||||
* 200:1,Syntax Error;
|
||||
*/
|
||||
if (strncmp(cmd, "ATCP", 4) == 0) {
|
||||
if (reg_ip(token) == 0)
|
||||
return obuf;
|
||||
else {
|
||||
stat_inc_serr();
|
||||
return ebuf;
|
||||
}
|
||||
/*
|
||||
* ATCP:1,pid;
|
||||
* 100:0;
|
||||
* 200:1,Syntax Error;
|
||||
*/
|
||||
if (strncmp(cmd, "ATCP", 4) == 0) {
|
||||
if (reg_ip(token) == 0)
|
||||
return obuf;
|
||||
else {
|
||||
stat_inc_serr();
|
||||
return ebuf;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* ATTY:2,pid,tty;
|
||||
* 100:0;
|
||||
* 200:1,Syntax Error;
|
||||
*/
|
||||
if (strncmp(cmd, "ATTY", 4) == 0) {
|
||||
if (reg_tty(token) == 0)
|
||||
return obuf;
|
||||
else {
|
||||
stat_inc_serr();
|
||||
return ebuf;
|
||||
}
|
||||
/*
|
||||
* ATTY:2,pid,tty;
|
||||
* 100:0;
|
||||
* 200:1,Syntax Error;
|
||||
*/
|
||||
if (strncmp(cmd, "ATTY", 4) == 0) {
|
||||
if (reg_tty(token) == 0)
|
||||
return obuf;
|
||||
else {
|
||||
stat_inc_serr();
|
||||
return ebuf;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* ALOG:5,file,program,pid,grade,text;
|
||||
* 100:0;
|
||||
* 201:1,errno;
|
||||
*/
|
||||
if (strncmp(cmd, "ALOG", 4) == 0) {
|
||||
if (userlog(token) != 0)
|
||||
sprintf(obuf, "201:1,%d;", oserr);
|
||||
return obuf;
|
||||
}
|
||||
/*
|
||||
* ALOG:5,file,program,pid,grade,text;
|
||||
* 100:0;
|
||||
* 201:1,errno;
|
||||
*/
|
||||
if (strncmp(cmd, "ALOG", 4) == 0) {
|
||||
if (userlog(token) != 0)
|
||||
sprintf(obuf, "201:1,%d;", oserr);
|
||||
return obuf;
|
||||
}
|
||||
|
||||
/*
|
||||
* AUSR:3,pid,user,city;
|
||||
* 100:0;
|
||||
* 200:1,Syntax Error;
|
||||
*/
|
||||
if (strncmp(cmd, "AUSR", 4) == 0) {
|
||||
if (reg_user(token) == 0)
|
||||
return obuf;
|
||||
else {
|
||||
stat_inc_serr();
|
||||
return ebuf;
|
||||
}
|
||||
/*
|
||||
* AUSR:3,pid,user,city;
|
||||
* 100:0;
|
||||
* 200:1,Syntax Error;
|
||||
*/
|
||||
if (strncmp(cmd, "AUSR", 4) == 0) {
|
||||
if (reg_user(token) == 0)
|
||||
return obuf;
|
||||
else {
|
||||
stat_inc_serr();
|
||||
return ebuf;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* ADIS:2,pid,flag; (set Do Not Disturb).
|
||||
* 100:0;
|
||||
* 200:1,Syntax Error;
|
||||
*/
|
||||
if (strncmp(cmd, "ADIS", 4) == 0) {
|
||||
if (reg_silent(token) == 0)
|
||||
return obuf;
|
||||
else {
|
||||
stat_inc_serr();
|
||||
return ebuf;
|
||||
}
|
||||
/*
|
||||
* ADIS:2,pid,flag; (set Do Not Disturb).
|
||||
* 100:0;
|
||||
* 200:1,Syntax Error;
|
||||
*/
|
||||
if (strncmp(cmd, "ADIS", 4) == 0) {
|
||||
if (reg_silent(token) == 0)
|
||||
return obuf;
|
||||
else {
|
||||
stat_inc_serr();
|
||||
return ebuf;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* ATIM:2,pid,seconds;
|
||||
* 100:0;
|
||||
* 200:1,Syntax Error;
|
||||
*/
|
||||
if (strncmp(cmd, "ATIM", 4) == 0) {
|
||||
if (reg_timer(TRUE, token) == 0)
|
||||
return obuf;
|
||||
else {
|
||||
stat_inc_serr();
|
||||
return ebuf;
|
||||
}
|
||||
/*
|
||||
* ATIM:2,pid,seconds;
|
||||
* 100:0;
|
||||
* 200:1,Syntax Error;
|
||||
*/
|
||||
if (strncmp(cmd, "ATIM", 4) == 0) {
|
||||
if (reg_timer(TRUE, token) == 0)
|
||||
return obuf;
|
||||
else {
|
||||
stat_inc_serr();
|
||||
return ebuf;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* ADEF:1,pid;
|
||||
* 100:0;
|
||||
*/
|
||||
if (strncmp(cmd, "ADEF", 4) == 0) {
|
||||
if (reg_timer(FALSE, token) == 0)
|
||||
return obuf;
|
||||
else {
|
||||
stat_inc_serr();
|
||||
return ebuf;
|
||||
}
|
||||
/*
|
||||
* ADEF:1,pid;
|
||||
* 100:0;
|
||||
*/
|
||||
if (strncmp(cmd, "ADEF", 4) == 0) {
|
||||
if (reg_timer(FALSE, token) == 0)
|
||||
return obuf;
|
||||
else {
|
||||
stat_inc_serr();
|
||||
return ebuf;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* The chat commands
|
||||
*
|
||||
* CIPM:1,pid; (Is personal message present)
|
||||
* 100:2,fromname,message;
|
||||
* 100:0;
|
||||
*/
|
||||
if (strncmp(cmd, "CIPM", 4) == 0) {
|
||||
return reg_ipm(token);
|
||||
}
|
||||
/*
|
||||
* The chat commands
|
||||
*
|
||||
* 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) {
|
||||
return reg_ipm(token);
|
||||
}
|
||||
|
||||
/*
|
||||
* CSPM:3,fromuser,touser,text; (Send personal message).
|
||||
* 100:1,n; n: 0=oke, 1=donotdisturb 2=buffer full 3=error
|
||||
* 100:0;
|
||||
*/
|
||||
if (strncmp(cmd, "CSPM", 4) == 0) {
|
||||
if ((result = reg_spm(token))) {
|
||||
sprintf(obuf, "100:1,%d;", result);
|
||||
return obuf;
|
||||
} else
|
||||
return obuf;
|
||||
}
|
||||
/*
|
||||
* 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) {
|
||||
if ((result = reg_spm(token))) {
|
||||
sprintf(obuf, "100:1,%d;", result);
|
||||
return obuf;
|
||||
} else
|
||||
return obuf;
|
||||
}
|
||||
|
||||
/*
|
||||
* The G(lobal) commands.
|
||||
*
|
||||
* GNOP:1,pid;
|
||||
* 100:0;
|
||||
*/
|
||||
if (strncmp(cmd ,"GNOP", 4) == 0) {
|
||||
reg_nop(token);
|
||||
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;
|
||||
}
|
||||
|
||||
/*
|
||||
* GPNG:n,data;
|
||||
* 100:n,data;
|
||||
*/
|
||||
if (strncmp(cmd, "GPNG", 4) == 0) {
|
||||
sprintf(obuf, "100:%s", token);
|
||||
return obuf;
|
||||
}
|
||||
|
||||
/*
|
||||
* GVER:0;
|
||||
* 100:1,Version ...;
|
||||
*/
|
||||
if (strncmp(cmd, "GVER", 4) == 0) {
|
||||
sprintf(obuf, "100:1,Version %s;", VERSION);
|
||||
return obuf;
|
||||
}
|
||||
/*
|
||||
* The G(lobal) commands.
|
||||
*
|
||||
* GNOP:1,pid;
|
||||
* 100:0;
|
||||
*/
|
||||
if (strncmp(cmd ,"GNOP", 4) == 0) {
|
||||
reg_nop(token);
|
||||
return obuf;
|
||||
}
|
||||
|
||||
/*
|
||||
* GSTA:0;
|
||||
* 100:19,start,laststart,daily,startups,clients,tot_clients,tot_peak,tot_syntax,tot_comerr,
|
||||
* today_clients,today_peak,today_syntax,today_comerr,!BBSopen,ZMH,internet,Processing,Load,sequence;
|
||||
* 201:1,16;
|
||||
*/
|
||||
if (strncmp(cmd, "GSTA", 4) == 0) {
|
||||
return stat_status();
|
||||
}
|
||||
/*
|
||||
* GPNG:n,data;
|
||||
* 100:n,data;
|
||||
*/
|
||||
if (strncmp(cmd, "GPNG", 4) == 0) {
|
||||
sprintf(obuf, "100:%s", token);
|
||||
return obuf;
|
||||
}
|
||||
|
||||
/*
|
||||
* GMON:1,n; n=1 First time
|
||||
* 100:7,pid,tty,user,program,city,isdoing,starttime;
|
||||
* 100:0;
|
||||
*/
|
||||
if (strncmp(cmd, "GMON", 4) == 0) {
|
||||
cnt = strtok(token, ",");
|
||||
strcpy(var1, strtok(NULL, ";"));
|
||||
return get_reginfo(atoi(var1));
|
||||
}
|
||||
/*
|
||||
* GVER:0;
|
||||
* 100:1,Version ...;
|
||||
*/
|
||||
if (strncmp(cmd, "GVER", 4) == 0) {
|
||||
sprintf(obuf, "100:1,Version %s;", VERSION);
|
||||
return obuf;
|
||||
}
|
||||
|
||||
/*
|
||||
* GDST:0;
|
||||
* 100:n,data1,..,data10;
|
||||
*/
|
||||
if (strncmp(cmd, "GDST", 4) == 0) {
|
||||
return get_diskstat();
|
||||
}
|
||||
/*
|
||||
* GSTA:0;
|
||||
* 100:19,start,laststart,daily,startups,clients,tot_clients,tot_peak,tot_syntax,tot_comerr,
|
||||
* today_clients,today_peak,today_syntax,today_comerr,!BBSopen,ZMH,internet,Processing,Load,sequence;
|
||||
* 201:1,16;
|
||||
*/
|
||||
if (strncmp(cmd, "GSTA", 4) == 0) {
|
||||
return stat_status();
|
||||
}
|
||||
|
||||
/*
|
||||
* GSYS:0;
|
||||
* 100:7,calls,pots_calls,isdn_calls,network_calls,local_calls,startdate,last_caller;
|
||||
* 201:1,16;
|
||||
*/
|
||||
if (strncmp(cmd, "GSYS", 4) == 0) {
|
||||
return get_sysinfo();
|
||||
}
|
||||
/*
|
||||
* GMON:1,n; n=1 First time
|
||||
* 100:7,pid,tty,user,program,city,isdoing,starttime;
|
||||
* 100:0;
|
||||
*/
|
||||
if (strncmp(cmd, "GMON", 4) == 0) {
|
||||
cnt = strtok(token, ",");
|
||||
strcpy(var1, strtok(NULL, ";"));
|
||||
return get_reginfo(atoi(var1));
|
||||
}
|
||||
|
||||
/*
|
||||
* GLCC:0;
|
||||
* 100:1,n;
|
||||
*/
|
||||
if (strncmp(cmd, "GLCC", 4) == 0) {
|
||||
return get_lastcallercount();
|
||||
}
|
||||
/*
|
||||
* GDST:0;
|
||||
* 100:n,data1,..,data10;
|
||||
*/
|
||||
if (strncmp(cmd, "GDST", 4) == 0) {
|
||||
return get_diskstat();
|
||||
}
|
||||
|
||||
/*
|
||||
* GLCR:1,recno;
|
||||
* 100:9,user,location,level,device,time,mins,calls,speed,actions;
|
||||
* 201:1,16;
|
||||
*/
|
||||
if (strncmp(cmd, "GLCR", 4) == 0) {
|
||||
cnt = strtok(token, ",");
|
||||
strcpy(var1, strtok(NULL, ";"));
|
||||
return get_lastcallerrec(atoi(var1));
|
||||
}
|
||||
/*
|
||||
* GSYS:0;
|
||||
* 100:7,calls,pots_calls,isdn_calls,network_calls,local_calls,startdate,last_caller;
|
||||
* 201:1,16;
|
||||
*/
|
||||
if (strncmp(cmd, "GSYS", 4) == 0) {
|
||||
return get_sysinfo();
|
||||
}
|
||||
|
||||
/*
|
||||
* GLCC:0;
|
||||
* 100:1,n;
|
||||
*/
|
||||
if (strncmp(cmd, "GLCC", 4) == 0) {
|
||||
return get_lastcallercount();
|
||||
}
|
||||
|
||||
/*
|
||||
* GLCR:1,recno;
|
||||
* 100:9,user,location,level,device,time,mins,calls,speed,actions;
|
||||
* 201:1,16;
|
||||
*/
|
||||
if (strncmp(cmd, "GLCR", 4) == 0) {
|
||||
cnt = strtok(token, ",");
|
||||
strcpy(var1, strtok(NULL, ";"));
|
||||
return get_lastcallerrec(atoi(var1));
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
|
@ -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 */
|
||||
|
||||
|
||||
@ -48,15 +49,15 @@ int ipmailers = 0; /* TCP/IP mail sessions */
|
||||
int reg_find(char *);
|
||||
int reg_find(char *pids)
|
||||
{
|
||||
int i;
|
||||
int i;
|
||||
|
||||
for (i = 0; i < MAXCLIENT; i++) {
|
||||
if ((int)reginfo[i].pid == atoi(pids))
|
||||
return i;
|
||||
}
|
||||
for (i = 0; i < MAXCLIENT; i++) {
|
||||
if ((int)reginfo[i].pid == atoi(pids))
|
||||
return i;
|
||||
}
|
||||
|
||||
Syslog('?', "Panic, pid %s not found", pids);
|
||||
return -1;
|
||||
Syslog('?', "Panic, pid %s not found", pids);
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
@ -68,70 +69,71 @@ int reg_find(char *pids)
|
||||
|
||||
int reg_newcon(char *data)
|
||||
{
|
||||
char *cnt, *pid, *tty, *uid, *prg, *city;
|
||||
int retval;
|
||||
char *cnt, *pid, *tty, *uid, *prg, *city;
|
||||
int retval;
|
||||
|
||||
cnt = strtok(data, ",");
|
||||
pid = strtok(NULL, ",");
|
||||
tty = strtok(NULL, ",");
|
||||
uid = strtok(NULL, ",");
|
||||
prg = strtok(NULL, ",");
|
||||
city = strtok(NULL, ";");
|
||||
cnt = strtok(data, ",");
|
||||
pid = strtok(NULL, ",");
|
||||
tty = strtok(NULL, ",");
|
||||
uid = strtok(NULL, ",");
|
||||
prg = strtok(NULL, ",");
|
||||
city = strtok(NULL, ";");
|
||||
|
||||
/*
|
||||
* Abort if no empty record is found
|
||||
*/
|
||||
if ((retval = reg_find((char *)"0")) == -1) {
|
||||
Syslog('?', "Maximum clients (%d) reached", MAXCLIENT);
|
||||
return -1;
|
||||
}
|
||||
/*
|
||||
* Abort if no empty record is found
|
||||
*/
|
||||
if ((retval = reg_find((char *)"0")) == -1) {
|
||||
Syslog('?', "Maximum clients (%d) reached", MAXCLIENT);
|
||||
return -1;
|
||||
}
|
||||
|
||||
memset((char *)®info[retval], 0, sizeof(reg_info));
|
||||
reginfo[retval].pid = atoi(pid);
|
||||
strncpy((char *)®info[retval].tty, tty, 6);
|
||||
strncpy((char *)®info[retval].uname, uid, 35);
|
||||
strncpy((char *)®info[retval].prg, prg, 14);
|
||||
strncpy((char *)®info[retval].city, city, 35);
|
||||
strcpy((char *)®info[retval].doing, "-");
|
||||
reginfo[retval].started = time(NULL);
|
||||
reginfo[retval].lastcon = time(NULL);
|
||||
reginfo[retval].altime = 600;
|
||||
memset((char *)®info[retval], 0, sizeof(reg_info));
|
||||
reginfo[retval].pid = atoi(pid);
|
||||
strncpy((char *)®info[retval].tty, tty, 6);
|
||||
strncpy((char *)®info[retval].uname, uid, 35);
|
||||
strncpy((char *)®info[retval].prg, prg, 14);
|
||||
strncpy((char *)®info[retval].city, city, 35);
|
||||
strcpy((char *)®info[retval].doing, "-");
|
||||
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
|
||||
* is cleared by the owner of this process.
|
||||
*/
|
||||
reginfo[retval].silent = 1;
|
||||
/*
|
||||
* Everyone says do not disturb, unless the flag
|
||||
* is cleared by the owner of this process.
|
||||
*/
|
||||
reginfo[retval].silent = 1;
|
||||
|
||||
stat_inc_clients();
|
||||
if (strcmp(prg, (char *)"mbcico") == 0)
|
||||
mailers++;
|
||||
Syslog('-', "Registered client pgm \"%s\", pid %s, slot %d, mailers %d, TCP/IP %d",
|
||||
stat_inc_clients();
|
||||
if (strcmp(prg, (char *)"mbcico") == 0)
|
||||
mailers++;
|
||||
Syslog('-', "Registered client pgm \"%s\", pid %s, slot %d, mailers %d, TCP/IP %d",
|
||||
prg, pid, retval, mailers, ipmailers);
|
||||
return retval;
|
||||
return retval;
|
||||
}
|
||||
|
||||
|
||||
|
||||
int reg_closecon(char *data)
|
||||
{
|
||||
char *cnt, *pid;
|
||||
int rec;
|
||||
char *cnt, *pid;
|
||||
int rec;
|
||||
|
||||
cnt = strtok(data, ",");
|
||||
pid = strtok(NULL, ";");
|
||||
if ((rec = reg_find(pid)) == -1)
|
||||
return -1;
|
||||
cnt = strtok(data, ",");
|
||||
pid = strtok(NULL, ";");
|
||||
if ((rec = reg_find(pid)) == -1)
|
||||
return -1;
|
||||
|
||||
if (strcmp(reginfo[rec].prg, (char *)"mbcico") == 0)
|
||||
mailers--;
|
||||
if (reginfo[rec].istcp)
|
||||
ipmailers--;
|
||||
Syslog('-', "Unregistered client pgm \"%s\", pid %s, slot %d, mailers %d, TCP/IP %d",
|
||||
if (strcmp(reginfo[rec].prg, (char *)"mbcico") == 0)
|
||||
mailers--;
|
||||
if (reginfo[rec].istcp)
|
||||
ipmailers--;
|
||||
Syslog('-', "Unregistered client pgm \"%s\", pid %s, slot %d, mailers %d, TCP/IP %d",
|
||||
reginfo[rec].prg, pid, rec, mailers, ipmailers);
|
||||
memset(®info[rec], 0, sizeof(reg_info));
|
||||
stat_dec_clients();
|
||||
return 0;
|
||||
memset(®info[rec], 0, sizeof(reg_info));
|
||||
stat_dec_clients();
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
@ -141,44 +143,47 @@ int reg_closecon(char *data)
|
||||
*/
|
||||
void reg_check(void)
|
||||
{
|
||||
int i;
|
||||
time_t Now;
|
||||
int i;
|
||||
time_t Now;
|
||||
|
||||
Now = time(NULL);
|
||||
for (i = 1; i < MAXCLIENT; i++) {
|
||||
if (reginfo[i].pid) {
|
||||
if (kill(reginfo[i].pid, 0) == -1) {
|
||||
if (errno == ESRCH) {
|
||||
if (strcmp(reginfo[i].prg, (char *)"mbcico") == 0)
|
||||
mailers--;
|
||||
if (reginfo[i].istcp)
|
||||
ipmailers--;
|
||||
Syslog('?', "Stale registration found for pid %d (%s), mailers now %d, TCP/IP now %d",
|
||||
Now = time(NULL);
|
||||
for (i = 1; i < MAXCLIENT; i++) {
|
||||
if (reginfo[i].pid) {
|
||||
if (kill(reginfo[i].pid, 0) == -1) {
|
||||
if (errno == ESRCH) {
|
||||
if (strcmp(reginfo[i].prg, (char *)"mbcico") == 0)
|
||||
mailers--;
|
||||
if (reginfo[i].istcp)
|
||||
ipmailers--;
|
||||
Syslog('?', "Stale registration found for pid %d (%s), mailers now %d, TCP/IP now %d",
|
||||
reginfo[i].pid, reginfo[i].prg, mailers, ipmailers);
|
||||
memset(®info[i], 0, sizeof(reg_info));
|
||||
stat_dec_clients();
|
||||
}
|
||||
} else {
|
||||
/*
|
||||
* Check timeout
|
||||
*/
|
||||
if ((Now - reginfo[i].lastcon) >= reginfo[i].altime) {
|
||||
if (reginfo[i].altime < 600) {
|
||||
kill(reginfo[i].pid, SIGKILL);
|
||||
Syslog('+', "Send SIGKILL to pid %d", reginfo[i].pid);
|
||||
} else {
|
||||
kill(reginfo[i].pid, SIGTERM);
|
||||
Syslog('+', "Send SIGTERM to pid %d", reginfo[i].pid);
|
||||
}
|
||||
/*
|
||||
* 10 seconds to the next kill
|
||||
*/
|
||||
reginfo[i].altime = 10;
|
||||
reginfo[i].lastcon = time(NULL);
|
||||
}
|
||||
}
|
||||
|
||||
// FIXME: If this was a moderators chat channel, kill the whole channel
|
||||
|
||||
memset(®info[i], 0, sizeof(reg_info));
|
||||
stat_dec_clients();
|
||||
}
|
||||
} else {
|
||||
/*
|
||||
* Check timeout
|
||||
*/
|
||||
if ((Now - reginfo[i].lastcon) >= reginfo[i].altime) {
|
||||
if (reginfo[i].altime < 600) {
|
||||
kill(reginfo[i].pid, SIGKILL);
|
||||
Syslog('+', "Send SIGKILL to pid %d", reginfo[i].pid);
|
||||
} else {
|
||||
kill(reginfo[i].pid, SIGTERM);
|
||||
Syslog('+', "Send SIGTERM to pid %d", reginfo[i].pid);
|
||||
}
|
||||
/*
|
||||
* 10 seconds to the next kill
|
||||
*/
|
||||
reginfo[i].altime = 10;
|
||||
reginfo[i].lastcon = time(NULL);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -349,39 +354,56 @@ 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
|
||||
*/
|
||||
char *reg_ipm(char *data)
|
||||
{
|
||||
char *cnt, *pid;
|
||||
static char buf[128];
|
||||
int rec;
|
||||
char *cnt, *pid;
|
||||
static char buf[128];
|
||||
int rec;
|
||||
|
||||
buf[0] = '\0';
|
||||
|
||||
sprintf(buf, "100:0;");
|
||||
cnt = strtok(data, ",");
|
||||
pid = strtok(NULL, ";");
|
||||
|
||||
if ((rec = reg_find(pid)) == -1)
|
||||
return buf;
|
||||
|
||||
reginfo[rec].lastcon = time(NULL);
|
||||
if (!reginfo[rec].ismsg)
|
||||
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]);
|
||||
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);
|
||||
buf[0] = '\0';
|
||||
sprintf(buf, "100:0;");
|
||||
cnt = strtok(data, ",");
|
||||
pid = strtok(NULL, ";");
|
||||
|
||||
if ((rec = reg_find(pid)) == -1)
|
||||
return buf;
|
||||
|
||||
reginfo[rec].lastcon = time(NULL);
|
||||
if (!reginfo[rec].ismsg || (reginfo[rec].channel != -1))
|
||||
return buf;
|
||||
|
||||
buf[0] = '\0';
|
||||
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: ch=%d in=%d out=%d ismsg=%d", reginfo[rec].channel,
|
||||
reginfo[rec].ptr_in, reginfo[rec].ptr_out, reginfo[rec].ismsg);
|
||||
|
||||
return buf;
|
||||
}
|
||||
|
||||
|
||||
@ -391,51 +413,77 @@ char *reg_ipm(char *data)
|
||||
*/
|
||||
int reg_spm(char *data)
|
||||
{
|
||||
char *cnt, *from, *too, *txt;
|
||||
int i;
|
||||
char *cnt, *from, *too, *txt;
|
||||
int ch, i;
|
||||
|
||||
cnt = strtok(data, ",");
|
||||
from = strtok(NULL, ",");
|
||||
too = strtok(NULL, ",");
|
||||
txt = strtok(NULL, ";");
|
||||
cnt = strtok(data, ",");
|
||||
ch = atoi(strtok(NULL, ","));
|
||||
from = strtok(NULL, ",");
|
||||
too = 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)) {
|
||||
/*
|
||||
* If the in and out pointers are the same and the
|
||||
* message present flag is still set, then this user
|
||||
* can't get anymore new messages.
|
||||
*/
|
||||
if (reginfo[i].ismsg && (reginfo[i].ptr_in == reginfo[i].ptr_out)) {
|
||||
return 2;
|
||||
}
|
||||
Syslog('-', "SIPM:%s,%d,%s,%s,%s;", cnt, ch, from, too, txt);
|
||||
|
||||
/*
|
||||
* If user has the "do not distrurb" flag set.
|
||||
*/
|
||||
if (reginfo[i].silent) {
|
||||
return 1;
|
||||
}
|
||||
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
|
||||
* can't get anymore new messages.
|
||||
*/
|
||||
if (reginfo[i].ismsg && (reginfo[i].ptr_in == reginfo[i].ptr_out)) {
|
||||
return 2;
|
||||
}
|
||||
|
||||
/*
|
||||
* If all is well, insert the new message.
|
||||
*/
|
||||
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: in=%d out=%d ismsg=%d", reginfo[i].ptr_in, reginfo[i].ptr_out, reginfo[i].ismsg);
|
||||
return 0;
|
||||
}
|
||||
/*
|
||||
* If user has the "do not distrurb" flag set, but the sysop ignore's this.
|
||||
*/
|
||||
if (reginfo[i].silent && (ch == -1)) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
/*
|
||||
* If all is well, insert the new message.
|
||||
*/
|
||||
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: 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