blob: 585005c271e6a0657f9bacb45fe5994bb902ab41 [file] [log] [blame]
yuezonghe824eb0c2024-06-27 02:32:26 -07001///////////////////////////////////////////////////////////////////////////
2//
3// Copyright (c) 2000-2003 Intel Corporation
4// All rights reserved.
5//
6// Redistribution and use in source and binary forms, with or without
7// modification, are permitted provided that the following conditions are met:
8//
9// * Redistributions of source code must retain the above copyright notice,
10// this list of conditions and the following disclaimer.
11// * Redistributions in binary form must reproduce the above copyright notice,
12// this list of conditions and the following disclaimer in the documentation
13// and/or other materials provided with the distribution.
14// * Neither name of Intel Corporation nor the names of its contributors
15// may be used to endorse or promote products derived from this software
16// without specific prior written permission.
17//
18// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
19// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
20// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
21// A PARTICULAR PURPOSE ARE DISCLAIMED. NO EVENT SHALL INTEL OR
22// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
23// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
24// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
25// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
26// OF LIABILITY, WHETHER CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
27// NEGLIGENCE OR OTHERWISE) ARISING ANY WAY OF THE USE OF THIS
28// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29//
30///////////////////////////////////////////////////////////////////////////
31
32#ifndef CWMP_XML_BUFFER_H
33#define CWMP_XML_BUFFER_H
34
35#include <stdlib.h>
36#include "cwmp/xmlet.h"
37
38#define MINVAL( a, b ) ( (a) < (b) ? (a) : (b) )
39#define MAXVAL( a, b ) ( (a) > (b) ? (a) : (b) )
40
41#define XINLINE inline
42
43#define MEMBUF_DEF_SIZE_INC 1024*4
44
45
46typedef struct // XmlBuffer
47{
48 char *buf;
49
50 size_t length;
51 size_t capacity;
52 size_t size_inc;
53
54} XmlBuffer;
55
56//--------------------------------------------------
57//////////////// functions /////////////////////////
58//--------------------------------------------------
59/*
60#ifdef __cplusplus
61extern "C" {
62#endif // __cplusplus
63*/
64
65
66void XmlBufferInit(XmlBuffer *m);
67void XmlBufferDestroy(
68#ifdef USE_CWMP_MEMORY_POOL
69 Pool * pool,
70#endif
71 XmlBuffer *m);
72
73int XmlBufferAssign(
74#ifdef USE_CWMP_MEMORY_POOL
75 Pool * pool,
76#endif
77
78 XmlBuffer *m, const void *buf,
79 size_t buf_len );
80int XmlBufferAssignString(
81#ifdef USE_CWMP_MEMORY_POOL
82 Pool * pool,
83#endif
84
85 XmlBuffer *m, const char *c_str );
86int XmlBufferAppend(
87#ifdef USE_CWMP_MEMORY_POOL
88 Pool * pool,
89#endif
90
91 XmlBuffer *m, const void *buf);
92int XmlBufferAppendString(
93#ifdef USE_CWMP_MEMORY_POOL
94 Pool * pool,
95#endif
96 XmlBuffer *m, const char *c_str);
97int XmlBufferInsert(
98#ifdef USE_CWMP_MEMORY_POOL
99 Pool * pool,
100#endif
101
102 XmlBuffer *m, const void* buf,
103 size_t buf_len, int index );
104
105#endif // _CWMP_XML_MEMBUF_H