Category : BBS Programs+Doors
Archive   : MXMS_160.ZIP
Filename : MAXLIB.C

 
Output of file : MAXLIB.C contained in archive : MXMS_160.ZIP
/****************************************************************************/
/* */
/* Maxlib.c :Miscellaneous Maximus routines for MaxMail */
/* */
/****************************************************************************/

#include "MaxMail.h"
#include "bios.h"

int getch(void);

extern int CurColor;


/* Load in the MAXimus PARM file into our global structure */
int read_prm(char *pname)
{
int prmfile,x;

offsets=NULL;

if ((prmfile=sopen(pname,O_RDONLY | O_BINARY,SH_DENYNO,S_IREAD))==-1)
return(-1);

x=read(prmfile,(char *)&prm,sizeof(struct m_pointers));

if (prm.id != 'M' || prm.version != CTL_VER)
{
printf("\a\a");
aborterror(FILEOPEN,"Bad PARM file");
}

x=(int)(fsize(pname)-((int)tell(prmfile)));
offsets=(char *)malloc(x+10);
x=read(prmfile,offsets,x);
close(prmfile);
return TRUE;
}

/* Quick simple method to return size of file without
opening it */

long fsize(char *fname)
{
struct find_t find;

if(_dos_findfirst(fname,0xffff,&find))
return(0L); /* An error occured */
else return(find.size);
}

void get_currents()
{
unsigned x;

_dos_getdrive(&x);
sprintf(sdrive,"%c:",'A' + x - 1);
getcwd(temp,_MAX_DIR - 1);
strcpy(sdir,temp+2);
strcat(sdir,"\\");
}


/* Switch to drive,dir specified */
int switch_dir(char *dname)
{
unsigned x,y,z;
char tt[65];

strcpy(tt,dname);
x = strlen(tt) - 1;
y = strlen(tt) - 1;
if (tt[x] == '\\')
tt[x] = 0; /* Nullify trailing \ */

x = (toupper(dname[0])) - 'A' + 1;
_dos_setdrive(x,&z); /* Ignore 2nd parm */
if (tt[y] == ':') { /* Just a drive letter for temp directory ? */
_dos_getdrive(&z);
if (x != z) /* Change drive did not work */
return 1;
else { /* If it's just a drive, move to root */
chdir("\\");
return 0;
}
}
else return(chdir(tt));
}

/* Video stuff */

void chrout(char ch)
{
putchar(ch);

if (!IsLocal)
FossSendCh(ch);

}

void strout(char *outmsg)
{
printf(outmsg);

if (!IsLocal) {
check_carrier();
FossSendStr(outmsg);
check_carrier();
}
}

void cleareol(void)
{
int x;

x = CurColor;
setcolor(7);

if (LastUser.ansi)
strout("\x1b[K");
else if (LastUser.avatar) {
printf("\x1b[K"); /* Always send ansi to local console */
FossSendStr("\x07"); /* ^G */
}
setcolor(x);
}

void strin(char *inmsg)
{
unsigned ch;
int key,minutes;
char *p;

p = inmsg;
cflush();
if (!IsLocal) { /* Simulate GETS function for fossil */
minutes = timeon(); /* Establish a counter */
while (1) {
check_carrier();
while ((ch = FossGetCh()) == 0xFFFF) {
check_carrier();
if (timeon() > minutes + IDLETIME) /* User is idle too long */
aborterror(USERIDLE,NULL);
}
key = ch & 0xff;
if (key == '\r') { /* Carraige return */
break;
}
if (key == '\b') { /* Backspace */
if (p > inmsg) {
FossSendCh((byte)key);
putchar(key);
FossSendCh(' ');
putchar(' ');
FossSendCh((byte) key);
putchar(key);
p--;
}
}
else {
(*p) = (char) key;
p++;
FossSendCh((byte) key);
putchar(key);
}
*p = 0; /* Terminate */
}
*(p+1) = 0;
}
else gets(inmsg);
}

int chrin(void)
{
unsigned ch;
int minutes;

cflush();
if (IsLocal) {
ch = _bios_keybrd(_KEYBRD_READ);
if (ChatOk && ch == 0x2e00) { /* Chat mode is enabled */
chat();
ch = '!'; /* Return saying to restart menu */
}
return(ch & 0xff); /* Return saying to restart menu */
}
else {
minutes = timeon(); /* Establish a counter */
while ((ch = FossGetCh()) == 0xFFFF) {
check_carrier();
if (timeon() > minutes + IDLETIME) { /* User is idle too long */
aborterror(USERIDLE,NULL);
}
}
if (ChatOk && ch == 0x2e00) { /* Chat mode is enabled */
chat();
ch = '!'; /* Return saying to restart menu */
}
return(ch & 0x00ff);
}
}

int chrinwait(int tminutes)
{
unsigned ch;
int minutes;

cflush();
minutes = timeon(); /* Establish a counter */
if (IsLocal) {
while (_bios_keybrd(_KEYBRD_READY)) {
if (timeon() > minutes + tminutes) { /* User is idle too long */
return('\r');
}
}
ch = _bios_keybrd(_KEYBRD_READ);
if (ChatOk && ch == 0x2e00) { /* Chat mode is enabled */
chat();
ch = '!'; /* Return saying to restart menu */
}
return(ch & 0xff); /* Return saying to restart menu */
}
else {
while ((ch = FossGetCh()) == 0xFFFF) {
check_carrier();
if (timeon() > minutes + tminutes) { /* User is idle too long */
return('\r');
}
}
if (ChatOk && ch == 0x2e00) { /* Chat mode is enabled */
chat();
ch = '!'; /* Return saying to restart menu */
}
return(ch);
}
}

void cflush(void)
{
while (_bios_keybrd(_KEYBRD_READY)) /* Flush local console */
getch();
if (IsLocal)
return;
FossPurgeBuff(TRUE);
}

int check_carrier(void)
{
if (IsLocal)
return(FALSE);

if ((FossMdmStatus() & prm.carrier_mask) == 0) { /* Look at DCD(carrier bit) */
fclose(outfile);
aborterror(DROPCARRIER,NULL);
}
return(FALSE);
}

void logit(char *strng,char flag)
{
FILE *log;
char ttemp[40];
char *ttemp1;
char *month;
char *day;

if (LogMode == FALSE)
return;

ttemp1 = (char *) malloc(101);
if (ttemp1 == NULL) {
LogMode = FALSE;
aborterror(BADALLOC,NULL);
}

strcpy(ttemp, timestring());
strtok(ttemp," "); /* Strip Day of week */
month = strtok(NULL," ");
day = strtok(NULL," ");
tm = strtok(NULL," ");

if (Task)
sprintf(ttemp1,"%c %s %s %s MaxMail{%x} %s\n",flag,day,month,tm,Task,strng);
else sprintf(ttemp1,"%c %s %s %s MaxMail %s\n",flag,day,month,tm,strng);
if ((log = _fsopen(LogFile,"at+",SH_DENYRW)) == NULL) {
printf("\a\aError opening log file!\n");
LogMode = FALSE;
free(ttemp1);
return;
}
fputs(ttemp1,log);
free(ttemp1);
fclose(log);
}

char *timestring(void)
{
time_t aclock;
struct tm *newtime;

time(&aclock);
newtime = localtime(&aclock);
return(asctime(newtime));
}

void find_class(void)
{
int x;

for (x=0;x < MAXCLASS;x++)
{
if (LastUser.priv==prm.class[x].priv) {
UserClass=x;
break;
}
}
}

void videoline(int row,int col,char *strng)
{
union REGS r,r1;
byte scol,srow;
char *p;

r.h.ah = 03; /* Get cursor pos */
r.h.bh = 0; /* Page 0 */
p = strng;

int86(0x10,&r,&r);
scol = r.h.dl;
srow = r.h.dh;

r.h.ah = 02; /* Set cursor pos */
r.h.bh = 0;
r.h.dh = (byte) row;
r.h.dl = (byte) col;
int86(0x10,&r,&r);

r.h.ah = 0x0e; /* Write character */
r.h.bh = 0;
r.h.bl = 0x7d; /* Black on white */

while (*p) {
r.h.al = *p;
int86(0x10,&r,&r1);
p++;
}

r.h.ah = 02; /* Set cursor pos */
r.h.bh = 0;
r.h.dh = srow;
r.h.dl = scol;
int86(0x10,&r,&r); /* Restore to original position */
}
/* Clear 25th line */

void clearstat(void)
{
union REGS r;

r.h.ah = 06; /* Scroll */
r.h.al = 1;
r.h.bh = 0;
r.h.ch = 24;
r.h.cl = 0;
r.h.dh = 24;
r.h.dl = 0;
int86(0x10,&r,&r);
}

void showstat(void)
{
if (*statline)
videoline(24,0,statline);
}

/* Clear the screen */
void clearscreen(void)
{
if (LastUser.ansi)
strout("\x1b[2J");
else if (LastUser.avatar) {
printf("\x1b[2,J"); /* Always send ansi to local console */
FossSendStr("\x0c"); /* ^L */
}
}


  3 Responses to “Category : BBS Programs+Doors
Archive   : MXMS_160.ZIP
Filename : MAXLIB.C

  1. Very nice! Thank you for this wonderful archive. I wonder why I found it only now. Long live the BBS file archives!

  2. This is so awesome! 😀 I’d be cool if you could download an entire archive of this at once, though.

  3. But one thing that puzzles me is the “mtswslnkmcjklsdlsbdmMICROSOFT” string. There is an article about it here. It is definitely worth a read: http://www.os2museum.com/wp/mtswslnk/