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

  1. /* asiputb.c
  2. *
  3. * The Greenleaf Comm Library
  4. *
  5. * Copyright (C) 1985-1990 Greenleaf Software Inc.  All Rights Reserved.
  6. *
  7. *  unsigned asiputb( port, buf, length)
  8. *  int port;            - Port 0..MAX_PORT-1
  9. *  char *buf;           - Pointer to buffer
  10. *  unsigned length;     - Length of buffer, number of characters.
  11. *
  12. * DESCRIPTION
  13. *  Transmit an arbitrary array or user buffer.  This function moves the
  14. *  contents of the specified buffer, (i.e. the specified number ("length")
  15. *  of characters) to the Transmitter Buffer.  This is done by means of
  16. *  repeated calls to asiputc().
  17. *
  18. * SIDE EFFECTS
  19. *  none
  20. *
  21. * RETURNS
  22. *  returns the number of characters SUCCESSFULLY transmitted.  The global
  23. *  variable _aserror can be examined to determine if an error was detected.
  24. *  _aserror == 0 if no errors were detected.  If the transmit queue becomes
  25. *  full before the entire buffer can be transmitted _aserror will be set to
  26. *  ASBUFRFULL.
  27. *
  28. *       _aserror =
  29. *
  30. *       Value           Meaning
  31. *     -------          --------
  32. *       ASSUCCESS       port initialized (no error)
  33. *       ASINVPORT       Requested port is out of range
  34. *       ASNOTSETUP      Requested port not setup with asifirst()
  35. *       ASBUFRFULL      Transmit buffer went full
  36. *       ASINVPAR        NULL pointer passed as parameter
  37. *
  38. *       Also see error returns for asiputc().
  39. *
  40. * MODIFICATIONS
  41. *  10-29-85     ""
  42. *               Modified for release 2.0
  43. *
  44. *  03-FEB-1987  13:27:28.03
  45. *       Added test for NULL pointer passed as buffer parameter, if this
  46. *       condition is detected an ASINVPAR error is returned in _aserror.
  47. *       Fixed error propogation problem from asiputc(), the only error
  48. *       that was being recognized was an ASBUFRFULL, modified to return
  49. *       any errors detected by asiputc().
  50. */
  51. #include <stdio.h>
  52. #include "gf.h"
  53. #include "asiports.h"
  54.  
  55. unsigned GF_CONV asiputb(port,buffer,length)
  56. int port;
  57. unsigned length;
  58. char *buffer;
  59. {
  60.         unsigned xmit_count;
  61.  
  62.         if(!buffer) {
  63.                 _aserror= ASINVPAR;
  64.                 return(0);
  65.         }
  66.         for(xmit_count=0;length;++buffer,++xmit_count,--length)
  67.                 if((_aserror=asiputc(port, ((int)*buffer&255) ))!=ASSUCCESS)
  68.                         return(xmit_count);
  69.         return(xmit_count);
  70. }
  71.  
  72.