Annotation of embedaddon/mpd/src/mbuf.h, revision 1.1.1.1
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)
32: #define MBLEN(bp) ((bp) ? (bp)->cnt : 0)
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"
58: #define MB_UTIL "UTIL"
59: #define MB_VJCOMP "VJCOMP"
60: #define MB_IPPOOL "IPPOOL"
61:
62: #ifndef __malloc_like
63: #define __malloc_like
64: #endif
65:
66: /*
67: * FUNCTIONS
68: */
69:
70: /* Replacements for malloc() & free() */
71:
72: extern void *Malloc(const char *type, size_t size) __malloc_like;
73: extern void *Mdup(const char *type, const void *src, size_t size) __malloc_like;
74: extern void *Mstrdup(const char *type, const void *src) __malloc_like;
75: extern void Freee(void *ptr);
76:
77: /* Mbuf manipulation */
78:
79: extern Mbuf mballoc(int size) __malloc_like;
80: extern void mbfree(Mbuf bp);
81: extern Mbuf mbread(Mbuf bp, void *ptr, int cnt);
82: extern int mbcopy(Mbuf bp, int offset, void *buf, int cnt);
83: extern Mbuf mbcopyback(Mbuf bp, int offset, const void *buf, int cnt);
84: extern Mbuf mbtrunc(Mbuf bp, int max);
85: extern Mbuf mbadj(Mbuf bp, int cnt);
86: extern Mbuf mbsplit(Mbuf bp, int cnt);
87:
88: /* Etc */
89:
90: extern int MemStat(Context ctx, int ac, char *av[], void *arg);
91: extern void DumpBp(Mbuf bp);
92:
93: #endif
94:
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>