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 / WGETCT.C < prev    next >
Encoding:
C/C++ Source or Header  |  1990-08-14  |  1.8 KB  |  64 lines

  1. /* wgetct.c
  2. *
  3. * The Greenleaf Comm Library
  4. *
  5. * Copyright (C) 1989-90 Greenleaf Software Inc.  All Rights Reserved.
  6. *
  7. *  int asiwgetc_timed( port, stat, ticks )
  8. *  int port;            - Port 0..MAX_PORT-1
  9. *  char *stat;          - Where to put status if Wide Track buffer
  10. *  int ticks;           - The maximum number of clock ticks to wait before
  11. *                         returning a timeout error.
  12. *
  13. * DESCRIPTION
  14. *  this function "gets" a character and it's status from the communications
  15. *  port using interrupt mode.  WideTrack Rx must be enabled.
  16. *
  17. * SIDE EFFECTS
  18. *  none.
  19. *
  20. * RETURNS
  21. *
  22. *       Value           Meaning
  23. *       ------          -------
  24. *       0 thru 255      Return value equals character received
  25. *       ASINVPORT       Requested port is out of range
  26. *       ASNOTSETUP      Requested port not setup with asifirst()
  27. *       ASBUFREMPTY     Requested port's buffer is empty
  28. *       ASNOWIDERX      Wide Track receive not enabled for this channel.
  29. *
  30. * MODIFICATIONS
  31. *
  32. *  11-01-85     ""
  33. *               Modified for release 2.0
  34. *
  35. *  Mark Nelson       07-DEC-1989
  36. *       Converted to use timed option in 3.0
  37. */
  38. #include <stdio.h>
  39. #include "gf.h"
  40. #include "asiports.h"
  41.  
  42. int GF_CONV asiwgetc_timed( int port, char *stat, int ticks )
  43. {
  44.     int charstat;
  45.     struct PORT_TABLE *p;
  46.  
  47.     p = _aschkcnl( port );
  48.     if ( p == NULL )
  49.         return(_aserror);
  50.     if ( p->chmode_bits.is_rxerror == 0 )
  51.         return( ASNOWIDERX );
  52.     while ( p->chst_bits.rxempty == 1 ) {
  53.         if ( ticks <= 0 )
  54.             return( ASBUFREMPTY );
  55.         timer(1);
  56.         ticks--;
  57.     }
  58.     charstat = _asigetc( p );
  59.     if ( stat != NULL )
  60.         *stat = ( char ) (( charstat >> 8 ) & 0xff);
  61.     return( charstat & 0xff);
  62. }
  63.  
  64.