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

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