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

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