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 Debug logging is now in a separate file, the normal logging is
now only in the normal logfiles. now only in the normal logfiles.
msgbase.a:
Moved messages link from mbmsg program into library.
mbcico: mbcico:
Fixed MB state error from the previous version. Fixed MB state error from the previous version.
Rewrote another part of the binkp driver, initializing the 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. mbtask debug switch from menu 18.
Import and purge oneliners now log what is done. 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 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 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 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 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 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 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 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 "libs.h"
#include "msgtext.h" #include "msgtext.h"
#include "msg.h" #include "msg.h"
#include "clcomm.h"
#include "structs.h"
#include "common.h"
#include "jammsg.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); void Msg_UnLock(void);
int Msg_WriteHeader(unsigned long); int Msg_WriteHeader(unsigned long);
void Msg_Write(FILE *); void Msg_Write(FILE *);
int Msg_Link(char *, int, int);
#endif #endif

View File

@ -420,127 +420,17 @@ void DoMsgBase()
typedef struct {
unsigned long Subject;
unsigned long Number;
} MSGLINK;
void LinkArea(char *Path, long Areanr) void LinkArea(char *Path, long Areanr)
{ {
int i, m; int rc;
unsigned long Number, Prev, Next, Crc, Total;
char Temp[128], *p;
MSGLINK *Link;
IsDoing("Linking %ld", Areanr);
if (Msg_Open(Path)) { IsDoing("Linking %ld", Areanr);
if (!do_quiet) { rc = Msg_Link(Path, do_quiet, CFG.slow_util);
colour(12, 0);
printf(" (linking)");
colour(13, 0);
fflush(stdout);
}
if ((Total = Msg_Number()) != 0L) { if (rc != -1) {
if (Msg_Lock(30L)) { msg_link = rc;
if ((Link = (MSGLINK *)malloc(Total * sizeof(MSGLINK))) != NULL) { processed = TRUE;
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);
}
}
} }

View File

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

View File

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

View File

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

View File

@ -44,6 +44,7 @@
int BaseWrite = FALSE; int BaseWrite = FALSE;
int NewMessages = FALSE;
static char *wdays[]={(char *)"Sun",(char *)"Mon",(char *)"Tue",(char *)"Wed", static char *wdays[]={(char *)"Sun",(char *)"Mon",(char *)"Tue",(char *)"Wed",
(char *)"Thu",(char *)"Fri",(char *)"Sat"}; (char *)"Thu",(char *)"Fri",(char *)"Sat"};
@ -113,6 +114,7 @@ char *rfcdate(time_t now)
int Open_Msgbase(char *Base, int Mode) int Open_Msgbase(char *Base, int Mode)
{ {
BaseWrite = FALSE; BaseWrite = FALSE;
NewMessages = FALSE;
if (!Msg_Open(Base)) if (!Msg_Open(Base))
return FALSE; return FALSE;
@ -134,11 +136,21 @@ int Open_Msgbase(char *Base, int Mode)
/* /*
* Close current messagebase. * 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) { if (BaseWrite) {
Msg_UnLock(); Msg_UnLock();
BaseWrite = FALSE; 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(); Msg_Close();
} }
@ -297,6 +309,7 @@ void Add_Footkludges(int Quote, char *tear, int HasTear)
free(aka); free(aka);
free(temp); free(temp);
NewMessages = TRUE;
} }

View File

@ -5,7 +5,7 @@
char *rfcdate(time_t); /* Create RFC style date */ char *rfcdate(time_t); /* Create RFC style date */
int Open_Msgbase(char *, int); /* Open msgbase for read/write */ 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_Headkludges(faddr *, int); /* Header part of kludges */
void Add_Footkludges(int, char *, int); /* Footer part of kludges */ void Add_Footkludges(int, char *, int); /* Footer part of kludges */
void Sema_Mailout(void); /* Set mailout semafore */ void Sema_Mailout(void); /* Set mailout semafore */

View File

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

View File

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