Added sysop page commands
This commit is contained in:
@@ -4,7 +4,7 @@
|
||||
* Purpose ...............: MBSE BBS Daemon
|
||||
*
|
||||
*****************************************************************************
|
||||
* Copyright (C) 1997-2002
|
||||
* Copyright (C) 1997-2003
|
||||
*
|
||||
* Michiel Broek FIDO: 2:280/2802
|
||||
* Beekmansbos 10
|
||||
@@ -241,7 +241,7 @@ char *exe_cmd(char *in)
|
||||
/*
|
||||
* The chat commands
|
||||
*
|
||||
* Used channels: -1 Personal messages between ordinary users.
|
||||
* Used channels: -1 Personal messages between ordinary users.
|
||||
* 0 Sysop/user chat
|
||||
* 1..99 Chatting channels
|
||||
*
|
||||
@@ -259,11 +259,9 @@ char *exe_cmd(char *in)
|
||||
* 100:0;
|
||||
*/
|
||||
if (strncmp(cmd, "CSPM", 4) == 0) {
|
||||
if ((result = reg_spm(token))) {
|
||||
if ((result = reg_spm(token)))
|
||||
sprintf(obuf, "100:1,%d;", result);
|
||||
return obuf;
|
||||
} else
|
||||
return obuf;
|
||||
return obuf;
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -276,6 +274,31 @@ char *exe_cmd(char *in)
|
||||
return obuf;
|
||||
}
|
||||
|
||||
/*
|
||||
* CPAG:2,pid,reason; Page sysop for a chat
|
||||
* 100:1,n; 1=busy, 2=sysop not available, 3=error
|
||||
* 100:0; Ok
|
||||
*/
|
||||
if (strncmp(cmd, "CPAG", 4) == 0) {
|
||||
if ((result = reg_page(token))) {
|
||||
sprintf(obuf, "100:1,%d;", result);
|
||||
Syslog('+', "%s", obuf);
|
||||
}
|
||||
return obuf;
|
||||
}
|
||||
|
||||
/*
|
||||
* CCAN:1,pid; Cancel sysop page
|
||||
* 100:0; Always Ok
|
||||
*/
|
||||
if (strncmp(cmd, "CCAN", 4) == 0) {
|
||||
reg_cancel(token);
|
||||
return obuf;
|
||||
}
|
||||
|
||||
if (strncmp(cmd, "CCKP", 4) == 0) {
|
||||
return reg_checkpage(token);
|
||||
}
|
||||
|
||||
/*
|
||||
* The G(lobal) commands.
|
||||
@@ -364,125 +387,122 @@ char *exe_cmd(char *in)
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* The (S)tatus commands.
|
||||
*
|
||||
* SBBS:0;
|
||||
* 100:2,n,status message;
|
||||
*/
|
||||
if (strncmp(cmd, "SBBS", 4) == 0) {
|
||||
switch(stat_bbs_stat()) {
|
||||
case 0:
|
||||
sprintf(obuf, "100:2,0,The system is open for use;");
|
||||
break;
|
||||
case 1:
|
||||
sprintf(obuf, "100:2,1,The system is closed right now!;");
|
||||
break;
|
||||
case 2:
|
||||
sprintf(obuf, "100:2,2,The system is closed for Zone Mail Hour!;");
|
||||
break;
|
||||
}
|
||||
return obuf;
|
||||
/*
|
||||
* The (S)tatus commands.
|
||||
*
|
||||
* SBBS:0;
|
||||
* 100:2,n,status message;
|
||||
*/
|
||||
if (strncmp(cmd, "SBBS", 4) == 0) {
|
||||
switch(stat_bbs_stat()) {
|
||||
case 0: sprintf(obuf, "100:2,0,The system is open for use;");
|
||||
break;
|
||||
case 1: sprintf(obuf, "100:2,1,The system is closed right now!;");
|
||||
break;
|
||||
case 2: sprintf(obuf, "100:2,2,The system is closed for Zone Mail Hour!;");
|
||||
break;
|
||||
}
|
||||
return obuf;
|
||||
}
|
||||
|
||||
/*
|
||||
* SOPE:0;
|
||||
* 100:0;
|
||||
*/
|
||||
if (strncmp(cmd, "SOPE", 4) == 0) {
|
||||
stat_set_open(1);
|
||||
return obuf;
|
||||
}
|
||||
/*
|
||||
* SOPE:0;
|
||||
* 100:0;
|
||||
*/
|
||||
if (strncmp(cmd, "SOPE", 4) == 0) {
|
||||
stat_set_open(1);
|
||||
return obuf;
|
||||
}
|
||||
|
||||
/*
|
||||
* SCLO:1,message;
|
||||
* 100:0;
|
||||
*/
|
||||
if (strncmp(cmd, "SCLO", 4) == 0) {
|
||||
stat_set_open(0);
|
||||
return obuf;
|
||||
}
|
||||
/*
|
||||
* SCLO:1,message;
|
||||
* 100:0;
|
||||
*/
|
||||
if (strncmp(cmd, "SCLO", 4) == 0) {
|
||||
stat_set_open(0);
|
||||
return obuf;
|
||||
}
|
||||
|
||||
/*
|
||||
* SFRE:0;
|
||||
* 100:1,Running utilities: n Active users: n;
|
||||
* 100:0;
|
||||
* 201:1,16;
|
||||
*/
|
||||
if (strncmp(cmd, "SFRE", 4) == 0) {
|
||||
return reg_fre();
|
||||
}
|
||||
/*
|
||||
* SFRE:0;
|
||||
* 100:1,Running utilities: n Active users: n;
|
||||
* 100:0;
|
||||
* 201:1,16;
|
||||
*/
|
||||
if (strncmp(cmd, "SFRE", 4) == 0) {
|
||||
return reg_fre();
|
||||
}
|
||||
|
||||
/*
|
||||
* SSEQ:0;
|
||||
* 100:1,number;
|
||||
* 200:1,16;
|
||||
*/
|
||||
if (strncmp(cmd, "SSEQ", 4) == 0) {
|
||||
return getseq();
|
||||
}
|
||||
/*
|
||||
* SSEQ:0;
|
||||
* 100:1,number;
|
||||
* 200:1,16;
|
||||
*/
|
||||
if (strncmp(cmd, "SSEQ", 4) == 0) {
|
||||
return getseq();
|
||||
}
|
||||
|
||||
/*
|
||||
* SEST:1,semafore; Get status of semafore
|
||||
* 100:1,n; 1 = set, 0 = not set
|
||||
* 200:1,16;
|
||||
*/
|
||||
if (strncmp(cmd, "SEST", 4) == 0) {
|
||||
return sem_status(token);
|
||||
}
|
||||
/*
|
||||
* SEST:1,semafore; Get status of semafore
|
||||
* 100:1,n; 1 = set, 0 = not set
|
||||
* 200:1,16;
|
||||
*/
|
||||
if (strncmp(cmd, "SEST", 4) == 0) {
|
||||
return sem_status(token);
|
||||
}
|
||||
|
||||
/*
|
||||
* SECR:1,semafore; Set semafore
|
||||
* 100:0;
|
||||
* 200:1,16;
|
||||
*/
|
||||
if (strncmp(cmd, "SECR", 4) == 0) {
|
||||
return sem_create(token);
|
||||
}
|
||||
/*
|
||||
* SECR:1,semafore; Set semafore
|
||||
* 100:0;
|
||||
* 200:1,16;
|
||||
*/
|
||||
if (strncmp(cmd, "SECR", 4) == 0) {
|
||||
return sem_create(token);
|
||||
}
|
||||
|
||||
/*
|
||||
* SERM:1,semafore; Remove semafore
|
||||
* 100:0;
|
||||
* 200:1,16;
|
||||
*/
|
||||
if (strncmp(cmd, "SERM", 4) == 0) {
|
||||
return sem_remove(token);
|
||||
}
|
||||
/*
|
||||
* SERM:1,semafore; Remove semafore
|
||||
* 100:0;
|
||||
* 200:1,16;
|
||||
*/
|
||||
if (strncmp(cmd, "SERM", 4) == 0) {
|
||||
return sem_remove(token);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* If we got this far, there must be an error.
|
||||
*/
|
||||
stat_inc_serr();
|
||||
return ebuf;
|
||||
/*
|
||||
* If we got this far, there must be an error.
|
||||
*/
|
||||
stat_inc_serr();
|
||||
return ebuf;
|
||||
}
|
||||
|
||||
|
||||
|
||||
void do_cmd(char *cmd)
|
||||
{
|
||||
char buf[SS_BUFSIZE];
|
||||
int slen, tries = 0;
|
||||
char buf[SS_BUFSIZE];
|
||||
int slen, tries = 0;
|
||||
|
||||
if (logtrans)
|
||||
Syslog('-', "< %s", cmd);
|
||||
sprintf(buf, "%s", exe_cmd(cmd));
|
||||
if (logtrans)
|
||||
Syslog('-', "> %s", buf);
|
||||
if (logtrans)
|
||||
Syslog('-', "< %s", cmd);
|
||||
sprintf(buf, "%s", exe_cmd(cmd));
|
||||
if (logtrans)
|
||||
Syslog('-', "> %s", buf);
|
||||
|
||||
for (;;) {
|
||||
slen = sendto(sock, buf, strlen(buf), 0, &from, fromlen);
|
||||
if (slen == -1)
|
||||
Syslog('?', "$do_cmd(): sendto error %d %s", tries, from.sun_path);
|
||||
else if (slen != strlen(buf))
|
||||
Syslog('?', "do_cmd(): send %d of %d bytes, try=%d", slen, strlen(buf), tries);
|
||||
else
|
||||
return;
|
||||
tries++;
|
||||
if (tries == 3)
|
||||
return;
|
||||
sleep(1);
|
||||
}
|
||||
for (;;) {
|
||||
slen = sendto(sock, buf, strlen(buf), 0, &from, fromlen);
|
||||
if (slen == -1)
|
||||
Syslog('?', "$do_cmd(): sendto error %d %s", tries, from.sun_path);
|
||||
else if (slen != strlen(buf))
|
||||
Syslog('?', "do_cmd(): send %d of %d bytes, try=%d", slen, strlen(buf), tries);
|
||||
else
|
||||
return;
|
||||
tries++;
|
||||
if (tries == 3)
|
||||
return;
|
||||
sleep(1);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@@ -36,6 +36,7 @@
|
||||
#include "taskutil.h"
|
||||
|
||||
extern reg_info reginfo[MAXCLIENT]; /* Array with clients */
|
||||
extern struct sysconfig CFG; /* System config */
|
||||
static int entrypos = 0; /* Status pointer */
|
||||
static int mailers = 0; /* Registered mailers */
|
||||
static int sysop_present = 0; /* Sysop present */
|
||||
@@ -193,19 +194,19 @@ void reg_check(void)
|
||||
*/
|
||||
int reg_doing(char *data)
|
||||
{
|
||||
char *cnt, *pid, *line;
|
||||
int rec;
|
||||
char *cnt, *pid, *line;
|
||||
int rec;
|
||||
|
||||
cnt = strtok(data, ",");
|
||||
pid = strtok(NULL, ",");
|
||||
line = strtok(NULL, ";");
|
||||
cnt = strtok(data, ",");
|
||||
pid = strtok(NULL, ",");
|
||||
line = strtok(NULL, ";");
|
||||
|
||||
if ((rec = reg_find(pid)) == -1)
|
||||
return -1;
|
||||
if ((rec = reg_find(pid)) == -1)
|
||||
return -1;
|
||||
|
||||
strncpy(reginfo[rec].doing, line, 35);
|
||||
reginfo[rec].lastcon = time(NULL);
|
||||
return 0;
|
||||
strncpy(reginfo[rec].doing, line, 35);
|
||||
reginfo[rec].lastcon = time(NULL);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
@@ -238,16 +239,16 @@ int reg_ip(char *data)
|
||||
*/
|
||||
int reg_nop(char *data)
|
||||
{
|
||||
char *cnt, *pid;
|
||||
int rec;
|
||||
char *cnt, *pid;
|
||||
int rec;
|
||||
|
||||
cnt = strtok(data, ",");
|
||||
pid = strtok(NULL, ";");
|
||||
if ((rec = reg_find(pid)) == -1)
|
||||
return -1;
|
||||
cnt = strtok(data, ",");
|
||||
pid = strtok(NULL, ";");
|
||||
if ((rec = reg_find(pid)) == -1)
|
||||
return -1;
|
||||
|
||||
reginfo[rec].lastcon = time(NULL);
|
||||
return 0;
|
||||
reginfo[rec].lastcon = time(NULL);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
@@ -257,31 +258,31 @@ int reg_nop(char *data)
|
||||
*/
|
||||
int reg_timer(int Set, char *data)
|
||||
{
|
||||
char *pid;
|
||||
int cnt, rec, val;
|
||||
char *pid;
|
||||
int cnt, rec, val;
|
||||
|
||||
cnt = atoi(strtok(data, ","));
|
||||
if (Set) {
|
||||
if (cnt != 2)
|
||||
return -1;
|
||||
pid = strtok(NULL, ",");
|
||||
val = atoi(strtok(NULL, ";"));
|
||||
if (val < 600)
|
||||
val = 600;
|
||||
} else {
|
||||
if (cnt != 1)
|
||||
return -1;
|
||||
pid = strtok(NULL, ";");
|
||||
val = 600;
|
||||
}
|
||||
cnt = atoi(strtok(data, ","));
|
||||
if (Set) {
|
||||
if (cnt != 2)
|
||||
return -1;
|
||||
pid = strtok(NULL, ",");
|
||||
val = atoi(strtok(NULL, ";"));
|
||||
if (val < 600)
|
||||
val = 600;
|
||||
} else {
|
||||
if (cnt != 1)
|
||||
return -1;
|
||||
pid = strtok(NULL, ";");
|
||||
val = 600;
|
||||
}
|
||||
|
||||
if ((rec = reg_find(pid)) == -1)
|
||||
return -1;
|
||||
if ((rec = reg_find(pid)) == -1)
|
||||
return -1;
|
||||
|
||||
reginfo[rec].altime = val;
|
||||
reginfo[rec].lastcon = time(NULL);
|
||||
Syslog('r', "Set timeout value for %d to %d", reginfo[rec].pid, val);
|
||||
return 0;
|
||||
reginfo[rec].altime = val;
|
||||
reginfo[rec].lastcon = time(NULL);
|
||||
Syslog('r', "Set timeout value for %d to %d", reginfo[rec].pid, val);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
@@ -291,19 +292,19 @@ int reg_timer(int Set, char *data)
|
||||
*/
|
||||
int reg_tty(char *data)
|
||||
{
|
||||
char *cnt, *pid, *tty;
|
||||
int rec;
|
||||
char *cnt, *pid, *tty;
|
||||
int rec;
|
||||
|
||||
cnt = strtok(data, ",");
|
||||
pid = strtok(NULL, ",");
|
||||
tty = strtok(NULL, ";");
|
||||
cnt = strtok(data, ",");
|
||||
pid = strtok(NULL, ",");
|
||||
tty = strtok(NULL, ";");
|
||||
|
||||
if ((rec = reg_find(pid)) == -1)
|
||||
return -1;
|
||||
if ((rec = reg_find(pid)) == -1)
|
||||
return -1;
|
||||
|
||||
strncpy((char *)®info[rec].tty, tty, 6);
|
||||
reginfo[rec].lastcon = time(NULL);
|
||||
return 0;
|
||||
strncpy((char *)®info[rec].tty, tty, 6);
|
||||
reginfo[rec].lastcon = time(NULL);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
@@ -313,19 +314,19 @@ int reg_tty(char *data)
|
||||
*/
|
||||
int reg_silent(char *data)
|
||||
{
|
||||
char *cnt, *pid, *line;
|
||||
int rec;
|
||||
char *cnt, *pid, *line;
|
||||
int rec;
|
||||
|
||||
cnt = strtok(data, ",");
|
||||
pid = strtok(NULL, ",");
|
||||
line = strtok(NULL, ";");
|
||||
cnt = strtok(data, ",");
|
||||
pid = strtok(NULL, ",");
|
||||
line = strtok(NULL, ";");
|
||||
|
||||
if ((rec = reg_find(pid)) == -1)
|
||||
return -1;
|
||||
if ((rec = reg_find(pid)) == -1)
|
||||
return -1;
|
||||
|
||||
reginfo[rec].silent = atoi(line);
|
||||
reginfo[rec].lastcon = time(NULL);
|
||||
return 0;
|
||||
reginfo[rec].silent = atoi(line);
|
||||
reginfo[rec].lastcon = time(NULL);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
@@ -335,21 +336,21 @@ int reg_silent(char *data)
|
||||
*/
|
||||
int reg_user(char *data)
|
||||
{
|
||||
char *cnt, *pid, *user, *city;
|
||||
int rec;
|
||||
char *cnt, *pid, *user, *city;
|
||||
int rec;
|
||||
|
||||
cnt = strtok(data, ",");
|
||||
pid = strtok(NULL, ",");
|
||||
user = strtok(NULL, ",");
|
||||
city = strtok(NULL, ";");
|
||||
cnt = strtok(data, ",");
|
||||
pid = strtok(NULL, ",");
|
||||
user = strtok(NULL, ",");
|
||||
city = strtok(NULL, ";");
|
||||
|
||||
if ((rec = reg_find(pid)) == -1)
|
||||
return -1;
|
||||
if ((rec = reg_find(pid)) == -1)
|
||||
return -1;
|
||||
|
||||
strncpy((char *)®info[rec].uname, user, 35);
|
||||
strncpy((char *)®info[rec].city, city, 35);
|
||||
reginfo[rec].lastcon = time(NULL);
|
||||
return 0;
|
||||
strncpy((char *)®info[rec].uname, user, 35);
|
||||
strncpy((char *)®info[rec].city, city, 35);
|
||||
reginfo[rec].lastcon = time(NULL);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
@@ -413,36 +414,41 @@ char *reg_ipm(char *data)
|
||||
*/
|
||||
int reg_spm(char *data)
|
||||
{
|
||||
char *cnt, *from, *too, *txt;
|
||||
int ch, i;
|
||||
char *cnt, *ch, *from, *too, *txt, *log;
|
||||
int i;
|
||||
|
||||
cnt = strtok(data, ",");
|
||||
ch = atoi(strtok(NULL, ","));
|
||||
ch = strtok(NULL, ",");
|
||||
from = strtok(NULL, ",");
|
||||
too = strtok(NULL, ",");
|
||||
txt = strtok(NULL, "\0");
|
||||
txt[strlen(txt)-1] = '\0';
|
||||
|
||||
Syslog('-', "SIPM:%s,%d,%s,%s,%s;", cnt, ch, from, too, txt);
|
||||
|
||||
log = calloc(PATH_MAX, sizeof(char));
|
||||
sprintf(log, "%s/log/%s", getenv("MBSE_ROOT"), CFG.chat_log);
|
||||
|
||||
for (i = 0; i < MAXCLIENT; i++) {
|
||||
/*
|
||||
* Personal messages and sysop/user chat messages.
|
||||
*/
|
||||
if (reginfo[i].pid && (strcasecmp(reginfo[i].uname, too) == 0) && ((ch == -1) || (ch == 0)) && (ch == reginfo[i].channel)) {
|
||||
if (reginfo[i].pid && (strcasecmp(reginfo[i].uname, too) == 0) &&
|
||||
((atoi(ch) == -1) || (atoi(ch) == 0)) && (atoi(ch) == reginfo[i].channel)) {
|
||||
/*
|
||||
* If the in and out pointers are the same and the
|
||||
* message present flag is still set, then this user
|
||||
* can't get anymore new messages.
|
||||
*/
|
||||
if (reginfo[i].ismsg && (reginfo[i].ptr_in == reginfo[i].ptr_out)) {
|
||||
free(log);
|
||||
return 2;
|
||||
}
|
||||
|
||||
/*
|
||||
* If user has the "do not distrurb" flag set, but the sysop ignore's this.
|
||||
*/
|
||||
if (reginfo[i].silent && (ch == -1)) {
|
||||
if (reginfo[i].silent && (atoi(ch) == -1)) {
|
||||
free(log);
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -457,14 +463,19 @@ int reg_spm(char *data)
|
||||
reginfo[i].ptr_in = 0;
|
||||
reginfo[i].ismsg = TRUE;
|
||||
|
||||
if (CFG.iAutoLog && strlen(CFG.chat_log)) {
|
||||
ulog(log, (char *)"+", from, ch, txt);
|
||||
}
|
||||
|
||||
Syslog('+', "reg_spm: in=%d out=%d ismsg=%d", reginfo[i].ptr_in, reginfo[i].ptr_out, reginfo[i].ismsg);
|
||||
free(log);
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* Chat messages, they are send to each user that is chatting in the right channel.
|
||||
*/
|
||||
if (reginfo[i].pid && reginfo[i].chatting && reginfo[i].channel == ch) {
|
||||
if (reginfo[i].pid && reginfo[i].chatting && reginfo[i].channel == atoi(ch)) {
|
||||
if (reginfo[i].ismsg && (reginfo[i].ptr_in == reginfo[i].ptr_out)) {
|
||||
Syslog('!', "reg_spm: buffer full for %s", reginfo[i].uname);
|
||||
} else {
|
||||
@@ -475,13 +486,19 @@ int reg_spm(char *data)
|
||||
else
|
||||
reginfo[i].ptr_in = 0;
|
||||
reginfo[i].ismsg = TRUE;
|
||||
|
||||
if (CFG.iAutoLog && strlen(CFG.chat_log)) {
|
||||
ulog(log, (char *)"+", from, ch, txt);
|
||||
}
|
||||
|
||||
Syslog('+', "reg_spm: user=%s in=%d out=%d ismsg=%d", reginfo[i].uname, reginfo[i].ptr_in,
|
||||
reginfo[i].ptr_out, reginfo[i].ismsg);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ((ch == -1) || (ch == 0))
|
||||
free(log);
|
||||
if ((atoi(ch) == -1) || (atoi(ch) == 0))
|
||||
return 3; // Error
|
||||
return 0; // Ok
|
||||
}
|
||||
@@ -490,37 +507,37 @@ int reg_spm(char *data)
|
||||
|
||||
char *reg_fre(void)
|
||||
{
|
||||
static char buf[80];
|
||||
int i, users = 0, utils = 0;
|
||||
static char buf[80];
|
||||
int i, users = 0, utils = 0;
|
||||
|
||||
buf[0] = '\0';
|
||||
buf[0] = '\0';
|
||||
|
||||
for (i = 1; i < MAXCLIENT; i++) {
|
||||
if (reginfo[i].pid) {
|
||||
if ((!strncmp(reginfo[i].prg, "mbsebbs", 7)) ||
|
||||
(!strncmp(reginfo[i].prg, "mbnewusr", 8)) ||
|
||||
(!strncmp(reginfo[i].prg, "mbftpd", 6)))
|
||||
users++;
|
||||
for (i = 1; i < MAXCLIENT; i++) {
|
||||
if (reginfo[i].pid) {
|
||||
if ((!strncmp(reginfo[i].prg, "mbsebbs", 7)) ||
|
||||
(!strncmp(reginfo[i].prg, "mbnewusr", 8)) ||
|
||||
(!strncmp(reginfo[i].prg, "mbftpd", 6)))
|
||||
users++;
|
||||
|
||||
if ((!strncmp(reginfo[i].prg, "mbfido", 6)) ||
|
||||
(!strncmp(reginfo[i].prg, "mbmail", 6)) ||
|
||||
(!strncmp(reginfo[i].prg, "mball", 5)) ||
|
||||
(!strncmp(reginfo[i].prg, "mbaff", 5)) ||
|
||||
(!strncmp(reginfo[i].prg, "mbcico", 6)) ||
|
||||
(!strncmp(reginfo[i].prg, "mbfile", 6)) ||
|
||||
(!strncmp(reginfo[i].prg, "mbmsg", 5)) ||
|
||||
(!strncmp(reginfo[i].prg, "mbindex", 7)) ||
|
||||
(!strncmp(reginfo[i].prg, "mbdiff", 6)) ||
|
||||
(!strncmp(reginfo[i].prg, "mbuser", 6)))
|
||||
utils++;
|
||||
}
|
||||
if ((!strncmp(reginfo[i].prg, "mbfido", 6)) ||
|
||||
(!strncmp(reginfo[i].prg, "mbmail", 6)) ||
|
||||
(!strncmp(reginfo[i].prg, "mball", 5)) ||
|
||||
(!strncmp(reginfo[i].prg, "mbaff", 5)) ||
|
||||
(!strncmp(reginfo[i].prg, "mbcico", 6)) ||
|
||||
(!strncmp(reginfo[i].prg, "mbfile", 6)) ||
|
||||
(!strncmp(reginfo[i].prg, "mbmsg", 5)) ||
|
||||
(!strncmp(reginfo[i].prg, "mbindex", 7)) ||
|
||||
(!strncmp(reginfo[i].prg, "mbdiff", 6)) ||
|
||||
(!strncmp(reginfo[i].prg, "mbuser", 6)))
|
||||
utils++;
|
||||
}
|
||||
}
|
||||
|
||||
if (users || utils)
|
||||
sprintf(buf, "100:1,Running utilities: %02d Active users: %02d;", utils, users);
|
||||
else
|
||||
sprintf(buf, "100:0;");
|
||||
return buf;
|
||||
if (users || utils)
|
||||
sprintf(buf, "100:1,Running utilities: %02d Active users: %02d;", utils, users);
|
||||
else
|
||||
sprintf(buf, "100:0;");
|
||||
return buf;
|
||||
}
|
||||
|
||||
|
||||
@@ -532,35 +549,131 @@ char *reg_fre(void)
|
||||
*/
|
||||
char *get_reginfo(int first)
|
||||
{
|
||||
static char buf[256];
|
||||
static char buf[256];
|
||||
|
||||
memset(&buf, 0, sizeof(buf));
|
||||
sprintf(buf, "100:0;");
|
||||
memset(&buf, 0, sizeof(buf));
|
||||
sprintf(buf, "100:0;");
|
||||
|
||||
/*
|
||||
* Loop forever until an error occours, eof is reached or
|
||||
* the data is valid. Only in the last case valid data is
|
||||
* returned to the caller.
|
||||
*/
|
||||
for (;;) {
|
||||
if (first == 1)
|
||||
entrypos = 0;
|
||||
else
|
||||
entrypos++;
|
||||
/*
|
||||
* Loop forever until an error occours, eof is reached or
|
||||
* the data is valid. Only in the last case valid data is
|
||||
* returned to the caller.
|
||||
*/
|
||||
for (;;) {
|
||||
if (first == 1)
|
||||
entrypos = 0;
|
||||
else
|
||||
entrypos++;
|
||||
|
||||
if (entrypos == MAXCLIENT)
|
||||
return buf;
|
||||
if (entrypos == MAXCLIENT)
|
||||
return buf;
|
||||
|
||||
if ((int)reginfo[entrypos].pid != 0) {
|
||||
sprintf(buf, "100:7,%d,%s,%s,%s,%s,%s,%d;",
|
||||
if ((int)reginfo[entrypos].pid != 0) {
|
||||
sprintf(buf, "100:7,%d,%s,%s,%s,%s,%s,%d;",
|
||||
reginfo[entrypos].pid, reginfo[entrypos].tty,
|
||||
reginfo[entrypos].uname, reginfo[entrypos].prg,
|
||||
reginfo[entrypos].city, reginfo[entrypos].doing,
|
||||
(int)reginfo[entrypos].started);
|
||||
return buf;
|
||||
}
|
||||
return buf;
|
||||
}
|
||||
/* never reached */
|
||||
}
|
||||
/* never reached */
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* Page sysop for a chat
|
||||
*/
|
||||
int reg_page(char *data)
|
||||
{
|
||||
char *cnt, *pid, *reason;
|
||||
int i, rec;
|
||||
|
||||
cnt = strtok(data, ",");
|
||||
pid = strtok(NULL, ",");
|
||||
reason = strtok(NULL, "\0");
|
||||
reason[strlen(reason)-1] = '\0';
|
||||
|
||||
Syslog('+', "reg_page: pid=%d, reason=\"%s\"", pid, reason);
|
||||
|
||||
if (!sysop_present)
|
||||
return 2;
|
||||
|
||||
/*
|
||||
* Check if another user is pagin the sysop or is already
|
||||
* chatting with the sysop, if so, mark sysop busy.
|
||||
*/
|
||||
for (i = 1; i < MAXCLIENT; i++) {
|
||||
if (reginfo[i].pid && (reginfo[i].pid != atoi(pid)) && (reginfo[i].channel == 0) && (reginfo[i].chatting))
|
||||
return 1;
|
||||
if (reginfo[i].pid && (reginfo[i].pid != atoi(pid)) && (reginfo[i].paging))
|
||||
return 1;
|
||||
}
|
||||
|
||||
if ((rec = reg_find(pid)) == -1)
|
||||
return 3;
|
||||
|
||||
/*
|
||||
* All seems well, accept the page
|
||||
*/
|
||||
reginfo[rec].paging = TRUE;
|
||||
reginfo[rec].channel = 0;
|
||||
strncpy(reginfo[rec].reason, reason, 80);
|
||||
reginfo[rec].lastcon = time(NULL);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* Cancel page sysop for a chat
|
||||
*/
|
||||
int reg_cancel(char *data)
|
||||
{
|
||||
char *cnt, *pid;
|
||||
int rec;
|
||||
|
||||
cnt = strtok(data, ",");
|
||||
pid = strtok(NULL, ";");
|
||||
|
||||
Syslog('+', "reg_cancel: pid=%d", pid);
|
||||
|
||||
if ((rec = reg_find(pid)) == -1)
|
||||
return -1;
|
||||
|
||||
if (reginfo[rec].paging) {
|
||||
reginfo[rec].paging = FALSE;
|
||||
reginfo[rec].haspaged = TRUE;
|
||||
reginfo[rec].channel = -1;
|
||||
}
|
||||
reginfo[rec].lastcon = time(NULL);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* Check paging status for from mbmon
|
||||
*/
|
||||
char *reg_checkpage(char *data)
|
||||
{
|
||||
static char buf[128];
|
||||
int i;
|
||||
|
||||
memset(&buf, 0, sizeof(buf));
|
||||
for (i = 1; i < MAXCLIENT; i++) {
|
||||
if (reginfo[i].pid && reginfo[i].paging) {
|
||||
sprintf(buf, "100:3,%d,1,%s;", reginfo[i].pid, reginfo[i].reason);
|
||||
return buf;
|
||||
}
|
||||
if (reginfo[i].pid && reginfo[i].haspaged) {
|
||||
sprintf(buf, "100:3,%d,0,%s;", reginfo[i].pid, reginfo[i].reason);
|
||||
return buf;
|
||||
}
|
||||
}
|
||||
sprintf(buf, "100:0;");
|
||||
return buf;
|
||||
}
|
||||
|
||||
|
||||
|
@@ -50,12 +50,15 @@ int reg_nop(char *);
|
||||
int reg_timer(int, char *);
|
||||
int reg_tty(char *);
|
||||
int reg_user(char *);
|
||||
int reg_silent(char *);
|
||||
char *reg_ipm(char *);
|
||||
int reg_spm(char *);
|
||||
char *reg_fre(void);
|
||||
char *get_reginfo(int);
|
||||
int reg_sysop(char *);
|
||||
int reg_silent(char *); /* Set/Reset do not disturb */
|
||||
char *reg_ipm(char *); /* Check for personal/chat msg */
|
||||
int reg_spm(char *); /* Send personal/chat message */
|
||||
char *reg_fre(void); /* Check if system is free */
|
||||
char *get_reginfo(int); /* Get registration info */
|
||||
int reg_sysop(char *); /* Registrate sysop presence */
|
||||
int reg_page(char *); /* Page sysop for chat */
|
||||
int reg_cancel(char *); /* Cancel sysop page */
|
||||
char *reg_checkpage(char *); /* Check paging status */
|
||||
|
||||
#endif
|
||||
|
||||
|
Reference in New Issue
Block a user