Fixed several small valgrind detected errors

This commit is contained in:
Michiel Broek 2003-12-16 21:50:32 +00:00
parent 2ab6cacda9
commit 2e58d4339a
19 changed files with 517 additions and 475 deletions

View File

@ -3,7 +3,7 @@ $Id$
v0.39.4 08-Dec-2003 v0.39.4 08-Dec-2003
Added --enable-experiment mbtask debugging code for Hans. Added --enable-experiment mbtask debugging code for Hans.
general: general:
Added French language file created by Francois Thunus. This Added French language file created by Francois Thunus. This
translation is not yet complete. translation is not yet complete.
@ -19,6 +19,9 @@ v0.39.4 08-Dec-2003
also fixed the message renumbering bug introduced with previous also fixed the message renumbering bug introduced with previous
version. version.
mbsebbs:
A lot of small fixes for problems found with valgrind.
mbsetup: mbsetup:
Added default record for french language. Added default record for french language.

2
TODO
View File

@ -58,6 +58,8 @@ mbsebbs:
N: Reimplememnt CHRS kludge. N: Reimplememnt CHRS kludge.
N: There are some bugs in the bbs list menu. Make it a door?
newuser: newuser:
N: Test with valgrind. N: Test with valgrind.

View File

@ -102,7 +102,7 @@ char *xstrcat(char *src, char *add)
void InitClient(char *user, char *myname, char *where, char *log, long loggr, char *err, char *mgr, char *debug) void InitClient(char *user, char *myname, char *where, char *logfname, long loggr, char *err, char *mgr, char *debug)
{ {
if ((getenv("MBSE_ROOT")) == NULL) { if ((getenv("MBSE_ROOT")) == NULL) {
printf("Could not get the MBSE_ROOT environment variable\n"); printf("Could not get the MBSE_ROOT environment variable\n");
@ -112,7 +112,7 @@ void InitClient(char *user, char *myname, char *where, char *log, long loggr, ch
} }
sprintf(progname, "%s", myname); sprintf(progname, "%s", myname);
sprintf(logfile, "%s", log); sprintf(logfile, "%s", logfname);
sprintf(errfile, "%s", err); sprintf(errfile, "%s", err);
sprintf(mgrfile, "%s", mgr); sprintf(mgrfile, "%s", mgr);
sprintf(logdebug, "%s", debug); sprintf(logdebug, "%s", debug);

View File

@ -1112,7 +1112,7 @@ void fill_binkp_list(binkp_list **bll, file_list *fal, off_t offs)
if (stat(fal->local, &tstat) != 0) { if (stat(fal->local, &tstat) != 0) {
Syslog('!', "$Can't add %s to sendlist", fal->local); Syslog('!', "$Can't add %s to sendlist", fal->local);
exit; return;
} }
if (strstr(fal->remote, (char *)".pkt")) if (strstr(fal->remote, (char *)".pkt"))
nethold += tstat.st_size; nethold += tstat.st_size;

View File

@ -4,7 +4,7 @@
* Purpose ...............: File forward to a node * Purpose ...............: File forward to a node
* *
***************************************************************************** *****************************************************************************
* Copyright (C) 1997-2002 * Copyright (C) 1997-2003
* *
* Michiel Broek FIDO: 2:280/2802 * Michiel Broek FIDO: 2:280/2802
* Beekmansbos 10 * Beekmansbos 10
@ -71,7 +71,7 @@ void ForwardFile(fidoaddr Node, fa_list *sbl)
T_File.Cost = TIC.FileCost + (TIC.FileCost * nodes.AddPerc / 1000); T_File.Cost = TIC.FileCost + (TIC.FileCost * nodes.AddPerc / 1000);
if ((nodes.Credit < (nodes.StopLevel + T_File.Cost)) && (!TIC.Charge)) { if ((nodes.Credit < (nodes.StopLevel + T_File.Cost)) && (!TIC.Charge)) {
Syslog('!', "No forward to %s, not enough credit left", aka2str(Node)); Syslog('!', "No forward to %s, not enough credit left", aka2str(Node));
exit; return;
} }
/* /*

View File

@ -134,7 +134,7 @@ lineedit.o: ../config.h ../lib/libs.h ../lib/mbse.h ../lib/structs.h ../lib/user
mblang.o: ../config.h ../lib/libs.h ../lib/structs.h ../lib/users.h ../lib/records.h ../lib/mberrors.h mblang.o: ../config.h ../lib/libs.h ../lib/structs.h ../lib/users.h ../lib/records.h ../lib/mberrors.h
mbuser.o: ../config.h ../lib/libs.h ../lib/structs.h ../lib/users.h ../lib/records.h ../lib/common.h ../lib/clcomm.h ../lib/dbcfg.h ../lib/mberrors.h mbuser.h mbuser.o: ../config.h ../lib/libs.h ../lib/structs.h ../lib/users.h ../lib/records.h ../lib/common.h ../lib/clcomm.h ../lib/dbcfg.h ../lib/mberrors.h mbuser.h
page.o: ../config.h ../lib/libs.h ../lib/mbse.h ../lib/structs.h ../lib/users.h ../lib/records.h ../lib/common.h ../lib/clcomm.h dispfile.h input.h chat.h page.h timeout.h mail.h language.h page.o: ../config.h ../lib/libs.h ../lib/mbse.h ../lib/structs.h ../lib/users.h ../lib/records.h ../lib/common.h ../lib/clcomm.h dispfile.h input.h chat.h page.h timeout.h mail.h language.h
bye.o: ../config.h ../lib/libs.h ../lib/mbse.h ../lib/structs.h ../lib/users.h ../lib/records.h ../lib/clcomm.h ../lib/common.h ../lib/mberrors.h dispfile.h misc.h language.h bye.h bye.o: ../config.h ../lib/libs.h ../lib/mbse.h ../lib/structs.h ../lib/users.h ../lib/records.h ../lib/clcomm.h ../lib/common.h ../lib/mberrors.h ../lib/nodelist.h dispfile.h misc.h language.h bye.h
funcs.o: ../config.h ../lib/libs.h ../lib/mbse.h ../lib/structs.h ../lib/users.h ../lib/records.h ../lib/common.h ../lib/msgtext.h ../lib/msg.h ../lib/clcomm.h ../lib/mberrors.h funcs.h funcs.o: ../config.h ../lib/libs.h ../lib/mbse.h ../lib/structs.h ../lib/users.h ../lib/records.h ../lib/common.h ../lib/msgtext.h ../lib/msg.h ../lib/clcomm.h ../lib/mberrors.h funcs.h
mail.o: ../config.h ../lib/libs.h ../lib/mbse.h ../lib/structs.h ../lib/users.h ../lib/records.h ../lib/common.h ../lib/nodelist.h ../lib/msgtext.h ../lib/clcomm.h ../lib/msg.h mail.h funcs.h input.h language.h misc.h timeout.h oneline.h exitinfo.h lineedit.h fsedit.h filesub.h msgutil.h pop3.h email.h door.h whoson.h mail.o: ../config.h ../lib/libs.h ../lib/mbse.h ../lib/structs.h ../lib/users.h ../lib/records.h ../lib/common.h ../lib/nodelist.h ../lib/msgtext.h ../lib/clcomm.h ../lib/msg.h mail.h funcs.h input.h language.h misc.h timeout.h oneline.h exitinfo.h lineedit.h fsedit.h filesub.h msgutil.h pop3.h email.h door.h whoson.h
newuser.o: ../config.h ../lib/libs.h ../lib/mbse.h ../lib/structs.h ../lib/users.h ../lib/records.h ../lib/clcomm.h ../lib/common.h ../lib/mberrors.h funcs.h input.h newuser.h language.h timeout.h change.h dispfile.h newuser.o: ../config.h ../lib/libs.h ../lib/mbse.h ../lib/structs.h ../lib/users.h ../lib/records.h ../lib/clcomm.h ../lib/common.h ../lib/mberrors.h funcs.h input.h newuser.h language.h timeout.h change.h dispfile.h

View File

@ -7,7 +7,7 @@
* Intro New BBS at logon * Intro New BBS at logon
* *
***************************************************************************** *****************************************************************************
* Copyright (C) 1997-2002 * Copyright (C) 1997-2003
* *
* Michiel Broek FIDO: 2:280/2802 * Michiel Broek FIDO: 2:280/2802
* Beekmansbos 10 * Beekmansbos 10
@ -597,115 +597,114 @@ void BBS_Show(void)
void BBS_Delete(void) void BBS_Delete(void)
{ {
FILE *pBBSLine; FILE *pBBSLine;
int recno = 0; int recno = 0, nrecno = 0;
long int offset; long offset;
int nrecno = 0; char srecno[7], *sFileName, stemp[50], sUser[35];
char srecno[7];
char *sFileName;
char stemp[50];
char sUser[35];
sFileName = calloc(PATH_MAX, sizeof(char)); sFileName = calloc(PATH_MAX, sizeof(char));
sprintf(sFileName,"%s/etc/bbslist.data", getenv("MBSE_ROOT")); sprintf(sFileName,"%s/etc/bbslist.data", getenv("MBSE_ROOT"));
if((pBBSLine = fopen(sFileName, "r+")) == NULL) { if ((pBBSLine = fopen(sFileName, "r+")) == NULL) {
WriteError("Can't open file: %s", sFileName); WriteError("Can't open file: %s", sFileName);
free(sFileName);
return;
}
free(sFileName); free(sFileName);
fread(&bbshdr, sizeof(bbshdr),1 , pBBSLine); return;
}
fread(&bbshdr, sizeof(bbshdr),1 , pBBSLine);
if(exitinfo.GraphMode) { if (exitinfo.GraphMode) {
colour(9, 0); colour(9, 0);
printf("\n\t\t\t\t%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c\n", 177, 177, 177, 177, 177, 177, 177, 177, 177, 177, 177, 177, 177, 177, 177, 177); printf("\n\t\t\t\t%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c\n", 177, 177, 177, 177, 177, 177, 177, 177, 177, 177, 177, 177, 177, 177, 177, 177);
printf("\t\t\t\t%c%c", 177, 177); printf("\t\t\t\t%c%c", 177, 177);
colour(15, 0); colour(15, 0);
/* Delete BBS */ /* Delete BBS */
printf(" %s", (char *) Language(330)); printf(" %s", (char *) Language(330));
colour(9, 0); colour(9, 0);
printf("%c%c %c\n", 177, 177, 219); printf("%c%c %c\n", 177, 177, 219);
printf("\t\t\t\t%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c %c\n", 177, 177, 177, 177, 177, 177, 177, 177, 177, 177, 177, 177, 177, 177, 177, 177, 219); printf("\t\t\t\t%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c %c\n", 177, 177, 177, 177, 177, 177, 177, 177, 177, 177, 177, 177, 177, 177, 177, 177, 219);
printf("\t\t\t\t %c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c\n\n", 220, 220, 220, 220, 220, 220, 220, 220, 220, 220, 220, 220, 220, 220, 220, 219); printf("\t\t\t\t %c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c\n\n", 220, 220, 220, 220, 220, 220, 220, 220, 220, 220, 220, 220, 220, 220, 220, 219);
} else { } else {
printf("\n\t\t\t\t+--------------+\n"); printf("\n\t\t\t\t+--------------+\n");
/* Delete BBS */ /* Delete BBS */
printf("\t\t\t\t| %s |\n", (char *) Language(330)); printf("\t\t\t\t| %s |\n", (char *) Language(330));
printf("\t\t\t\t+--------------+\n\n"); printf("\t\t\t\t+--------------+\n\n");
} }
Enter(1); Enter(1);
/* Please enter number to delete: */ /* Please enter number to delete: */
pout(15, 0, (char *) Language(331)); pout(15, 0, (char *) Language(331));
colour(CFG.InputColourF, CFG.InputColourB); colour(CFG.InputColourF, CFG.InputColourB);
GetstrC(srecno, 9); GetstrC(srecno, 9);
if((strcmp(srecno,"")) == 0) if ((strcmp(srecno,"")) == 0)
return; return;
recno = atoi(srecno); recno = atoi(srecno);
nrecno = recno; nrecno = recno;
recno = 0; recno = 0;
while (fread(&bbs, bbshdr.recsize, 1, pBBSLine) == 1) while (fread(&bbs, bbshdr.recsize, 1, pBBSLine) == 1)
recno++; recno++;
if(nrecno >= recno) { if (nrecno >= recno) {
Enter(1); Enter(1);
/* Record does not exist */ /* Record does not exist */
pout(12, 0, (char *) Language(319)); pout(12, 0, (char *) Language(319));
Enter(2); Enter(2);
fclose(pBBSLine); fclose(pBBSLine);
Pause(); free(sFileName);
return; Pause();
} else { return;
offset = bbshdr.hdrsize + (nrecno * bbshdr.recsize); } else {
if (fseek(pBBSLine, offset, 0) != 0) offset = bbshdr.hdrsize + (nrecno * bbshdr.recsize);
WriteError("Can't move pointer there. %s",sFileName); if (fseek(pBBSLine, offset, 0) != 0)
WriteError("Can't move pointer there. %s",sFileName);
fread(&bbs, sizeof(bbs), 1, pBBSLine); fread(&bbs, sizeof(bbs), 1, pBBSLine);
/* Convert Record Int to string, so we can print to logfiles */ /* Convert Record Int to string, so we can print to logfiles */
sprintf(stemp,"%d", nrecno); sprintf(stemp,"%d", nrecno);
/* Print UserName to String, so we can compare for deletion */ /* Print UserName to String, so we can compare for deletion */
sprintf(sUser,"%s", exitinfo.sUserName); sprintf(sUser,"%s", exitinfo.sUserName);
if((strcmp(sUser, bbs.UserName)) != 0) { if ((strcmp(sUser, bbs.UserName)) != 0) {
if((!SYSOP) && (exitinfo.Security.level < CFG.sysop_access)) { if ((!SYSOP) && (exitinfo.Security.level < CFG.sysop_access)) {
/* Record */ /* does not belong to you.*/ /* Record */ /* does not belong to you.*/
printf("\n%s%s %s\n\n", (char *) Language(332), stemp, (char *) Language(333)); printf("\n%s%s %s\n\n", (char *) Language(332), stemp, (char *) Language(333));
Syslog('!', "User tried to delete somebody else's bbslist record: %s", stemp); Syslog('!', "User tried to delete somebody else's bbslist record: %s", stemp);
return; free(sFileName);
} fclose(pBBSLine);
} return;
}
if ((bbs.Available == FALSE)) {
colour(12, 0);
/* Record */
printf("\n%s%d %s\n\n", (char *) Language(332), nrecno, (char *) Language(334));
Syslog('!', "User tried to mark an already marked bbslist record: %s", stemp);
} else {
bbs.Available = FALSE;
colour(10, 0);
/* Record: */
printf("\n%s%d %s\n\n", (char *) Language(332), nrecno, (char *) Language(335));
Syslog('+', "User marked bbslist record for deletion: %s", stemp);
colour(15, 2);
/* The Sysop will purge the list once he has *//* seen you have marked a record for deletion. */
printf("%s\n%s\n\n", (char *) Language(336), (char *) Language(337));
Pause();
}
offset = bbshdr.hdrsize + (nrecno * bbshdr.recsize);
if(fseek(pBBSLine, offset, 0) != 0)
WriteError("Can't move pointer there. %s",sFileName);
fwrite(&bbs, sizeof(bbs), 1, pBBSLine);
} }
fclose(pBBSLine); if ((bbs.Available == FALSE)) {
chmod(sFileName, 0660); colour(12, 0);
/* Record */
printf("\n%s%d %s\n\n", (char *) Language(332), nrecno, (char *) Language(334));
Syslog('!', "User tried to mark an already marked bbslist record: %s", stemp);
} else {
bbs.Available = FALSE;
colour(10, 0);
/* Record: */
printf("\n%s%d %s\n\n", (char *) Language(332), nrecno, (char *) Language(335));
Syslog('+', "User marked bbslist record for deletion: %s", stemp);
colour(15, 2);
/* The Sysop will purge the list once he has *//* seen you have marked a record for deletion. */
printf("%s\n%s\n\n", (char *) Language(336), (char *) Language(337));
Pause();
}
offset = bbshdr.hdrsize + (nrecno * bbshdr.recsize);
if (fseek(pBBSLine, offset, 0) != 0)
WriteError("Can't move pointer there. %s",sFileName);
fwrite(&bbs, sizeof(bbs), 1, pBBSLine);
}
fclose(pBBSLine);
chmod(sFileName, 0660);
free(sFileName);
} }

View File

@ -37,6 +37,7 @@
#include "../lib/clcomm.h" #include "../lib/clcomm.h"
#include "../lib/common.h" #include "../lib/common.h"
#include "../lib/mberrors.h" #include "../lib/mberrors.h"
#include "../lib/nodelist.h"
#include "dispfile.h" #include "dispfile.h"
#include "misc.h" #include "misc.h"
#include "language.h" #include "language.h"
@ -45,6 +46,9 @@
extern pid_t mypid; extern pid_t mypid;
extern time_t t_start; extern time_t t_start;
extern char *StartTime;
int do_mailout = FALSE; int do_mailout = FALSE;
@ -129,6 +133,9 @@ void Good_Bye(int onsig)
Unsetraw(); Unsetraw();
Free_Language(); Free_Language();
free(pTTY); free(pTTY);
if (StartTime)
free(StartTime);
deinitnl();
exit(onsig); exit(onsig);
} }
@ -152,6 +159,8 @@ void Quick_Bye(int onsig)
Free_Language(); Free_Language();
free(pTTY); free(pTTY);
if (StartTime)
free(StartTime);
exit(MBERR_OK); exit(MBERR_OK);
} }

View File

@ -807,96 +807,101 @@ void Reply_Email(int IsReply)
void Write_Email(void) void Write_Email(void)
{ {
faddr *Dest = NULL; faddr *Dest = NULL;
int i; int i;
char *orgbox; char *orgbox;
if (HasNoEmail()) if (HasNoEmail())
return; return;
orgbox = xstrcpy(sMailbox); orgbox = xstrcpy(sMailbox);
SetEmailArea((char *)"mailbox"); SetEmailArea((char *)"mailbox");
WhosDoingWhat(READ_POST, NULL); WhosDoingWhat(READ_POST, NULL);
clear(); clear();
for (i = 0; i < (TEXTBUFSIZE + 1); i++)
Message[i] = (char *) calloc(MAX_LINE_LENGTH +1, sizeof(char));
Line = 1;
Msg_New();
colour(9, 0);
/* Posting message in area: */
printf("\n%s\"%s\"\n", (char *) Language(156), "mailbox");
Enter(1);
/* From : */
pout(14, 0, (char *) Language(157));
if (CFG.EmailMode != E_PRMISP) {
/*
* If not permanent connected to the internet, use fidonet.org style addressing.
*/
Dest = fido2faddr(CFG.EmailFidoAka);
sprintf(Msg.From, "%s@%s (%s)", exitinfo.sUserName, ascinode(Dest, 0x2f), exitinfo.sUserName);
} else
sprintf(Msg.From, "%s@%s (%s)", exitinfo.Name, CFG.sysdomain, exitinfo.sUserName);
for (i = 0; i < strlen(Msg.From); i++) {
if (Msg.From[i] == ' ')
Msg.From[i] = '_';
if (Msg.From[i] == '@')
break;
}
colour(CFG.MsgInputColourF, CFG.MsgInputColourB);
printf("%s", Msg.From);
Syslog('b', "Setting From: %s", Msg.From);
Enter(1);
/* To : */
pout(14, 0, (char *) Language(158));
colour(CFG.MsgInputColourF, CFG.MsgInputColourB);
GetstrU(Msg.To, 63);
if ((strcmp(Msg.To, "")) == 0) {
for (i = 0; i < (TEXTBUFSIZE + 1); i++) for (i = 0; i < (TEXTBUFSIZE + 1); i++)
Message[i] = (char *) calloc(MAX_LINE_LENGTH +1, sizeof(char)); free(Message[i]);
Line = 1; SetEmailArea(orgbox);
free(orgbox);
return;
}
Msg_New(); /* Subject : */
pout(14, 0, (char *) Language(161));
colour(9, 0); colour(CFG.MsgInputColourF, CFG.MsgInputColourB);
/* Posting message in area: */ fflush(stdout);
printf("\n%s\"%s\"\n", (char *) Language(156), "mailbox"); alarm_on();
GetstrP(Msg.Subject, 65, 0);
if ((strcmp(Msg.Subject, "")) == 0) {
Enter(1); Enter(1);
/* From : */ /* Abort Message [y/N] ?: */
pout(14, 0, (char *) Language(157)); pout(3, 0, (char *) Language(162));
if (CFG.EmailMode != E_PRMISP) {
/*
* If not permanent connected to the internet, use fidonet.org style addressing.
*/
Dest = fido2faddr(CFG.EmailFidoAka);
sprintf(Msg.From, "%s@%s (%s)", exitinfo.sUserName, ascinode(Dest, 0x2f), exitinfo.sUserName);
} else
sprintf(Msg.From, "%s@%s (%s)", exitinfo.Name, CFG.sysdomain, exitinfo.sUserName);
for (i = 0; i < strlen(Msg.From); i++) {
if (Msg.From[i] == ' ')
Msg.From[i] = '_';
if (Msg.From[i] == '@')
break;
}
colour(CFG.MsgInputColourF, CFG.MsgInputColourB);
printf("%s", Msg.From);
Syslog('b', "Setting From: %s", Msg.From);
Enter(1);
/* To : */
pout(14, 0, (char *) Language(158));
colour(CFG.MsgInputColourF, CFG.MsgInputColourB);
GetstrU(Msg.To, 63);
if ((strcmp(Msg.To, "")) == 0) {
for(i = 0; i < (TEXTBUFSIZE + 1); i++)
free(Message[i]);
SetEmailArea(orgbox);
return;
}
/* Subject : */
pout(14, 0, (char *) Language(161));
colour(CFG.MsgInputColourF, CFG.MsgInputColourB);
fflush(stdout); fflush(stdout);
alarm_on(); alarm_on();
GetstrP(Msg.Subject, 65, 0);
if((strcmp(Msg.Subject, "")) == 0) { if (toupper(Getone()) == Keystroke(162, 0)) {
Enter(1); for (i = 0; i < (TEXTBUFSIZE + 1); i++)
/* Abort Message [y/N] ?: */
pout(3, 0, (char *) Language(162));
fflush(stdout);
alarm_on();
if (toupper(Getone()) == Keystroke(162, 0)) {
for(i = 0; i < (TEXTBUFSIZE + 1); i++)
free(Message[i]);
SetEmailArea(orgbox);
return;
}
}
Msg.Private = TRUE;
if (Edit_Msg()) {
Save_Email(FALSE);
}
for (i = 0; i < (TEXTBUFSIZE + 1); i++)
free(Message[i]); free(Message[i]);
SetEmailArea(orgbox);
free(orgbox);
return;
}
}
SetEmailArea(orgbox); Msg.Private = TRUE;
if (Edit_Msg()) {
Save_Email(FALSE);
}
for (i = 0; i < (TEXTBUFSIZE + 1); i++)
free(Message[i]);
SetEmailArea(orgbox);
free(orgbox);
} }

View File

@ -297,12 +297,12 @@ void Download(void)
} }
} }
} }
fclose(tf);
/* /*
* If anything left to download... * If anything left to download...
*/ */
if (!Count) { if (!Count) {
fclose(tf);
SetFileArea(OldArea); SetFileArea(OldArea);
unlink("taglist"); unlink("taglist");
/* No files marked for download */ /* No files marked for download */
@ -458,6 +458,7 @@ void Download(void)
} }
} }
} }
fclose(tf);
} }
/* /*
@ -844,147 +845,151 @@ int FilenameScan()
*/ */
int NewfileScan(int AskStart) int NewfileScan(int AskStart)
{ {
FILE *pAreas, *pFile; FILE *pAreas, *pFile;
long ifDate, itDate; long ifDate, itDate;
char *temp, *Date; char *temp, *Date;
int Found, Count = 0; int Found, Count = 0;
_Tag T; _Tag T;
Date = calloc(81, sizeof(char)); Date = calloc(81, sizeof(char));
temp = calloc(81, sizeof(char)); temp = calloc(81, sizeof(char));
iLineCount = 2; iLineCount = 2;
arecno = 1; /* Reset Area Number to One */ arecno = 1; /* Reset Area Number to One */
if (AskStart) { if (AskStart) {
Enter(2);
/* Search for new since your last call [Y/n]: */
pout(11, 0, (char *) Language(273));
colour(CFG.InputColourF, CFG.InputColourB);
fflush(stdout);
if (toupper(Getone()) == Keystroke(273, 1)) {
Enter(1);
/* Enter new date to search for [DD-MM-YYYY]: */
pout(2, 0, (char *) Language(274));
colour(CFG.InputColourF, CFG.InputColourB);
fflush(stdout);
GetDate(temp, 10);
} else
strcpy(temp, LastLoginDate);
} else
strcpy(temp, LastLoginDate);
Syslog('+', "NewfileScan() since %s", temp);
clear();
/* File Search by Date */
pout(15, 0, (char *) Language(275));
Enter(2); Enter(2);
/* Search for new since your last call [Y/n]: */
pout(11, 0, (char *) Language(273));
colour(CFG.InputColourF, CFG.InputColourB);
fflush(stdout);
Date[0] = temp[6]; /* Swap the date around */ if (toupper(Getone()) == Keystroke(273, 1)) {
Date[1] = temp[7]; /* Instead of DD-MM-YYYY */ Enter(1);
Date[2] = temp[8]; /* Let it equal YYYYMMDD */ /* Enter new date to search for [DD-MM-YYYY]: */
Date[3] = temp[9]; /* Swap the date around */ pout(2, 0, (char *) Language(274));
Date[4] = temp[3]; /* Swap the date around */ colour(CFG.InputColourF, CFG.InputColourB);
Date[5] = temp[4]; /* because when you convert */ fflush(stdout);
Date[6] = temp[0]; /* a string to an int you */ GetDate(temp, 10);
Date[7] = temp[1]; /* loose the front Zero */ } else
Date[8] = '\0'; /* making the number smaller */ strcpy(temp, LastLoginDate);
itDate = atol(Date); } else
strcpy(temp, LastLoginDate);
InitTag(); Syslog('+', "NewfileScan() since %s", temp);
clear();
/* File Search by Date */
pout(15, 0, (char *) Language(275));
Enter(2);
if ((pAreas = OpenFareas(FALSE)) == NULL) Date[0] = temp[6]; /* Swap the date around */
return 0; Date[1] = temp[7]; /* Instead of DD-MM-YYYY */
Date[2] = temp[8]; /* Let it equal YYYYMMDD */
Date[3] = temp[9]; /* Swap the date around */
Date[4] = temp[3]; /* Swap the date around */
Date[5] = temp[4]; /* because when you convert */
Date[6] = temp[0]; /* a string to an int you */
Date[7] = temp[1]; /* loose the front Zero */
Date[8] = '\0'; /* making the number smaller */
itDate = atol(Date);
while (fread(&area, areahdr.recsize, 1, pAreas) == 1) { InitTag();
if ((Access(exitinfo.Security, area.LTSec)) && (area.Available) && if ((pAreas = OpenFareas(FALSE)) == NULL)
(strlen(area.Password) == 0) && (area.New)) { return 0;
if ((pFile = OpenFileBase(arecno, FALSE)) != NULL ) { while (fread(&area, areahdr.recsize, 1, pAreas) == 1) {
Sheader(); if ((Access(exitinfo.Security, area.LTSec)) && (area.Available) && (strlen(area.Password) == 0) && (area.New)) {
Found = FALSE;
Nopper();
while (fread(&file, sizeof(file), 1, pFile) == 1) { if ((pFile = OpenFileBase(arecno, FALSE)) != NULL ) {
strcpy(temp, StrDateDMY(file.UploadDate)); /* Realloc Space for Date */
Date[0] = temp[6]; /* Swap the date around */
Date[1] = temp[7]; /* Instead of DD-MM-YYYY */
Date[2] = temp[8]; /* Let it equal YYYYMMDD */
Date[3] = temp[9]; /* Swap the date around */
Date[4] = temp[3]; /* Swap the date around */
Date[5] = temp[4]; /* because when you convert */
Date[6] = temp[0]; /* a string to an int you */
Date[7] = temp[1]; /* loose the front Zero */
Date[8] = '\0'; /* making the number smaller */
/* and invalid to this cause */
ifDate = atol(Date);
if(ifDate >= itDate) { Sheader();
if (!Found) { Found = FALSE;
printf("\n\n"); Nopper();
if (iLC(2) == 1) {
free(Date);
free(temp);
return 1;
}
Found = TRUE;
}
memset(&T, 0, sizeof(T)); while (fread(&file, sizeof(file), 1, pFile) == 1) {
T.Area = arecno; strcpy(temp, StrDateDMY(file.UploadDate)); /* Realloc Space for Date */
T.Active = FALSE; Date[0] = temp[6]; /* Swap the date around */
T.Cost = file.Cost; Date[1] = temp[7]; /* Instead of DD-MM-YYYY */
T.Size = file.Size; Date[2] = temp[8]; /* Let it equal YYYYMMDD */
strncpy(T.SFile, file.Name, 12); Date[3] = temp[9]; /* Swap the date around */
strncpy(T.LFile, file.LName, 80); Date[4] = temp[3]; /* Swap the date around */
SetTag(T); Date[5] = temp[4]; /* because when you convert */
Date[6] = temp[0]; /* a string to an int you */
Count++; Date[7] = temp[1]; /* loose the front Zero */
if (ShowOneFile() == 1) { Date[8] = '\0'; /* making the number smaller */
free(Date); /* and invalid to this cause */
free(temp); ifDate = atol(Date);
return 1;
}
} /* End of if */
} /* End of while */
if (ifDate >= itDate) {
if (!Found) {
printf("\n\n");
if (iLC(2) == 1) {
free(Date);
free(temp);
fclose(pFile); fclose(pFile);
fclose(pAreas);
return 1;
}
Found = TRUE;
}
/* memset(&T, 0, sizeof(T));
* Add 2 blank lines after found files. T.Area = arecno;
*/ T.Active = FALSE;
if (Found) { T.Cost = file.Cost;
printf("\n\n"); T.Size = file.Size;
if (iLC(2) == 1) { strncpy(T.SFile, file.Name, 12);
free(Date); strncpy(T.LFile, file.LName, 80);
free(temp); SetTag(T);
return 1;
}
}
} /* End of open filebase */ Count++;
if (ShowOneFile() == 1) {
free(Date);
free(temp);
fclose(pFile);
fclose(pAreas);
return 1;
}
} /* End of check new files scan */ } /* End of if */
arecno++; /* Go to next file area */ } /* End of while */
} /* End of Main */ fclose(pFile);
if (Count) /*
Syslog('+', "Found %d new files", Count); * Add 2 blank lines after found files.
fclose(pAreas); */
printf("\n"); if (Found) {
if (Count) printf("\n\n");
Mark(); if (iLC(2) == 1) {
else free(Date);
Pause(); free(temp);
fclose(pAreas);
return 1;
}
}
free(temp); } /* End of open filebase */
free(Date);
return 1; } /* End of check new files scan */
arecno++; /* Go to next file area */
} /* End of Main */
if (Count)
Syslog('+', "Found %d new files", Count);
fclose(pAreas);
printf("\n");
if (Count)
Mark();
else
Pause();
free(temp);
free(Date);
return 1;
} }

View File

@ -225,6 +225,13 @@ int Crash_Option(faddr *Dest)
printf("%c", Keystroke(462, 1)); printf("%c", Keystroke(462, 1));
} }
fflush(stdout); fflush(stdout);
if (Nlent->addr.domain)
free(Nlent->addr.domain);
Nlent->addr.domain = NULL;
if (Nlent->url)
free(Nlent->url);
Nlent->url = NULL;
} }
Dest->point = point; Dest->point = point;
@ -399,7 +406,7 @@ void Post_Msg()
int i, x, cc; int i, x, cc;
char *FidoNode; char *FidoNode;
faddr *Dest = NULL; faddr *Dest = NULL;
node *Nlent; node *Nlent = NULL;
unsigned short point; unsigned short point;
Line = 1; Line = 1;
@ -505,6 +512,13 @@ void Post_Msg()
point = Dest->point; point = Dest->point;
Dest->point = 0; Dest->point = 0;
if (((Nlent = getnlent(Dest)) != NULL) && (Nlent->addr.zone)) { if (((Nlent = getnlent(Dest)) != NULL) && (Nlent->addr.zone)) {
if (Nlent->url)
free(Nlent->url);
Nlent->url = NULL;
if (Nlent->addr.domain)
free(Nlent->addr.domain);
Nlent->addr.domain = NULL;
colour(YELLOW, BLACK); colour(YELLOW, BLACK);
if (point) if (point)
printf("Boss : "); printf("Boss : ");
@ -577,6 +591,7 @@ void Post_Msg()
if (toupper(Getone()) == Keystroke(162, 0)) { if (toupper(Getone()) == Keystroke(162, 0)) {
for(i = 0; i < (TEXTBUFSIZE + 1); i++) for(i = 0; i < (TEXTBUFSIZE + 1); i++)
free(Message[i]); free(Message[i]);
tidy_faddr(Dest);
return; return;
} }
} }
@ -642,6 +657,7 @@ void Post_Msg()
for (i = 0; i < (TEXTBUFSIZE + 1); i++) for (i = 0; i < (TEXTBUFSIZE + 1); i++)
free(Message[i]); free(Message[i]);
tidy_faddr(Dest);
} }

View File

@ -143,9 +143,9 @@ int main(int argc, char **argv)
* Trap signals * Trap signals
*/ */
for(i = 0; i < NSIG; i++) { for(i = 0; i < NSIG; i++) {
if ((i == SIGHUP) || (i == SIGBUS) || (i == SIGILL) || (i == SIGSEGV) || (i == SIGTERM) || (i == SIGKILL)) if ((i == SIGHUP) || (i == SIGBUS) || (i == SIGILL) || (i == SIGSEGV) || (i == SIGTERM))
signal(i, (void (*))die); signal(i, (void (*))die);
else else if ((i != SIGKILL) && (i != SIGSTOP))
signal(i, SIG_IGN); signal(i, SIG_IGN);
} }

View File

@ -4,7 +4,7 @@
* Purpose ...............: Misc functions * Purpose ...............: Misc functions
* *
***************************************************************************** *****************************************************************************
* Copyright (C) 1997-2002 * Copyright (C) 1997-2003
* *
* Michiel Broek FIDO: 2:280/2802 * Michiel Broek FIDO: 2:280/2802
* Beekmansbos 10 * Beekmansbos 10
@ -62,75 +62,74 @@ int LC_Door = FALSE;
int ChkFiles() int ChkFiles()
{ {
FILE *pCallerLog, *pUsersFile; FILE *fp;
char *sDataFile; char *temp;
time_t Now; time_t Now;
char *temp;
sDataFile = calloc(PATH_MAX, sizeof(char)); temp = calloc(PATH_MAX, sizeof(char));
temp = calloc(PATH_MAX, sizeof(char));
sprintf(sDataFile, "%s/etc/sysinfo.data", getenv("MBSE_ROOT"));
chmod(sDataFile, 0660);
/* /*
* Check if users.data exists, if not create a new one. * Check if users.data exists, if not create a new one.
*/ */
sprintf(temp, "%s/etc/users.data", getenv("MBSE_ROOT")); sprintf(temp, "%s/etc/users.data", getenv("MBSE_ROOT"));
if ((pUsersFile = fopen(temp,"rb")) == NULL) { if ((fp = fopen(temp,"rb")) == NULL) {
if((pUsersFile = fopen(temp,"wb")) == NULL) { if ((fp = fopen(temp,"wb")) == NULL) {
WriteError("$Can't create %s", temp); WriteError("$Can't create %s", temp);
ExitClient(MBERR_INIT_ERROR); ExitClient(MBERR_INIT_ERROR);
} else { } else {
usrconfighdr.hdrsize = sizeof(usrconfighdr); usrconfighdr.hdrsize = sizeof(usrconfighdr);
usrconfighdr.recsize = sizeof(usrconfig); usrconfighdr.recsize = sizeof(usrconfig);
fwrite(&usrconfighdr, sizeof(usrconfighdr), 1, pUsersFile); fwrite(&usrconfighdr, sizeof(usrconfighdr), 1, fp);
fclose(pUsersFile); fclose(fp);
chmod(temp, 0660);
}
} }
} else {
fclose(fp);
}
chmod(temp, 0660);
/* /*
* Check if sysinfo.data exists, if not, create a new one. * Check if sysinfo.data exists, if not, create a new one.
*/ */
if ((pCallerLog = fopen(sDataFile, "rb")) == NULL) { sprintf(temp, "%s/etc/sysinfo.data", getenv("MBSE_ROOT"));
if((pCallerLog = fopen(sDataFile, "wb")) == NULL) if ((fp = fopen(temp, "rb")) == NULL) {
WriteError("$ChkFiles: Can't create %s", sDataFile); if ((fp = fopen(temp, "wb")) == NULL) {
else { WriteError("$ChkFiles: Can't create %s", temp);
memset((char *)&SYSINFO, 0, sizeof(SYSINFO)); } else {
Now = time(NULL); memset((char *)&SYSINFO, 0, sizeof(SYSINFO));
SYSINFO.StartDate = Now; Now = time(NULL);
SYSINFO.StartDate = Now;
rewind(pCallerLog); fwrite(&SYSINFO, sizeof(SYSINFO), 1, fp);
fwrite(&SYSINFO, sizeof(SYSINFO), 1, pCallerLog); fclose(fp);
fclose(pCallerLog);
chmod(sDataFile, 0660);
}
} }
free(temp); } else {
free(sDataFile); fclose(fp);
return 1; }
chmod(temp, 0660);
free(temp);
return 1;
} }
void DisplayLogo() void DisplayLogo()
{ {
FILE *pLogo; FILE *pLogo;
char *sString, *temp; char *sString, *temp;
temp = calloc(PATH_MAX, sizeof(char)); temp = calloc(PATH_MAX, sizeof(char));
sString = calloc(81, sizeof(char)); sString = calloc(81, sizeof(char));
sprintf(temp, "%s/%s", CFG.bbs_txtfiles, CFG.welcome_logo); sprintf(temp, "%s/%s", CFG.bbs_txtfiles, CFG.welcome_logo);
if((pLogo = fopen(temp,"rb")) == NULL) if ((pLogo = fopen(temp,"rb")) == NULL)
WriteError("$DisplayLogo: Can't open %s", temp); WriteError("$DisplayLogo: Can't open %s", temp);
else { else {
while( fgets(sString,80,pLogo) != NULL) while (fgets(sString, 80, pLogo) != NULL)
printf("%s", sString); printf("%s", sString);
fclose(pLogo); fclose(pLogo);
} }
free(sString); free(sString);
free(temp); free(temp);
} }
@ -140,85 +139,86 @@ void DisplayLogo()
*/ */
void Setup(char *Option, char *variable) void Setup(char *Option, char *variable)
{ {
ReadExitinfo(); ReadExitinfo();
strcpy(Option, variable); strcpy(Option, variable);
WriteExitinfo(); WriteExitinfo();
} }
void SaveLastCallers() void SaveLastCallers()
{ {
FILE *pGLC; FILE *pGLC;
char *sFileName; char *sFileName, sFileDate[9], sDate[9];
char sFileDate[9]; struct stat statfile;
char sDate[9];
struct stat statfile;
/* /*
* First check if we passed midnight, in that case we * First check if we passed midnight, in that case we create a fresh file.
* create a fresh file. */
*/ sFileName = calloc(PATH_MAX, sizeof(char));
sFileName = calloc(PATH_MAX, sizeof(char)); sprintf(sFileName,"%s/etc/lastcall.data", getenv("MBSE_ROOT"));
sprintf(sFileName,"%s/etc/lastcall.data", getenv("MBSE_ROOT")); stat(sFileName, &statfile);
stat(sFileName, &statfile);
sprintf(sFileDate,"%s", StrDateDMY(statfile.st_mtime)); sprintf(sFileDate,"%s", StrDateDMY(statfile.st_mtime));
sprintf(sDate,"%s", (char *) GetDateDMY()); sprintf(sDate,"%s", (char *) GetDateDMY());
if ((strcmp(sDate,sFileDate)) != 0) { if ((strcmp(sDate,sFileDate)) != 0) {
unlink(sFileName); unlink(sFileName);
Syslog('+', "Erased old lastcall.data"); Syslog('+', "Erased old lastcall.data");
}
/*
* Check if file exists, if not create the file and write the fileheader.
*/
if ((pGLC = fopen(sFileName, "r")) == NULL) {
if ((pGLC = fopen(sFileName, "w")) != NULL) {
LCALLhdr.hdrsize = sizeof(LCALLhdr);
LCALLhdr.recsize = sizeof(LCALL);
fwrite(&LCALLhdr, sizeof(LCALLhdr), 1, pGLC);
fclose(pGLC);
Syslog('+', "Created new lastcall.data");
} }
} else {
fclose(pGLC);
}
chmod(sFileName, 0660);
/* /*
* Check if file exists, if not create the file and * Now append a record
* write the fileheader. */
*/ if ((pGLC = fopen(sFileName,"a+")) == NULL) {
if ((pGLC = fopen(sFileName, "r")) == NULL) { WriteError("$Can't open %s", sFileName);
if ((pGLC = fopen(sFileName, "w")) != NULL) { return;
LCALLhdr.hdrsize = sizeof(LCALLhdr); } else {
LCALLhdr.recsize = sizeof(LCALL); ReadExitinfo();
fwrite(&LCALLhdr, sizeof(LCALLhdr), 1, pGLC); memset(&LCALL, 0, sizeof(LCALL));
Syslog('+', "Created new lastcall.data"); sprintf(LCALL.UserName,"%s", exitinfo.sUserName);
} sprintf(LCALL.Handle,"%s", exitinfo.sHandle);
fclose(pGLC); sprintf(LCALL.Name, "%s", exitinfo.Name);
} sprintf(LCALL.TimeOn,"%s", StartTime);
chmod(sFileName, 0660); sprintf(LCALL.Device,"%s", pTTY);
LCALL.SecLevel = exitinfo.Security.level;
LCALL.Calls = exitinfo.iTotalCalls;
LCALL.CallTime = exitinfo.iConnectTime;
LCALL.Download = LC_Download;
LCALL.Upload = LC_Upload;
LCALL.Read = LC_Read;
LCALL.Wrote = LC_Wrote;
LCALL.Chat = LC_Chat;
LCALL.Olr = LC_Olr;
LCALL.Door = LC_Door;
sprintf(LCALL.Speed, "%s", ttyinfo.speed);
if ((pGLC = fopen(sFileName,"a+")) == NULL) { /* If true then set hidden so it doesn't display in lastcallers function */
WriteError("$Can't open %s", sFileName); LCALL.Hidden = exitinfo.Hidden;
return;
} else {
ReadExitinfo();
memset(&LCALL, 0, sizeof(LCALL));
sprintf(LCALL.UserName,"%s", exitinfo.sUserName);
sprintf(LCALL.Handle,"%s", exitinfo.sHandle);
sprintf(LCALL.Name, "%s", exitinfo.Name);
sprintf(LCALL.TimeOn,"%s", StartTime);
sprintf(LCALL.Device,"%s", pTTY);
LCALL.SecLevel = exitinfo.Security.level;
LCALL.Calls = exitinfo.iTotalCalls;
LCALL.CallTime = exitinfo.iConnectTime;
LCALL.Download = LC_Download;
LCALL.Upload = LC_Upload;
LCALL.Read = LC_Read;
LCALL.Wrote = LC_Wrote;
LCALL.Chat = LC_Chat;
LCALL.Olr = LC_Olr;
LCALL.Door = LC_Door;
sprintf(LCALL.Speed, "%s", ttyinfo.speed);
/* If true then set hidden so it doesn't display in lastcallers function */ sprintf(LCALL.Location,"%s", exitinfo.sLocation);
LCALL.Hidden = exitinfo.Hidden;
sprintf(LCALL.Location,"%s", exitinfo.sLocation); rewind(pGLC); /* ???????????? */
fwrite(&LCALL, sizeof(LCALL), 1, pGLC);
rewind(pGLC); /* ???????????? */ fclose(pGLC);
fwrite(&LCALL, sizeof(LCALL), 1, pGLC); }
fclose(pGLC); free(sFileName);
}
free(sFileName);
} }
@ -226,14 +226,14 @@ void SaveLastCallers()
/* Gets Date for GetLastCallers(), returns DD:Mmm */ /* Gets Date for GetLastCallers(), returns DD:Mmm */
char *GLCdate() char *GLCdate()
{ {
static char GLcdate[15]; static char GLcdate[15];
Time_Now = time(NULL); Time_Now = time(NULL);
l_date = localtime(&Time_Now); l_date = localtime(&Time_Now);
sprintf(GLcdate,"%02d-", l_date->tm_mday); sprintf(GLcdate,"%02d-", l_date->tm_mday);
strcat(GLcdate,GetMonth(l_date->tm_mon+1)); strcat(GLcdate,GetMonth(l_date->tm_mon+1));
return(GLcdate); return(GLcdate);
} }

View File

@ -4,7 +4,7 @@
* Purpose ...............: Offline Reader * Purpose ...............: Offline Reader
* *
***************************************************************************** *****************************************************************************
* Copyright (C) 1997-2002 * Copyright (C) 1997-2003
* *
* Michiel Broek FIDO: 2:280/2802 * Michiel Broek FIDO: 2:280/2802
* Beekmansbos 10 * Beekmansbos 10
@ -2544,13 +2544,13 @@ union Converter {
float IEEToMSBIN(float f) float IEEToMSBIN(float f)
{ {
int sign, exp; int sign, expo;
union Converter t; union Converter t;
t.f[0] = f; t.f[0] = f;
sign = t.uc[3] / 0x80; sign = t.uc[3] / 0x80;
exp = ((t.ui[1] >> 7) - 0x7F + 0x81) & 0xFF; expo = ((t.ui[1] >> 7) - 0x7F + 0x81) & 0xFF;
t.ui[1] = (t.ui[1] & 0x7F) | (sign << 7) | (exp << 8); t.ui[1] = (t.ui[1] & 0x7F) | (sign << 7) | (expo << 8);
return t.f[0]; return t.f[0];
} }
@ -2560,12 +2560,12 @@ float IEEToMSBIN(float f)
float MSBINToIEEE(float f) float MSBINToIEEE(float f)
{ {
union Converter t; union Converter t;
int sign, exp; int sign, expo;
t.f[0] = f; t.f[0] = f;
sign = t.uc[2] / 0x80; sign = t.uc[2] / 0x80;
exp = (t.uc[3] - 0x81 + 0x7f) & 0xff; expo = (t.uc[3] - 0x81 + 0x7f) & 0xff;
t.ui[1] = (t.ui[1] & 0x7f) | (exp << 7) | (sign << 15); t.ui[1] = (t.ui[1] & 0x7f) | (expo << 7) | (sign << 15);
return t.f[0]; return t.f[0];
} }

View File

@ -4,7 +4,7 @@
* Purpose ...............: Oneliner functions. * Purpose ...............: Oneliner functions.
* *
***************************************************************************** *****************************************************************************
* Copyright (C) 1997-2002 * Copyright (C) 1997-2003
* *
* Michiel Broek FIDO: 2:280/2802 * Michiel Broek FIDO: 2:280/2802
* Beekmansbos 10 * Beekmansbos 10
@ -48,23 +48,26 @@ int iColour; /* Current color */
void Oneliner_Check() void Oneliner_Check()
{ {
FILE *pOneline; FILE *pOneline;
char *sFileName; char *sFileName;
sFileName = calloc(128, sizeof(char)); sFileName = calloc(PATH_MAX, sizeof(char));
sprintf(sFileName, "%s/etc/oneline.data", getenv("MBSE_ROOT")); sprintf(sFileName, "%s/etc/oneline.data", getenv("MBSE_ROOT"));
if ((pOneline = fopen(sFileName, "r")) == NULL) { if ((pOneline = fopen(sFileName, "r")) == NULL) {
if ((pOneline = fopen(sFileName, "w")) != NULL) { if ((pOneline = fopen(sFileName, "w")) != NULL) {
olhdr.hdrsize = sizeof(olhdr); olhdr.hdrsize = sizeof(olhdr);
olhdr.recsize = sizeof(ol); olhdr.recsize = sizeof(ol);
fwrite(&olhdr, sizeof(olhdr), 1, pOneline); fwrite(&olhdr, sizeof(olhdr), 1, pOneline);
fclose(pOneline); fclose(pOneline);
chmod(sFileName, 0660); Syslog('-', "Created oneliner database");
Syslog('-', "Created oneliner database");
}
} }
free(sFileName); } else {
fclose(pOneline);
}
chmod(sFileName, 0660);
free(sFileName);
} }

View File

@ -59,7 +59,7 @@
extern int sock; extern int sock;
extern pid_t mypid; extern pid_t mypid;
char *StartTime; char *StartTime = NULL;
/* /*

View File

@ -352,7 +352,7 @@ void chat_cleanuser(pid_t pid)
void chat_msg(int channel, char *nick, char *msg) void chat_msg(int channel, char *nick, char *msg)
{ {
int i; int i;
char buf[128], *log; char buf[128], *logm;
if (nick == NULL) if (nick == NULL)
sprintf(buf, "%s", msg); sprintf(buf, "%s", msg);
@ -360,10 +360,10 @@ void chat_msg(int channel, char *nick, char *msg)
sprintf(buf, "<%s> %s", nick, msg); sprintf(buf, "<%s> %s", nick, msg);
if (CFG.iAutoLog && strlen(CFG.chat_log)) { if (CFG.iAutoLog && strlen(CFG.chat_log)) {
log = calloc(PATH_MAX, sizeof(char)); logm = calloc(PATH_MAX, sizeof(char));
sprintf(log, "%s/log/%s", getenv("MBSE_ROOT"), CFG.chat_log); sprintf(logm, "%s/log/%s", getenv("MBSE_ROOT"), CFG.chat_log);
ulog(log, (char *)"+", chat_channels[channel].name, (char *)"-1", buf); ulog(logm, (char *)"+", chat_channels[channel].name, (char *)"-1", buf);
free(log); free(logm);
} }
buf[79] = '\0'; buf[79] = '\0';

View File

@ -422,7 +422,7 @@ char *reg_ipm(char *data)
*/ */
int reg_spm(char *data) int reg_spm(char *data)
{ {
char *cnt, *from, *too, *txt, *log; char *cnt, *from, *too, *txt, *logm;
int i; int i;
cnt = strtok(data, ","); cnt = strtok(data, ",");
@ -463,10 +463,10 @@ int reg_spm(char *data)
reginfo[i].ismsg = TRUE; reginfo[i].ismsg = TRUE;
if (CFG.iAutoLog && strlen(CFG.chat_log)) { if (CFG.iAutoLog && strlen(CFG.chat_log)) {
log = calloc(PATH_MAX, sizeof(char)); logm = calloc(PATH_MAX, sizeof(char));
sprintf(log, "%s/log/%s", getenv("MBSE_ROOT"), CFG.chat_log); sprintf(logm, "%s/log/%s", getenv("MBSE_ROOT"), CFG.chat_log);
ulog(log, (char *)"+", from, (char *)"-1", txt); ulog(logm, (char *)"+", from, (char *)"-1", txt);
free(log); free(logm);
} }
Syslog('+', "reg_spm: rec=%d in=%d out=%d ismsg=%d", i, reginfo[i].ptr_in, reginfo[i].ptr_out, reginfo[i].ismsg); Syslog('+', "reg_spm: rec=%d in=%d out=%d ismsg=%d", i, reginfo[i].ptr_in, reginfo[i].ptr_out, reginfo[i].ismsg);

View File

@ -4,7 +4,7 @@
* Purpose ...............: MBSE BBS Task Manager, utilities * Purpose ...............: MBSE BBS Task Manager, utilities
* *
***************************************************************************** *****************************************************************************
* Copyright (C) 1997-2001 * Copyright (C) 1997-2003
* *
* Michiel Broek FIDO: 2:280/2802 * Michiel Broek FIDO: 2:280/2802
* Beekmansbos 10 * Beekmansbos 10
@ -194,30 +194,30 @@ void Syslog(int grade, const char *format, ...)
int ulog(char *fn, char *grade, char *prname, char *prpid, char *format) int ulog(char *fn, char *grade, char *prname, char *prpid, char *format)
{ {
int i, oldmask; int i, oldmask;
FILE *log; FILE *fp;
oldmask = umask(066); oldmask = umask(066);
log = fopen(fn, "a"); fp = fopen(fn, "a");
umask(oldmask); umask(oldmask);
if (log == NULL) { if (fp == NULL) {
oserr = errno; oserr = errno;
Syslog('!', "$Cannot open user logfile %s", fn); Syslog('!', "$Cannot open user logfile %s", fn);
return -1; return -1;
} }
fprintf(log, "%s %s %s[%s] ", grade, date(), prname, prpid); fprintf(fp, "%s %s %s[%s] ", grade, date(), prname, prpid);
for (i = 0; i < strlen(format); i++) { for (i = 0; i < strlen(format); i++) {
if (iscntrl(format[i])) { if (iscntrl(format[i])) {
fputc('^', log); fputc('^', fp);
fputc(format[i] + 64, log); fputc(format[i] + 64, fp);
} else { } else {
fputc(format[i], log); fputc(format[i], fp);
} }
} }
fputc('\n', log); fputc('\n', fp);
fflush(log); fflush(fp);
if (fclose(log) != 0) { if (fclose(fp) != 0) {
oserr = errno; oserr = errno;
Syslog('!', "$Cannot close user logfile %s", fn); Syslog('!', "$Cannot close user logfile %s", fn);
return -1; return -1;