2001-08-17 05:46:24 +00:00
|
|
|
/*****************************************************************************
|
|
|
|
*
|
2002-06-05 21:07:36 +00:00
|
|
|
* $Id$
|
2001-08-17 05:46:24 +00:00
|
|
|
* Purpose ...............: Give system information
|
|
|
|
*
|
|
|
|
*****************************************************************************
|
2005-08-29 21:03:28 +00:00
|
|
|
* Copyright (C) 1997-2005
|
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.
|
|
|
|
*
|
|
|
|
* MB 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 MB BBS; see the file COPYING. If not, write to the Free
|
|
|
|
* Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
|
|
|
|
*****************************************************************************/
|
|
|
|
|
2002-06-30 13:20:57 +00:00
|
|
|
#include "../config.h"
|
2004-02-21 17:22:00 +00:00
|
|
|
#include "../lib/mbselib.h"
|
2001-08-17 05:46:24 +00:00
|
|
|
#include "taskinfo.h"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Get BBS System info.
|
|
|
|
*/
|
|
|
|
char *get_sysinfo(void)
|
|
|
|
{
|
2004-04-07 20:01:49 +00:00
|
|
|
FILE *fp;
|
|
|
|
static char buf[SS_BUFSIZE];
|
|
|
|
char *temp;
|
|
|
|
time_t startdate;
|
2001-08-17 05:46:24 +00:00
|
|
|
|
2005-08-29 21:03:28 +00:00
|
|
|
snprintf(buf, SS_BUFSIZE, "201:1,16;");
|
2004-04-07 20:01:49 +00:00
|
|
|
temp = calloc(PATH_MAX, sizeof(char));
|
2005-08-29 21:03:28 +00:00
|
|
|
snprintf(temp, PATH_MAX, "%s/etc/sysinfo.data", getenv("MBSE_ROOT"));
|
2001-08-17 05:46:24 +00:00
|
|
|
|
2004-04-07 20:01:49 +00:00
|
|
|
if ((fp = fopen(temp, "r")) == NULL) {
|
2001-08-17 05:46:24 +00:00
|
|
|
free(temp);
|
2004-04-07 20:01:49 +00:00
|
|
|
return buf;
|
|
|
|
}
|
|
|
|
free(temp);
|
2001-08-17 05:46:24 +00:00
|
|
|
|
2004-04-07 20:01:49 +00:00
|
|
|
if (fread(&SYSINFO, sizeof(SYSINFO), 1, fp) == 1) {
|
|
|
|
startdate = SYSINFO.StartDate;
|
2005-10-11 20:49:41 +00:00
|
|
|
snprintf(buf, SS_BUFSIZE, "100:7,%d,%d,%d,%d,%d,%s,%s;", SYSINFO.SystemCalls,
|
2001-08-17 05:46:24 +00:00
|
|
|
SYSINFO.Pots, SYSINFO.ISDN, SYSINFO.Network, SYSINFO.Local,
|
2005-10-17 14:36:12 +00:00
|
|
|
ctime(&startdate), clencode(SYSINFO.LastCaller));
|
2004-04-07 20:01:49 +00:00
|
|
|
}
|
2004-04-06 21:32:06 +00:00
|
|
|
|
2004-04-07 20:01:49 +00:00
|
|
|
fclose(fp);
|
2001-08-17 05:46:24 +00:00
|
|
|
|
2004-04-07 20:01:49 +00:00
|
|
|
return buf;
|
2001-08-17 05:46:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
char *get_lastcallercount(void)
|
|
|
|
{
|
2005-09-11 13:07:42 +00:00
|
|
|
static char buf[41];
|
|
|
|
char *temp;
|
|
|
|
FILE *fp;
|
2001-08-17 05:46:24 +00:00
|
|
|
|
2005-09-11 13:07:42 +00:00
|
|
|
snprintf(buf, 41, "100:1,0;");
|
|
|
|
temp = calloc(PATH_MAX, sizeof(char));
|
|
|
|
snprintf(temp, PATH_MAX, "%s/etc/lastcall.data", getenv("MBSE_ROOT"));
|
|
|
|
if ((fp = fopen(temp, "r")) == NULL) {
|
2005-08-29 21:03:28 +00:00
|
|
|
free(temp);
|
2001-08-17 05:46:24 +00:00
|
|
|
return buf;
|
2005-09-11 13:07:42 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
fread(&LCALLhdr, sizeof(LCALLhdr), 1, fp);
|
|
|
|
fseek(fp, 0, SEEK_END);
|
|
|
|
snprintf(buf, 41, "100:1,%ld;", ((ftell(fp) - LCALLhdr.hdrsize) / LCALLhdr.recsize));
|
|
|
|
fclose(fp);
|
|
|
|
free(temp);
|
|
|
|
return buf;
|
2001-08-17 05:46:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
char *get_lastcallerrec(int Rec)
|
|
|
|
{
|
2005-10-17 14:36:12 +00:00
|
|
|
static char buf[SS_BUFSIZE];
|
|
|
|
char *temp, action[9], *name, *city;
|
|
|
|
FILE *fp;
|
2001-08-17 05:46:24 +00:00
|
|
|
|
2005-10-17 14:36:12 +00:00
|
|
|
snprintf(buf, SS_BUFSIZE, "201:1,16;");
|
|
|
|
temp = calloc(PATH_MAX, sizeof(char));
|
|
|
|
snprintf(temp, PATH_MAX, "%s/etc/lastcall.data", getenv("MBSE_ROOT"));
|
|
|
|
if ((fp = fopen(temp, "r")) == NULL) {
|
2005-08-29 21:03:28 +00:00
|
|
|
free(temp);
|
2001-08-17 05:46:24 +00:00
|
|
|
return buf;
|
2005-10-17 14:36:12 +00:00
|
|
|
}
|
|
|
|
fread(&LCALLhdr, sizeof(LCALLhdr), 1, fp);
|
|
|
|
fseek(fp, ((Rec -1) * LCALLhdr.recsize) + LCALLhdr.hdrsize, SEEK_SET);
|
|
|
|
|
|
|
|
if (fread(&LCALL, LCALLhdr.recsize, 1, fp) == 1) {
|
|
|
|
LCALL.UserName[15] = '\0';
|
|
|
|
LCALL.Location[12] = '\0';
|
|
|
|
strcpy(action, "--------");
|
|
|
|
if (LCALL.Hidden)
|
|
|
|
action[0] = 'H';
|
|
|
|
if (LCALL.Download)
|
|
|
|
action[1] = 'D';
|
|
|
|
if (LCALL.Upload)
|
|
|
|
action[2] = 'U';
|
|
|
|
if (LCALL.Read)
|
|
|
|
action[3] = 'R';
|
|
|
|
if (LCALL.Wrote)
|
|
|
|
action[4] = 'P';
|
|
|
|
if (LCALL.Chat)
|
|
|
|
action[5] = 'C';
|
|
|
|
if (LCALL.Olr)
|
|
|
|
action[6] = 'O';
|
|
|
|
if (LCALL.Door)
|
|
|
|
action[7] = 'E';
|
|
|
|
action[8] = '\0';
|
|
|
|
name = xstrcpy(clencode(LCALL.UserName));
|
|
|
|
city = xstrcpy(clencode(LCALL.Location));
|
|
|
|
snprintf(buf, SS_BUFSIZE, "100:9,%s,%s,%d,%s,%s,%d,%d,%s,%s;", name, city,
|
|
|
|
LCALL.SecLevel, LCALL.Device, LCALL.TimeOn,
|
|
|
|
(int)LCALL.CallTime, LCALL.Calls, LCALL.Speed, action);
|
|
|
|
free(name);
|
|
|
|
free(city);
|
|
|
|
}
|
|
|
|
|
|
|
|
free(temp);
|
|
|
|
fclose(fp);
|
|
|
|
return buf;
|
2001-08-17 05:46:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|