mirror of
https://gitlab.gnome.org/GNOME/libxml2.git
synced 2025-01-27 14:03:36 +03:00
82cdfc4eb3
As suggested by Andrew W. Nosenko: Proposal: expose the new xmlBufShrink() to the "public" API for compatibility with xmlBufUse(). Reason: the following scenario: 1. Read something into xmlParserInputBuffer (e.g. using xmlParserInputBufferRead()) 2. Extract content through xmlBufContent() 3. Extract content length through xmlBufUse(). Result have type 'size_t'. 4. Use this content 5. Now, you need to shrink the buffer. How to do it? Doing that through legacy xmlBufferShrink() is unsafe because it uses 'unsigned int' and the whole point of introducing the new API was handling the cases, when 'unsigned int' is not enough. Therefore, need to use the new xmlBufShrink(). But it is "private". Therefore, I propose to expose the new xmlBufShrink() in the same way, as xmlBufContent() and xmlBufUse() are exposed.
73 lines
2.3 KiB
C
73 lines
2.3 KiB
C
/*
|
|
* Summary: Internal Interfaces for memory buffers in libxml2
|
|
* Description: this module describes most of the new xmlBuf buffer
|
|
* entry points, those are private routines, with a
|
|
* few exceptions exported in tree.h. This was added
|
|
* in 2.9.0.
|
|
*
|
|
* Copy: See Copyright for the status of this software.
|
|
*
|
|
* Author: Daniel Veillard
|
|
*/
|
|
|
|
#ifndef __XML_BUF_H__
|
|
#define __XML_BUF_H__
|
|
|
|
#include <libxml/tree.h>
|
|
|
|
#ifdef __cplusplus
|
|
extern "C" {
|
|
#endif
|
|
|
|
xmlBufPtr xmlBufCreate(void);
|
|
xmlBufPtr xmlBufCreateSize(size_t size);
|
|
xmlBufPtr xmlBufCreateStatic(void *mem, size_t size);
|
|
|
|
int xmlBufSetAllocationScheme(xmlBufPtr buf,
|
|
xmlBufferAllocationScheme scheme);
|
|
int xmlBufGetAllocationScheme(xmlBufPtr buf);
|
|
|
|
void xmlBufFree(xmlBufPtr buf);
|
|
void xmlBufEmpty(xmlBufPtr buf);
|
|
|
|
/* size_t xmlBufShrink(xmlBufPtr buf, size_t len); */
|
|
int xmlBufGrow(xmlBufPtr buf, int len);
|
|
int xmlBufInflate(xmlBufPtr buf, size_t len);
|
|
int xmlBufResize(xmlBufPtr buf, size_t len);
|
|
|
|
int xmlBufAdd(xmlBufPtr buf, const xmlChar *str, int len);
|
|
int xmlBufAddHead(xmlBufPtr buf, const xmlChar *str, int len);
|
|
int xmlBufCat(xmlBufPtr buf, const xmlChar *str);
|
|
int xmlBufCCat(xmlBufPtr buf, const char *str);
|
|
int xmlBufWriteCHAR(xmlBufPtr buf, const xmlChar *string);
|
|
int xmlBufWriteChar(xmlBufPtr buf, const char *string);
|
|
int xmlBufWriteQuotedString(xmlBufPtr buf, const xmlChar *string);
|
|
|
|
size_t xmlBufAvail(const xmlBufPtr buf);
|
|
size_t xmlBufLength(const xmlBufPtr buf);
|
|
/* size_t xmlBufUse(const xmlBufPtr buf); */
|
|
int xmlBufIsEmpty(const xmlBufPtr buf);
|
|
int xmlBufAddLen(xmlBufPtr buf, size_t len);
|
|
int xmlBufErase(xmlBufPtr buf, size_t len);
|
|
|
|
/* const xmlChar * xmlBufContent(const xmlBufPtr buf); */
|
|
/* const xmlChar * xmlBufEnd(const xmlBufPtr buf); */
|
|
|
|
xmlChar * xmlBufDetach(xmlBufPtr buf);
|
|
|
|
size_t xmlBufDump(FILE *file, xmlBufPtr buf);
|
|
|
|
xmlBufPtr xmlBufFromBuffer(xmlBufferPtr buffer);
|
|
xmlBufferPtr xmlBufBackToBuffer(xmlBufPtr buf);
|
|
int xmlBufMergeBuffer(xmlBufPtr buf, xmlBufferPtr buffer);
|
|
|
|
int xmlBufResetInput(xmlBufPtr buf, xmlParserInputPtr input);
|
|
size_t xmlBufGetInputBase(xmlBufPtr buf, xmlParserInputPtr input);
|
|
int xmlBufSetInputBaseCur(xmlBufPtr buf, xmlParserInputPtr input,
|
|
size_t base, size_t cur);
|
|
#ifdef __cplusplus
|
|
}
|
|
#endif
|
|
#endif /* __XML_BUF_H__ */
|
|
|