home *** CD-ROM | disk | FTP | other *** search
/ Piper's Pit BBS/FTP: ibm 0020 - 0029 / ibm0020-0029 / ibm0028.tar / ibm0028 / GRLF-C-1.ZIP / GCOMM / ASPUTC.C < prev    next >
Encoding:
C/C++ Source or Header  |  1990-08-14  |  2.1 KB  |  80 lines

  1. /*  asputc.c
  2. *
  3. * The Greenleaf Comm Library
  4. *
  5. * Copyright (C) 1985-1990 Greenleaf Software Inc.  All Rights Reserved.
  6. *
  7. *  int asputc( port, c )
  8. *  int port;            - Port 0..MAX_PORT-1
  9. *  char c;
  10. *
  11. * DESCRIPTION
  12. *  this function transmits a character via "polled" mode.
  13. *
  14. * SIDE EFFECTS
  15. *       Turns off interrupts while sending.
  16. *
  17. * RETURNS
  18. *
  19. *       Value           Meaning
  20. *       ------          -------
  21. *       ASSUCCESS       Successful (No error(s))
  22. *       ASINVPORT       Requested port is out of range
  23. *       ASNOTSETUP      Requested port not setup with asifirst()
  24. *       ASNOCTS         CTS was not active
  25. *
  26. * MODIFICATIONS
  27. *
  28. *  10-29-85     ""
  29. *               Modified for release 2.0
  30. *  26-FEB-1987  17:37:04.46
  31. *       Modified to use new asputc() function.
  32. */
  33. #include <stdio.h>
  34. #include "gf.h"
  35. #include "asiports.h"
  36.  
  37. int GF_CONV asputc( port,character )
  38. int port,
  39. character;
  40. {
  41.         int iret,timeout,finished;
  42.         unsigned pv=0;
  43.         struct PORT_TABLE *p;
  44.  
  45.         if((p=_aschkcnl(port))==NULL)
  46.                 return(_aserror);
  47.         if(p->chmode_bits.is_txint) {
  48.                 pv|=ASOUT;
  49.                 asihold(port,ASOUT);
  50.         }
  51.         if(p->chmode_bits.is_rxint)
  52.                 pv|=ASIN;
  53.         timeout=p->aswtime;
  54.         if(p->chmode_bits.is_ascii)
  55.                 character&=0x007f;
  56.         for(finished=0;!finished;) {
  57.                 if(p->aswmodem && (iscts(port,DIRECT)==0)) {
  58.                         iret = ASNOCTS;
  59.                         ++finished;
  60.                         continue;
  61.                 }
  62.                 if(_asputc(p->base_8250,character)==ASSUCCESS) {
  63.                         iret = ASSUCCESS;
  64.                         ++finished;
  65.                         continue;
  66.                 }
  67.                 if(!timeout) {
  68.                         iret= ASTIMEOUT;
  69.                         ++finished;
  70.                         continue;
  71.                 }
  72.                 timer(1);
  73.                 --timeout;
  74.         }
  75.         if(pv)
  76.                 asiresume(port,pv);
  77.         return(iret);
  78. }
  79.  
  80.