BSD 4_3_Net_2 development
[unix-history] / usr / src / contrib / usr.x25 / nimd / buf.h
CommitLineData
d635240e
C
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
13struct 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
18struct 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
25struct buf *getbuf(), *FillBuf();