ixmlmembuf.h
Go to the documentation of this file.
/**************************************************************************
*
* Copyright (c) 2000-2003 Intel Corporation
* All rights reserved.
* Copyright (c) 2012 France Telecom All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* - Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* - Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
* - Neither name of Intel Corporation nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL INTEL OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
* OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
**************************************************************************/
#ifndef IXML_MEMBUF_H
#define IXML_MEMBUF_H
#include "ixml.h"
#include <stdlib.h> /* for size_t */
#define MINVAL(a, b) ((a) < (b) ? (a) : (b))
#define MAXVAL(a, b) ((a) > (b) ? (a) : (b))
#define MEMBUF_DEF_SIZE_INC 20u
typedef struct
{
char *buf;
size_t length;
size_t capacity;
size_t size_inc;
} ixml_membuf;
void ixml_membuf_init(
ixml_membuf *m);
void ixml_membuf_destroy(
ixml_membuf *m);
int ixml_membuf_assign(
ixml_membuf *m,
const void *buf,
size_t buf_len);
int ixml_membuf_assign_str(
ixml_membuf *m,
const char *c_str);
int ixml_membuf_append(
ixml_membuf *m,
const void *buf);
int ixml_membuf_append_str(
ixml_membuf *m,
const char *c_str);
int ixml_membuf_insert(
ixml_membuf *m,
const void *buf,
size_t buf_len,
size_t index);
#endif /* IXML_MEMBUF_H */
ixml.h
ixml_membuf_destroy
void ixml_membuf_destroy(ixml_membuf *m)
ixml_membuf clearing routine.
Definition ixmlmembuf.c:113
ixml_membuf_init
void ixml_membuf_init(ixml_membuf *m)
ixml_membuf initialization routine.
Definition ixmlmembuf.c:103
ixml_membuf_assign_str
int ixml_membuf_assign_str(ixml_membuf *m, const char *c_str)
Copies a NULL terminated string to the ixml_buffer.
Definition ixmlmembuf.c:150
ixml_membuf_append
int ixml_membuf_append(ixml_membuf *m, const void *buf)
Appends one byte to the designated ixml_membuffer.
Definition ixmlmembuf.c:155
ixml_membuf_append_str
int ixml_membuf_append_str(ixml_membuf *m, const char *c_str)
Appends the contents of a NULL terminated string to the designated ixml_membuf.
Definition ixmlmembuf.c:166
ixml_membuf_assign
int ixml_membuf_assign(ixml_membuf *m, const void *buf, size_t buf_len)
Copies the contents o a buffer to the designated ixml_membuf.
Definition ixmlmembuf.c:123
ixml_membuf_insert
int ixml_membuf_insert(ixml_membuf *m, const void *buf, size_t buf_len, size_t index)
Definition ixmlmembuf.c:175
ixml_membuf
The ixml_membuf type.
Definition ixmlmembuf.h:53