home *** CD-ROM | disk | FTP | other *** search
/ InfoMagic Source Code 1993 July / THE_SOURCE_CODE_CD_ROM.iso / bsd_srcs / contrib / usr.x25 / nimd / buf.h < prev    next >
Encoding:
C/C++ Source or Header  |  1988-04-13  |  986 b   |  26 lines

  1. #define FLAG(bp)    (bp)->b_data[0]
  2. #define ISEMPTY(bp)    ((bp)->b_top == (bp)->b_bot)
  3. #define RESET(bp)    (bp)->b_top = (bp)->b_bot = (bp)->b_data
  4. #define QEMPTY(qp)    ((qp)->b_next == (struct buf *)qp)
  5. #define SIZE(bp)    ((bp)->b_top - (bp)->b_bot)
  6. #define GETCHAR(bp)    (*(bp)->b_bot++ & 0377)
  7. #define PUTCHAR(c, bp)    *(bp)->b_top++ = c
  8. #define UNGETC(c, bp)    *--(bp)->b_bot = c
  9. #define BUFCOPY(f, t)    bcopy((f)->b_bot, (t)->b_top, SIZE(f)); (t)->b_top+=SIZE(f);
  10. #define STRTOBUF(s, bp)    { register char *sp=s; register int l=strlen(s); \
  11.             bcopy(s, (bp)->b_top, l); (bp)->b_top += l;}
  12.  
  13. struct    bufhd {        /* buffer header; b_prev and b_next must be first */
  14.     struct    buf *b_prev, *b_next;
  15.     short    b_count;    /* total number of bytes of data queued */
  16. };
  17.  
  18. struct    buf {
  19.     struct    buf *b_prev, *b_next;    /* previous and next buffers */
  20.     char    *b_bot;        /* start of useful data */
  21.     char    *b_top;        /* current position in data */
  22.     char    b_data[1];    /* usually more than 1 byte */
  23. } ;
  24.  
  25. struct    buf *getbuf(), *FillBuf();
  26.