home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 3 Comm / 03-Comm.zip / MCOMM530.ZIP / INT14CTS.C < prev    next >
C/C++ Source or Header  |  1990-06-22  |  3KB  |  69 lines

  1.  
  2. /** * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
  3. *                                                                           *
  4. *       I N T   1 4   H O O K   T H A T   W A I T S   F O R   C T S         *
  5. *              Mike Dumdei, 6 Holly Lane, Texarkana TX 75503                *
  6. *                   Requires ASM module --> INT14HK.ASM                     *
  7. *                                                                           *
  8. *   This function sets a hook into the BIOS serial interrupt vector that    *
  9. *   waits indefinitely for CTS to go high on the specified port when send-  *
  10. *   ing data.  For the hook to have any effect when INT14 is called:        *
  11. *       1)  DX has to equal the 'portval' you set here                      *
  12. *       2)  AH has to equal '1' -- the send char service ID                 *
  13. *       3)  CTS must be FALSE                                               *
  14. *   If these conditions are all TRUE, then the hook goes into a loop        *
  15. *   until CTS goes high.  The purpose of the function is keep high speed    *
  16. *   modems that CTS handshake from creating timeout errors when redirect-   *
  17. *   ing stdout and stderr to the comm port.                                 *
  18. *                                                                           *
  19. *           To enable:  call with flag = 1                                  *
  20. *                       portval = COM1 (0) or COM2 (1)                      *
  21. *                       combase = base adrs of comm chip (ex: 3F8)          *
  22. *           To disable: call with flag = 0                                  *
  23. *                       portval = don't care                                *
  24. *                       combase = don't care                                *
  25. *                                                                           *
  26. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * **/
  27. #include <dos.h>
  28.  
  29. #if defined (__TURBOC__)
  30.   #define     _dos_getvect    getvect
  31.   #define    _dos_setvect    setvect
  32. #endif
  33.  
  34. #define uint    unsigned int
  35. #define INT14   0x14                       /* BIOS serial interrupt vector */
  36.  
  37. /* these are in the ASM module */
  38. void interrupt far int14ctshook(void);
  39. extern void (interrupt far *oldint14)();
  40. extern uint msradr14;
  41. extern uint port14;
  42.  
  43. int ctshookset(int flag, uint portval, uint combase)
  44. {
  45.     if (flag)                                   /* enabling the INT14 hook */
  46.     {
  47.         if (msradr14 != 0)
  48.             return (-1);                       /* error if already enabled */
  49.         /* else set pointers and hook into BIOS serial port interrupt */
  50.         msradr14 = combase + 6;          /* point to modem status register */
  51.         port14 = portval;                        /* identify port affected */
  52.         oldint14 = _dos_getvect(INT14);
  53.         _dos_setvect(INT14, int14ctshook);           /* hook INT 14 vector */
  54.         return (0);
  55.     }
  56.     else                                       /* disabling the INT14 hook */
  57.     {
  58.         if (msradr14 == 0)
  59.             return (-1);                           /* error if not enabled */
  60.         /* else set INT 14 back to original vector & reset comchip var */
  61.         _dos_setvect(INT14, oldint14);         /* reset vector to original */
  62.         msradr14 = 0;                                  /* show not enabled */
  63.         return (0);
  64.     }
  65. }
  66.  
  67.         
  68.  
  69.