--- os2sdk/demos/apps/terminal/modem.c 2018/08/09 12:25:13 1.1.1.1 +++ os2sdk/demos/apps/terminal/modem.c 2018/08/09 12:26:01 1.1.1.2 @@ -3,8 +3,7 @@ * TITLE * * modem.c - * Copyright (C) Microsoft Corporation 1987 - * March 1987 + * Created by Microsoft Corporation 1987 * * DESCRIPTION * @@ -12,9 +11,13 @@ * ***/ +#define INCL_DOSDEVICES +#define INCL_DOSFILEMGR +#define INCL_DOSPROCESS + +#include +#include #include -#include -#include #include #include #include @@ -25,10 +28,10 @@ /* v2tov3.h (c v2.0) header file */ extern char *ErrMsg[]; -extern unsigned FileHndl; +extern HFILE FileHndl; make_dial_cmd(char *, int); -void flush_ques(int); +void flush_ques(USHORT); void clr_com_error(void); void com_clr_flush(void); @@ -74,8 +77,8 @@ struct s_Cmd{ make_modem_conn() { - unsigned NumBytes, /* number of bytes to be written */ - RetCode, /* return code from system calls */ + USHORT NumBytes; /* number of bytes to be written */ + unsigned RetCode, /* return code from system calls */ Result = FALSE; /* to be returned by this routine */ char OutBuffer, ModemRetry = TRUE, /* retry for modem connection */ @@ -90,7 +93,7 @@ make_modem_conn() Result = TRUE; ModemRetry = FALSE; OutBuffer = '\r'; - if ((RetCode = DOSWRITE(FileHndl, &OutBuffer, 1, + if ((RetCode = DosWrite(FileHndl, &OutBuffer, 1, &NumBytes)) != 0) error(ERR_DOSWRITE, RetCode); break; @@ -149,7 +152,7 @@ int setup_modem_conn() return(Result); if (get_modem_reply() != MS_OK) return(Result); - DOSSLEEP((long) 100); + DosSleep(100L); /* write AT string to the modem. This will cause the modem to * determine the communications rate of the terminal as well @@ -159,7 +162,7 @@ int setup_modem_conn() return(Result); if (get_modem_reply() != MS_OK) return(Result); - DOSSLEEP((long) 100); + DosSleep(100L); /* send DIAL command to the modem */ if (!(send_modem_cmd(MC_DIAL))) @@ -196,10 +199,10 @@ send_modem_cmd(CmdType) int CmdType; /* The command to send */ { int Result = TRUE, - ReadCnt, - WriteCnt, - CmdLen, RetCode; + USHORT WriteCnt, + ReadCnt, + CmdLen; char Buf[80], Cmd[80], *pDst, @@ -226,18 +229,18 @@ int CmdType; /* The command }; /* write the command out to the modem */ - if (((RetCode = DOSWRITE(FileHndl, pCmd, CmdLen, &WriteCnt)) != 0) + if (((RetCode = DosWrite(FileHndl, pCmd, CmdLen, &WriteCnt)) != 0) || (WriteCnt != CmdLen)) return(FALSE); /* wait for the echo & wait for the command to clear */ - DOSSLEEP((long) 250); + DosSleep(250L); if (CmdType == MC_DIAL || CmdType == MC_RESET) - DOSSLEEP((long) 750); + DosSleep(750L); /* read back the echo from the modem & check if it matches the input */ RetCode = - DOSREAD(FileHndl, Buf, min(WriteCnt, sizeof(Buf)), &ReadCnt); + DosRead(FileHndl, Buf, min(WriteCnt, sizeof(Buf)), &ReadCnt); if ((RetCode != 0) || (ReadCnt != WriteCnt)) Result = FALSE; else { @@ -376,12 +379,12 @@ int i; int get_modem_reply() { char Ch; - int Cnt, - Result, + USHORT Cnt; + int Result, RetCode; do /* skip CR, LF and get resultcode */ - if ((RetCode = DOSREAD(FileHndl, &Ch, 1, &Cnt)) != 0) + if ((RetCode = DosRead(FileHndl, &Ch, 1, &Cnt)) != 0) Error(ERR_DOSREAD, RetCode); while ((Cnt == 1) && ((Ch == 0x0d) || (Ch == 0x0a))); @@ -421,15 +424,15 @@ int get_modem_reply() void discon_modem() { /* Wait for the last command to clear, then be quiet for 1.5 seconds */ - DOSSLEEP((long) 1000); /* wait 1. second */ + DosSleep(1000L); /* wait 1. second */ flush_ques(FLUSHOUTPUT); /* flush the transmit que */ - DOSSLEEP((long) 1500); /* wait 1.5 seconds */ + DosSleep(1500L); /* wait 1.5 seconds */ send_modem_cmd(MC_ESC); /* put modem in command mode */ - DOSSLEEP((long) 2000); /* wait 2 seconds */ + DosSleep(2000L); /* wait 2 seconds */ send_modem_cmd(MC_ONHOOK); /* place phone back on hook */ - DOSSLEEP((long) 200); /* wait for command to clear*/ + DosSleep(200L); /* wait for command to clear*/ } @@ -480,14 +483,14 @@ void com_clr_flush() ***/ void flush_ques(FuncId) -int FuncId; +USHORT FuncId; { char FlushData, /* data returned by flush IOCTL function */ FlushParm = FLUSH_CMDINFO; /* param to flush IOCTL function */ int RetCode; /* flush transmit/receive queue */ - if ((RetCode = DOSDEVIOCTL(&FlushData, &FlushParm, + if ((RetCode = DosDevIOCtl(&FlushData, &FlushParm, FuncId, GENERIC, FileHndl)) != 0) Error(ERR_IOCTLFLUSHQUE, RetCode); } @@ -516,7 +519,7 @@ void clr_com_error() int ComError, RetCode; - if ((RetCode = DOSDEVIOCTL((char *) &ComError, 0L, GETCOMERROR, + if ((RetCode = DosDevIOCtl(&ComError, 0L, GETCOMERROR, SERIAL, FileHndl)) != 0) Error(ERR_IOCTLGETCOMERROR, RetCode); }