Annotation of embedaddon/mpd/src/mbuf.h, revision 1.1.1.5
1.1 misho 1:
2: /*
3: * mbuf.c
4: *
5: * Written by Toshiharu OHNO <tony-o@iij.ad.jp>
6: * Copyright (c) 1993, Internet Initiative Japan, Inc. All rights reserved.
7: * See ``COPYRIGHT.iij''
8: *
9: * Rewritten by Archie Cobbs <archie@freebsd.org>
10: * Copyright (c) 1995-1999 Whistle Communications, Inc. All rights reserved.
11: * See ``COPYRIGHT.whistle''
12: */
13:
14: #ifndef _MBUF_H_
15: #define _MBUF_H_
16:
17: /*
18: * DEFINITIONS
19: */
20:
21: struct mpdmbuf {
22: int size; /* size allocated */
23: int offset; /* offset to start position */
24: int cnt; /* available byte count in buffer */
25: };
26:
27: typedef struct mpdmbuf *Mbuf;
28:
29: /* Macros */
30: #define MBDATAU(bp) ((u_char *)(bp) + sizeof(struct mpdmbuf) + (bp)->offset)
31: #define MBDATA(bp) ((bp) ? MBDATAU(bp) : NULL)
1.1.1.3 misho 32: #define MBLEN(bp) ((size_t)((bp) ? (bp)->cnt : 0))
1.1 misho 33: #define MBSPACE(bp) ((bp) ? (bp)->size - (bp)->offset : 0)
34:
35: /* Types of allocated memory */
36: #define MB_AUTH "AUTH"
37: #define MB_CONS "CONSOLE"
38: #define MB_WEB "WEB"
39: #define MB_IFACE "IFACE"
40: #define MB_BUND "BUND"
41: #define MB_REP "REP"
42: #define MB_LINK "LINK"
43: #define MB_CHAT "CHAT"
44: #define MB_CMD "CMD"
45: #define MB_CMDL "CMDL"
46: #define MB_COMP "COMP"
47: #define MB_CRYPT "CRYPT"
48: #define MB_ECHO "ECHO"
49: #define MB_EVENT "EVENT"
50: #define MB_FSM "FSM"
51: #define MB_LOG "LOG"
52: #define MB_MP "MP"
53: #define MB_MBUF "MBUF"
54: #define MB_PHYS "PHYS"
55: #define MB_PPTP "PPTP"
56: #define MB_RADIUS "RADIUS"
57: #define MB_RADSRV "RADSRV"
1.1.1.2 misho 58: #define MB_ACL "ACL_BPF"
59: #define MB_IPFW "ACL_IPFW"
1.1 misho 60: #define MB_UTIL "UTIL"
61: #define MB_VJCOMP "VJCOMP"
62: #define MB_IPPOOL "IPPOOL"
63:
64: #ifndef __malloc_like
65: #define __malloc_like
66: #endif
67:
68: /*
69: * FUNCTIONS
70: */
71:
72: /* Replacements for malloc() & free() */
73:
74: extern void *Malloc(const char *type, size_t size) __malloc_like;
75: extern void *Mdup(const char *type, const void *src, size_t size) __malloc_like;
1.1.1.4 misho 76: extern void *Mdup2(const char *type, const void *src, size_t oldsize, size_t newsize) __malloc_like;
1.1 misho 77: extern void *Mstrdup(const char *type, const void *src) __malloc_like;
78: extern void Freee(void *ptr);
79:
80: /* Mbuf manipulation */
81:
82: extern Mbuf mballoc(int size) __malloc_like;
83: extern void mbfree(Mbuf bp);
84: extern Mbuf mbread(Mbuf bp, void *ptr, int cnt);
85: extern int mbcopy(Mbuf bp, int offset, void *buf, int cnt);
86: extern Mbuf mbcopyback(Mbuf bp, int offset, const void *buf, int cnt);
87: extern Mbuf mbtrunc(Mbuf bp, int max);
88: extern Mbuf mbadj(Mbuf bp, int cnt);
89: extern Mbuf mbsplit(Mbuf bp, int cnt);
90:
91: /* Etc */
92:
1.1.1.5 ! misho 93: extern int MemStat(Context ctx, int ac, const char *const av[], const void *arg);
1.1 misho 94: extern void DumpBp(Mbuf bp);
95:
96: #endif
97:
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>