home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Monster Media 1994 #1
/
monster.zip
/
monster
/
MODEM
/
PCL4W10.ZIP
/
LINE.C
< prev
next >
Wrap
Text File
|
1994-01-27
|
2KB
|
93 lines
/*** line ***/
#include "windows.h"
#include "line.h"
#include "pcl4w.h"
#include "config.h"
#include "simple.h"
#include "expect.h"
#include "sioerror.h"
#include "simpl_io.h"
extern HWND hMainWnd;
extern int FatalFlag;
extern int OnLineFlag;
/* private */
static WORD RxSelector = 0;
static WORD LockCount = 0;
static void FreeDOSmemory(void);
void GoOnLine(void)
{DWORD dwValue;
int RetCode;
int Port;
HMENU hMenu;
if(OnLineFlag) return;
/* allocate windows/DOS memory for receive buffer */
dwValue = GlobalDosAlloc(2<<(3+RXBUFFERCODE));
if(dwValue)
{/* get selector */
RxSelector = LOWORD(dwValue);
LockCount = GlobalPageLock(RxSelector);
if(LockCount==0) FatalFlag = TRUE;
}
else FatalFlag = TRUE;
/* memory allocation error ? */
if(FatalFlag)
{RxSelector = 0;
ErrorMessage("Cannot allocate memory");
return;
}
/* pass selector to PCL4C */
Port = GetPort();
RetCode = SioRxBuf(Port,RxSelector,RXBUFFERCODE);
if(RetCode<0)
{SioError(RetCode,"SioRxBuf");
FreeDOSmemory();
return;
}
else
{/* reset Port */
RetCode = SioReset(Port,GetBaud());
if(RetCode<0)
{SioError(RetCode,"SioReset");
FreeDOSmemory();
return;
}
/* set DTR & RTS */
SioDTR(Port,'S');
SioRTS(Port,'S');
/* Set FIFO level for 16550 */
if( SioFIFO(Port,LEVEL_14) ) DisplayLine("INS16550 detected");
/* clear PCL4C receive buffer */
SioRxFlush(Port);
}
OnLineFlag = TRUE;
SetTitle();
hMenu = GetMenu(hMainWnd);
CheckMenuItem(hMenu,MSG_OFFLINE,MF_BYCOMMAND | MF_UNCHECKED);
CheckMenuItem(hMenu,MSG_ONLINE,MF_BYCOMMAND | MF_CHECKED);
} /* end GoOnLine */
void GoOffLine()
{HMENU hMenu;
FreeDOSmemory();
if(OnLineFlag)
{SioDone((int)GetPort());
SetTitle();
hMenu = GetMenu(hMainWnd);
CheckMenuItem(hMenu,MSG_ONLINE,MF_BYCOMMAND | MF_UNCHECKED);
CheckMenuItem(hMenu,MSG_OFFLINE,MF_BYCOMMAND | MF_CHECKED);
OnLineFlag = FALSE;
}
} /* end GoOffLine */
void FreeDOSmemory(void)
{
if(RxSelector)
{GlobalPageUnlock(RxSelector);
GlobalDosFree(RxSelector);
RxSelector = 0;
}
} /* end FreeDOSmemory */