Fixed small bbs problem, started chat protocol
This commit is contained in:
@@ -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());
|
||||
|
Reference in New Issue
Block a user