2001-08-17 05:46:24 +00:00
|
|
|
/*****************************************************************************
|
|
|
|
*
|
2001-11-10 17:14:16 +00:00
|
|
|
* $Id$
|
2001-08-17 05:46:24 +00:00
|
|
|
* Purpose ...............: Exitinfo functions
|
|
|
|
*
|
|
|
|
*****************************************************************************
|
2002-01-07 19:16:03 +00:00
|
|
|
* Copyright (C) 1997-2002
|
2001-08-17 05:46:24 +00:00
|
|
|
*
|
|
|
|
* Michiel Broek FIDO: 2:280/2802
|
|
|
|
* Beekmansbos 10
|
|
|
|
* 1971 BV IJmuiden
|
|
|
|
* the Netherlands
|
|
|
|
*
|
|
|
|
* This file is part of MBSE BBS.
|
|
|
|
*
|
|
|
|
* This BBS is free software; you can redistribute it and/or modify it
|
|
|
|
* under the terms of the GNU General Public License as published by the
|
|
|
|
* Free Software Foundation; either version 2, or (at your option) any
|
|
|
|
* later version.
|
|
|
|
*
|
|
|
|
* MBSE BBS is distributed in the hope that it will be useful, but
|
|
|
|
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with MBSE BBS; see the file COPYING. If not, write to the Free
|
|
|
|
* Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
|
|
|
|
*****************************************************************************/
|
|
|
|
|
2002-06-30 12:48:44 +00:00
|
|
|
#include "../config.h"
|
2001-08-17 05:46:24 +00:00
|
|
|
#include "../lib/libs.h"
|
2002-06-30 12:48:44 +00:00
|
|
|
#include "../lib/memwatch.h"
|
2001-08-17 05:46:24 +00:00
|
|
|
#include "../lib/mbse.h"
|
|
|
|
#include "../lib/structs.h"
|
2002-01-07 19:16:03 +00:00
|
|
|
#include "../lib/users.h"
|
2001-08-17 05:46:24 +00:00
|
|
|
#include "../lib/records.h"
|
|
|
|
#include "../lib/common.h"
|
|
|
|
#include "../lib/clcomm.h"
|
|
|
|
#include "funcs.h"
|
2001-11-10 17:14:16 +00:00
|
|
|
#include "input.h"
|
2001-08-17 05:46:24 +00:00
|
|
|
#include "language.h"
|
|
|
|
#include "oneline.h"
|
|
|
|
#include "misc.h"
|
|
|
|
#include "bye.h"
|
|
|
|
#include "timeout.h"
|
|
|
|
#include "timecheck.h"
|
|
|
|
#include "exitinfo.h"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
2001-11-12 21:42:17 +00:00
|
|
|
* Copy usersrecord into ~/home/unixname/exitinfo
|
2001-08-17 05:46:24 +00:00
|
|
|
*/
|
2001-11-11 12:07:39 +00:00
|
|
|
int InitExitinfo()
|
2001-08-17 05:46:24 +00:00
|
|
|
{
|
2003-05-08 18:59:31 +00:00
|
|
|
FILE *pUsrConfig, *pExitinfo;
|
|
|
|
char *temp;
|
|
|
|
long offset;
|
|
|
|
|
|
|
|
temp = calloc(PATH_MAX, sizeof(char));
|
|
|
|
sprintf(temp, "%s/etc/users.data", getenv("MBSE_ROOT"));
|
|
|
|
|
|
|
|
if ((pUsrConfig = fopen(temp,"r+b")) == NULL) {
|
|
|
|
WriteError("$Can't open %s for writing", temp);
|
|
|
|
free(temp);
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
fread(&usrconfighdr, sizeof(usrconfighdr), 1, pUsrConfig);
|
|
|
|
offset = usrconfighdr.hdrsize + (grecno * usrconfighdr.recsize);
|
|
|
|
if (fseek(pUsrConfig, offset, 0) != 0) {
|
|
|
|
WriteError("$Can't move pointer in %s", temp);
|
2001-08-17 05:46:24 +00:00
|
|
|
free(temp);
|
2003-05-08 18:59:31 +00:00
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
fread(&usrconfig, usrconfighdr.recsize, 1, pUsrConfig);
|
|
|
|
|
|
|
|
exitinfo = usrconfig;
|
|
|
|
fclose(pUsrConfig);
|
|
|
|
|
|
|
|
sprintf(temp, "%s/%s/exitinfo", CFG.bbs_usersdir, usrconfig.Name);
|
|
|
|
if ((pExitinfo = fopen(temp, "w+b")) == NULL) {
|
|
|
|
WriteError("$Can't open %s for writing", temp);
|
|
|
|
free(temp);
|
|
|
|
return FALSE;
|
|
|
|
} else {
|
|
|
|
fwrite(&exitinfo, sizeof(exitinfo), 1, pExitinfo);
|
|
|
|
fclose(pExitinfo);
|
|
|
|
if (chmod(temp, 0600))
|
|
|
|
WriteError("$Can't chmod 0600 %s", temp);
|
|
|
|
}
|
|
|
|
free(temp);
|
|
|
|
return TRUE;
|
2001-08-17 05:46:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Function will re-read users file in memory, so the latest information
|
|
|
|
* is available to other functions
|
|
|
|
*/
|
|
|
|
void ReadExitinfo()
|
|
|
|
{
|
2003-05-08 18:59:31 +00:00
|
|
|
FILE *pExitinfo;
|
|
|
|
char *temp;
|
|
|
|
|
|
|
|
temp = calloc(PATH_MAX, sizeof(char));
|
|
|
|
sprintf(temp, "%s/%s/exitinfo", CFG.bbs_usersdir, sUnixName);
|
|
|
|
mkdirs(temp, 0770);
|
|
|
|
if ((pExitinfo = fopen(temp,"r+b")) == NULL)
|
|
|
|
InitExitinfo();
|
|
|
|
else {
|
|
|
|
fflush(stdin);
|
|
|
|
fread(&exitinfo, sizeof(exitinfo), 1, pExitinfo);
|
|
|
|
fclose(pExitinfo);
|
|
|
|
}
|
|
|
|
free(temp);
|
2001-08-17 05:46:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Function will rewrite userinfo from memory, so the latest information
|
|
|
|
* is available to other functions
|
|
|
|
*/
|
|
|
|
void WriteExitinfo()
|
|
|
|
{
|
2003-05-08 18:59:31 +00:00
|
|
|
FILE *pExitinfo;
|
|
|
|
char *temp;
|
|
|
|
|
|
|
|
temp = calloc(PATH_MAX, sizeof(char));
|
|
|
|
|
|
|
|
sprintf(temp, "%s/%s/exitinfo", CFG.bbs_usersdir, sUnixName);
|
|
|
|
if ((pExitinfo = fopen(temp,"w+b")) == NULL)
|
|
|
|
WriteError("$WriteExitinfo() failed");
|
|
|
|
else {
|
|
|
|
fwrite(&exitinfo, sizeof(exitinfo), 1, pExitinfo);
|
|
|
|
fclose(pExitinfo);
|
|
|
|
}
|
|
|
|
free(temp);
|
2001-08-17 05:46:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|