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,126 +420,16 @@ 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);
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);
if (rc != -1) {
msg_link = rc;
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

@ -264,13 +264,10 @@ void ScanFull()
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) &&
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);
sprintf(sbe, "%u/%u", CFG.aka[i].net, CFG.aka[i].node);
fill_list(&sbl, sbe, NULL);
}
}
@ -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
@ -62,7 +62,7 @@ void error_popmail(char *umsg)
void retr_msg(int);
void retr_msg(int msgnum)
{
char *p, *q, temp[128];
char *p, *q, temp[PATH_MAX], *base;
int Header;
unsigned long crc = -1;
@ -71,7 +71,8 @@ void retr_msg(int msgnum)
Msg_New();
Header = TRUE;
sprintf(temp, "%s/%s/mailbox", CFG.bbs_usersdir, exitinfo.Name);
Open_Msgbase(temp, 'w');
base = xstrcpy(temp);
Open_Msgbase(base, 'w');
Msg.Arrived = time(NULL) - (gmt_offset((time_t)0) * 60);
Msg.Private = TRUE;
while (TRUE) {
@ -119,7 +120,8 @@ void retr_msg(int msgnum)
}
Msg_AddMsg();
Msg_UnLock();
Msg_Close();
Close_Msgbase(base);
free(base);
sprintf(temp, "DELE %d\r\n", msgnum);
pop3_cmd(temp);
} else {