2001-08-17 05:46:24 +00:00
|
|
|
/*****************************************************************************
|
|
|
|
*
|
2002-01-11 19:01:00 +00:00
|
|
|
* $Id$
|
2001-08-17 05:46:24 +00:00
|
|
|
* Purpose ...............: Monitor Program
|
|
|
|
*
|
|
|
|
*****************************************************************************
|
2006-02-04 14:06:15 +00:00
|
|
|
* Copyright (C) 1997-2006
|
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
|
2003-08-15 20:05:34 +00:00
|
|
|
* Software Foundation, 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
|
2001-08-17 05:46:24 +00:00
|
|
|
*****************************************************************************/
|
|
|
|
|
2002-06-30 12:48:44 +00:00
|
|
|
#include "../config.h"
|
2004-02-21 15:42:39 +00:00
|
|
|
#include "../lib/mbselib.h"
|
|
|
|
#include "../lib/users.h"
|
|
|
|
#include "../lib/mbsedb.h"
|
2003-08-03 14:08:07 +00:00
|
|
|
#include "proglock.h"
|
2001-08-17 05:46:24 +00:00
|
|
|
#include "mutil.h"
|
|
|
|
|
|
|
|
|
2005-10-17 14:36:12 +00:00
|
|
|
int cols = 80;
|
|
|
|
int rows = 24;
|
2003-03-23 21:27:14 +00:00
|
|
|
|
|
|
|
extern int bbs_free;
|
|
|
|
extern int ttyfd;
|
|
|
|
extern pid_t mypid;
|
2002-05-04 19:45:19 +00:00
|
|
|
|
2003-03-24 19:44:38 +00:00
|
|
|
struct sysconfig CFG;
|
|
|
|
|
|
|
|
|
2006-02-06 14:23:35 +00:00
|
|
|
char rbuf[50][81]; /* Chat receive buffer */ /* FIXME: must be a dynamic buffer */
|
2003-03-24 19:44:38 +00:00
|
|
|
int rpointer = 0; /* Chat receive pointer */
|
|
|
|
int rsize = 5; /* Chat receive size */
|
|
|
|
|
2002-05-04 19:45:19 +00:00
|
|
|
|
2001-08-17 05:46:24 +00:00
|
|
|
static void die(int onsig)
|
|
|
|
{
|
2003-03-19 22:45:46 +00:00
|
|
|
char buf[128];
|
|
|
|
|
|
|
|
signal(onsig, SIG_IGN);
|
2003-08-03 14:08:07 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Prevent clear screen when the program was locked
|
|
|
|
*/
|
|
|
|
if (onsig != MBERR_NO_PROGLOCK)
|
|
|
|
screen_stop();
|
|
|
|
|
2003-03-19 22:45:46 +00:00
|
|
|
if (onsig && (onsig <= NSIG))
|
2003-08-03 14:08:07 +00:00
|
|
|
Syslog('?', "MBMON Finished on signal %s", SigName[onsig]);
|
2003-03-19 22:45:46 +00:00
|
|
|
else
|
2003-08-03 14:08:07 +00:00
|
|
|
Syslog(' ', "MBMON Normally finished");
|
2003-03-19 22:45:46 +00:00
|
|
|
|
2005-08-28 17:08:03 +00:00
|
|
|
snprintf(buf, 128, "CSYS:2,%d,0;", mypid);
|
2003-03-19 22:45:46 +00:00
|
|
|
if (socket_send(buf) == 0)
|
2005-08-28 17:08:03 +00:00
|
|
|
snprintf(buf, 128, "%s", socket_receive());
|
2003-08-03 14:08:07 +00:00
|
|
|
ulockprogram((char *)"mbmon");
|
2003-03-19 22:45:46 +00:00
|
|
|
ExitClient(0);
|
2001-08-17 05:46:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void ShowSysinfo(void)
|
|
|
|
{
|
2003-03-23 21:27:14 +00:00
|
|
|
int ch;
|
2005-10-17 14:36:12 +00:00
|
|
|
char buf[128], *cnt, *lc;
|
2003-03-23 21:27:14 +00:00
|
|
|
|
|
|
|
clr_index();
|
|
|
|
set_color(WHITE, BLACK);
|
2004-10-27 11:08:09 +00:00
|
|
|
mbse_mvprintw( 5, 6, "4. SHOW BBS SYSTEM INFO");
|
2003-03-23 21:27:14 +00:00
|
|
|
set_color(CYAN, BLACK);
|
2004-10-27 11:08:09 +00:00
|
|
|
mbse_mvprintw( 7, 6, "1. Total calls");
|
|
|
|
mbse_mvprintw( 8, 6, "2. Pots calls");
|
|
|
|
mbse_mvprintw( 9, 6, "3. ISDN calls");
|
|
|
|
mbse_mvprintw(10, 6, "4. Network calls");
|
|
|
|
mbse_mvprintw(11, 6, "5. Local calls");
|
|
|
|
mbse_mvprintw(12, 6, "6. Date started");
|
|
|
|
mbse_mvprintw(13, 6, "7. Last caller");
|
2005-10-17 14:36:12 +00:00
|
|
|
center_addstr(rows - 3, (char *)"Press any key");
|
2003-03-23 21:27:14 +00:00
|
|
|
IsDoing("View System Info");
|
|
|
|
|
|
|
|
do {
|
|
|
|
show_date(LIGHTGRAY, BLACK, 0, 0);
|
|
|
|
set_color(LIGHTGRAY, BLACK);
|
2005-08-28 17:08:03 +00:00
|
|
|
snprintf(buf, 128, "GSYS:1,%d;", getpid());
|
2003-03-23 21:27:14 +00:00
|
|
|
if (socket_send(buf) == 0) {
|
2005-08-28 17:08:03 +00:00
|
|
|
snprintf(buf, 128, "%s", socket_receive());
|
2003-03-23 21:27:14 +00:00
|
|
|
if (strncmp(buf, "100:7,", 6) == 0) {
|
|
|
|
cnt = strtok(buf, ",");
|
2004-10-27 11:08:09 +00:00
|
|
|
mbse_mvprintw( 7,26, "%s", strtok(NULL, ","));
|
|
|
|
mbse_mvprintw( 8,26, "%s", strtok(NULL, ","));
|
|
|
|
mbse_mvprintw( 9,26, "%s", strtok(NULL, ","));
|
|
|
|
mbse_mvprintw(10,26, "%s", strtok(NULL, ","));
|
|
|
|
mbse_mvprintw(11,26, "%s", strtok(NULL, ","));
|
|
|
|
mbse_mvprintw(12,26, "%s", strtok(NULL, ","));
|
2005-10-17 14:36:12 +00:00
|
|
|
lc = xstrcpy(cldecode(strtok(NULL, ";")));
|
|
|
|
mbse_mvprintw(13,26, "%s", lc);
|
|
|
|
free(lc);
|
2003-03-23 21:27:14 +00:00
|
|
|
fflush(stdout);
|
|
|
|
}
|
|
|
|
}
|
2005-10-17 14:36:12 +00:00
|
|
|
ch = testkey(rows - 3, cols / 2 + 8);
|
2003-03-23 21:27:14 +00:00
|
|
|
} while (ch == '\0');
|
2001-08-17 05:46:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void ShowLastcaller(void)
|
|
|
|
{
|
2003-03-23 21:27:14 +00:00
|
|
|
int records, maxrows, ch, i, y, o;
|
|
|
|
char buf[128], *cnt;
|
2001-08-17 05:46:24 +00:00
|
|
|
|
2003-03-23 21:27:14 +00:00
|
|
|
clr_index();
|
|
|
|
set_color(WHITE, BLACK);
|
2004-10-27 11:08:09 +00:00
|
|
|
mbse_mvprintw( 4, 6, "5. SHOW BBS LASTCALLERS");
|
2003-03-23 21:27:14 +00:00
|
|
|
set_color(YELLOW, RED);
|
2004-10-27 11:08:09 +00:00
|
|
|
mbse_mvprintw( 6, 1, "Nr Username Location Level Device Time Mins Calls Speed Actions ");
|
2003-03-23 21:27:14 +00:00
|
|
|
set_color(CYAN, BLACK);
|
2005-10-17 14:36:12 +00:00
|
|
|
center_addstr(rows - 1, (char *)"Press any key");
|
2003-03-23 21:27:14 +00:00
|
|
|
IsDoing("View Lastcallers");
|
2005-10-17 14:36:12 +00:00
|
|
|
maxrows = rows - 10;
|
2003-03-23 21:27:14 +00:00
|
|
|
|
|
|
|
do {
|
|
|
|
show_date(LIGHTGRAY, BLACK, 0, 0);
|
|
|
|
records = 0;
|
2005-08-28 17:08:03 +00:00
|
|
|
snprintf(buf, 128, "GLCC:0;");
|
2003-03-23 21:27:14 +00:00
|
|
|
if (socket_send(buf) == 0) {
|
2005-08-28 17:08:03 +00:00
|
|
|
snprintf(buf, 128, "%s", socket_receive());
|
2003-03-23 21:27:14 +00:00
|
|
|
if (strncmp(buf, "100:1,", 6) == 0) {
|
|
|
|
cnt = strtok(buf, ",");
|
|
|
|
records = atoi(strtok(NULL, ";"));
|
|
|
|
}
|
|
|
|
}
|
2001-08-17 05:46:24 +00:00
|
|
|
|
2003-03-23 21:27:14 +00:00
|
|
|
if (records) {
|
|
|
|
y = 7;
|
|
|
|
if (records > maxrows)
|
|
|
|
o = records - maxrows;
|
|
|
|
else
|
|
|
|
o = 1;
|
|
|
|
set_color(CYAN, BLACK);
|
|
|
|
for (i = o; i <= records; i++) {
|
2005-08-28 17:08:03 +00:00
|
|
|
snprintf(buf, 128, "GLCR:1,%d;", i);
|
2001-08-17 05:46:24 +00:00
|
|
|
if (socket_send(buf) == 0) {
|
2005-08-28 17:08:03 +00:00
|
|
|
snprintf(buf, 128, "%s", socket_receive());
|
2003-03-23 21:27:14 +00:00
|
|
|
if (strncmp(buf, "100:9,", 6) == 0) {
|
|
|
|
cnt = strtok(buf, ",");
|
2004-10-27 11:08:09 +00:00
|
|
|
mbse_mvprintw(y, 1, "%2d", i);
|
2005-10-17 14:36:12 +00:00
|
|
|
mbse_mvprintw(y, 4, "%s", cldecode(strtok(NULL, ",")));
|
|
|
|
mbse_mvprintw(y,19, "%s", cldecode(strtok(NULL, ",")));
|
2004-10-27 11:08:09 +00:00
|
|
|
mbse_mvprintw(y,32, "%s", strtok(NULL, ","));
|
|
|
|
mbse_mvprintw(y,38, "%s", strtok(NULL, ","));
|
|
|
|
mbse_mvprintw(y,45, "%s", strtok(NULL, ","));
|
|
|
|
mbse_mvprintw(y,51, "%s", strtok(NULL, ","));
|
|
|
|
mbse_mvprintw(y,56, "%s", strtok(NULL, ","));
|
|
|
|
mbse_mvprintw(y,62, "%s", strtok(NULL, ","));
|
|
|
|
mbse_mvprintw(y,72, "%s", strtok(NULL, ";"));
|
2003-03-23 21:27:14 +00:00
|
|
|
y++;
|
|
|
|
}
|
2001-08-17 05:46:24 +00:00
|
|
|
}
|
2003-03-23 21:27:14 +00:00
|
|
|
}
|
|
|
|
}
|
2005-10-17 14:36:12 +00:00
|
|
|
ch = testkey(rows - 1, cols / 2 + 8);
|
2003-03-23 21:27:14 +00:00
|
|
|
} while (ch == '\0');
|
2001-08-17 05:46:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void system_moni(void)
|
|
|
|
{
|
2003-03-23 21:27:14 +00:00
|
|
|
int ch, y, eof;
|
2006-05-27 16:02:19 +00:00
|
|
|
char *cnt, buf[128], *t;
|
2003-03-23 21:27:14 +00:00
|
|
|
time_t start, now;
|
|
|
|
|
|
|
|
clr_index();
|
|
|
|
set_color(WHITE, BLACK);
|
2004-10-27 11:08:09 +00:00
|
|
|
mbse_mvprintw( 5, 6, "1. SERVER CLIENTS");
|
2003-03-23 21:27:14 +00:00
|
|
|
set_color(YELLOW, RED);
|
2004-10-27 11:08:09 +00:00
|
|
|
mbse_mvprintw( 7, 1, "Pid tty user program city doing time ");
|
2003-03-23 21:27:14 +00:00
|
|
|
set_color(CYAN, BLACK);
|
2005-10-17 14:36:12 +00:00
|
|
|
center_addstr(rows - 1, (char *)"Press any key");
|
2003-03-23 21:27:14 +00:00
|
|
|
IsDoing("System Monitor");
|
|
|
|
|
|
|
|
do {
|
|
|
|
show_date(LIGHTGRAY, BLACK, 0, 0);
|
|
|
|
|
|
|
|
eof = 0;
|
|
|
|
set_color(LIGHTGRAY, BLACK);
|
|
|
|
|
2005-10-17 14:36:12 +00:00
|
|
|
for (y = 8; y <= rows - 2; y++) {
|
2003-03-23 21:27:14 +00:00
|
|
|
if (y == 8)
|
2005-08-28 17:08:03 +00:00
|
|
|
snprintf(buf, 128, "GMON:1,1;");
|
2003-03-23 21:27:14 +00:00
|
|
|
else
|
2005-08-28 17:08:03 +00:00
|
|
|
snprintf(buf, 128, "GMON:1,0;");
|
2003-03-23 21:27:14 +00:00
|
|
|
if (eof == 0) {
|
|
|
|
if (socket_send(buf) == 0) {
|
2005-08-28 17:08:03 +00:00
|
|
|
strncpy(buf, socket_receive(), 128);
|
2004-10-27 11:08:09 +00:00
|
|
|
mbse_locate(y, 1);
|
2003-03-23 21:27:14 +00:00
|
|
|
clrtoeol();
|
|
|
|
if (strncmp(buf, "100:0;", 6) == 0) {
|
|
|
|
/*
|
|
|
|
* There's no more information
|
|
|
|
*/
|
|
|
|
eof = 1;
|
|
|
|
} else {
|
|
|
|
cnt = strtok(buf, ",");
|
2004-10-27 11:08:09 +00:00
|
|
|
mbse_mvprintw(y, 1, (char *)"%.5s", strtok(NULL, ","));
|
|
|
|
mbse_mvprintw(y, 7, (char *)"%.6s", strtok(NULL, ","));
|
2005-10-17 14:36:12 +00:00
|
|
|
mbse_mvprintw(y,14, (char *)"%.8s", cldecode(strtok(NULL, ",")));
|
|
|
|
mbse_mvprintw(y,23, (char *)"%.8s", cldecode(strtok(NULL, ",")));
|
2006-05-27 16:02:19 +00:00
|
|
|
t = strtok(NULL, ",");
|
|
|
|
Syslog('-', "%s", t);
|
|
|
|
Syslog('-', "%s", cldecode(t));
|
|
|
|
mbse_mvprintw(y,32, (char *)"%.15s", t);
|
|
|
|
// mbse_mvprintw(y,32, (char *)"%.15s", cldecode(strtok(NULL, ",")));
|
|
|
|
mbse_mvprintw(y,48, (char *)"%.26s", cldecode(strtok(NULL, ",")));
|
2003-03-23 21:27:14 +00:00
|
|
|
start = atoi(strtok(NULL, ";"));
|
|
|
|
now = time(NULL);
|
2004-10-27 11:08:09 +00:00
|
|
|
mbse_mvprintw(y,75, (char *)"%s", t_elapsed(start, now));
|
2003-03-23 21:27:14 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
/*
|
|
|
|
* If no valid data, clear line
|
|
|
|
*/
|
2004-10-27 11:08:09 +00:00
|
|
|
mbse_locate(y, 1);
|
2003-03-23 21:27:14 +00:00
|
|
|
clrtoeol();
|
|
|
|
}
|
|
|
|
} /* for () */
|
|
|
|
|
2005-10-17 14:36:12 +00:00
|
|
|
ch = testkey(rows - 1, cols / 2 + 8);
|
2003-03-23 21:27:14 +00:00
|
|
|
} while (ch == '\0');
|
2001-08-17 05:46:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void system_stat(void)
|
|
|
|
{
|
2004-03-20 16:09:35 +00:00
|
|
|
int ch;
|
|
|
|
char buf[256], *cnt;
|
|
|
|
time_t now;
|
|
|
|
|
|
|
|
clr_index();
|
|
|
|
set_color(WHITE, BLACK);
|
2004-10-27 11:08:09 +00:00
|
|
|
mbse_mvprintw( 5, 6, "2. SERVER STATISTICS");
|
2004-03-20 16:09:35 +00:00
|
|
|
set_color(CYAN, BLACK);
|
2004-10-27 11:08:09 +00:00
|
|
|
mbse_mvprintw( 7, 6, "First date started");
|
2005-05-01 09:18:17 +00:00
|
|
|
mbse_mvprintw( 7,59, "BBS Open");
|
2004-10-27 11:08:09 +00:00
|
|
|
mbse_mvprintw( 8, 6, "Last date started");
|
2005-05-01 09:18:17 +00:00
|
|
|
mbse_mvprintw( 8,59, "ZMH");
|
2004-10-27 11:08:09 +00:00
|
|
|
mbse_mvprintw( 9, 6, "Total server starts");
|
2005-05-01 09:18:17 +00:00
|
|
|
mbse_mvprintw( 9,59, "Internet up");
|
2004-10-27 11:08:09 +00:00
|
|
|
mbse_mvprintw(10, 6, "Connected clients");
|
2005-05-01 09:18:17 +00:00
|
|
|
mbse_mvprintw(10,59, "Need inet");
|
|
|
|
mbse_mvprintw(11,59, "Running");
|
2004-10-27 11:08:09 +00:00
|
|
|
mbse_mvprintw(12,30, "Total Today");
|
2005-05-01 09:18:17 +00:00
|
|
|
mbse_mvprintw(12,59, "Load average");
|
2004-03-20 16:09:35 +00:00
|
|
|
hor_lin(13,30,8);
|
|
|
|
hor_lin(13,45,8);
|
2005-05-01 09:18:17 +00:00
|
|
|
mbse_mvprintw(13,59, "Diskspace");
|
2004-10-27 11:08:09 +00:00
|
|
|
mbse_mvprintw(14, 6, "Client connects");
|
2005-05-01 09:18:17 +00:00
|
|
|
mbse_mvprintw(14,59, "IBC servers");
|
2004-10-27 11:08:09 +00:00
|
|
|
mbse_mvprintw(15, 6, "Peak connections");
|
2005-05-01 09:18:17 +00:00
|
|
|
mbse_mvprintw(15,59, "IBC channels");
|
2004-10-27 11:08:09 +00:00
|
|
|
mbse_mvprintw(16, 6, "Protocol syntax errors");
|
2005-05-01 09:18:17 +00:00
|
|
|
mbse_mvprintw(16,59, "IBC users");
|
2004-10-27 11:08:09 +00:00
|
|
|
mbse_mvprintw(17, 6, "Communication errors");
|
|
|
|
mbse_mvprintw(19, 6, "Next sequence number");
|
2005-10-17 14:36:12 +00:00
|
|
|
mbse_mvprintw(rows -3,59, "Press any key");
|
2004-03-20 16:09:35 +00:00
|
|
|
IsDoing("System Statistics");
|
|
|
|
|
|
|
|
do {
|
|
|
|
show_date(LIGHTGRAY, BLACK, 0, 0);
|
2001-08-17 05:46:24 +00:00
|
|
|
|
2005-08-28 17:08:03 +00:00
|
|
|
snprintf(buf, 256, "GSTA:1,%d;", getpid());
|
2004-03-20 16:09:35 +00:00
|
|
|
if (socket_send(buf) == 0) {
|
2005-08-28 17:08:03 +00:00
|
|
|
strncpy(buf, socket_receive(), 256);
|
2004-03-20 16:09:35 +00:00
|
|
|
set_color(LIGHTGRAY, BLACK);
|
|
|
|
cnt = strtok(buf, ",");
|
|
|
|
now = atoi(strtok(NULL, ","));
|
2004-10-27 11:08:09 +00:00
|
|
|
mbse_mvprintw(7, 30, "%s", ctime(&now));
|
2004-03-20 16:09:35 +00:00
|
|
|
now = atoi(strtok(NULL, ","));
|
2004-10-27 11:08:09 +00:00
|
|
|
mbse_mvprintw(8, 30, "%s", ctime(&now));
|
2004-03-20 16:09:35 +00:00
|
|
|
cnt = strtok(NULL, ",");
|
2004-10-27 11:08:09 +00:00
|
|
|
mbse_mvprintw(9, 30, (char *)"%s ", strtok(NULL, ","));
|
|
|
|
mbse_mvprintw(10,30, (char *)"%s ", strtok(NULL, ","));
|
|
|
|
mbse_mvprintw(14,30, (char *)"%s ", strtok(NULL, ","));
|
|
|
|
mbse_mvprintw(15,30, (char *)"%s ", strtok(NULL, ","));
|
|
|
|
mbse_mvprintw(16,30, (char *)"%s ", strtok(NULL, ","));
|
|
|
|
mbse_mvprintw(17,30, (char *)"%s ", strtok(NULL, ","));
|
|
|
|
mbse_mvprintw(14,45, (char *)"%s ", strtok(NULL, ","));
|
|
|
|
mbse_mvprintw(15,45, (char *)"%s ", strtok(NULL, ","));
|
|
|
|
mbse_mvprintw(16,45, (char *)"%s ", strtok(NULL, ","));
|
|
|
|
mbse_mvprintw(17,45, (char *)"%s ", strtok(NULL, ","));
|
|
|
|
mbse_mvprintw(7,72, "%s", atoi(strtok(NULL, ",")) == 1?"Yes":"No ");
|
|
|
|
mbse_mvprintw(8,72, "%s", atoi(strtok(NULL, ",")) == 1?"Yes":"No ");
|
|
|
|
mbse_mvprintw(9,72, "%s", atoi(strtok(NULL, ",")) == 1?"Yes":"No ");
|
|
|
|
mbse_mvprintw(10,72,"%s", atoi(strtok(NULL, ",")) == 1?"Yes":"No ");
|
|
|
|
mbse_mvprintw(11,72,"%s", atoi(strtok(NULL, ",")) == 1?"Yes":"No ");
|
|
|
|
mbse_mvprintw(12,72, "%s ", strtok(NULL, ","));
|
2005-05-01 09:18:17 +00:00
|
|
|
mbse_mvprintw(19,30, (char *)"%s", strtok(NULL, ","));
|
|
|
|
mbse_mvprintw(14,72, (char *)"%s ", strtok(NULL, ","));
|
|
|
|
mbse_mvprintw(15,72, (char *)"%s ", strtok(NULL, ","));
|
|
|
|
mbse_mvprintw(16,72, (char *)"%s ", strtok(NULL, ";"));
|
2004-03-20 16:09:35 +00:00
|
|
|
}
|
|
|
|
|
2004-03-20 21:12:06 +00:00
|
|
|
switch (enoughspace(CFG.freespace)) {
|
2004-10-27 11:08:09 +00:00
|
|
|
case 0: mbse_mvprintw(13, 72, "Full ");
|
2004-03-20 16:09:35 +00:00
|
|
|
break;
|
2004-10-27 11:08:09 +00:00
|
|
|
case 1: mbse_mvprintw(13, 72, "Ok ");
|
2004-03-20 16:09:35 +00:00
|
|
|
break;
|
2004-10-27 11:08:09 +00:00
|
|
|
case 2: mbse_mvprintw(13, 72, "N/A ");
|
2004-03-20 16:09:35 +00:00
|
|
|
break;
|
2004-10-27 11:08:09 +00:00
|
|
|
case 3: mbse_mvprintw(13, 72, "Error");
|
2004-03-20 16:09:35 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2005-10-17 14:36:12 +00:00
|
|
|
ch = testkey(rows -3,73);
|
2004-03-20 16:09:35 +00:00
|
|
|
} while (ch == '\0');
|
2001-08-17 05:46:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void disk_stat(void)
|
|
|
|
{
|
2004-03-21 13:40:25 +00:00
|
|
|
int ch, i, ro;
|
2003-12-04 22:07:33 +00:00
|
|
|
char buf[1024], *cnt, *type, *fs, *p, sign;
|
2005-10-11 20:49:41 +00:00
|
|
|
unsigned int last[10], size, used, perc, avail;
|
2001-08-17 05:46:24 +00:00
|
|
|
|
2003-12-04 22:07:33 +00:00
|
|
|
clr_index();
|
|
|
|
set_color(WHITE, BLACK);
|
2004-10-27 11:08:09 +00:00
|
|
|
mbse_mvprintw( 5, 6, "3. FILESYSTEM USAGE");
|
2003-12-04 22:07:33 +00:00
|
|
|
set_color(YELLOW, RED);
|
2004-10-27 11:08:09 +00:00
|
|
|
mbse_mvprintw( 7, 1, " Size MB Free MB Used FS-Type St Mountpoint ");
|
2003-12-04 22:07:33 +00:00
|
|
|
set_color(CYAN, BLACK);
|
2005-10-17 14:36:12 +00:00
|
|
|
mbse_mvprintw(rows - 2, 6, "Press any key");
|
2003-12-04 22:07:33 +00:00
|
|
|
IsDoing("Filesystem Usage");
|
|
|
|
for (i = 0; i < 10; i++)
|
|
|
|
last[i] = 0;
|
2001-08-17 05:46:24 +00:00
|
|
|
|
2003-12-04 22:07:33 +00:00
|
|
|
do {
|
|
|
|
show_date(LIGHTGRAY, BLACK, 0, 0);
|
2001-08-17 05:46:24 +00:00
|
|
|
|
2005-08-28 17:08:03 +00:00
|
|
|
snprintf(buf, 1024, "DGFS:0;");
|
2003-12-04 22:07:33 +00:00
|
|
|
if (socket_send(buf) == 0) {
|
|
|
|
strcpy(buf, socket_receive());
|
|
|
|
set_color(LIGHTGRAY, BLACK);
|
|
|
|
cnt = strtok(buf, ":");
|
|
|
|
cnt = strtok(NULL, ",;");
|
|
|
|
if (atoi(cnt)) {
|
|
|
|
for (i = 0; i < atoi(cnt); i++) {
|
|
|
|
p = strtok(NULL, " ");
|
|
|
|
size = atoi(p);
|
2004-03-20 21:30:11 +00:00
|
|
|
avail = atoi(strtok(NULL, " "));
|
|
|
|
used = size - avail;
|
2003-12-04 22:07:33 +00:00
|
|
|
perc = (used * 100) / size;
|
|
|
|
sign = ' ';
|
|
|
|
fs = strtok(NULL, " ");
|
2004-03-21 13:40:25 +00:00
|
|
|
type = strtok(NULL, " ");
|
|
|
|
ro = atoi(strtok(NULL, ",;"));
|
2003-12-04 22:07:33 +00:00
|
|
|
if (used > last[i])
|
|
|
|
sign = '^';
|
|
|
|
if (used < last[i])
|
|
|
|
sign = 'v';
|
|
|
|
if (last[i] == 0)
|
|
|
|
sign = ' ';
|
|
|
|
last[i] = used;
|
|
|
|
set_color(CYAN, BLACK);
|
2004-10-27 11:08:09 +00:00
|
|
|
mbse_mvprintw(i+8, 1, "%8lu %8lu ", size, avail);
|
2003-12-04 22:07:33 +00:00
|
|
|
set_color(WHITE, BLACK);
|
|
|
|
printf("%c ", sign);
|
2004-03-21 13:40:25 +00:00
|
|
|
if (ro == 0) {
|
2004-03-20 21:30:11 +00:00
|
|
|
if (avail <= CFG.freespace)
|
2003-12-04 22:07:33 +00:00
|
|
|
set_color(LIGHTRED, BLACK);
|
2004-03-20 21:30:11 +00:00
|
|
|
else if (avail <= (CFG.freespace * 4))
|
2003-12-04 22:07:33 +00:00
|
|
|
set_color(YELLOW, BLACK);
|
2004-03-20 21:30:11 +00:00
|
|
|
else
|
|
|
|
set_color(CYAN, BLACK);
|
|
|
|
} else {
|
2004-03-21 13:40:25 +00:00
|
|
|
set_color(GREEN, BLACK);
|
2003-12-04 22:07:33 +00:00
|
|
|
}
|
2005-10-11 20:49:41 +00:00
|
|
|
printf("%3u", perc);
|
2003-12-04 22:07:33 +00:00
|
|
|
putchar('%');
|
|
|
|
set_color(CYAN, BLACK);
|
2004-03-21 13:40:25 +00:00
|
|
|
printf(" %-8s %s %-37s", type, ro ?"RO":"RW", fs);
|
2001-08-17 05:46:24 +00:00
|
|
|
}
|
2004-10-27 11:08:09 +00:00
|
|
|
mbse_locate(i+8, 1);
|
2003-12-04 22:07:33 +00:00
|
|
|
clrtoeol();
|
|
|
|
}
|
|
|
|
}
|
2001-08-17 05:46:24 +00:00
|
|
|
|
2005-10-17 14:36:12 +00:00
|
|
|
ch = testkey(rows - 2, 20);
|
2003-12-04 22:07:33 +00:00
|
|
|
} while (ch == '\0');
|
2001-08-17 05:46:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void soft_info(void)
|
|
|
|
{
|
2003-10-03 19:48:15 +00:00
|
|
|
char temp[81], *p;
|
2001-11-02 22:34:32 +00:00
|
|
|
|
2001-08-17 05:46:24 +00:00
|
|
|
clr_index();
|
|
|
|
set_color(YELLOW, BLACK);
|
2005-01-07 21:46:24 +00:00
|
|
|
|
|
|
|
#if defined(__linux__)
|
2003-10-03 19:48:15 +00:00
|
|
|
p = xstrcpy((char *)"MBSE BBS (GNU/Linux");
|
2005-01-07 21:46:24 +00:00
|
|
|
#elif defined(__FreeBSD__)
|
2003-10-03 19:48:15 +00:00
|
|
|
p = xstrcpy((char *)"MBSE BBS (FreeBSD");
|
2005-01-07 21:46:24 +00:00
|
|
|
#elif defined(__NetBSD__)
|
2003-10-03 19:48:15 +00:00
|
|
|
p = xstrcpy((char *)"MBSE BBS (NetBSD");
|
2005-01-07 21:46:24 +00:00
|
|
|
#elif defined(__OpenBSD__)
|
2004-12-28 15:30:52 +00:00
|
|
|
p = xstrcpy((char *)"MBSE BBS (OpenBSD");
|
2001-08-25 19:53:11 +00:00
|
|
|
#else
|
2005-01-07 21:46:24 +00:00
|
|
|
#error "Unknown OS"
|
2001-08-25 19:53:11 +00:00
|
|
|
#endif
|
2005-01-07 21:46:24 +00:00
|
|
|
|
|
|
|
#if defined(__i386__)
|
2003-10-03 19:48:15 +00:00
|
|
|
p = xstrcat(p, (char *)" i386)");
|
2005-01-07 21:46:24 +00:00
|
|
|
#elif defined(__x86_64__)
|
|
|
|
p = xstrcat(p, (char *)" x86-64");
|
|
|
|
#elif defined(__PPC__) || defined(__ppc__)
|
2003-10-03 19:48:15 +00:00
|
|
|
p = xstrcat(p, (char *)" PPC)");
|
2005-01-07 21:46:24 +00:00
|
|
|
#elif defined(__sparc__)
|
2003-10-03 19:48:15 +00:00
|
|
|
p = xstrcat(p, (char *)" Sparc)");
|
2005-01-07 21:46:24 +00:00
|
|
|
#elif defined(__alpha__)
|
2003-10-03 19:48:15 +00:00
|
|
|
p = xstrcat(p, (char *)" Alpha)");
|
2005-01-07 21:46:24 +00:00
|
|
|
#elif defined(__hppa__)
|
2003-10-03 19:48:15 +00:00
|
|
|
p = xstrcat(p, (char *)" HPPA)");
|
|
|
|
#else
|
2005-01-07 21:46:24 +00:00
|
|
|
#error "Unknown CPU"
|
2003-10-03 19:48:15 +00:00
|
|
|
#endif
|
2005-01-07 21:46:24 +00:00
|
|
|
|
2003-10-03 19:48:15 +00:00
|
|
|
center_addstr( 6, p);
|
|
|
|
free(p);
|
2001-08-17 05:46:24 +00:00
|
|
|
set_color(WHITE, BLACK);
|
2001-11-04 16:41:54 +00:00
|
|
|
center_addstr( 8, (char *)COPYRIGHT);
|
2001-08-17 05:46:24 +00:00
|
|
|
set_color(YELLOW, BLACK);
|
2001-11-02 22:34:32 +00:00
|
|
|
center_addstr(10, (char *)"Made in the Netherlands.");
|
|
|
|
set_color(WHITE, BLACK);
|
|
|
|
#ifdef __GLIBC__
|
2005-08-28 17:08:03 +00:00
|
|
|
snprintf(temp, 81, "Compiled on glibc v%d.%d", __GLIBC__, __GLIBC_MINOR__);
|
2001-11-02 22:34:32 +00:00
|
|
|
#else
|
|
|
|
#ifdef __GNU_LIBRARY__
|
2005-08-28 17:08:03 +00:00
|
|
|
snprintf(temp, 81, "Compiled on libc v%d", __GNU_LIBRARY__);
|
2001-11-02 22:34:32 +00:00
|
|
|
#else
|
2005-08-28 17:08:03 +00:00
|
|
|
snprintf(temp, 81, "Compiled on unknown library");
|
2001-11-02 22:34:32 +00:00
|
|
|
#endif
|
|
|
|
#endif
|
|
|
|
center_addstr(12, temp);
|
|
|
|
set_color(LIGHTCYAN, BLACK);
|
2003-09-02 18:29:19 +00:00
|
|
|
center_addstr(14, (char *)"http://www.mbse.dds.nl or 2:280/2802");
|
2001-08-17 05:46:24 +00:00
|
|
|
set_color(LIGHTGREEN, BLACK);
|
2005-10-17 14:36:12 +00:00
|
|
|
center_addstr(rows -7, (char *)"This is free software; released under the terms of the GNU General");
|
|
|
|
center_addstr(rows -6, (char *)"Public License as published by the Free Software Foundation.");
|
2001-08-17 05:46:24 +00:00
|
|
|
set_color(CYAN, BLACK);
|
2005-10-17 14:36:12 +00:00
|
|
|
center_addstr(rows -4, (char *)"Press any key");
|
|
|
|
readkey(rows - 4, cols / 2 + 8, LIGHTGRAY, BLACK);
|
2003-03-23 21:27:14 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
2003-04-03 20:51:19 +00:00
|
|
|
/*
|
|
|
|
* Colorize the chat window
|
|
|
|
*/
|
2006-02-05 13:21:34 +00:00
|
|
|
void Showline(int y, int x, char *msg)
|
2003-04-03 20:51:19 +00:00
|
|
|
{
|
2006-02-04 15:17:11 +00:00
|
|
|
int i, done = FALSE;
|
2003-04-03 20:51:19 +00:00
|
|
|
|
2006-02-05 13:21:34 +00:00
|
|
|
if (strlen(msg)) {
|
2006-03-06 20:30:09 +00:00
|
|
|
mbse_locate(y, x);
|
2003-04-03 20:51:19 +00:00
|
|
|
if (msg[0] == '<') {
|
2004-10-27 11:08:09 +00:00
|
|
|
mbse_colour(LIGHTCYAN, BLACK);
|
2003-04-03 20:51:19 +00:00
|
|
|
putchar('<');
|
2004-10-27 11:08:09 +00:00
|
|
|
mbse_colour(LIGHTBLUE, BLACK);
|
2003-04-03 20:51:19 +00:00
|
|
|
for (i = 1; i < strlen(msg); i++) {
|
2006-02-04 15:17:11 +00:00
|
|
|
if ((msg[i] == '>') && (! done)) {
|
2004-10-27 11:08:09 +00:00
|
|
|
mbse_colour(LIGHTCYAN, BLACK);
|
2003-04-03 20:51:19 +00:00
|
|
|
putchar(msg[i]);
|
2004-10-27 11:08:09 +00:00
|
|
|
mbse_colour(CYAN, BLACK);
|
2006-02-04 15:17:11 +00:00
|
|
|
done = TRUE;
|
2003-04-03 20:51:19 +00:00
|
|
|
} else {
|
|
|
|
putchar(msg[i]);
|
|
|
|
}
|
|
|
|
}
|
2005-04-23 11:14:28 +00:00
|
|
|
} else if (msg[0] == '*') {
|
2006-02-04 15:17:11 +00:00
|
|
|
if (msg[1] == '*') {
|
|
|
|
if (msg[2] == '*')
|
|
|
|
mbse_colour(YELLOW, BLACK);
|
|
|
|
else
|
|
|
|
mbse_colour(LIGHTRED, BLACK);
|
|
|
|
} else {
|
|
|
|
mbse_colour(LIGHTMAGENTA, BLACK);
|
|
|
|
}
|
2006-03-06 20:30:09 +00:00
|
|
|
for (i = 0; i < strlen(msg); i++)
|
|
|
|
putchar(msg[i]);
|
2003-04-03 20:51:19 +00:00
|
|
|
} else {
|
2004-10-27 11:08:09 +00:00
|
|
|
mbse_colour(GREEN, BLACK);
|
2006-03-06 20:30:09 +00:00
|
|
|
for (i = 0; i < strlen(msg); i++)
|
|
|
|
putchar(msg[i]);
|
2003-04-03 20:51:19 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
2003-03-24 19:44:38 +00:00
|
|
|
/*
|
|
|
|
* Display received chat message
|
|
|
|
*/
|
|
|
|
void DispMsg(char *);
|
|
|
|
void DispMsg(char *msg)
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
|
2006-02-04 16:30:00 +00:00
|
|
|
/*
|
|
|
|
* Beep on minor system messages
|
|
|
|
*/
|
|
|
|
if ((msg[0] == '*') && (msg[1] != '*'))
|
|
|
|
putchar('\007');
|
|
|
|
|
2006-02-06 14:23:35 +00:00
|
|
|
strncpy(rbuf[rpointer], msg, 81);
|
2003-04-03 20:51:19 +00:00
|
|
|
Showline(4+rpointer, 1, rbuf[rpointer]);
|
2003-03-24 19:44:38 +00:00
|
|
|
if (rpointer == rsize) {
|
|
|
|
/*
|
|
|
|
* Scroll buffer
|
|
|
|
*/
|
|
|
|
for (i = 0; i <= rsize; i++) {
|
2004-10-27 11:08:09 +00:00
|
|
|
mbse_locate(i+4,1);
|
2003-03-24 19:44:38 +00:00
|
|
|
clrtoeol();
|
2006-03-06 20:30:09 +00:00
|
|
|
strncpy(rbuf[i], rbuf[i+1], 81);
|
|
|
|
// snprintf(rbuf[i], 81, "%s", rbuf[i+1]);
|
2003-04-03 20:51:19 +00:00
|
|
|
Showline(i+4, 1, rbuf[i]);
|
2003-03-24 19:44:38 +00:00
|
|
|
}
|
|
|
|
} else {
|
|
|
|
rpointer++;
|
|
|
|
}
|
2006-02-05 13:21:34 +00:00
|
|
|
|
2003-03-24 19:44:38 +00:00
|
|
|
fflush(stdout);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
2003-03-23 21:27:14 +00:00
|
|
|
/*
|
|
|
|
* Sysop/user chat
|
|
|
|
*/
|
2003-04-02 21:36:47 +00:00
|
|
|
void Chat(int sysop)
|
2003-03-23 21:27:14 +00:00
|
|
|
{
|
2006-02-06 14:23:35 +00:00
|
|
|
int curpos = 0, width, stop = FALSE, data, rc;
|
2003-03-23 21:27:14 +00:00
|
|
|
unsigned char ch = 0;
|
2006-03-06 16:34:26 +00:00
|
|
|
char *p, sbuf[81], resp[128], *sysop_name, *name;
|
2003-03-24 19:44:38 +00:00
|
|
|
static char buf[200];
|
2003-03-23 21:27:14 +00:00
|
|
|
|
|
|
|
clr_index();
|
2005-10-17 14:36:12 +00:00
|
|
|
rsize = rows - 7;
|
2003-03-24 19:44:38 +00:00
|
|
|
rpointer = 0;
|
|
|
|
|
2005-10-17 18:02:00 +00:00
|
|
|
sysop_name = xstrcpy(clencode(CFG.sysop_name));
|
|
|
|
name = xstrcpy(clencode(CFG.sysop));
|
2006-02-06 14:23:35 +00:00
|
|
|
width = cols - (strlen(name) + 3);
|
2005-10-17 18:02:00 +00:00
|
|
|
snprintf(buf, 200, "CCON,4,%d,%s,%s,%s;", mypid, sysop_name, name, sysop ? "1":"0");
|
|
|
|
free(sysop_name);
|
|
|
|
free(name);
|
|
|
|
|
2003-03-24 19:44:38 +00:00
|
|
|
if (socket_send(buf) == 0) {
|
|
|
|
strcpy(buf, socket_receive());
|
2005-09-01 21:06:05 +00:00
|
|
|
if (strncmp(buf, "200:1,", 6) == 0) {
|
2003-03-24 19:44:38 +00:00
|
|
|
set_color(LIGHTRED, BLACK);
|
2005-11-13 21:33:54 +00:00
|
|
|
mbse_mvprintw(4, 1, (char *)"Add \"fido 60179/udp # Chatserver\" to /etc/services");
|
|
|
|
mbse_mvprintw(5, 1, (char *)"Leave mbmon, then restart mbtask and come back here");
|
2003-03-24 19:44:38 +00:00
|
|
|
working(2, 0, 0);
|
|
|
|
working(0, 0, 0);
|
2005-10-17 14:36:12 +00:00
|
|
|
center_addstr(rows -4, (char *)"Press any key");
|
|
|
|
readkey(rows - 4, cols / 2 + 8, LIGHTGRAY, BLACK);
|
2003-03-24 19:44:38 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2005-10-17 14:36:12 +00:00
|
|
|
mbse_locate(rows - 2, 1);
|
2003-03-23 21:27:14 +00:00
|
|
|
set_color(WHITE, BLUE);
|
|
|
|
clrtoeol();
|
2006-02-05 13:21:34 +00:00
|
|
|
mbse_mvprintw(rows - 2, 2, "Chat, type \"/EXIT\" to exit or \"/HELP\" for help");
|
2003-03-23 21:27:14 +00:00
|
|
|
|
2003-04-03 20:51:19 +00:00
|
|
|
set_color(WHITE, BLACK);
|
2005-10-17 14:36:12 +00:00
|
|
|
mbse_mvprintw(rows - 1, 1, ">");
|
2006-02-06 14:23:35 +00:00
|
|
|
mbse_mvprintw(rows - 1, width + 2, "<");
|
2003-03-23 21:27:14 +00:00
|
|
|
memset(&sbuf, 0, sizeof(sbuf));
|
|
|
|
memset(&rbuf, 0, sizeof(rbuf));
|
|
|
|
|
2003-04-02 21:36:47 +00:00
|
|
|
if (sysop) {
|
|
|
|
/*
|
|
|
|
* Join channel #sysop automatic
|
|
|
|
*/
|
2005-08-28 17:08:03 +00:00
|
|
|
snprintf(buf, 200, "CPUT:2,%d,/JOIN #sysop;", mypid);
|
2003-04-02 21:36:47 +00:00
|
|
|
if (socket_send(buf) == 0) {
|
|
|
|
strcpy(buf, socket_receive());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2003-03-24 19:44:38 +00:00
|
|
|
while (stop == FALSE) {
|
2003-03-23 21:27:14 +00:00
|
|
|
|
|
|
|
/*
|
2003-03-24 19:44:38 +00:00
|
|
|
* Check for new message, loop fast until no more data available.
|
2003-03-23 21:27:14 +00:00
|
|
|
*/
|
2003-03-24 19:44:38 +00:00
|
|
|
data = TRUE;
|
|
|
|
while (data) {
|
2005-08-28 17:08:03 +00:00
|
|
|
snprintf(buf, 200, "CGET:1,%d;", mypid);
|
2003-03-24 19:44:38 +00:00
|
|
|
if (socket_send(buf) == 0) {
|
2003-04-03 20:51:19 +00:00
|
|
|
memset(&buf, 0, sizeof(buf));
|
|
|
|
strncpy(buf, socket_receive(), sizeof(buf)-1);
|
2003-04-02 21:36:47 +00:00
|
|
|
if (strncmp(buf, "100:2,", 6) == 0) {
|
2003-03-24 19:44:38 +00:00
|
|
|
strncpy(resp, strtok(buf, ":"), 10); /* Should be 100 */
|
2003-04-02 21:36:47 +00:00
|
|
|
strncpy(resp, strtok(NULL, ","), 5); /* Should be 2 */
|
|
|
|
strncpy(resp, strtok(NULL, ","), 5); /* 1= fatal error */
|
|
|
|
rc = atoi(resp);
|
2003-04-03 20:51:19 +00:00
|
|
|
memset(&resp, 0, sizeof(resp));
|
2006-02-06 14:23:35 +00:00
|
|
|
strncpy(resp, cldecode(strtok(NULL, ";")), 81); /* The message */
|
2003-03-24 19:44:38 +00:00
|
|
|
DispMsg(resp);
|
2003-04-02 21:36:47 +00:00
|
|
|
if (rc == 1) {
|
2006-05-27 13:06:39 +00:00
|
|
|
Syslog('+', "Chat server message: %s", resp);
|
2003-04-02 21:36:47 +00:00
|
|
|
stop = TRUE;
|
|
|
|
data = FALSE;
|
|
|
|
}
|
2003-03-24 19:44:38 +00:00
|
|
|
} else {
|
|
|
|
data = FALSE;
|
2003-03-23 21:27:14 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2003-04-02 21:36:47 +00:00
|
|
|
if (stop)
|
|
|
|
break;
|
|
|
|
|
2003-03-23 21:27:14 +00:00
|
|
|
/*
|
|
|
|
* Update top bars
|
|
|
|
*/
|
|
|
|
show_date(LIGHTGRAY, BLACK, 0, 0);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Check for a pressed key, if so then process it
|
|
|
|
*/
|
2005-10-17 14:36:12 +00:00
|
|
|
ch = testkey(rows -1, curpos + 2);
|
2003-04-03 20:51:19 +00:00
|
|
|
if (isprint(ch)) {
|
|
|
|
set_color(CYAN, BLACK);
|
2006-02-06 14:23:35 +00:00
|
|
|
if (curpos < width) {
|
2003-03-23 21:27:14 +00:00
|
|
|
putchar(ch);
|
|
|
|
fflush(stdout);
|
|
|
|
sbuf[curpos] = ch;
|
|
|
|
curpos++;
|
|
|
|
} else {
|
|
|
|
putchar(7);
|
|
|
|
}
|
|
|
|
} else if ((ch == KEY_BACKSPACE) || (ch == KEY_RUBOUT) || (ch == KEY_DEL)) {
|
2003-04-03 20:51:19 +00:00
|
|
|
set_color(CYAN, BLACK);
|
2003-03-23 21:27:14 +00:00
|
|
|
if (curpos) {
|
|
|
|
curpos--;
|
|
|
|
sbuf[curpos] = '\0';
|
|
|
|
printf("\b \b");
|
|
|
|
} else {
|
|
|
|
putchar(7);
|
|
|
|
}
|
|
|
|
} else if ((ch == '\r') && curpos) {
|
2006-03-06 16:34:26 +00:00
|
|
|
snprintf(buf, 12, "%d", mypid);
|
|
|
|
p = xstrcpy((char *)"CPUT:2,");
|
|
|
|
p = xstrcat(p, buf);
|
|
|
|
p = xstrcat(p, (char *)",");
|
|
|
|
p = xstrcat(p, clencode(sbuf));
|
|
|
|
p = xstrcat(p, (char *)";");
|
|
|
|
strncpy(buf, p, 200);
|
|
|
|
free(p);
|
2003-03-23 21:27:14 +00:00
|
|
|
if (socket_send(buf) == 0) {
|
|
|
|
strcpy(buf, socket_receive());
|
2003-04-02 21:36:47 +00:00
|
|
|
if (strncmp(buf, "100:2,", 6) == 0) {
|
2003-03-24 19:44:38 +00:00
|
|
|
strncpy(resp, strtok(buf, ":"), 10); /* Should be 100 */
|
2003-04-02 21:36:47 +00:00
|
|
|
strncpy(resp, strtok(NULL, ","), 5); /* Should be 2 */
|
|
|
|
strncpy(resp, strtok(NULL, ","), 5); /* 1= fatal error, end chat */
|
|
|
|
rc = atoi(resp);
|
2006-02-06 14:23:35 +00:00
|
|
|
strncpy(resp, cldecode(strtok(NULL, ";")), 81); /* The message */
|
2003-03-24 19:44:38 +00:00
|
|
|
DispMsg(resp);
|
2003-04-02 21:36:47 +00:00
|
|
|
if (rc == 1) {
|
|
|
|
Syslog('+', "Chat server error: %s", resp);
|
|
|
|
stop = TRUE;
|
|
|
|
}
|
2003-03-24 19:44:38 +00:00
|
|
|
}
|
2003-03-23 21:27:14 +00:00
|
|
|
}
|
|
|
|
curpos = 0;
|
|
|
|
memset(&sbuf, 0, sizeof(sbuf));
|
2005-10-17 14:36:12 +00:00
|
|
|
mbse_locate(rows - 1, 2);
|
2003-03-23 21:27:14 +00:00
|
|
|
clrtoeol();
|
2003-04-03 20:51:19 +00:00
|
|
|
set_color(WHITE, BLACK);
|
2005-10-17 14:36:12 +00:00
|
|
|
mbse_mvprintw(rows - 1, 1, ">");
|
2006-02-06 14:23:35 +00:00
|
|
|
mbse_mvprintw(rows - 1, width + 2, "<");
|
2003-03-23 21:27:14 +00:00
|
|
|
}
|
|
|
|
}
|
2003-03-24 19:44:38 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Before sending the close command, purge all outstanding messages.
|
|
|
|
*/
|
|
|
|
data = TRUE;
|
|
|
|
while (data) {
|
2005-08-28 17:08:03 +00:00
|
|
|
snprintf(buf, 200, "CGET:1,%d;", mypid);
|
2003-03-24 19:44:38 +00:00
|
|
|
if (socket_send(buf) == 0) {
|
2003-04-03 20:51:19 +00:00
|
|
|
strncpy(buf, socket_receive(), sizeof(buf)-1);
|
2003-04-02 21:36:47 +00:00
|
|
|
if (strncmp(buf, "100:2,", 6) == 0) {
|
2003-03-24 19:44:38 +00:00
|
|
|
strncpy(resp, strtok(buf, ":"), 10); /* Should be 100 */
|
2003-04-02 21:36:47 +00:00
|
|
|
strncpy(resp, strtok(NULL, ","), 5); /* Should be 2 */
|
|
|
|
strncpy(resp, strtok(NULL, ","), 5); /* 1= fatal error */
|
|
|
|
rc = atoi(resp);
|
2003-04-03 20:51:19 +00:00
|
|
|
memset(&resp, 0, sizeof(resp));
|
2005-10-17 18:02:00 +00:00
|
|
|
strncpy(resp, cldecode(strtok(NULL, ";")), 80); /* The message */
|
2003-03-24 19:44:38 +00:00
|
|
|
DispMsg(resp);
|
2003-04-02 21:36:47 +00:00
|
|
|
if (rc == 1) {
|
|
|
|
Syslog('+', "Chat server error: %s", resp);
|
|
|
|
data = FALSE;
|
|
|
|
}
|
2003-03-24 19:44:38 +00:00
|
|
|
} else {
|
|
|
|
data = FALSE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Close server connection
|
|
|
|
*/
|
2005-08-28 17:08:03 +00:00
|
|
|
snprintf(buf, 200, "CCLO,1,%d;", mypid);
|
2003-03-24 19:44:38 +00:00
|
|
|
if (socket_send(buf) == 0) {
|
|
|
|
strcpy(buf, socket_receive());
|
|
|
|
}
|
|
|
|
sleep(1);
|
2001-08-17 05:46:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
int main(int argc, char *argv[])
|
|
|
|
{
|
2003-03-19 22:45:46 +00:00
|
|
|
struct passwd *pw;
|
2005-10-17 14:36:12 +00:00
|
|
|
struct winsize ws;
|
2004-02-21 17:22:00 +00:00
|
|
|
char buf[128];
|
2004-02-21 15:42:39 +00:00
|
|
|
|
2003-03-24 19:44:38 +00:00
|
|
|
/*
|
2004-02-21 15:42:39 +00:00
|
|
|
* Find out who is on the keyboard or automated the keyboard.
|
2003-03-24 19:44:38 +00:00
|
|
|
*/
|
2004-02-21 15:42:39 +00:00
|
|
|
pw = getpwuid(geteuid());
|
|
|
|
if (strcmp(pw->pw_name, (char *)"mbse")) {
|
|
|
|
printf("ERROR: only user \"mbse\" may use this program\n");
|
|
|
|
exit(MBERR_INIT_ERROR);
|
2003-03-24 19:44:38 +00:00
|
|
|
}
|
|
|
|
|
2003-03-19 22:45:46 +00:00
|
|
|
/*
|
2004-02-21 15:42:39 +00:00
|
|
|
* Read the global configuration data, registrate connection
|
2003-03-19 22:45:46 +00:00
|
|
|
*/
|
2004-02-21 15:42:39 +00:00
|
|
|
InitConfig();
|
|
|
|
InitClient(pw->pw_name, (char *)"mbmon", CFG.location, (char *)"mbmon.log", CFG.util_loglevel, CFG.error_log, CFG.mgrlog, CFG.debuglog);
|
2003-08-03 14:08:07 +00:00
|
|
|
Syslog(' ', "MBMON Started by %s", pw->pw_name);
|
2003-03-19 22:45:46 +00:00
|
|
|
bbs_free = FALSE;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Report sysop available for chat
|
|
|
|
*/
|
2005-08-28 17:08:03 +00:00
|
|
|
snprintf(buf, 128, "CSYS:2,%d,1;", mypid);
|
2003-03-19 22:45:46 +00:00
|
|
|
if (socket_send(buf) == 0)
|
2005-08-28 17:08:03 +00:00
|
|
|
snprintf(buf, 128, "%s", socket_receive());
|
2001-08-17 05:46:24 +00:00
|
|
|
|
2002-05-04 19:45:19 +00:00
|
|
|
|
2003-03-19 22:45:46 +00:00
|
|
|
/*
|
|
|
|
* Setup several signals so when the program terminate's it
|
|
|
|
* will properly close.
|
|
|
|
*/
|
|
|
|
signal(SIGINT, (void (*))die);
|
|
|
|
signal(SIGBUS, (void (*))die);
|
|
|
|
signal(SIGSEGV,(void (*))die);
|
|
|
|
signal(SIGTERM,(void (*))die);
|
|
|
|
signal(SIGKILL,(void (*))die);
|
|
|
|
|
2005-10-17 14:36:12 +00:00
|
|
|
if (ioctl(1, TIOCGWINSZ, &ws) != -1 && (ws.ws_col > 0) && (ws.ws_row > 0)) {
|
|
|
|
rows = ws.ws_row;
|
|
|
|
if (rows < 24) {
|
|
|
|
Syslog('!', "Warning, only %d screen rows, forcing to 24", rows);
|
|
|
|
rows = 24;
|
|
|
|
}
|
2003-03-23 21:27:14 +00:00
|
|
|
}
|
2005-10-17 14:36:12 +00:00
|
|
|
Syslog('+', "Screen size set to %dx%d", cols, rows);
|
2003-03-23 21:27:14 +00:00
|
|
|
|
2003-08-03 14:08:07 +00:00
|
|
|
if (lockprogram((char *)"mbmon")) {
|
|
|
|
printf("\n\7Another mbmon is already running, abort.\n\n");
|
|
|
|
die(MBERR_NO_PROGLOCK);
|
|
|
|
}
|
2003-03-23 21:27:14 +00:00
|
|
|
|
2003-03-19 22:45:46 +00:00
|
|
|
screen_start((char *)"MBmon");
|
|
|
|
|
|
|
|
for (;;) {
|
|
|
|
|
|
|
|
IsDoing("Browsing Menu");
|
|
|
|
clr_index();
|
|
|
|
set_color(WHITE, BLACK);
|
2004-10-27 11:08:09 +00:00
|
|
|
mbse_mvprintw( 5, 6, "0. MBSE BBS MONITOR");
|
2003-03-19 22:45:46 +00:00
|
|
|
set_color(CYAN, BLACK);
|
2004-10-27 11:08:09 +00:00
|
|
|
mbse_mvprintw( 7, 6, "1. View Server Clients");
|
|
|
|
mbse_mvprintw( 8, 6, "2. View Server Statistics");
|
|
|
|
mbse_mvprintw( 9, 6, "3. View Filesystem Usage");
|
|
|
|
mbse_mvprintw(10, 6, "4. View BBS System Information");
|
|
|
|
mbse_mvprintw(11, 6, "5. View BBS Lastcallers List");
|
|
|
|
mbse_mvprintw(12, 6, "6. Chat with any user");
|
|
|
|
mbse_mvprintw(13, 6, "7. Respond to sysop page");
|
|
|
|
mbse_mvprintw(14, 6, "8. View Software Information");
|
2003-03-19 22:45:46 +00:00
|
|
|
|
2003-04-02 21:36:47 +00:00
|
|
|
switch(select_menu(8)) {
|
2003-03-19 22:45:46 +00:00
|
|
|
case 0:
|
|
|
|
die(0);
|
|
|
|
break;
|
|
|
|
case 1:
|
|
|
|
system_moni();
|
|
|
|
break;
|
|
|
|
case 2:
|
|
|
|
system_stat();
|
|
|
|
break;
|
|
|
|
case 3:
|
|
|
|
disk_stat();
|
|
|
|
break;
|
|
|
|
case 4:
|
|
|
|
ShowSysinfo();
|
|
|
|
break;
|
|
|
|
case 5:
|
|
|
|
ShowLastcaller();
|
|
|
|
break;
|
|
|
|
case 6:
|
2003-04-02 21:36:47 +00:00
|
|
|
Chat(FALSE);
|
2003-03-23 21:27:14 +00:00
|
|
|
break;
|
|
|
|
case 7:
|
2003-04-02 21:36:47 +00:00
|
|
|
Chat(TRUE);
|
|
|
|
break;
|
|
|
|
case 8:
|
2003-03-19 22:45:46 +00:00
|
|
|
soft_info();
|
|
|
|
break;
|
2001-08-17 05:46:24 +00:00
|
|
|
}
|
2003-03-19 22:45:46 +00:00
|
|
|
}
|
2001-08-17 05:46:24 +00:00
|
|
|
}
|
|
|
|
|