home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 2 BBS / 02-BBS.zip / MXMS_160.LZH / FOSSIL.C < prev    next >
C/C++ Source or Header  |  1991-06-17  |  4KB  |  188 lines

  1. /****************************************************************************/
  2. /*                                                                          */
  3. /*    Fossil.c      :Fossil routines for MaxMail                            */
  4. /*                                                                          */
  5. /****************************************************************************/
  6.  
  7. #include "MaxMail.h"
  8. #include <Bios.h>
  9.  
  10.  
  11. /* Higher level fossil routines */
  12.  
  13. union REGS r;
  14. struct SREGS sr;
  15.  
  16. /* Initialize fossil */
  17. int FossilInit(void)
  18. {
  19.  
  20.   r.h.ah = 0x4;
  21.   r.x.dx = prm.com_port;
  22.   r.x.bx = 0;
  23.  
  24. /*  r.x.cx = FP_OFF(&break_flag);
  25.   sr.es = FP_SEG(&break_flag); */
  26.  
  27.   int86x(0x14,&r,&r,&sr);        /* Call Fossil */
  28.  
  29.   if (0x1954 != r.x.ax)
  30.     return FALSE;
  31.   else if (r.h.bl < 0x18 || r.h.bh < 5){
  32.     logit("Level 5 FOSSIL req'd",'!');
  33.     return FALSE;
  34.   }
  35.   else {
  36.    r.h.ah = 0x0f;
  37.    r.h.al = (byte) prm.handshake_mask;
  38.    r.x.dx = prm.com_port;
  39.    int86x(0x14,&r,&r,&sr);        /* Call Fossil */
  40.    return TRUE;
  41.   }
  42. }
  43.  
  44. /* De-initialize fossil */
  45. void FossilDeInit(void)
  46. {
  47.   r.h.ah = 0x5;
  48.   r.x.dx = prm.com_port;
  49.  
  50.   int86(0x14,&r,&r);        /* Call Fossil */
  51. }
  52.  
  53.  
  54. /* Purge Fossil buffer. If Mode is TRUE, purge input buffer, FALSE
  55.     purge outout buffer */
  56.  
  57. void FossPurgeBuff(int mode)
  58. {
  59.  
  60.    r.x.dx = prm.com_port;
  61.  
  62.    if (mode) {        /* purge input buffer */
  63.       r.h.ah = 0x0a;
  64.       int86(0x14,&r,&r);        /* Call Fossil */
  65.    }
  66.    else {        /* Purge output buffer */
  67.       r.h.ah = 0x09;
  68.       int86(0x14,&r,&r);        /* Call Fossil */
  69.    }
  70.  
  71. /* Turn on break */
  72.  
  73.    FossBreak(10);
  74.  
  75.    delay_s(1);
  76. }
  77.  
  78. void FossFlow(byte mask)
  79. {
  80.    r.x.dx = prm.com_port;
  81.    r.h.al = mask;
  82.    r.h.ah = 0x0f;
  83.    int86(0x14,&r,&r);        /* Call Fossil */
  84.  
  85. }
  86.  
  87. /* Toggle DTR, if mode = TRUE, raise DTR. If mode = FALSE lower DTR */
  88. void FossDtr(int mode)
  89. {
  90.    r.x.dx = prm.com_port;
  91.    r.h.ah = 0x06;
  92.    r.h.al = (byte) mode;
  93.  
  94.    int86(0x14,&r,&r);        /* Call Fossil */
  95. }
  96.  
  97. unsigned FossMdmStatus(void)
  98. {
  99.    int x;
  100.  
  101.    x = prm.com_port;
  102.  
  103.    _asm {
  104.       mov   ah,03
  105.       mov   dx,x
  106.       int   14h
  107.       mov   x,ax
  108.    }
  109.  
  110.    return(x);
  111. }
  112.  
  113. /* Return a keystroke. Check local keyboard first, then fossil */
  114. unsigned FossGetCh(void)
  115. {
  116.  
  117.    if (_bios_keybrd(_KEYBRD_READY)) {        /* Local keyboard has priority */
  118.       return(_bios_keybrd(_KEYBRD_READ));
  119.    }
  120.  
  121.    r.x.dx = prm.com_port;
  122.    r.h.ah = 0x0c;        /* Non destructive fossil read-ahead */
  123.    int86(0x14,&r,&r);        /* Call Fossil */
  124.    if (r.x.ax != 0xffff) {
  125.       r.x.dx = prm.com_port;
  126.       r.h.ah = 0x02;        /* Read fossil char with wait */
  127.       int86(0x14,&r,&r);        /* Call Fossil */
  128.    }
  129.    return(r.x.ax);
  130. }
  131.  
  132. /* Transmit a character to fossil with wait */
  133.  
  134. void FossSendCh(byte chr)
  135. {
  136.    
  137.    _asm {
  138.       mov   bx, OFFSET prm
  139.       mov   dx,[bx]prm.com_port
  140.       mov   al,chr
  141.       mov   ah,1
  142.       int   14h
  143.    }
  144. }
  145.  
  146. /* Transmit a string to fossil with wait */
  147. void FossSendStr(char *strng)
  148. {
  149.  
  150.     if (IsLocal)
  151.       return;
  152.  
  153.     _asm {
  154.       mov   bx, OFFSET prm
  155.       mov   dx,[bx]prm.com_port
  156.       mov   si,strng
  157.  
  158.       strstart:
  159.  
  160.       lodsb
  161.       cmp   al,0
  162.       je    strret
  163.       mov   ah,1
  164.       int   14h
  165.       jmp   strstart
  166.  
  167.       strret:
  168.    }
  169. }
  170.  
  171. void FossBreak(int tsecs)
  172. {
  173.    if (prm.flags & FLAG_break_clr) {
  174.       r.x.dx = prm.com_port;
  175.       r.h.ah = 0x1a;
  176.       r.h.al = 1;        /* Send break */
  177.       int86(0x14,&r,&r);        /* Call Fossil */
  178.  
  179.       delay_ms(100 * tsecs);
  180.  
  181.       r.x.dx = prm.com_port;
  182.       r.h.ah = 0x1a;
  183.       r.h.al = 0;        /* Stop break */
  184.       int86(0x14,&r,&r);        /* Call Fossil */
  185.    }
  186. }
  187.  
  188.