Changed terminal i/o for the bbs

This commit is contained in:
Michiel Broek 2004-11-03 20:48:45 +00:00
parent fd8eb8b6f3
commit 3fb35f698c
57 changed files with 6202 additions and 4999 deletions

View File

@ -1,8 +1,25 @@
$Id$
!!!! DON'T USE, THIS VERSION HAS LOTS OF BUGS !!!!
v0.71.0 27-Oct-2004
mbsebbs:
In change handle the first character of the name is not
capitalized.
Changed layout of raw directory listing to support long
filenames.
Rewrote terminal i/o.
mbnewusr:
Rewrote terminal i/o.
lang:
Changed width of prompt 261.
examples:
Fixed logo display.
v0.70.0 06-Jun-2004 - 26-Oct-2004.

2
TODO
View File

@ -124,6 +124,8 @@ mbcico:
N: Make workaround for binkp bug in Irex 2.24 upto 2.29
U: See whathappens if we remove FLUSHOUT(), this may give troubles.
mbfile:
L: Update <filespec> <area> <-touch>

Binary file not shown.

View File

@ -2240,13 +2240,13 @@ char *arcname(faddr *, unsigned short, int);
/*
* From rawio.c
*/
void Setraw(void); /* Set raw mode */
void Unsetraw(void); /* Unset raw mode */
unsigned char Getone(void); /* Get one raw character */
long Speed(void); /* Get (locked) tty speed */
int Waitchar(unsigned char *, int); /* Wait n * 10mSec for char */
int Escapechar(unsigned char *); /* Escape sequence test */
unsigned char Readkey(void); /* Read a translated key */
void mbse_Setraw(void); /* Set raw mode */
void mbse_Unsetraw(void); /* Unset raw mode */
unsigned char mbse_Getone(void); /* Get one raw character */
long mbse_Speed(void); /* Get (locked) tty speed */
int mbse_Waitchar(unsigned char *, int); /* Wait n * 10mSec for char */
int mbse_Escapechar(unsigned char *); /* Escape sequence test */
unsigned char mbse_Readkey(void); /* Read a translated key */

View File

@ -38,7 +38,7 @@ int rawset = FALSE;
/*
* Sets raw mode and saves the terminal setup
*/
void Setraw()
void mbse_Setraw()
{
int rc;
@ -72,7 +72,7 @@ void Setraw()
/*
* Unsets raw mode and returns state of terminal
*/
void Unsetraw()
void mbse_Unsetraw()
{
int rc;
@ -95,7 +95,7 @@ void Unsetraw()
* This function is used to get a single character from a user ie for a
* menu option
*/
unsigned char Getone()
unsigned char mbse_Getone()
{
unsigned char c = 0;
@ -103,11 +103,11 @@ unsigned char Getone()
perror("open 8");
exit(MBERR_TTYIO_ERROR);
}
Setraw();
mbse_Setraw();
c = Readkey();
c = mbse_Readkey();
Unsetraw();
mbse_Unsetraw();
close(ttyfd);
return(c);
}
@ -117,7 +117,7 @@ unsigned char Getone()
/*
* Read the (locked) speed from the tty
*/
long Speed(void)
long mbse_Speed(void)
{
speed_t mspeed;
@ -227,7 +227,7 @@ long Speed(void)
/*
* Wait for a character for a maximum of wtime * 10 mSec.
*/
int Waitchar(unsigned char *ch, int wtime)
int mbse_Waitchar(unsigned char *ch, int wtime)
{
int i, rc = -1;
@ -242,7 +242,7 @@ int Waitchar(unsigned char *ch, int wtime)
int Escapechar(unsigned char *ch)
int mbse_Escapechar(unsigned char *ch)
{
int rc;
unsigned char c;
@ -251,7 +251,7 @@ int Escapechar(unsigned char *ch)
* Escape character, if nothing follows within
* 50 mSec, the user really pressed <esc>.
*/
if ((rc = Waitchar(ch, 5)) == -1)
if ((rc = mbse_Waitchar(ch, 5)) == -1)
return rc;
if (*ch == '[') {
@ -259,7 +259,7 @@ int Escapechar(unsigned char *ch)
* Start of CSI sequence. If nothing follows,
* return immediatly.
*/
if ((rc = Waitchar(ch, 5)) == -1)
if ((rc = mbse_Waitchar(ch, 5)) == -1)
return rc;
/*
@ -303,13 +303,13 @@ int Escapechar(unsigned char *ch)
* If for example cursur keys are detected, this function returns
* a translated value.
*/
unsigned char Readkey(void)
unsigned char mbse_Readkey(void)
{
unsigned char ch = 0;
int rc = -1;
while (rc == -1) {
rc = Waitchar(&ch, 5);
rc = mbse_Waitchar(&ch, 5);
/*
* If the character is not an Escape character,
@ -319,7 +319,7 @@ unsigned char Readkey(void)
return ch;
if ((rc == 1) && (ch == KEY_ESCAPE)) {
rc = Escapechar(&ch);
rc = mbse_Escapechar(&ch);
if (rc == 1)
return ch;
else

View File

@ -611,7 +611,7 @@ int main(int argc, char **argv)
mbse_colour(LIGHTGREEN, BLACK);
printf("Are you sure to process all area lists [y/N] ");
fflush(stdout);
x = Getone();
x = mbse_Getone();
printf("\r \r");
fflush(stdout);
if (toupper(x) != 'Y')

View File

@ -47,7 +47,7 @@ unsigned char readkey(int y, int x, int fg, int bg)
perror("open /dev/tty");
exit(MBERR_TTYIO_ERROR);
}
Setraw();
mbse_Setraw();
i = 0;
while (rc == -1) {
@ -56,12 +56,12 @@ unsigned char readkey(int y, int x, int fg, int bg)
mbse_locate(y, x);
fflush(stdout);
rc = Waitchar(&ch, 5);
rc = mbse_Waitchar(&ch, 5);
if ((rc == 1) && (ch != KEY_ESCAPE))
break;
if ((rc == 1) && (ch == KEY_ESCAPE))
rc = Escapechar(&ch);
rc = mbse_Escapechar(&ch);
if (rc == 1)
break;
@ -69,7 +69,7 @@ unsigned char readkey(int y, int x, int fg, int bg)
Nopper();
}
Unsetraw();
mbse_Unsetraw();
close(ttyfd);
return ch;
@ -90,15 +90,15 @@ unsigned char testkey(int y, int x)
perror("open /dev/tty");
exit(MBERR_TTYIO_ERROR);
}
Setraw();
mbse_Setraw();
rc = Waitchar(&ch, 50);
rc = mbse_Waitchar(&ch, 50);
if (rc == 1) {
if (ch == KEY_ESCAPE)
rc = Escapechar(&ch);
rc = mbse_Escapechar(&ch);
}
Unsetraw();
mbse_Unsetraw();
close(ttyfd);
if (rc == 1)

View File

@ -7,7 +7,7 @@ include ../Makefile.global
SRCS = signature.c filesub.c language.c mbtoberep.c \
msgutil.c oneline.c bbslist.c morefile.c \
email.c fsedit.c lineedit.c mblang.c mbuser.c page.c \
bye.c funcs.c mail.c term.c \
bye.c funcs.c mail.c term.c ttyio.c openport.c \
newuser.c pinfo.c timecheck.c change.c \
exitinfo.c mball.c mbsebbs.c menu.c pop3.c lastcallers.c \
timeout.c chat.c file.c mbstat.c misc.c \
@ -16,7 +16,7 @@ SRCS = signature.c filesub.c language.c mbtoberep.c \
HDRS = signature.h filesub.h language.h mbsebbs.h misc.h offline.h \
timeout.h bbslist.h email.h fsedit.h lineedit.h \
mbstat.h msgutil.h oneline.h user.h bye.h morefile.h \
funcs.h mail.h mbuser.h page.h term.h \
funcs.h mail.h mbuser.h page.h term.h ttyio.h openport.h \
change.h exitinfo.h mball.h newuser.h \
pinfo.h chat.h file.h menu.h \
pop3.h timecheck.h mbnewusr.h input.h whoson.h \
@ -26,10 +26,10 @@ MBSEBBS_OBJS = signature.o bbslist.o chat.o file.o funcs.o mail.o menu.o \
bye.o change.o mbsebbs.o timeout.o user.o timecheck.o \
exitinfo.o filesub.o lineedit.o offline.o language.o msgutil.o \
pop3.o email.o input.o whoson.o door.o dispfile.o userlist.o timestats.o \
logentry.o morefile.o lastcallers.o term.o
logentry.o morefile.o lastcallers.o term.o ttyio.o openport.o
MBSEBBS_LIBS = ../lib/libmbse.a ../lib/libmsgbase.a ../lib/libdbase.a ../lib/libmbinet.a ../lib/libnodelist.a
MBNEWUSR_OBJS = mbnewusr.o newuser.o language.o timeout.o dispfile.o oneline.o \
timecheck.o input.o exitinfo.o funcs.o misc.o change.o door.o term.o \
MBNEWUSR_OBJS = mbnewusr.o newuser.o language.o timeout.o dispfile.o oneline.o ttyio.o \
timecheck.o input.o exitinfo.o funcs.o misc.o change.o door.o term.o openport.o \
filesub.o mail.o email.o msgutil.o pop3.o lineedit.o fsedit.o whoson.o
MBNEWUSR_LIBS = ../lib/libmbse.a ../lib/libmsgbase.a ../lib/libdbase.a ../lib/libmbinet.a ../lib/libnodelist.a
MBALL_OBJS = mball.o
@ -118,47 +118,49 @@ depend:
# DO NOT DELETE THIS LINE - MAKE DEPEND RELIES ON IT
# Dependencies generated by make depend
signature.o: ../config.h ../lib/mbselib.h ../lib/mbse.h ../lib/users.h signature.h funcs.h input.h language.h timeout.h term.h
filesub.o: ../config.h ../lib/mbselib.h ../lib/mbse.h ../lib/users.h ../lib/mbsedb.h filesub.h funcs.h language.h input.h misc.h timeout.h exitinfo.h change.h term.h
language.o: ../config.h ../lib/mbselib.h ../lib/mbse.h ../lib/users.h input.h language.h term.h
signature.o: ../config.h ../lib/mbselib.h ../lib/mbse.h ../lib/users.h signature.h funcs.h input.h language.h timeout.h term.h ttyio.h
filesub.o: ../config.h ../lib/mbselib.h ../lib/mbse.h ../lib/users.h ../lib/mbsedb.h filesub.h funcs.h language.h input.h misc.h timeout.h exitinfo.h change.h term.h ttyio.h
language.o: ../config.h ../lib/mbselib.h ../lib/mbse.h ../lib/users.h input.h language.h term.h ttyio.h
mbtoberep.o: ../config.h ../lib/mbselib.h
msgutil.o: ../config.h ../lib/mbselib.h ../lib/mbse.h ../lib/users.h ../lib/msgtext.h ../lib/msg.h oneline.h msgutil.h
oneline.o: ../config.h ../lib/mbselib.h ../lib/mbse.h ../lib/users.h oneline.h funcs.h input.h language.h term.h
oneline.o: ../config.h ../lib/mbselib.h ../lib/mbse.h ../lib/users.h oneline.h funcs.h input.h language.h term.h ttyio.h
bbslist.o: ../config.h ../lib/mbselib.h ../lib/mbse.h ../lib/users.h bbslist.h funcs.h input.h language.h term.h
morefile.o: ../config.h ../lib/mbselib.h ../lib/mbse.h ../lib/users.h input.h language.h morefile.h timeout.h
email.o: ../config.h ../lib/mbselib.h ../lib/mbse.h ../lib/users.h ../lib/msgtext.h ../lib/msg.h ../lib/mbinet.h exitinfo.h language.h mail.h timeout.h msgutil.h input.h email.h whoson.h term.h
fsedit.o: ../config.h ../lib/mbselib.h ../lib/mbse.h ../lib/users.h mail.h input.h language.h timeout.h pinfo.h fsedit.h term.h
lineedit.o: ../config.h ../lib/mbselib.h ../lib/mbse.h ../lib/users.h mail.h input.h language.h timeout.h lineedit.h term.h
morefile.o: ../config.h ../lib/mbselib.h ../lib/mbse.h ../lib/users.h input.h language.h morefile.h timeout.h term.h ttyio.h
email.o: ../config.h ../lib/mbselib.h ../lib/mbse.h ../lib/users.h ../lib/msgtext.h ../lib/msg.h ../lib/mbinet.h exitinfo.h language.h mail.h timeout.h msgutil.h input.h email.h whoson.h term.h ttyio.h
fsedit.o: ../config.h ../lib/mbselib.h ../lib/mbse.h ../lib/users.h mail.h input.h language.h timeout.h pinfo.h fsedit.h term.h ttyio.h
lineedit.o: ../config.h ../lib/mbselib.h ../lib/mbse.h ../lib/users.h mail.h input.h language.h timeout.h lineedit.h term.h ttyio.h
mblang.o: ../config.h ../lib/mbselib.h
mbuser.o: ../config.h ../lib/mbselib.h ../lib/users.h ../lib/mbsedb.h mbuser.h
page.o: ../config.h ../lib/mbselib.h ../lib/mbse.h ../lib/users.h dispfile.h input.h chat.h page.h timeout.h mail.h language.h term.h
bye.o: ../config.h ../lib/mbselib.h ../lib/mbse.h ../lib/users.h ../lib/nodelist.h dispfile.h misc.h language.h bye.h term.h
funcs.o: ../config.h ../lib/mbselib.h ../lib/mbse.h ../lib/users.h ../lib/msgtext.h ../lib/msg.h funcs.h
mail.o: ../config.h ../lib/mbselib.h ../lib/mbse.h ../lib/users.h ../lib/nodelist.h ../lib/msgtext.h ../lib/msg.h mail.h funcs.h input.h language.h misc.h timeout.h oneline.h exitinfo.h lineedit.h fsedit.h filesub.h msgutil.h pop3.h email.h door.h whoson.h term.h
term.o: ../config.h ../lib/mbselib.h ../lib/users.h term.h
newuser.o: ../config.h ../lib/mbselib.h ../lib/mbse.h ../lib/users.h funcs.h input.h newuser.h language.h timeout.h change.h dispfile.h term.h
pinfo.o: ../config.h ../lib/mbselib.h ../lib/mbse.h ../lib/users.h pinfo.h input.h term.h
timecheck.o: ../config.h ../lib/mbselib.h ../lib/mbse.h ../lib/users.h timecheck.h funcs.h bye.h exitinfo.h language.h input.h term.h
change.o: ../config.h ../lib/mbselib.h ../lib/mbse.h ../lib/users.h change.h dispfile.h funcs.h input.h language.h misc.h timeout.h exitinfo.h bye.h term.h
page.o: ../config.h ../lib/mbselib.h ../lib/mbse.h ../lib/users.h dispfile.h input.h chat.h page.h timeout.h mail.h language.h term.h ttyio.h
bye.o: ../config.h ../lib/mbselib.h ../lib/mbse.h ../lib/users.h ../lib/nodelist.h dispfile.h misc.h language.h bye.h term.h openport.h ttyio.h
funcs.o: ../config.h ../lib/mbselib.h ../lib/mbse.h ../lib/users.h ../lib/msgtext.h ../lib/msg.h funcs.h term.h ttyio.h
mail.o: ../config.h ../lib/mbselib.h ../lib/mbse.h ../lib/users.h ../lib/nodelist.h ../lib/msgtext.h ../lib/msg.h mail.h funcs.h input.h language.h misc.h timeout.h oneline.h exitinfo.h lineedit.h fsedit.h filesub.h msgutil.h pop3.h email.h door.h whoson.h term.h ttyio.h openport.h
term.o: ../config.h ../lib/mbselib.h ../lib/users.h term.h ttyio.h
ttyio.o: ../config.h ../lib/mbselib.h ttyio.h
openport.o: ../config.h ../lib/mbselib.h ttyio.h openport.h
newuser.o: ../config.h ../lib/mbselib.h ../lib/mbse.h ../lib/users.h funcs.h input.h newuser.h language.h timeout.h change.h dispfile.h term.h ttyio.h openport.h
pinfo.o: ../config.h ../lib/mbselib.h ../lib/mbse.h ../lib/users.h pinfo.h input.h term.h ttyio.h
timecheck.o: ../config.h ../lib/mbselib.h ../lib/mbse.h ../lib/users.h timecheck.h funcs.h bye.h exitinfo.h language.h input.h term.h ttyio.h
change.o: ../config.h ../lib/mbselib.h ../lib/mbse.h ../lib/users.h change.h dispfile.h funcs.h input.h language.h misc.h timeout.h exitinfo.h bye.h term.h ttyio.h
exitinfo.o: ../config.h ../lib/mbselib.h ../lib/mbse.h ../lib/users.h funcs.h input.h language.h oneline.h misc.h bye.h timeout.h timecheck.h exitinfo.h
mball.o: ../config.h ../lib/mbselib.h ../lib/mbse.h ../lib/users.h ../lib/mbsedb.h mball.h
mbsebbs.o: ../config.h ../lib/mbselib.h ../lib/mbse.h ../lib/users.h ../lib/msg.h mbsebbs.h user.h dispfile.h language.h menu.h misc.h bye.h timeout.h funcs.h term.h
menu.o: ../config.h ../lib/mbselib.h ../lib/mbse.h ../lib/users.h oneline.h mail.h bbslist.h change.h chat.h file.h funcs.h input.h misc.h timeout.h menu.h page.h pinfo.h bye.h timecheck.h whoson.h language.h offline.h email.h door.h dispfile.h userlist.h timestats.h logentry.h morefile.h lastcallers.h signature.h term.h
pop3.o: ../config.h ../lib/mbselib.h ../lib/mbse.h ../lib/users.h ../lib/mbinet.h ../lib/msgtext.h ../lib/msg.h msgutil.h pop3.h term.h
lastcallers.o: ../config.h ../lib/mbselib.h ../lib/mbse.h ../lib/users.h input.h language.h lastcallers.h term.h
mbsebbs.o: ../config.h ../lib/mbselib.h ../lib/mbse.h ../lib/users.h ../lib/msg.h mbsebbs.h user.h dispfile.h language.h menu.h misc.h bye.h timeout.h funcs.h term.h ttyio.h openport.h
menu.o: ../config.h ../lib/mbselib.h ../lib/mbse.h ../lib/users.h oneline.h mail.h bbslist.h change.h chat.h file.h funcs.h input.h misc.h timeout.h menu.h page.h pinfo.h bye.h timecheck.h whoson.h language.h offline.h email.h door.h dispfile.h userlist.h timestats.h logentry.h morefile.h lastcallers.h signature.h term.h ttyio.h
pop3.o: ../config.h ../lib/mbselib.h ../lib/mbse.h ../lib/users.h ../lib/mbinet.h ../lib/msgtext.h ../lib/msg.h msgutil.h pop3.h term.h ttyio.h
lastcallers.o: ../config.h ../lib/mbselib.h ../lib/mbse.h ../lib/users.h input.h language.h lastcallers.h term.h ttyio.h
timeout.o: ../config.h ../lib/mbselib.h ../lib/mbse.h ../lib/users.h ../lib/msg.h timeout.h funcs.h bye.h filesub.h language.h term.h
chat.o: ../config.h ../lib/mbselib.h ../lib/mbse.h ../lib/users.h chat.h funcs.h input.h language.h misc.h whoson.h term.h
file.o: ../config.h ../lib/mbselib.h ../lib/mbse.h ../lib/users.h ../lib/mbsedb.h filesub.h file.h funcs.h input.h language.h misc.h timeout.h exitinfo.h whoson.h change.h dispfile.h term.h
chat.o: ../config.h ../lib/mbselib.h ../lib/mbse.h ../lib/users.h chat.h funcs.h input.h language.h misc.h whoson.h term.h ttyio.h
file.o: ../config.h ../lib/mbselib.h ../lib/mbse.h ../lib/users.h ../lib/mbsedb.h filesub.h file.h funcs.h input.h language.h misc.h timeout.h exitinfo.h whoson.h change.h dispfile.h term.h ttyio.h openport.h
mbstat.o: ../config.h ../lib/mbselib.h ../lib/users.h ../lib/mbsedb.h mbstat.h
misc.o: ../config.h ../lib/mbselib.h ../lib/mbse.h ../lib/users.h funcs.h input.h language.h misc.h timeout.h exitinfo.h
offline.o: ../config.h ../lib/mbselib.h ../lib/mbse.h ../lib/users.h ../lib/bluewave.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 term.h
user.o: ../config.h ../lib/mbselib.h ../lib/mbse.h ../lib/users.h timeout.h user.h dispfile.h funcs.h input.h misc.h bye.h file.h mail.h change.h menu.h exitinfo.h language.h offline.h email.h term.h
mbnewusr.o: ../config.h ../lib/mbselib.h ../lib/mbse.h ../lib/users.h mbnewusr.h funcs.h input.h language.h misc.h timeout.h newuser.h term.h
input.o: ../config.h ../lib/mbselib.h ../lib/mbse.h ../lib/users.h input.h timeout.h language.h term.h
whoson.o: ../config.h ../lib/mbselib.h ../lib/mbse.h ../lib/users.h input.h language.h exitinfo.h whoson.h term.h
door.o: ../config.h ../lib/mbselib.h ../lib/mbse.h ../lib/users.h language.h input.h timeout.h exitinfo.h whoson.h door.h term.h
dispfile.o: ../config.h ../lib/mbselib.h ../lib/mbse.h ../lib/users.h ../lib/msgtext.h ../lib/msg.h funcs.h language.h oneline.h misc.h timeout.h timecheck.h exitinfo.h mail.h email.h input.h dispfile.h filesub.h term.h
userlist.o: ../config.h ../lib/mbselib.h ../lib/mbse.h ../lib/users.h userlist.h language.h input.h timeout.h term.h
misc.o: ../config.h ../lib/mbselib.h ../lib/mbse.h ../lib/users.h ../lib/msg.h funcs.h input.h language.h misc.h timeout.h exitinfo.h ttyio.h term.h
offline.o: ../config.h ../lib/mbselib.h ../lib/mbse.h ../lib/users.h ../lib/bluewave.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 term.h ttyio.h openport.h
user.o: ../config.h ../lib/mbselib.h ../lib/mbse.h ../lib/users.h timeout.h user.h dispfile.h funcs.h input.h misc.h bye.h file.h mail.h change.h menu.h exitinfo.h language.h offline.h email.h term.h ttyio.h
mbnewusr.o: ../config.h ../lib/mbselib.h ../lib/mbse.h ../lib/users.h mbnewusr.h funcs.h input.h language.h misc.h timeout.h newuser.h term.h ttyio.h openport.h
input.o: ../config.h ../lib/mbselib.h ../lib/mbse.h ../lib/users.h input.h timeout.h language.h term.h ttyio.h
whoson.o: ../config.h ../lib/mbselib.h ../lib/mbse.h ../lib/users.h input.h language.h exitinfo.h whoson.h term.h ttyio.h
door.o: ../config.h ../lib/mbselib.h ../lib/mbse.h ../lib/users.h language.h input.h timeout.h exitinfo.h whoson.h door.h term.h ttyio.h openport.h
dispfile.o: ../config.h ../lib/mbselib.h ../lib/mbse.h ../lib/users.h ../lib/msgtext.h ../lib/msg.h funcs.h language.h oneline.h misc.h timeout.h timecheck.h exitinfo.h mail.h email.h input.h dispfile.h filesub.h term.h ttyio.h
userlist.o: ../config.h ../lib/mbselib.h ../lib/mbse.h ../lib/users.h userlist.h language.h input.h timeout.h term.h ttyio.h
timestats.o: ../config.h ../lib/mbselib.h ../lib/mbse.h ../lib/users.h timestats.h funcs.h language.h input.h exitinfo.h term.h
logentry.o: ../config.h ../lib/mbselib.h ../lib/mbse.h ../lib/users.h logentry.h
# End of generated dependencies

View File

@ -38,12 +38,14 @@
#include "language.h"
#include "bye.h"
#include "term.h"
#include "openport.h"
#include "ttyio.h"
extern pid_t mypid;
extern time_t t_start;
extern char *StartTime;
extern int hanged_up;
int do_mailout = FALSE;
@ -54,6 +56,7 @@ void Good_Bye(int onsig)
char *temp;
long offset;
time_t t_end;
int i;
IsDoing("Hangup");
temp = calloc(PATH_MAX, sizeof(char));
@ -63,7 +66,7 @@ void Good_Bye(int onsig)
* Don't display goodbye screen on SIGHUP and idle timeout.
* With idle timeout this will go into a loop.
*/
if ((onsig != SIGHUP) && (onsig != SIGALRM) && (onsig != MBERR_TIMEOUT))
if ((onsig != SIGHUP) && (onsig != SIGALRM) && (onsig != MBERR_TIMEOUT) && (hanged_up == 0))
DisplayFile((char *)"goodbye");
if (do_mailout)
@ -86,7 +89,7 @@ void Good_Bye(int onsig)
usrconfig.iLastFileArea = iAreaNumber;
/* If time expired, do not say say successful logoff */
if (!iExpired)
if (!iExpired && !hanged_up)
Syslog('+', "User successfully logged off BBS");
usrconfig.iLastMsgArea = iMsgAreaNumber;
@ -102,8 +105,24 @@ void Good_Bye(int onsig)
}
}
/*
* Flush all data to the user, wait 5 seconds to
* be sure the user received all data.
*/
if (! hanged_up) {
colour(LIGHTGRAY, BLACK);
sleep(4);
}
for (i = 0; i < NSIG; i++)
signal(i, SIG_IGN);
cookedport();
hangup();
t_end = time(NULL);
Syslog(' ', "MBSEBBS finished in %s", t_elapsed(t_start, t_end));
sleep(1);
/*
* Start shutting down this session
@ -117,16 +136,6 @@ void Good_Bye(int onsig)
free(temp);
unlink("taglist");
/*
* Flush all data to the user, wait 5 seconds to
* be sure the user received all data.
*/
colour(LIGHTGRAY, BLACK);
fflush(stdout);
fflush(stdin);
sleep(5);
Unsetraw();
Free_Language();
free(pTTY);
if (StartTime)
@ -156,10 +165,11 @@ void Quick_Bye(int onsig)
signal(i, SIG_DFL);
colour(LIGHTGRAY, BLACK);
fflush(stdout);
fflush(stdin);
sleep(3);
cookedport();
hangup();
free(pTTY);
if (StartTime)
free(StartTime);

View File

@ -42,7 +42,7 @@
#include "exitinfo.h"
#include "bye.h"
#include "term.h"
#include "ttyio.h"
int Chg_Language(int NewMode)
{
@ -59,7 +59,8 @@ int Chg_Language(int NewMode)
sprintf(temp, "%s/etc/language.data", getenv("MBSE_ROOT"));
if(( pLang = fopen(temp, "r")) == NULL) {
WriteError("$Can't open %s", temp);
printf("\nFATAL: Can't open language file\n\n");
sprintf(temp, "\nFATAL: Can't open language file\n\n");
PUTSTR(temp);
Pause();
free(temp);
return 0;
@ -68,34 +69,40 @@ int Chg_Language(int NewMode)
colour(CFG.HiliteF, CFG.HiliteB);
/* Select your preferred language */
printf("\n%s\n\n", (char *) Language(378));
sprintf(temp, "\r\n%s\r\n\r\n", (char *) Language(378));
PUTSTR(temp);
iLang = 6;
colour(9,0);
while (fread(&lang, langhdr.recsize, 1, pLang) == 1)
if (lang.Available) {
colour(13, 0);
printf("(%s)", lang.LangKey);
sprintf(temp, "(%s)", lang.LangKey);
PUTSTR(temp);
colour(8,0);
printf(" %c ", 46);
sprintf(temp, " %c ", 46);
PUTSTR(temp);
colour(3,0);
printf("%-29s ", lang.Name);
sprintf(temp, "%-29s ", lang.Name);
PUTSTR(temp);
iLang++;
if ((iLang % 2) == 0)
printf("\n");
if ((iLang % 2) == 0) {
PUTCHAR('\r');
PUTCHAR('\n');
}
}
Enter(1);
colour(CFG.HiliteF, CFG.HiliteB);
/* Select language: */
printf("\n%s", (char *) Language(379));
sprintf(temp, "\n%s", (char *) Language(379));
PUTSTR(temp);
fflush(stdout);
alarm_on();
iLang = toupper(Getone());
iLang = toupper(Readkey());
printf("%c", iLang);
PUTCHAR(iLang);
fseek(pLang, langhdr.hdrsize, 0);
@ -123,7 +130,8 @@ int Chg_Language(int NewMode)
colour(10, 0);
/* Language now set to" */
printf("\n\n%s%s\n\n", (char *) Language(380), lang.Name);
sprintf(temp, "\r\n\r\n%s%s\r\n\r\n", (char *) Language(380), lang.Name);
PUTSTR(temp);
if (!NewMode) {
Syslog('+', "Changed language to %s", lang.Name);
@ -154,7 +162,6 @@ void Chg_Password()
Enter(1);
/* Old password: */
language(15, 0, 120);
fflush(stdout);
colour(CFG.InputColourF, CFG.InputColourB);
Getpass(temp1);
@ -163,7 +170,6 @@ void Chg_Password()
Enter(1);
/* New password: */
language(9, 0, 121);
fflush(stdout);
colour(CFG.InputColourF, CFG.InputColourB);
Getpass(temp1);
if((strlen(temp1)) >= CFG.password_length) {
@ -171,7 +177,6 @@ void Chg_Password()
/* Confirm new password: */
language(9, 0, 122);
colour(CFG.InputColourF, CFG.InputColourB);
fflush(stdout);
Getpass(temp2);
if(( strcmp(temp1,temp2)) != 0) {
/* Passwords do not match! */
@ -179,14 +184,13 @@ void Chg_Password()
language(12, 0, 123);
Enter(1);
} else {
fflush(stdout);
fflush(stdin);
break;
}
} else {
colour(12, 0);
/* Your password must contain at least %d characters! Try again.*/
printf("\n%s%d %s\n\n", (char *) Language(42), CFG.password_length, (char *) Language(43));
sprintf(temp2, "\r\n%s%d %s\r\n\r\n", (char *) Language(42), CFG.password_length, (char *) Language(43));
PUTSTR(temp2);
}
}
@ -275,8 +279,7 @@ void Chg_Handle()
/* Enter a handle (Enter to Quit): */
pout(9, 0, (char *) Language(412));
colour(CFG.InputColourF, CFG.InputColourB);
fflush(stdout);
Getname(temp, 34);
GetstrC(temp, 34);
if ((strcmp(temp, "")) == 0) {
free(Handle);
@ -286,14 +289,14 @@ void Chg_Handle()
strcpy(Handle, tlcap(temp));
if (CheckHandle(Handle) || CheckUnixNames(Handle)) {
pout(12, 0, (char *)"\nThat handle is already been used\n");
pout(12, 0, (char *)"\r\nThat handle is already been used\r\n");
} else if (CheckName(Handle)) {
pout(12, 0, (char *)"\nThat name is already been used\n");
} else if((strcmp(Handle, "sysop")) == 0) {
pout(12, 0, (char *)"\nYou cannot use Sysop as a handle\n");
pout(12, 0, (char *)"\r\nThat name is already been used\r\n");
} else if((strcasecmp(Handle, "sysop")) == 0) {
pout(12, 0, (char *)"\r\nYou cannot use Sysop as a handle\r\n");
} else if(strcmp(temp, "") != 0) {
Setup(exitinfo.sHandle, temp);
pout(10, 0, (char *)"\nHandle Changed!\n\n");
pout(10, 0, (char *)"\r\nHandle Changed!\r\n\r\n");
Syslog('+', "New handle \"%s\"", exitinfo.sHandle);
break;
}
@ -390,6 +393,7 @@ void Chg_FileCheck()
void Chg_FsMsged()
{
int z;
char temp[81];
ReadExitinfo();
Enter(2);
@ -398,7 +402,8 @@ void Chg_FsMsged()
pout(LIGHTMAGENTA, BLACK, (char *)Language(372));
/* Line/Fullscreen/External */
colour(LIGHTCYAN, BLACK);
printf(" %s ", Language(387 + (exitinfo.MsgEditor & 3)));
sprintf(temp, " %s ", Language(387 + (exitinfo.MsgEditor & 3)));
PUTSTR(temp);
/* Editor */
pout(LIGHTMAGENTA, BLACK, (char *)Language(390));
Enter(1);
@ -409,9 +414,8 @@ void Chg_FsMsged()
else
/* Select: 1) Line editor, 2) Fullscreen editor */
pout(WHITE, BLACK, (char *)Language(438));
fflush(stdout);
alarm_on();
z = toupper(Getone());
z = toupper(Readkey());
if (z == Keystroke(373, 0)) {
exitinfo.MsgEditor = LINEEDIT;
@ -430,7 +434,8 @@ void Chg_FsMsged()
pout(LIGHTMAGENTA, BLACK, (char *)Language(372));
/* Line/Fullscreen/External */
colour(LIGHTCYAN, BLACK);
printf(" %s ", Language(387 + (exitinfo.MsgEditor & 3)));
sprintf(temp, " %s ", Language(387 + (exitinfo.MsgEditor & 3)));
PUTSTR(temp);
/* Editor */
pout(LIGHTMAGENTA, BLACK, (char *)Language(390));
@ -472,18 +477,19 @@ void Chg_FsMsgedKeys()
void Chg_Disturb()
{
ReadExitinfo();
colour(10, 0);
Enter(2);
if(exitinfo.DoNotDisturb) {
exitinfo.DoNotDisturb = FALSE;
/* Do not disturb turned OFF */
printf("\n%s\n", (char *) Language(416));
pout(10, 0, (char *) Language(416));
} else {
exitinfo.DoNotDisturb = TRUE;
/* Do not disturb turned ON */
printf("\n%s\n", (char *) Language(417));
pout(10, 0, (char *) Language(417));
}
Enter(2);
Syslog('+', "Do not disturb now %s", exitinfo.DoNotDisturb?"True":"False");
UserSilent(exitinfo.DoNotDisturb);
sleep(2);
@ -504,18 +510,15 @@ void Chg_Location()
Enter(1);
/* Old location: */
pout(15, 0, (char *) Language(73));
colour(9, 0);
printf("%s\n", exitinfo.sLocation);
Enter(1);
pout(9, 0, exitinfo.sLocation);
Enter(2);
/* Please enter your location: */
pout(14, 0, (char *) Language(49));
if(CFG.iCapLocation) {
colour(CFG.InputColourF, CFG.InputColourB);
fflush(stdout);
if (CFG.iCapLocation) {
GetnameNE(temp, 24);
} else {
colour(CFG.InputColourF, CFG.InputColourB);
GetstrC(temp, 80);
}
@ -526,7 +529,8 @@ void Chg_Location()
Enter(1);
/* Please enter a longer location (min */
colour(12, 0);
printf("%s%d)", (char *) Language(74), CFG.CityLen);
sprintf(temp, "%s%d)", (char *) Language(74), CFG.CityLen);
PUTSTR(temp);
Enter(1);
} else {
Setup(exitinfo.sLocation,temp);
@ -556,10 +560,12 @@ void Chg_Address()
pout(WHITE, BLACK, (char *) Language(476));
Enter(1);
colour(LIGHTBLUE, BLACK);
printf("%s\n", exitinfo.address[0]);
printf("%s\n", exitinfo.address[1]);
printf("%s\n", exitinfo.address[2]);
PUTSTR(exitinfo.address[0]);
Enter(1);
PUTSTR(exitinfo.address[1]);
Enter(1);
PUTSTR(exitinfo.address[2]);
Enter(2);
/* Your address, maximum 3 lines (only visible for the sysop): */
pout(YELLOW, BLACK, (char *) Language(474));
Enter(1);
@ -568,7 +574,6 @@ void Chg_Address()
colour(YELLOW, BLACK);
printf("%d: ", i+1);
colour(CFG.InputColourF, CFG.InputColourB);
fflush(stdout);
alarm_on();
GetstrC(temp, 40);
if (strcmp(temp, ""))
@ -633,7 +638,6 @@ void Chg_VoicePhone()
Enter(1);
pout(10, 0, (char *)": ");
colour(CFG.InputColourF, CFG.InputColourB);
fflush(stdout);
GetPhone(temp, 16);
if (strlen(temp) < 6) {
@ -689,17 +693,19 @@ void Chg_DataPhone()
void Chg_News()
{
ReadExitinfo();
Enter(2);
if (exitinfo.ieNEWS) {
exitinfo.ieNEWS = FALSE;
/* News bulletins turned OFF */
printf("\n\n%s\n\n", (char *) Language(79));
pout(10, 0, (char *) Language(79));
} else {
exitinfo.ieNEWS = TRUE;
/* News bulletins turned ON */
printf("\n\n%s\n\n", (char *) Language(78));
pout(10, 0, (char *) Language(78));
}
Enter(2);
Syslog('+', "News bullentins now %s", exitinfo.ieNEWS?"True":"False");
sleep(2);
WriteExitinfo();
@ -714,22 +720,21 @@ void Chg_ScreenLen()
ReadExitinfo();
temp = calloc(81, sizeof(char));
Syslog('+', "Old screenlen %d", exitinfo.iScreenLen);
fflush(stdin);
Enter(1);
/* Please enter your Screen Length? [24]: */
pout(13, 0, (char *) Language(64));
colour(CFG.InputColourF, CFG.InputColourB);
fflush(stdout);
Getnum(temp, 2);
if((strcmp(temp, "")) == 0) {
exitinfo.iScreenLen = 24;
printf("\n%s\n\n", (char *) Language(80));
sprintf(temp, "\r\n%s\r\n\r\n", (char *) Language(80));
} else {
exitinfo.iScreenLen = atoi(temp);
printf("\n%s%d\n\n", (char *) Language(81), exitinfo.iScreenLen);
sprintf(temp, "\r\n%s%d\r\n\r\n", (char *) Language(81), exitinfo.iScreenLen);
}
PUTSTR(temp);
TermInit(exitinfo.GraphMode, 80, exitinfo.iScreenLen);
Syslog('+', "New screenlen %d", exitinfo.iScreenLen);
@ -766,6 +771,7 @@ int Test_DOB(char *DOB)
language(14, 0, 83);
return FALSE;
}
/*
* Split the date into pieces
*/
@ -838,10 +844,8 @@ void Chg_DOB()
void Chg_Protocol()
{
FILE *pProtConfig;
int iProt, iFoundProt = FALSE;
int precno = 0;
char *temp;
char Prot[2];
int iProt, iFoundProt = FALSE, precno = 0;
char *temp, Prot[2];
temp = calloc(PATH_MAX, sizeof(char));
ReadExitinfo();
@ -853,7 +857,9 @@ void Chg_Protocol()
if ((pProtConfig = fopen(temp, "r")) == NULL) {
WriteError("$Can't open %s", temp);
/* Protocol: Can't open protocol file. */
printf("\n%s\n\n", (char *) Language(262));
Enter(1);
PUTSTR((char *) Language(262));
Enter(2);
Pause();
free(temp);
fclose(pProtConfig);
@ -861,29 +867,31 @@ void Chg_Protocol()
}
fread(&PROThdr, sizeof(PROThdr), 1, pProtConfig);
colour(CFG.HiliteF, CFG.HiliteB);
Enter(1);
/* Select your preferred protocol */
printf("\n%s\n\n", (char *) Language(263));
pout(CFG.HiliteF, CFG.HiliteB, (char *) Language(263));
Enter(2);
colour(9,0);
while (fread(&PROT, PROThdr.recsize, 1, pProtConfig) == 1)
if (PROT.Available && Access(exitinfo.Security, PROT.Level))
printf("(%s) %-20s Efficiency %3d %%\n", PROT.ProtKey, PROT.ProtName, PROT.Efficiency);
while (fread(&PROT, PROThdr.recsize, 1, pProtConfig) == 1) {
if (PROT.Available && Access(exitinfo.Security, PROT.Level)) {
sprintf(temp, "(%s) %-20s Efficiency %3d %%\r\n", PROT.ProtKey, PROT.ProtName, PROT.Efficiency);
PUTSTR(temp);
}
}
colour(CFG.HiliteF, CFG.HiliteB);
printf("\n%s", (char *) Language(264));
Enter(1);
pout(CFG.HiliteF, CFG.HiliteB, (char *) Language(264));
fflush(stdout);
alarm_on();
iProt = toupper(Getone());
iProt = toupper(Readkey());
printf("%c", iProt);
PUTCHAR(iProt);
sprintf(Prot, "%c", iProt);
fseek(pProtConfig, PROThdr.hdrsize, 0);
while (fread(&PROT, PROThdr.recsize, 1, pProtConfig) == 1) {
if ((strncmp(PROT.ProtKey, Prot, 1) == 0) &&
PROT.Available && Access(exitinfo.Security, PROT.Level)) {
if ((strncmp(PROT.ProtKey, Prot, 1) == 0) && PROT.Available && Access(exitinfo.Security, PROT.Level)) {
strcpy(sProtName, PROT.ProtName);
strcpy(sProtUp, PROT.ProtUp);
strcpy(sProtDn, PROT.ProtDn);
@ -901,7 +909,7 @@ void Chg_Protocol()
if (iProt == 13) {
free(temp);
return;
} else
} else {
if (!iFoundProt) {
Enter(2);
pout(10, 0, (char *) Language(265));
@ -909,13 +917,16 @@ void Chg_Protocol()
/* Loop for new attempt */
} else {
Setup(exitinfo.sProtocol, sProtName);
colour(10,0);
Enter(1);
/* Protocol now set to: */
printf("\n\n%s%s\n\n", (char *) Language(266), sProtName);
pout(10, 0, (char *) Language(266));
PUTSTR(sProtName);
Enter(2);
Pause();
break;
}
}
}
Syslog('+', "New protocol %s", sProtName);
WriteExitinfo();
@ -936,8 +947,10 @@ void Set_Protocol(char *Protocol)
if(( pProtConfig = fopen(temp, "rb")) == NULL) {
WriteError("$Can't open %s", temp);
Enter(1);
/* Protocol: Can't open protocol file. */
printf("\n%s\n\n", (char *) Language(262));
pout(LIGHTRED, BLACK, (char *) Language(262));
Enter(2);
Pause();
free(temp);
return;
@ -968,16 +981,19 @@ void Set_Protocol(char *Protocol)
void Chg_OLR_ExtInfo()
{
ReadExitinfo();
Enter(2);
if (exitinfo.OL_ExtInfo) {
exitinfo.OL_ExtInfo = FALSE;
/* Offline Reader: Extended Info turned OFF */
printf("\n\n%s\n\n", (char *) Language(16));
pout(GREEN, BLACK, (char *) Language(16));
} else {
exitinfo.OL_ExtInfo = TRUE;
/* Offline Reader: Extended Info turned ON */
printf("\n\n%s\n\n", (char *) Language(15));
pout(GREEN, BLACK, (char *) Language(15));
}
Enter(2);
Syslog('+', "OLR Extended Info now %s", exitinfo.OL_ExtInfo?"True":"False");
sleep(2);
WriteExitinfo();
@ -998,25 +1014,28 @@ void Chg_Charset()
Syslog('+', "Old character set %s", getchrs(exitinfo.Charset));
while(TRUE) {
colour(CFG.HiliteF, CFG.HiliteB);
Enter(1);
/* Select your preferred character set */
printf("\n%s\n\n", (char *) Language(23));
pout(CFG.HiliteF, CFG.HiliteB, (char *) Language(23));
Enter(2);
colour(LIGHTBLUE, BLACK);
for (i = (FTNC_NONE + 1); i <= FTNC_MAXCHARS; i++) {
colour(LIGHTBLUE, BLACK);
printf("%2d ", i);
sprintf(temp, "%2d ", i);
PUTSTR(temp);
colour(LIGHTCYAN, BLACK);
printf("%-9s ", getchrs(i));
sprintf(temp, "%-9s ", getchrs(i));
PUTSTR(temp);
colour(LIGHTMAGENTA, BLACK);
printf("%s\n", getchrsdesc(i));
sprintf(temp, "%s\r\n", getchrsdesc(i));
PUTSTR(temp);
}
colour(CFG.HiliteF, CFG.HiliteB);
Enter(1);
/* Select character set (Enter to Quit): */
printf("\n%s", (char *) Language(24));
pout(CFG.HiliteF, CFG.HiliteB, (char *) Language(24));
fflush(stdout);
Getnum(temp, 2);
if (((strcmp(temp, "")) == 0) && (exitinfo.Charset != FTNC_NONE)) {
@ -1030,10 +1049,13 @@ void Chg_Charset()
exitinfo.Charset = i;
Syslog('+', "New character set %s", getchrs(exitinfo.Charset));
WriteExitinfo();
free(temp);
Enter(2);
colour(LIGHTGREEN, BLACK);
/* Character set now set to: */
printf("\n\n%s%s\n\n", (char *) Language(25), getchrs(i));
sprintf(temp, "%s%s", (char *) Language(25), getchrs(i));
PUTSTR(temp);
free(temp);
Enter(2);
Pause();
return;
}

View File

@ -39,6 +39,7 @@
#include "misc.h"
#include "whoson.h"
#include "term.h"
#include "ttyio.h"
int chat_with_sysop = FALSE; /* Global sysop chat flag */
@ -63,21 +64,12 @@ unsigned char testkey(int y, int x)
Nopper();
locate(y, x);
fflush(stdout);
if ((ttyfd = open("/dev/tty", O_RDWR|O_NONBLOCK)) < 0) {
perror("open /dev/tty");
exit(MBERR_TTYIO_ERROR);
}
Setraw();
rc = Waitchar(&ch, 50);
if (rc == 1) {
if (ch == KEY_ESCAPE)
rc = Escapechar(&ch);
}
Unsetraw();
close(ttyfd);
if (rc == 1)
return ch;
else
@ -97,15 +89,15 @@ void Showline(int y, int x, char *msg)
if (msg[0] == '<') {
locate(y, x);
colour(LIGHTCYAN, BLACK);
putchar('<');
PUTCHAR('<');
colour(LIGHTBLUE, BLACK);
for (i = 1; i < strlen(msg); i++) {
if (msg[i] == '>') {
colour(LIGHTCYAN, BLACK);
putchar(msg[i]);
PUTCHAR(msg[i]);
colour(CYAN, BLACK);
} else {
putchar(msg[i]);
PUTCHAR(msg[i]);
}
}
} else if (msg[0] == '*') {
@ -142,7 +134,6 @@ void DispMsg(char *msg)
} else {
rpointer++;
}
fflush(stdout);
}
@ -152,7 +143,7 @@ void DispMsg(char *msg)
*/
void clrtoeol(void)
{
fprintf(stdout, ANSI_CLREOL);
PUTSTR((char *)ANSI_CLREOL);
}
@ -178,15 +169,14 @@ void Chat(char *username, char *channel)
if (username && channel) {
colour(LIGHTGREEN, BLACK);
PUTCHAR('\007');
/* *** Sysop is starting chat *** */
printf("\007%s\n\r", (char *) Language(59));
fflush(stdout);
pout(LIGHTGREEN, BLACK, (char *) Language(59));
Enter(1);
sleep(1);
printf("\007");
fflush(stdout);
PUTCHAR('\007');
sleep(1);
printf("\007");
fflush(stdout);
PUTCHAR('\007');
Syslog('+', "Sysop chat started");
chat_with_sysop = TRUE;
} else {
@ -200,7 +190,8 @@ void Chat(char *username, char *channel)
locate(1, 1);
colour(WHITE, BLUE);
clrtoeol();
mvprintw(1, 2, "MBSE BBS Chat Server");
sprintf(buf, "%-*s", 79, " MBSE BBS Chat Server");
mvprintw(1, 1, buf);
sprintf(buf, "CCON,3,%d,%s,0;", mypid, exitinfo.Name);
Syslog('c', "> %s", buf);
@ -223,7 +214,8 @@ void Chat(char *username, char *channel)
locate(exitinfo.iScreenLen - 2, 1);
colour(WHITE, BLUE);
clrtoeol();
mvprintw(exitinfo.iScreenLen - 2, 2, "Chat, type \"/EXIT\" to exit");
sprintf(buf, "%-*s", 79, " Chat, type \"/EXIT\" to exit or \"/HELP\" for help");
mvprintw(exitinfo.iScreenLen - 2, 1, buf);
colour(LIGHTGRAY, BLACK);
mvprintw(exitinfo.iScreenLen - 1, 1, ">");
@ -287,21 +279,19 @@ void Chat(char *username, char *channel)
ch = testkey(exitinfo.iScreenLen -1, curpos + 2);
if (isprint(ch)) {
if (curpos < 77) {
putchar(ch);
fflush(stdout);
PUTCHAR(ch);
sbuf[curpos] = ch;
curpos++;
} else {
putchar(7);
fflush(stdout);
PUTCHAR(7);
}
} else if ((ch == KEY_BACKSPACE) || (ch == KEY_RUBOUT) || (ch == KEY_DEL)) {
if (curpos) {
curpos--;
sbuf[curpos] = '\0';
printf("\b \b");
BackErase();
} else {
putchar(7);
PUTCHAR(7);
}
} else if ((ch == '\r') && curpos) {
sprintf(buf, "CPUT:2,%d,%s;", mypid, sbuf);

View File

@ -47,6 +47,7 @@
#include "dispfile.h"
#include "filesub.h"
#include "term.h"
#include "ttyio.h"
/*
@ -100,8 +101,10 @@ void DisplayRules(void)
if ((dp = opendir(CFG.rulesdir)) == NULL) {
WriteError("$Can't open directory %s", CFG.rulesdir);
Enter(1);
/* Can't open directory for listing: */
printf("\n%s\n\n", (char *) Language(290));
pout(LIGHTRED, BLACK, (char *) Language(290));
Enter(2);
Pause();
return;
}
@ -138,9 +141,9 @@ void DisplayRules(void)
} else {
Syslog('+', "Display rules for %s failed, not found", msgs.Tag);
Enter(1);
colour(LIGHTRED, BLACK);
/* No rules found for this area */
printf("\n%s\n\n", (char *) Language(13));
pout(LIGHTRED, BLACK, (char *) Language(13));
Enter(2);
Pause();
}
}
@ -157,7 +160,8 @@ int DisplayTextFile(char *filename)
{
FILE *fp;
char *buf;
int i, x, c, z, lc = 0;
int i, x, z, lc = 0;
unsigned char c;
if ((fp = fopen(filename, "r")) == NULL) {
WriteError("$DisplayTextFile(%s) failed");
@ -172,26 +176,23 @@ int DisplayTextFile(char *filename)
i = strlen(buf);
for (x = 0; x < i; x++) {
c = (*(buf + x));
c = (*(buf + x) & 0xff);
if (isprint(c))
printf("%c", c);
PUTCHAR(c);
}
printf("\n");
fflush(stdout);
Enter(1);
lc++;
if ((lc >= exitinfo.iScreenLen) && (lc < 1000)) {
lc = 0;
/* More (Y/n/=) */
pout(CFG.MoreF, CFG.MoreB, (char *) Language(61));
fflush(stdout);
alarm_on();
z = toupper(Getone());
z = toupper(Readkey());
if (z == Keystroke(61, 1)) {
printf("\n");
fflush(stdout);
Enter(1);
fclose(fp);
free(buf);
return TRUE;
@ -211,10 +212,8 @@ int DisplayTextFile(char *filename)
Enter(1);
/* Press ENTER to continue */
language(CFG.MoreF, CFG.MoreB, 436);
fflush(stdout);
fflush(stdin);
alarm_on();
Getone();
Readkey();
return TRUE;
}
@ -232,6 +231,7 @@ int DisplayFile(char *filename)
long iSec = 0;
char *sFileName, *tmp, *tmp1, newfile[PATH_MAX];
int i, x;
unsigned char c;
sFileName = calloc(16385, sizeof(char));
tmp = calloc(PATH_MAX, sizeof(char));
@ -272,7 +272,8 @@ int DisplayFile(char *filename)
i = fread(sFileName, sizeof(char), 16384, pFileName);
for (x = 0; x < i; x++) {
switch(*(sFileName + x)) {
c = *(sFileName + x) & 0xff;
switch (c) {
case '': ControlCodeU(sFileName[++x]);
break;
@ -282,10 +283,8 @@ int DisplayFile(char *filename)
case ' ': ControlCodeK(sFileName[++x]);
break;
case '': fflush(stdout);
fflush(stdin);
alarm_on();
Getone();
case '': alarm_on();
Readkey();
break;
case '': /*
@ -306,16 +305,20 @@ int DisplayFile(char *filename)
iSec = atoi(tmp1);
while ((x <= i) && (*(sFileName + x) != '')) {
if (exitinfo.Security.level >= iSec)
printf("%c", *(sFileName + x));
PUTCHAR(*(sFileName + x));
x++;
}
break;
case '': fflush(stdout);
sleep(1);
case '': sleep(1);
break;
default: printf("%c", *(sFileName + x));
case '\n': Enter(1); /* Insert <cr>, we are in raw mode */
break;
case '\r': break; /* If the file has <cr> chars (DOS), eat them */
default: PUTCHAR(*(sFileName + x));
} /* switch */
} /* for */
@ -338,10 +341,8 @@ int DisplayFileEnter(char *File)
Enter(1);
/* Press ENTER to continue */
language(13, 0, 436);
fflush(stdout);
fflush(stdin);
alarm_on();
Getone();
Readkey();
return rc;
}
@ -349,66 +350,71 @@ int DisplayFileEnter(char *File)
void ControlCodeF(int ch)
{
char temp[81];
/* Update user info */
ReadExitinfo();
switch (toupper(ch)) {
case '!':
printf(exitinfo.sProtocol);
sprintf(temp, "%s", exitinfo.sProtocol);
break;
case 'A':
printf("%ld", exitinfo.Uploads);
sprintf(temp, "%ld", exitinfo.Uploads);
break;
case 'B':
printf("%ld", exitinfo.Downloads);
sprintf(temp, "%ld", exitinfo.Downloads);
break;
case 'C':
printf("%lu", exitinfo.DownloadK);
sprintf(temp, "%lu", exitinfo.DownloadK);
break;
case 'D':
printf("%lu", exitinfo.UploadK);
sprintf(temp, "%lu", exitinfo.UploadK);
break;
case 'E':
printf("%lu", exitinfo.DownloadK + exitinfo.UploadK);
sprintf(temp, "%lu", exitinfo.DownloadK + exitinfo.UploadK);
break;
case 'F':
printf("%lu", LIMIT.DownK);
sprintf(temp, "%lu", LIMIT.DownK);
break;
case 'G':
printf("%d", exitinfo.iTransferTime);
sprintf(temp, "%d", exitinfo.iTransferTime);
break;
case 'H':
printf("%d", iAreaNumber);
sprintf(temp, "%d", iAreaNumber);
break;
case 'I':
printf(sAreaDesc);
sprintf(temp, "%s", sAreaDesc);
break;
case 'J':
printf("%u", LIMIT.DownF);
sprintf(temp, "%u", LIMIT.DownF);
break;
case 'K':
printf("%s", LIMIT.Description);
sprintf(temp, "%s", LIMIT.Description);
break;
default:
printf(" ");
sprintf(temp, " ");
}
PUTSTR(temp);
}
void ControlCodeU(int ch)
{
char temp[81];
/*
* Update user info
*/
@ -417,148 +423,149 @@ void ControlCodeU(int ch)
switch (toupper(ch)) {
case 'A':
printf("%s", exitinfo.sUserName);
sprintf(temp, "%s", exitinfo.sUserName);
break;
case 'B':
printf(exitinfo.sLocation);
sprintf(temp, "%s", exitinfo.sLocation);
break;
case 'C':
printf(exitinfo.sVoicePhone);
sprintf(temp, "%s", exitinfo.sVoicePhone);
break;
case 'D':
printf(exitinfo.sDataPhone);
sprintf(temp, "%s", exitinfo.sDataPhone);
break;
case 'E':
printf(LastLoginDate);
sprintf(temp, "%s", LastLoginDate);
break;
case 'F':
printf("%s %s", StrDateDMY(exitinfo.tFirstLoginDate), StrTimeHMS(exitinfo.tFirstLoginDate));
sprintf(temp, "%s %s", StrDateDMY(exitinfo.tFirstLoginDate), StrTimeHMS(exitinfo.tFirstLoginDate));
break;
case 'G':
printf(LastLoginTime);
sprintf(temp, "%s", LastLoginTime);
break;
case 'H':
printf("%d", exitinfo.Security.level);
sprintf(temp, "%d", exitinfo.Security.level);
break;
case 'I':
printf("%d", exitinfo.iTotalCalls);
sprintf(temp, "%d", exitinfo.iTotalCalls);
break;
case 'J':
printf("%d", exitinfo.iTimeUsed);
sprintf(temp, "%d", exitinfo.iTimeUsed);
break;
case 'K':
printf("%d", exitinfo.iConnectTime);
sprintf(temp, "%d", exitinfo.iConnectTime);
break;
case 'L':
printf("%d", exitinfo.iTimeLeft);
sprintf(temp, "%d", exitinfo.iTimeLeft);
break;
case 'M':
printf("%d", exitinfo.iScreenLen);
sprintf(temp, "%d", exitinfo.iScreenLen);
break;
case 'N':
printf(FirstName);
sprintf(temp, "%s", FirstName);
break;
case 'O':
printf(LastName);
sprintf(temp, "%s", LastName);
break;
case 'Q':
printf("%s", exitinfo.ieNEWS ? (char *) Language(147) : (char *) Language(148));
sprintf(temp, "%s", exitinfo.ieNEWS ? (char *) Language(147) : (char *) Language(148));
break;
case 'P':
printf("%s", exitinfo.GraphMode ? (char *) Language(147) : (char *) Language(148));
sprintf(temp, "%s", exitinfo.GraphMode ? (char *) Language(147) : (char *) Language(148));
break;
case 'R':
printf("%s", exitinfo.HotKeys ? (char *) Language(147) : (char *) Language(148));
sprintf(temp, "%s", exitinfo.HotKeys ? (char *) Language(147) : (char *) Language(148));
break;
case 'S':
printf("%d", exitinfo.iTimeUsed + exitinfo.iTimeLeft);
sprintf(temp, "%d", exitinfo.iTimeUsed + exitinfo.iTimeLeft);
break;
case 'T':
printf(exitinfo.sDateOfBirth);
sprintf(temp, "%s", exitinfo.sDateOfBirth);
break;
case 'U':
printf("%d", exitinfo.iPosted);
sprintf(temp, "%d", exitinfo.iPosted);
break;
case 'X':
printf(lang.Name);
sprintf(temp, "%s", lang.Name);
break;
case 'Y':
printf(exitinfo.sHandle);
sprintf(temp, "%s", exitinfo.sHandle);
break;
case 'Z':
printf("%s", exitinfo.DoNotDisturb ? (char *) Language(147) : (char *) Language(148));
sprintf(temp, "%s", exitinfo.DoNotDisturb ? (char *) Language(147) : (char *) Language(148));
break;
case '1':
printf("%s", exitinfo.MailScan ? (char *) Language(147) : (char *) Language(148));
sprintf(temp, "%s", exitinfo.MailScan ? (char *) Language(147) : (char *) Language(148));
break;
case '2':
printf("%s", exitinfo.ieFILE ? (char *) Language(147) : (char *) Language(148));
sprintf(temp, "%s", exitinfo.ieFILE ? (char *) Language(147) : (char *) Language(148));
break;
case '3':
switch(exitinfo.MsgEditor) {
case LINEEDIT: printf(Language(387));
case LINEEDIT: sprintf(temp, "%s", Language(387));
break;
case FSEDIT: printf(Language(388));
case FSEDIT: sprintf(temp, "%s", Language(388));
break;
case EXTEDIT: printf(Language(389));
case EXTEDIT: sprintf(temp, "%s", Language(389));
break;
default: printf("?");
default: sprintf(temp, "?");
}
break;
case '4':
printf("%s", exitinfo.FSemacs ? (char *) Language(147) : (char *) Language(148));
sprintf(temp, "%s", exitinfo.FSemacs ? (char *) Language(147) : (char *) Language(148));
break;
case '5':
printf(exitinfo.address[0]);
sprintf(temp, "%s", exitinfo.address[0]);
break;
case '6':
printf(exitinfo.address[1]);
sprintf(temp, "%s", exitinfo.address[1]);
break;
case '7':
printf(exitinfo.address[2]);
sprintf(temp, "%s", exitinfo.address[2]);
break;
case '8':
printf("%s", exitinfo.OL_ExtInfo ? (char *) Language(147) : (char *) Language(148));
sprintf(temp, "%s", exitinfo.OL_ExtInfo ? (char *) Language(147) : (char *) Language(148));
break;
case '9':
printf("%s", getchrs(exitinfo.Charset));
sprintf(temp, "%s", getchrs(exitinfo.Charset));
break;
default:
printf(" ");
sprintf(temp, " ");
}
PUTSTR(temp);
}
@ -566,62 +573,62 @@ void ControlCodeU(int ch)
void ControlCodeK(int ch)
{
FILE *pCallerLog;
char sDataFile[PATH_MAX];
char sDataFile[PATH_MAX], temp[81];
lastread LR;
switch (toupper(ch)) {
case 'A':
printf("%s", (char *) GetDateDMY());
sprintf(temp, "%s", (char *) GetDateDMY());
break;
case 'B':
printf("%s", (char *) GetLocalHMS());
sprintf(temp, "%s", (char *) GetLocalHMS());
break;
case 'C':
printf("%s", (char *) GLCdate());
sprintf(temp, "%s", (char *) GLCdate());
break;
case 'D':
printf("%s", (char *) GLCdateyy());
sprintf(temp, "%s", (char *) GLCdateyy());
break;
case 'E':
printf("%ld", Speed());
sprintf(temp, "%ld", Speed());
break;
case 'F':
printf("%s", LastCaller);
sprintf(temp, "%s", LastCaller);
break;
case 'G':
printf("%d", TotalUsers());
sprintf(temp, "%d", TotalUsers());
break;
case 'H':
sprintf(sDataFile, "%s/etc/sysinfo.data", getenv("MBSE_ROOT"));
if((pCallerLog = fopen(sDataFile, "rb")) != NULL) {
fread(&SYSINFO, sizeof(SYSINFO), 1, pCallerLog);
printf("%ld", SYSINFO.SystemCalls);
sprintf(temp, "%ld", SYSINFO.SystemCalls);
fclose(pCallerLog);
}
break;
case 'I':
printf("%d", iMsgAreaNumber + 1);
sprintf(temp, "%d", iMsgAreaNumber + 1);
break;
case 'J':
printf(sMsgAreaDesc);
sprintf(temp, "%s", sMsgAreaDesc);
break;
case 'K':
printf("%s", Oneliner_Get());
sprintf(temp, "%s", Oneliner_Get());
break;
case 'L':
SetMsgArea(iMsgAreaNumber);
printf("%ld", MsgBase.Total);
sprintf(temp, "%ld", MsgBase.Total);
break;
case 'M':
@ -630,20 +637,20 @@ void ControlCodeK(int ch)
if (Msg_GetLastRead(&LR) == TRUE) {
if (LR.HighReadMsg > MsgBase.Highest)
LR.HighReadMsg = MsgBase.Highest;
printf("%ld", LR.HighReadMsg);
sprintf(temp, "%ld", LR.HighReadMsg);
} else
printf("?");
sprintf(temp, "?");
Msg_Close();
}
break;
case 'N':
printf("%s", sMailbox);
sprintf(temp, "%s", sMailbox);
break;
case 'O':
SetEmailArea(sMailbox);
printf("%ld", EmailBase.Total);
sprintf(temp, "%ld", EmailBase.Total);
break;
case 'P':
@ -653,21 +660,23 @@ void ControlCodeK(int ch)
if (Msg_GetLastRead(&LR) == TRUE) {
if (LR.HighReadMsg > EmailBase.Highest)
LR.HighReadMsg = EmailBase.Highest;
printf("%ld", LR.HighReadMsg);
sprintf(temp, "%ld", LR.HighReadMsg);
} else
printf("?");
sprintf(temp, "?");
Msg_Close();
}
break;
case 'Q':
printf("%s %s", StrDateDMY(LastCallerTime), StrTimeHMS(LastCallerTime));
sprintf(temp, "%s %s", StrDateDMY(LastCallerTime), StrTimeHMS(LastCallerTime));
break;
default:
printf(" ");
sprintf(temp, " ");
}
PUTSTR(temp);
}

View File

@ -39,6 +39,8 @@
#include "whoson.h"
#include "door.h"
#include "term.h"
#include "ttyio.h"
#include "openport.h"
extern time_t t_start;
@ -128,9 +130,10 @@ void ExtDoor(char *Program, int NoDoorsys, int Y2Kdoorsys, int Comport, int NoSu
strtok(NULL, ","); /* location */
if (strcmp(strtok(NULL, ","), menus.DoorName) == 0) {
Syslog('+', "User tried single user door %s, but door is in use", menus.DoorName);
colour(LIGHTRED, BLACK);
Enter(1);
/* The door is in use by another user, try again later */
printf("\n%s\n\n", (char *) Language(20));
pout(LIGHTRED, BLACK, (char *) Language(20));
Enter(2);
Pause();
free(temp1);
free(String);
@ -149,14 +152,14 @@ void ExtDoor(char *Program, int NoDoorsys, int Y2Kdoorsys, int Comport, int NoSu
}
if ((strstr(Program, "/A")) != NULL) {
Enter(1);
colour(3, 0);
if ((String = strstr(Program, "/T=")) != NULL) {
String1 = String + 3;
printf("\n%s", String1);
PUTSTR(String1);
} else
printf("\nPlease enter filename: ");
PUTSTR((char *)"Please enter filename: ");
fflush(stdout);
colour(CFG.InputColourF, CFG.InputColourB);
GetstrC(temp1, 80);
@ -288,19 +291,32 @@ void ExtDoor(char *Program, int NoDoorsys, int Y2Kdoorsys, int Comport, int NoSu
}
clear();
printf("Loading ...\n\n");
PUTSTR((char *)"Loading ...");
Enter(2);
/*
* Put terminal back in cooked mode, prefered by some doors.
*/
cookedport();
if (NoSuid)
rc = exec_nosuid(Program);
else
rc = execute_str((char *)"/bin/sh", (char *)"-c", Program, NULL, NULL, NULL);
/*
* Restore raw mode if needed, some doors put the terminal
* back in cooked mode.
*/
rawport();
Altime(0);
alarm_off();
alarm_on();
Syslog('+', "Door end, rc=%d", rc);
free(temp1);
printf("\n\n");
Enter(2);
if (!NoPrompt)
Pause();

View File

@ -44,6 +44,8 @@
#include "email.h"
#include "whoson.h"
#include "term.h"
#include "ttyio.h"
extern unsigned long LastNum;
extern int Kludges;
@ -69,8 +71,9 @@ int HasNoEmail(void)
if (exitinfo.Email)
return FALSE;
colour(15, 0);
printf("\nYou have no e-mail access\n\n");
Enter(1);
pout(WHITE, BLACK, (char *)"You have no e-mail access");
Enter(2);
sleep(3);
return TRUE;
}
@ -82,7 +85,7 @@ int HasNoEmail(void)
*/
void ShowEmailHdr(void)
{
static char Buf1[35], Buf2[35], Buf3[81];
static char Buf1[35], Buf2[35], Buf3[81], temp[81];
struct tm *tm;
Buf1[0] = '\0';
@ -90,87 +93,86 @@ void ShowEmailHdr(void)
Buf3[0] = '\0';
clear();
colour(1,7);
printf(" %-70s", sMailbox);
sprintf(temp, " %-70s", sMailbox);
pout(1, 7, temp);
colour(4,7);
printf("#%-5lu\n", Msg.Id);
sprintf(temp, "#%-5lu", Msg.Id);
pout(4, 7, temp);
Enter(1);
/* Date : */
pout(14, 0, (char *) Language(206));
colour(10, 0);
tm = gmtime(&Msg.Written);
printf("%02d-%02d-%d %02d:%02d:%02d", tm->tm_mday, tm->tm_mon+1,
sprintf(temp, "%02d-%02d-%d %02d:%02d:%02d", tm->tm_mday, tm->tm_mon+1,
tm->tm_year+1900, tm->tm_hour, tm->tm_min, tm->tm_sec);
pout(10, 0, temp);
colour(12, 0);
if (Msg.Local) printf(" Local");
if (Msg.Intransit) printf(" Transit");
if (Msg.Private) printf(" Priv.");
if (Msg.Received) printf(" Rcvd");
if (Msg.Sent) printf(" Sent");
if (Msg.KillSent) printf(" KillSent");
if (Msg.ArchiveSent) printf(" ArchiveSent");
if (Msg.Hold) printf(" Hold");
if (Msg.Crash) printf(" Crash");
if (Msg.Immediate) printf(" Imm.");
if (Msg.Direct) printf(" Dir");
if (Msg.Gate) printf(" Gate");
if (Msg.FileRequest) printf(" Freq");
if (Msg.FileAttach) printf(" File");
if (Msg.TruncFile) printf(" TruncFile");
if (Msg.KillFile) printf(" KillFile");
if (Msg.ReceiptRequest) printf(" RRQ");
if (Msg.ConfirmRequest) printf(" CRQ");
if (Msg.Orphan) printf(" Orphan");
if (Msg.Encrypt) printf(" Crypt");
if (Msg.Compressed) printf(" Comp");
if (Msg.Escaped) printf(" 7bit");
if (Msg.ForcePU) printf(" FPU");
if (Msg.Localmail) printf(" Localmail");
if (Msg.Netmail) printf(" Netmail");
if (Msg.Echomail) printf(" Echomail");
if (Msg.News) printf(" News");
if (Msg.Email) printf(" E-mail");
if (Msg.Nodisplay) printf(" Nodisp");
if (Msg.Locked) printf(" LCK");
if (Msg.Deleted) printf(" Del");
printf("\n");
if (Msg.Local) PUTSTR((char *)" Local");
if (Msg.Intransit) PUTSTR((char *)" Transit");
if (Msg.Private) PUTSTR((char *)" Priv.");
if (Msg.Received) PUTSTR((char *)" Rcvd");
if (Msg.Sent) PUTSTR((char *)" Sent");
if (Msg.KillSent) PUTSTR((char *)" KillSent");
if (Msg.ArchiveSent) PUTSTR((char *)" ArchiveSent");
if (Msg.Hold) PUTSTR((char *)" Hold");
if (Msg.Crash) PUTSTR((char *)" Crash");
if (Msg.Immediate) PUTSTR((char *)" Imm.");
if (Msg.Direct) PUTSTR((char *)" Dir");
if (Msg.Gate) PUTSTR((char *)" Gate");
if (Msg.FileRequest) PUTSTR((char *)" Freq");
if (Msg.FileAttach) PUTSTR((char *)" File");
if (Msg.TruncFile) PUTSTR((char *)" TruncFile");
if (Msg.KillFile) PUTSTR((char *)" KillFile");
if (Msg.ReceiptRequest) PUTSTR((char *)" RRQ");
if (Msg.ConfirmRequest) PUTSTR((char *)" CRQ");
if (Msg.Orphan) PUTSTR((char *)" Orphan");
if (Msg.Encrypt) PUTSTR((char *)" Crypt");
if (Msg.Compressed) PUTSTR((char *)" Comp");
if (Msg.Escaped) PUTSTR((char *)" 7bit");
if (Msg.ForcePU) PUTSTR((char *)" FPU");
if (Msg.Localmail) PUTSTR((char *)" Localmail");
if (Msg.Netmail) PUTSTR((char *)" Netmail");
if (Msg.Echomail) PUTSTR((char *)" Echomail");
if (Msg.News) PUTSTR((char *)" News");
if (Msg.Email) PUTSTR((char *)" E-mail");
if (Msg.Nodisplay) PUTSTR((char *)" Nodisp");
if (Msg.Locked) PUTSTR((char *)" LCK");
if (Msg.Deleted) PUTSTR((char *)" Del");
Enter(1);
/* From : */
pout(14,0, (char *) Language(209));
colour(10, 0);
printf("%s\n", Msg.From);
pout(10, 0, Msg.From);
Enter(1);
/* To : */
pout(14,0, (char *) Language(208));
colour(10, 0);
printf("%s\n", Msg.To);
pout(10, 0, Msg.To);
Enter(1);
/* Subject : */
pout(14,0, (char *) Language(210));
colour(10, 0);
printf("%s\n", Msg.Subject);
pout(10, 0, Msg.Subject);
Enter(1);
colour(CFG.HiliteF, CFG.HiliteB);
colour(14, 1);
if (Msg.Reply)
sprintf(Buf1, "\"+\" %s %lu", (char *)Language(211), Msg.Reply);
if (Msg.Original)
sprintf(Buf2, " \"-\" %s %lu", (char *)Language(212), Msg.Original);
sprintf(Buf3, "%s%s ", Buf1, Buf2);
colour(14, 1);
printf("%78s \n", Buf3);
sprintf(temp, "%78s ", Buf3);
pout(14, 1, temp);
Enter(1);
}
/*
* Export a email to file in the users home directory.
*/
int Export_a_Email(unsigned long Num)
{
char *p;
char *p, temp[21];
LastNum = Num;
iLineCount = 7;
@ -181,9 +183,10 @@ int Export_a_Email(unsigned long Num)
* The area data is already set, so we can do the next things
*/
if (EmailBase.Total == 0) {
colour(15, 0);
Enter(1);
/* There are no messages in this area */
printf("\n%s\n\n", (char *) Language(205));
pout(WHITE, BLACK, (char *) Language(205));
Enter(2);
sleep(3);
return FALSE;
}
@ -194,10 +197,10 @@ int Export_a_Email(unsigned long Num)
}
if (!Msg_ReadHeader(Num)) {
perror("");
colour(15, 0);
printf("\n%s\n\n", (char *)Language(77));
Enter(1);
pout(WHITE, BLACK, (char *)Language(77));
Msg_Close();
Enter(2);
sleep(3);
return FALSE;
}
@ -213,7 +216,7 @@ int Export_a_Email(unsigned long Num)
free(p);
p = NULL;
if (Msg_Read(Num, 80)) {
if ((p = (char *)MsgText_First()) != NULL)
if ((p = (char *)MsgText_First()) != NULL) {
do {
if (p[0] == '\001') {
if (Kludges) {
@ -224,6 +227,7 @@ int Export_a_Email(unsigned long Num)
fprintf(qf, "%s\r\n", p);
} while ((p = (char *)MsgText_Next()) != NULL);
}
}
fclose(qf);
} else {
WriteError("$Can't open %s", p);
@ -234,10 +238,11 @@ int Export_a_Email(unsigned long Num)
/*
* Report the result.
*/
colour(CFG.TextColourF, CFG.TextColourB);
printf("\n\n%s", (char *) Language(46));
colour(CFG.HiliteF, CFG.HiliteB);
printf("%s_%lu.msg\n\n", sMailbox, Num);
Enter(2);
pout(CFG.TextColourF, CFG.TextColourB, (char *) Language(46));
sprintf(temp, "%s_%lu.msg", sMailbox, Num);
pout(CFG.HiliteF, CFG.HiliteB, temp);
Enter(2);
Pause();
return TRUE;
}
@ -340,10 +345,11 @@ int Save_Email(int IsReply)
Syslog('+', "Email (%ld) to \"%s\", \"%s\", in mailbox", Msg.Id, Msg.To, Msg.Subject);
colour(CFG.HiliteF, CFG.HiliteB);
Enter(1);
/* Saving message to disk */
printf("\n%s(%ld)\n\n", (char *) Language(202), Msg.Id);
fflush(stdout);
sprintf(temp, "%s(%ld)", (char *) Language(202), Msg.Id);
pout(CFG.HiliteF, CFG.HiliteB, temp);
Enter(2);
sleep(2);
/*
@ -376,9 +382,10 @@ int Read_a_Email(unsigned long Num)
* The area data is already set, so we can do the next things
*/
if (EmailBase.Total == 0) {
colour(15, 0);
Enter(1);
/* There are no messages in this area */
printf("\n%s\n\n", (char *) Language(205));
pout(WHITE, BLACK, (char *) Language(205));
Enter(2);
sleep(3);
return FALSE;
}
@ -389,9 +396,9 @@ int Read_a_Email(unsigned long Num)
}
if (!Msg_ReadHeader(Num)) {
perror("");
colour(15, 0);
printf("\n%s\n\n", (char *)Language(77));
Enter(1);
pout(WHITE, BLACK, (char *)Language(77));
Enter(2);
Msg_Close();
sleep(3);
return FALSE;
@ -441,8 +448,8 @@ int Read_a_Email(unsigned long Num)
do {
if (p[0] == '\001') {
if (Kludges) {
colour(7, 0);
printf("%s\n", p);
pout(LIGHTGRAY, BLACK, p);
Enter(1);
if (CheckLine(CFG.TextColourF, CFG.TextColourB, TRUE))
break;
}
@ -451,7 +458,8 @@ int Read_a_Email(unsigned long Num)
if (strchr(p, '>') != NULL)
if ((strlen(p) - strlen(strchr(p, '>'))) < 10)
colour(CFG.HiliteF, CFG.HiliteB);
printf("%s\n", p);
PUTSTR(p);
Enter(1);
if (CheckLine(CFG.TextColourF, CFG.TextColourB, TRUE))
break;
}
@ -517,15 +525,13 @@ int EmailPanel(void)
WhosDoingWhat(READ_POST, NULL);
colour(15, 4);
/* (A)gain, (N)ext, (L)ast, (R)eply, (E)nter, (D)elete, (Q)uit, e(X)port */
printf("%s", (char *) Language(214));
pout(WHITE, RED, (char *) Language(214));
if (exitinfo.Security.level >= CFG.sysop_access)
printf(", (!)");
printf(": ");
fflush(stdout);
PUTSTR((char *)", (!)");
PUTSTR((char *)": ");
alarm_on();
input = toupper(Getone());
input = toupper(Readkey());
if (input == '!') {
if (exitinfo.Security.level >= CFG.sysop_access) {
@ -549,7 +555,8 @@ int EmailPanel(void)
Read_a_Email(LastNum);
} else if (input == Keystroke(214, 5)) { /* (Q)uit */
/* Quit */
printf("%s\n", (char *) Language(189));
pout(WHITE, BLACK, (char *) Language(189));
Enter(1);
return FALSE;
} else if (input == Keystroke(214, 7)) { /* e(X)port */
Export_a_Email(LastNum);
@ -596,9 +603,12 @@ void Read_Email(void)
if (HasNoEmail())
return;
colour(CFG.TextColourF, CFG.TextColourB);
Enter(1);
temp = calloc(128, sizeof(char));
/* Message area \"%s\" contains %lu messages. */
printf("\n%s\"%s\" %s%lu %s", (char *) Language(221), sMailbox, (char *) Language(222), EmailBase.Total, (char *) Language(223));
sprintf(temp, "\n%s\"%s\" %s%lu %s", (char *) Language(221), sMailbox, (char *) Language(222),
EmailBase.Total, (char *) Language(223));
pout(CFG.TextColourF, CFG.TextColourB, temp);
/*
* Check for lastread pointer, suggest lastread number for start.
@ -620,13 +630,15 @@ void Read_Email(void)
Start = EmailBase.Highest;
}
colour(15, 0);
Enter(1);
/* Please enter a message between */
printf("\n%s(%lu - %lu)", (char *) Language(224), EmailBase.Lowest, EmailBase.Highest);
sprintf(temp, "%s(%lu - %lu)", (char *) Language(224), EmailBase.Lowest, EmailBase.Highest);
pout(WHITE, BLACK, temp);
Enter(1);
/* Message number [ */
printf("\n%s%lu]: ", (char *) Language(225), Start);
sprintf(temp, "%s%lu]: ", (char *) Language(225), Start);
PUTSTR(temp);
temp = calloc(128, sizeof(char));
colour(CFG.InputColourF, CFG.InputColourB);
GetstrC(temp, 80);
if ((strcmp(temp, "")) != 0)
@ -651,7 +663,7 @@ void Read_Email(void)
void Reply_Email(int IsReply)
{
int i, j, x;
char to[65], from[65], subj[72], msgid[81], replyto[81], replyaddr[81], *tmp, *buf, qin[9];
char to[65], from[65], subj[72], msgid[81], replyto[81], replyaddr[81], *tmp, *buf, qin[9], temp[81];
faddr *Dest = NULL;
sprintf(from, "%s", Msg.To);
@ -672,13 +684,15 @@ void Reply_Email(int IsReply)
Line = 1;
WhosDoingWhat(READ_POST, NULL);
clear();
colour(1,7);
printf(" %-71s", sMailbox);
colour(4,7);
printf("#%-5lu", EmailBase.Highest + 1);
sprintf(temp, " %-70s", sMailbox);
pout(BLUE, LIGHTGRAY, temp);
sprintf(temp, "#%-5lu", EmailBase.Highest + 1);
pout(RED, LIGHTGRAY, temp);
Enter(1);
colour(CFG.HiliteF, CFG.HiliteB);
sLine();
Enter(1);
for (i = 0; i < (TEXTBUFSIZE + 1); i++)
Message[i] = (char *) calloc(MAX_LINE_LENGTH +1, sizeof(char));
@ -690,7 +704,7 @@ void Reply_Email(int IsReply)
sprintf(Msg.ReplyAddr, "%s", replyaddr);
/* From : */
pout(14, 0, (char *) Language(209));
pout(YELLOW, BLACK, (char *) Language(209));
if (CFG.EmailMode != E_PRMISP) {
/*
* If not permanent connected to the internet, use fidonet.org style addressing.
@ -712,23 +726,21 @@ void Reply_Email(int IsReply)
/* To : */
sprintf(Msg.To, "%s", to);
pout(14, 0, (char *) Language(208));
pout(YELLOW, BLACK, (char *) Language(208));
pout(CFG.MsgInputColourF, CFG.MsgInputColourB, Msg.To);
Enter(1);
/* Enter to keep Subject. */
pout(12, 0, (char *) Language(219));
pout(LIGHTRED, BLACK, (char *) Language(219));
Enter(1);
/* Subject : */
pout(14, 0, (char *) Language(210));
pout(YELLOW, BLACK, (char *) Language(210));
sprintf(Msg.Subject, "%s", subj);
pout(CFG.MsgInputColourF, CFG.MsgInputColourB, Msg.Subject);
x = strlen(subj);
fflush(stdout);
colour(CFG.MsgInputColourF, CFG.MsgInputColourB);
GetstrP(subj, 50, x);
fflush(stdout);
if (strlen(subj))
strcpy(Msg.Subject, subj);
@ -816,13 +828,15 @@ void Write_Email(void)
Msg_New();
Enter(1);
colour(9, 0);
/* Posting message in area: */
printf("\n%s\"%s\"\n", (char *) Language(156), "mailbox");
pout(LIGHTBLUE, BLACK, (char *) Language(156));
PUTSTR((char *)"\"mailbox\"");
Enter(2);
Enter(1);
/* From : */
pout(14, 0, (char *) Language(157));
pout(YELLOW, BLACK, (char *) Language(157));
if (CFG.EmailMode != E_PRMISP) {
/*
* If not permanent connected to the internet, use fidonet.org style addressing.
@ -839,15 +853,14 @@ void Write_Email(void)
break;
}
colour(CFG.MsgInputColourF, CFG.MsgInputColourB);
printf("%s", Msg.From);
pout(CFG.MsgInputColourF, CFG.MsgInputColourB, Msg.From);
Syslog('b', "Setting From: %s", Msg.From);
Enter(1);
/* To : */
pout(14, 0, (char *) Language(158));
/* To : */
pout(YELLOW, BLACK, (char *) Language(158));
colour(CFG.MsgInputColourF, CFG.MsgInputColourB);
alarm_on();
GetstrU(Msg.To, 63);
if ((strcmp(Msg.To, "")) == 0) {
@ -859,20 +872,18 @@ void Write_Email(void)
}
/* Subject : */
pout(14, 0, (char *) Language(161));
pout(YELLOW, BLACK, (char *) Language(161));
colour(CFG.MsgInputColourF, CFG.MsgInputColourB);
fflush(stdout);
alarm_on();
GetstrP(Msg.Subject, 65, 0);
if ((strcmp(Msg.Subject, "")) == 0) {
Enter(1);
/* Abort Message [y/N] ?: */
pout(3, 0, (char *) Language(162));
fflush(stdout);
pout(CYAN, BLACK, (char *) Language(162));
alarm_on();
if (toupper(Getone()) == Keystroke(162, 0)) {
if (toupper(Readkey()) == Keystroke(162, 0)) {
for (i = 0; i < (TEXTBUFSIZE + 1); i++)
free(Message[i]);
SetEmailArea(orgbox);
@ -900,6 +911,7 @@ void QuickScan_Email(void)
{
int FoundMsg = FALSE;
long i;
char temp[81];
iLineCount = 2;
WhosDoingWhat(READ_POST, NULL);
@ -907,30 +919,30 @@ void QuickScan_Email(void)
if (EmailBase.Total == 0) {
Enter(1);
/* There are no messages in this area. */
pout(15, 0, (char *) Language(205));
Enter(3);
pout(WHITE, BLACK, (char *) Language(205));
Enter(2);
sleep(3);
return;
}
clear();
/* # From To Subject */
poutCR(14, 1, (char *) Language(220));
poutCR(YELLOW, BLUE, (char *) Language(220));
if (Msg_Open(sMailpath)) {
for (i = EmailBase.Lowest; i <= EmailBase.Highest; i++) {
if (Msg_ReadHeader(i)) {
colour(15, 0);
printf("%-6lu", Msg.Id);
colour(3, 0);
printf("%s ", padleft(Msg.From, 20, ' '));
sprintf(temp, "%-6lu", Msg.Id);
pout(WHITE, BLACK, temp);
sprintf(temp, "%s ", padleft(Msg.From, 20, ' '));
pout(CYAN, BLACK, temp);
colour(2, 0);
printf("%s ", padleft(Msg.To, 20, ' '));
colour(5, 0);
printf("%s", padleft(Msg.Subject, 31, ' '));
printf("\n");
sprintf(temp, "%s ", padleft(Msg.To, 20, ' '));
pout(GREEN, BLACK, temp);
sprintf(temp, "%s", padleft(Msg.Subject, 31, ' '));
pout(MAGENTA, BLACK, temp);
Enter(1);
FoundMsg = TRUE;
if (LC(1))
break;
@ -942,7 +954,7 @@ void QuickScan_Email(void)
if(!FoundMsg) {
Enter(1);
/* There are no messages in this area. */
pout(10, 0, (char *) Language(205));
pout(LIGHTGREEN, BLACK, (char *) Language(205));
Enter(2);
sleep(3);
}
@ -995,13 +1007,12 @@ void Choose_Mailbox(char *Option)
pout(CFG.HiliteF, CFG.HiliteB, (char *) Language(231));
Enter(2);
pout(15, 0, (char *)" 1"); pout(9, 0, (char *)" . "); pout(3, 0, (char *) Language(467)); printf("\n");
pout(15, 0, (char *)" 2"); pout(9, 0, (char *)" . "); pout(3, 0, (char *) Language(468)); printf("\n");
pout(15, 0, (char *)" 3"); pout(9, 0, (char *)" . "); pout(3, 0, (char *) Language(469)); printf("\n");
pout(15, 0, (char *)" 1"); pout(9, 0, (char *)" . "); pout(3, 0, (char *) Language(467)); Enter(1);
pout(15, 0, (char *)" 2"); pout(9, 0, (char *)" . "); pout(3, 0, (char *) Language(468)); Enter(1);
pout(15, 0, (char *)" 3"); pout(9, 0, (char *)" . "); pout(3, 0, (char *) Language(469)); Enter(1);
pout(CFG.MoreF, CFG.MoreB, (char *) Language(470));
colour(CFG.InputColourF, CFG.InputColourB);
fflush(stdout);
temp = calloc(81, sizeof(char));
GetstrC(temp, 7);

File diff suppressed because it is too large Load Diff

View File

@ -42,6 +42,7 @@
#include "exitinfo.h"
#include "change.h"
#include "term.h"
#include "ttyio.h"
extern pid_t mypid;
@ -116,13 +117,6 @@ void GetstrD(char *sStr, int iMaxlen)
unsigned char ch = 0;
int iPos = 0;
fflush(stdout);
if ((ttyfd = open ("/dev/tty", O_RDWR)) < 0) {
perror("open 6");
return;
}
Setraw();
strcpy(sStr, "");
alarm_on();
@ -130,8 +124,7 @@ void GetstrD(char *sStr, int iMaxlen)
ch = Readkey();
if (((ch == 8) || (ch == KEY_DEL) || (ch == 127)) && (iPos > 0)) {
printf("\b \b");
fflush(stdout);
BackErase();
sStr[--iPos]='\0';
}
@ -139,15 +132,11 @@ void GetstrD(char *sStr, int iMaxlen)
if (iPos <= iMaxlen) {
iPos++;
sprintf(sStr, "%s%c", sStr, ch);
printf("%c", ch);
fflush(stdout);
PUTCHAR(ch);
} else
ch=07;
PUTCHAR(7);
}
}
Unsetraw();
close(ttyfd);
}
@ -173,7 +162,8 @@ FILE *OpenFareas(int Write)
if (pAreas == NULL) {
WriteError("$Can't open FileBase %s", FileArea);
/* FATAL: Unable to open areas database */
printf("%s\n\n", (char *) Language(243));
pout(LIGHTRED, BLACK, (char *) Language(243));
Enter(2);
sleep(2);
} else
fread(&areahdr, sizeof(areahdr), 1, pAreas);
@ -189,14 +179,16 @@ FILE *OpenFareas(int Write)
*/
void Header()
{
colour(4, 7);
printf(" Area ");
char temp[81];
colour(4, 7);
printf("%-5d ", iAreaNumber);
pout(RED, LIGHTGRAY, (char *)" Area ");
colour(1,7);
printf("%-65s\n", sAreaDesc);
sprintf(temp, "%-5d ", iAreaNumber);
pout(RED, LIGHTGRAY, temp);
sprintf(temp, "%-65s", sAreaDesc);
pout(BLUE, LIGHTGRAY, temp);
Enter(1);
colour(15,0);
fLine(79);
@ -209,20 +201,21 @@ void Header()
*/
void Sheader()
{
colour(Hcolor, 0);
printf("\r %-4ld", arecno);
char temp[81];
colour(9, 0);
printf(" ... ");
PUTCHAR('\r');
sprintf(temp, " %-4ld", arecno);
pout(Hcolor, BLACK, temp);
colour(Hcolor, 0);
printf("%-44s", area.Name);
fflush(stdout);
pout(LIGHTBLUE, BLACK, (char *)" ... ");
if (Hcolor < 15)
sprintf(temp, "%-44s", area.Name);
pout(Hcolor, BLACK, temp);
if (Hcolor < WHITE)
Hcolor++;
else
Hcolor = 9;
Hcolor = LIGHTBLUE;
}
@ -235,13 +228,12 @@ void Blanker(int count)
int i;
for (i = 0; i < count; i++)
printf("\b");
PUTCHAR('\b');
for (i = 0; i < count; i++)
printf(" ");
PUTCHAR(' ');
printf("\r");
fflush(stdout);
PUTCHAR('\r');
}
@ -254,8 +246,7 @@ void Mark()
{
char *temp;
FILE *fp;
int i, Found;
int Count, Size;
int i, Found, Count, Size;
temp = calloc(81, sizeof(char));
@ -273,12 +264,12 @@ void Mark()
fclose(fp);
}
colour(CFG.HiliteF, CFG.HiliteB);
/* Marked: */
printf("%s%d, %dK; ", (char *) Language(360), Count, Size);
sprintf(temp, "%s%d, %dK; ", (char *) Language(360), Count, Size);
pout(CFG.HiliteF, CFG.HiliteB, temp);
/* Mark file number of press <Enter> to stop */
printf("%s", (char *) Language(7));
PUTSTR((char *) Language(7));
colour(CFG.InputColourF, CFG.InputColourB);
GetstrD(temp, 10);
@ -315,10 +306,8 @@ void Mark()
fclose(fp);
}
} else {
colour(12, 0);
/* You do not have enough access to download from this area. */
printf("%s", (char *) Language(244));
fflush(stdout);
pout(LIGHTRED, BLACK, (char *) Language(244));
sleep(3);
Blanker(strlen(Language(244)));
}
@ -343,22 +332,21 @@ int iLC(int Lines)
if ((iLineCount >= exitinfo.iScreenLen) && (iLineCount < 1000)) {
iLineCount = 0;
while(TRUE) {
while (TRUE) {
/* More (Y/n/=) M=Mark */
pout(CFG.MoreF, CFG.MoreB, (char *) Language(131));
fflush(stdout);
alarm_on();
z = toupper(Getone());
z = toupper(Readkey());
Blanker(x);
if (z == Keystroke(131, 1)) {
printf("\n");
Enter(1);
return 1;
}
if (z == Keystroke(131, 2)) {
iLineCount = 1000;
iLineCount = 9000;
return 0;
}
@ -382,29 +370,31 @@ int iLC(int Lines)
int ShowOneFile()
{
int y, z, fg, bg;
char temp[81];
if (!fdb.Deleted) {
colour(7, 0);
printf(" %02d ", Tagnr);
sprintf(temp, " %02d ", Tagnr);
pout(LIGHTGRAY, BLACK, temp);
colour(CFG.FilenameF, CFG.FilenameB);
printf("%-12s", fdb.Name);
sprintf(temp, "%-12s", fdb.Name);
pout(CFG.FilenameF, CFG.FilenameB, temp);
colour(CFG.FilesizeF, CFG.FilesizeB);
printf("%10lu ", (long)(fdb.Size));
sprintf(temp, "%10lu ", (long)(fdb.Size));
pout(CFG.FilesizeF, CFG.FilesizeB, temp);
colour(CFG.FiledateF, CFG.FiledateB);
printf("%-10s ", StrDateDMY(fdb.UploadDate));
sprintf(temp, "%-10s ", StrDateDMY(fdb.UploadDate));
pout(CFG.FiledateF, CFG.FiledateB, temp);
colour(12, 0);
printf("[%4ld] ", fdb.TimesDL);
sprintf(temp, "[%4ld] ", fdb.TimesDL);
pout(LIGHTRED, BLACK, temp);
if ((strcmp(fdb.Uploader, "")) == 0)
strcpy(fdb.Uploader, "SysOp");
colour(CFG.HiliteF, CFG.HiliteB);
printf("%s%s\n", (char *) Language(238), fdb.Uploader);
sprintf(temp, "%s%s", (char *) Language(238), fdb.Uploader);
pout(CFG.HiliteF, CFG.HiliteB, temp);
Enter(1);
if (iLC(1) == 1)
return 1;
@ -420,12 +410,13 @@ int ShowOneFile()
else
fg = (int)fdb.Desc[z][3] - 48;
bg = (int)fdb.Desc[z][2] - 48;
colour(fg, bg);
printf(" %s\n",fdb.Desc[z]+4);
sprintf(temp, " %s",fdb.Desc[z]+4);
pout(fg, bg, temp);
} else {
colour(CFG.FiledescF, CFG.FiledescB);
printf(" %s\n",fdb.Desc[z]);
sprintf(temp, " %s",fdb.Desc[z]);
pout(CFG.FiledescF, CFG.FiledescB, temp);
}
Enter(1);
if (iLC(1) == 1)
return 1;
@ -439,6 +430,8 @@ int ShowOneFile()
int CheckBytesAvailable(long CostSize)
{
char temp[81];
if (LIMIT.DownK) {
if ((exitinfo.DownloadKToday <= 0) || ((CostSize / 1024) > exitinfo.DownloadKToday)) {
@ -447,14 +440,14 @@ int CheckBytesAvailable(long CostSize)
Enter(1);
Syslog('+', "Not enough bytes to download %ld", CostSize);
colour(WHITE, BLACK);
/* You must upload before you can download. */
pout(LIGHTRED, BLACK, (char *) Language(253));
Enter(2);
colour(YELLOW, BLACK);
/* Kilobytes currently available: */
printf("%s%lu Kbytes.\n\n", (char *) Language(254), exitinfo.DownloadKToday);
sprintf(temp, "%s%lu Kbytes.", (char *) Language(254), exitinfo.DownloadKToday);
pout(YELLOW, BLACK, temp);
Enter(2);
Pause();
return FALSE;
@ -488,7 +481,7 @@ int ScanDirect(char *fn)
{
FILE *fp, *lp;
int err, Found = FALSE;
char *temp, *temp1, *stdlog, *errlog, buf[256];
char *temp, *temp1, *stdlog, *errlog, buf[256], msg[81];
temp = calloc(PATH_MAX, sizeof(char));
temp1 = calloc(PATH_MAX, sizeof(char));
@ -506,10 +499,9 @@ int ScanDirect(char *fn)
while (fread(&virscan, virscanhdr.recsize, 1, fp) == 1) {
if (virscan.available) {
colour(CFG.TextColourF, CFG.TextColourB);
/* Scanning */ /* with */
printf("%s %s %s %s ", (char *) Language(132), fn, (char *) Language(133), virscan.comment);
fflush(stdout);
sprintf(msg, "%s %s %s %s ", (char *) Language(132), fn, (char *) Language(133), virscan.comment);
pout(CFG.TextColourF, CFG.TextColourB, msg);
Altime(3600);
err = execute_str(virscan.scanner, virscan.options, temp, (char *)"/dev/null", stdlog, errlog);
@ -535,17 +527,18 @@ int ScanDirect(char *fn)
unlink(errlog);
if (err != virscan.error) {
WriteError("VIRUS ALERT: Result %d (%s)", err, virscan.comment);
colour(CFG.HiliteF, CFG.HiliteB);
/* Possible VIRUS found! */
printf("%s\n", (char *) Language(199));
sprintf(msg, "%s", (char *) Language(199));
pout(CFG.HiliteF, CFG.HiliteB, msg);
Found = TRUE;
} else {
/* Ok */
printf("%s\n", (char *) Language(200));
sprintf(msg, "%s", (char *) Language(200));
PUTSTR(msg);
}
Enter(1);
Altime(0);
Nopper();
fflush(stdout);
}
}
fclose(fp);
@ -572,7 +565,7 @@ int ScanArchive(char *fn, char *ftype)
{
FILE *fp, *lp;
int err = 0, Found = FALSE;
char *temp, *stdlog, *errlog, buf[256];
char *temp, *stdlog, *errlog, buf[256], msg[81];
char *cwd = NULL;
@ -613,10 +606,9 @@ int ScanArchive(char *fn, char *ftype)
return 1;
}
colour(CFG.TextColourF, CFG.TextColourB);
/* Unpacking archive */
printf("%s %s ", (char *) Language(201), fn);
fflush(stdout);
sprintf(msg, "%s %s ", (char *) Language(201), fn);
pout(CFG.TextColourF, CFG.TextColourB, msg);
if (!strlen(archiver.funarc)) {
WriteError("No unarc command available");
@ -627,17 +619,16 @@ int ScanArchive(char *fn, char *ftype)
execute_pth((char *)"rm", (char *)"-r -f ./*", (char *)"/dev/null", (char *)"/dev/null", (char *)"/dev/null");
chdir(cwd);
free(cwd);
colour(CFG.HiliteF, CFG.HiliteB);
/* ERROR */
printf("%s\n", (char *) Language(217));
fflush(stdout);
pout(CFG.HiliteF, CFG.HiliteB, (char *) Language(217));
Enter(1);
return 1;
}
}
/* Ok */
printf("%s\n", (char *) Language(200));
fflush(stdout);
PUTSTR((char *) Language(200));
Enter(1);
sprintf(temp, "%s/etc/virscan.data", getenv("MBSE_ROOT"));
@ -646,10 +637,9 @@ int ScanArchive(char *fn, char *ftype)
while (fread(&virscan, virscanhdr.recsize, 1, fp) == 1) {
if (virscan.available) {
colour(CFG.TextColourF, CFG.TextColourB);
/* Scanning */ /* with */
printf("%s %s %s %s ", (char *) Language(132), fn, (char *) Language(133), virscan.comment);
fflush(stdout);
sprintf(msg, "%s %s %s %s ", (char *) Language(132), fn, (char *) Language(133), virscan.comment);
pout(CFG.TextColourF, CFG.TextColourB, msg);
Altime(3600);
err = execute_str(virscan.scanner, virscan.options, (char *)"*", (char *)"/dev/null", stdlog, errlog);
@ -675,15 +665,14 @@ int ScanArchive(char *fn, char *ftype)
unlink(errlog);
if (err != virscan.error) {
WriteError("VIRUS ALERT: Result %d (%s)", err, virscan.comment);
colour(CFG.HiliteF, CFG.HiliteB);
/* Possible VIRUS found! */
printf("%s\n", (char *) Language(199));
pout(CFG.HiliteF, CFG.HiliteB, (char *) Language(199));
Found = TRUE;
} else {
/* Ok */
printf("%s\n", (char *) Language(200));
PUTSTR((char *) Language(200));
}
fflush(stdout);
Enter(1);
Altime(0);
Nopper();
}
@ -792,7 +781,7 @@ char *GetFileType(char *fn)
*/
int ImportFile(char *fn, int Area, int fileid, time_t iTime, off_t Size)
{
char *temp, *temp1;
char *temp, *temp1, msg[81];
temp = calloc(PATH_MAX, sizeof(char));
temp1 = calloc(PATH_MAX, sizeof(char));
@ -817,7 +806,9 @@ int ImportFile(char *fn, int Area, int fileid, time_t iTime, off_t Size)
exitinfo.UploadKToday += (Size / 1024);
Syslog('b', "Uploads %d, Kb %d, Kb today %d", exitinfo.Uploads, exitinfo.UploadK, exitinfo.UploadKToday);
/* You have */ /* extra download KBytes. */
printf("%s %ld %s\n", (char *) Language(249), (long)(Size / 1024), (char *) Language(250));
sprintf(msg, "%s %ld %s", (char *) Language(249), (long)(Size / 1024), (char *) Language(250));
PUTSTR(msg);
Enter(1);
exitinfo.DownloadKToday += (Size / 1024);
Syslog('b', "DownloadKToday %d", exitinfo.DownloadKToday);
@ -825,7 +816,9 @@ int ImportFile(char *fn, int Area, int fileid, time_t iTime, off_t Size)
iTime /= 60; /* Divide Seconds by 60 to give minutes */
/* You have */ /* extra minutes. */
printf("%s %ld %s\n", (char *) Language(249), iTime, (char *) Language(259));
sprintf(msg, "%s %ld %s", (char *) Language(249), iTime, (char *) Language(259));
PUTSTR(msg);
Enter(1);
exitinfo.iTimeLeft += iTime;
WriteExitinfo();
@ -852,7 +845,7 @@ int Addfile(char *File, int AreaNum, int fileid)
{
FILE *id, *pPrivate;
int err = 1, iDesc = 1, iPrivate = FALSE, GotId = FALSE, lines, i, j;
char *Filename, *temp1, *idname = NULL, *Desc[26], *lname, temp[81];
char *Filename, *temp1, *idname = NULL, *Desc[26], *lname, temp[81], msg[81];
struct stat statfile;
struct _fdbarea *fdb_area = NULL;
@ -870,9 +863,12 @@ int Addfile(char *File, int AreaNum, int fileid)
*/
if (stat(Filename, &statfile) != 0) {
Enter(1);
colour(10, 0);
/* Upload was unsuccessful for: */
printf("\n%s%s\n\n", (char *) Language(284), File);
sprintf(msg, "%s%s", (char *) Language(284), File);
pout(LIGHTGREEN, BLACK, msg);
Enter(2);
mbsedb_CloseFDB(fdb_area);
free(Filename);
@ -899,20 +895,17 @@ int Addfile(char *File, int AreaNum, int fileid)
}
if (area.PwdUP) {
colour(9,0);
Enter(1);
/* Do you want to password protect your upload ? [y/N]: */
printf("\n%s", (char *) Language(285));
fflush(stdout);
pout(LIGHTBLUE, BLACK, (char *) Language(285));
if (toupper(Getone()) == Keystroke(285, 0)) {
colour(10, 0);
if (toupper(Readkey()) == Keystroke(285, 0)) {
Enter(1);
/* REMEMBER: Passwords are "CaSe SeNsITiVe!" */
printf("\n%s\n", (char *) Language(286));
colour(14,0);
pout(LIGHTGREEN, BLACK, (char *) Language(286));
Enter(1);
/* Password: */
printf("%s", (char *) Language(8));
fflush(stdout);
fflush(stdin);
pout(YELLOW, BLACK, (char *) Language(8));
GetstrC(fdb.Password, 20);
}
}
@ -994,10 +987,10 @@ int Addfile(char *File, int AreaNum, int fileid)
}
if (lines) {
Syslog('+', "Using %d FILE_ID.DIZ lines for description", lines);
colour(CFG.TextColourF, CFG.TextColourB);
/* Found FILE_ID.DIZ in */
printf("%s %s\n", (char *) Language(257), File);
fflush(stdout);
sprintf(msg, "%s %s", (char *) Language(257), File);
pout(CFG.TextColourF, CFG.TextColourB, msg);
Enter(1);
} else {
Syslog('!', "No FILE_ID.DIZ lines left to use");
GotId = FALSE;
@ -1012,15 +1005,16 @@ int Addfile(char *File, int AreaNum, int fileid)
for (i = 0; i < 26; i++)
*(Desc + i) = (char *) calloc(49, sizeof(char));
colour(12,0);
Enter(1);
/* Please enter description of file */
printf("\n%s %s\n\n", (char *) Language(287), File);
while (TRUE) {
colour(10,0);
printf("%2d> ", iDesc);
fflush(stdout);
colour(CFG.InputColourF, CFG.InputColourB);
sprintf(msg, "%s %s", (char *) Language(287), File);
pout(LIGHTRED, BLACK, msg);
Enter(2);
while (TRUE) {
sprintf(msg, "%2d> ", iDesc);
pout(LIGHTGREEN, BLACK, msg);
colour(CFG.InputColourF, CFG.InputColourB);
GetstrC(*(Desc + iDesc), 47);
if ((strcmp(*(Desc + iDesc), "")) == 0)
@ -1061,7 +1055,7 @@ int Addfile(char *File, int AreaNum, int fileid)
Enter(1);
/* Your upload time has been returned to you. Thank you for your upload! */
pout(10, 0, (char *) Language(288));
pout(LIGHTGREEN, BLACK, (char *) Language(288));
Enter(1);
}

View File

@ -39,46 +39,54 @@
#include "pinfo.h"
#include "fsedit.h"
#include "term.h"
#include "ttyio.h"
void Show_Ins(void)
{
locate(1, 70);
colour(YELLOW, BLUE);
printf("%s", InsMode ? "INS": "OVR");
fflush(stdout);
if (InsMode)
PUTSTR((char *)"INS");
else
PUTSTR((char *)"OVR");
}
void Top_Help()
{
char temp[81];
locate(1,1);
colour(YELLOW, BLUE);
printf("%s", padleft((char *)"Press ESC for menu, other keys is edit text", 80, ' '));
sprintf(temp, "%s", padleft((char *)"Press ESC for menu, other keys is edit text", 79, ' '));
PUTSTR(temp);
Show_Ins();
}
void Top_Menu(void)
{
char temp[81];
locate(1,1);
colour(WHITE, RED);
printf("%s", padleft((char *)"(A)bort (H)elp (S)ave - Any other key is continue edit", 80, ' '));
fflush(stdout);
sprintf(temp, "%s", padleft((char *)"(A)bort (H)elp (S)ave - Any other key is continue edit", 79, ' '));
PUTSTR(temp);
}
void Ls(int a, int y)
{
locate(y, 10);
printf("%c ", a ? 179 : '|');
PUTCHAR(a ? 179 : '|');
}
void Rs(int a)
{
colour(LIGHTGREEN, BLUE);
printf("%c", a ? 179 : '|');
PUTCHAR(a ? 179 : '|');
}
@ -87,8 +95,8 @@ void Ws(int a, int y)
int i;
Ls(a, y);
for (i = 0; i < 57; i++)
printf(" ");
for (i = 0; i < 58; i++)
PUTCHAR(' ');
Rs(a);
}
@ -97,7 +105,7 @@ void Hl(int a, int y, char *txt)
{
Ls(a, y);
colour(WHITE, BLUE);
printf("%s", padleft(txt, 57, ' '));
PUTSTR(padleft(txt, 58, ' '));
Rs(a);
}
@ -112,16 +120,16 @@ void Full_Help(void)
/* Top row */
locate(1, 10);
printf("%c", a ? 213 : '+');
PUTCHAR(a ? 213 : '+');
for (i = 0; i < 58; i++)
printf("%c", a ? 205 : '=');
printf("%c", a ? 184 : '+');
PUTCHAR(a ? 205 : '=');
PUTCHAR(a ? 184 : '+');
Ws(a, 2);
Ls(a, 3);
colour(YELLOW, BLUE);
printf("%s", padleft((char *)" Editor Help", 57, ' '));
PUTSTR(padleft((char *)" Editor Help", 58, ' '));
Rs(a);
Ws(a, 4);
@ -138,26 +146,24 @@ void Full_Help(void)
Ws(a, 15);
locate(16,10);
printf("%c", a ? 212 : '+');
PUTCHAR(a ? 212 : '+');
for (i = 0; i < 58; i++)
printf("%c", a ? 205 : '=');
printf("%c", a ? 190 : '+');
fflush(stdout);
PUTCHAR(a ? 205 : '=');
PUTCHAR(a ? 190 : '+');
}
void Setcursor(void)
{
CurRow = Row + TopVisible - 1;
locate(Row + 1, Col);
fflush(stdout);
}
void Beep(void)
{
printf("\007");
fflush(stdout);
PUTCHAR('\007');
}
@ -177,7 +183,7 @@ void Refresh(void)
if ((i >= TopVisible) && (i < (TopVisible + exitinfo.iScreenLen -1))) {
locate(j, 1);
j++;
printf("%s", Message[i]);
PUTSTR(Message[i]);
}
}
Setcursor();
@ -195,12 +201,11 @@ void GetstrLC(char *sStr, int iMaxlen)
while (ch != 13) {
fflush(stdout);
ch = Readkey();
if ((ch == 8) || (ch == KEY_DEL) || (ch == 127)) {
if (iPos > 0) {
printf("\b \b");
BackErase();
sStr[--iPos] = '\0';
} else {
Beep();
@ -211,14 +216,14 @@ void GetstrLC(char *sStr, int iMaxlen)
if (iPos <= iMaxlen) {
iPos++;
sprintf(sStr, "%s%c", sStr, ch);
printf("%c", ch);
PUTCHAR(ch);
} else {
Beep();
}
}
}
printf("\n");
Enter(1);
}
@ -403,12 +408,6 @@ int Fs_Edit()
Syslog('b', "FSEDIT: Entering FullScreen editor");
clear();
fflush(stdout);
if ((ttyfd = open("/dev/tty", O_RDWR|O_NONBLOCK)) < 0) {
WriteError("$Can't open tty");
return FALSE;
}
Setraw();
InsMode = TRUE;
TopVisible = 1;
Col = 1;
@ -521,9 +520,10 @@ int Fs_Edit()
Setcursor();
for (i = Col; i <= strlen(Message[CurRow]); i++) {
Message[CurRow][i-1] = Message[CurRow][i];
printf("%c", Message[CurRow][i]);
PUTCHAR(Message[CurRow][i]);
}
printf(" \b");
PUTCHAR(' ');
PUTCHAR('\b');
Message[CurRow][i-1] = '\0';
Setcursor();
} else if (((strlen(Message[CurRow]) + strlen(Message[CurRow+1]) < 75)
@ -572,8 +572,7 @@ int Fs_Edit()
} else {
if (Col == strlen(Message[CurRow]) + 1) {
/* BS at end of line */
printf("\b \b");
fflush(stdout);
BackErase();
Col--;
Message[CurRow][Col-1] = '\0';
Changed = TRUE;
@ -583,9 +582,10 @@ int Fs_Edit()
Setcursor();
for (i = Col; i <= strlen(Message[CurRow]); i++) {
Message[CurRow][i-1] = Message[CurRow][i];
printf("%c", Message[CurRow][i]);
PUTCHAR(Message[CurRow][i]);
}
printf(" \b");
PUTCHAR(' ');
PUTCHAR('\b');
Message[CurRow][strlen(Message[CurRow])] = '\0';
Setcursor();
Changed = TRUE;
@ -617,16 +617,17 @@ int Fs_Edit()
tmpname = calloc(PATH_MAX, sizeof(char));
filname = calloc(PATH_MAX, sizeof(char));
colour(14, 0);
Enter(1);
/* Please enter filename: */
printf("\n%s", (char *) Language(245));
pout(YELLOW, BLACK, (char *) Language(245));
colour(CFG.InputColourF, CFG.InputColourB);
GetstrLC(filname, 80);
if ((strcmp(filname, "") == 0)) {
colour(CFG.HiliteF, CFG.HiliteB);
Enter(2);
/* No filename entered, aborting */
printf("\n\n%s\n", (char *) Language(246));
pout(CFG.HiliteF, CFG.HiliteB, (char *) Language(246));
Enter(1);
Pause();
free(filname);
free(tmpname);
@ -635,9 +636,10 @@ int Fs_Edit()
}
if (*(filname) == '/' || *(filname) == ' ') {
colour(CFG.HiliteF, CFG.HiliteB);
Enter(2);
/* Illegal filename */
printf("\n\n%s\n", (char *) Language(247));
pout(CFG.HiliteF, CFG.HiliteB, (char *) Language(247));
Enter(1);
Pause();
free(tmpname);
free(filname);
@ -648,9 +650,10 @@ int Fs_Edit()
sprintf(tmpname, "%s/%s/wrk/%s", CFG.bbs_usersdir, exitinfo.Name, filname);
if ((fd = fopen(tmpname, "r")) == NULL) {
WriteError("$Can't open %s", tmpname);
colour(CFG.HiliteF, CFG.HiliteB);
Enter(2);
/* File does not exist, please try again */
printf("\n\n%s\n", (char *) Language(296));
pout(CFG.HiliteF, CFG.HiliteB, (char *) Language(296));
Enter(1);
Pause();
} else {
while ((fgets(filname, 80, fd)) != NULL) {
@ -692,10 +695,7 @@ int Fs_Edit()
ch = toupper(Readkey());
if (ch == 'A' || ch == 'S') {
Syslog('b', "FSEDIT: %s message (%c)", (ch == 'S' && Changed) ? "Saving" : "Aborting", ch);
Unsetraw();
close(ttyfd);
clear();
fflush(stdout);
if (ch == 'S' && Changed) {
Syslog('+', "FSEDIT: Message will be saved");
return TRUE;
@ -732,8 +732,7 @@ int Fs_Edit()
Refresh();
} else {
Col++;
printf("%c", ch);
fflush(stdout);
PUTCHAR(ch);
}
Changed = TRUE;
} else {
@ -763,14 +762,13 @@ int Fs_Edit()
Refresh();
} else {
locate(Row + 1, 1);
printf(Message[CurRow]);
PUTSTR(Message[CurRow]);
Setcursor();
}
Changed = TRUE;
} else {
Message[CurRow][Col-1] = ch;
printf("%c", ch);
fflush(stdout);
PUTCHAR(ch);
Col++;
Changed = TRUE;
}
@ -780,8 +778,6 @@ int Fs_Edit()
}
WriteError("FsEdit(): Impossible to be here");
Unsetraw();
close(ttyfd);
return FALSE;
}

View File

@ -35,6 +35,8 @@
#include "../lib/msgtext.h"
#include "../lib/msg.h"
#include "funcs.h"
#include "term.h"
#include "ttyio.h"
extern pid_t mypid; /* Original pid */
@ -54,7 +56,7 @@ void UserSilent(int flag)
*/
int CheckStatus()
{
static char buf[81];
static char buf[81], msg[81];
sprintf(buf, "SBBS:0;");
if (socket_send(buf) == 0) {
@ -64,8 +66,11 @@ int CheckStatus()
if ((strncmp(buf, "100:2,2", 7) == 0) && (!ttyinfo.honor_zmh))
return TRUE;
buf[strlen(buf) -1] = '\0';
printf("\n\n\007*** %s ***\n\n\n", buf+8);
fflush(stdout);
Enter(2);
PUTCHAR('\007');
sprintf(msg, "*** %s ***", buf+8);
PUTSTR(msg);
Enter(3);
}
return FALSE;
}

View File

@ -36,6 +36,243 @@
#include "timeout.h"
#include "language.h"
#include "term.h"
#include "ttyio.h"
/*
* Wait for a character for a maximum of wtime * 10 mSec.
*/
int Waitchar(unsigned char *ch, int wtime)
{
int i, rc = TIMEOUT;
for (i = 0; i < wtime; i++) {
rc = GETCHAR(0);
// Syslog('t', "Waitchar(): after GETCHAR() tty_status = %d, rc = %d", tty_status, rc);
if (tty_status == STAT_SUCCESS) {
// Syslog('t', "Waitchar(): return %d", rc);
memcpy(ch, &rc, sizeof(unsigned char));
return 1;
}
if (tty_status != STAT_TIMEOUT) {
Syslog('t', "Waitchar(): error rc=%d", rc);
return rc;
}
msleep(10);
}
// Syslog('t', "Waitchar() timeout returns %d", rc);
return rc;
}
int Escapechar(unsigned char *ch)
{
int rc;
unsigned char c;
/*
* Escape character, if nothing follows within
* 50 mSec, the user really pressed <esc>.
*/
if ((rc = Waitchar(ch, 5)) == TIMEOUT)
return rc;
if (*ch == '[') {
/*
* Start of CSI sequence. If nothing follows,
* return immediatly.
*/
if ((rc = Waitchar(ch, 5)) == TIMEOUT)
return rc;
/*
* Test for the most important keys. Note
* that only the cursor movement keys are
* guaranteed to work with PC-clients.
*/
c = *ch;
if (c == 'A')
c = KEY_UP;
if (c == 'B')
c = KEY_DOWN;
if (c == 'C')
c = KEY_RIGHT;
if (c == 'D')
c = KEY_LEFT;
if ((c == '1') || (c == 'H') || (c == 0))
c = KEY_HOME;
if ((c == '4') || (c == 'K') || (c == 101) || (c == 144))
c = KEY_END;
if (c == '2')
c = KEY_INS;
if (c == '3')
c = KEY_DEL;
if (c == '5')
c = KEY_PGUP;
if (c == '6')
c = KEY_PGDN;
memcpy(ch, &c, sizeof(unsigned char));
return rc;
}
return -1;
}
/*
* This next function will detect the grey keys on the keyboard for
* VT100, VT220, Xterm, PC-ANSI, and Linux console. Works with
* several terminals on serial lines (tested 1200 bps).
* If for example cursur keys are detected, this function returns
* a translated value.
*/
unsigned char Readkey(void)
{
unsigned char ch = 0;
int rc = TIMEOUT;
Syslog('t', "Readkey()");
while (rc == TIMEOUT) {
rc = Waitchar(&ch, 5);
// Syslog('t', "rc = %d, ch = %d", rc, ch);
/*
* If the character is not an Escape character,
* then this function is finished.
*/
if ((rc == 1) && (ch != KEY_ESCAPE)) {
Syslog('t', "Readkey() returns %d", ch);
return ch;
}
if ((rc == 1) && (ch == KEY_ESCAPE)) {
rc = Escapechar(&ch);
if (rc == 1) {
Syslog('t', "Readkey() returns %d", ch);
return ch;
} else {
Syslog('t', "Readkey() returns %d", KEY_ESCAPE);
return KEY_ESCAPE;
}
}
}
Syslog('t', "Readkey() returns %d", rc);
return rc;
}
/*
* Read the (locked) speed from the tty
*/
long Speed(void)
{
speed_t mspeed;
mspeed = cfgetospeed(&tbufs);
#ifdef CBAUD
switch (mspeed & CBAUD) {
#else
switch (mspeed) {
#endif
case B0: return 0;
#if defined(B50)
case B50: return 50;
#endif
#if defined(B75)
case B75: return 75;
#endif
#if defined(B110)
case B110: return 110;
#endif
#if defined(B134)
case B134: return 134;
#endif
#if defined(B150)
case B150: return 150;
#endif
#if defined(B200)
case B200: return 200;
#endif
#if defined(B300)
case B300: return 300;
#endif
#if defined(B600)
case B600: return 600;
#endif
#if defined(B1200)
case B1200: return 1200;
#endif
#if defined(B1800)
case B1800: return 1800;
#endif
#if defined(B2400)
case B2400: return 2400;
#endif
#if defined(B4800)
case B4800: return 4800;
#endif
#if defined(B9600)
case B9600: return 9600;
#endif
#if defined(B19200)
case B19200: return 19200;
#endif
#if defined(B38400)
case B38400: return 38400;
#endif
#if defined(B57600)
case B57600: return 57600;
#endif
#if defined(B115200)
case B115200: return 115200;
#endif
#if defined(B230400)
case B230400: return 203400;
#endif
#if defined(B460800)
case B460800: return 460800;
#endif
#if defined(B500000)
case B500000: return 500000;
#endif
#if defined(B576000)
case B576000: return 576000;
#endif
#if defined(B921600)
case B921600: return 921600;
#endif
#if defined(B1000000)
case B1000000: return 1000000;
#endif
#if defined(B1152000)
case B1152000: return 1152000;
#endif
#if defined(B1500000)
case B1500000: return 1500000;
#endif
#if defined(B2000000)
case B2000000: return 2000000;
#endif
#if defined(B2500000)
case B2500000: return 2500000;
#endif
#if defined(B3000000)
case B3000000: return 3000000;
#endif
#if defined(B3500000)
case B3500000: return 3500000;
#endif
#if defined(B4000000)
case B4000000: return 4000000;
#endif
default: return 9600;
}
}
@ -56,6 +293,16 @@ int traduce(char *ch)
}
void BackErase(void)
{
PUTCHAR('\b');
PUTCHAR(' ');
PUTCHAR('\b');
}
/*
* Get a character string with cursor position
*/
@ -64,40 +311,34 @@ void GetstrP(char *sStr, int iMaxLen, int Position)
unsigned char ch = 0;
int iPos = Position;
if ((ttyfd = open("/dev/tty", O_RDWR|O_NONBLOCK)) < 0) {
perror("open 1");
return;
}
Setraw();
FLUSHIN();
alarm_on();
while (ch != KEY_ENTER) {
fflush(stdout);
ch = Readkey();
if ((ch == KEY_BACKSPACE) || (ch == KEY_DEL) || (ch == KEY_RUBOUT)) {
if (iPos > 0) {
printf("\b \b");
BackErase();
sStr[--iPos] = '\0';
} else
putchar('\007');
PUTCHAR('\007');
}
if ((ch > 31 && ch < 127) || traduce(&ch)) {
if (iPos <= iMaxLen) {
iPos++;
sprintf(sStr, "%s%c", sStr, ch);
printf("%c", ch);
} else
putchar('\007');
PUTCHAR(ch);
} else {
PUTCHAR('\007');
}
}
}
Unsetraw();
close(ttyfd);
printf("\n");
PUTCHAR('\r');
PUTCHAR('\n');
}
@ -110,42 +351,34 @@ void GetstrC(char *sStr, int iMaxlen)
unsigned char ch = 0;
int iPos = 0;
fflush(stdout);
if ((ttyfd = open ("/dev/tty", O_RDWR|O_NONBLOCK)) < 0) {
perror("open 6");
return;
}
Setraw();
FLUSHIN();
strcpy(sStr, "");
alarm_on();
while (ch != 13) {
fflush(stdout);
ch = Readkey();
if ((ch == 8) || (ch == KEY_DEL) || (ch == 127)) {
if (iPos > 0) {
printf("\b \b");
BackErase();
sStr[--iPos] = '\0';
} else
putchar('\007');
PUTCHAR('\007');
}
if ((ch > 31) && (ch < 127) && (ch != ',')) {
if (iPos <= iMaxlen) {
iPos++;
sprintf(sStr, "%s%c", sStr, ch);
printf("%c", ch);
PUTCHAR(ch);
} else
putchar('\007');
PUTCHAR('\007');
}
}
Unsetraw();
close(ttyfd);
printf("\n");
PUTCHAR('\r');
PUTCHAR('\n');
}
@ -158,42 +391,34 @@ void GetstrU(char *sStr, int iMaxlen)
unsigned char ch = 0;
int iPos = 0;
fflush(stdout);
if ((ttyfd = open ("/dev/tty", O_RDWR|O_NONBLOCK)) < 0) {
perror("open 6");
return;
}
Setraw();
FLUSHIN();
strcpy(sStr, "");
alarm_on();
while (ch != 13) {
fflush(stdout);
ch = Readkey();
if ((ch == 8) || (ch == KEY_DEL) || (ch == 127)) {
if (iPos > 0) {
printf("\b \b");
BackErase();
sStr[--iPos] = '\0';
} else
putchar('\007');
PUTCHAR('\007');
}
if (isalnum(ch) || (ch == '@') || (ch == '.') || (ch == '-') || (ch == '_')) {
if (iPos <= iMaxlen) {
iPos++;
sprintf(sStr, "%s%c", sStr, ch);
printf("%c", ch);
PUTCHAR(ch);
} else
putchar('\007');
PUTCHAR('\007');
}
}
Unsetraw();
close(ttyfd);
printf("\n");
PUTCHAR('\r');
PUTCHAR('\n');
}
@ -206,43 +431,35 @@ void GetPhone(char *sStr, int iMaxlen)
unsigned char ch = 0;
int iPos = 0;
fflush(stdout);
if ((ttyfd = open ("/dev/tty", O_RDWR|O_NONBLOCK)) < 0) {
perror("open 5");
return;
}
Setraw();
FLUSHIN();
strcpy(sStr, "");
alarm_on();
while (ch != 13) {
fflush(stdout);
ch = Readkey();
if ((ch == 8) || (ch == KEY_DEL) || (ch == 127)) {
if (iPos > 0) {
printf("\b \b");
BackErase();
sStr[--iPos]='\0';
} else
putchar('\007');
PUTCHAR('\007');
}
if ((ch >= '0' && ch <= '9') || (ch == '-') || (ch == '+')) {
if (iPos <= iMaxlen) {
iPos++;
sprintf(sStr, "%s%c", sStr, ch);
printf("%c", ch);
PUTCHAR(ch);
} else
putchar('\007');
PUTCHAR('\007');
}
}
Unsetraw();
close(ttyfd);
printf("\n");
PUTCHAR('\r');
PUTCHAR('\n');
}
@ -255,45 +472,36 @@ void Getnum(char *sStr, int iMaxlen)
unsigned char ch = 0;
int iPos = 0;
fflush(stdout);
if ((ttyfd = open ("/dev/tty", O_RDWR|O_NONBLOCK)) < 0) {
perror("open 5");
return;
}
Setraw();
FLUSHIN();
strcpy(sStr, "");
alarm_on();
while (ch != 13) {
fflush(stdout);
ch = Readkey();
if ((ch == 8) || (ch == KEY_DEL) || (ch == 127)) {
if (iPos > 0) {
printf("\b \b");
BackErase();
sStr[--iPos]='\0';
} else
putchar('\007');
PUTCHAR('\007');
}
if ((ch >= '0' && ch <= '9') || (ch == '-') || (ch == ' ') \
|| (ch == ',') || (ch == '.')) {
if ((ch >= '0' && ch <= '9') || (ch == '-') || (ch == ' ') || (ch == ',') || (ch == '.')) {
if (iPos <= iMaxlen) {
iPos++;
sprintf(sStr, "%s%c", sStr, ch);
printf("%c", ch);
PUTCHAR(ch);
} else
putchar('\007');
PUTCHAR('\007');
}
}
Unsetraw();
close(ttyfd);
printf("\n");
PUTCHAR('\r');
PUTCHAR('\n');
}
@ -307,30 +515,22 @@ void GetDate(char *sStr, int iMaxlen)
unsigned char ch = 0;
int iPos = 0;
fflush(stdout);
FLUSHIN();
strcpy(sStr, "");
if ((ttyfd = open ("/dev/tty", O_RDWR|O_NONBLOCK)) < 0) {
perror("open 4");
return;
}
Setraw();
alarm_on();
while (ch != 13) {
fflush(stdout);
ch = Readkey();
if ((ch == 8) || (ch == KEY_DEL) || (ch == 127)) {
if (iPos > 0)
printf("\b \b");
BackErase();
else
putchar('\007');
PUTCHAR('\007');
if (iPos == 3 || iPos == 6) {
printf("\b \b");
BackErase();
--iPos;
}
@ -341,20 +541,19 @@ void GetDate(char *sStr, int iMaxlen)
if (iPos < iMaxlen) {
iPos++;
sprintf(sStr, "%s%c", sStr, ch);
printf("%c", ch);
PUTCHAR(ch);
if (iPos == 2 || iPos == 5) {
printf("-");
PUTCHAR('-');
sprintf(sStr, "%s-", sStr);
iPos++;
}
} else
putchar('\007');
PUTCHAR('\007');
}
}
Unsetraw();
close(ttyfd);
printf("\n");
PUTCHAR('\r');
PUTCHAR('\n');
}
@ -371,11 +570,6 @@ void Getname(char *sStr, int iMaxlen)
strcpy(sStr, "");
if ((ttyfd = open ("/dev/tty", O_RDWR|O_NONBLOCK)) < 0) {
perror("open 2");
return;
}
Setraw();
alarm_on();
while (ch != 13) {
@ -418,8 +612,6 @@ void Getname(char *sStr, int iMaxlen)
}
}
Unsetraw();
close(ttyfd);
printf("\n");
}
@ -438,11 +630,6 @@ void GetnameNE(char *sStr, int iMaxlen)
strcpy(sStr, "");
if ((ttyfd = open ("/dev/tty", O_RDWR|O_NONBLOCK)) < 0) {
perror("open 2");
return;
}
Setraw();
alarm_on();
while (ch != 13) {
@ -485,8 +672,6 @@ void GetnameNE(char *sStr, int iMaxlen)
}
}
Unsetraw();
close(ttyfd);
printf("\n");
}
@ -504,17 +689,6 @@ void Getpass(char *theword)
int counter = 0;
char password[Max_passlen+1];
/*
* Open the device that we want to read the password from, you can't use
* stdin as this might change in a pipe
*/
if ((ttyfd = open ("/dev/tty", O_RDWR)) < 0) {
perror("open 7");
ExitClient(MBERR_TTYIO_ERROR);
}
/* Set Raw mode so that the characters don't echo */
Setraw();
alarm_on();
/*
@ -543,8 +717,6 @@ void Getpass(char *theword)
printf("%c", CFG.iPasswd_Char);
}
}
Unsetraw(); /* Go normal */
close(ttyfd);
password[counter] = '\0'; /* Make sure the string has a NULL at the end*/
strcpy(theword,password);
@ -562,23 +734,20 @@ void Pause()
/* Press (Enter) to continue: */
sprintf(string, "\r%s", (char *) Language(375));
colour(CFG.CRColourF, CFG.CRColourB);
printf(string);
PUTSTR(string);
do {
fflush(stdout);
fflush(stdin);
alarm_on();
i = Getone();
i = Readkey();
} while ((i != '\r') && (i != '\n'));
x = strlen(string);
for(i = 0; i < x; i++)
printf("\b");
PUTCHAR('\b');
for(i = 0; i < x; i++)
printf(" ");
PUTCHAR(' ');
for(i = 0; i < x; i++)
printf("\b");
fflush(stdout);
PUTCHAR('\b');
free(string);
}

View File

@ -4,6 +4,13 @@
#define _INPUT_H
long Speed(void); /* Get (locked) tty speed */
int Waitchar(unsigned char *, int); /* Wait n* 10mSec for char */
int Escapechar(unsigned char *); /* Escape sequence test */
unsigned char Readkey(void); /* Read a translated key */
void BackErase(void); /* Send backspace with erase */
void GetstrU(char *, int); /* Get string, forbid spaces */
void GetstrP(char *, int, int); /* Get string with cursor position */
void GetstrC(char *, int); /* Get string, length, clear string */

View File

@ -35,7 +35,7 @@
#include "input.h"
#include "language.h"
#include "term.h"
#include "ttyio.h"
/*
@ -92,7 +92,9 @@ void Set_Language(int iLanguage)
if ((pLang = fopen(temp, "rb")) == NULL) {
WriteError("Language: Can't open file: %s", temp);
printf("\nLanguage: Can't open language file\n\n");
Enter(1);
PUTSTR((char *)"Language: Can't open language file");
Enter(2);
free(temp);
Pause();
return;
@ -137,8 +139,10 @@ void InitLanguage()
strcpy(mKeystroke[iLang], ldata.sKey);
iLang++;
if(iLang >= LANG) {
printf("FATAL: Language file has to many lines in it");
if (iLang >= LANG) {
Enter(1);
PUTSTR((char *)"FATAL: Language file has to many lines in it");
Enter(2);
ExitClient(MBERR_INIT_ERROR);
}
}

View File

@ -36,6 +36,7 @@
#include "language.h"
#include "lastcallers.h"
#include "term.h"
#include "ttyio.h"
/*
@ -86,7 +87,7 @@ void LastCallers(char *OpData)
colour(LIGHTRED, BLACK);
Center(Underline);
printf("\n");
Enter(1);
/* # User Name Device timeOn Calls Location */
pout(LIGHTGREEN, BLACK, (char *) Language(85));
@ -100,31 +101,34 @@ void LastCallers(char *OpData)
count++;
colour(WHITE, BLACK);
printf("%-5d", count);
sprintf(Heading, "%-5d", count);
PUTSTR(Heading);
colour(LIGHTCYAN, BLACK);
if ((strcasecmp(OpData, "/H")) == 0) {
if ((strcmp(lcall.Handle, "") != 0 && *(lcall.Handle) != ' '))
printf("%-20s", lcall.Handle);
sprintf(Heading, "%-20s", lcall.Handle);
else
printf("%-20s", lcall.UserName);
sprintf(Heading, "%-20s", lcall.UserName);
} else if (strcasecmp(OpData, "/U") == 0) {
printf("%-20s", lcall.Name);
sprintf(Heading, "%-20s", lcall.Name);
} else {
printf("%-20s", lcall.UserName);
sprintf(Heading, "%-20s", lcall.UserName);
}
PUTSTR(Heading);
colour(LIGHTBLUE, BLACK);
printf("%-8s", lcall.Device);
sprintf(Heading, "%-8s", lcall.Device);
pout(LIGHTBLUE, BLACK, Heading);
colour(LIGHTMAGENTA, BLACK);
printf("%-8s", lcall.TimeOn);
sprintf(Heading, "%-8s", lcall.TimeOn);
pout(LIGHTMAGENTA, BLACK, Heading);
colour(YELLOW, BLACK);
printf("%-7d", lcall.Calls);
sprintf(Heading, "%-7d", lcall.Calls);
pout(YELLOW, BLACK, Heading);
colour(LIGHTRED, BLACK);
printf("%-32s\n", lcall.Location);
sprintf(Heading, "%-32s", lcall.Location);
pout(LIGHTRED, BLACK, Heading);
Enter(1);
LineCount++;
if (LineCount == exitinfo.iScreenLen) {
@ -138,7 +142,7 @@ void LastCallers(char *OpData)
fLine(79);
fclose(pLC);
printf("\n");
Enter(1);
Pause();
}
free(sFileName);

View File

@ -38,6 +38,7 @@
#include "timeout.h"
#include "lineedit.h"
#include "term.h"
#include "ttyio.h"
extern int Line;
@ -60,30 +61,31 @@ void Line_Edit_Center(void); /* Center a line */
void Line_Edit_Append()
{
if((Line - 1) == TEXTBUFSIZE) {
char msg[41];
if ((Line - 1) == TEXTBUFSIZE) {
Enter(1);
/* Maximum message length exceeded */
pout(3, 0, (char *) Language(166));
pout(CYAN, BLACK, (char *) Language(166));
Enter(1);
return;
}
while (TRUE) {
colour(10, 0);
printf("%-2d : ", Line);
sprintf(msg, "%-2d : ", Line);
pout(LIGHTGREEN, BLACK, msg);
colour(CFG.MsgInputColourF, CFG.MsgInputColourB);
fflush(stdout);
alarm_on();
GetstrP(Message[Line], 72, 0);
if((strcmp(Message[Line], "")) == 0)
if ((strcmp(Message[Line], "")) == 0)
return;
Line++;
if((Line - 1) == TEXTBUFSIZE) {
if ((Line - 1) == TEXTBUFSIZE) {
Enter(1);
/* Maximum message length exceeded */
pout(12, 0, (char *) Language(166));
pout(LIGHTRED, BLACK, (char *) Language(166));
Enter(1);
return;
}
@ -94,54 +96,56 @@ void Line_Edit_Append()
void Line_Edit_Delete()
{
int i, start, end = 0, total;
int Loop;
int i, start, end = 0, total, Loop;
char temp[81];
while (TRUE) {
colour(10, 0);
Enter(2);
/* Delete starting at line */
printf("\n\n%s#(1 - %d): ", (char *) Language(176), (Line - 1) );
sprintf(temp, "%s#(1 - %d): ", (char *) Language(176), (Line - 1) );
pout(LIGHTGREEN, BLACK, temp);
colour(CFG.InputColourF, CFG.InputColourB);
GetstrC(temp, 80);
if((strcmp(temp, "")) == 0) {
if ((strcmp(temp, "")) == 0) {
/* Aborted. */
pout(15, 0, (char *) Language(177));
pout(WHITE, BLACK, (char *) Language(177));
Enter(1);
return;
}
start = atoi(temp);
colour(10, 0);
if(start > (Line - 1) )
if (start > (Line - 1)) {
Enter(1);
/* Please enter a number in the range of */
printf("\n%s(1 - %d)", (char *) Language(178), (Line - 1) );
else
sprintf(temp, "%s(1 - %d)", (char *) Language(178), (Line - 1) );
pout(LIGHTGREEN, BLACK, temp);
} else
break;
}
while (TRUE) {
colour(10, 0);
/* Delete ending at line */
printf("%s# (1 - %d): ", (char *) Language(179), (Line - 1) );
sprintf(temp, "%s# (1 - %d): ", (char *) Language(179), (Line - 1) );
pout(LIGHTGREEN, BLACK, temp);
colour(CFG.InputColourF, CFG.InputColourB);
GetstrC(temp, 80);
if((strcmp(temp, "")) == 0) {
if ((strcmp(temp, "")) == 0) {
/* Aborted. */
pout(15, 0, (char *) Language(176));
pout(WHITE, BLACK, (char *) Language(176));
Enter(1);
return;
}
end = atoi(temp);
colour(10, 0);
if(end > (Line - 1))
if(end > (Line - 1)) {
Enter(1);
/* Please enter a number in the range of */
printf("\n%s(1 - %d)\n\n", (char *) Language(179), (Line - 1) );
else
sprintf(temp, "%s(1 - %d)", (char *) Language(179), (Line - 1) );
pout(LIGHTGREEN, BLACK, temp);
Enter(2);
} else
break;
}
/* Get total by minusing the end line from the start line */
@ -173,33 +177,35 @@ void Line_Edit_Edit()
while (TRUE) {
while (TRUE) {
colour(10, 0);
Enter(1);
/* Enter line # to edit */
printf("\n%s(1 - %d): ", (char *) Language(181), (Line - 1) );
sprintf(temp, "%s(1 - %d): ", (char *) Language(181), (Line - 1) );
pout(LIGHTGREEN, BLACK, temp);
colour(CFG.InputColourF, CFG.InputColourB);
GetstrC(temp, 80);
if((strcmp(temp, "")) == 0)
if ((strcmp(temp, "")) == 0)
return;
edit = atoi(temp);
colour(10, 0);
if(edit > Line)
if (edit > Line) {
Enter(1);
/* Please enter a number in the range of */
printf("\n%s(1 - %d) ", (char *) Language(178), (Line - 1) );
else
sprintf(temp, "%s(1 - %d) ", (char *) Language(178), (Line - 1) );
pout(LIGHTGREEN, BLACK, temp);
} else
break;
}
colour(10, 0);
printf("\n%d : ", edit);
Enter(1);
sprintf(temp, "%d : ", edit);
pout(LIGHTGREEN, BLACK, temp);
colour(CFG.MsgInputColourF, CFG.MsgInputColourB);
printf("%s", Message[edit]);
fflush(stdout);
PUTSTR(Message[edit]);
j = strlen(Message[edit]);
colour(CFG.MsgInputColourF, CFG.MsgInputColourB);
alarm_on();
GetstrP(Message[edit], 81, j);
GetstrP(Message[edit], 80, j);
}
}
@ -210,43 +216,46 @@ void Line_Edit_Insert()
int i, j, start, end = 0, total;
char temp[81];
if((Line - 1) == TEXTBUFSIZE) {
if ((Line - 1) == TEXTBUFSIZE) {
Enter(1);
/* Maximum message length exceeded */
pout(3, 0, (char *) Language(166));
pout(CYAN, BLACK, (char *) Language(166));
Enter(1);
return;
}
while (TRUE) {
colour(10, 0);
Enter(2);
/* Enter line # to insert text before */
printf("\n\n%s(1 - %d): ", (char *) Language(183), (Line - 1));
sprintf(temp, "%s(1 - %d): ", (char *) Language(183), (Line - 1));
pout(LIGHTGREEN, BLACK, temp);
colour(CFG.InputColourF, CFG.InputColourB);
GetstrC(temp, 80);
if((strcmp(temp, "")) == 0) {
if ((strcmp(temp, "")) == 0) {
/* Aborted. */
pout(15, 0, (char *) Language(177));
pout(WHITE, BLACK, (char *) Language(177));
return;
}
start = atoi(temp);
colour(10, 0);
if(start > (Line - 1))
if (start > (Line - 1)) {
Enter(1);
/* Please enter a number in the range of */
printf("\n%s(1 - %d)", (char *) Language(178), (Line - 1));
else
sprintf(temp, "%s(1 - %d)", (char *) Language(178), (Line - 1));
pout(LIGHTGREEN, BLACK, temp);
} else
break;
}
Enter(1);
j = start;
colour(10, 0);
printf("\n%-2d : ", start);
sprintf(temp, "%-2d : ", start);
pout(LIGHTGREEN, BLACK, temp);
colour(CFG.MsgInputColourF, CFG.MsgInputColourB);
GetstrC(temp, 80);
if((strcmp(temp, "")) == 0)
if ((strcmp(temp, "")) == 0)
return;
total = Line - start;
@ -272,56 +281,59 @@ void Line_Edit_Replace()
while (TRUE) {
while (TRUE) {
colour(10, 0);
Enter(2);
/* Enter line # to replace */
printf("\n\n%s(1 - %d): ", (char *) Language(185), (Line - 1) );
sprintf(temp, "%s(1 - %d): ", (char *) Language(185), (Line - 1) );
pout(LIGHTGREEN, BLACK, temp);
colour(CFG.InputColourF, CFG.InputColourB);
GetstrC(temp, 80);
if((strcmp(temp, "")) == 0)
if ((strcmp(temp, "")) == 0)
return;
edit = atoi(temp);
colour(10, 0);
if(edit > Line)
if (edit > Line) {
Enter(1);
/* Please enter a number in the range of */
printf("\n%s(1 - %d) ", (char *) Language(178), (Line - 1));
else
sprintf(temp, "%s(1 - %d) ", (char *) Language(178), (Line - 1));
pout(LIGHTGREEN, BLACK, temp);
} else
break;
}
Enter(1);
/* Line reads: */
pout(15, 0, (char *) Language(186));
pout(WHITE, BLACK, (char *) Language(186));
Enter(1);
colour(10, 0);
printf("%d : ", edit);
sprintf(temp, "%d : ", edit);
pout(LIGHTGREEN, BLACK, temp);
colour(CFG.MsgInputColourF, CFG.MsgInputColourB);
printf("%s\n\n", Message[edit]);
PUTSTR(Message[edit]);
Enter(2);
colour(10, 0);
printf("%d : ", edit);
sprintf(temp, "%d : ", edit);
pout(LIGHTGREEN, BLACK, temp);
colour(CFG.MsgInputColourF, CFG.MsgInputColourB);
GetstrC(temp, 80);
if((strcmp(temp, "")) == 0) {
if ((strcmp(temp, "")) == 0) {
Enter(1);
/* Unchanged. */
pout(15, 0, (char *) Language(187));
pout(WHITE, BLACK, (char *) Language(187));
Enter(1);
} else
strcpy(Message[edit], temp);
Enter(1);
/* Line now reads: */
pout(15, 0, (char *) Language(188));
pout(WHITE, BLACK, (char *) Language(188));
Enter(1);
colour(10, 0);
printf("%d : ", edit);
sprintf(temp, "%d : ", edit);
pout(LIGHTGREEN, BLACK, temp);
colour(CFG.MsgInputColourF, CFG.MsgInputColourB);
printf("%s", Message[edit]);
PUTSTR(Message[edit]);
}
}
@ -330,44 +342,46 @@ void Line_Edit_Replace()
void Line_Edit_Text()
{
int edit;
char temp[81];
char temp1[81];
char temp[81], temp1[81];
while (TRUE) {
while (TRUE) {
colour(10, 0);
Enter(2);
/* Enter line # to edit */
printf("\n\n%s(1 - %d): ", (char *) Language(194), (Line - 1));
sprintf(temp, "%s(1 - %d): ", (char *) Language(194), (Line - 1));
pout(LIGHTGREEN, BLACK, temp);
colour(CFG.InputColourF, CFG.InputColourB);
GetstrC(temp, 80);
if((strcmp(temp, "")) == 0)
if ((strcmp(temp, "")) == 0)
return;
edit = atoi(temp);
colour(10, 0);
if(edit > Line)
if (edit > Line) {
Enter(1);
/* Please enter a number in the range of */
printf("\n%s(1 - %d) ", (char *) Language(178), (Line - 1) );
else
sprintf(temp, "%s(1 - %d) ", (char *) Language(178), (Line - 1) );
pout(LIGHTGREEN, BLACK, temp);
} else
break;
}
Enter(1);
/* Line reads: */
pout(15, 0, (char *) Language(186));
pout(WHITE, BLACK, (char *) Language(186));
Enter(1);
colour(10, 0);
printf("%d : ", edit);
sprintf(temp, "%d : ", edit);
pout(LIGHTGREEN, BLACK, temp);
colour(CFG.MsgInputColourF, CFG.MsgInputColourB);
printf("%s\n\n", Message[edit]);
PUTSTR(Message[edit]);
Enter(2);
/* Text to replace: */
pout(10, 0, (char *) Language(195));
pout(LIGHTGREEN, BLACK, (char *) Language(195));
colour(CFG.InputColourF, CFG.InputColourB);
GetstrC(temp, 80);
/* Replacement text: */
pout(10, 0, (char *) Language(196));
pout(LIGHTGREEN, BLACK, (char *) Language(196));
colour(CFG.InputColourF, CFG.InputColourB);
GetstrC(temp1, 80);
@ -375,12 +389,12 @@ void Line_Edit_Text()
Enter(1);
/* Line now reads: */
pout(15, 0, (char *) Language(197));
pout(WHITE, BLACK, (char *) Language(197));
Enter(1);
colour(10, 0);
printf("%d : ", edit);
sprintf(temp, "%d : ", edit);
pout(LIGHTGREEN, BLACK, temp);
colour(CFG.MsgInputColourF, CFG.MsgInputColourB);
printf("%s", Message[edit]);
PUTSTR(Message[edit]);
}
}
@ -388,36 +402,38 @@ void Line_Edit_Text()
void Line_Edit_Center()
{
int i, j, z, center;
int maxlen = 78;
char *CEnter;
char temp[81];
int i, j, z, center, maxlen = 78;
char *CEnter, temp[81];
colour(15, 0);
Enter(2);
/* Enter line # to center */
printf("\n\n%s(1 - %d): ", (char *) Language(203), (Line - 1));
fflush(stdout);
sprintf(temp, "%s(1 - %d): ", (char *) Language(203), (Line - 1));
pout(WHITE, BLACK, temp);
GetstrC(temp, 80);
if((strcmp(temp, "")) == 0)
if ((strcmp(temp, "")) == 0)
return;
CEnter = calloc(81, sizeof(char));
center = atoi(temp);
j = strlen(Message[center]);
if (j >= maxlen)
if (j >= maxlen) {
Enter(1);
/* Line is maximum length and cannot be centered */
printf("\n%s\n", (char *) Language(204));
else {
pout(LIGHTGREEN, BLACK, (char *) Language(204));
Enter(1);
} else {
z = 35 - (j / 2);
for(i = 0; i < z; i++)
for (i = 0; i < z; i++)
strcat(CEnter," ");
strcat(CEnter, Message[center]);
strcpy(Message[center], CEnter);
}
Enter(1);
colour(CFG.MsgInputColourF, CFG.MsgInputColourB);
printf("\n%s\n", Message[center]);
PUTSTR(Message[center]);
Enter(1);
free(CEnter);
}
@ -426,146 +442,131 @@ void Line_Edit_Center()
int Line_Edit()
{
int i, j;
char msg[81];
clear();
colour(12, 0);
colour(LIGHTRED, BLACK);
/* Begin your message now, Blank line to end */
Center((char *) Language(164));
/* Maximum of TEXTBUFSIZE lines, 73 chars per line */
Center((char *) Language(165));
colour(14, 0);
printf(" (");
colour(YELLOW, BLACK);
PUTSTR((char *)" (");
for (i = 0; i < 74; i++)
printf("-");
printf(")\n");
PUTSTR((char *)"-");
PUTSTR((char *)")");
Enter(1);
Line_Edit_Append();
while (TRUE) {
colour(14, 0);
/* Functions available: (Current Message: */
printf("\n%s%d ", (char *) Language(167), (Line - 1));
/* Lines) */
printf("%s\n\n", (char *) Language(168));
colour(11, 0);
Enter(1);
/* Functions available: (Current Message: */ /* Lines) */
sprintf(msg, "%s%d %s", (char *) Language(167), (Line - 1), (char *) Language(168));
pout(YELLOW, BLACK, msg);
Enter(2);
/* L - List message S - Save message C - Continue message */
printf("%s\n", (char *) Language(169));
pout(LIGHTCYAN, BLACK, (char *) Language(169));
Enter(1);
/* Q - Quit message D - Delete line I - Insert line */
printf("%s\n", (char *) Language(170));
pout(LIGHTCYAN, BLACK, (char *) Language(170));
Enter(1);
/* T - Text edit E - Edit line R - Replace line */
printf("%s\n", (char *) Language(171));
pout(LIGHTCYAN, BLACK, (char *) Language(171));
Enter(1);
/* Z - Center line */
printf("%s\n", (char *) Language(172));
pout(LIGHTCYAN, BLACK, (char *) Language(172));
Enter(2);
colour(15, 0);
printf("\n%s [", (char *) Language(173));
sprintf(msg, "%s [", (char *) Language(173));
pout(WHITE, BLACK, msg);
for (i = 0; i < 10; i++)
putchar(Keystroke(172, i));
printf("]: ");
fflush(stdout);
PUTCHAR(Keystroke(172, i));
PUTSTR((char *)"]: ");
alarm_on();
j = toupper(Getone());
j = toupper(Readkey());
if (j == Keystroke(172, 2)) {
/* Continue */
pout(15, 0, (char *) Language(174));
pout(WHITE, BLACK, (char *) Language(174));
Enter(1);
Line_Edit_Append();
} else
if (j == Keystroke(172, 4)) {
} else if (j == Keystroke(172, 4)) {
/* Delete */
pout(15, 0, (char *) Language(175));
pout(WHITE, BLACK, (char *) Language(175));
Enter(1);
Line_Edit_Delete();
} else
if (j == Keystroke(172, 7)) {
} else if (j == Keystroke(172, 7)) {
/* Edit */
pout(15, 0, (char *) Language(180));
pout(WHITE, BLACK, (char *) Language(180));
Enter(1);
Line_Edit_Edit();
} else
if (j == Keystroke(172, 5)) {
} else if (j == Keystroke(172, 5)) {
/* Insert */
pout(15, 0, (char *) Language(182));
pout(WHITE, BLACK, (char *) Language(182));
Enter(1);
Line_Edit_Insert();
} else
if (j == Keystroke(172, 0)) {
pout(15, 0, (char *) Language(184));
} else if (j == Keystroke(172, 0)) {
pout(WHITE, BLACK, (char *) Language(184));
Enter(2);
for(i = 1; i < Line; i++) {
colour(10, 0);
printf("%d: ", i);
for (i = 1; i < Line; i++) {
sprintf(msg, "%d: ", i);
pout(LIGHTGREEN, BLACK, msg);
colour(CFG.MsgInputColourF, CFG.MsgInputColourB);
printf("%s\n", Message[i]);
PUTSTR(Message[i]);
Enter(1);
}
} else
if (j == Keystroke(172, 8)) {
} else if (j == Keystroke(172, 8)) {
/* Replace */
pout(15, 0, (char *) Language(362));
pout(WHITE, BLACK, (char *) Language(362));
Enter(1);
Line_Edit_Replace();
} else
if (j == Keystroke(172, 3)) {
} else if (j == Keystroke(172, 3)) {
/* Quit */
pout(15, 0, (char *) Language(189));
pout(WHITE, BLACK, (char *) Language(189));
Enter(2);
/* Are you sure [y/N] */
printf("%s", (char *) Language(190));
fflush(stdout);
PUTSTR((char *) Language(190));
alarm_on();
if (toupper(Getone()) == Keystroke(190, 0)) {
if (toupper(Readkey()) == Keystroke(190, 0)) {
/* Yes */
pout(CFG.HiliteF, CFG.HiliteB, (char *) Language(356));
Enter(1);
/* Message aborted. */
pout(15, 0, (char *) Language(191));
pout(WHITE, BLACK, (char *) Language(191));
Enter(2);
fflush(stdout);
sleep(1);
return FALSE;
}
colour(CFG.HiliteF, CFG.HiliteB);
/* No */
printf("%s\n", (char *) Language(192));
} else
if (j == Keystroke(172, 6)) {
/* Text Edit */
pout(15, 0, (char *) Language(193));
Line_Edit_Text();
} else
if (j == Keystroke(172, 1)) {
/* Save */
pout(15, 0, (char *) Language(198));
pout(CFG.HiliteF, CFG.HiliteB, (char *) Language(192));
Enter(1);
} else if (j == Keystroke(172, 6)) {
/* Text Edit */
pout(WHITE, BLACK, (char *) Language(193));
Line_Edit_Text();
} else if (j == Keystroke(172, 1)) {
/* Save */
pout(WHITE, BLACK, (char *) Language(198));
Enter(1);
fflush(stdout);
if (Line > 1)
return TRUE;
return FALSE;
} else
if (j == Keystroke(172, 9)) {
} else if (j == Keystroke(172, 9)) {
/* Center */
pout(15, 0, (char *) Language(376));
pout(WHITE, BLACK, (char *) Language(376));
Enter(1);
Line_Edit_Center();
}

File diff suppressed because it is too large Load Diff

View File

@ -40,7 +40,8 @@
#include "timeout.h"
#include "newuser.h"
#include "term.h"
#include "ttyio.h"
#include "openport.h"
extern int do_quiet; /* Logging quiet flag */
@ -52,10 +53,9 @@ int main(int argc, char **argv)
{
char *p, *tty, temp[PATH_MAX];
FILE *pTty;
int i;
int i, rc = 0;
struct passwd *pw;
printf("\n\nLoading MBSE BBS New User Registration ...\n\n");
pTTY = calloc(15, sizeof(char));
tty = ttyname(1);
@ -105,6 +105,15 @@ int main(int argc, char **argv)
Syslog(' ', " ");
Syslog(' ', "MBNEWUSR v%s", VERSION);
if ((rc = rawport()) != 0) {
WriteError("Unable to set raw mode");
Fast_Bye(MBERR_OK);;
}
Enter(2);
PUTSTR((char *)"Loading MBSE BBS New User Registration ...");
Enter(2);
if ((p = getenv("CONNECT")) != NULL)
Syslog('+', "CONNECT %s", p);
if ((p = getenv("CALLER_ID")) != NULL)
@ -137,7 +146,7 @@ int main(int argc, char **argv)
* Trap signals
*/
for (i = 0; i < NSIG; i++) {
if ((i == SIGHUP) || (i == SIGBUS) || (i == SIGILL) || (i == SIGSEGV) || (i == SIGTERM) || (i == SIGKILL))
if ((i == SIGHUP) || (i == SIGPIPE) || (i == SIGBUS) || (i == SIGILL) || (i == SIGSEGV) || (i == SIGTERM))
signal(i, (void (*))die);
else if (i == SIGCHLD)
signal(i, SIG_DFL);
@ -160,10 +169,10 @@ int main(int argc, char **argv)
Fast_Bye(MBERR_OK);
}
colour(YELLOW, BLACK);
printf("MBSE BBS v%s (Release: %s) on %s/%s\n", VERSION, ReleaseDate, OsName(), OsCPU());
colour(WHITE, BLACK);
printf("%s\n\n", COPYRIGHT);
sprintf(temp, "MBSE BBS v%s (Release: %s) on %s/%s", VERSION, ReleaseDate, OsName(), OsCPU());
poutCR(YELLOW, BLACK, temp);
pout(WHITE, BLACK, (char *)COPYRIGHT);
Enter(2);
/*
* Check if this port is available.
@ -183,7 +192,8 @@ int main(int argc, char **argv)
if ((strcmp(ttyinfo.tty, pTTY) != 0) || (!ttyinfo.available)) {
Syslog('+', "No BBS allowed on port \"%s\"", pTTY);
printf("No BBS on this port allowed!\n\n");
PUTSTR((char *)"No BBS on this port allowed!");
Enter(2);
Fast_Bye(MBERR_OK);
}
@ -192,10 +202,12 @@ int main(int argc, char **argv)
*/
if (CFG.iConnectString) {
/* Connected on port */
colour(CYAN, BLACK);
printf("%s\"%s\" ", (char *) Language(348), ttyinfo.comment);
sprintf(temp, "%s\"%s\" ", (char *) Language(348), ttyinfo.comment);
pout(CYAN, BLACK, temp);
/* on */
printf("%s %s\n", (char *) Language(135), ctime(&ltime));
sprintf(temp, "%s %s", (char *) Language(135), ctime(&ltime));
PUTSTR(temp);
Enter(1);
}
}

View File

@ -43,6 +43,8 @@
#include "timeout.h"
#include "funcs.h"
#include "term.h"
#include "ttyio.h"
#include "openport.h"
#include <locale.h>
#include <langinfo.h>
@ -57,10 +59,9 @@ int main(int argc, char **argv)
{
FILE *pTty;
char *p, *tty, temp[PATH_MAX];
int i;
int i, rc;
struct stat sb;
printf("Loading MBSE BBS ...\n");
pTTY = calloc(15, sizeof(char));
tty = ttyname(1);
@ -73,7 +74,7 @@ int main(int argc, char **argv)
} else if (getenv("USER") != NULL) {
strcpy(sUnixName, getenv("USER"));
} else {
WriteError("No username in environment");
fprintf(stderr, "No username in environment\n");
Quick_Bye(MBERR_OK);
}
@ -104,10 +105,18 @@ int main(int argc, char **argv)
InitClient(sUnixName, (char *)"mbsebbs", (char *)"Unknown", CFG.logfile,
CFG.bbs_loglevel, CFG.error_log, CFG.mgrlog, CFG.debuglog);
IsDoing("Loging in");
Syslog(' ', " ");
Syslog(' ', "MBSEBBS v%s", VERSION);
if ((rc = rawport()) != 0) {
WriteError("Unable to set raw mode");
Quick_Bye(MBERR_OK);;
}
PUTSTR((char *)"Loading MBSE BBS ...");
PUTCHAR('\r');
PUTCHAR('\n');
if ((p = getenv("CONNECT")) != NULL)
Syslog('+', "CONNECT %s", p);
if ((p = getenv("CALLER_ID")) != NULL)
@ -142,8 +151,8 @@ int main(int argc, char **argv)
/*
* Trap signals
*/
for(i = 0; i < NSIG; i++) {
if ((i == SIGHUP) || (i == SIGBUS) || (i == SIGILL) || (i == SIGSEGV) || (i == SIGTERM))
for (i = 0; i < NSIG; i++) {
if ((i == SIGHUP) || (i == SIGPIPE) || (i == SIGBUS) || (i == SIGILL) || (i == SIGSEGV) || (i == SIGTERM))
signal(i, (void (*))die);
else if (i == SIGCHLD)
signal(i, SIG_DFL);
@ -170,10 +179,10 @@ int main(int argc, char **argv)
clear();
DisplayLogo();
colour(YELLOW, BLACK);
printf("MBSE BBS v%s (Release: %s) on %s/%s\n", VERSION, ReleaseDate, OsName(), OsCPU());
colour(WHITE, BLACK);
printf("%s\n\n", COPYRIGHT);
sprintf(temp, "MBSE BBS v%s (Release: %s) on %s/%s", VERSION, ReleaseDate, OsName(), OsCPU());
poutCR(YELLOW, BLACK, temp);
pout(WHITE, BLACK, (char *)COPYRIGHT);
Enter(2);
/*
* Check users homedirectory, some *nix systems let users in if no
@ -181,7 +190,8 @@ int main(int argc, char **argv)
*/
sprintf(temp, "%s/%s", CFG.bbs_usersdir, sUnixName);
if (stat(temp, &sb)) {
printf("No homedirectory\n\n");
sprintf(temp, "No homedirectory\r\n\r\n");
PUTSTR(temp);
WriteError("homedirectory %s doesn't exist", temp);
Quick_Bye(MBERR_OK);
}
@ -204,7 +214,8 @@ int main(int argc, char **argv)
if ((strcmp(ttyinfo.tty, pTTY) != 0) || (!ttyinfo.available)) {
Syslog('+', "No BBS allowed on port \"%s\"", pTTY);
printf("No BBS on this port allowed!\n\n");
sprintf(temp, "No BBS on this port allowed!\r\n\r\n");
PUTSTR(temp);
Free_Language();
Quick_Bye(MBERR_OK);
}
@ -214,10 +225,12 @@ int main(int argc, char **argv)
*/
if (CFG.iConnectString) {
/* Connected on port */
colour(CYAN, BLACK);
printf("%s\"%s\" ", (char *) Language(348), ttyinfo.comment);
sprintf(temp, "%s\"%s\" ", (char *) Language(348), ttyinfo.comment);
pout(CYAN, BLACK, temp);
/* on */
printf("%s %s\n", (char *) Language(135), ctime(&ltime));
sprintf(temp, "%s %s", (char *) Language(135), ctime(&ltime));
PUTSTR(temp);
Enter(1);
}
}

View File

@ -60,6 +60,7 @@
#include "lastcallers.h"
#include "signature.h"
#include "term.h"
#include "ttyio.h"
extern pid_t mypid;
@ -90,7 +91,7 @@ void menu()
{
FILE *pMenuFile;
int iFoundKey = FALSE, Key, IsANSI;
char *Input, *sMenuPathFileName, buf[81];
char temp[81], *Input, *sMenuPathFileName, buf[81];
Input = calloc(PATH_MAX, sizeof(char));
sMenuPathFileName = calloc(PATH_MAX, sizeof(char));
@ -127,7 +128,8 @@ void menu()
*/
if (MenuError == 10) {
WriteError("FATAL ERROR: Too many menu errors");
printf("Too many menu errors, notifying Sysop\n\n");
sprintf(temp, "Too many menu errors, notifying Sysop\r\n\r\n");
PUTSTR(temp);
sleep(3);
die(MBERR_CONFIG_ERROR);
}
@ -179,7 +181,9 @@ void menu()
if (IsSema((char *)"upsdown")) {
fclose(pMenuFile);
Syslog('+', "Kicking user out, upsdown semafore detected");
printf("System power failure, closing the bbs\n\n");
sprintf(temp, "System power failure, closing the bbs");
PUTSTR(temp);
Enter(2);
sleep(3);
Good_Bye(MBERR_OK);
}
@ -205,10 +209,9 @@ void menu()
alarm_on();
if (exitinfo.HotKeys) {
fflush(stdout);
Key = Getone();
Key = Readkey();
sprintf(Input, "%c", Key);
printf("\n");
Enter(1);
} else {
colour(CFG.InputColourF, CFG.InputColourB);
GetstrC(Input, 80);
@ -381,7 +384,8 @@ void DoMenu(int Type)
for (i = 0; i < strlen(menus.OptionalData); i++)
if (*(menus.OptionalData + i) == '@')
*(menus.OptionalData + i) = '\n';
printf("%s\n", menus.OptionalData);
sprintf(temp, "%s\r\n", menus.OptionalData);
PUTSTR(temp);
}
break;
@ -743,7 +747,7 @@ void DisplayMenu(void)
if ( ( dpos + 1 ) == maxdpos ) {
skipCRLF=1;
} else {
printf("%c",menus.Display[ dpos ]);
PUTCHAR(menus.Display[ dpos ]);
}
break;
@ -751,7 +755,7 @@ void DisplayMenu(void)
escaped = 1;
} else {
escaped = 0;
printf("%c",menus.Display[ dpos ]);
PUTCHAR(menus.Display[ dpos ]);
}
break;
@ -767,17 +771,17 @@ void DisplayMenu(void)
}
} else {
escaped=0;
printf("%c",menus.Display[ dpos ]);
PUTCHAR(menus.Display[ dpos ]);
}
break;
default: /* all other characters */
printf("%c",menus.Display[ dpos ]);
PUTCHAR(menus.Display[ dpos ]);
}
}
if ( !skipCRLF ) {
printf("\n");
Enter(1);
}
}

View File

@ -32,12 +32,15 @@
#include "../lib/mbselib.h"
#include "../lib/mbse.h"
#include "../lib/users.h"
#include "../lib/msg.h"
#include "funcs.h"
#include "input.h"
#include "language.h"
#include "misc.h"
#include "timeout.h"
#include "exitinfo.h"
#include "ttyio.h"
#include "term.h"
extern char *StartTime; /* Time user logged in */
@ -113,14 +116,17 @@ void DisplayLogo()
char *sString, *temp;
temp = calloc(PATH_MAX, sizeof(char));
sString = calloc(81, sizeof(char));
sString = calloc(1024, sizeof(char));
sprintf(temp, "%s/%s", CFG.bbs_txtfiles, CFG.welcome_logo);
if ((pLogo = fopen(temp,"rb")) == NULL)
WriteError("$DisplayLogo: Can't open %s", temp);
else {
while (fgets(sString, 80, pLogo) != NULL)
printf("%s", sString);
while (Fgets(sString, 1023, pLogo) != NULL) {
// Striplf(sString);
PUTSTR(sString);
Enter(1);
}
fclose(pLogo);
}
free(sString);

View File

@ -36,31 +36,31 @@
#include "language.h"
#include "morefile.h"
#include "timeout.h"
#include "term.h"
#include "ttyio.h"
int MoreFile(char *filename)
{
char Buf[81];
static FILE *fptr;
int lines;
int input;
int ignore = FALSE;
int maxlines;
int lines, input, ignore = FALSE, maxlines;
maxlines = lines = exitinfo.iScreenLen - 2;
if ((fptr = fopen(filename,"r")) == NULL) {
printf("%s%s\n", (char *) Language(72), filename);
sprintf(Buf, "%s%s", (char *) Language(72), filename);
pout(LIGHTRED, BLACK, Buf);
Enter(2);
return(0);
}
printf("\n");
Enter(1);
while (fgets(Buf,80,fptr) != NULL) {
if ((lines != 0) || (ignore)) {
lines--;
printf("%s",Buf);
PUTSTR(Buf);
}
if (strlen(Buf) == 0) {
@ -68,10 +68,9 @@ int MoreFile(char *filename)
return(0);
}
if (lines == 0) {
fflush(stdin);
/* More (Y/n/=) */
printf(" %sY\x08", (char *) Language(61));
fflush(stdout);
sprintf(Buf, " %sY\x08", (char *) Language(61));
PUTSTR(Buf);
alarm_on();
input = toupper(getchar());

View File

@ -41,6 +41,9 @@
#include "change.h"
#include "dispfile.h"
#include "term.h"
#include "ttyio.h"
#include "openport.h"
/*
@ -105,7 +108,6 @@ int newuser()
/* Please enter your First and Last name: */
language(CYAN, BLACK, 0);
fflush(stdout);
alarm_on();
Getname(temp, 35);
strcpy(FullName, tlcap(temp));
@ -148,14 +150,12 @@ int newuser()
Enter(1);
/* Please enter new password : */
language(LIGHTCYAN, BLACK, 39);
fflush(stdout);
alarm_on();
Getpass(temp1);
if ((x = strlen(temp1)) >= CFG.password_length) {
Enter(1);
/* Please enter password again : */
language(LIGHTCYAN, BLACK, 40);
fflush(stdout);
alarm_on();
Getpass(temp2);
if ((i = strcmp(temp1,temp2)) != 0) {
@ -171,7 +171,8 @@ int newuser()
Enter(2);
/* Your password must contain at least */
language(LIGHTRED, BLACK, 42);
printf("%d ", CFG.password_length);
sprintf(temp, "%d ", CFG.password_length);
PUTSTR(temp);
/* characters! Try again. */
language(WHITE, BLACK, 43);
Enter(1);
@ -218,7 +219,6 @@ int newuser()
pout(LIGHTGREEN, BLACK, (char *)": ");
colour(CFG.InputColourF, CFG.InputColourB);
fflush(stdout);
alarm_on();
GetPhone(temp, 16);
@ -269,7 +269,7 @@ int newuser()
} /* End of if Statement */
if (!CFG.iDataPhone)
printf("\n");
Enter(1);
if (CFG.iLocation) {
while (TRUE) {
@ -279,7 +279,6 @@ int newuser()
colour(CFG.InputColourF, CFG.InputColourB);
alarm_on();
if (CFG.iCapLocation) { /* Cap Location is turned on, Capitalise first letter */
fflush(stdout);
GetnameNE(temp, 24);
} else
GetstrC(temp, 80);
@ -289,7 +288,8 @@ int newuser()
/* Please enter a longer location */
language(LIGHTRED, BLACK, 50);
Enter(1);
printf("%s%d)", (char *) Language(74), CFG.CityLen);
sprintf(temp, "%s%d)", (char *) Language(74), CFG.CityLen);
PUTSTR(temp);
Enter(1);
} else {
strcpy(usrconfig.sLocation, temp);
@ -306,10 +306,9 @@ int newuser()
language(LIGHTMAGENTA, BLACK, 474);
Enter(1);
for (i = 0; i < 3; i++) {
colour(YELLOW, BLACK);
printf("%d: ", i+1);
sprintf(temp, "%d: ", i+1);
pout(YELLOW, BLACK, temp);
colour(CFG.InputColourF, CFG.InputColourB);
fflush(stdout);
alarm_on();
GetstrC(usrconfig.address[i], 40);
}
@ -328,7 +327,6 @@ int newuser()
/* Enter a handle (Enter to Quit): */
language(LIGHTRED, BLACK, 412);
colour(CFG.InputColourF, CFG.InputColourB);
fflush(stdout);
alarm_on();
Getname(temp, 34);
@ -356,9 +354,8 @@ int newuser()
/* What is your sex? (M)ale or (F)emale: */
language(LIGHTBLUE, BLACK, 51);
colour(CFG.InputColourF, CFG.InputColourB);
fflush(stdout);
alarm_on();
i = toupper(Getone());
i = toupper(Readkey());
if (i == Keystroke(51, 0)) {
/* Male */
@ -388,7 +385,6 @@ int newuser()
/* Please enter your Date of Birth DD-MM-YYYY: */
pout(CYAN, BLACK, (char *) Language(56));
colour(CFG.InputColourF, CFG.InputColourB);
fflush(stdout);
alarm_on();
GetDate(temp, 10);
@ -454,7 +450,6 @@ int newuser()
/* Please enter your Screen Length [24]: */
pout(LIGHTMAGENTA, BLACK, (char *) Language(64));
colour(CFG.InputColourF, CFG.InputColourB);
fflush(stdout);
alarm_on();
Getnum(temp, 3);
@ -572,15 +567,16 @@ int newuser()
/* Login Name : */
pout(LIGHTBLUE, BLACK, (char *) Language(68));
colour(CYAN, BLACK);
printf("%s (%s)\n", UnixName, FullName);
sprintf(temp, "%s (%s)", UnixName, FullName);
PUTSTR(temp);
Enter(1);
/* Password : */
pout(LIGHTBLUE, BLACK, (char *) Language(69));
pout(CYAN, BLACK, (char *)"<");
/* not displayed */
pout(WHITE, BLACK, (char *) Language(70));
pout(CYAN, BLACK, (char *)">\n\n");
fflush(stdout);
fflush(stdin);
pout(CYAN, BLACK, (char *)">");
Enter(2);
if (CFG.iVoicePhone && TelephoneScan(Phone1, FullName))
Syslog('!', "Duplicate phone numbers found");
@ -597,8 +593,7 @@ int newuser()
Syslog('+', "Completed new-user procedure");
/* New user registration completed. */
pout(LIGHTGREEN, BLACK, (char *) Language(71));
Enter(1);
poutCR(LIGHTGREEN, BLACK, (char *) Language(71));
/* You need to login again with the name: */
pout(LIGHTRED, BLACK, (char *) Language(5));
pout(YELLOW, BLACK, UnixName);
@ -606,7 +601,7 @@ int newuser()
alarm_on();
Pause();
alarm_off();
printf("\n");
Enter(1);
return 0;
}
@ -627,10 +622,11 @@ void Fast_Bye(int onsig)
free(temp);
colour(LIGHTGRAY, BLACK);
fflush(stdout);
fflush(stdin);
sleep(3);
cookedport();
hangup();
Free_Language();
free(pTTY);
exit(MBERR_OK);
@ -661,24 +657,22 @@ char *NameGen(char *FidoName)
Syslog('+', "NameGen(%s)", FidoName);
while ((strcmp(sUserName, "") == 0) || (CheckUnixNames(sUserName)) || (strlen(sUserName) < 3)) {
colour(LIGHTRED, BLACK);
printf("\n%s\n\n", (char *) Language(381));
colour(WHITE, BLACK);
Enter(1);
pout(LIGHTRED, BLACK, (char *) Language(381));
Enter(2);
/* Please enter a login name (Maximum 8 characters) */
printf("\n%s\n", (char *) Language(383));
poutCR(WHITE, BLACK, (char *) Language(383));
/* ie. John Doe, login = jdoe */
printf("%s\n", (char *) Language(384));
colour(LIGHTGREEN, BLACK);
poutCR(WHITE, BLACK, (char *) Language(384));
/* login > */
printf("%s", (char *) Language(385));
fflush(stdout);
fflush(stdin);
pout(LIGHTGREEN, BLACK, (char *) Language(385));
GetstrU(sUserName, 7);
if (CheckUnixNames(sUserName)) {
Enter(1);
/* That login name already exists, please choose another one. */
colour(LIGHTRED, BLACK);
printf("\n%s\n", (char *) Language(386));
poutCR(LIGHTRED, BLACK, (char *) Language(386));
Syslog('+', "Users tried to use \"%s\" as Unix name", MBSE_SS(sUserName));
}
}
@ -705,8 +699,6 @@ char *NameCreate(char *Name, char *Comment, char *Password)
*/
sprintf(progname, "%s/bin/mbuseradd", getenv("MBSE_ROOT"));
sprintf(gidstr, "%d", getgid());
fflush(stdout);
fflush(stdin);
args[0] = progname;
args[1] = gidstr;
args[2] = Name;
@ -729,8 +721,6 @@ char *NameCreate(char *Name, char *Comment, char *Password)
args[2] = Name;
args[3] = Password;
args[4] = NULL;
fflush(stdout);
fflush(stdin);
if ((err = execute(args, (char *)"/dev/null", (char *)"/dev/null", (char *)"/dev/null"))) {
WriteError("Failed to set unix password");
@ -738,9 +728,9 @@ char *NameCreate(char *Name, char *Comment, char *Password)
ExitClient(MBERR_GENERAL);
}
colour(YELLOW, BLACK);
Enter(1);
/* Your "Unix Account" is created, you may use it the next time you call */
printf("\n%s\n", (char *) Language(382));
poutCR(YELLOW, BLACK, (char *) Language(382));
Syslog('+', "Created Unix account %s for %s", Name, Comment);
free(progname);
@ -770,7 +760,9 @@ int BadNames(char *Username)
strcpy(String, tl(String));
Striplf(String);
if ((strstr(User, String)) != NULL) {
printf("\nSorry that name is not acceptable on this system\n");
Enter(1);
pout(LIGHTRED, BLACK, (char *)"Sorry that name is not acceptable on this system");
Enter(1);
Syslog('+', "User tried username \"%s\", found in %s", Username, temp);
iFoundName = TRUE;
break;

View File

@ -48,6 +48,9 @@
#include "offline.h"
#include "whoson.h"
#include "term.h"
#include "ttyio.h"
#include "openport.h"
long Total, TotalPersonal, Current, Personal;
@ -100,7 +103,6 @@ void AddArc(char *Temp, char *Pktname)
execute_str((char *)archiver.marc, Pktname, Temp, (char *)"/dev/null", (char *)"/dev/null", (char *)"/dev/null");
unlink(Temp);
printf(".");
fflush(stdout);
}
@ -140,14 +142,12 @@ void UpdateLR(msg_high *mhl, FILE *mf)
char *p;
msg_high *tmp;
colour(YELLOW, BLACK);
/* Updating lastread pointer */
printf("%s\n", (char *)Language(449));
poutCR(YELLOW, BLACK, (char *)Language(449));
colour(LIGHTMAGENTA, BLACK);
for (tmp = mhl; tmp; tmp = tmp->next) {
printf(".");
fflush(stdout);
PUTCHAR('.');
fseek(mf, ((tmp->Area -1) * (msgshdr.recsize + msgshdr.syssize)) + msgshdr.hdrsize, SEEK_SET);
fread(&msgs, msgshdr.recsize, 1, mf);
if (Msg_Open(msgs.Base)) {
@ -224,7 +224,7 @@ void OLR_TagArea()
{
char *Msgname, *Tagname;
FILE *ma, *tf;
char *buf;
char *buf, msg[81];
long total, Offset, Area;
int lines, input, ignore = FALSE, maxlines;
@ -238,22 +238,20 @@ void OLR_TagArea()
sprintf(Tagname, "%s/%s/.olrtags", CFG.bbs_usersdir, exitinfo.Name);
clear();
colour(YELLOW, BLACK);
/* Tag Offline Reader message areas */
printf("%s\n", (char *)Language(66));
poutCR(YELLOW, BLACK, (char *)Language(66));
do {
colour(WHITE, BLACK);
Enter(1);
/* Enter the name of the conference, or ? for a list: */
printf("\n%s", (char *)Language(228));
pout(WHITE, BLACK, (char *)Language(228));
colour(CFG.InputColourF, CFG.InputColourB);
GetstrC(buf, 20);
if (buf[0] == '?') {
maxlines = lines = exitinfo.iScreenLen - 1;
colour(LIGHTCYAN, BLACK);
/* Conference Area Msgs Description */
printf("%s\n", (char *)Language(229));
poutCR(LIGHTCYAN, BLACK, (char *)Language(229));
if ((ma = fopen(Msgname, "r")) != NULL) {
fread(&msgshdr, sizeof(msgshdr), 1, ma);
Area = 0;
@ -267,21 +265,20 @@ void OLR_TagArea()
Msg_Close();
} else
total = 0;
colour(CYAN, BLACK);
if (msgs.Active && Access(exitinfo.Security, msgs.RDSec) && (!olrtagrec.Tagged) && strlen(msgs.QWKname)) {
if ( (lines != 0) || (ignore) ) {
lines--;
printf("%-20.20s %-5ld %-5ld %s\n", msgs.QWKname, Area, total, msgs.Name);
sprintf(msg, "%-20.20s %-5ld %-5ld %s", msgs.QWKname, Area, total, msgs.Name);
poutCR(CYAN, BLACK, msg);
}
if (lines == 0) {
fflush(stdin);
colour(WHITE, BLACK);
/* More (Y/n/=) */
printf("%s%c\x08", (char *) Language(61),Keystroke(61,0));
fflush(stdout);
sprintf(msg, "%s%c\x08", (char *) Language(61),Keystroke(61,0));
pout(WHITE, BLACK, msg);
alarm_on();
input = toupper(Getone());
printf("%c\r",input);
input = toupper(Readkey());
PUTCHAR(input);
PUTCHAR('\r');
if ((input == Keystroke(61, 0)) || (input == '\r'))
lines = maxlines;
@ -366,7 +363,7 @@ void OLR_TagArea()
*/
void OLR_UntagArea()
{
char *Msgname, *Tagname, *buf;
char *Msgname, *Tagname, *buf, msg[81];
FILE *ma, *tf;
long total, Offset, Area;
int lines, input, ignore = FALSE, maxlines;
@ -381,22 +378,20 @@ void OLR_UntagArea()
sprintf(Tagname, "%s/%s/.olrtags", CFG.bbs_usersdir, exitinfo.Name);
clear();
colour(YELLOW, BLACK);
/* Untag Offline Reader message areas */
printf("%s\n", (char *)Language(256));
poutCR(YELLOW, BLACK, (char *)Language(256));
do {
colour(WHITE, BLACK);
Enter(1);
/* Enter the name of the conference, or ? for a list: */
printf("\n%s", (char *)Language(228));
pout(WHITE, BLACK, (char *)Language(228));
colour(CFG.InputColourF, CFG.InputColourB);
GetstrC(buf, 20);
if (buf[0] == '?') {
maxlines = lines = exitinfo.iScreenLen - 1;
colour(LIGHTCYAN, BLACK);
/* Conference Area Msgs Description */
printf("%s\n", (char *)Language(229));
poutCR(LIGHTCYAN, BLACK, (char *)Language(229));
if ((ma = fopen(Msgname, "r")) != NULL) {
fread(&msgshdr, sizeof(msgshdr), 1, ma);
Area = 0;
@ -410,21 +405,20 @@ void OLR_UntagArea()
Msg_Close();
} else
total = 0;
colour(CYAN, BLACK);
if (msgs.Active && Access(exitinfo.Security, msgs.RDSec) && olrtagrec.Tagged && strlen(msgs.QWKname)) {
if ( (lines != 0) || (ignore) ) {
lines--;
printf("%-20.20s %-5ld %-5ld %s\n", msgs.QWKname, Area, total, msgs.Name);
sprintf(msg, "%-20.20s %-5ld %-5ld %s", msgs.QWKname, Area, total, msgs.Name);
poutCR(CYAN, BLACK, msg);
}
if (lines == 0) {
fflush(stdin);
colour(WHITE, BLACK);
/* More (Y/n/=) */
printf("%s%c\x08", (char *) Language(61),Keystroke(61,0));
fflush(stdout);
sprintf(msg, "%s%c\x08", (char *) Language(61),Keystroke(61,0));
pout(WHITE, BLACK, msg);
alarm_on();
input = toupper(Getone());
printf("%c\r",input);
input = toupper(Readkey());
PUTCHAR(input);
PUTCHAR('\r');
if ((input == Keystroke(61, 0)) || (input == '\r'))
lines = maxlines;
@ -485,7 +479,7 @@ void OLR_UntagArea()
fread(&olrtagrec, sizeof(olrtagrec), 1, tf);
if (olrtagrec.Tagged) {
if (msgs.OLR_Forced) {
printf("Area cannot be switched off\n");
poutCR(LIGHTRED, BLACK, (char *)"Area cannot be switched off");
} else {
olrtagrec.Tagged = FALSE;
fseek(tf, - sizeof(olrtagrec), SEEK_CUR);
@ -523,11 +517,12 @@ void New_Hdr()
/* New or deleted mail areas at */
sprintf(temp, "%s%s", (char *) Language(364), CFG.bbs_name);
Center(temp);
free(temp);
printf("\n");
Enter(1);
colour(WHITE, BLUE);
/* Area State Type Description */
printf("%-79s\n", (char *) Language(365));
sprintf(temp, "%-79s", (char *) Language(365));
poutCR(WHITE, BLUE, temp);
free(temp);
}
@ -535,21 +530,25 @@ void New_Hdr()
void New_Area(long);
void New_Area(long Area)
{
colour(LIGHTCYAN, BLACK);
char msg[81];
/* New */
printf("%4ld %s", Area, (char *)Language(391));
sprintf(msg, "%4ld %s", Area, (char *)Language(391));
pout(LIGHTCYAN, BLACK, msg);
switch (msgs.Type) {
case LOCALMAIL: printf(Language(392)); /* Local */
case LOCALMAIL: PUTSTR((char *)Language(392)); /* Local */
break;
case NETMAIL: printf(Language(393)); /* Netmail */
case NETMAIL: PUTSTR((char *)Language(393)); /* Netmail */
break;
case LIST:
case ECHOMAIL: printf(Language(394)); /* Echomail */
case ECHOMAIL: PUTSTR((char *)Language(394)); /* Echomail */
break;
case NEWS: printf(Language(395)); /* News */
case NEWS: PUTSTR((char *)Language(395)); /* News */
break;
}
printf("%s\n", msgs.Name);
PUTSTR(msgs.Name);
Enter(1);
}
@ -557,9 +556,11 @@ void New_Area(long Area)
void Old_Area(long);
void Old_Area(long Area)
{
colour(LIGHTRED, BLACK);
char msg[81];
/* Del */
printf("%4ld %s\n", Area, (char *)Language(397));
sprintf(msg, "%4ld %s", Area, (char *)Language(397));
poutCR(LIGHTRED, BLACK, msg);
}
@ -710,7 +711,7 @@ void OLR_SyncTags()
*/
void OLR_ViewTags()
{
char *Tagname, *Msgname;
char *Tagname, *Msgname, msg[81];
FILE *tf, *ma;
long total, Area = 0;
int lines, input, ignore = FALSE, maxlines;
@ -739,14 +740,12 @@ void OLR_ViewTags()
fread(&msgshdr, sizeof(msgshdr), 1, ma);
clear();
colour(YELLOW, BLACK);
/* You have selected the following Conference(s): */
printf ("%s\n", (char *)Language(260));
colour(LIGHTCYAN, BLACK);
poutCR(YELLOW, BLACK, (char *)Language(260));
Enter(1);
/* Conference Area Msgs Description */
printf ("\n%s\n", (char *)Language(229));
poutCR(LIGHTCYAN, BLACK, (char *)Language(229));
colour(CYAN, BLACK);
fflush(stdout);
maxlines = lines = exitinfo.iScreenLen - 1;
while (fread(&msgs, msgshdr.recsize, 1, ma) == 1) {
@ -762,17 +761,18 @@ void OLR_ViewTags()
total = 0;
if ( (lines != 0) || (ignore) ) {
lines--;
printf("%-20.20s %-5ld %-5ld %s\n", msgs.QWKname, Area, total, msgs.Name);
sprintf(msg, "%-20.20s %-5ld %-5ld %s", msgs.QWKname, Area, total, msgs.Name);
PUTSTR(msg);
Enter(1);
}
if (lines == 0) {
fflush(stdin);
colour(WHITE, BLACK);
/* More (Y/n/=) */
printf("%s%c\x08", (char *) Language(61),Keystroke(61,0));
fflush(stdout);
sprintf(msg, "%s%c\x08", (char *) Language(61),Keystroke(61,0));
pout(WHITE, BLACK, msg);
alarm_on();
input = toupper(Getone());
printf("%c\r",input);
input = toupper(Readkey());
PUTCHAR(input);
PUTCHAR('\r');
if ((input == Keystroke(61, 0)) || (input == '\r'))
lines = maxlines;
@ -785,7 +785,6 @@ void OLR_ViewTags()
lines = maxlines;
colour(CYAN, BLACK);
}
fflush(stdout);
}
}
@ -805,16 +804,15 @@ int OLR_Prescan()
{
unsigned short RetVal = FALSE, Areas;
unsigned long Number;
char *Temp;
char *Temp, msg[81];
FILE *mf, *tf;
int x;
WhosDoingWhat(OLR, NULL);
clear();
colour(LIGHTMAGENTA, BLACK);
/* Offline Reader Download */
printf("%s\n\n", (char *)Language(277));
fflush(stdout);
pout(LIGHTMAGENTA, BLACK, (char *)Language(277));
Enter(2);
if (exitinfo.Email)
check_popmail(exitinfo.Name, exitinfo.Password);
@ -828,9 +826,10 @@ int OLR_Prescan()
tf = fopen(Temp, "r");
Total = TotalPersonal = Areas = 0;
Enter(1);
colour(WHITE, BLUE);
/* Forum Description Msgs. Pers. */
printf("\n%s\n", (char *)Language(297));
poutCR(WHITE, BLUE, (char *)Language(297));
while (fread(&msgs, msgshdr.recsize, 1, mf) == 1) {
fseek(mf, msgshdr.syssize, SEEK_CUR);
@ -840,9 +839,8 @@ int OLR_Prescan()
if (Msg_Open(msgs.Base)) {
Areas++;
Current = Personal = 0;
colour(LIGHTCYAN, BLACK);
printf("%-20.20s %-41.41s ", msgs.QWKname, msgs.Name);
fflush(stdout);
sprintf(msg, "%-20.20s %-41.41s ", msgs.QWKname, msgs.Name);
pout(LIGHTCYAN, BLACK, msg);
memset(&LR, 0, sizeof(LR));
LR.UserID = grecno;
@ -867,9 +865,8 @@ int OLR_Prescan()
} while (Msg_Next(&Number));
}
colour(LIGHTGREEN, BLACK);
printf("%5lu %5lu\n", Current, Personal);
fflush(stdout);
sprintf(msg, "%5lu %5lu", Current, Personal);
poutCR(LIGHTGREEN, BLACK, msg);
Msg_Close();
}
}
@ -877,27 +874,30 @@ int OLR_Prescan()
Syslog('+', "OLR Prescan: %u Areas, %lu Messages", Areas, Total);
colour(LIGHTBLUE, BLACK);
Enter(1);
/* Total messages found: */
printf("\n%s %lu\n\n", (char *)Language(338), Total);
sprintf(msg, "%s %lu", (char *)Language(338), Total);
pout(LIGHTBLUE, BLACK, msg);
Enter(2);
if (Total == 0L) {
colour(YELLOW, BLACK);
/* No messages found to download! */
printf("%s\n\007", (char *)Language(374));
poutCR(YELLOW, BLACK, (char *)Language(374));
PUTCHAR('\007');
Pause();
} else {
if (CFG.OLR_MaxMsgs != 0 && Total > CFG.OLR_MaxMsgs) {
/* Too much messages. Only the first will be packed! */
printf("%s %d %s\n\n\007", (char *)Language(377), CFG.OLR_MaxMsgs, (char *)Language(411));
sprintf(msg, "%s %d %s", (char *)Language(377), CFG.OLR_MaxMsgs, (char *)Language(411));
PUTCHAR('\007');
Enter(2);
Total = CFG.OLR_MaxMsgs;
}
colour(CFG.HiliteF, CFG.HiliteB);
/* Do you want to download these messages [Y/n]? */
printf("%s", (char *)Language(425));
fflush(stdout);
pout(CFG.HiliteF, CFG.HiliteB, (char *)Language(425));
alarm_on();
x = toupper(Getone());
x = toupper(Readkey());
if (x != Keystroke(425, 1)) {
RetVal = TRUE;
@ -922,13 +922,16 @@ int OLR_Prescan()
*/
void DrawBar(char *Pktname)
{
colour(YELLOW, BLACK);
char msg[81];
Enter(1);
/* Preparing packet */
printf("\n%s %s...\n\n", (char *)Language(445), Pktname);
colour(LIGHTGREEN, BLACK);
printf("0%% 10%% 20%% 30%% 40%% 50%% 60%% 70%% 80%% 90%% 100%%\n");
printf("|-----|-----|-----|-----|-----|-----|-----|-----|-----|-----|\r");
fflush(stdout);
sprintf(msg, "%s %s...", (char *)Language(445), Pktname);
pout(YELLOW, BLACK, msg);
Enter(2);
poutCR(LIGHTGREEN, BLACK, (char *)"0%% 10%% 20%% 30%% 40%% 50%% 60%% 70%% 80%% 90%% 100%%");
PUTSTR((char *)"|-----|-----|-----|-----|-----|-----|-----|-----|-----|-----|");
PUTCHAR('\r');
}
@ -937,7 +940,8 @@ void OLR_RestrictDate()
{
WhosDoingWhat(OLR, NULL);
printf("Not Yet Implemented\n");
PUTSTR((char *)"Not Yet Implemented");
Enter(1);
Pause();
}
@ -1006,13 +1010,14 @@ USHORT TOffline::TooOld (ULONG Restrict, class TMsgBase *Msg)
*/
void OLR_Upload(void)
{
char *File, *temp, *Arc, Dirpath[PATH_MAX], Filename[81];
char *File, *temp, *Arc, Dirpath[PATH_MAX], Filename[81], msg[81];
time_t ElapstimeStart, ElapstimeFin, iTime;
int err, Strlen, RetVal = FALSE;
FILE *fp;
if (strlen(CFG.bbsid) == 0) {
printf("System configuration error, inform sysop\n");
PUTSTR((char *)"System configuration error, inform sysop");
Enter(1);
WriteError("Config OLR bbsid not configured");
Pause();
return;
@ -1020,9 +1025,8 @@ void OLR_Upload(void)
WhosDoingWhat(OLR, NULL);
clear();
colour(LIGHTMAGENTA, BLACK);
/* Offline Reader Upload */
printf("%s\n", (char *)Language(439));
poutCR(LIGHTMAGENTA, BLACK, (char *)Language(439));
if (!ForceProtocol())
return;
@ -1044,9 +1048,10 @@ void OLR_Upload(void)
return;
if (File[0] == '.' || File[0] == '*' || File[0] == ' ') {
colour(CFG.HiliteF, CFG.HiliteB);
Enter(1);
/* Illegal filename! */
printf("\n%s\n\n", (char *) Language(247));
pout(CFG.HiliteF, CFG.HiliteB, (char *) Language(247));
Enter(2);
Pause();
return;
}
@ -1055,26 +1060,30 @@ void OLR_Upload(void)
Strlen--;
if (File[Strlen] == '.' || File[Strlen] == '/' || File[Strlen] == ' ') {
colour(CFG.HiliteF, CFG.HiliteB);
Enter(1);
/* Illegal Filename! */
printf("\n%s\n\n", (char *) Language(247));
pout(CFG.HiliteF, CFG.HiliteB, (char *) Language(247));
Enter(2);
Pause();
return;
}
if (strncasecmp(File, CFG.bbsid, strlen(CFG.bbsid))) {
colour(CFG.HiliteF, CFG.HiliteB);
Enter(1);
/* Illegal filename! */
printf("\n%s\n\n", (char *) Language(247));
pout(CFG.HiliteF, CFG.HiliteB, (char *) Language(247));
Enter(2);
Pause();
return;
}
Syslog('+', "Filename accepted");
}
colour(CFG.HiliteF, CFG.HiliteB);
Enter(1);
/* Please start your upload now */
printf("\n%s, %s\n\n", sProtAdvice, (char *) Language(283));
sprintf(msg, "%s, %s", sProtAdvice, (char *) Language(283));
pout(CFG.HiliteF, CFG.HiliteB, msg);
Enter(2);
if (uProtBatch)
Syslog('+', "Upload using %s", sProtName);
else
@ -1087,8 +1096,6 @@ void OLR_Upload(void)
return;
}
fflush(stdout);
fflush(stdin);
sleep(2);
ElapstimeStart = time(NULL);
@ -1097,16 +1104,18 @@ void OLR_Upload(void)
*/
Altime(7200);
alarm_set(7190);
if ((err = execute_str(sProtUp, (char *)"", NULL, NULL, NULL, NULL))) {
colour(CFG.HiliteF, CFG.HiliteB);
err = execute_str(sProtUp, (char *)"", NULL, NULL, NULL, NULL);
if (rawport() != 0) {
WriteError("Unable to set raw mode");
}
if (err) {
WriteError("$Upload error %d, prot: %s", err, sProtUp);
}
Altime(0);
alarm_off();
alarm_on();
printf("\n");
fflush(stdout);
fflush(stdin);
Enter(1);
ElapstimeFin = time(NULL);
/*
@ -1136,7 +1145,8 @@ void OLR_Upload(void)
if (RetVal == FALSE) {
WriteError("Invalid OLR packed received");
/* Invalid packet received */
printf("%s\n\n", (char *)Language(440));
pout(LIGHTRED, BLACK, (char *)Language(440));
Enter(2);
sleep(2);
return;
}
@ -1146,7 +1156,7 @@ void OLR_Upload(void)
if ((Arc = GetFileType(File)) == NULL) {
/* Unknown compression type */
printf("%s\n", (char *)Language(441));
poutCR(LIGHTRED, BLACK, (char *)Language(441));
Syslog('+', "Unknown compression type");
Pause();
return;
@ -1169,7 +1179,7 @@ void OLR_Upload(void)
if (strcmp(Arc, archiver.name) || (!archiver.available)) {
Syslog('+', "Archiver %s not available", Arc);
/* Archiver not available */
printf("%s\n", (char *)Language(442));
poutCR(LIGHTRED, BLACK, (char *)Language(442));
Pause();
return;
}
@ -1178,24 +1188,27 @@ void OLR_Upload(void)
colour(CFG.TextColourF, CFG.TextColourB);
/* Unpacking archive */
printf("%s ", (char *) Language(201));
fflush(stdout);
pout(CFG.TextColourF, CFG.TextColourB, (char *) Language(201));
PUTCHAR(' ');
sprintf(temp, "%s %s", archiver.funarc, File);
Syslog('m', "Unarc %s", temp);
colour(CFG.HiliteF, CFG.HiliteB);
if ((err = execute_str(archiver.funarc, File, NULL, (char *)"/dev/null", (char *)"/dev/null", (char *)"/dev/null"))) {
err = execute_str(archiver.funarc, File, NULL, (char *)"/dev/null", (char *)"/dev/null", (char *)"/dev/null");
if (rawport() != 0) {
WriteError("Unable to set raw mode");
}
if (err) {
WriteError("$Failed %s", temp);
/* ERROR */
printf("%s\n", (char *) Language(217));
fflush(stdout);
poutCR(LIGHTRED, BLACK, (char *) Language(217));
Pause();
return;
}
/* Ok */
printf("%s\n", (char *) Language(200));
fflush(stdout);
PUTSTR((char *) Language(200));
Enter(1);
unlink(File);
/*
@ -1244,7 +1257,7 @@ void OLR_Upload(void)
WriteError("OLR_Upload: Garbage in mailpacket, clean directory!");
/* Unknown type mailpacket */
printf("%s\n", (char *)Language(443));
poutCR(LIGHTRED, BLACK, (char *)Language(443));
Pause();
free(File);
free(temp);
@ -1281,7 +1294,8 @@ void OLR_DownBW()
msg_high *mhl = NULL;
if (strlen(CFG.bbsid) == 0) {
printf("System configuration error, inform sysop\n");
PUTSTR((char *)"System configuration error, inform sysop");
Enter(1);
WriteError("Config OLR bbsid not configured");
Pause();
return;
@ -1292,9 +1306,8 @@ void OLR_DownBW()
Total = TotalPersonal = 0;
clear();
colour(LIGHTBLUE, BLACK);
/* BlueWave Offline download */
printf("%s\n", (char *)Language(444));
poutCR(LIGHTBLUE, BLACK, (char *)Language(444));
Work = calloc(PATH_MAX, sizeof(char));
Temp = calloc(PATH_MAX, sizeof(char));
@ -1476,14 +1489,17 @@ void OLR_DownBW()
if (Total) {
/* Packing with */
printf("\n%s ", (char *)Language(446));
Enter(1);
PUTSTR((char *)Language(446));
PUTCHAR(' ');
sprintf(Temp, "%s/etc/archiver.data", getenv("MBSE_ROOT"));
if ((af = fopen(Temp, "r")) != NULL) {
fread(&archiverhdr, sizeof(archiverhdr), 1, af);
while (fread(&archiver, archiverhdr.recsize, 1, af) == 1) {
if (archiver.available && (!strcmp(archiver.name, exitinfo.Archiver))) {
Syslog('+', "Archiver %s", archiver.comment);
printf("%s ", archiver.comment);
PUTSTR(archiver.comment);
PUTCHAR(' ');
sprintf(Temp, "%s/%s.DAT", Work, CFG.bbsid);
AddArc(Temp, Pktname);
alarm_on();
@ -1503,15 +1519,15 @@ void OLR_DownBW()
}
}
colour(CFG.HiliteF, CFG.HiliteB);
if (rc == FALSE) {
Syslog('+', "BlueWave download failed");
/* Download failed */
printf("%s", (char *)Language(447));
poutCR(CFG.HiliteF, CFG.HiliteB, (char *)Language(447));
} else {
Syslog('+', "BlueWave download successfull");
PUTCHAR('\r');
/* Download successfull */
printf("\r%s\n", (char *)Language(448));
poutCR(CFG.HiliteF, CFG.HiliteB, (char *)Language(448));
if (mhl != NULL)
UpdateLR(mhl, mf);
@ -1522,7 +1538,7 @@ void OLR_DownBW()
free(Temp);
free(Work);
printf("\n\n");
Enter(2);
Pause();
}
@ -1543,9 +1559,8 @@ void BlueWave_Fetch()
time_t now;
struct tm *tm;
colour(LIGHTBLUE, BLACK);
/* Processing BlueWave reply packet */
printf("%s\n", (char *)Language(450));
poutCR(LIGHTBLUE, BLACK, (char *)Language(450));
temp = calloc(PATH_MAX, sizeof(char));
b = calloc(256, sizeof(char));
buffer = b;
@ -1568,7 +1583,7 @@ void BlueWave_Fetch()
fclose(up);
free(temp);
/* ERROR in packet */
printf("%s\n", (char *)Language(451));
poutCR(LIGHTRED, BLACK, (char *)Language(451));
Pause();
return;
}
@ -1581,15 +1596,14 @@ void BlueWave_Fetch()
colour(CFG.TextColourF, CFG.TextColourB);
/* Import messages */
printf("%s ", (char *)Language(452));
pout(CFG.TextColourF, CFG.TextColourB, (char *)Language(452));
PUTCHAR(' ');
colour(CFG.HiliteF, CFG.HiliteB);
fflush(stdout);
i = 0;
memset(&Upr, 0, sizeof(UPL_REC));
while (fread(&Upr, Uph.upl_rec_len, 1, up) == 1) {
printf(".");
fflush(stdout);
PUTCHAR('.');
Syslog('m', " From : %s", Upr.from);
Syslog('m', " To : %s", Upr.to);
Syslog('m', " Subj : %s", Upr.subj);
@ -1692,8 +1706,10 @@ void BlueWave_Fetch()
Close_Msgbase(msgs.Base);
}
} else {
Enter(1);
/* No Write access to area */
printf("\n%s %s\n", (char *)Language(453), msgs.Name);
sprintf(temp, "%s %s", (char *)Language(453), msgs.Name);
poutCR(LIGHTRED, BLACK, temp);
WriteError("No Write Access to area %s", msgs.Name);
}
}
@ -1701,17 +1717,16 @@ void BlueWave_Fetch()
}
memset(&Upr, 0, sizeof(UPL_REC));
}
printf("\n");
colour(CFG.TextColourF, CFG.TextColourB);
Enter(1);
if (i) {
/* Messages imported */
printf("%d %s\n", i, (char *)Language(454));
sprintf(temp, "%d %s", i, (char *)Language(454));
poutCR(CFG.TextColourF, CFG.TextColourB, temp);
ReadExitinfo();
exitinfo.iPosted += i;
WriteExitinfo();
do_mailout = TRUE;
}
fflush(stdout);
fclose(up);
sprintf(temp, "%s/%s", Dirpath, Filename);
unlink(temp);
@ -1731,9 +1746,8 @@ void BlueWave_Fetch()
iol = fopen(temp, "r");
}
if (iol != NULL) {
colour(LIGHTBLUE, BLACK);
/* Processing Offline Configuration */
printf("%s\n", (char *)Language(455));
poutCR(LIGHTBLUE, BLACK, (char *)Language(455));
Syslog('+', "Processing BlueWave v3 configuration file \"%s\"", Filename);
OLC_head = FALSE;
@ -1869,9 +1883,9 @@ void BlueWave_Fetch()
fclose(iol);
sprintf(temp, "%s/%s", Dirpath, Filename);
unlink(temp);
colour(CYAN, BLACK);
/* Message areas selected */
printf("%d %s\n", i, (char *)Language(456));
sprintf(temp, "%d %s", i, (char *)Language(456));
poutCR(CYAN, BLACK, temp);
Syslog('+', " %d active message areas.", i);
}
@ -1891,12 +1905,11 @@ void BlueWave_Fetch()
while (fread(&Req, sizeof(REQ_REC), 1, tp) == 1) {
Syslog('m', " File %s", Req.filename);
colour(CFG.TextColourF, CFG.TextColourB);
printf("%-12s ", Req.filename);
sprintf(temp, "%-12s ", Req.filename);
pout(CFG.TextColourF, CFG.TextColourB, temp);
colour(CFG.HiliteF, CFG.HiliteB);
fflush(stdout);
printf("\n");
Enter(1);
}
fclose(tp);
@ -1915,7 +1928,7 @@ void BlueWave_Fetch()
unsigned long BlueWave_PackArea(unsigned long ulLast, long Area)
{
FILE *fdm, *fdfti, *fdmix;
char *Temp, *Text;
char *Temp, *Text, msg[81];
unsigned long Number;
MIX_REC Mix;
FTI_REC Fti;
@ -1998,9 +2011,8 @@ unsigned long BlueWave_PackArea(unsigned long ulLast, long Area)
if (BarWidth != (unsigned short)((Total * 61L) / TotalPack)) {
BarWidth = (unsigned short)((Total * 61L) / TotalPack);
colour(CYAN, BLACK);
printf("\r%.*s", BarWidth, "ÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛ");
fflush(stdout);
sprintf(msg, "\r%.*s", BarWidth, "ÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛ");
pout(CYAN, BLACK, msg);
}
} while (Msg_Next(&Number));
}
@ -2044,7 +2056,7 @@ void OLR_DownQWK(void)
msg_high *tmp, *mhl = NULL;
if (strlen(CFG.bbsid) == 0) {
printf("System configuration error, inform sysop\n");
poutCR(LIGHTRED, BLACK, (char *)"System configuration error, inform sysop");
WriteError("Config OLR bbsid not configured");
Pause();
return;
@ -2055,9 +2067,8 @@ void OLR_DownQWK(void)
Total = TotalPersonal = 0L;
clear();
colour(LIGHTBLUE, BLACK);
/* QWK Offline Download */
printf("%s\n", (char *)Language(458));
poutCR(LIGHTBLUE, BLACK, (char *)Language(458));
Work = calloc(PATH_MAX, sizeof(char));
Temp = calloc(PATH_MAX, sizeof(char));
@ -2199,15 +2210,18 @@ void OLR_DownQWK(void)
fclose(tf);
if (Total) {
Enter(1);
/* Packing with */
printf("\n%s ", (char *)Language(446));
PUTSTR((char *)Language(446));
PUTCHAR(' ');
sprintf(Temp, "%s/etc/archiver.data", getenv("MBSE_ROOT"));
if ((af = fopen(Temp, "r")) != NULL) {
fread(&archiverhdr, sizeof(archiverhdr), 1, af);
while (fread(&archiver, archiverhdr.recsize, 1, af) == 1) {
if (archiver.available && (!strcmp(archiver.name, exitinfo.Archiver))) {
Syslog('+', "Archiver %s", archiver.comment);
printf("%s ", archiver.comment);
PUTSTR(archiver.comment);
PUTCHAR(' ');
sprintf(Temp, "%s/CONTROL.DAT", Work);
AddArc(Temp, Pktname);
alarm_on();
@ -2237,15 +2251,15 @@ void OLR_DownQWK(void)
}
}
colour(CFG.HiliteF, CFG.HiliteB);
if (rc == FALSE) {
Syslog('+', "QWK download failed");
/* Download failed */
printf("%s", (char *)Language(447));
pout(CFG.HiliteF, CFG.HiliteB, (char *)Language(447));
} else {
Syslog('+', "QWK download successfull");
PUTCHAR('\r');
/* Download successfull */
printf("\r%s\n", (char *)Language(448));
poutCR(CFG.HiliteF, CFG.HiliteB, (char *)Language(448));
if (mhl != NULL)
UpdateLR(mhl, mf);
@ -2255,7 +2269,7 @@ void OLR_DownQWK(void)
free(Temp);
free(Work);
printf("\n\n");
Enter(2);
Pause();
}
@ -2274,9 +2288,8 @@ void QWK_Fetch()
fidoaddr dest;
int HasTear;
colour(LIGHTBLUE, BLACK);
/* Processing BlueWave reply packet */
printf("%s\n", (char *)Language(459));
poutCR(LIGHTBLUE, BLACK, (char *)Language(459));
temp = calloc(PATH_MAX, sizeof(char));
otemp = calloc(PATH_MAX, sizeof(char));
nWidth = 78;
@ -2298,7 +2311,7 @@ void QWK_Fetch()
fclose(up);
unlink(temp);
/* ERROR in packet */
printf("%s\n", (char *)Language(451));
poutCR(LIGHTRED, BLACK, (char *)Language(451));
free(temp);
free(otemp);
Pause();
@ -2509,17 +2522,16 @@ void QWK_Fetch()
fclose(up);
}
printf("\n");
colour(CFG.TextColourF, CFG.TextColourB);
Enter(1);
if (nPosted) {
/* Messages imported */
printf("%d %s\n", nPosted, (char *)Language(454));
sprintf(temp, "%d %s", nPosted, (char *)Language(454));
poutCR(CFG.TextColourF, CFG.TextColourB, temp);
ReadExitinfo();
exitinfo.iPosted += nPosted;
WriteExitinfo();
do_mailout = TRUE;
}
fflush(stdout);
sprintf(temp, "%s/%s", Dirpath, Filename);
Syslog('m', "Unlink %s rc=%d", temp, unlink(temp));
free(temp);
@ -2575,7 +2587,7 @@ unsigned long QWK_PackArea(unsigned long ulLast, long Area)
{
FILE *fdm, *fdi, *fdp;
float out, in;
char *Work, *Temp, *Text;
char *Work, *Temp, *Text, msg[81];
unsigned long Number, Pos, Size, Blocks;
int Pack = FALSE;
struct tm *tp;
@ -2695,9 +2707,9 @@ unsigned long QWK_PackArea(unsigned long ulLast, long Area)
if (BarWidth != (unsigned short)((Total * 61L) / TotalPack)) {
BarWidth = (unsigned short)((Total * 61L) / TotalPack);
colour(CYAN, BLACK);
printf("\r%.*s", BarWidth, "ÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛ");
fflush(stdout);
PUTCHAR('\r');
sprintf(msg, "%.*s", BarWidth, "ÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛ");
pout(CYAN, BLACK, msg);
}
}
} while (Msg_Next(&Number));
@ -2754,7 +2766,7 @@ void OLR_DownASCII(void)
msg_high *tmp, *mhl = NULL;
if (strlen(CFG.bbsid) == 0) {
printf("System configuration error, inform sysop\n");
poutCR(LIGHTRED, BLACK, (char *)"System configuration error, inform sysop");
WriteError("Config OLR bbsid not configured");
Pause();
return;
@ -2765,9 +2777,8 @@ void OLR_DownASCII(void)
Total = TotalPersonal = 0L;
clear();
colour(LIGHTBLUE, BLACK);
/* ASCII Offline Download */
printf("%s\n", (char *)Language(460));
poutCR(LIGHTBLUE, BLACK, (char *)Language(460));
Work = calloc(PATH_MAX, sizeof(char));
Temp = calloc(PATH_MAX, sizeof(char));
@ -2829,15 +2840,18 @@ void OLR_DownASCII(void)
}
if (Total) {
Enter(1);
/* Packing with */
printf("\n%s ", (char *)Language(446));
PUTSTR((char *)Language(446));
PUTCHAR(' ');
sprintf(Temp, "%s/etc/archiver.data", getenv("MBSE_ROOT"));
if ((af = fopen(Temp, "r")) != NULL) {
fread(&archiverhdr, sizeof(archiverhdr), 1, af);
while (fread(&archiver, archiverhdr.recsize, 1, af) == 1) {
if (archiver.available && (!strcmp(archiver.name, exitinfo.Archiver))) {
Syslog('+', "Archiver %s", archiver.comment);
printf("%s ", archiver.comment);
PUTSTR(archiver.comment);
PUTCHAR(' ');
alarm_on();
for (tmp = mhl; tmp; tmp = tmp->next) {
@ -2853,15 +2867,15 @@ void OLR_DownASCII(void)
}
}
colour(CFG.HiliteF, CFG.HiliteB);
if (rc == FALSE) {
Syslog('+', "ASCII download failed");
/* Download failed */
printf("%s", (char *)Language(447));
pout(CFG.HiliteF, CFG.HiliteB, (char *)Language(447));
} else {
Syslog('+', "ASCII download successfull");
PUTCHAR('\r');
/* Download successfull */
printf("\r%s\n", (char *)Language(448));
poutCR(CFG.HiliteF, CFG.HiliteB, (char *)Language(448));
if (mhl != NULL)
UpdateLR(mhl, mf);
@ -2870,7 +2884,7 @@ void OLR_DownASCII(void)
tidy_high(&mhl);
free(Temp);
free(Work);
printf("\n\n");
Enter(2);
Pause();
}
@ -2882,7 +2896,7 @@ void OLR_DownASCII(void)
unsigned long ASCII_PackArea(unsigned long ulLast, long Area)
{
FILE *fp;
char *Work, *Temp, *Text;
char *Work, *Temp, *Text, msg[81];
unsigned long Number;
int Pack = FALSE;
struct tm *tp;
@ -2938,9 +2952,9 @@ unsigned long ASCII_PackArea(unsigned long ulLast, long Area)
if (BarWidth != (unsigned short)((Total * 61L) / TotalPack)) {
BarWidth = (unsigned short)((Total * 61L) / TotalPack);
colour(CYAN, BLACK);
printf("\r%.*s", BarWidth, "ÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛ");
fflush(stdout);
PUTCHAR('\r');
sprintf(msg, "%.*s", BarWidth, "ÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛ");
pout(CYAN, BLACK, msg);
}
}
} while (Msg_Next(&Number));

View File

@ -37,6 +37,7 @@
#include "input.h"
#include "language.h"
#include "term.h"
#include "ttyio.h"
char sOneliner[81];
@ -78,10 +79,10 @@ void Oneliner_Add()
Oneliner_Check();
sFileName = calloc(128, sizeof(char));
sFileName = calloc(PATH_MAX, sizeof(char));
sprintf(sFileName,"%s/etc/oneline.data", getenv("MBSE_ROOT"));
if((pOneline = fopen(sFileName, "a+")) == NULL) {
if ((pOneline = fopen(sFileName, "a+")) == NULL) {
WriteError("Can't open file: %s", sFileName);
return;
}
@ -90,27 +91,25 @@ void Oneliner_Add()
memset(&ol, 0, sizeof(ol));
clear();
/* MBSE BBS Oneliners will randomly appear on the main menu. */
poutCR(15, 0, Language(341));
poutCR(WHITE, BLACK, Language(341));
Enter(1);
/* Obscene or libellous oneliners will be deleted!! */
poutCR(15, 1, Language(342));
poutCR(WHITE, BLUE, Language(342));
Enter(1);
/* Please enter your oneliner below. You have 75 characters.*/
pout(12, 0, Language(343));
Enter(1);
pout(15, 0, (char *)"> ");
poutCR(LIGHTRED, BLACK, Language(343));
pout(WHITE, BLACK, (char *)"> ");
colour(CFG.InputColourF, CFG.InputColourB);
fflush(stdout);
GetstrC(temp, 75);
if((strcmp(temp, "")) == 0) {
if ((strcmp(temp, "")) == 0) {
fclose(pOneline);
return;
} else {
x = strlen(temp);
if(x >= 78)
if (x >= 78)
temp[78] = '\0';
strcpy(ol.Oneline, temp);
@ -118,7 +117,7 @@ void Oneliner_Add()
Enter(1);
/* Oneliner added */
pout(3, 0, Language(344));
pout(CYAN, BLACK, Language(344));
Enter(2);
Pause();
@ -141,9 +140,7 @@ void Oneliner_Add()
*/
void Oneliner_Print()
{
int i, x, z;
int Strlen;
int Maxlen = 80;
int i, x, z, Strlen, Maxlen = 80;
char sNewOneliner[81] = "";
/*
@ -167,16 +164,18 @@ void Oneliner_Print()
*/
Strlen = strlen(sOneliner);
if(Strlen == Maxlen)
printf("%s\n", sOneliner);
else {
if (Strlen == Maxlen) {
PUTSTR(sOneliner);
Enter(1);
} else {
x = Maxlen - Strlen;
z = x / 2;
for(i = 0; i < z; i++)
strcat(sNewOneliner," ");
strcat(sNewOneliner, sOneliner);
colour(iColour, 0);
printf("%s\n", sNewOneliner);
PUTSTR(sNewOneliner);
Enter(1);
}
}
@ -188,8 +187,7 @@ void Oneliner_Print()
char *Oneliner_Get()
{
FILE *pOneline;
int i, j, in, id;
int recno = 0;
int i, j, in, id, recno = 0;
long offset;
int nrecno;
char *sFileName;
@ -201,7 +199,7 @@ char *Oneliner_Get()
sFileName = calloc(128, sizeof(char));
sprintf(sFileName,"%s/etc/oneline.data", getenv("MBSE_ROOT"));
if((pOneline = fopen(sFileName, "r+")) == NULL) {
if ((pOneline = fopen(sFileName, "r+")) == NULL) {
WriteError("Can't open file: %s", sFileName);
return '\0';
}
@ -248,62 +246,59 @@ char *Oneliner_Get()
void Oneliner_List()
{
FILE *pOneline;
int recno = 0;
int Colour = 1;
char *sFileName;
int recno = 0, Colour = 1;
char *sFileName, msg[81];
clear();
sFileName = calloc(128, sizeof(char));
sFileName = calloc(PATH_MAX, sizeof(char));
sprintf(sFileName,"%s/etc/oneline.data", getenv("MBSE_ROOT"));
if((pOneline = fopen(sFileName, "r+")) == NULL) {
if ((pOneline = fopen(sFileName, "r+")) == NULL) {
WriteError("Can't open file: %s", sFileName);
return;
}
fread(&olhdr, sizeof(olhdr), 1, pOneline);
if((SYSOP == TRUE) || (exitinfo.Security.level >= CFG.sysop_access)) {
if ((SYSOP == TRUE) || (exitinfo.Security.level >= CFG.sysop_access)) {
/* # A Date User Description */
pout(10, 0, Language(345));
Enter(1);
pout(LIGHTGREEN, BLACK, Language(345));
} else {
/* # Description */
pout(10, 0, Language(346));
Enter(1);
pout(LIGHTGREEN, BLACK, Language(346));
}
colour(2, 0);
Enter(1);
colour(GREEN, BLACK);
sLine();
while (fread(&ol, olhdr.recsize, 1, pOneline) == 1) {
if((SYSOP == TRUE) || (exitinfo.Security.level >= CFG.sysop_access)) {
colour(15, 0);
printf("%2d", recno);
if ((SYSOP == TRUE) || (exitinfo.Security.level >= CFG.sysop_access)) {
sprintf(msg, "%2d", recno);
pout(WHITE, BLACK, msg);
colour(9, 0);
printf("%2d ", ol.Available);
sprintf(msg, "%2d ", ol.Available);
pout(LIGHTBLUE, BLACK, msg);
colour(11, 0);
printf("%s ", ol.DateOfEntry);
pout(LIGHTCYAN, BLACK, ol.DateOfEntry);
colour(3, 0);
printf("%-15s ", ol.UserName);
sprintf(msg, "%-15s ", ol.UserName);
pout(CYAN, BLACK, msg);
colour(Colour, 0);
printf("%-.48s\n", ol.Oneline);
sprintf(msg, "%-.48s", ol.Oneline);
poutCR(Colour, BLACK, msg);
} else {
colour(15, 0);
printf("%2d ", recno);
colour(Colour, 0);
printf("%-.76s\n", ol.Oneline);
sprintf(msg, "%2d ", recno);
pout(WHITE, BLACK, msg);
sprintf(msg, "%-.76s", ol.Oneline);
poutCR(Colour, BLACK, msg);
}
recno++;
Colour++;
if(Colour >= 16)
if (Colour >= 16)
Colour = 1;
}
fclose(pOneline);
printf("\n");
Enter(1);
Pause();
free(sFileName);
}
@ -315,12 +310,12 @@ void Oneliner_Show()
FILE *pOneline;
int recno = 0;
long offset;
char *sFileName;
char *sFileName, msg[11];
sFileName = calloc(128, sizeof(char));
sFileName = calloc(PATH_MAX, sizeof(char));
sprintf(sFileName,"%s/etc/oneline.data", getenv("MBSE_ROOT"));
if((pOneline = fopen(sFileName, "r+")) == NULL) {
if ((pOneline = fopen(sFileName, "r+")) == NULL) {
WriteError("Can't open file: %s", sFileName);
return;
}
@ -328,7 +323,7 @@ void Oneliner_Show()
Enter(1);
/* Please enter number to list: */
pout(15, 0, Language(347));
pout(WHITE, BLACK, Language(347));
colour(CFG.InputColourF, CFG.InputColourB);
scanf("%d", &recno);
@ -338,10 +333,11 @@ void Oneliner_Show()
fread(&ol, olhdr.recsize, 1, pOneline);
colour(15, 0);
printf("\n%d ", recno);
colour(12, 0);
printf("%s\n\n", ol.Oneline);
Enter(1);
sprintf(msg, "%d ", recno);
pout(WHITE, BLACK, msg);
pout(LIGHTRED, BLACK, ol.Oneline);
Enter(2);
Pause();
fclose(pOneline);
@ -353,18 +349,14 @@ void Oneliner_Show()
void Oneliner_Delete()
{
FILE *pOneline;
int recno = 0;
int recno = 0, nrecno = 0;
long offset;
int nrecno = 0;
char srecno[7];
char *sFileName;
char stemp[50];
char sUser[35];
char srecno[7], *sFileName, stemp[50], sUser[36], msg[81];
sFileName = calloc(128, sizeof(char));
sFileName = calloc(PATH_MAX, sizeof(char));
sprintf(sFileName,"%s/etc/oneline.data", getenv("MBSE_ROOT"));
if((pOneline = fopen(sFileName, "r+")) == NULL) {
if ((pOneline = fopen(sFileName, "r+")) == NULL) {
WriteError("Can't open file: %s", sFileName);
return;
}
@ -372,11 +364,11 @@ void Oneliner_Delete()
Enter(1);
/* Please enter number to delete: */
pout(15, 0, Language(331));
pout(WHITE, BLACK, Language(331));
colour(CFG.InputColourF, CFG.InputColourB);
GetstrC(srecno, 6);
if((strcmp(srecno,"")) == 0) {
if ((strcmp(srecno,"")) == 0) {
fclose(pOneline);
return;
}
@ -390,10 +382,10 @@ void Oneliner_Delete()
recno++;
}
if(nrecno >= recno) {
if (nrecno >= recno) {
Enter(1);
/* Record does not exist */
pout(12, 0, Language(319));
pout(LIGHTRED, BLACK, Language(319));
Enter(2);
fclose(pOneline);
Pause();
@ -411,11 +403,13 @@ void Oneliner_Delete()
/* Print UserName to String, so we can compare for deletion */
sprintf(sUser,"%s", exitinfo.sUserName);
if((strcmp(sUser, ol.UserName)) != 0) {
if((!SYSOP) && (exitinfo.Security.level < CFG.sysop_access)) {
colour(12, 0);
if ((strcmp(sUser, ol.UserName)) != 0) {
if ((!SYSOP) && (exitinfo.Security.level < CFG.sysop_access)) {
Enter(1);
/* Record *//* does not belong to you.*/
printf("\n%s%s %s\n\n", (char *) Language(332), stemp, (char *) Language(333));
sprintf(msg, "%s%s %s", (char *) Language(332), stemp, (char *) Language(333));
pout(LIGHTRED, BLACK, msg);
Enter(2);
Syslog('!', "User tried to delete somebody else's record: %s", stemp);
Pause();
fclose(pOneline);
@ -423,20 +417,21 @@ void Oneliner_Delete()
}
}
Enter(1);
if ((ol.Available ) == FALSE) {
colour(12, 0);
/* Record: %d already marked for deletion */
printf("\n%s%d %s\n\n", (char *) Language(332), nrecno, (char *) Language(334));
sprintf(msg, "%s%d %s", (char *) Language(332), nrecno, (char *) Language(334));
pout(LIGHTRED, BLACK, msg);
Syslog('!', "User tried to mark an already marked record: %s", stemp);
Pause();
} else {
ol.Available = FALSE;
colour(10, 0);
/* Record *//* marked for deletion */
printf("\n%s%d %s\n\n", (char *) Language(332), nrecno, (char *) Language(334));
sprintf(msg, "%s%d %s", (char *) Language(332), nrecno, (char *) Language(334));
pout(LIGHTGREEN, BLACK, msg);
Syslog('+', "User marked oneliner record for deletion: %s", stemp);
Pause();
}
Enter(2);
Pause();
if (fseek(pOneline, offset, 0) != 0)
WriteError("Can't move pointer in %s",sFileName);

162
mbsebbs/openport.c Normal file
View File

@ -0,0 +1,162 @@
/*****************************************************************************
*
* $Id$
*
*****************************************************************************
* Copyright (C) 1997-2004
*
* Michiel Broek FIDO: 2:280/2802
* Beekmansbos 10
* 1971 BV IJmuiden
* the Netherlands
*
* This file is part of MBSE BBS.
*
* This BBS is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the
* Free Software Foundation; either version 2, or (at your option) any
* later version.
*
* MBSE BBS is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with MBSE BBS; see the file COPYING. If not, write to the Free
* Software Foundation, 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
*****************************************************************************/
#include "../config.h"
#include "../lib/mbselib.h"
#include "ttyio.h"
#include "openport.h"
int hanged_up = 0;
static struct termios savetios;
static struct termios tios;
/*
* Set port to local, hangup using DTR drop.
*/
void hangup(void)
{
struct termios Tios;
tcflag_t cflag;
speed_t ispeed, ospeed;
int rc;
Syslog('t', "Setting port local");
if (isatty(0)) {
if ((rc = tcgetattr(0,&Tios))) {
WriteError("$tcgetattr(0,save) return %d",rc);
return;
}
Syslog('+', "Lowering DTR to hangup");
cflag = Tios.c_cflag | CLOCAL;
ispeed = cfgetispeed(&tios);
ospeed = cfgetospeed(&tios);
cfsetispeed(&Tios,0);
cfsetospeed(&Tios,0);
if ((rc = tcsetattr(0,TCSADRAIN,&Tios)))
WriteError("$tcsetattr(0,TCSADRAIN,hangup) return %d",rc);
sleep(1); /* as far as I notice, DTR goes back high on next op. */
Tios.c_cflag = cflag;
cfsetispeed(&Tios,ispeed);
cfsetospeed(&Tios,ospeed);
if ((rc = tcsetattr(0,TCSADRAIN,&Tios)))
Syslog('t', "$tcsetattr(0,TCSADRAIN,clocal) return %d",rc);
} else {
Syslog('t', "Not at a tty");
}
return;
}
/*
* Put the current opened tty in raw mode.
*/
int rawport(void)
{
int rc = 0;
Syslog('t', "rawport()");
tty_status = 0;
Syslog('t', "ttyname 0 %s", ttyname(0));
Syslog('t', "ttyname 1 %s", ttyname(1));
Syslog('t', "fd = %d", fileno(stdin));
Syslog('t', "fd = %d", fileno(stdout));
Syslog('t', "fd = %d", fileno(stderr));
if (isatty(0)) {
if ((rc = tcgetattr(0,&savetios))) {
WriteError("$tcgetattr(0,save) return %d",rc);
return rc;
}
tios = savetios;
tios.c_iflag &= ~(INLCR | ICRNL | ISTRIP | IXON ); /* IUCLC removed for FreeBSD */
/*
* Map CRNL modes strip control characters and flow control
*/
tios.c_oflag &= ~OPOST; /* Don't do ouput character translation */
tios.c_lflag &= ~(ICANON | ECHO); /* No canonical input and no echo */
tios.c_cc[VMIN] = 1; /* Receive 1 character at a time */
tios.c_cc[VTIME] = 0; /* No time limit per character */
if ((rc = tcsetattr(0,TCSADRAIN,&tios)))
WriteError("$tcsetattr(0,TCSADRAIN,raw) return %d",rc);
} else {
Syslog('t', "not at a tty");
}
return rc;
}
int cookedport(void)
{
int rc = 0;
Syslog('t', "cookedport()");
if (isatty(0)) {
if ((rc = tcsetattr(0,TCSAFLUSH,&savetios)))
Syslog('t', "$tcsetattr(0,TCSAFLUSH,save) return %d", rc);
}
return rc;
}
void sendbrk(void)
{
Syslog('t', "Send break");
if (isatty(0)) {
#if (defined(TIOCSBRK))
Syslog('t', "TIOCSBRK");
ioctl(0, TIOCSBRK, 0L);
#elif (defined(TCSBRK))
Syslog('t', "TCSBRK");
ioctl(0, TCSBRK, 0L);
#else /* any ideas about BSD? */
;
#endif
}
}

11
mbsebbs/openport.h Normal file
View File

@ -0,0 +1,11 @@
#ifndef _OPENPORT_H
#define _OPENPORT_H
/* $Id$ */
void hangup(void);
int rawport(void);
int cookedport(void);
void sendbrk(void);
#endif

View File

@ -41,6 +41,7 @@
#include "mail.h"
#include "language.h"
#include "term.h"
#include "ttyio.h"
extern pid_t mypid;
@ -65,33 +66,34 @@ void Page_Sysop(char *String)
if (CFG.iAskReason) {
locate(6, 0);
colour(BLUE, BLACK);
printf("%c", 213);
PUTCHAR(213);
for (i = 0; i < 78; i++)
printf("%c", 205);
printf("%c\n", 184);
PUTCHAR(205);
PUTCHAR(184);
Enter(1);
colour(LIGHTGRAY, BLACK);
for (i = 0; i < 78; i++)
printf("%c", 250);
printf("\n");
PUTCHAR(250);
Enter(1);
colour(BLUE, BLACK);
printf("%c", 212);
PUTCHAR(212);
for (i = 0; i < 78; i++)
printf("%c", 205);
printf("%c\n", 190);
PUTCHAR(205);
PUTCHAR(190);
Enter(1);
locate(7, 2);
colour(LIGHTGRAY, BLACK);
fflush(stdout);
GetPageStr(temp, 76);
colour(BLUE, BLACK);
printf("%c", 212);
PUTCHAR(212);
for (i = 0; i < 78; i++)
printf("%c", 205);
printf("%c\n", 190);
PUTCHAR(205);
PUTCHAR(190);
Enter(1);
if ((strcmp(temp, "")) == 0)
return;
@ -102,7 +104,6 @@ void Page_Sysop(char *String)
sprintf(Reason, "User want's to chat");
}
CFG.iMaxPageTimes--;
if (CFG.iMaxPageTimes <= 0) {
@ -129,7 +130,7 @@ void Page_Sysop(char *String)
pout(WHITE, BLACK, (char *)"[");
colour(BLUE, BLACK);
for (i = 0; i < CFG.iPageLength; i++)
printf("%c", 176);
PUTCHAR(176);
pout(WHITE, BLACK, (char *)"]");
locate(16, ((80 - CFG.iPageLength) / 2 - 2) + 1);
@ -168,8 +169,7 @@ void Page_Sysop(char *String)
* Check for other errors
*/
if (strcmp(buf, "100:1,3;") == 0) {
colour(LIGHTRED, BLACK);
printf("Internal system error, the sysop is informed");
pout(LIGHTRED, BLACK, (char *)"Internal system error, the sysop is informed");
Enter(2);
Syslog('!', "Got error on page sysop command");
Pause();
@ -183,8 +183,7 @@ void Page_Sysop(char *String)
*/
colour(LIGHTBLUE, BLACK);
for (i = 0; i < CFG.iPageLength; i++) {
printf("%c", 219);
fflush(stdout);
PUTCHAR(219);
sleep(1);
sprintf(buf, "CISC:1,%d", mypid);
@ -214,7 +213,7 @@ void Page_Sysop(char *String)
}
PageReason();
printf("\n\n\n");
Enter(3);
Pause();
if (strlen(Reason))
SysopComment(Reason);
@ -235,12 +234,6 @@ void GetPageStr(char *sStr, int iMaxlen)
unsigned char ch = 0;
int iPos = 0;
if ((ttyfd = open ("/dev/tty", O_RDWR)) < 0) {
perror("open 6");
return;
}
Setraw();
strcpy(sStr, "");
alarm_on();
@ -248,8 +241,9 @@ void GetPageStr(char *sStr, int iMaxlen)
ch = Readkey();
if (((ch == 8) || (ch == KEY_DEL) || (ch == 127)) && (iPos > 0)) {
printf("\b%c\b", 250);
fflush(stdout);
PUTCHAR('\b');
PUTCHAR(250);
PUTCHAR('\b');
sStr[--iPos]='\0';
}
@ -257,16 +251,14 @@ void GetPageStr(char *sStr, int iMaxlen)
if (iPos <= iMaxlen) {
iPos++;
sprintf(sStr, "%s%c", sStr, ch);
printf("%c", ch);
PUTCHAR(ch);
fflush(stdout);
} else
ch=13;
}
}
Unsetraw();
close(ttyfd);
printf("\n");
Enter(1);
}
@ -309,9 +301,9 @@ void PageReason()
if (Lines == j) {
Striplf(String);
locate(18, ((78 - strlen(String) ) / 2));
pout(15, 0, (char *)"[");
pout(9, 0, String);
pout(15, 0, (char *)"]");
pout(WHITE, BLACK, (char *)"[");
pout(LIGHTBLUE, BLACK, String);
pout(WHITE, BLACK, (char *)"]");
iFoundString = TRUE;
}
@ -323,9 +315,9 @@ void PageReason()
/* Sysop currently is not available ... please leave a comment */
sprintf(String, "%s", (char *) Language(155));
locate(18, ((78 - strlen(String) ) / 2));
pout(15, 0, (char *)"[");
pout(9, 0, String);
pout(15, 0, (char *)"]");
pout(WHITE, BLACK, (char *)"[");
pout(LIGHTBLUE, BLACK, String);
pout(WHITE, BLACK, (char *)"]");
}
free(temp);

View File

@ -35,19 +35,21 @@
#include "pinfo.h"
#include "input.h"
#include "term.h"
#include "ttyio.h"
void ls(int a)
{
printf("%c ", a ? 179 : '|');
PUTCHAR(a ? 179 : '|');
}
void rs(int a)
{
colour(8, 0);
printf("%c\n", a ? 179 : '|');
colour(DARKGRAY, BLACK);
PUTCHAR(a ? 179 : '|');
Enter(1);
}
@ -58,7 +60,7 @@ void wl(int a)
ls(a);
for(i = 0; i < 76; i++)
printf(" ");
PUTCHAR(' ');
rs(a);
}
@ -78,70 +80,71 @@ void cr(void)
temp = calloc(81, sizeof(char));
clear();
colour(8, 0);
colour(DARKGRAY, BLACK);
/* Print top row */
printf("%c", a ? 213 : '+');
for(i = 0; i < 77; i++)
printf("%c", a ? 205 : '=');
printf("%c\n", a ? 184 : '+');
PUTCHAR(a ? 213 : '+');
for (i = 0; i < 76; i++)
PUTCHAR(a ? 205 : '=');
PUTCHAR(a ? 184 : '+');
Enter(1);
wl(a);
ls(a);
sprintf(temp, "MBSE Bulletin Board System %s (%s-%s)", VERSION, OsName(), OsCPU());
pout(14, 0, padleft(temp, 76, ' '));
pout(YELLOW, BLACK, padleft(temp, 76, ' '));
rs(a);
wl(a);
ls(a);
sprintf(temp, "%s", COPYRIGHT);
pout(11, 0, padleft(temp, 76, ' '));
pout(LIGHTCYAN, BLACK, padleft(temp, 76, ' '));
rs(a);
wl(a);
ls(a);
sprintf(temp, "Compiled on %s at %s", __DATE__, __TIME__);
pout(14, 0, padleft(temp, 76, ' '));
pout(LIGHTRED, BLACK, padleft(temp, 76, ' '));
rs(a);
wl(a);
ls(a);
pout(11, 0, (char *)"MBSE has been written and designed by Michiel Broek. Many others have given ");
pout(LIGHTCYAN, BLACK, (char *)"MBSE has been written and designed by Michiel Broek. Many others have given ");
rs(a);
ls(a);
pout(11, 0, (char *)"valuable time in the form of new ideas and suggestions on how to make MBSE ");
pout(LIGHTCYAN, BLACK, (char *)"valuable time in the form of new ideas and suggestions on how to make MBSE ");
rs(a);
ls(a);
pout(11, 0, (char *)"BBS a better BBS ");
pout(LIGHTCYAN, BLACK, (char *)"BBS a better BBS ");
rs(a);
wl(a);
ls(a);
pout(15, 0, (char *)"Available from http://www.mbse.dds.nl or 2:280/2802 ");
pout(WHITE, BLACK, (char *)"Available from http://www.mbse.dds.nl or 2:280/2802 ");
rs(a);
wl(a);
ls(a);
pout(12, 0, (char *)"JAM(mbp) - Copyright 1993 Joaquim Homrighausen, Andrew Milner, ");
pout(LIGHTRED, BLACK, (char *)"JAM(mbp) - Copyright 1993 Joaquim Homrighausen, Andrew Milner, ");
rs(a);
ls(a);
pout(12, 0, (char *)" Mats Birch, Mats Wallin. ");
pout(LIGHTRED, BLACK, (char *)" Mats Birch, Mats Wallin. ");
rs(a);
ls(a);
pout(12, 0, (char *)" ALL RIGHTS RESERVED. ");
pout(LIGHTRED, BLACK, (char *)" ALL RIGHTS RESERVED. ");
rs(a);
wl(a);
ls(a);
pout(9, 0, (char *)"This is free software; released under the terms of the GNU General Public ");
pout(LIGHTBLUE, BLACK, (char *)"This is free software; released under the terms of the GNU General Public ");
rs(a);
ls(a);
pout(9, 0, (char *)"License as published by the Free Software Foundation. ");
pout(LIGHTBLUE, BLACK, (char *)"License as published by the Free Software Foundation. ");
rs(a);
wl(a);
printf("%c", a ? 212 : '+');
for(i = 0; i < 77; i++)
printf("%c", a ? 205 : '=');
printf("%c", a ? 190 : '+');
PUTCHAR(a ? 212 : '+');
for (i = 0; i < 76; i++)
PUTCHAR(a ? 205 : '=');
PUTCHAR(a ? 190 : '+');
free(string);
free(temp);
printf("\n");
Enter(1);
Pause();
}

View File

@ -38,15 +38,14 @@
#include "msgutil.h"
#include "pop3.h"
#include "term.h"
#include "ttyio.h"
void error_popmail(char *);
void error_popmail(char *umsg)
{
pop3_close();
colour(LIGHTRED, BLACK);
printf("%s\r\n", umsg);
fflush(stdout);
poutCR(LIGHTRED, BLACK, umsg);
}
@ -185,9 +184,9 @@ void check_popmail(char *user, char *pass)
/*
* Show progress
*/
colour(color, BLACK);
printf("\rFetching message %02d/%02d, total %d bytes", msgnum, tmsgs, size);
fflush(stdout);
PUTCHAR('\r');
sprintf(temp, "Fetching message %02d/%02d, total %d bytes", msgnum, tmsgs, size);
pout(color, BLACK, temp);
if (color < WHITE)
color++;
else
@ -197,16 +196,16 @@ void check_popmail(char *user, char *pass)
fclose(tp);
}
}
fflush(stdout);
}
pop3_cmd((char *)"QUIT\r\n");
pop3_close();
if (tmsgs) {
PUTCHAR('\r');
colour(LIGHTMAGENTA, BLACK);
printf("\r \r");
fflush(stdout);
pout(LIGHTMAGENTA, BLACK, (char *)" ");
PUTCHAR('\r');
}
}

View File

@ -38,6 +38,7 @@
#include "language.h"
#include "timeout.h"
#include "term.h"
#include "ttyio.h"
#define MAXSIGLINES 4
@ -83,8 +84,9 @@ void toprow(void)
pout(YELLOW, BLACK, (char *)" Õ");
for (i = 0; i < LENSIGLINES; i++)
printf("Í");
printf("¸\n");
PUTCHAR('Í');
PUTCHAR('¸');
Enter(1);
}
@ -96,8 +98,9 @@ void botrow(void)
pout(YELLOW, BLACK, (char *)" Ô");
for (i = 0; i < LENSIGLINES; i++)
printf("Í");
printf("¾\n");
PUTCHAR('Í');
PUTCHAR('¾');
Enter(1);
}
@ -139,11 +142,9 @@ int loadsignature(void)
toprow();
for (i = 0; i < MAXSIGLINES; i++) {
colour(LIGHTRED, BLACK);
printf("%d:", i+1);
colour(CFG.MoreF, CFG.MoreB);
printf("%s\n", sLiNE[i]);
fflush(stdout);
sprintf(temp, "%d:", i+1);
pout(LIGHTRED, BLACK, temp);
poutCR(CFG.MoreF, CFG.MoreB, sLiNE[i]);
}
botrow();
@ -176,10 +177,9 @@ int editsignature(void)
/* Select: */
pout(CFG.HiliteF, CFG.HiliteB, (char *) Language(115));
fflush(stdout);
alarm_on();
i = toupper(Getone());
i = toupper(Readkey());
Enter(1);
if (i == Keystroke(114, 3)) {
@ -191,9 +191,10 @@ int editsignature(void)
return TRUE;
} else if (i == Keystroke(114, 2)) {
Enter(1);
/* Edit which line: */
colour(CFG.HiliteF, CFG.HiliteB);
printf("\n %s", (char *) Language(118));
sprintf(temp, " %s", (char *) Language(118));
pout(CFG.HiliteF, CFG.HiliteB, temp);
colour(CFG.InputColourF, CFG.InputColourB);
GetstrC(temp, 3);
@ -202,27 +203,25 @@ int editsignature(void)
i = atoi(temp);
if ((i < 1) || (i > MAXSIGLINES)) {
Enter(1);
/* Line does not exist. */
printf("%s\n", (char *) Language(119));
poutCR(LIGHTRED, BLACK, (char *) Language(119));
break;
}
x = strlen(sLiNE[i-1]);
colour(LIGHTRED, BLACK);
printf("%d:", i);
colour(CFG.InputColourF, CFG.InputColourB);
printf("%s", sLiNE[i-1]);
fflush(stdout);
sprintf(temp, "%d:", i);
pout(LIGHTRED, BLACK, temp);
pout(CFG.InputColourF, CFG.InputColourB, sLiNE[i-1]);
GetstrP(sLiNE[i-1], LENSIGLINES-1, x);
} else if (i == Keystroke(114, 0)) {
/* List lines */
toprow();
for (i = 0; i < MAXSIGLINES; i++) {
colour(LIGHTRED, BLACK);
printf("%d:", i+1);
colour(CFG.MoreF, CFG.MoreB);
printf("%s\n", sLiNE[i]);
sprintf(temp, "%d:", i+1);
pout(LIGHTRED, BLACK, temp);
poutCR(CFG.MoreF, CFG.MoreB, sLiNE[i]);
}
botrow();
@ -251,9 +250,9 @@ int editsignature(void)
return TRUE;
} else if (i == Keystroke(114, 1)) {
Enter(1);
/* Edit which line: */
colour(CFG.HiliteF, CFG.HiliteB);
printf("\n%s", (char *) Language(118));
pout(CFG.HiliteF, CFG.HiliteB, (char *) Language(118));
colour(CFG.InputColourF, CFG.InputColourB);
GetstrC(temp, 3);
@ -263,15 +262,17 @@ int editsignature(void)
i = atoi(temp);
if ((i < 1) || (i > MAXSIGLINES)) {
Enter(1);
/* Line does not exist. */
printf("\n%s", (char *) Language(119));
poutCR(LIGHTRED, BLACK, (char *) Language(119));
break;
}
Enter(1);
/* Line reads: */
poutCR(CFG.MoreF, CFG.MoreB, (char *) Language(186));
printf("%d:%s\n", i, sLiNE[i-1]);
sprintf(temp, "%d:%s", i, sLiNE[i-1]);
poutCR(CFG.MoreF, CFG.MoreB, temp);
Enter(1);
/* Text to replace: */
@ -292,7 +293,7 @@ int editsignature(void)
strreplace(sLiNE[i-1], temp, temp1);
} else
printf("\n");
Enter(1);
}
free(temp);

View File

@ -33,6 +33,7 @@
#include "../lib/mbselib.h"
#include "../lib/users.h"
#include "term.h"
#include "ttyio.h"
int termmode; /* 0 = tty, 1 = ANSI */
@ -56,9 +57,10 @@ void Enter(int num)
{
int i;
for (i = 0; i < num; i++)
fprintf(stdout, "\n");
fflush(stdout);
for (i = 0; i < num; i++) {
PUTCHAR('\r');
PUTCHAR('\n');
}
}
@ -67,8 +69,7 @@ void Enter(int num)
void pout(int fg, int bg, char *Str)
{
colour(fg, bg);
fprintf(stdout, Str);
fflush(stdout);
PUTSTR(Str);
}
@ -84,9 +85,9 @@ void poutCenter(int fg, int bg, char *Str)
void poutCR(int fg, int bg, char *Str)
{
colour(fg, bg);
fputs(Str, stdout);
fprintf(stdout, "\n");
fflush(stdout);
PUTSTR(Str);
PUTCHAR('\r');
PUTCHAR('\n');
}
@ -96,19 +97,21 @@ void poutCR(int fg, int bg, char *Str)
*/
void colour(int fg, int bg)
{
char temp[61];
if (termmode == 1) {
int att=0, fore=37, back=40;
if (fg<0 || fg>31 || bg<0 || bg>7) {
fprintf(stdout, "ANSI: Illegal colour specified: %i, %i\n", fg, bg);
fflush(stdout);
sprintf(temp, "ANSI: Illegal colour specified: %i, %i\n", fg, bg);
PUTSTR(temp);
return;
}
fprintf(stdout, "[");
PUTSTR((char *)"[");
if ( fg > WHITE) {
fprintf(stdout, "5;");
PUTSTR((char *)"5;");
fg-= 16;
}
if (fg > LIGHTGRAY) {
@ -134,8 +137,8 @@ void colour(int fg, int bg)
else if (bg == LIGHTGRAY) back=47;
else back=40;
fprintf(stdout, "%d;%d;%dm", att, fore, back);
fflush(stdout);
sprintf(temp, "%d;%d;%dm", att, fore, back);
PUTSTR(temp);
}
}
@ -152,17 +155,17 @@ void Center(char *string)
Strlen = strlen(string);
if (Strlen == Maxlen)
fprintf(stdout, "%s\n", string);
PUTSTR(string);
else {
x = Maxlen - Strlen;
z = x / 2;
for (i = 0; i < z; i++)
strcat(Str, " ");
strcat(Str, string);
fprintf(stdout, "%s\n", Str);
PUTSTR(Str);
}
fflush(stdout);
PUTCHAR('\r');
PUTCHAR('\n');
free(Str);
}
@ -172,9 +175,8 @@ void clear()
{
if (termmode == 1) {
colour(LIGHTGRAY, BLACK);
fprintf(stdout, ANSI_HOME);
fprintf(stdout, ANSI_CLEAR);
fflush(stdout);
PUTSTR((char *)ANSI_HOME);
PUTSTR((char *)ANSI_CLEAR);
} else
Enter(1);
}
@ -186,14 +188,15 @@ void clear()
*/
void locate(int y, int x)
{
char temp[61];
if (termmode > 0) {
if (y > termy || x > termx) {
fprintf(stdout, "ANSI: Invalid screen coordinates: %i, %i\n", y, x);
fflush(stdout);
return;
sprintf(temp, "ANSI: Invalid screen coordinates: %i, %i\n", y, x);
} else {
sprintf(temp, "\x1B[%i;%iH", y, x);
}
fprintf(stdout, "\x1B[%i;%iH", y, x);
fflush(stdout);
PUTSTR(temp);
}
}
@ -205,19 +208,18 @@ void fLine(int Len)
if (termmode == 0)
for (x = 0; x < Len; x++)
fprintf(stdout, "-");
PUTCHAR('-');
if (termmode == 1)
for (x = 0; x < Len; x++)
fprintf(stdout, "%c", 196);
PUTCHAR(196);
fprintf(stdout, " \n");
fflush(stdout);
PUTCHAR('\r');
PUTCHAR('\n');
}
void sLine()
{
fLine(termx -1);
@ -240,9 +242,8 @@ void mvprintw(int y, int x, const char *format, ...)
va_end(va_ptr);
locate(y, x);
fprintf(stdout, outputstr);
PUTSTR(outputstr);
free(outputstr);
fflush(stdout);
}

View File

@ -39,6 +39,7 @@
#include "language.h"
#include "input.h"
#include "term.h"
#include "ttyio.h"
extern pid_t mypid; /* Pid of this program */
@ -53,7 +54,7 @@ void Check_PM(void);
void Check_PM(void)
{
static char buf[200];
char resp[128];
char resp[128], msg[81];
sprintf(buf, "CIPM:1,%d;", mypid);
if (socket_send(buf) == 0) {
@ -64,12 +65,17 @@ void Check_PM(void)
strncpy(resp, strtok(buf, ":"), 5); /* Should be 100 */
strncpy(resp, strtok(NULL, ","), 3); /* Should be 2 */
strncpy(resp, strtok(NULL, ","), 36); /* From Name */
Enter(2);
PUTCHAR('\007');
colour(CYAN, BLACK);
/* ** Message ** from */
printf("\n\n\007%s %s:\n", (char *)Language(434), resp);
sprintf(msg, "%s %s:", (char *)Language(434), resp);
poutCR(CYAN, BLACK, msg);
strncpy(resp, strtok(NULL, "\0"), 80); /* The real message */
resp[strlen(resp)-1] = '\0';
printf("%s\n", resp);
PUTSTR(resp);
Enter(1);
Pause();
}
}
@ -110,7 +116,8 @@ void TimeCheck(void)
}
if (exitinfo.iTimeLeft <= 0) {
printf("\n%s\n", (char *) Language(130));
Enter(1);
poutCR(YELLOW, BLACK, (char *) Language(130));
sleep(3);
Syslog('!', "Users time limit exceeded ... user disconnected!");
iExpired = TRUE;

View File

@ -42,11 +42,14 @@
extern int e_pid; /* Pid of external program */
extern int hanged_up; /* Hanged up status */
void die(int onsig)
{
if (onsig <= NSIG)
signal(onsig, SIG_IGN);
/*
* First check if there is a child running, if so, kill it.
*/
@ -59,11 +62,6 @@ void die(int onsig)
else
WriteError("Failed to kill pid %d", e_pid);
}
/*
* In case the child had the tty in raw mode, reset the tty
*/
execute_pth((char *)"stty", (char *)"sane", (char *)"/dev/null", (char *)"/dev/null", (char *)"/dev/null");
}
if (MsgBase.Locked)
@ -72,10 +70,13 @@ void die(int onsig)
Msg_Close();
Home();
signal(onsig, SIG_IGN);
if (onsig)
if (onsig) {
if (onsig == SIGHUP) {
hanged_up = 1;
Syslog('+', "Lost Carrier");
} else if (onsig == SIGPIPE) {
hanged_up = 1;
Syslog('+', "Broken Pipe");
} else if (onsig == SIGALRM) {
Syslog('+', "User inactivity timeout");
} else {
@ -84,8 +85,9 @@ void die(int onsig)
else
WriteError("Terminated with error %d", onsig);
}
else
} else {
Syslog(' ', "Terminated by user");
}
if (onsig == SIGSEGV) {
Syslog('+', "Last msg area %s", msgs.Name);
@ -98,9 +100,10 @@ void die(int onsig)
void alarm_sig()
{
colour(LIGHTRED, BLACK);
Enter(2);
/* Autologout: idletime reached.*/
printf("\r\n%s\r\n", (char *) Language(410));
pout(LIGHTRED, BLACK, (char *) Language(410));
Enter(2);
Syslog('!', "Autologout: idletime reached");
die(SIGALRM);

View File

@ -42,48 +42,55 @@
void TimeStats()
{
char Logdate[15];
char Logdate[21], msg[81];
Time_Now = time(NULL);
l_date = localtime(&Time_Now);
sprintf(Logdate,"%02d-%s %02d:%02d:%02d", l_date->tm_mday, GetMonth(l_date->tm_mon+1),
sprintf(Logdate, "%02d-%s %02d:%02d:%02d", l_date->tm_mday, GetMonth(l_date->tm_mon+1),
l_date->tm_hour, l_date->tm_min, l_date->tm_sec);
clear();
ReadExitinfo();
colour(15, 0);
Enter(1);
/* TIME STATISTICS for */
printf("\n%s%s ", (char *) Language(134), exitinfo.sUserName);
sprintf(msg, "%s%s ", (char *) Language(134), exitinfo.sUserName);
pout(WHITE, BLACK, msg);
/* on */
printf("%s %s\n", (char *) Language(135), Logdate);
sprintf(msg, "%s %s", (char *) Language(135), Logdate);
poutCR(WHITE, BLACK, msg);
colour(12, 0);
colour(LIGHTRED, BLACK);
fLine(79);
printf("\n");
colour(10, 0);
Enter(1);
/* Current Time */
printf("%s %s\n", (char *) Language(136), (char *) GetLocalHMS());
sprintf(msg, "%s %s", (char *) Language(136), (char *) GetLocalHMS());
poutCR(LIGHTGREEN, BLACK, msg);
/* Current Date */
printf("%s %s\n\n", (char *) Language(137), (char *) GLCdateyy());
sprintf(msg, "%s %s", (char *) Language(137), (char *) GLCdateyy());
poutCR(LIGHTGREEN, BLACK, msg);
Enter(1);
/* Connect time */
printf("%s %d %s\n", (char *) Language(138), exitinfo.iConnectTime, (char *) Language(471));
sprintf(msg, "%s %d %s", (char *) Language(138), exitinfo.iConnectTime, (char *) Language(471));
poutCR(LIGHTGREEN, BLACK, msg);
/* Time used today */
printf("%s %d %s\n", (char *) Language(139), exitinfo.iTimeUsed, (char *) Language(471));
sprintf(msg, "%s %d %s", (char *) Language(139), exitinfo.iTimeUsed, (char *) Language(471));
poutCR(LIGHTGREEN, BLACK, msg);
/* Time remaining today */
printf("%s %d %s\n", (char *) Language(140), exitinfo.iTimeLeft, (char *) Language(471));
sprintf(msg, "%s %d %s", (char *) Language(140), exitinfo.iTimeLeft, (char *) Language(471));
poutCR(LIGHTGREEN, BLACK, msg);
/* Daily time limit */
printf("%s %d %s\n", (char *) Language(141), exitinfo.iTimeUsed + exitinfo.iTimeLeft, (char *) Language(471));
sprintf(msg, "%s %d %s", (char *) Language(141), exitinfo.iTimeUsed + exitinfo.iTimeLeft, (char *) Language(471));
poutCR(LIGHTGREEN, BLACK, msg);
printf("\n");
Enter(1);
Pause();
}

594
mbsebbs/ttyio.c Normal file
View File

@ -0,0 +1,594 @@
/*****************************************************************************
*
* $Id$
* Purpose ...............: tty I/O for mbsebbs and mbnewusr
*
*****************************************************************************
* Copyright (C) 1997-2004
*
* Michiel Broek FIDO: 2:280/2802
* Beekmansbos 10
* 1971 BV IJmuiden
* the Netherlands
*
* This file is part of MBSE BBS.
*
* This BBS is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the
* Free Software Foundation; either version 2, or (at your option) any
* later version.
*
* MBSE BBS is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with MBSE BBS; see the file COPYING. If not, write to the Free
* Software Foundation, 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
*****************************************************************************/
#include "../config.h"
#include "../lib/mbselib.h"
#include "ttyio.h"
extern int hanged_up;
extern char *inetaddr;
#define TT_BUFSIZ 1024
#define NUMTIMERS 3
int tty_status = 0;
int f_flags;
static char buffer[TT_BUFSIZ];
static char *next;
static int left = 0;
static time_t timer[NUMTIMERS];
char *ttystat[]= {(char *)"Ok",
(char *)"Error",
(char *)"TimeOut",
(char *)"EOF",
(char *)"Hangup",
(char *)"Empty",
(char *)"UnCompress"};
int tty_resettimer(int tno);
void tty_resettimers(void);
int tty_settimer(int,int);
int tty_expired(int);
int tty_running(int);
#define RESETTIMER(x) tty_resettimer(x)
#define RESETTIMERS() tty_resettimers()
#define SETTIMER(x,y) tty_settimer(x,y)
#define EXPIRED(x) tty_expired(x)
#define RUNNING(x) tty_running(x)
/*
* timer functions
*/
int tty_resettimer(int tno)
{
if (tno >= NUMTIMERS) {
errno = EINVAL;
WriteError("ttyio: invalid timer No for resettimer(%d)", tno);
return -1;
}
timer[tno] = (time_t) 0;
return 0;
}
void tty_resettimers(void)
{
int i;
for (i = 0; i < NUMTIMERS; i++)
timer[i] = (time_t)0;
}
int tty_settimer(int tno, int interval)
{
if (tno >= NUMTIMERS) {
errno = EINVAL;
WriteError("ttyio: invalid timer No for settimer(%d)", tno);
return -1;
}
timer[tno]=time((time_t*)NULL)+interval;
return 0;
}
int tty_expired(int tno)
{
time_t now;
if (tno >= NUMTIMERS) {
errno = EINVAL;
WriteError("ttyio: invalid timer No for expired(%d)", tno);
return -1;
}
/*
* Check if timer is running
*/
if (timer[tno] == (time_t) 0)
return 0;
now = time(NULL);
return (now >= timer[tno]);
}
int tty_running(int tno)
{
if (tno > NUMTIMERS) {
errno = EINVAL;
WriteError("ttyio: invalid timer for tty_running(%d)", tno);
return -1;
}
/*
* check if timer is running
*/
if (timer[tno] == (time_t) 0)
return 0;
else
return 1;
}
/*
* private r/w functions
*/
static int tty_read(char *buf, int size, int tot)
{
time_t timeout, now;
int i, rc;
fd_set readfds, writefds, exceptfds;
struct timeval seltimer;
if (size == 0)
return 0;
tty_status = 0;
now = time(NULL);
timeout = (time_t)300; /* maximum of 5 minutes */
for (i = 0; i < NUMTIMERS; i++) {
if (timer[i]) {
if (now >= timer[i]) {
tty_status=STAT_TIMEOUT;
Syslog('!', "tty_read: timer %d already expired, return", i);
return -tty_status;
} else {
if (timeout > (timer[i]-now))
timeout=timer[i]-now;
}
}
}
if ((tot != -1) && (timeout > tot))
timeout=tot;
FD_ZERO(&readfds);
FD_ZERO(&writefds);
FD_ZERO(&exceptfds);
FD_SET(0,&readfds);
FD_SET(0,&exceptfds);
seltimer.tv_sec=timeout;
seltimer.tv_usec=0;
rc = select(1,&readfds,&writefds,&exceptfds,&seltimer);
if (rc < 0) {
if (hanged_up) {
tty_status=STAT_HANGUP;
WriteError("tty_read: hanged_up flag");
} else {
WriteError("$tty_read: select for read failed");
tty_status = STAT_ERROR;
}
} else if (rc == 0) {
tty_status = STAT_TIMEOUT;
} else { /* rc > 0 */
if (FD_ISSET(0,&exceptfds)) {
Syslog('!', "$tty_read: exeption error");
tty_status = STAT_ERROR;
}
}
if (tty_status) {
return -tty_status;
}
if (!FD_ISSET(0,&readfds)) {
WriteError("tty_read: Cannot be: select returned but read fd not set");
tty_status = STAT_ERROR;
return -tty_status;
}
rc = read(0,buf,size);
if (rc <= 0) {
Syslog('t', "tty_read: return %d",rc);
if (hanged_up || (errno == EPIPE) || (errno == ECONNRESET)) {
tty_status = STAT_HANGUP;
WriteError("tty_read: hanged_up flag");
} else {
tty_status = STAT_ERROR;
Syslog('!', "tty_read: error flag");
}
rc=-tty_status;
}
return rc;
}
int tty_write(char *buf, int size)
{
int result;
tty_status=0;
result = write(1, buf, size);
if (result != size) {
if (hanged_up || (errno == EPIPE) || (errno == ECONNRESET)) {
tty_status = STAT_HANGUP;
WriteError("tty_write: hanged_up flag");
} else {
tty_status=STAT_ERROR;
Syslog('!', "tty_write: error flag");
}
}
if (tty_status)
Syslog('t', "tty_write: error %s", ttystat[tty_status]);
return -tty_status;
}
/* public r/w functions */
/*
* Check if there is data available on stdin.
*/
int tty_check(void)
{
int rc;
// try to read available (timeout = 0) data if we have no data in
// our buffer
if (!left) {
rc = tty_read(buffer, TT_BUFSIZ, 0);
if (rc > 0) {
left = rc;
}
}
return (left > 0);
}
int tty_putcheck(int size)
{
fd_set set;
struct timeval timeout;
/*
* Initialize the file descriptor set.
*/
FD_ZERO(&set);
FD_SET(1, &set);
/*
* Initialize the timeout data structure.
*/
timeout.tv_sec = 0;
timeout.tv_usec = 0;
/*
* `select' returns 0 if timeout, 1 if input available, -1 if error.
*/
return select(FD_SETSIZE, NULL, &set, NULL, &timeout);
}
int tty_waitputget(int tot)
{
int i, rc;
time_t timeout, now;
fd_set readfds, writefds, exceptfds;
struct timeval seltimer;
tty_status=0;
now = time(NULL);
timeout=(time_t)300; /* maximum of 5 minutes */
for (i = 0; i < NUMTIMERS; i++) {
if (timer[i]) {
if (now >= timer[i]) {
tty_status = STAT_TIMEOUT;
WriteError("tty_waitputget: timer %d already expired, return",i);
return -tty_status;
} else {
if (timeout > (timer[i]-now))
timeout = timer[i]-now;
}
}
}
if ((tot != -1) && (timeout > tot))
timeout=tot;
Syslog('t', "tty_waitputget: timeout=%d",timeout);
/*
* Initialize the file descriptor set.
*/
FD_ZERO(&readfds);
FD_ZERO(&writefds);
FD_ZERO(&exceptfds);
FD_SET(0, &readfds);
FD_SET(1, &writefds);
FD_SET(0, &exceptfds);
FD_SET(1, &exceptfds);
/*
* Initialize the timeout data structure.
*/
seltimer.tv_sec = timeout;
seltimer.tv_usec = 0;
/*
* `select' returns 0 if timeout, 1 if input available, -1 if error.
*/
rc = select(FD_SETSIZE, &readfds, &writefds, &exceptfds, &seltimer);
if (rc < 0) {
if (hanged_up) {
tty_status=STAT_HANGUP;
WriteError("tty_waitputget: hanged_up flag");
} else {
WriteError("$tty_waitputget: select failed");
tty_status=STAT_ERROR;
}
} else if (rc == 0) {
tty_status=STAT_TIMEOUT;
} else {
/* rc > 0 */
if ((FD_ISSET(0,&exceptfds)) || (FD_ISSET(1,&exceptfds))) {
WriteError("$tty_waitputget: exeption error");
tty_status=STAT_ERROR;
}
}
if (tty_status) {
Syslog('t', "tty_waitputget: return after select status %s",ttystat[tty_status]);
return -tty_status;
}
rc = 0;
if (FD_ISSET(0,&readfds))
rc |= 1;
if (FD_ISSET(1,&writefds))
rc |= 2;
return rc;
}
/*
* Discard all available input characters
*/
void tty_flushin(void)
{
tcflush(0, TCIFLUSH);
}
/*
* Discard all available characters in output buffer.
*/
void tty_flushout(void)
{
tcflush(1, TCOFLUSH);
}
int tty_ungetc(int c)
{
if (next == buffer) {
if (left >= TT_BUFSIZ) {
return -1;
}
next = buffer + TT_BUFSIZ - left;
memcpy(next, buffer, left);
}
next--;
*next = c;
left++;
return 0;
}
int tty_getc(int tot)
{
if (!left) {
left=tty_read(buffer,TT_BUFSIZ,tot);
next=buffer;
}
if (left <= 0) {
left=0;
return -tty_status;
} else {
left--;
return (*next++)&0xff;
}
}
int tty_get(char *buf, int size, int tot)
{
int result=0;
if (left >= size) {
memcpy(buf,next,size);
next += size;
left -= size;
return 0;
}
if (left > 0) {
memcpy(buf,next,left);
buf += left;
next += left;
size -= left;
left=0;
}
while ((result=tty_read(buf,size,tot)) > 0) {
buf += result;
size -= result;
}
return result;
}
int tty_putc(int c)
{
char buf = c;
return tty_write(&buf,1);
}
int tty_put(char *buf, int size)
{
return tty_write(buf,size);
}
int tty_putget(char **obuf, int *osize, char **ibuf, int *isize)
{
time_t timeout, now;
int i, rc;
fd_set readfds, writefds, exceptfds;
struct timeval seltimer;
tty_status = 0;
now = time(NULL);
timeout = (time_t)300; /* maximum of 5 minutes */
for (i = 0; i < NUMTIMERS; i++) {
if (timer[i]) {
if (now >= timer[i]) {
tty_status = STAT_TIMEOUT;
WriteError("tty_putget: timer %d already expired, return",i);
return -tty_status;
} else {
if (timeout > (timer[i]-now))
timeout=timer[i]-now;
}
}
}
Syslog('t', "tty_putget: timeout=%d",timeout);
FD_ZERO(&readfds);
FD_ZERO(&writefds);
FD_ZERO(&exceptfds);
FD_SET(0,&readfds);
FD_SET(1,&writefds);
FD_SET(0,&exceptfds);
FD_SET(1,&exceptfds);
seltimer.tv_sec=timeout;
seltimer.tv_usec=0;
rc=select(2,&readfds,&writefds,&exceptfds,&seltimer);
if (rc < 0) {
if (hanged_up) {
tty_status=STAT_HANGUP;
WriteError("tty_putget: hanged_up flag");
} else {
WriteError("$tty_putget: select failed");
tty_status=STAT_ERROR;
}
} else if (rc == 0) {
tty_status=STAT_TIMEOUT;
} else {
/* rc > 0 */
if ((FD_ISSET(0,&exceptfds)) || (FD_ISSET(1,&exceptfds))) {
WriteError("$tty_putget: exeption error");
tty_status=STAT_ERROR;
}
}
if (tty_status) {
Syslog('t', "tty_putget: return after select status %s",ttystat[tty_status]);
return -tty_status;
}
if (FD_ISSET(0,&readfds) && *isize) {
rc = read(0, *ibuf, *isize);
if (rc < 0) {
WriteError("$tty_putget: read failed");
tty_status=STAT_ERROR;
} else {
(*ibuf)+=rc;
(*isize)-=rc;
}
}
if (FD_ISSET(1,&writefds) && *osize) {
rc=write(1, *obuf, *osize);
if (rc < 0) {
WriteError("$tty_putget: write failed");
tty_status=STAT_ERROR;
} else {
(*obuf)+=rc;
(*osize)-=rc;
}
}
if (tty_status)
return -tty_status;
else
return ((*isize == 0) | ((*osize == 0) << 1));
}

115
mbsebbs/ttyio.h Normal file
View File

@ -0,0 +1,115 @@
/* $Id */
#ifndef TTYIO_H
#define TTYIO_H
#define TIMERNO_BRAIN 0 /* BRAIN timerno */
#define TIMERNO_RX 1 /* Receiver timerno */
#define TIMERNO_TX 2 /* Transmitter timerno */
#define RESETTIMER(x) tty_resettimer(x)
#define RESETTIMERS() tty_resettimers()
#define SETTIMER(x,y) tty_settimer(x,y)
#define EXPIRED(x) tty_expired(x)
#define RUNNING(x) tty_running(x)
#define TCHECK() tty_check()
#define PUTCHECK(x) tty_putcheck(x)
#define WAITPUTGET(x) tty_waitputget(x)
#define FLUSHOUT() tty_flushout()
#define FLUSHIN() tty_flushin()
#define PUTCHAR(x) tty_putc(x)
#define PUT(x,y) tty_put(x,y)
#define PUTSTR(x) tty_put(x,strlen(x))
#define GETCHAR(x) tty_getc(x)
#define UNGETCHAR(x) tty_ungetc(x)
#define GET(x,y,z) tty_get(x,y,z)
#define PUTGET(a,b,x,y) tty_putget(a,b,x,y)
#define STATUS tty_status
#define STAT_SUCCESS 0
#define STAT_ERROR 1
#define STAT_TIMEOUT 2
#define STAT_EOFILE 3
#define STAT_HANGUP 4
#define STAT_EMPTY 5
#define STAT_UNCOMP 6
#define SUCCESS (STATUS == 0)
#define TERROR (-STAT_ERROR)
#define TIMEOUT (-STAT_TIMEOUT)
#define EOFILE (-STAT_EOFILE)
#define HANGUP (-STAT_HANGUP)
#define EMPTY (-STAT_EMPTY)
#define GET_COMPLETE(x) (x & 1)
#define PUT_COMPLETE(x) (x & 2)
#ifndef NUL
#define NUL 0x00
#endif
#define SOH 0x01
#define STX 0x02
#define ETX 0x03
#define EOT 0x04
#define ENQ 0x05
#define ACK 0x06
#define BEL 0x07
#define BS 0x08
#define HT 0x09
#define LF 0x0a
#define VT 0x0b
#ifndef FF
#define FF 0x0c
#endif
#ifndef CR
#define CR 0x0d
#endif
#define SO 0x0e
#define SI 0x0f
#define DLE 0x10
#ifndef XON
#define XON 0x11
#endif
#define DC1 0x11
#define DC2 0x12
#ifndef XOFF
#define XOFF 0x13
#endif
#define DC3 0x13
#define DC4 0x14
#define NAK 0x15
#define SYN 0x16
#define ETB 0x17
#define CAN 0x18
#define EM 0x19
#define SUB 0x1a
#ifndef ESC
#define ESC 0x1b
#endif
#define RS 0x1e
#define US 0x1f
#define TSYNC 0xae
#define YOOHOO 0xf1
extern int tty_status;
extern int tty_resettimer(int tno);
extern void tty_resettimers(void);
extern int tty_settimer(int,int);
extern int tty_expired(int);
extern int tty_running(int);
extern int tty_check(void);
extern int tty_waitputget(int);
extern int tty_ungetc(int);
extern int tty_getc(int);
extern int tty_get(char*,int,int);
extern int tty_putcheck(int);
extern int tty_putc(int);
extern int tty_put(char*,int);
extern int tty_putget(char**,int*,char**,int*);
extern void tty_flushout(void);
extern void tty_flushin(void);
extern void sendbrk(void);
#endif

View File

@ -50,6 +50,7 @@
#include "offline.h"
#include "email.h"
#include "term.h"
#include "ttyio.h"
extern int sock;
@ -184,7 +185,8 @@ void user()
* This should not happen.
*/
WriteError("$Can't open %s", temp);
printf("Can't open userfile, run \"newuser\" first");
PUTSTR((char *)"Can't open userfile, run \"newuser\" first");
Enter(1);
ExitClient(MBERR_OK);
}
@ -199,11 +201,14 @@ void user()
if (!FoundName) {
fclose(pUsrConfig);
printf("Unknown username: %s\n", sUnixName);
sprintf(temp, "Unknown username: %s\r\n", sUnixName);
PUTSTR(temp);
/* FATAL ERROR: You are not in the BBS users file.*/
printf("%s\n", (char *) Language(389));
sprintf(temp, "%s\r\n", (char *) Language(389));
PUTSTR(temp);
/* Please run 'newuser' to create an account */
printf("%s\n", (char *) Language(390));
sprintf(temp, "%s\r\n", (char *) Language(390));
PUTSTR(temp);
Syslog('?', "FATAL: Could not find user in BBS users file.");
Syslog('?', " and system is using unix accounts\n");
Free_Language();
@ -285,7 +290,8 @@ void user()
if (CFG.max_logins && (logins > CFG.max_logins)) {
Syslog('+', "User logins %d, allowed %d, disconnecting", logins, CFG.max_logins);
colour(LIGHTRED, BLACK);
printf("%s %d %s\n", (char *) Language(18), CFG.max_logins, (char *) Language(19));
sprintf(temp, "%s %d %s\r\n", (char *) Language(18), CFG.max_logins, (char *) Language(19));
PUTSTR(temp);
Quick_Bye(MBERR_INIT_ERROR);
}

View File

@ -37,13 +37,14 @@
#include "input.h"
#include "timeout.h"
#include "term.h"
#include "ttyio.h"
void UserList(char *OpData)
{
FILE *pUsrConfig;
int LineCount = 2, iFoundName = FALSE, iNameCount = 0;
char *Name, *sTemp, *User, *temp;
char *Name, *sTemp, *User, *temp, msg[81];
struct userhdr uhdr;
struct userrec u;
@ -93,16 +94,18 @@ void UserList(char *OpData)
if ((!u.Hidden) && (!u.Deleted)) {
if ((strcasecmp(OpData, "/H")) == 0) {
if ((strcmp(u.sHandle, "") != 0 && *(u.sHandle) != ' '))
printf("%-25s", u.sHandle);
sprintf(msg, "%-25s", u.sHandle);
else
printf("%-25s", u.sUserName);
sprintf(msg, "%-25s", u.sUserName);
} else if (strcasecmp(OpData, "/U") == 0) {
printf("%-25s", u.Name);
sprintf(msg, "%-25s", u.Name);
} else {
printf("%-25s", u.sUserName);
sprintf(msg, "%-25s", u.sUserName);
}
PUTSTR(msg);
printf("%-30s%-14s%-11d", u.sLocation, StrDateDMY(u.tLastLoginDate), u.iTotalCalls);
sprintf(msg, "%-30s%-14s%-10d", u.sLocation, StrDateDMY(u.tLastLoginDate), u.iTotalCalls);
PUTSTR(msg);
iFoundName = TRUE;
LineCount++;
iNameCount++;
@ -112,16 +115,18 @@ void UserList(char *OpData)
} else if ((!u.Hidden) && (!u.Deleted) && (strlen(u.sUserName) > 0)) {
if ((strcmp(OpData, "/H")) == 0) {
if ((strcasecmp(u.sHandle, "") != 0 && *(u.sHandle) != ' '))
printf("%-25s", u.sHandle);
sprintf(msg, "%-25s", u.sHandle);
else
printf("%-25s", u.sUserName);
sprintf(msg, "%-25s", u.sUserName);
} else if (strcasecmp(OpData, "/U") == 0) {
printf("%-25s", u.Name);
sprintf(msg, "%-25s", u.Name);
} else {
printf("%-25s", u.sUserName);
sprintf(msg, "%-25s", u.sUserName);
}
PUTSTR(msg);
printf("%-30s%-14s%-11d", u.sLocation, StrDateDMY(u.tLastLoginDate), u.iTotalCalls);
sprintf(msg, "%-30s%-14s%-10d", u.sLocation, StrDateDMY(u.tLastLoginDate), u.iTotalCalls);
PUTSTR(msg);
iFoundName = TRUE;
LineCount++;
iNameCount++;

View File

@ -37,6 +37,7 @@
#include "exitinfo.h"
#include "whoson.h"
#include "term.h"
#include "ttyio.h"
extern int LC_Download, LC_Upload, LC_Read, LC_Chat, LC_Olr, LC_Door;
@ -50,7 +51,7 @@ extern int LC_Download, LC_Upload, LC_Read, LC_Chat, LC_Olr, LC_Door;
void WhosOn(char *OpData)
{
char buf[128], *Heading, *Underline, *cnt, *isdoing, *location, *device;
char *fullname, *temp;
char *fullname, *temp, msg[81];
int i, x, Start = TRUE;
FILE *fp;
struct userhdr ushdr;
@ -73,7 +74,7 @@ void WhosOn(char *OpData)
sprintf(Underline, "%s%c", Underline, exitinfo.GraphMode ? 196 : 45);
colour(LIGHTRED, BLACK);
Center(Underline);
printf("\n");
Enter(1);
/* Name Device Status Location */
pout(LIGHTGREEN, BLACK, (char *) Language(415));
@ -126,51 +127,51 @@ void WhosOn(char *OpData)
}
free(temp);
}
colour(LIGHTCYAN, BLACK);
printf("%-30s", fullname);
sprintf(msg, "%-30s", fullname);
pout(LIGHTCYAN, BLACK, msg);
free(fullname);
colour(LIGHTBLUE, BLACK);
printf("%-9s", device);
sprintf(msg, "%-9s", device);
pout(LIGHTBLUE, BLACK, msg);
free(device);
strtok(NULL, ",");
location = xstrcpy(strtok(NULL, ","));
isdoing = xstrcpy(strtok(NULL, ","));
colour(WHITE, BLACK);
if (strstr(isdoing, "Browsing"))
/* Browseng */
printf("%-15s", (char *) Language(418));
sprintf(msg, "%-15s", (char *) Language(418));
else if (strstr(isdoing, "Downloading"))
/* Downloading */
printf("%-15s", (char *) Language(419));
sprintf(msg, "%-15s", (char *) Language(419));
else if (strstr(isdoing, "Uploading"))
/* Uploading */
printf("%-15s", (char *) Language(420));
sprintf(msg, "%-15s", (char *) Language(420));
else if (strstr(isdoing, "Read"))
/* Msg Section */
printf("%-15s", (char *) Language(421));
sprintf(msg, "%-15s", (char *) Language(421));
else if (strstr(isdoing, "External"))
/* External Door */
printf("%-15s", (char *) Language(422));
sprintf(msg, "%-15s", (char *) Language(422));
else if (strstr(isdoing, "Chat"))
/* Chatting */
printf("%-15s", (char *) Language(423));
sprintf(msg, "%-15s", (char *) Language(423));
else if (strstr(isdoing, "Files"))
/* Listing Files */
printf("%-15s", (char *) Language(424));
sprintf(msg, "%-15s", (char *) Language(424));
else if (strstr(isdoing, "Time"))
/* Banking Door */
printf("%-15s", (char *) Language(426));
sprintf(msg, "%-15s", (char *) Language(426));
else if (strstr(isdoing, "Safe"))
/* Safe Door */
printf("%-15s", (char *) Language(427));
sprintf(msg, "%-15s", (char *) Language(427));
else if (strstr(isdoing, "Whoson"))
/* WhosOn List */
printf("%-15s", (char *) Language(428));
sprintf(msg, "%-15s", (char *) Language(428));
else if (strstr(isdoing, "Offline"))
/* Offline Reader */
printf("%-15s", (char *) Language(429));
sprintf(msg, "%-15s", (char *) Language(429));
else {
/*
* This is default when nothing matches, with doors this
@ -178,11 +179,13 @@ void WhosOn(char *OpData)
*/
if (strlen(isdoing) > 15)
isdoing[15] = '\0';
printf("%-15s", isdoing);
sprintf(msg, "%-15s", isdoing);
}
pout(WHITE, BLACK, msg);
colour(LIGHTRED, BLACK);
printf("%-25s\n", location);
sprintf(msg, "%-25s", location);
pout(LIGHTRED, BLACK, msg);
Enter(1);
free(location);
free(isdoing);
}
@ -194,8 +197,7 @@ void WhosOn(char *OpData)
free(Underline);
free(Heading);
printf("\n");
Enter(1);
}
@ -277,20 +279,19 @@ void SendOnlineMsg(char *OpData)
/* Please enter username to send message to: */
pout(CYAN, BLACK, (char *) Language(430));
colour(CFG.InputColourF, CFG.InputColourB);
fflush(stdout);
GetstrC(User, 35);
if (!strcmp(User, "")) {
free(User);
free(String);
return;
}
temp = calloc(PATH_MAX, sizeof(char));
/*
* If we were displaying handles or real names, then lookup the
* users unix name to send to mbtask.
*/
if ((strcasecmp(OpData, "/H") == 0) || (strlen(OpData) == 0)) {
temp = calloc(PATH_MAX, sizeof(char));
sprintf(temp, "%s/etc/users.data", getenv("MBSE_ROOT"));
if ((fp = fopen(temp, "rb")) != NULL) {
fread(&ushdr, sizeof(ushdr), 1, fp);
@ -307,14 +308,13 @@ void SendOnlineMsg(char *OpData)
}
fclose(fp);
}
free(temp);
}
/* Please enter message to send (Max 76 Characters) */
pout(LIGHTGREEN, BLACK, (char *)Language(433));
pout(LIGHTGREEN, BLACK, (char *)"\n> ");
Enter(1);
pout(LIGHTGREEN, BLACK, (char *)"> ");
colour(CFG.InputColourF, CFG.InputColourB);
fflush(stdout);
GetstrC(String, 76);
if ((strcmp(String, "")) != 0) {
@ -330,24 +330,33 @@ void SendOnlineMsg(char *OpData)
strcpy(buf, socket_receive());
if (strncmp(buf, "100:1,3;", 8) == 0) {
Enter(1);
/* Sorry, there is no user on */
printf("\n%s %s\n\n", (char *) Language(431), User);
sprintf(temp, "%s %s", (char *) Language(431), User);
PUTSTR(temp);
Enter(1);
}
if (strncmp(buf, "100:1,2;", 8) == 0) {
printf("\nNo more room in users message buffer\n\n");
Enter(1);
PUTSTR((char *)"No more room in users message buffer");
Enter(2);
}
if (strncmp(buf, "100:1,1;", 8) == 0) {
colour(LIGHTRED, BLACK);
Enter(1);
/* doesn't wish to be disturbed */
printf("\n%s %s\n", User, (char *) Language(432));
sprintf(temp, "%s %s", User, (char *) Language(432));
pout(LIGHTRED, BLACK, temp);
Enter(1);
}
if (strncmp(buf, "100:0;", 6) == 0) {
printf("Message Sent!\n");
PUTSTR((char *)"Message Sent!");
Enter(1);
Syslog('+', "Online msg to %s: \"%s\"", User, String);
}
}
}
free(temp);
free(User);
free(String);
Pause();

View File

@ -47,7 +47,7 @@ unsigned char readkey(int y, int x, int fg, int bg)
perror("open 9");
exit(MBERR_TTYIO_ERROR);
}
Setraw();
mbse_Setraw();
i = 0;
while (rc == -1) {
@ -56,12 +56,12 @@ unsigned char readkey(int y, int x, int fg, int bg)
mbse_locate(y, x);
fflush(stdout);
rc = Waitchar(&ch, 5);
rc = mbse_Waitchar(&ch, 5);
if ((rc == 1) && (ch != KEY_ESCAPE))
break;
if ((rc == 1) && (ch == KEY_ESCAPE))
rc = Escapechar(&ch);
rc = mbse_Escapechar(&ch);
if (rc == 1)
break;
@ -69,7 +69,7 @@ unsigned char readkey(int y, int x, int fg, int bg)
Nopper();
}
Unsetraw();
mbse_Unsetraw();
close(ttyfd);
return ch;
@ -89,15 +89,15 @@ unsigned char testkey(int y, int x)
perror("open 9");
exit(MBERR_TTYIO_ERROR);
}
Setraw();
mbse_Setraw();
rc = Waitchar(&ch, 100);
rc = mbse_Waitchar(&ch, 100);
if (rc == 1) {
if (ch == KEY_ESCAPE)
rc = Escapechar(&ch);
rc = mbse_Escapechar(&ch);
}
Unsetraw();
mbse_Unsetraw();
close(ttyfd);
if (rc == 1)