home *** CD-ROM | disk | FTP | other *** search
/ Piper's Pit BBS/FTP: ibm 0020 - 0029 / ibm0020-0029 / ibm0028.tar / ibm0028 / GRLF-C-2.ZIP / GFUNC / PRBUFS.C < prev    next >
Encoding:
C/C++ Source or Header  |  1990-05-30  |  1.3 KB  |  62 lines

  1. /*
  2. ** prbufs.c
  3. ** contains: PrBufS()
  4. */
  5.  
  6. #include <stdio.h>
  7. #include "gf.h"
  8. #include "parint.h"
  9.  
  10.  
  11. /*
  12. **  unsigned short
  13. ** PrBufS(PARINT *p,int option,char *string)
  14. **
  15. ** ARGUMENT(s)
  16. **    p    -    points to PARINT structure.
  17. **    option    -    1==send CR/LF sequence to printer after
  18. **               string.
  19. **            0==send nothing after string.
  20. **    string    -    points to NULL terminated string to transmit.
  21. **
  22. ** DESCRIPTION
  23. **  Transfers a string to the printer buffer.  Will optionally add a
  24. **  CR/LF sequence to the end of the string.  If there is not enough
  25. **  room in the buffer to hold all characters in string this function
  26. **  will return.  Look at the return code to determine how many characters
  27. **  were actually put in the buffer.
  28. **
  29. ** RETURNS
  30. **  Number of characters sent to the printer buffer.
  31. **
  32. ** AUTHOR
  33. **  ""   Fri 18-Nov-1988  11:34:33
  34. **   Copyright (C)1988-1990 Greenleaf Software Inc. All Rights Reserved.
  35. **
  36. ** MODIFICATIONS
  37. **
  38. */
  39.  
  40. unsigned GF_CONV PrBufS(p,option,string)
  41. PARINT *p;
  42. int option;
  43. char *string;
  44. {
  45.     unsigned returnvalue=0;
  46.  
  47.     while(*string&&!p->StatusBits.bufferfull){
  48.         PrBufC(p,*string++);
  49.         returnvalue++;
  50.     }
  51.     if(*string)
  52.         return(returnvalue);
  53.     if(option) {
  54.         if(!PrBufC(p,'\x0d')) {
  55.             ++returnvalue;
  56.             if(!PrBufC(p,'\x0a'))
  57.                 ++returnvalue;
  58.         }
  59.     }
  60.     return(returnvalue);
  61. }
  62.