home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / cscope.zip / IOCTL.C < prev    next >
Text File  |  1995-06-19  |  18KB  |  588 lines

  1. /*******************************************************************************
  2. *
  3. *       Copyright (c) 1988-95 OS/tools Incorporated -- All rights reserved
  4. *
  5. *       This source code is supplied AS-IS.  No garantees, no promises.
  6. *       Use as you see fit.
  7. *
  8. *   NOTE: The device driver changes some of the DCB fields during normal
  9. *            processing.  The only way to be sure that you change only those
  10. *            fields you intend to change is to use the following sequence to
  11. *            modify a device's DCB:
  12. *
  13. *            Read the DCB (GetDCB()), make any required changes to the 
  14. *            variables just read, then write the DCB (SendDCB()) when
  15. *            making changes to a device's Device Control Block.
  16. *
  17. *     This is NOT the source used to build the IOCTL.DLL supplied on the 
  18. *     distribution diskette.  This sample code is intended for you to compile
  19. *     and link with your communications application.
  20. *
  21. *     You may want to link with the IOCTL.DLL dynamic library included
  22. *     instead of using this code.  Read "IOCTL.TXT" for details on using the
  23. *     IOCTL.DLL.
  24. *
  25. *    The IOctlErrorMessageBox function will only work in a Presentation Manager
  26. *    program.
  27. *
  28. *******************************************************************************/
  29. #define INCL_DEV
  30. #define INCL_DOS
  31. #include <os2.h>
  32. #include <stdio.h>
  33.  
  34. typedef unsigned char BYTE;
  35. typedef unsigned short WORD;
  36.  
  37. /*
  38. **  Atom constants
  39. */
  40. #define IC_ATM_LINEWRT      3001
  41. #define IC_ATM_LINERD       3002
  42. #define IC_ATM_DCBWRT       3003
  43. #define IC_ATM_DCBRD        3004
  44. #define IC_ATM_BAUDWRT      3005
  45. #define IC_ATM_BAUDRD       3006
  46. #define IC_ATM_FXOFF        3007
  47. #define IC_ATM_FXON         3008
  48. #define IC_ATM_MDMGET       3009
  49. #define IC_ATM_MDMSET       3010
  50. #define IC_ATM_FLUSH        3011
  51. #define IC_ATM_COMEVENTS    3012
  52. #define IC_ATM_COMEVENT     3013
  53. #define IC_ATM_COMERROR     3014
  54. #define IC_ATM_XMITSTAT     3015
  55. #define IC_ATM_COMSTAT      3016
  56. #define IC_ATM_BRKON        3017
  57. #define IC_ATM_BRKOFF       3018
  58. #define IC_ATM_RCVQLEN      3019
  59. #define IC_ATM_TXQLEN       3020
  60. #define IC_ATM_IMMBYTE      3021
  61.  
  62. #define EIC_ATM_ERRORCD     5001
  63. #define EIC_ATM_FUNCTION    5002
  64. #define EIC_ATM_IOCTL       5003
  65.  
  66. /*
  67. ** constants used by FlushBuffers function
  68. **
  69. **  INPUT causes the receive buffer to be flushed
  70. **  OUTPUT causes the transmit buffer to be flushed
  71. */
  72. #define INPUT         1
  73. #define OUTPUT        2
  74.  
  75. /*
  76. **      Used by the "SetModemSignals" and "GetOutputModemSignals" functions 
  77. **      (46H).
  78. **
  79. **  Turn bits ON (one) in the "ModemSigOn" field to activate a modem signal
  80. **   all other bits must be off (zero).
  81. **
  82. **  Turn bits OFF in the "ModemSigOff" field to de-activate a modem signal
  83. **   all other bits must be on (one)
  84. **
  85. **   Bit        Signal
  86. **    0           DTR
  87. **    1           RTS
  88. **    2           OUT1
  89. **    4           LOOP
  90. **
  91. **    Marking any other bit will cause the function to be rejected by
  92. **    device driver.  Bits turning on a signal will take precedence over
  93. **    bits turning off a signal.
  94. **
  95. **    Example One:
  96. **
  97. **      stLineChar.ModemSigOn = 0x02;
  98. **      stLineChar.ModemSigOff = 0xfe;
  99. **
  100. **      Sending these values will cause the RTS signal to be activated and
  101. **      will cause the DTR Signal to be de-activated.
  102. **
  103. **    Example Two:
  104. **
  105. **      stLineChar.ModemSigOn = '\x03'
  106. **      stLineChar.ModemSigOff = '\xff'
  107. **
  108. **      Sending these values will cause the RTS and DTR signals to be 
  109. **      activated.
  110. **
  111. **  NOTE:  Bits two (OUT1) and four (LOOP) will be available only when the
  112. **            device driver being used to access a device is COMi and the
  113. **            extension "Enable Modem Extensions" is enabled for that device.
  114. */
  115. typedef struct
  116.   {
  117.   BYTE byModemSigOn;
  118.   BYTE byModemSigOff;
  119.   }MDMSSIG;
  120.  
  121. /*
  122. **      Used by "SetLineCharacteristics" and "GetLineCharacteristics" functions
  123. **      (42H and 62H)
  124. **
  125. **      DataBits (word length) field bit definitions:
  126. **
  127. **      0x00-0x04       Reserved
  128. **      0x05            5 data bits
  129. **      0x06            6 data bits
  130. **      0x07            7 data bits
  131. **      0x08            8 data bits
  132. **      0x09-0xff        Reserved
  133. **
  134. **      StopBits (stop bits) field bit definitions:
  135. **
  136. **      0x00            1 stop bit
  137. **      0x01            1.5 stop bits (valid only with 5-bit word length)
  138. **      0x02            2 stop bits (not valid with 5-bit word length)
  139. **
  140. **      Parity field bit definitions:
  141. **
  142. **      0x00            no parity
  143. **      0x01            odd parity
  144. **      0x02            even parity
  145. **      0x03            mark parity (parity bit always 1)
  146. **      0x04            space parity (parity bit always 0)
  147. **      0x05-0xff       Reserved
  148. **
  149. **      The "bTransmittingBreak" field is used only for the 
  150. **      "GetLineCharacteristice" function and returns TRUE (one)
  151. **      if the hardware is currently transmitting a break, and returns
  152. **      FALSE (zero) if the hardware is not currently transmitting
  153. **      a break;
  154. */
  155. typedef struct
  156.   {
  157.   BYTE byDataBits;
  158.   BYTE byParity;
  159.   BYTE byStopBits;
  160.   BOOL bTransmittingBreak;
  161.   }LINECHAR;
  162.  
  163. /*
  164. ** used by the "SetBaudRate function (43H)
  165. **
  166. **  Set "lBaudRate" to the desired baud rate.  Set "byFraction" to zero
  167. **  under normal conditions.  See the "Physical Device Driver" technical
  168. **  reference under Category One, Function 43H for more detail.
  169. */
  170. typedef struct
  171.   {
  172.   LONG lBaudRate;
  173.   BYTE byFraction;
  174.   }BAUDRT;
  175.  
  176. /*
  177. **      Used by the "GetBaudRate" function (63H)
  178. */
  179. typedef struct
  180.   {
  181.   BAUDRT stCurrentBaud;
  182.   BAUDRT stHighestBaud;
  183.   BAUDRT stLowestBaud;
  184.   }BAUDST;
  185.  
  186. /*
  187. **      Used by the "SetDCB" and GetDCB" functions (53H and 73H)
  188. **
  189. **      DCB flag bit definitions:
  190. **
  191. **      Flags1:
  192. **
  193. **      bit 7   = Unused
  194. **      bit 6   = enable DSR input Handshaking
  195. **      bit 5   = enable DCD output Handshaking
  196. **      bit 4   = enable DSR output Handshaking
  197. **      bit 3   = enable CTS output Handshaking
  198. **      bit 2   = Unused
  199. **      bit 0-1 = DTR Control Mode
  200. **        BR1 BR0
  201. **           0   0      Disable
  202. **           0   1      Enable
  203. **           1   0      Input Handshaking
  204. **           1   1      Output Handshaking
  205. **
  206. **      Flags2:
  207. **
  208. **      bit 6-7 = RTS Control Mode
  209. **        BR7 BR6
  210. **           0   0      Disable
  211. **           0   1      Enable
  212. **           1   0      Input Handshaking
  213. **           1   1      Toggling on Transmit
  214. **
  215. **      bit 5 = Automatic Receive Flow Control
  216. **           0 = Normal
  217. **           1 = Full_Duplex
  218. **
  219. **      bit 4   = enable break replacement
  220. **      bit 3   = enable NULL striping
  221. **      bit 2   = enable error Replacement
  222. **      bit 1   = enable automatic receive flow control (Xon/Xoff)
  223. **      bit 0   = enable automatic transmit flow control (Xon/Xoff)
  224. **
  225. **      Flags3:
  226. **
  227. **      bit 7 = Transmit Buffer Load Count
  228. **          0 = no transmit buffering
  229. **          1 = 16 byte transmit buffering
  230. **
  231. **      bits 5-6 = receive trigger level
  232. **        BR6 BR5
  233. **           0   0      one character
  234. **           0   1      four characters
  235. **           1   0      eight characters
  236. **           1   1      fourteen characters
  237. **
  238. **      bits 3-4 = Extended Hardware Buffering
  239. **       BR4 BR3
  240. **          0   0      not supported - ignored - no change to fifo mode
  241. **          0   1      extended hardware buffering disabled
  242. **          1   0      extended hardware buffering enabled
  243. **          1   1      automatic protocol override
  244. **
  245. **      bits 1-2 = Read Timeout Processing
  246. **        BR2 BR1
  247. **          0   0       invalid
  248. **          0   1       normal read timeout processing
  249. **          1   0       wait for something, read timeout processing
  250. **          1   1       no wait, read timeout processing
  251. **
  252. **      bit 0    = Enable infinite write timeout processing
  253. **
  254. */
  255. typedef struct
  256.   {
  257.   WORD wWrtTimeout;
  258.   WORD wReadTimeout;
  259.   BYTE byFlags1;
  260.   BYTE byFlags2;
  261.   BYTE byFlags3;
  262.   BYTE byErrChar;
  263.   BYTE byBrkChar;
  264.   BYTE byXonChar;
  265.   BYTE byXoffChar;
  266.  }DCB;
  267.  
  268. VOID IOctlErrorMessageBox(ULONG idErrMsg,WORD wFunction,WORD wError);
  269. void SendXonXoff(HFILE hCom,WORD wSignal);
  270. void FlushComBuffer(HFILE hCom,WORD wDirection);
  271. APIRET ForceXoff(HFILE hCom);
  272. APIRET ForceXon(HFILE hCom);
  273. APIRET GetBaudRate(HFILE hCom,LONG *plBaud);
  274. APIRET SetBaudRate(HFILE hCom,LONG lBaud);
  275. APIRET GetLineCharacteristics(HFILE hCom,LINECHAR *pstLineChar);
  276. APIRET SetLineCharacteristics(HFILE hCom,LINECHAR *pstLineChar);
  277. APIRET SetModemSignals(HFILE hCom,BYTE byOnByte,BYTE byOffByte,WORD *pwCOMerror);
  278. APIRET GetModemOutputSignals(HFILE hCom,BYTE *pbySignals);
  279. APIRET GetModemInputSignals(HFILE hCom,BYTE *pbySignals);
  280. APIRET GetTransmitQueueLen(HFILE hCom,WORD *pwQueueLen,WORD *pwByteCount);
  281. APIRET GetReceiveQueueLen(HFILE hCom,WORD *pwQueueLen,WORD *pwByteCount);
  282. APIRET BreakOff(HFILE hCom,WORD *pwCOMerror);
  283. APIRET BreakOn(HFILE hCom,WORD *pwCOMerror);
  284. APIRET GetCOMerror(HFILE hCom,WORD *pwCOMerror);
  285. APIRET GetCOMevent(HFILE hCom,WORD *pwCOMevent);
  286. APIRET GetCOMstatus(HFILE hCom,BYTE *pbyCOMstatus);
  287. APIRET GetXmitStatus(HFILE hCom,BYTE *pbyCOMstatus);
  288. APIRET SendDCB(HFILE hCom,DCB *pstComDCB);
  289. APIRET GetDCB(HFILE hCom,DCB *pstComDCB);
  290.  
  291. extern HAB habAnchorBlock;
  292. extern char szPortName[];
  293. extern HWND hwndFrame;
  294.  
  295. VOID IOctlErrorMessageBox(ULONG idErrMsg,WORD wFunction,WORD wError)
  296.   {
  297.   CHAR szErrMsg[80];
  298.   CHAR szMsgString[200];
  299.   LONG lLength;
  300.  
  301.   lLength = WinLoadString(habAnchorBlock,NULLHANDLE,idErrMsg,sizeof(szMsgString),szMsgString);
  302.   WinLoadString(habAnchorBlock,NULLHANDLE,EIC_ATM_FUNCTION,sizeof(szErrMsg),szErrMsg);
  303.   lLength += sprintf(&szMsgString[lLength],"\n\n%s 0x%02X",szErrMsg,wFunction);
  304.   WinLoadString(habAnchorBlock,NULLHANDLE,EIC_ATM_ERRORCD,sizeof(szErrMsg),szErrMsg);
  305.   sprintf(&szMsgString[lLength],"\n%s 0x%04X",szErrMsg,wError);
  306.   lLength = WinLoadString(habAnchorBlock,NULLHANDLE,EIC_ATM_IOCTL,sizeof(szErrMsg),szErrMsg);
  307.   sprintf(&szErrMsg[lLength]," %s",szPortName);
  308.   /*
  309.   ** Display a message box with MB_OK and CUA warning style
  310.   */
  311.   WinMessageBox(HWND_DESKTOP,
  312.                 hwndFrame,
  313.            (PSZ)szMsgString,
  314.            (PSZ)szErrMsg,
  315.                 0,
  316.                (MB_MOVEABLE | MB_OK | MB_CUAWARNING));
  317.   }
  318.  
  319. APIRET GetDCB(HFILE hCom,DCB *pstComDCB)
  320.   {
  321.   ULONG ulDataLen = sizeof(DCB);
  322.   ULONG ulParmLen = 0L;
  323.   APIRET rc;
  324.  
  325.   if ((rc = DosDevIOCtl(hCom,0x01,0x73,0L,0L,&ulParmLen,(PVOID)pstComDCB,sizeof(DCB),&ulDataLen)) != 0)
  326.     IOctlErrorMessageBox(IC_ATM_DCBRD,0x73,rc);
  327.   return(rc);
  328.   }
  329.  
  330. APIRET SendDCB(HFILE hCom,DCB *pstComDCB)
  331.   {
  332.   ULONG ulDataLen = 0L;
  333.   ULONG ulParmLen = sizeof(DCB);
  334.   APIRET rc;
  335.  
  336.   if ((rc = DosDevIOCtl(hCom,0x01,0x53,(PVOID)pstComDCB,sizeof(DCB),&ulParmLen,0L,0L,&ulDataLen)) != 0)
  337.     IOctlErrorMessageBox(IC_ATM_DCBWRT,0x53,rc);
  338.   return(rc);
  339.   }
  340.  
  341. APIRET SendByteImmediate(HFILE hCom,BYTE bySendByte)
  342.   {
  343.   ULONG ulDataLen = 0L;
  344.   ULONG ulParmLen = 1L;
  345.   USHORT rc;
  346.  
  347.   if ((rc = DosDevIOCtl(hCom,0x01,0x44,(PVOID)&bySendByte,1L,&ulParmLen,0L,0L,&ulDataLen)) != 0)
  348.     IOctlErrorMessageBox(IC_ATM_IMMBYTE,0x44,rc);
  349.   return(rc);
  350.   }
  351.  
  352. APIRET GetXmitStatus(HFILE hCom,BYTE *pbyCOMstatus)
  353.   {
  354.   ULONG ulDataLen = 1l;
  355.   ULONG ulParmLen = 0l;
  356.   APIRET rc;
  357.  
  358.   if ((rc = DosDevIOCtl(hCom,0x01,0x65,0L,0L,&ulParmLen,(PVOID)pbyCOMstatus,1L,&ulDataLen)) != 0)
  359.     IOctlErrorMessageBox(IC_ATM_XMITSTAT,0x65,rc);
  360.   return(rc);
  361.   }
  362.  
  363. APIRET GetCOMstatus(HFILE hCom,BYTE *pbyCOMstatus)
  364.   {
  365.   ULONG ulDataLen = 1L;
  366.   ULONG ulParmLen = 0L;
  367.   APIRET rc;
  368.  
  369.   if ((rc = DosDevIOCtl(hCom,0x01,0x64,0L,0L,&ulParmLen,pbyCOMstatus,1L,&ulDataLen)) != 0)
  370.     IOctlErrorMessageBox(IC_ATM_COMSTAT,0x64,rc);
  371.   return(rc);
  372.   }
  373.  
  374. APIRET GetCOMevent(HFILE hCom,WORD *pwCOMevent)
  375.   {
  376.   ULONG ulDataLen = 2L;
  377.   ULONG ulParmLen = 0L;
  378.   APIRET rc;
  379.  
  380.   if ((rc = DosDevIOCtl(hCom,0x01,0x72,0L,0L,&ulParmLen,pwCOMevent,2L,&ulDataLen)) != 0)
  381.       IOctlErrorMessageBox(IC_ATM_COMEVENT,0x72,rc);
  382.   return(rc);
  383.   }
  384.  
  385. APIRET GetCOMerror(HFILE hCom,WORD *pwCOMerror)
  386.   {
  387.   ULONG ulDataLen = 2L;
  388.   ULONG ulParmLen = 0L;
  389.   APIRET rc;
  390.  
  391.   if ((rc = DosDevIOCtl(hCom,0x01,0x6d,0L,0L,&ulParmLen,pwCOMerror,2L,&ulDataLen)) != 0)
  392.     IOctlErrorMessageBox(IC_ATM_COMERROR,0x6d,rc);
  393.   return(rc);
  394.   }
  395.  
  396. APIRET BreakOn(HFILE hCom,WORD *pwCOMerror)
  397.   {
  398.   ULONG ulDataLen = 2L;
  399.   ULONG ulParmLen = 0L;
  400.   APIRET rc;
  401.  
  402.   if ((rc = DosDevIOCtl(hCom,0x01,0x4b,0L,0L,&ulParmLen,pwCOMerror,2L,&ulDataLen)) != 0)
  403.     IOctlErrorMessageBox(IC_ATM_BRKON,0x4b,rc);
  404.   return(rc);
  405.   }
  406.  
  407. APIRET BreakOff(HFILE hCom,WORD *pwCOMerror)
  408.   {
  409.   ULONG ulDataLen = 2L;
  410.   ULONG ulParmLen = 0L;
  411.   APIRET rc;
  412.  
  413.   if ((rc = DosDevIOCtl(hCom,0x01,0x45,0L,0L,&ulParmLen,pwCOMerror,2L,&ulDataLen)) != 0)
  414.     IOctlErrorMessageBox(IC_ATM_BRKOFF,0x45,rc);
  415.   return(rc);
  416.   }
  417.  
  418. APIRET GetReceiveQueueLen(HFILE hCom,WORD *pwQueueLen,WORD *pwByteCount)
  419.   {
  420.   ULONG ulDataLen = 4L;
  421.   ULONG ulParmLen = 0L;
  422.   APIRET rc;
  423.   struct
  424.     {
  425.     WORD wByteCount;
  426.     WORD wQueueLen;
  427.     }stWordPair;
  428.  
  429.   if ((rc = DosDevIOCtl(hCom,0x01,0x68,0L,0L,&ulParmLen,&stWordPair,4L,&ulDataLen)) != 0)
  430.     IOctlErrorMessageBox(IC_ATM_RCVQLEN,0x68,rc);
  431.   *pwQueueLen = stWordPair.wQueueLen;
  432.   *pwByteCount = stWordPair.wByteCount;
  433.   return(rc);
  434.   }
  435.  
  436. APIRET GetTransmitQueueLen(HFILE hCom,WORD *pwQueueLen,WORD *pwByteCount)
  437.   {
  438.   ULONG ulDataLen = 4L;
  439.   ULONG ulParmLen = 0L;
  440.   APIRET rc;
  441.   struct
  442.     {
  443.     WORD wByteCount;
  444.     WORD wQueueLen;
  445.     }stWordPair;
  446.  
  447.   if ((rc = DosDevIOCtl(hCom,0x01,0x69,0L,0L,&ulParmLen,&stWordPair,4L,&ulDataLen)) != 0)
  448.     IOctlErrorMessageBox(IC_ATM_TXQLEN,0x69,rc);
  449.   *pwQueueLen = stWordPair.wQueueLen;
  450.   *pwByteCount = stWordPair.wByteCount;
  451.   return(rc);
  452.   }
  453.  
  454. APIRET GetModemInputSignals(HFILE hCom,BYTE *pbySignals)
  455.   {
  456.   ULONG ulDataLen = 1L;
  457.   ULONG ulParmLen = 0L;
  458.   APIRET rc;
  459.  
  460.   if ((rc = DosDevIOCtl(hCom,0x01,0x67,0L,0L,&ulParmLen,pbySignals,1L,&ulDataLen)) != 0)
  461.     IOctlErrorMessageBox(IC_ATM_MDMSET,0x67,rc);
  462.   return(rc);
  463.   }
  464.  
  465. APIRET GetModemOutputSignals(HFILE hCom,BYTE *pbySignals)
  466.   {
  467.   ULONG ulDataLen = 1L;
  468.   ULONG ulParmLen = 0L;
  469.   APIRET rc;
  470.  
  471.   if ((rc = DosDevIOCtl(hCom,0x01,0x66,0L,0L,&ulParmLen,pbySignals,1L,&ulDataLen)) != 0)
  472.     IOctlErrorMessageBox(IC_ATM_MDMGET,0x66,rc);
  473.   return(rc);
  474.   }
  475.  
  476. APIRET SetModemSignals(HFILE hCom,BYTE byOnByte,BYTE byOffByte,WORD *pwCOMerror)
  477.   {
  478.   ULONG ulDataLen = 2L;
  479.   ULONG ulParmLen = 2L;
  480.   APIRET rc;
  481.   MDMSSIG stModemSetSignals;
  482.  
  483.   stModemSetSignals.byModemSigOn = byOnByte;
  484.   stModemSetSignals.byModemSigOff = byOffByte;
  485.  
  486.   if ((rc = DosDevIOCtl(hCom,0x01,0x46,&stModemSetSignals,2L,&ulParmLen,pwCOMerror,2L,&ulDataLen)) != 0)
  487.     IOctlErrorMessageBox(IC_ATM_MDMSET,0x46,rc);
  488.   return(rc);
  489.   }
  490.  
  491. APIRET SetLineCharacteristics(HFILE hCom,LINECHAR *pstLineChar)
  492.   {
  493.   ULONG ulDataLen = 0L;
  494.   ULONG ulParmLen = sizeof(LINECHAR);
  495.   APIRET rc;
  496.  
  497.   if ((rc = DosDevIOCtl(hCom,0x01,0x42,pstLineChar,sizeof(LINECHAR),&ulParmLen,0L,0L,&ulDataLen)) != 0)
  498.     IOctlErrorMessageBox(IC_ATM_LINERD,0x42,rc);
  499.   return(rc);
  500.   }
  501.  
  502. APIRET GetLineCharacteristics(HFILE hCom,LINECHAR *pstLineChar)
  503.   {
  504.   ULONG ulDataLen = sizeof(LINECHAR);
  505.   ULONG ulParmLen = 0L;
  506.   APIRET rc;
  507.  
  508.   if ((rc = DosDevIOCtl(hCom,0x01,0x62,0L,0L,&ulParmLen,pstLineChar,sizeof(LINECHAR),&ulDataLen)) != 0)
  509.     IOctlErrorMessageBox(IC_ATM_LINERD,0x62,rc);
  510.   return(rc);
  511.   }
  512.  
  513. APIRET SetBaudRate(HFILE hCom,LONG lBaud)
  514.   {
  515.   ULONG ulDataLen = 0l;
  516.   ULONG ulParmLen = sizeof(BAUDRT);
  517.   APIRET rc;
  518.   BAUDRT stBaudRate;
  519.  
  520.   stBaudRate.lBaudRate = lBaud;
  521.   stBaudRate.byFraction = 0;
  522.   if ((rc = DosDevIOCtl(hCom,0x01,0x43,&stBaudRate,sizeof(BAUDRT),&ulParmLen,0L,0L,&ulDataLen)) != 0)
  523.     IOctlErrorMessageBox(IC_ATM_BAUDWRT,0x43,rc);
  524.   return(rc);
  525.   }
  526.  
  527. APIRET GetBaudRate(HFILE hCom,LONG *plBaud)
  528.   {
  529.   ULONG ulDataLen = sizeof(BAUDRT);
  530.   ULONG ulParmLen = 0L;
  531.   APIRET rc;
  532.   BAUDST stBaudRate;
  533.  
  534.   *plBaud = 0;
  535.   if ((rc = DosDevIOCtl(hCom,0x01,0x63,0L,0L,&ulParmLen,&stBaudRate,sizeof(BAUDRT),&ulDataLen)) != 0)
  536.     IOctlErrorMessageBox(IC_ATM_BAUDRD,0x63,rc);
  537.   *plBaud = stBaudRate.stCurrentBaud.lBaudRate;
  538.   return(rc);
  539.   }
  540.  
  541. APIRET ForceXon(HFILE hCom)
  542.   {
  543.   ULONG ulDataLen = 0L;
  544.   ULONG ulParmLen = 0L;
  545.   APIRET rc;
  546.  
  547.   if ((rc = DosDevIOCtl(hCom,0x01,0x48,0L,0L,&ulParmLen,0L,0L,&ulDataLen)) != 0)
  548.     IOctlErrorMessageBox(IC_ATM_FXON,0x48,rc);
  549.   return(rc);
  550.   }
  551.  
  552. APIRET ForceXoff(HFILE hCom)
  553.   {
  554.   ULONG ulDataLen = 0L;
  555.   ULONG ulParmLen = 0L;
  556.   APIRET rc;
  557.  
  558.   if ((rc = DosDevIOCtl(hCom,0x01,0x47,0L,0L,&ulParmLen,0L,0L,&ulDataLen)) != 0)
  559.     IOctlErrorMessageBox(IC_ATM_FXOFF,0x47,rc);
  560.   return(rc);
  561.   }
  562.  
  563. void FlushComBuffer(HFILE hCom,WORD wDirection)
  564.   {
  565.     ULONG pcbDataLen = 0;
  566.     ULONG pcbParmLen = 1;
  567.   WORD Error;
  568.   BYTE byParam = 0;
  569.  
  570.     if ((Error = DosDevIOCtl(hCom,0x0b,(ULONG)wDirection,&byParam,1L,&pcbParmLen,0L,0L,&pcbDataLen)) != 0)
  571.     IOctlErrorMessageBox(IC_ATM_FLUSH,0x0b,Error);
  572.   }
  573.  
  574. void SendXonXoff(HFILE hCom,WORD wSignal)
  575.   {
  576.   DCB stComDCB;
  577.   BYTE byTemp;
  578.  
  579.   GetDCB(hCom,&stComDCB);
  580.   if (wSignal == SEND_XON)
  581.     byTemp = stComDCB.byXonChar;
  582.   else
  583.     byTemp = stComDCB.byXoffChar;
  584.  
  585.   SendByteImmediate(hCom,byTemp);
  586.   }
  587.  
  588.