Some messages bugfixes

This commit is contained in:
Michiel Broek 2003-09-14 12:24:18 +00:00
parent 5bc73a973b
commit e843b06ca9
12 changed files with 418 additions and 365 deletions

View File

@ -46,6 +46,9 @@ v0.37.7 09-Sep-2003
Debug logging is now in a separate file, the normal logging is
now only in the normal logfiles.
msgbase.a:
Moved messages link from mbmsg program into library.
mbcico:
Fixed MB state error from the previous version.
Rewrote another part of the binkp driver, initializing the
@ -64,6 +67,15 @@ v0.37.7 09-Sep-2003
mbtask debug switch from menu 18.
Import and purge oneliners now log what is done.
mbmsg:
Moved message linking to msgbase library.
mbsebbs:
When a message is saved, the messages in that area are linked.
mbfido:
When mails are scanned for export via ftn and one of the from,
to or subject lines are too long, the export is cancelled.
v0.37.6 10-Aug-2003 - 09-Sep-2003

View File

@ -160,7 +160,7 @@ dbnode.o: ../config.h libs.h structs.h common.h users.h records.h clcomm.h dbcfg
dbtic.o: ../config.h libs.h structs.h users.h records.h clcomm.h dbcfg.h dbtic.h
dbuser.o: ../config.h libs.h structs.h users.h records.h dbcfg.h dbuser.h
jammsg.o: ../config.h libs.h clcomm.h msgtext.h msg.h jam.h jammsg.h
msg.o: ../config.h libs.h msgtext.h msg.h jammsg.h
msg.o: ../config.h libs.h msgtext.h msg.h clcomm.h structs.h common.h jammsg.h
msgtext.o: ../config.h libs.h msgtext.h msg.h
nntp.o: ../config.h libs.h structs.h users.h records.h clcomm.h mbinet.h
pop3.o: ../config.h libs.h structs.h users.h records.h clcomm.h mbinet.h

132
lib/msg.c
View File

@ -32,6 +32,9 @@
#include "libs.h"
#include "msgtext.h"
#include "msg.h"
#include "clcomm.h"
#include "structs.h"
#include "common.h"
#include "jammsg.h"
@ -329,3 +332,132 @@ void Msg_Write(FILE *fp)
}
typedef struct {
unsigned long Subject;
unsigned long Number;
} MSGLINK;
/*
* Link messages in one area.
* Returns -1 if error, else the number of linked messages.
*/
int Msg_Link(char *Path, int do_quiet, int slow_util)
{
int i, m, msg_link = 0;
unsigned long Number, Prev, Next, Crc, Total;
char Temp[128], *p;
MSGLINK *Link;
if (! Msg_Open(Path)) {
return -1;
}
if (!do_quiet) {
colour(12, 0);
printf(" (linking)");
colour(13, 0);
fflush(stdout);
}
if ((Total = Msg_Number()) != 0L) {
if (Msg_Lock(30L)) {
if ((Link = (MSGLINK *)malloc(Total * sizeof(MSGLINK))) != NULL) {
memset(Link, 0, Total * sizeof(MSGLINK));
Number = Msg_Lowest();
i = 0;
do {
Msg_ReadHeader(Number);
strcpy(Temp, Msg.Subject);
p = strupr(Temp);
if (!strncmp(p, "RE:", 3)) {
p += 3;
if (*p == ' ')
p++;
}
Link[i].Subject = StringCRC32(p);
Link[i].Number = Number;
i++;
if (slow_util && do_quiet && ((i % 5) == 0))
usleep(1);
if (((i % 10) == 0) && (!do_quiet)) {
printf("%6d / %6lu\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b", i, Total);
fflush(stdout);
}
} while(Msg_Next(&Number) == TRUE);
if (!do_quiet) {
printf("%6d / %6lu\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b", i, Total);
fflush(stdout);
}
Number = Msg_Lowest();
i = 0;
do {
Msg_ReadHeader(Number);
Prev = Next = 0;
Crc = Link[i].Subject;
for (m = 0; m < Total; m++) {
if (m == i)
continue;
if (Link[m].Subject == Crc) {
if (m < i)
Prev = Link[m].Number;
else if (m > i) {
Next = Link[m].Number;
break;
}
}
}
if (slow_util && do_quiet && ((i % 5) == 0))
usleep(1);
if (((i % 10) == 0) && (!do_quiet)) {
printf("%6d / %6lu\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b", i, Total);
fflush(stdout);
}
if (Msg.Original != Prev || Msg.Reply != Next) {
Msg.Original = Prev;
Msg.Reply = Next;
Msg_WriteHeader(Number);
msg_link++;
}
i++;
} while(Msg_Next(&Number) == TRUE);
if (!do_quiet) {
printf("%6d / %6lu\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b", i, Total);
fflush(stdout);
}
free(Link);
}
if (!do_quiet) {
printf(" \b\b\b\b\b\b\b\b\b\b\b\b\b\b\b");
fflush(stdout);
}
Msg_UnLock();
} else {
Syslog('+', "Can't lock %s", Path);
return -1;
}
}
Msg_Close();
if (!do_quiet) {
printf("\b\b\b\b\b\b\b\b\b\b \b\b\b\b\b\b\b\b\b\b");
fflush(stdout);
}
return msg_link;
}

View File

@ -141,7 +141,7 @@ int Msg_SetLastRead(lastread);
void Msg_UnLock(void);
int Msg_WriteHeader(unsigned long);
void Msg_Write(FILE *);
int Msg_Link(char *, int, int);
#endif

View File

@ -420,127 +420,17 @@ void DoMsgBase()
typedef struct {
unsigned long Subject;
unsigned long Number;
} MSGLINK;
void LinkArea(char *Path, long Areanr)
{
int i, m;
unsigned long Number, Prev, Next, Crc, Total;
char Temp[128], *p;
MSGLINK *Link;
int rc;
IsDoing("Linking %ld", Areanr);
IsDoing("Linking %ld", Areanr);
rc = Msg_Link(Path, do_quiet, CFG.slow_util);
if (Msg_Open(Path)) {
if (!do_quiet) {
colour(12, 0);
printf(" (linking)");
colour(13, 0);
fflush(stdout);
}
if ((Total = Msg_Number()) != 0L) {
if (Msg_Lock(30L)) {
if ((Link = (MSGLINK *)malloc(Total * sizeof(MSGLINK))) != NULL) {
memset(Link, 0, Total * sizeof(MSGLINK));
Number = Msg_Lowest();
i = 0;
do {
Msg_ReadHeader(Number);
strcpy(Temp, Msg.Subject);
p = strupr(Temp);
if (!strncmp(p, "RE:", 3)) {
p += 3;
if (*p == ' ')
p++;
}
Link[i].Subject = StringCRC32(p);
Link[i].Number = Number;
i++;
if (CFG.slow_util && do_quiet && ((i % 5) == 0))
usleep(1);
if (((i % 10) == 0) && (!do_quiet)) {
printf("%6d / %6lu\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b", i, Total);
fflush(stdout);
}
} while(Msg_Next(&Number) == TRUE);
if (!do_quiet) {
printf("%6d / %6lu\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b", i, Total);
fflush(stdout);
}
Number = Msg_Lowest();
i = 0;
do {
Msg_ReadHeader(Number);
Prev = Next = 0;
Crc = Link[i].Subject;
for (m = 0; m < Total; m++) {
if (m == i)
continue;
if (Link[m].Subject == Crc) {
if (m < i)
Prev = Link[m].Number;
else if (m > i) {
Next = Link[m].Number;
break;
}
}
}
if (CFG.slow_util && do_quiet && ((i % 5) == 0))
usleep(1);
if (((i % 10) == 0) && (!do_quiet)) {
printf("%6d / %6lu\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b", i, Total);
fflush(stdout);
}
if (Msg.Original != Prev || Msg.Reply != Next) {
Msg.Original = Prev;
Msg.Reply = Next;
Msg_WriteHeader(Number);
processed = TRUE;
msg_link++;
}
i++;
} while(Msg_Next(&Number) == TRUE);
if (!do_quiet) {
printf("%6d / %6lu\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b", i, Total);
fflush(stdout);
}
free(Link);
}
if (!do_quiet) {
printf(" \b\b\b\b\b\b\b\b\b\b\b\b\b\b\b");
fflush(stdout);
}
Msg_UnLock();
} else {
Syslog('+', "Can't lock %s", Path);
}
}
Msg_Close();
if (!do_quiet) {
printf("\b\b\b\b\b\b\b\b\b\b \b\b\b\b\b\b\b\b\b\b");
fflush(stdout);
}
}
if (rc != -1) {
msg_link = rc;
processed = TRUE;
}
}

View File

@ -141,195 +141,192 @@ void ScanMail(int DoAll)
void ScanFull()
{
char *sAreas, sbe[128];
FILE *pAreas;
long arearec = 0, sysstart, nextstart;
unsigned long Total, Number;
int i;
sysconnect Link;
fa_list *sbl = NULL;
char *sAreas, sbe[128];
FILE *pAreas;
long arearec = 0, sysstart, nextstart;
unsigned long Total, Number;
int i;
sysconnect Link;
fa_list *sbl = NULL;
Syslog('+', "Full mailscan");
IsDoing("Scanning mail");
Syslog('+', "Full mailscan");
IsDoing("Scanning mail");
if (!do_quiet) {
colour(9, 0);
printf("Scanning mail\n");
colour(3, 0);
fflush(stdout);
}
if (!do_quiet) {
colour(9, 0);
printf("Scanning mail\n");
colour(3, 0);
fflush(stdout);
}
sAreas = calloc(PATH_MAX, sizeof(char));
sprintf(sAreas, "%s/etc/users.data", getenv("MBSE_ROOT"));
if ((pAreas = fopen(sAreas, "r")) != NULL) {
fread(&usrconfighdr, sizeof(usrconfighdr), 1, pAreas);
sAreas = calloc(PATH_MAX, sizeof(char));
sprintf(sAreas, "%s/etc/users.data", getenv("MBSE_ROOT"));
if ((pAreas = fopen(sAreas, "r")) != NULL) {
fread(&usrconfighdr, sizeof(usrconfighdr), 1, pAreas);
while (fread(&usrconfig, usrconfighdr.recsize, 1, pAreas) == 1) {
if (usrconfig.Email && strlen(usrconfig.Name)) {
while (fread(&usrconfig, usrconfighdr.recsize, 1, pAreas) == 1) {
if (usrconfig.Email && strlen(usrconfig.Name)) {
Nopper();
if (!do_quiet) {
colour(3, 0);
printf("\r%8s %-40s", usrconfig.Name, usrconfig.sUserName);
colour(13, 0);
fflush(stdout);
}
sprintf(sAreas, "%s/%s/mailbox", CFG.bbs_usersdir, usrconfig.Name);
if (Msg_Open(sAreas)) {
if ((Total = Msg_Number()) != 0L) {
Number = Msg_Lowest();
do {
if (CFG.slow_util && do_quiet)
usleep(1);
if (((Number % 10) == 0) && (!do_quiet)) {
printf("%6lu\b\b\b\b\b\b", Number);
fflush(stdout);
}
Msg_ReadHeader(Number);
if (Msg.Local) {
if (Msg_Lock(15L)) {
Syslog('m', "Export %lu email from %s", Number, usrconfig.Name);
ExportEmail(Number);
Msg.Local = FALSE;
Msg.Arrived = time(NULL);
Msg_WriteHeader(Number);
Msg_UnLock();
}
}
} while (Msg_Next(&Number) == TRUE);
}
Msg_Close();
if (!do_quiet) {
printf(" \b\b\b\b\b\b");
fflush(stdout);
}
}
}
Nopper();
if (!do_quiet) {
colour(3, 0);
printf("\r%8s %-40s", usrconfig.Name, usrconfig.sUserName);
colour(13, 0);
fflush(stdout);
}
fclose(pAreas);
}
sprintf(sAreas, "%s/etc/mareas.data", getenv("MBSE_ROOT"));
if ((pAreas = fopen(sAreas, "r")) == NULL) {
WriteError("Can't open %s", sAreas);
free(sAreas);
return;
}
free(sAreas);
fread(&msgshdr, sizeof(msgshdr), 1, pAreas);
sprintf(sAreas, "%s/%s/mailbox", CFG.bbs_usersdir, usrconfig.Name);
if (Msg_Open(sAreas)) {
if ((Total = Msg_Number()) != 0L) {
Number = Msg_Lowest();
while (fread(&msgs, msgshdr.recsize, 1, pAreas) == 1) {
sysstart = ftell(pAreas);
fseek(pAreas, msgshdr.syssize, SEEK_CUR);
nextstart = ftell(pAreas);
arearec++;
do {
if (CFG.slow_util && do_quiet)
usleep(1);
if ((msgs.Active) && (msgs.Type == ECHOMAIL || msgs.Type == NETMAIL || msgs.Type == NEWS)) {
Nopper();
if (!do_quiet) {
colour(3, 0);
printf("\r%5ld .. %-40s", arearec, msgs.Name);
colour(13, 0);
if (((Number % 10) == 0) && (!do_quiet)) {
printf("%6lu\b\b\b\b\b\b", Number);
fflush(stdout);
}
}
if (Msg_Open(msgs.Base)) {
if ((Total = Msg_Number()) != 0L) {
Number = Msg_Lowest();
do {
if (CFG.slow_util && do_quiet)
usleep(1);
if (((Number % 10) == 0) && (!do_quiet)) {
printf("%6lu\b\b\b\b\b\b", Number);
fflush(stdout);
}
Msg_ReadHeader(Number);
if (Msg.Local) {
if (Msg_Lock(15L)) {
Syslog('m', "Export %lu from area %ld", Number, arearec);
/*
* Setup SEEN-BY lines
*/
if ((msgs.Type == ECHOMAIL) || (msgs.Type == NEWS)) {
echo_in++;
fill_list(&sbl, aka2str(msgs.Aka), NULL);
for (i = 0; i < 40; i++) {
if (CFG.akavalid[i] &&
(msgs.Aka.zone == CFG.aka[i].zone) &&
(CFG.aka[i].point == 0) &&
!((msgs.Aka.net == CFG.aka[i].net) &&
(msgs.Aka.node == CFG.aka[i].node))) {
sprintf(sbe, "%u/%u", CFG.aka[i].net,
CFG.aka[i].node);
fill_list(&sbl, sbe, NULL);
}
}
fseek(pAreas, sysstart, SEEK_SET);
for (i = 0; i < (msgshdr.syssize / sizeof(sysconnect)); i++) {
fread(&Link, sizeof(sysconnect), 1, pAreas);
if ((Link.aka.zone) && (Link.sendto) && (!Link.pause)) {
fill_list(&sbl, aka2str(Link.aka), NULL);
}
}
uniq_list(&sbl);
sort_list(&sbl);
fseek(pAreas, sysstart, SEEK_SET);
for (i = 0; i < (msgshdr.syssize / sizeof(sysconnect)); i++) {
fread(&Link, sizeof(sysconnect), 1, pAreas);
if (Link.aka.zone)
ExportEcho(Link, Number, &sbl);
}
if (strlen(msgs.Newsgroup))
ExportNews(Number, &sbl);
tidy_falist(&sbl);
}
if (msgs.Type == NETMAIL) {
ExportNet(Number, FALSE);
most_debug = FALSE;
}
Msg.Local = FALSE;
Msg.Arrived = time(NULL);
Msg_WriteHeader(Number);
Msg_UnLock();
}
}
} while (Msg_Next(&Number) == TRUE);
Msg_ReadHeader(Number);
if (Msg.Local) {
if (Msg_Lock(15L)) {
Syslog('m', "Export %lu email from %s", Number, usrconfig.Name);
ExportEmail(Number);
Msg.Local = FALSE;
Msg.Arrived = time(NULL);
Msg_WriteHeader(Number);
Msg_UnLock();
}
}
Msg_Close();
if (!do_quiet) {
printf(" \b\b\b\b\b\b");
fflush(stdout);
}
}
/*
* Make sure to start at the next area.
*/
fseek(pAreas, nextstart, SEEK_SET);
} while (Msg_Next(&Number) == TRUE);
}
Msg_Close();
if (!do_quiet) {
printf(" \b\b\b\b\b\b");
fflush(stdout);
}
}
}
}
fclose(pAreas);
}
if (!do_quiet) {
printf("\r \r");
sprintf(sAreas, "%s/etc/mareas.data", getenv("MBSE_ROOT"));
if ((pAreas = fopen(sAreas, "r")) == NULL) {
WriteError("Can't open %s", sAreas);
free(sAreas);
return;
}
free(sAreas);
fread(&msgshdr, sizeof(msgshdr), 1, pAreas);
while (fread(&msgs, msgshdr.recsize, 1, pAreas) == 1) {
sysstart = ftell(pAreas);
fseek(pAreas, msgshdr.syssize, SEEK_CUR);
nextstart = ftell(pAreas);
arearec++;
if ((msgs.Active) && (msgs.Type == ECHOMAIL || msgs.Type == NETMAIL || msgs.Type == NEWS)) {
Nopper();
if (!do_quiet) {
colour(3, 0);
printf("\r%5ld .. %-40s", arearec, msgs.Name);
colour(13, 0);
fflush(stdout);
}
if (Msg_Open(msgs.Base)) {
if ((Total = Msg_Number()) != 0L) {
Number = Msg_Lowest();
do {
if (CFG.slow_util && do_quiet)
usleep(1);
if (((Number % 10) == 0) && (!do_quiet)) {
printf("%6lu\b\b\b\b\b\b", Number);
fflush(stdout);
}
Msg_ReadHeader(Number);
if (Msg.Local) {
if (Msg_Lock(15L)) {
Syslog('m', "Export %lu from area %ld", Number, arearec);
/*
* Setup SEEN-BY lines
*/
if ((msgs.Type == ECHOMAIL) || (msgs.Type == NEWS)) {
echo_in++;
fill_list(&sbl, aka2str(msgs.Aka), NULL);
for (i = 0; i < 40; i++) {
if (CFG.akavalid[i] && (msgs.Aka.zone == CFG.aka[i].zone) &&
(CFG.aka[i].point == 0) && !((msgs.Aka.net == CFG.aka[i].net) &&
(msgs.Aka.node == CFG.aka[i].node))) {
sprintf(sbe, "%u/%u", CFG.aka[i].net, CFG.aka[i].node);
fill_list(&sbl, sbe, NULL);
}
}
fseek(pAreas, sysstart, SEEK_SET);
for (i = 0; i < (msgshdr.syssize / sizeof(sysconnect)); i++) {
fread(&Link, sizeof(sysconnect), 1, pAreas);
if ((Link.aka.zone) && (Link.sendto) && (!Link.pause)) {
fill_list(&sbl, aka2str(Link.aka), NULL);
}
}
uniq_list(&sbl);
sort_list(&sbl);
fseek(pAreas, sysstart, SEEK_SET);
for (i = 0; i < (msgshdr.syssize / sizeof(sysconnect)); i++) {
fread(&Link, sizeof(sysconnect), 1, pAreas);
if (Link.aka.zone)
ExportEcho(Link, Number, &sbl);
}
if (strlen(msgs.Newsgroup))
ExportNews(Number, &sbl);
tidy_falist(&sbl);
}
if (msgs.Type == NETMAIL) {
ExportNet(Number, FALSE);
most_debug = FALSE;
}
Msg.Local = FALSE;
Msg.Arrived = time(NULL);
Msg_WriteHeader(Number);
Msg_UnLock();
}
}
} while (Msg_Next(&Number) == TRUE);
}
Msg_Close();
if (!do_quiet) {
printf(" \b\b\b\b\b\b");
fflush(stdout);
}
}
/*
* Make sure to start at the next area.
*/
fseek(pAreas, nextstart, SEEK_SET);
}
}
fclose(pAreas);
if (!do_quiet) {
printf("\r \r");
fflush(stdout);
}
}
@ -573,7 +570,7 @@ int RescanOne(faddr *L, char *marea, unsigned long Num)
*/
void ExportEcho(sysconnect L, unsigned long MsgNum, fa_list **sbl)
{
int seenlen, oldnet, flags = 0, kludges = TRUE;
int rc, seenlen, oldnet, flags = 0, kludges = TRUE;
char *p, sbe[16], ext[4];
fa_list *tmpl;
FILE *qp;
@ -612,9 +609,16 @@ void ExportEcho(sysconnect L, unsigned long MsgNum, fa_list **sbl)
flags |= (Msg.Private) ? M_PVT : 0;
from = fido2faddr(msgs.Aka);
dest = fido2faddr(L.aka);
AddMsgHdr(qp, from, dest, flags, 0, Msg.Written, Msg.To, Msg.From, Msg.Subject);
rc = AddMsgHdr(qp, from, dest, flags, 0, Msg.Written, Msg.To, Msg.From, Msg.Subject);
tidy_faddr(from);
tidy_faddr(dest);
if (rc) {
Syslog('+', "Cannot export message");
fclose(qp);
return;
}
fprintf(qp, "AREA:%s\r", msgs.Tag);
if (Msg_Read(MsgNum, 78)) {

View File

@ -360,7 +360,7 @@ int Save_Email(int IsReply)
}
free(temp);
Msg_Close();
Close_Msgbase(sMailpath);
return TRUE;
}

View File

@ -684,7 +684,7 @@ int Save_Msg(int IsReply, faddr *Dest)
}
}
free(temp);
Msg_Close();
Close_Msgbase(msgs.Base);
SetMsgArea(iMsgAreaNumber);
return TRUE;

View File

@ -44,6 +44,7 @@
int BaseWrite = FALSE;
int NewMessages = FALSE;
static char *wdays[]={(char *)"Sun",(char *)"Mon",(char *)"Tue",(char *)"Wed",
(char *)"Thu",(char *)"Fri",(char *)"Sat"};
@ -113,6 +114,7 @@ char *rfcdate(time_t now)
int Open_Msgbase(char *Base, int Mode)
{
BaseWrite = FALSE;
NewMessages = FALSE;
if (!Msg_Open(Base))
return FALSE;
@ -134,11 +136,21 @@ int Open_Msgbase(char *Base, int Mode)
/*
* Close current messagebase.
*/
void Close_Msgbase()
void Close_Msgbase(char *Base)
{
int rc;
Syslog('b', "Close_Msgbase(%s) BaseWrite=%s NewMessages=%s", Base, BaseWrite?"TRUE":"FALSE", NewMessages?"TRUE":"FALSE");
if (BaseWrite) {
Msg_UnLock();
BaseWrite = FALSE;
if (NewMessages) {
rc = Msg_Link(Base, TRUE, CFG.slow_util);
if (rc != -1)
Syslog('+', "Linked %d message%s", rc, (rc != 1) ? "s":"");
else
Syslog('+', "Could not link messages");
}
}
Msg_Close();
}
@ -297,6 +309,7 @@ void Add_Footkludges(int Quote, char *tear, int HasTear)
free(aka);
free(temp);
NewMessages = TRUE;
}

View File

@ -5,7 +5,7 @@
char *rfcdate(time_t); /* Create RFC style date */
int Open_Msgbase(char *, int); /* Open msgbase for read/write */
void Close_Msgbase(void); /* Close msgbase */
void Close_Msgbase(char *); /* Close msgbase */
void Add_Headkludges(faddr *, int); /* Header part of kludges */
void Add_Footkludges(int, char *, int); /* Footer part of kludges */
void Sema_Mailout(void); /* Set mailout semafore */

View File

@ -1692,7 +1692,7 @@ void BlueWave_Fetch()
fclose(fp);
}
}
Msg_Close();
Close_Msgbase(msgs.Base);
}
} else {
/* No Write access to area */
@ -2493,7 +2493,7 @@ void QWK_Fetch()
fclose(fp);
}
}
Msg_Close();
Close_Msgbase(msgs.Base);
}
} else {
Syslog('+', "Can't post messages in area %u", Area);

View File

@ -4,7 +4,7 @@
* Purpose ...............: POP3 client
*
*****************************************************************************
* Copyright (C) 1997-2002
* Copyright (C) 1997-2003
*
* Michiel Broek FIDO: 2:280/2802
* Beekmansbos 10
@ -47,14 +47,14 @@
void error_popmail(char *);
void error_popmail(char *umsg)
{
char *p;
char *p;
pop3_send((char *)"QUIT\r\n");
p = pop3_receive();
pop3_close();
colour(LIGHTRED, BLACK);
printf("%s\r\n", umsg);
fflush(stdout);
pop3_send((char *)"QUIT\r\n");
p = pop3_receive();
pop3_close();
colour(LIGHTRED, BLACK);
printf("%s\r\n", umsg);
fflush(stdout);
}
@ -62,69 +62,71 @@ void error_popmail(char *umsg)
void retr_msg(int);
void retr_msg(int msgnum)
{
char *p, *q, temp[128];
int Header;
unsigned long crc = -1;
char *p, *q, temp[PATH_MAX], *base;
int Header;
unsigned long crc = -1;
sprintf(temp, "RETR %d\r\n", msgnum);
if (pop3_cmd(temp) == 0) {
Msg_New();
Header = TRUE;
sprintf(temp, "%s/%s/mailbox", CFG.bbs_usersdir, exitinfo.Name);
Open_Msgbase(temp, 'w');
Msg.Arrived = time(NULL) - (gmt_offset((time_t)0) * 60);
Msg.Private = TRUE;
while (TRUE) {
p = pop3_receive();
if ((p[0] == '.') && (strlen(p) == 1)) {
break;
} else {
if (Header) {
/*
* Check the primary message header lines.
*/
if (strncmp(p, "To: ", 4) == 0) {
if (strlen(p) > 104)
p[104] = '\0';
sprintf(Msg.To, "%s", p+4);
}
if (strncmp(p, "From: ", 6) == 0) {
if (strlen(p) > 106)
p[106] = '\0';
sprintf(Msg.From, "%s", p+6);
}
if (strncmp(p, "Subject: ", 9) == 0) {
if (strlen(p) > 109)
p[109] = '\0';
sprintf(Msg.Subject, "%s", p+9);
}
if (strncmp(p, "Date: ", 6) == 0)
Msg.Written = parsedate(p+6, NULL) - (gmt_offset((time_t)0) * 60);
if (strncmp(p, "Message-Id: ", 12) == 0) {
q = xstrcpy(p+12);
Msg.MsgIdCRC = upd_crc32(q, crc, strlen(q));
free(q);
}
Msg.ReplyCRC = 0xffffffff;
if (strlen(p) == 0) {
Header = FALSE;
} else {
sprintf(temp, "\001%s", p);
MsgText_Add2(temp);
}
} else {
MsgText_Add2(p);
}
}
sprintf(temp, "RETR %d\r\n", msgnum);
if (pop3_cmd(temp) == 0) {
Msg_New();
Header = TRUE;
sprintf(temp, "%s/%s/mailbox", CFG.bbs_usersdir, exitinfo.Name);
base = xstrcpy(temp);
Open_Msgbase(base, 'w');
Msg.Arrived = time(NULL) - (gmt_offset((time_t)0) * 60);
Msg.Private = TRUE;
while (TRUE) {
p = pop3_receive();
if ((p[0] == '.') && (strlen(p) == 1)) {
break;
} else {
if (Header) {
/*
* Check the primary message header lines.
*/
if (strncmp(p, "To: ", 4) == 0) {
if (strlen(p) > 104)
p[104] = '\0';
sprintf(Msg.To, "%s", p+4);
}
if (strncmp(p, "From: ", 6) == 0) {
if (strlen(p) > 106)
p[106] = '\0';
sprintf(Msg.From, "%s", p+6);
}
if (strncmp(p, "Subject: ", 9) == 0) {
if (strlen(p) > 109)
p[109] = '\0';
sprintf(Msg.Subject, "%s", p+9);
}
if (strncmp(p, "Date: ", 6) == 0)
Msg.Written = parsedate(p+6, NULL) - (gmt_offset((time_t)0) * 60);
if (strncmp(p, "Message-Id: ", 12) == 0) {
q = xstrcpy(p+12);
Msg.MsgIdCRC = upd_crc32(q, crc, strlen(q));
free(q);
}
Msg.ReplyCRC = 0xffffffff;
if (strlen(p) == 0) {
Header = FALSE;
} else {
sprintf(temp, "\001%s", p);
MsgText_Add2(temp);
}
} else {
MsgText_Add2(p);
}
Msg_AddMsg();
Msg_UnLock();
Msg_Close();
sprintf(temp, "DELE %d\r\n", msgnum);
pop3_cmd(temp);
} else {
WriteError("POP3: Can't retrieve message %d", msgnum);
}
}
Msg_AddMsg();
Msg_UnLock();
Close_Msgbase(base);
free(base);
sprintf(temp, "DELE %d\r\n", msgnum);
pop3_cmd(temp);
} else {
WriteError("POP3: Can't retrieve message %d", msgnum);
}
}