2001-08-17 05:46:24 +00:00
|
|
|
/*****************************************************************************
|
|
|
|
*
|
2001-11-12 21:42:17 +00:00
|
|
|
* $Id$
|
2001-08-17 05:46:24 +00:00
|
|
|
* Purpose ...............: Hangup functions
|
|
|
|
*
|
|
|
|
*****************************************************************************
|
2003-05-08 18:59:31 +00:00
|
|
|
* Copyright (C) 1997-2003
|
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/clcomm.h"
|
|
|
|
#include "../lib/common.h"
|
2002-10-20 20:58:55 +00:00
|
|
|
#include "../lib/mberrors.h"
|
2001-11-10 17:14:16 +00:00
|
|
|
#include "dispfile.h"
|
2001-11-02 22:04:57 +00:00
|
|
|
#include "misc.h"
|
2001-08-17 05:46:24 +00:00
|
|
|
#include "language.h"
|
|
|
|
#include "bye.h"
|
|
|
|
|
|
|
|
|
|
|
|
extern pid_t mypid;
|
|
|
|
extern time_t t_start;
|
|
|
|
int do_mailout = FALSE;
|
|
|
|
|
|
|
|
|
|
|
|
void Good_Bye(int onsig)
|
|
|
|
{
|
2003-05-08 18:59:31 +00:00
|
|
|
FILE *pUsrConfig, *pExitinfo;
|
|
|
|
char *temp;
|
|
|
|
long offset;
|
|
|
|
time_t t_end;
|
2001-08-17 05:46:24 +00:00
|
|
|
|
2003-05-08 18:59:31 +00:00
|
|
|
IsDoing("Hangup");
|
|
|
|
temp = calloc(PATH_MAX, sizeof(char));
|
|
|
|
Syslog('+', "Good_Bye()");
|
2001-08-17 05:46:24 +00:00
|
|
|
|
2003-05-08 18:59:31 +00:00
|
|
|
if (onsig != SIGHUP)
|
|
|
|
DisplayFile((char *)"goodbye");
|
2001-08-17 05:46:24 +00:00
|
|
|
|
2003-05-08 18:59:31 +00:00
|
|
|
if (do_mailout)
|
|
|
|
CreateSema((char *)"mailout");
|
2001-08-17 05:46:24 +00:00
|
|
|
|
2003-05-08 18:59:31 +00:00
|
|
|
SaveLastCallers();
|
2001-08-17 05:46:24 +00:00
|
|
|
|
2003-05-08 18:59:31 +00:00
|
|
|
/*
|
|
|
|
* Update the users database record.
|
|
|
|
*/
|
|
|
|
sprintf(temp, "%s/etc/users.data", getenv("MBSE_ROOT"));
|
2003-05-10 11:51:43 +00:00
|
|
|
if ((pUsrConfig = fopen(temp,"r+")) != NULL) {
|
2003-05-08 18:59:31 +00:00
|
|
|
sprintf(temp, "%s/%s/exitinfo", CFG.bbs_usersdir, exitinfo.Name);
|
|
|
|
if ((pExitinfo = fopen(temp,"rb")) != NULL) {
|
|
|
|
fread(&usrconfighdr, sizeof(usrconfighdr), 1, pUsrConfig);
|
|
|
|
fread(&exitinfo, sizeof(exitinfo), 1, pExitinfo);
|
2001-08-17 05:46:24 +00:00
|
|
|
|
2003-05-08 18:59:31 +00:00
|
|
|
usrconfig = exitinfo;
|
|
|
|
fclose(pExitinfo);
|
|
|
|
usrconfig.iLastFileArea = iAreaNumber;
|
2001-08-17 05:46:24 +00:00
|
|
|
|
2003-05-08 18:59:31 +00:00
|
|
|
/* If time expired, do not say say successful logoff */
|
|
|
|
if (!iExpired)
|
|
|
|
Syslog('+', "User successfully logged off BBS");
|
2001-08-17 05:46:24 +00:00
|
|
|
|
2003-05-08 18:59:31 +00:00
|
|
|
usrconfig.iLastMsgArea = iMsgAreaNumber;
|
2001-08-17 05:46:24 +00:00
|
|
|
|
2003-05-08 18:59:31 +00:00
|
|
|
offset = usrconfighdr.hdrsize + (grecno * usrconfighdr.recsize);
|
2003-05-10 11:51:43 +00:00
|
|
|
if (fseek(pUsrConfig, offset, SEEK_SET) != 0) {
|
2003-05-08 18:59:31 +00:00
|
|
|
WriteError("Can't move pointer in file %s", temp);
|
|
|
|
ExitClient(MBERR_GENERAL);
|
|
|
|
}
|
2001-08-17 05:46:24 +00:00
|
|
|
|
2003-05-08 18:59:31 +00:00
|
|
|
fwrite(&usrconfig, sizeof(usrconfig), 1, pUsrConfig);
|
|
|
|
fclose(pUsrConfig);
|
2001-08-17 05:46:24 +00:00
|
|
|
}
|
2003-05-08 18:59:31 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
t_end = time(NULL);
|
|
|
|
Syslog(' ', "MBSEBBS finished in %s", t_elapsed(t_start, t_end));
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Start shutting down this session
|
|
|
|
*/
|
|
|
|
socket_shutdown(mypid);
|
|
|
|
sprintf(temp, "%s/tmp/mbsebbs%d", getenv("MBSE_ROOT"), getpid());
|
|
|
|
unlink(temp);
|
|
|
|
|
|
|
|
sprintf(temp, "%s/%s/exitinfo", CFG.bbs_usersdir, exitinfo.Name);
|
|
|
|
unlink(temp);
|
|
|
|
free(temp);
|
|
|
|
unlink("taglist");
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Flush all data to the user, wait 5 seconds to
|
2003-07-29 20:42:38 +00:00
|
|
|
* be sure the user received all data.
|
2003-05-08 18:59:31 +00:00
|
|
|
*/
|
2003-07-29 20:42:38 +00:00
|
|
|
colour(LIGHTGRAY, BLACK);
|
2003-05-08 18:59:31 +00:00
|
|
|
fflush(stdout);
|
|
|
|
fflush(stdin);
|
|
|
|
sleep(5);
|
|
|
|
|
|
|
|
Unsetraw();
|
|
|
|
Free_Language();
|
|
|
|
free(pTTY);
|
2001-08-17 05:46:24 +00:00
|
|
|
#ifdef MEMWATCH
|
2003-05-08 18:59:31 +00:00
|
|
|
mwTerm();
|
2001-08-17 05:46:24 +00:00
|
|
|
#endif
|
2003-05-08 18:59:31 +00:00
|
|
|
exit(onsig);
|
2001-08-17 05:46:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void Quick_Bye(int onsig)
|
|
|
|
{
|
2003-05-08 18:59:31 +00:00
|
|
|
char *temp;
|
|
|
|
|
|
|
|
temp = calloc(PATH_MAX, sizeof(char));
|
|
|
|
Syslog('+', "Quick_Bye");
|
|
|
|
socket_shutdown(mypid);
|
|
|
|
sprintf(temp, "%s/tmp/mbsebbs%d", getenv("MBSE_ROOT"), getpid());
|
|
|
|
unlink(temp);
|
|
|
|
free(temp);
|
|
|
|
|
2003-07-29 20:42:38 +00:00
|
|
|
colour(LIGHTGRAY, BLACK);
|
2003-05-08 18:59:31 +00:00
|
|
|
fflush(stdout);
|
|
|
|
fflush(stdin);
|
|
|
|
sleep(3);
|
|
|
|
|
|
|
|
Free_Language();
|
|
|
|
free(pTTY);
|
2001-08-17 05:46:24 +00:00
|
|
|
#ifdef MEMWATCH
|
2003-05-08 18:59:31 +00:00
|
|
|
mwTerm();
|
2001-08-17 05:46:24 +00:00
|
|
|
#endif
|
2003-05-08 18:59:31 +00:00
|
|
|
exit(MBERR_OK);
|
2001-08-17 05:46:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|