home *** CD-ROM | disk | FTP | other *** search
/ The Pier Shareware 6 / The_Pier_Shareware_Number_6_(The_Pier_Exchange)_(1995).iso / 024 / psi110g.zip / MBUF.H < prev    next >
C/C++ Source or Header  |  1994-04-17  |  3KB  |  75 lines

  1. #ifndef _MBUF_H
  2. #define _MBUF_H
  3.   
  4. #include <stdio.h>
  5.   
  6. #ifndef _GLOBAL_H
  7. #include "global.h"
  8. #endif
  9.   
  10. #ifndef LINUX
  11. extern unsigned Ibufsize;   /* Size of interrupt buffers to allocate */
  12. extern int Nibufs;      /* Number of interrupt buffers to allocate */
  13. #endif
  14.   
  15. /* Basic message buffer structure */
  16. struct mbuf {
  17.     struct mbuf *next;  /* Links mbufs belonging to single packets */
  18.     struct mbuf *anext; /* Links packets on queues */
  19.     int16 size;     /* Size of associated data buffer */
  20.     int refcnt;     /* Reference count */
  21.     struct mbuf *dup;   /* Pointer to duplicated mbuf */
  22.     char *data;     /* Active working pointers */
  23.     int16 cnt;
  24. };
  25. #define NULLBUF (struct mbuf *)0
  26. #define NULLBUFP (struct mbuf **)0
  27.   
  28. #define PULLCHAR(bpp)\
  29. ((bpp) != NULL && (*bpp) != NULLBUF && (*bpp)->cnt > 1 ? \
  30. ((*bpp)->cnt--,(unsigned char)*(*bpp)->data++) : pullchar(bpp))
  31.   
  32. /* In mbuf.c: */
  33. struct mbuf *alloc_mbuf __ARGS((int16 size));
  34. struct mbuf *free_mbuf __ARGS((struct mbuf *bp));
  35.   
  36. struct mbuf *ambufw __ARGS((int16 size));
  37. struct mbuf *copy_p __ARGS((struct mbuf *bp,int16 cnt));
  38. int16 dup_p __ARGS((struct mbuf **hp,struct mbuf *bp,int16 offset,int16 cnt));
  39. struct mbuf *free_p __ARGS((struct mbuf *bp));
  40. int16 len_p __ARGS((struct mbuf *bp));
  41. void trim_mbuf __ARGS((struct mbuf **bpp,int16 length));
  42. int write_p __ARGS((FILE *fp,struct mbuf *bp));
  43.   
  44. struct mbuf *dequeue __ARGS((struct mbuf **q));
  45. void enqueue __ARGS((struct mbuf **q,struct mbuf *bp));
  46. void free_q __ARGS((struct mbuf **q));
  47. int16 len_q __ARGS((struct mbuf *bp));
  48.   
  49. struct mbuf *qdata __ARGS((char *data,int16 cnt));
  50. int16 dqdata __ARGS((struct mbuf *bp,char *buf,unsigned cnt));
  51.   
  52. void append __ARGS((struct mbuf **bph,struct mbuf *bp));
  53. struct mbuf *pushdown __ARGS((struct mbuf *bp,int16 size));
  54. int16 pullup __ARGS((struct mbuf **bph,char *buf,int16 cnt));
  55.   
  56. int pullchar __ARGS((struct mbuf **bpp));       /* returns -1 if nothing */
  57. long pull16 __ARGS((struct mbuf **bpp));    /* returns -1 if nothing */
  58. int32 pull32 __ARGS((struct mbuf **bpp));   /* returns  0 if nothing */
  59.   
  60. int16 get16 __ARGS((char *cp));
  61. int32 get32 __ARGS((char *cp));
  62. char *put16 __ARGS((char *cp,int16 x));
  63. char *put32 __ARGS((char *cp,int32 x));
  64.   
  65. #ifndef LINUX
  66. void iqclear __ARGS((void));
  67. void iqstat __ARGS((void));
  68. void refiq __ARGS((void));
  69. #endif
  70. void mbuf_crunch __ARGS((struct mbuf **bpp));
  71.   
  72. #define AUDIT(bp)       audit(bp,__FILE__,__LINE__)
  73.   
  74. #endif  /* _MBUF_H */
  75.