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

@@ -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);
}
}