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

  1. /* getct.c
  2. *
  3. * The Greenleaf Comm Library
  4. *
  5. * Copyright (C) 1985-1990 Greenleaf Software Inc.  All Rights Reserved.
  6. *
  7. *  int asigetc_timed( port, ticks )
  8. *  int port;            - Port 0..MAX_PORTS-1
  9. *  int ticks;
  10. *
  11. * DESCRIPTION
  12. *  this function "gets" a character from the communications port
  13. *  using interrupt mode.  It will wait for up to the tick count for
  14. *  a character if the buffer is empty.
  15. *
  16. * SIDE EFFECTS
  17. *  none.
  18. *
  19. * RETURNS
  20. *
  21. *       Value           Meaning
  22. *       ------          -------
  23. *       0 thru 255      Return value equals character received
  24. *       ASINVPORT       Requested port is out of range
  25. *       ASNOTSETUP      Requested port not setup with asifirst()
  26. *       ASBUFREMPTY     Requested port's buffer is empty
  27. *
  28. * MODIFICATIONS
  29. *
  30. *  11-01-85     ""
  31. *               Modified for release 2.0
  32. *
  33. *  23-FEB-1987  08:55:40.44
  34. *       removed call to _aschkcnl(), replaced with in-line code for speed.
  35. *
  36. *  Mark Nelson       07-DEC-1989
  37. *       Converted to use timed option in 3.0
  38. */
  39. #include <stdio.h>
  40. #include "gf.h"
  41. #include "asiports.h"
  42.  
  43. int GF_CONV asigetc_timed( int port, int ticks )
  44. {
  45.     struct PORT_TABLE *p;
  46.  
  47.     if ( port < 0 || port >= MAX_PORT ) {
  48.         _aserror = ASINVPORT ;
  49.         return( ASINVPORT );
  50.     }
  51.     if ( as_chnl == NULL || ( p = as_chnl->tblport[port].ptb ) == NULL ) {
  52.         _aserror = ASNOTSETUP;
  53.         return( ASNOTSETUP );
  54.     }
  55.     _aserror= ASSUCCESS;
  56.     while ( p->chst_bits.rxempty == 1 )
  57.     {
  58.         if ( ticks <= 0 )
  59.             return( ASBUFREMPTY );
  60.         ticks--;
  61.         timer(1);
  62.     }
  63.     return( _asigetc( p ) );
  64. }
  65.  
  66.