home *** CD-ROM | disk | FTP | other *** search
/ Piper's Pit BBS/FTP: ibm 0020 - 0029 / ibm0020-0029 / ibm0028.tar / ibm0028 / GRLF-C-1.ZIP / PARINT.H < prev   
Encoding:
C/C++ Source or Header  |  1990-05-30  |  2.7 KB  |  91 lines

  1. /*
  2. ** parint.h
  3. ** contains:
  4. */
  5.  
  6.  
  7. /*
  8. ** DESCRIPTION
  9. **  Header file for interrupt driven parallel port functions.
  10. **
  11. ** AUTHOR
  12. **  ""   Wed 16-Nov-1988  16:17:16
  13. **   Copyright (C)1988-1990 Greenleaf Software Inc. All Rights Reserved.
  14. **
  15. ** MODIFICATIONS
  16. **
  17. */
  18.  
  19.  
  20. /* PARSTATUSBITS defines the bits inside the StatusBits member of the
  21. ** PARINT structure.
  22. */
  23. typedef struct PARSTATUSBITS {
  24.     unsigned bufferempty: 1;
  25.     unsigned bufferfull:  1;
  26.     unsigned intsrunning: 1;
  27.     unsigned intsenabled: 1;
  28.     unsigned _parstresrv: 12;
  29. } PARSTATUSBITS;
  30.  
  31. /* The PARINT structure keeps all of the state information for a
  32. ** Parallel port.
  33. **
  34. */
  35. typedef struct {
  36.     PARSTATUSBITS  StatusBits;
  37.     unsigned BaseIOPARO;    /* Base Address of Parallel port */
  38.     unsigned IntNum;        /* Software Interrupt Number to use */
  39.     unsigned long  PrevVector;    /* What was at Interrupt vector previously */
  40.     unsigned PrevBase2;    /* What was at Interrupt Enable port of Parallel port */
  41.     unsigned Irq8259;     /* Irq # in 8259 to use */
  42.     unsigned Prev8259;    /* Previous value of 8259 bit */
  43.     unsigned IOAdd8259;    /* Base I/O Address of 8259 */
  44.     unsigned pBufSize;    /* Size of buffer */
  45.     unsigned pBufCount;    /* Number of characters in buffer */
  46.     unsigned pBufHead;    /* Offset into buffer for head */
  47.     unsigned pBufTail;    /* Offset into buffer for tail */
  48.     unsigned char  *pBuffer;    /* Points to actual buffer */
  49. } PARINT;
  50.  
  51. #define PARBUFFULL    -800        /* Parallel Buffer is Full */
  52.  
  53.  
  54. #define PRCHARINBUF(p)        p->pBufCount            /* Characters in buffer */
  55. #define PRSPACEINBUF(p)     (p->pBufSize-p->pBufCount)    /* Free Space in buffer */
  56. #define PRBUFEMPTY(p)        (p->StatusBits.bufferempty?1:0) /* Is buffer empty    */
  57. #define PRBUFFULL(p)        (p->StatusBits.bufferfull?1:0)    /* Is buffer full    */
  58.  
  59. /* PRROOMFORSTR(p,s) returns true (1) if there is room for the string (s)
  60. ** in the buffer, else returns false.  NOTE: Uses strlen().
  61. **/
  62.  
  63. #define PRROOMFORSTR(p,s)    (strlen(s)>p->pBufSize-p->pBufCount?0:1)
  64.  
  65.  
  66. #define OpenPrinter(a)    openprt(a)
  67. #define ClosePrinter(a) closeprt(a)
  68. #define StopPrinter(a)    stopprt(a)
  69. #define StartPrinter(a) strtprt(a)
  70. #define TestPrinter(a)    testprt(a)
  71.  
  72.  
  73. #ifdef __cplusplus
  74. extern "C" {
  75. #endif
  76.  
  77.  void GF_CDECL strtprt(PARINT *printdata);
  78.  PARINT * GF_CONV openprt(unsigned buffersize);
  79.  int  GF_CDECL PrBufC(PARINT *printdata,unsigned char character);
  80.  unsigned GF_CONV PrBufS(PARINT *printdata,int option,char *string);
  81.  unsigned GF_CDECL PrBufF(PARINT *printdata,int option,char *string,...);
  82.  unsigned char GF_CDECL testprt(PARINT *printdata);
  83.  void GF_CONV closeprt(PARINT *printdata);
  84.  void GF_CDECL stopprt(PARINT *printdata);
  85.  void GF_CDECL _closepar(PARINT *printdata);
  86.  void GF_CDECL _setpari(PARINT *printdata);
  87.  
  88. #ifdef __cplusplus
  89. }
  90. #endif
  91.