Debug fixes

This commit is contained in:
Michiel Broek 2003-05-10 11:51:43 +00:00
parent dc79124b4e
commit 55dc3c68f7
6 changed files with 272 additions and 278 deletions

View File

@ -19,6 +19,8 @@ v0.37.3 09-Apr-2003.
Fixed recognition of tar.gz files.
Added menu function display file.
Display ascii textfiles now uses the More Y/n/= prompt.
When a new message is saved in a local area, the mailout
semafore is not set anymore.
mbuser:
Added nopper code during pack.

2
TODO
View File

@ -46,6 +46,8 @@ mbsebbs:
N: OLR: qwk, check netmail entered from reader, fido address missing?
N: Reimplememnt CHRS kludge.
newuser:
L: Allow handles to be the same as the unixname.

View File

@ -72,11 +72,10 @@ void Good_Bye(int onsig)
* Update the users database record.
*/
sprintf(temp, "%s/etc/users.data", getenv("MBSE_ROOT"));
if ((pUsrConfig = fopen(temp,"r+b")) != NULL) {
if ((pUsrConfig = fopen(temp,"r+")) != NULL) {
sprintf(temp, "%s/%s/exitinfo", CFG.bbs_usersdir, exitinfo.Name);
if ((pExitinfo = fopen(temp,"rb")) != NULL) {
fread(&usrconfighdr, sizeof(usrconfighdr), 1, pUsrConfig);
offset = usrconfighdr.hdrsize + (grecno * usrconfighdr.recsize);
fread(&exitinfo, sizeof(exitinfo), 1, pExitinfo);
usrconfig = exitinfo;
@ -93,8 +92,9 @@ void Good_Bye(int onsig)
usrconfig.iLastMsgArea = iMsgAreaNumber;
offset = usrconfighdr.hdrsize + (grecno * usrconfighdr.recsize);
Syslog('b', "hdrsize=%ld recsize=%ld grecno=%ld", usrconfighdr.hdrsize, usrconfighdr.recsize, grecno);
Syslog('b', "Good_Bye: write users.data at offset %ld", offset);
if (fseek(pUsrConfig, offset, 0) != 0) {
if (fseek(pUsrConfig, offset, SEEK_SET) != 0) {
WriteError("Can't move pointer in file %s", temp);
ExitClient(MBERR_GENERAL);
}

View File

@ -604,95 +604,92 @@ void Post_Msg()
*/
int Save_Msg(int IsReply, faddr *Dest)
{
int i;
char *temp;
FILE *fp;
int i;
char *temp;
FILE *fp;
if (Line < 2)
return TRUE;
if (!Open_Msgbase(msgs.Base, 'w'))
return FALSE;
Msg.Arrived = time(NULL) - (gmt_offset((time_t)0) * 60);
Msg.Written = Msg.Arrived;
Msg.Local = TRUE;
temp = calloc(PATH_MAX, sizeof(char));
if (strlen(Msg.ReplyTo) && (msgs.Type == NETMAIL)) {
/*
* Send message to internet gateway.
*/
Syslog('m', "UUCP message to %s", Msg.ReplyAddr);
sprintf(Msg.To, "UUCP");
Add_Headkludges(Dest, IsReply);
sprintf(temp, "To: %s", Msg.ReplyAddr);
MsgText_Add2(temp);
MsgText_Add2((char *)"");
} else {
Add_Headkludges(Dest, IsReply);
}
/*
* Add message text
*/
for (i = 1; i <= Line; i++) {
MsgText_Add2(Message[i]);
}
Add_Footkludges(TRUE, NULL, FALSE);
/*
* Save if to disk
*/
Msg_AddMsg();
Msg_UnLock();
ReadExitinfo();
exitinfo.iPosted++;
WriteExitinfo();
do_mailout = TRUE;
LC_Wrote = TRUE;
Syslog('+', "Msg (%ld) to \"%s\", \"%s\", in %ld", Msg.Id, Msg.To, Msg.Subject, iMsgAreaNumber + 1);
colour(CFG.HiliteF, CFG.HiliteB);
/* Saving message to disk */
printf("\n%s(%ld)\n\n", (char *) Language(202), Msg.Id);
fflush(stdout);
sleep(2);
msgs.LastPosted = time(NULL);
msgs.Posted.total++;
msgs.Posted.tweek++;
msgs.Posted.tdow[Diw]++;
msgs.Posted.month[Miy]++;
sprintf(temp, "%s/etc/mareas.data", getenv("MBSE_ROOT"));
if ((fp = fopen(temp, "r+")) != NULL) {
fseek(fp, msgshdr.hdrsize + (iMsgAreaNumber * (msgshdr.recsize + msgshdr.syssize)), SEEK_SET);
fwrite(&msgs, msgshdr.recsize, 1, fp);
fclose(fp);
}
/*
* Add quick mailscan info
*/
if (msgs.Type != LOCALMAIL) {
sprintf(temp, "%s/tmp/%smail.jam", getenv("MBSE_ROOT"),
((msgs.Type == ECHOMAIL) || (msgs.Type == LIST))? "echo" : "net");
if ((fp = fopen(temp, "a")) != NULL) {
fprintf(fp, "%s %lu\n", msgs.Base, Msg.Id);
fclose(fp);
}
}
free(temp);
Msg_Close();
SetMsgArea(iMsgAreaNumber);
if (Line < 2)
return TRUE;
if (!Open_Msgbase(msgs.Base, 'w'))
return FALSE;
Msg.Written = Msg.Arrived = time(NULL) - (gmt_offset((time_t)0) * 60);
Msg.Local = TRUE;
temp = calloc(PATH_MAX, sizeof(char));
if (strlen(Msg.ReplyTo) && (msgs.Type == NETMAIL)) {
/*
* Send message to internet gateway.
*/
Syslog('m', "UUCP message to %s", Msg.ReplyAddr);
sprintf(Msg.To, "UUCP");
Add_Headkludges(Dest, IsReply);
sprintf(temp, "To: %s", Msg.ReplyAddr);
MsgText_Add2(temp);
MsgText_Add2((char *)"");
} else {
Add_Headkludges(Dest, IsReply);
}
/*
* Add message text
*/
for (i = 1; i <= Line; i++)
MsgText_Add2(Message[i]);
Add_Footkludges(TRUE, NULL, FALSE);
/*
* Save if to disk
*/
Msg_AddMsg();
Msg_UnLock();
ReadExitinfo();
exitinfo.iPosted++;
WriteExitinfo();
LC_Wrote = TRUE;
Syslog('+', "Msg (%ld) to \"%s\", \"%s\", in %ld", Msg.Id, Msg.To, Msg.Subject, iMsgAreaNumber + 1);
colour(CFG.HiliteF, CFG.HiliteB);
/* Saving message to disk */
printf("\n%s(%ld)\n\n", (char *) Language(202), Msg.Id);
fflush(stdout);
sleep(2);
msgs.LastPosted = time(NULL);
msgs.Posted.total++;
msgs.Posted.tweek++;
msgs.Posted.tdow[Diw]++;
msgs.Posted.month[Miy]++;
sprintf(temp, "%s/etc/mareas.data", getenv("MBSE_ROOT"));
if ((fp = fopen(temp, "r+")) != NULL) {
fseek(fp, msgshdr.hdrsize + (iMsgAreaNumber * (msgshdr.recsize + msgshdr.syssize)), SEEK_SET);
fwrite(&msgs, msgshdr.recsize, 1, fp);
fclose(fp);
}
/*
* Add quick mailscan info
*/
if (msgs.Type != LOCALMAIL) {
do_mailout = TRUE;
sprintf(temp, "%s/tmp/%smail.jam", getenv("MBSE_ROOT"), ((msgs.Type == ECHOMAIL) || (msgs.Type == LIST))? "echo" : "net");
if ((fp = fopen(temp, "a")) != NULL) {
fprintf(fp, "%s %lu\n", msgs.Base, Msg.Id);
fclose(fp);
}
}
free(temp);
Msg_Close();
SetMsgArea(iMsgAreaNumber);
return TRUE;
}

View File

@ -4,7 +4,7 @@
* Purpose ...............: Utilities for message handling.
*
*****************************************************************************
* Copyright (C) 1997-2002
* Copyright (C) 1997-2003
*
* Michiel Broek FIDO: 2:280/2802
* Beekmansbos 10
@ -58,53 +58,52 @@ static char *months[]={(char *)"Jan",(char *)"Feb",(char *)"Mar",
char *rfcdate(time_t now)
{
static char buf[40];
struct tm ptm, gtm;
char sign;
int hr, min;
long offset;
static char buf[40];
struct tm ptm, gtm;
char sign;
int hr, min;
long offset;
if (!now)
now = time(NULL);
ptm = *localtime(&now);
if (!now)
now = time(NULL);
ptm = *localtime(&now);
/*
* To get the timezone, compare localtime with GMT.
*/
gtm = *gmtime(&now);
/*
* To get the timezone, compare localtime with GMT.
*/
gtm = *gmtime(&now);
/*
* Assume we are never more than 24 hours away.
*/
offset = gtm.tm_yday - ptm.tm_yday;
if (offset > 1)
offset = -24;
else if (offset < -1)
offset = 24;
else
offset *= 24;
/*
* Assume we are never more than 24 hours away.
*/
offset = gtm.tm_yday - ptm.tm_yday;
if (offset > 1)
offset = -24;
else if (offset < -1)
offset = 24;
else
offset *= 24;
/*
* Scale in the hours and minutes; ignore seconds.
*/
offset += gtm.tm_hour - ptm.tm_hour;
offset *= 60;
offset += gtm.tm_min - ptm.tm_min;
/*
* Scale in the hours and minutes; ignore seconds.
*/
offset += gtm.tm_hour - ptm.tm_hour;
offset *= 60;
offset += gtm.tm_min - ptm.tm_min;
if (offset <= 0)
{
sign='+';
offset=-offset;
}
else sign='-';
hr=offset/60L;
min=offset%60L;
if (offset <= 0) {
sign='+';
offset=-offset;
} else
sign='-';
hr=offset/60L;
min=offset%60L;
sprintf(buf,"%s, %02d %s %04d %02d:%02d:%02d %c%02d%02d",
sprintf(buf,"%s, %02d %s %04d %02d:%02d:%02d %c%02d%02d",
wdays[gtm.tm_wday],gtm.tm_mday,months[gtm.tm_mon],
gtm.tm_year+1900,gtm.tm_hour,gtm.tm_min,gtm.tm_sec,
sign,hr,min);
return(buf);
return(buf);
}
@ -114,21 +113,21 @@ char *rfcdate(time_t now)
*/
int Open_Msgbase(char *Base, int Mode)
{
BaseWrite = FALSE;
BaseWrite = FALSE;
if (!Msg_Open(Base))
return FALSE;
if (!Msg_Open(Base))
return FALSE;
if (Mode != 'w')
return TRUE;
if (!Msg_Lock(30L)) {
Msg_Close();
return FALSE;
}
BaseWrite = TRUE;
if (Mode != 'w')
return TRUE;
if (!Msg_Lock(30L)) {
Msg_Close();
return FALSE;
}
BaseWrite = TRUE;
return TRUE;
}
@ -138,104 +137,101 @@ int Open_Msgbase(char *Base, int Mode)
*/
void Close_Msgbase()
{
if (BaseWrite) {
Msg_UnLock();
BaseWrite = FALSE;
}
Msg_Close();
if (BaseWrite) {
Msg_UnLock();
BaseWrite = FALSE;
}
Msg_Close();
}
void Add_Headkludges(faddr *dest, int IsReply)
{
char *temp, *temp2;
unsigned long crc = -1;
time_t tt;
int i;
faddr *Node;
char *temp, *temp2;
unsigned long crc = -1;
time_t tt;
int i;
faddr *Node;
temp = calloc(128, sizeof(char));
temp = calloc(128, sizeof(char));
switch (msgs.Type) {
case LOCALMAIL: Msg.Localmail = TRUE;
break;
switch (msgs.Type) {
case LOCALMAIL: Msg.Localmail = TRUE;
break;
case NETMAIL: Msg.Netmail = TRUE;
sprintf(Msg.FromAddress, "%s", aka2str(msgs.Aka));
sprintf(Msg.ToAddress, "%s", ascfnode(dest, 0x1f));
case NETMAIL: Msg.Netmail = TRUE;
sprintf(Msg.FromAddress, "%s", aka2str(msgs.Aka));
sprintf(Msg.ToAddress, "%s", ascfnode(dest, 0x1f));
if (msgs.Aka.point) {
sprintf(temp, "\001FMPT %d", msgs.Aka.point);
MsgText_Add2(temp);
}
if (dest->point) {
sprintf(temp, "\001TOPT %d", dest->point);
MsgText_Add2(temp);
}
sprintf(temp, "\001INTL %d:%d/%d %d:%d/%d", dest->zone, dest->net,
dest->node, msgs.Aka.zone, msgs.Aka.net, msgs.Aka.node);
MsgText_Add2(temp);
break;
if (msgs.Aka.point) {
sprintf(temp, "\001FMPT %d", msgs.Aka.point);
MsgText_Add2(temp);
}
case LIST: Msg.Echomail = TRUE;
sprintf(Msg.FromAddress, "%s", aka2str(msgs.Aka));
break;
if (dest->point) {
sprintf(temp, "\001TOPT %d", dest->point);
MsgText_Add2(temp);
}
case ECHOMAIL: Msg.Echomail = TRUE;
sprintf(Msg.FromAddress, "%s", aka2str(msgs.Aka));
break;
sprintf(temp, "\001INTL %d:%d/%d %d:%d/%d", dest->zone, dest->net, dest->node, msgs.Aka.zone, msgs.Aka.net, msgs.Aka.node);
MsgText_Add2(temp);
case NEWS: /*
* Header style is the same as GoldED does.
*/
Msg.News = TRUE;
sprintf(temp, "\001Date: %s", rfcdate(Msg.Written));
MsgText_Add2(temp);
Node = fido2faddr(msgs.Aka);
temp2 = xstrcpy(Msg.From);
for (i = 0; i < strlen(temp2); i++)
if (temp2[i] == ' ')
temp2[i] = '_';
sprintf(temp, "\001From: %s@%s (%s)", temp2, ascinode(Node, 0x2f), Msg.From);
MsgText_Add2(temp);
sprintf(temp, "\001Subject: %s", Msg.Subject);
MsgText_Add2(temp);
sprintf(temp, "\001Sender: %s@%s (%s)", temp2, ascinode(Node, 0x2f), Msg.From);
MsgText_Add2(temp);
free(temp2);
tidy_faddr(Node);
MsgText_Add2((char *)"\001To: All");
MsgText_Add2((char *)"\001MIME-Version: 1.0");
MsgText_Add2((char *)"\001Content-Type: text/plain");
MsgText_Add2((char *)"\001Content-Transfer-Encoding: 8bit");
sprintf(temp, "\001X-Mailreader: MBSE BBS %s", VERSION);
MsgText_Add2(temp);
break;
}
break;
// sprintf(temp, "\001CHRS: %s", getchrs(msgs.Ftncode));
// MsgText_Add2(temp);
sprintf(temp, "\001MSGID: %s %08lx", aka2str(msgs.Aka), sequencer());
MsgText_Add2(temp);
Msg.MsgIdCRC = upd_crc32(temp, crc, strlen(temp));
case LIST: Msg.Echomail = TRUE;
sprintf(Msg.FromAddress, "%s", aka2str(msgs.Aka));
break;
case ECHOMAIL: Msg.Echomail = TRUE;
sprintf(Msg.FromAddress, "%s", aka2str(msgs.Aka));
break;
case NEWS: /*
* Header style is the same as GoldED does.
*/
Msg.News = TRUE;
sprintf(temp, "\001Date: %s", rfcdate(Msg.Written));
MsgText_Add2(temp);
Node = fido2faddr(msgs.Aka);
temp2 = xstrcpy(Msg.From);
for (i = 0; i < strlen(temp2); i++)
if (temp2[i] == ' ')
temp2[i] = '_';
sprintf(temp, "\001From: %s@%s (%s)", temp2, ascinode(Node, 0x2f), Msg.From);
MsgText_Add2(temp);
sprintf(temp, "\001Subject: %s", Msg.Subject);
MsgText_Add2(temp);
sprintf(temp, "\001Sender: %s@%s (%s)", temp2, ascinode(Node, 0x2f), Msg.From);
MsgText_Add2(temp);
free(temp2);
tidy_faddr(Node);
MsgText_Add2((char *)"\001To: All");
MsgText_Add2((char *)"\001MIME-Version: 1.0");
MsgText_Add2((char *)"\001Content-Type: text/plain");
MsgText_Add2((char *)"\001Content-Transfer-Encoding: 8bit");
sprintf(temp, "\001X-Mailreader: MBSE BBS %s", VERSION);
MsgText_Add2(temp);
break;
}
// sprintf(temp, "\001CHRS: %s", getchrs(msgs.Ftncode));
// MsgText_Add2(temp);
sprintf(temp, "\001MSGID: %s %08lx", aka2str(msgs.Aka), sequencer());
if (IsReply) {
sprintf(temp, "\001REPLY: %s", Msg.Replyid);
MsgText_Add2(temp);
Msg.MsgIdCRC = upd_crc32(temp, crc, strlen(temp));
crc = -1;
Msg.ReplyCRC = upd_crc32(temp, crc, strlen(temp));
} else
Msg.ReplyCRC = 0xffffffff;
if (IsReply) {
sprintf(temp, "\001REPLY: %s", Msg.Replyid);
MsgText_Add2(temp);
crc = -1;
Msg.ReplyCRC = upd_crc32(temp, crc, strlen(temp));
} else
Msg.ReplyCRC = 0xffffffff;
sprintf(temp, "\001PID: MBSE-BBS %s", VERSION);
MsgText_Add2(temp);
tt = time(NULL);
sprintf(temp, "\001TZUTC: %s", gmtoffset(tt));
MsgText_Add2(temp);
free(temp);
sprintf(temp, "\001PID: MBSE-BBS %s", VERSION);
MsgText_Add2(temp);
tt = time(NULL);
sprintf(temp, "\001TZUTC: %s", gmtoffset(tt));
MsgText_Add2(temp);
free(temp);
}
@ -247,65 +243,61 @@ void Add_Headkludges(faddr *dest, int IsReply)
*/
void Add_Footkludges(int Quote, char *tear, int HasTear)
{
char *temp;
char *aka;
FILE *fp;
char *temp, *aka;
FILE *fp;
temp = calloc(PATH_MAX, sizeof(char));
aka = calloc(32, sizeof(char));
temp = calloc(PATH_MAX, sizeof(char));
aka = calloc(32, sizeof(char));
/*
* If Quote (message entered at the bbs) we append a signature.
*/
if (Quote) {
sprintf(temp, "%s/%s/.signature", CFG.bbs_usersdir, exitinfo.Name);
if ((fp = fopen(temp, "r"))) {
Syslog('m', " Add .signature");
MsgText_Add2((char *)"");
while (fgets(temp, 80, fp)) {
Striplf(temp);
MsgText_Add2(temp);
}
fclose(fp);
MsgText_Add2((char *)"");
/*
* If Quote (message entered at the bbs) we append a signature.
*/
if (Quote) {
sprintf(temp, "%s/%s/.signature", CFG.bbs_usersdir, exitinfo.Name);
if ((fp = fopen(temp, "r"))) {
MsgText_Add2((char *)"");
while (fgets(temp, 80, fp)) {
Striplf(temp);
MsgText_Add2(temp);
}
fclose(fp);
MsgText_Add2((char *)"");
}
}
if (msgs.Quotes && Quote) {
Syslog('m', " Add quote");
sprintf(temp, "... %s", Oneliner_Get());
MsgText_Add2(temp);
MsgText_Add2((char *)"");
if (msgs.Quotes && Quote) {
sprintf(temp, "... %s", Oneliner_Get());
MsgText_Add2(temp);
MsgText_Add2((char *)"");
}
/*
* The offline reader may override the tearline
*/
if (!HasTear) {
if (tear == NULL) {
MsgText_Add2(TearLine());
} else {
sprintf(temp, "--- %s", tear);
MsgText_Add2(temp);
}
}
/*
* The offline reader may override the tearline
*/
if (!HasTear) {
if (tear == NULL) {
MsgText_Add2(TearLine());
} else {
sprintf(temp, "--- %s", tear);
MsgText_Add2(temp);
}
}
if ((msgs.Type == ECHOMAIL) || (msgs.Type == LIST)) {
if (msgs.Aka.point)
sprintf(aka, "(%d:%d/%d.%d)", msgs.Aka.zone, msgs.Aka.net, msgs.Aka.node, msgs.Aka.point);
else
sprintf(aka, "(%d:%d/%d)", msgs.Aka.zone, msgs.Aka.net, msgs.Aka.node);
if ((msgs.Type == ECHOMAIL) || (msgs.Type == LIST)) {
/* RANDOM ORIGIN LINES IMPLEMENTEREN */
if (msgs.Aka.point)
sprintf(aka, "(%d:%d/%d.%d)", msgs.Aka.zone, msgs.Aka.net, msgs.Aka.node, msgs.Aka.point);
else
sprintf(aka, "(%d:%d/%d)", msgs.Aka.zone, msgs.Aka.net, msgs.Aka.node);
if (strlen(msgs.Origin))
sprintf(temp, " * Origin: %s %s", msgs.Origin, aka);
else
sprintf(temp, " * Origin: %s %s", CFG.origin, aka);
MsgText_Add2(temp);
}
if (strlen(msgs.Origin))
sprintf(temp, " * Origin: %s %s", msgs.Origin, aka);
else
sprintf(temp, " * Origin: %s %s", CFG.origin, aka);
MsgText_Add2(temp);
}
free(aka);
free(temp);
free(aka);
free(temp);
}

View File

@ -6,7 +6,7 @@
* does a lot of checking in general.
*
*****************************************************************************
* Copyright (C) 1997-2002
* Copyright (C) 1997-2003
*
* Michiel Broek FIDO: 2:280/2802
* Beekmansbos 10
@ -185,7 +185,7 @@ void user()
Syslog('+', "Unixmode login: %s", sUnixName);
sprintf(temp, "%s/etc/users.data", getenv("MBSE_ROOT"));
if ((pUsrConfig = fopen(temp,"r+b")) == NULL) {
if ((pUsrConfig = fopen(temp,"r+")) == NULL) {
/*
* This should not happen.
*/
@ -204,6 +204,7 @@ void user()
}
if (!FoundName) {
fclose(pUsrConfig);
printf("Unknown username: %s\n", sUnixName);
/* FATAL ERROR: You are not in the BBS users file.*/
printf("%s\n", (char *) Language(389));
@ -407,8 +408,8 @@ void user()
WriteError("Can't seek in %s/etc/users.data", getenv("MBSE_ROOT"));
} else {
fwrite(&usrconfig, sizeof(usrconfig), 1, pUsrConfig);
fclose(pUsrConfig);
}
fclose(pUsrConfig);
/*
* Write users structure to tmp file in ~/home/unixname/exitinfo
@ -422,9 +423,9 @@ void user()
ChangeHomeDir(exitinfo.Name, exitinfo.Email);
Syslog('+', "User successfully logged into BBS");
Syslog('+', "Level %d (%s), %d mins. left, port %s", usrconfig.Security.level, LIMIT.Description, usrconfig.iTimeLeft, pTTY);
Syslog('+', "Level %d (%s), %d mins. left, port %s", exitinfo.Security.level, LIMIT.Description, exitinfo.iTimeLeft, pTTY);
Time2Go = time(NULL);
Time2Go += usrconfig.iTimeLeft * 60;
Time2Go += exitinfo.iTimeLeft * 60;
iUserTimeLeft = exitinfo.iTimeLeft;
IsDoing("Welcome screens");