Added sysop page commands

This commit is contained in:
Michiel Broek 2003-03-20 22:43:40 +00:00
parent 0fc8c478f4
commit 0cf00e1716
18 changed files with 591 additions and 659 deletions

View File

@ -4,6 +4,8 @@ $Id$
menus do not work. menus do not work.
All other users on Intel machines (99,9% I think) can use this version. All other users on Intel machines (99,9% I think) can use this version.
WARNING, sysop chat doesn't work right now.
v0.37.2 23-Feb-2003. v0.37.2 23-Feb-2003.
@ -49,10 +51,14 @@ v0.37.2 23-Feb-2003.
Added email reply when reading new (e)mail. Added email reply when reading new (e)mail.
With the CIPM and CSPM mbtask commands added the parameter for With the CIPM and CSPM mbtask commands added the parameter for
the chat channel. the chat channel.
To page the sysop, the CPAG and CCAN commands to mbtask are now
used.
mbmon: mbmon:
Reports sysop available or left the system when mbmon starts Reports sysop available or left the system when mbmon starts
or stops. or stops.
Reports a page from a user in row 3 of the screen (but doesn't
do chat right now).
mbtask: mbtask:
Safer logging of user log messages. Safer logging of user log messages.
@ -61,9 +67,12 @@ v0.37.2 23-Feb-2003.
In personal message text the text after a ; character is not In personal message text the text after a ; character is not
ignored anymore. ignored anymore.
Added CSYS command to report if sysop is available. Added CSYS command to report if sysop is available.
Added CPAG command to page the sysop.
Added CCAN command to cancel the sysop page.
Added CCKP command to check for a page.
lang: lang:
Changed language prompts 15 and 16. Changed language prompts 15, 16 and 152.
v0.37.1 14-Jan-2003 - 23-Feb-2003 v0.37.1 14-Jan-2003 - 23-Feb-2003

View File

@ -150,9 +150,9 @@
149 newuser.c |User name already exists 149 newuser.c |User name already exists
150 mail.c |Checking your mail box ... 150 mail.c |Checking your mail box ...
151 page.c | MBSE BBS Chat 151 page.c | MBSE BBS Chat
152 page.c |The SysOp is currently speaking to somebody else on 152 page.c |The SysOp is currently speaking to somebody else.
153 page.c |Try paging him again in a few minutes ... 153 page.c |Try paging him again in a few minutes ...
154 page.c ||You have paged the Sysop the maximum times allowed. 154 page.c |You have paged the Sysop the maximum times allowed.
155 page.c |Sysop currently is not available ... please leave a comment 155 page.c |Sysop currently is not available ... please leave a comment
156 mail.c |Posting message in area: 156 mail.c |Posting message in area:
157 mail.c |From : 157 mail.c |From :

View File

@ -150,7 +150,7 @@ JN|berichten, nu de post lezen? [J/n]:
|Gebruikersnaam bestaat al |Gebruikersnaam bestaat al
|Even in Uw postbus kijken ... |Even in Uw postbus kijken ...
| MBSE BBS Kletsen | MBSE BBS Kletsen
|De Sysop is nu even met iemand anders in gesprek op |De Sysop is nu even met iemand anders in gesprek.
|Probeer het opnieuw in enkele minuten ... |Probeer het opnieuw in enkele minuten ...
|U heeft de Sysop meer dan het maximaal aantal keren geroepen. |U heeft de Sysop meer dan het maximaal aantal keren geroepen.
|De Sysop is niet aanwezig ... laat een bericht achter |De Sysop is niet aanwezig ... laat een bericht achter

View File

@ -150,7 +150,7 @@ YN|messages, read your mail now? [Y/n]:
|User name already exists |User name already exists
|Checking your mail box ... |Checking your mail box ...
| MBSE BBS Chat | MBSE BBS Chat
|The SysOp is currently speaking to somebody else on |The SysOp is currently speaking to somebody else.
|Try paging him again in a few minutes ... |Try paging him again in a few minutes ...
|You have paged the Sysop the maximum times allowed. |You have paged the Sysop the maximum times allowed.
|Sysop currently is not available ... please leave a comment |Sysop currently is not available ... please leave a comment

View File

@ -150,7 +150,7 @@ SN|mensaxes,
|O nome xa existe |O nome xa existe
|Buscando correo novo ... |Buscando correo novo ...
| Charla de MBSE BBS | Charla de MBSE BBS
|O Sysop est  falando con outro usuario en |O Sysop est  falando con outro usuario.
|Intenta chamalo de novo dentro de un pouco ... |Intenta chamalo de novo dentro de un pouco ...
|Xa chamacves moitas veces. |Xa chamacves moitas veces.
|O SysOp non est  ... ¨por que non lle deixas unha mensaxe? |O SysOp non est  ... ¨por que non lle deixas unha mensaxe?

View File

@ -150,7 +150,7 @@ JN|Mitteilungen, moechten Sie jetzt Ihre Post lesen? [J/n]:
|Dieser Benutzername existiert bereits |Dieser Benutzername existiert bereits
|Suchen nach persoenlichen Mitteilungen, bitte warten ... |Suchen nach persoenlichen Mitteilungen, bitte warten ...
| MBSE BBS Chat | MBSE BBS Chat
|Der SysOp spricht gerade mit einem anderen User auf |Der SysOp spricht gerade mit einem anderen User.
|Bitte versuchen Sie es in einigen Minuten nochmals ... |Bitte versuchen Sie es in einigen Minuten nochmals ...
|Ihre maximale Anzahl von Sysop-Anrufen ist erreicht. |Ihre maximale Anzahl von Sysop-Anrufen ist erreicht.
|Sysop ist zurzeit nicht erreichbar. Bitte hinterlassen Sie eine Mitteilung... |Sysop ist zurzeit nicht erreichbar. Bitte hinterlassen Sie eine Mitteilung...

View File

@ -150,7 +150,7 @@ SN|nuovi messaggi, vuoi leggere la posta ora? [S/n]:
|Nome utente gia' in uso |Nome utente gia' in uso
|Sto controllando la tua mail box ... |Sto controllando la tua mail box ...
| MBSE BBS Chat | MBSE BBS Chat
|Il SysOp sta parlando con un altro utente su |Il SysOp sta parlando con un altro utente.
|Prova a chiamarlo di nuovo fra pochi minuti ... |Prova a chiamarlo di nuovo fra pochi minuti ...
|Hai gia' chiamato il SysOp per il massimo numero di volte consentito. |Hai gia' chiamato il SysOp per il massimo numero di volte consentito.
|Il SysOp non e' al momento disponibile ... lascia un messaggio |Il SysOp non e' al momento disponibile ... lascia un messaggio

View File

@ -150,7 +150,7 @@ SN|mensajes,
|El nombre ya existe |El nombre ya existe
|Buscando correo nuevo ... |Buscando correo nuevo ...
| Charla de mbsebbs | Charla de mbsebbs
|El Sysop est  hablando con otro usuario en |El Sysop est  hablando con otro usuario.
|Intenta llamarlo de nuevo dentro de un rato ... |Intenta llamarlo de nuevo dentro de un rato ...
|Ya has llamado muchas veces. |Ya has llamado muchas veces.
|El SysOp no est  ... ¨por que no le dejas un mensaje? |El SysOp no est  ... ¨por que no le dejas un mensaje?

View File

@ -369,12 +369,13 @@ void set_color(int f, int b)
static time_t lasttime; static time_t lasttime;
/* /*
* Show the current date & time in the second status row * Show the current date & time in the second status row.
* Show user paging status in third screen row.
*/ */
void show_date(int fg, int bg, int y, int x) void show_date(int fg, int bg, int y, int x)
{ {
time_t now; time_t now;
char *p, buf[128]; char *p, buf[128], *pid, *page, *reason;
now = time(NULL); now = time(NULL);
if (now != lasttime) { if (now != lasttime) {
@ -407,6 +408,36 @@ void show_date(int fg, int bg, int y, int x)
bbs_free = FALSE; bbs_free = FALSE;
} }
/*
* Check paging status
*/
strcpy(buf, SockR("CCKP:0;"));
if (strcmp(buf, "100:0;") == 0) {
locate(3, 1);
set_color(LIGHTGRAY, BLACK);
clrtoeol();
} else {
pid = strtok(buf, ",");
pid = strtok(NULL, ",");
page = strtok(NULL, ",");
reason = strtok(NULL, "\0");
reason[strlen(reason)-1] = '\0';
if (strlen(reason) > 60)
reason[60] = '\0';
locate(3, 1);
if (strcmp(page, "1")) {
set_color(RED, BLACK);
mvprintw(3, 1, " Old page (%s) %-60s", pid, reason);
if ((now % 10) == 0) /* Every 10 seconds */
putchar(7);
} else {
set_color(LIGHTRED, BLACK);
mvprintw(3, 1, " Sysop page (%s) %-60s", pid, reason);
putchar(7); /* Each second */
}
}
if (y && x) if (y && x)
locate(y, x); locate(y, x);
set_color(fg, bg); set_color(fg, bg);
@ -531,7 +562,7 @@ void clr_index()
int i; int i;
set_color(LIGHTGRAY, BLACK); set_color(LIGHTGRAY, BLACK);
for (i = 3; i <= (LINES - 1); i++) { for (i = 4; i <= (LINES - 1); i++) {
locate(i, 1); locate(i, 1);
clrtoeol(); clrtoeol();
} }

View File

@ -10,7 +10,7 @@ SRCS = signature.c filesub.c language.c mbtoberep.c \
bye.c funcs.c mail.c \ bye.c funcs.c mail.c \
newuser.c pinfo.c timecheck.c change.c \ newuser.c pinfo.c timecheck.c change.c \
exitinfo.c mball.c mbsebbs.c menu.c pop3.c lastcallers.c \ exitinfo.c mball.c mbsebbs.c menu.c pop3.c lastcallers.c \
timeout.c chat.c file.c mbchat.c mbstat.c misc.c \ timeout.c chat.c file.c mbstat.c misc.c \
offline.c user.c mbnewusr.c input.c whoson.c \ offline.c user.c mbnewusr.c input.c whoson.c \
door.c dispfile.c userlist.c timestats.c logentry.c door.c dispfile.c userlist.c timestats.c logentry.c
HDRS = signature.h filesub.h language.h mbsebbs.h misc.h offline.h \ HDRS = signature.h filesub.h language.h mbsebbs.h misc.h offline.h \
@ -38,8 +38,6 @@ MBALL_OBJS = mball.o
MBALL_LIBS = ../lib/libmemwatch.a ../lib/libclcomm.a ../lib/libcommon.a ../lib/libdbase.a MBALL_LIBS = ../lib/libmemwatch.a ../lib/libclcomm.a ../lib/libcommon.a ../lib/libdbase.a
MBLANG_OBJS = mblang.o MBLANG_OBJS = mblang.o
MBLANG_LIBS = ../lib/libmemwatch.a ../lib/libclcomm.a ../lib/libcommon.a ../lib/libdbase.a MBLANG_LIBS = ../lib/libmemwatch.a ../lib/libclcomm.a ../lib/libcommon.a ../lib/libdbase.a
MBCHAT_OBJS = mbchat.o
MBCHAT_LIBS = ../lib/libmemwatch.a ../lib/libclcomm.a ../lib/libcommon.a ../lib/libdbase.a
MBSTAT_OBJS = mbstat.o MBSTAT_OBJS = mbstat.o
MBSTAT_LIBS = ../lib/libmemwatch.a ../lib/libclcomm.a ../lib/libcommon.a ../lib/libdbase.a MBSTAT_LIBS = ../lib/libmemwatch.a ../lib/libclcomm.a ../lib/libcommon.a ../lib/libdbase.a
MBTOBE_OBJS = mbtoberep.o MBTOBE_OBJS = mbtoberep.o
@ -47,7 +45,7 @@ MBTOBE_LIBS = ../lib/libmemwatch.a ../lib/libclcomm.a ../lib/libcommon.a ../lib/
MBUSER_OBJS = mbuser.o MBUSER_OBJS = mbuser.o
MBUSER_LIBS = ../lib/libmemwatch.a ../lib/libclcomm.a ../lib/libcommon.a ../lib/libdbase.a MBUSER_LIBS = ../lib/libmemwatch.a ../lib/libclcomm.a ../lib/libcommon.a ../lib/libdbase.a
OTHER = Makefile OTHER = Makefile
TARGET = mbsebbs mbnewusr mball mblang mbchat mbstat mbtoberep mbuser TARGET = mbsebbs mbnewusr mball mblang mbstat mbtoberep mbuser
############################################################################################################# #############################################################################################################
@ -75,10 +73,6 @@ mblang: ${MBLANG_OBJS} ${MBLANG_LIBS}
${CC} -o mblang ${MBLANG_OBJS} ${LIBS} ${MBLANG_LIBS} ${CC} -o mblang ${MBLANG_OBJS} ${LIBS} ${MBLANG_LIBS}
strip mblang strip mblang
mbchat: ${MBCHAT_OBJS} ${MBCHAT_LIBS}
${CC} -o mbchat ${MBCHAT_OBJS} ${LIBS} ${MBCHAT_LIBS}
strip mbchat
mbstat: ${MBSTAT_OBJS} ${MBSTAT_LIBS} mbstat: ${MBSTAT_OBJS} ${MBSTAT_LIBS}
${CC} -o mbstat ${MBSTAT_OBJS} ${LIBS} ${MBSTAT_LIBS} ${CC} -o mbstat ${MBSTAT_OBJS} ${LIBS} ${MBSTAT_LIBS}
strip mbstat strip mbstat
@ -99,11 +93,10 @@ install: all
${INSTALL} -c -s -o ${OWNER} -g ${GROUP} -m 6711 mbnewusr ${BINDIR} ${INSTALL} -c -s -o ${OWNER} -g ${GROUP} -m 6711 mbnewusr ${BINDIR}
${INSTALL} -c -s -o ${OWNER} -g ${GROUP} -m 0711 mball ${BINDIR} ${INSTALL} -c -s -o ${OWNER} -g ${GROUP} -m 0711 mball ${BINDIR}
${INSTALL} -c -s -o ${OWNER} -g ${GROUP} -m 0711 mblang ${BINDIR} ${INSTALL} -c -s -o ${OWNER} -g ${GROUP} -m 0711 mblang ${BINDIR}
${INSTALL} -c -s -o ${OWNER} -g ${GROUP} -m 0711 mbchat ${BINDIR}
${INSTALL} -c -s -o ${OWNER} -g ${GROUP} -m 0711 mbstat ${BINDIR} ${INSTALL} -c -s -o ${OWNER} -g ${GROUP} -m 0711 mbstat ${BINDIR}
${INSTALL} -c -s -o ${OWNER} -g ${GROUP} -m 0711 mbtoberep ${BINDIR} ${INSTALL} -c -s -o ${OWNER} -g ${GROUP} -m 0711 mbtoberep ${BINDIR}
${INSTALL} -c -s -o `id -un` -g `id -gn` -m 6711 mbuser ${BINDIR} ${INSTALL} -c -s -o `id -un` -g `id -gn` -m 6711 mbuser ${BINDIR}
@rm -f mbuseradd mbpasswd mblogin @rm -f mbuseradd mbpasswd mblogin mbchat
filelist: Makefile filelist: Makefile
BASE=`pwd`; \ BASE=`pwd`; \
@ -164,7 +157,6 @@ lastcallers.o: ../config.h ../lib/libs.h ../lib/memwatch.h ../lib/mbse.h ../lib/
timeout.o: ../config.h ../lib/libs.h ../lib/memwatch.h ../lib/mbse.h ../lib/structs.h ../lib/users.h ../lib/records.h ../lib/common.h ../lib/clcomm.h ../lib/msg.h timeout.h funcs.h bye.h filesub.h language.h timeout.o: ../config.h ../lib/libs.h ../lib/memwatch.h ../lib/mbse.h ../lib/structs.h ../lib/users.h ../lib/records.h ../lib/common.h ../lib/clcomm.h ../lib/msg.h timeout.h funcs.h bye.h filesub.h language.h
chat.o: ../config.h ../lib/libs.h ../lib/memwatch.h ../lib/mbse.h ../lib/structs.h ../lib/users.h ../lib/records.h ../lib/common.h ../lib/clcomm.h chat.h funcs.h input.h language.h misc.h whoson.h chat.o: ../config.h ../lib/libs.h ../lib/memwatch.h ../lib/mbse.h ../lib/structs.h ../lib/users.h ../lib/records.h ../lib/common.h ../lib/clcomm.h chat.h funcs.h input.h language.h misc.h whoson.h
file.o: ../config.h ../lib/libs.h ../lib/memwatch.h ../lib/mbse.h ../lib/structs.h ../lib/users.h ../lib/records.h ../lib/common.h ../lib/clcomm.h filesub.h file.h funcs.h input.h language.h misc.h timeout.h exitinfo.h whoson.h change.h file.o: ../config.h ../lib/libs.h ../lib/memwatch.h ../lib/mbse.h ../lib/structs.h ../lib/users.h ../lib/records.h ../lib/common.h ../lib/clcomm.h filesub.h file.h funcs.h input.h language.h misc.h timeout.h exitinfo.h whoson.h change.h
mbchat.o: ../config.h ../lib/libs.h ../lib/memwatch.h ../lib/structs.h ../lib/common.h ../lib/clcomm.h ../lib/mberrors.h
mbstat.o: ../config.h ../lib/libs.h ../lib/memwatch.h ../lib/structs.h ../lib/users.h ../lib/records.h ../lib/common.h ../lib/clcomm.h ../lib/dbcfg.h ../lib/mberrors.h mbstat.h mbstat.o: ../config.h ../lib/libs.h ../lib/memwatch.h ../lib/structs.h ../lib/users.h ../lib/records.h ../lib/common.h ../lib/clcomm.h ../lib/dbcfg.h ../lib/mberrors.h mbstat.h
misc.o: ../config.h ../lib/libs.h ../lib/memwatch.h ../lib/mbse.h ../lib/structs.h ../lib/users.h ../lib/records.h ../lib/clcomm.h ../lib/common.h ../lib/mberrors.h funcs.h input.h language.h misc.h timeout.h exitinfo.h misc.o: ../config.h ../lib/libs.h ../lib/memwatch.h ../lib/mbse.h ../lib/structs.h ../lib/users.h ../lib/records.h ../lib/clcomm.h ../lib/common.h ../lib/mberrors.h funcs.h input.h language.h misc.h timeout.h exitinfo.h
offline.o: ../config.h ../lib/libs.h ../lib/memwatch.h ../lib/structs.h ../lib/mbse.h ../lib/users.h ../lib/records.h ../lib/bluewave.h ../lib/common.h ../lib/clcomm.h ../lib/msgtext.h ../lib/msg.h mail.h funcs.h input.h language.h file.h filesub.h exitinfo.h timeout.h msgutil.h pop3.h offline.h whoson.h offline.o: ../config.h ../lib/libs.h ../lib/memwatch.h ../lib/structs.h ../lib/mbse.h ../lib/users.h ../lib/records.h ../lib/bluewave.h ../lib/common.h ../lib/clcomm.h ../lib/msgtext.h ../lib/msg.h mail.h funcs.h input.h language.h file.h filesub.h exitinfo.h timeout.h msgutil.h pop3.h offline.h whoson.h

View File

@ -49,9 +49,7 @@
#define DEVICE "/tmp/chatdev" #define DEVICE "/tmp/chatdev"
void Chat(int channel)
void Chat(void)
{ {
FILE *pGetDev, *pLog, *pBusy, *pChat; FILE *pGetDev, *pLog, *pBusy, *pChat;
int ch; int ch;

View File

@ -1,8 +1,8 @@
#ifndef _CHAT_H #ifndef _CHAT_H
#define _CHAT_H #define _CHAT_H
void Chat(void); /* Chat Function */ /* $Id$ */
void Chat(int); /* Chat Function */
#endif #endif

View File

@ -1,259 +0,0 @@
/*****************************************************************************
*
* $Id$
* Purpose ...............: Sysop chat utility.
*
*****************************************************************************
* Copyright (C) 1997-2002
*
* Michiel Broek FIDO: 2:2801/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.
*****************************************************************************/
#include "../config.h"
#include "../lib/libs.h"
#include "../lib/memwatch.h"
#include "../lib/structs.h"
#include "../lib/common.h"
#include "../lib/clcomm.h"
#include "../lib/mberrors.h"
char *ttime2(void); /* Returns current time HH:MM */
struct sysconfig CFG;
int main(int argc, char **argv)
{
FILE *fp1, *pChatDev, *pPid, *pLog;
FILE *pDataFile;
int ch;
int iLetter = 0;
short ipid;
char *tty;
char *sStr1= (char *)"";
char pid[81];
char pid1[20];
char sTTY[10];
char *sLog= (char *)"";
char *Config, *FileName, *LogName;
char *BBSpath;
#ifdef MEMWATCH
mwInit();
#endif
FileName = calloc(PATH_MAX, sizeof(char));
Config = calloc(PATH_MAX, sizeof(char));
LogName = calloc(PATH_MAX, sizeof(char));
if ((BBSpath = getenv("MBSE_ROOT")) == NULL) {
printf("Could not get MBSE_ROOT environment variable\n");
printf("Please set the environment variable ie:\n\n");
printf("\"MBSE_ROOT=/usr/local/mbse;export MBSE_ROOT\"\n\n");
#ifdef MEMWATCH
mwTerm();
#endif
exit(MBERR_INIT_ERROR);
}
sprintf(FileName, "%s/etc/config.data", BBSpath);
if ((pDataFile = fopen(FileName, "rb")) == NULL) {
perror("\n\nFATAL ERROR: Can't open config.data for reading!!!");
printf("Please run mbsetup to create configuration file.\n");
printf("Or check that your MBSE_ROOT variable is set to the BBS Path!\n");
#ifdef MEMWATCH
mwTerm();
#endif
exit(MBERR_CONFIG_ERROR);
}
fread(&CFG, sizeof(CFG), 1, pDataFile);
fclose(pDataFile);
free(Config);
free(FileName);
if(CFG.iAutoLog)
sLog = calloc(56, sizeof(char));
if(argc != 2) {
printf("\nSCHAT: MBSE BBS %s Sysop chat facilty\n", VERSION);
printf(" %s\n", COPYRIGHT);
printf("\nCommand-line parameters:\n\n");
printf(" %s <device>", *(argv));
printf("\n");
#ifdef MEMWATCH
mwTerm();
#endif
exit(MBERR_COMMANDLINE);
}
printf("\f");
if (strncmp( (tty = *(argv+1)), "/dev/", 5 ) == 0 ) {
tty+=5;
sprintf(pid,"%s/bbs/exitinfo", CFG.bbs_usersdir);
strcpy(sTTY,"");
} else {
sprintf(pid,"%s/bbs/exitinfo", CFG.bbs_usersdir);
strcpy(sTTY,"/dev/");
}
strcat(sTTY, *(argv + 1));
if(( fp1 = fopen(sTTY,"w")) == NULL)
perror("Error");
if(( pPid = fopen(pid,"r")) == NULL) {
printf("\nThere is no user on %s\n", pid);
#ifdef MEMWATCH
mwTerm();
#endif
exit(MBERR_COMMANDLINE);
} else {
fgets(pid1,19,pPid);
fclose(pPid);
}
ipid = atoi(pid1);
if(( pChatDev = fopen("/tmp/chatdev","w")) == NULL)
perror("Can't open file");
else {
sStr1=ttyname(1);
fprintf(pChatDev,"%s", sStr1);
fclose(pChatDev);
}
if(!CFG.iExternalChat || (strlen(CFG.sExternalChat) < 1) || \
(access(CFG.sExternalChat, X_OK) != 0)) {
printf("Users chatting device: %s\n", sTTY);
printf("Wait until the user is ready");
printf("Press ESC to exit chat\n\n");
umask(00000);
chmod("/tmp/chatdev", 00777);
chmod(sStr1, 00777);
sleep(2);
Setraw();
sleep(2);
while (1) {
ch = getc(stdin);
ch &= '\377';
if (ch == '\033')
break;
putchar(ch);
putc(ch, fp1);
if(CFG.iAutoLog) {
if(ch != '\b')
iLetter++; /* Count the letters user presses for logging */
sprintf(sLog, "%s%c", sLog, ch);
}
if (ch == '\n') {
ch = '\r';
putchar(ch);
putc(ch, fp1);
}
if (ch == '\r') {
ch = '\n';
putchar(ch);
putc(ch, fp1);
}
if (ch == '\b') {
ch = ' ';
putchar(ch);
putc(ch, fp1);
ch = '\b';
putchar(ch);
putc(ch, fp1);
if(CFG.iAutoLog)
sLog[--iLetter] = '\0';
}
/* Check if log chat is on and if so log chat to disk */
if(CFG.iAutoLog) {
if(iLetter >= 55 || ch == '\n') {
iLetter = 0;
sprintf(LogName, "%s/log/chat.log", BBSpath);
if(( pLog = fopen(LogName, "a+")) != NULL) {
fflush(pLog);
fprintf(pLog, "%s [%s]: %s\n", CFG.sysop_name, ttime2(), sLog);
fclose(pLog);
strcpy(sLog, "");
} else
perror("\nCan't open chat.log");
}
}
} /* while chatting */
// fprintf(fp1, "The sysop ended the chat, press a key.\n");
} else {
system(CFG.sExternalChat);
printf("\n\n");
}
fclose(fp1);
sleep(2);
Unsetraw();
sleep(2);
unlink("/tmp/chatdev");
unlink("/tmp/.BusyChatting");
fclose(fp1);
printf("Done chatting.\n");
#ifdef MEMWATCH
mwTerm();
#endif
exit(MBERR_OK);
}
/*
* This function returns the date for today, to test against other functions
* HH:MM (HOUR-MINUTE)
*/
char *ttime2()
{
struct tm *l_date; /* Structure for Date */
time_t Time_Now;
static char Ttime2[9];
Time_Now = time(NULL);
l_date = localtime(&Time_Now);
sprintf(Ttime2, "%02d:%02d", l_date->tm_hour,l_date->tm_min);
return(Ttime2);
}

View File

@ -197,7 +197,7 @@ void menu()
* logs in, that .BusyChatting does exist. * logs in, that .BusyChatting does exist.
*/ */
if (CFG.iChatPromptChk && (access("/tmp/chatdev", R_OK) == 0) && (access("/tmp/.BusyChatting", F_OK) != 0)) if (CFG.iChatPromptChk && (access("/tmp/chatdev", R_OK) == 0) && (access("/tmp/.BusyChatting", F_OK) != 0))
Chat(); Chat(0);
/* /*
* Check users timeleft * Check users timeleft

View File

@ -47,19 +47,22 @@
#include "language.h" #include "language.h"
extern pid_t mypid;
/* /*
* Function to Page Sysop * Function to Page Sysop
*/ */
void Page_Sysop(char *String) void Page_Sysop(char *String)
{ {
FILE *pWritingDevice; int i;
int i, iOpenDevice = FALSE; /* Flag to check if you can write to CFG.sChatDevice */
char *Reason, temp[81]; char *Reason, temp[81];
static char buf[128];
Reason = calloc(81, sizeof(char)); Reason = calloc(81, sizeof(char));
clear(); clear();
colour(12, 0); colour(LIGHTRED, BLACK);
/* MBSE BBS Chat */ /* MBSE BBS Chat */
Center((char *) Language(151)); Center((char *) Language(151));
@ -99,24 +102,10 @@ void Page_Sysop(char *String)
Syslog('+', "Chat Reason: %s", temp); Syslog('+', "Chat Reason: %s", temp);
strcpy(Reason, temp); strcpy(Reason, temp);
} else {
sprintf(Reason, "User want's to chat");
} }
// if (access("/tmp/.BusyChatting", F_OK) == 0) {
// if((pBusy = fopen("/tmp/.BusyChatting", "r")) == NULL)
// WriteError("Unable to open BusyChatting file", pTTY);
// else {
// fscanf(pBusy, "%10s", temp);
// fclose(pBusy);
// }
// colour(13, 0);
// printf("%s%s\n", (char *) Language(152), temp);
// pout(10, 0, (char *) Language(153));
// Enter(2);
// Syslog('+', "SysOp was busy chatting to user on %s", temp);
// Pause();
// free(Reason);
// return;
// }
CFG.iMaxPageTimes--; CFG.iMaxPageTimes--;
@ -124,13 +113,17 @@ void Page_Sysop(char *String)
if (!DisplayFile((char *)"maxpage")) { if (!DisplayFile((char *)"maxpage")) {
/* If i is FALSE display hard coded message */ /* If i is FALSE display hard coded message */
Enter(1); Enter(1);
/* You have paged the Sysop the maximum times allowed. */
pout(WHITE, BLACK, (char *) Language(154)); pout(WHITE, BLACK, (char *) Language(154));
Enter(2); Enter(2);
} }
Syslog('!', "Attempted to page Sysop, above maximum page limit."); Syslog('!', "Attempted to page Sysop, above maximum page limit.");
Pause(); Pause();
} else { free(Reason);
return;
}
locate(14, ((80 - strlen(String) ) / 2 - 2)); locate(14, ((80 - strlen(String) ) / 2 - 2));
pout(WHITE, BLACK, (char *)"["); pout(WHITE, BLACK, (char *)"[");
pout(LIGHTGRAY, BLACK, String); pout(LIGHTGRAY, BLACK, String);
@ -145,40 +138,73 @@ void Page_Sysop(char *String)
locate(16, ((80 - CFG.iPageLength) / 2 - 2) + 1); locate(16, ((80 - CFG.iPageLength) / 2 - 2) + 1);
if ((pWritingDevice = fopen(CFG.sChatDevice, "w")) != NULL) { sprintf(buf, "CPAG:2,%d,%s;", mypid, Reason);
fprintf(pWritingDevice, "\n\n\n%s is trying to page you on %s.\n", \ if (socket_send(buf)) {
usrconfig.sUserName, pTTY); Syslog('+', "Failed to send message to mbtask");
fprintf(pWritingDevice, "Type: '%s/bin/schat %s' to talk to him, you have", \
getenv("MBSE_ROOT"), pTTY);
fprintf(pWritingDevice, "\n%d seconds to respond!\n\n", CFG.iPageLength);
fprintf(pWritingDevice, "%s\n", temp);
iOpenDevice = TRUE;
}
colour(LIGHTBLUE, BLACK);
for (i = 0; i < CFG.iPageLength; i++) {
printf("\x07");
/* If there weren't any problems opening the writing device */
if (iOpenDevice) {
fprintf(pWritingDevice, "\x07");
fflush(pWritingDevice);
}
printf("%c", 219);
fflush(stdout);
sleep(1);
if (access("/tmp/chatdev", R_OK) == 0) {
fclose(pWritingDevice);
Chat();
free(Reason); free(Reason);
return; return;
} }
strcpy(buf, socket_receive());
/*
* Check if sysop is busy
*/
if (strcmp(buf, "100:1,1;") == 0) {
/* The SysOp is currently speaking to somebody else */
pout(LIGHTMAGENTA, BLACK, (char *) Language(152));
/* Try paging him again in a few minutes ... */
pout(LIGHTGREEN, BLACK, (char *) Language(153));
Enter(2);
Syslog('+', "SysOp was busy chatting with another user");
Pause();
free(Reason);
return;
} }
if (iOpenDevice) { /*
fclose(pWritingDevice); * Check if sysop is not available
iOpenDevice = 0; */
if (strcmp(buf, "100:1,2;") == 0) {
Syslog('+', "Sysop is not available for chat");
} }
/*
* Check for other errors
*/
if (strcmp(buf, "100:1,3;") == 0) {
colour(LIGHTRED, BLACK);
printf("Internal system error, the sysop is informed");
Enter(2);
Syslog('!', "Got error on page sysop command");
Pause();
free(Reason);
return;
}
if (strcmp(buf, "100:0;") == 0) {
/*
* Page accpeted, wait until sysop responds
*/
colour(LIGHTBLUE, BLACK);
for (i = 0; i < CFG.iPageLength; i++) {
printf("%c", 219);
fflush(stdout);
sleep(1);
// if drop into chat
// Chat();
// free(Reason);
// return;
}
/*
* Cancel page request
*/
sprintf(buf, "CCAN:1,%d", mypid);
socket_send(buf);
strcpy(buf, socket_receive());
}
PageReason(); PageReason();
printf("\n\n\n"); printf("\n\n\n");
Pause(); Pause();
@ -186,7 +212,6 @@ void Page_Sysop(char *String)
SysopComment(Reason); SysopComment(Reason);
else else
SysopComment((char *)"Failed chat"); SysopComment((char *)"Failed chat");
}
free(Reason); free(Reason);
Pause(); Pause();

View File

@ -4,7 +4,7 @@
* Purpose ...............: MBSE BBS Daemon * Purpose ...............: MBSE BBS Daemon
* *
***************************************************************************** *****************************************************************************
* Copyright (C) 1997-2002 * Copyright (C) 1997-2003
* *
* Michiel Broek FIDO: 2:280/2802 * Michiel Broek FIDO: 2:280/2802
* Beekmansbos 10 * Beekmansbos 10
@ -259,11 +259,9 @@ char *exe_cmd(char *in)
* 100:0; * 100:0;
*/ */
if (strncmp(cmd, "CSPM", 4) == 0) { if (strncmp(cmd, "CSPM", 4) == 0) {
if ((result = reg_spm(token))) { if ((result = reg_spm(token)))
sprintf(obuf, "100:1,%d;", result); sprintf(obuf, "100:1,%d;", result);
return obuf; return obuf;
} else
return obuf;
} }
/* /*
@ -276,6 +274,31 @@ char *exe_cmd(char *in)
return obuf; 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. * The G(lobal) commands.
@ -372,14 +395,11 @@ char *exe_cmd(char *in)
*/ */
if (strncmp(cmd, "SBBS", 4) == 0) { if (strncmp(cmd, "SBBS", 4) == 0) {
switch(stat_bbs_stat()) { switch(stat_bbs_stat()) {
case 0: case 0: sprintf(obuf, "100:2,0,The system is open for use;");
sprintf(obuf, "100:2,0,The system is open for use;");
break; break;
case 1: case 1: sprintf(obuf, "100:2,1,The system is closed right now!;");
sprintf(obuf, "100:2,1,The system is closed right now!;");
break; break;
case 2: case 2: sprintf(obuf, "100:2,2,The system is closed for Zone Mail Hour!;");
sprintf(obuf, "100:2,2,The system is closed for Zone Mail Hour!;");
break; break;
} }
return obuf; return obuf;

View File

@ -36,6 +36,7 @@
#include "taskutil.h" #include "taskutil.h"
extern reg_info reginfo[MAXCLIENT]; /* Array with clients */ extern reg_info reginfo[MAXCLIENT]; /* Array with clients */
extern struct sysconfig CFG; /* System config */
static int entrypos = 0; /* Status pointer */ static int entrypos = 0; /* Status pointer */
static int mailers = 0; /* Registered mailers */ static int mailers = 0; /* Registered mailers */
static int sysop_present = 0; /* Sysop present */ static int sysop_present = 0; /* Sysop present */
@ -413,36 +414,41 @@ char *reg_ipm(char *data)
*/ */
int reg_spm(char *data) int reg_spm(char *data)
{ {
char *cnt, *from, *too, *txt; char *cnt, *ch, *from, *too, *txt, *log;
int ch, i; int i;
cnt = strtok(data, ","); cnt = strtok(data, ",");
ch = atoi(strtok(NULL, ",")); ch = strtok(NULL, ",");
from = strtok(NULL, ","); from = strtok(NULL, ",");
too = strtok(NULL, ","); too = strtok(NULL, ",");
txt = strtok(NULL, "\0"); txt = strtok(NULL, "\0");
txt[strlen(txt)-1] = '\0'; txt[strlen(txt)-1] = '\0';
Syslog('-', "SIPM:%s,%d,%s,%s,%s;", cnt, ch, from, too, txt); 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++) { for (i = 0; i < MAXCLIENT; i++) {
/* /*
* Personal messages and sysop/user chat messages. * 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 * If the in and out pointers are the same and the
* message present flag is still set, then this user * message present flag is still set, then this user
* can't get anymore new messages. * can't get anymore new messages.
*/ */
if (reginfo[i].ismsg && (reginfo[i].ptr_in == reginfo[i].ptr_out)) { if (reginfo[i].ismsg && (reginfo[i].ptr_in == reginfo[i].ptr_out)) {
free(log);
return 2; return 2;
} }
/* /*
* If user has the "do not distrurb" flag set, but the sysop ignore's this. * 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; return 1;
} }
@ -457,14 +463,19 @@ int reg_spm(char *data)
reginfo[i].ptr_in = 0; reginfo[i].ptr_in = 0;
reginfo[i].ismsg = TRUE; 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); Syslog('+', "reg_spm: in=%d out=%d ismsg=%d", reginfo[i].ptr_in, reginfo[i].ptr_out, reginfo[i].ismsg);
free(log);
return 0; return 0;
} }
/* /*
* Chat messages, they are send to each user that is chatting in the right channel. * 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)) { if (reginfo[i].ismsg && (reginfo[i].ptr_in == reginfo[i].ptr_out)) {
Syslog('!', "reg_spm: buffer full for %s", reginfo[i].uname); Syslog('!', "reg_spm: buffer full for %s", reginfo[i].uname);
} else { } else {
@ -475,13 +486,19 @@ int reg_spm(char *data)
else else
reginfo[i].ptr_in = 0; reginfo[i].ptr_in = 0;
reginfo[i].ismsg = TRUE; 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, 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); 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 3; // Error
return 0; // Ok return 0; // Ok
} }
@ -564,3 +581,99 @@ char *get_reginfo(int first)
} }
/*
* 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;
}

View File

@ -50,12 +50,15 @@ int reg_nop(char *);
int reg_timer(int, char *); int reg_timer(int, char *);
int reg_tty(char *); int reg_tty(char *);
int reg_user(char *); int reg_user(char *);
int reg_silent(char *); int reg_silent(char *); /* Set/Reset do not disturb */
char *reg_ipm(char *); char *reg_ipm(char *); /* Check for personal/chat msg */
int reg_spm(char *); int reg_spm(char *); /* Send personal/chat message */
char *reg_fre(void); char *reg_fre(void); /* Check if system is free */
char *get_reginfo(int); char *get_reginfo(int); /* Get registration info */
int reg_sysop(char *); 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 #endif