gwenhywfar 5.12.0
buffer.h File Reference
#include <gwenhywfar/gwenhywfarapi.h>
#include <gwenhywfar/types.h>
#include <stdio.h>
#include <string.h>

Go to the source code of this file.

Macros

#define GWEN_BUFFER_MAX_BOOKMARKS   64
 
#define GWEN_BUFFER_MODE_ABORT_ON_MEMFULL   0x0002
 
#define GWEN_BUFFER_MODE_DEFAULT
 
#define GWEN_BUFFER_MODE_DYNAMIC   0x0001
 
#define GWEN_BUFFER_MODE_READONLY   0x0020
 

Typedefs

typedef struct GWEN_BUFFER GWEN_BUFFER
 A dynamically resizeable text buffer.
 

Functions

GWENHYWFAR_API void GWEN_Buffer_AddMode (GWEN_BUFFER *bf, uint32_t mode)
 
GWENHYWFAR_API int GWEN_Buffer_AdjustUsedBytes (GWEN_BUFFER *bf)
 
GWENHYWFAR_API int GWEN_Buffer_AllocRoom (GWEN_BUFFER *bf, uint32_t size)
 
GWENHYWFAR_API int GWEN_Buffer_AppendBuffer (GWEN_BUFFER *bf, GWEN_BUFFER *sf)
 
GWENHYWFAR_API int GWEN_Buffer_AppendByte (GWEN_BUFFER *bf, char c)
 
GWENHYWFAR_API int GWEN_Buffer_AppendBytes (GWEN_BUFFER *bf, const char *buffer, uint32_t size)
 
GWENHYWFAR_API int GWEN_Buffer_AppendString (GWEN_BUFFER *bf, const char *buffer)
 
GWENHYWFAR_API void GWEN_Buffer_Attach (GWEN_BUFFER *bf)
 
GWENHYWFAR_API int GWENHYWFAR_CB GWEN_Buffer_CacheFn_Attach (void *ptr)
 
GWENHYWFAR_API int GWENHYWFAR_CB GWEN_Buffer_CacheFn_Free (void *ptr)
 
GWENHYWFAR_API int GWEN_Buffer_Crop (GWEN_BUFFER *bf, uint32_t pos, uint32_t l)
 
GWENHYWFAR_API int GWEN_Buffer_DecrementPos (GWEN_BUFFER *bf, uint32_t i)
 
GWENHYWFAR_API void GWEN_Buffer_Dump (GWEN_BUFFER *bf, unsigned int insert)
 
GWENHYWFAR_API GWEN_BUFFERGWEN_Buffer_dup (GWEN_BUFFER *bf)
 
GWENHYWFAR_API int GWEN_Buffer_FillLeftWithBytes (GWEN_BUFFER *bf, unsigned char c, uint32_t size)
 
GWENHYWFAR_API const char GWENHYWFAR_API int GWEN_Buffer_FillWithBytes (GWEN_BUFFER *bf, unsigned char c, uint32_t size)
 
GWENHYWFAR_API void GWEN_Buffer_free (GWEN_BUFFER *bf)
 
GWENHYWFAR_API uint32_t GWEN_Buffer_GetBookmark (const GWEN_BUFFER *bf, unsigned int idx)
 
GWENHYWFAR_API uint32_t GWEN_Buffer_GetBytesLeft (GWEN_BUFFER *bf)
 
GWENHYWFAR_API uint32_t GWEN_Buffer_GetHardLimit (GWEN_BUFFER *bf)
 
GWENHYWFAR_API uint32_t GWEN_Buffer_GetMaxUnsegmentedWrite (GWEN_BUFFER *bf)
 
GWENHYWFAR_API uint32_t GWEN_Buffer_GetMode (GWEN_BUFFER *bf)
 
GWENHYWFAR_API uint32_t GWEN_Buffer_GetPos (const GWEN_BUFFER *bf)
 
GWENHYWFAR_API char * GWEN_Buffer_GetPosPointer (const GWEN_BUFFER *bf)
 
GWENHYWFAR_API uint32_t GWEN_Buffer_GetSize (const GWEN_BUFFER *bf)
 
GWENHYWFAR_API char * GWEN_Buffer_GetStart (const GWEN_BUFFER *bf)
 
GWENHYWFAR_API uint32_t GWEN_Buffer_GetStep (GWEN_BUFFER *bf)
 
GWENHYWFAR_API uint32_t GWEN_Buffer_GetUsedBytes (const GWEN_BUFFER *bf)
 
GWENHYWFAR_API int GWEN_Buffer_IncrementPos (GWEN_BUFFER *bf, uint32_t i)
 
GWENHYWFAR_API int GWEN_Buffer_InsertBuffer (GWEN_BUFFER *bf, GWEN_BUFFER *sf)
 
GWENHYWFAR_API int GWEN_Buffer_InsertByte (GWEN_BUFFER *bf, char c)
 
GWENHYWFAR_API int GWEN_Buffer_InsertBytes (GWEN_BUFFER *bf, const char *buffer, uint32_t size)
 
GWENHYWFAR_API int GWEN_Buffer_InsertRoom (GWEN_BUFFER *bf, uint32_t size)
 
GWENHYWFAR_API int GWEN_Buffer_InsertString (GWEN_BUFFER *bf, const char *buffer)
 
GWENHYWFAR_API int GWEN_Buffer_KeepTextBetweenStrings (GWEN_BUFFER *bf, const char *openingString, const char *closingString, int onlyBetween)
 
GWENHYWFAR_API GWEN_BUFFERGWEN_Buffer_new (char *buffer, uint32_t size, uint32_t used, int take_ownership)
 
GWENHYWFAR_API void GWEN_Buffer_OverwriteContent (GWEN_BUFFER *bf, int c)
 
GWENHYWFAR_API int GWEN_Buffer_PeekByte (GWEN_BUFFER *bf)
 
GWENHYWFAR_API int GWEN_Buffer_ReadByte (GWEN_BUFFER *bf)
 
GWENHYWFAR_API int GWEN_Buffer_ReadBytes (GWEN_BUFFER *bf, char *buffer, uint32_t *size)
 
GWENHYWFAR_API int GWEN_Buffer_Relinquish (GWEN_BUFFER *bf)
 
GWENHYWFAR_API int GWEN_Buffer_RemoveRoom (GWEN_BUFFER *bf, uint32_t size)
 
GWENHYWFAR_API int GWEN_Buffer_ReplaceBytes (GWEN_BUFFER *bf, uint32_t rsize, const char *buffer, uint32_t size)
 
GWENHYWFAR_API int GWEN_Buffer_ReserveBytes (GWEN_BUFFER *bf, uint32_t res)
 
GWENHYWFAR_API void GWEN_Buffer_Reset (GWEN_BUFFER *bf)
 
GWENHYWFAR_API void GWEN_Buffer_Rewind (GWEN_BUFFER *bf)
 
GWENHYWFAR_API void GWEN_Buffer_SetBookmark (GWEN_BUFFER *bf, unsigned int idx, uint32_t v)
 
GWENHYWFAR_API void GWEN_Buffer_SetHardLimit (GWEN_BUFFER *bf, uint32_t l)
 
GWENHYWFAR_API void GWEN_Buffer_SetMode (GWEN_BUFFER *bf, uint32_t mode)
 
GWENHYWFAR_API int GWEN_Buffer_SetPos (GWEN_BUFFER *bf, uint32_t i)
 
GWENHYWFAR_API void GWEN_Buffer_SetStep (GWEN_BUFFER *bf, uint32_t step)
 
GWENHYWFAR_API void GWEN_Buffer_SubMode (GWEN_BUFFER *bf, uint32_t mode)
 
GWENHYWFAR_API GWEN_FORMAT (printf, 2, 3) int GWEN_Buffer_AppendArgs(GWEN_BUFFER *bf
 

Variables

GWENHYWFAR_API const char * fmt
 

Macro Definition Documentation

◆ GWEN_BUFFER_MAX_BOOKMARKS

#define GWEN_BUFFER_MAX_BOOKMARKS   64

Definition at line 64 of file buffer.h.

◆ GWEN_BUFFER_MODE_ABORT_ON_MEMFULL

#define GWEN_BUFFER_MODE_ABORT_ON_MEMFULL   0x0002

Definition at line 67 of file buffer.h.

◆ GWEN_BUFFER_MODE_DEFAULT

#define GWEN_BUFFER_MODE_DEFAULT
Value:
(\
)
#define GWEN_BUFFER_MODE_ABORT_ON_MEMFULL
Definition buffer.h:67
#define GWEN_BUFFER_MODE_DYNAMIC
Definition buffer.h:66

Definition at line 70 of file buffer.h.

◆ GWEN_BUFFER_MODE_DYNAMIC

#define GWEN_BUFFER_MODE_DYNAMIC   0x0001

Definition at line 66 of file buffer.h.

◆ GWEN_BUFFER_MODE_READONLY

#define GWEN_BUFFER_MODE_READONLY   0x0020

Definition at line 68 of file buffer.h.

Function Documentation

◆ GWEN_Buffer_AddMode()

GWENHYWFAR_API void GWEN_Buffer_AddMode ( GWEN_BUFFER * bf,
uint32_t mode )

Adds the give mode to the current mode of the buffer (such as GWEN_BUFFER_MODE_DYNAMIC).

◆ GWEN_Buffer_AdjustUsedBytes()

GWENHYWFAR_API int GWEN_Buffer_AdjustUsedBytes ( GWEN_BUFFER * bf)

The functions GWEN_Buffer_IncrementPos and GWEN_Buffer_DecrementPos only modify the internal position pointer. This function here adjusts the number of used bytes to just before the internal position pointer. This is often used to avoid copying, like in the following example:

char *p;
int i;
for (i=0; i<100; i++) {
GWEN_Buffer_AllocRoom(buffer, 512);
p=GWEN_Buffer_GetPosPtr(buffer);
READ_512_BYTES_TO_P;
}
GWENHYWFAR_API int GWEN_Buffer_AllocRoom(GWEN_BUFFER *bf, uint32_t size)
GWENHYWFAR_API int GWEN_Buffer_AdjustUsedBytes(GWEN_BUFFER *bf)
GWENHYWFAR_API int GWEN_Buffer_IncrementPos(GWEN_BUFFER *bf, uint32_t i)

◆ GWEN_Buffer_AllocRoom()

GWENHYWFAR_API int GWEN_Buffer_AllocRoom ( GWEN_BUFFER * bf,
uint32_t size )

Make sure that the buffer has enough room for the given bytes.

◆ GWEN_Buffer_AppendBuffer()

GWENHYWFAR_API int GWEN_Buffer_AppendBuffer ( GWEN_BUFFER * bf,
GWEN_BUFFER * sf )

Append the content of the buffer sf at the end of the buffer bf. The size of bf will be increased accordingly. Returns zero on success or nonzero if this failed (e.g. because of out of memory error).

◆ GWEN_Buffer_AppendByte()

GWENHYWFAR_API int GWEN_Buffer_AppendByte ( GWEN_BUFFER * bf,
char c )

Appends a single byte to this GWEN_BUFFER, if there is enough room. The position pointer is adjusted accordingly.

Returns
0 if ok, !=0 on error

◆ GWEN_Buffer_AppendBytes()

GWENHYWFAR_API int GWEN_Buffer_AppendBytes ( GWEN_BUFFER * bf,
const char * buffer,
uint32_t size )

Copies the contents of the given buffer to this GWEN_BUFFER, if there is enough room. The position pointer is adjusted accordingly.

Returns
0 if ok, !=0 on error

◆ GWEN_Buffer_AppendString()

GWENHYWFAR_API int GWEN_Buffer_AppendString ( GWEN_BUFFER * bf,
const char * buffer )

Appends a string to the buffer (without the trailing null char!) The position pointer is adjusted accordingly.

Returns
0 if ok, !=0 on error

◆ GWEN_Buffer_Attach()

GWENHYWFAR_API void GWEN_Buffer_Attach ( GWEN_BUFFER * bf)

Increases the internal reference counter. It is decreased by GWEN_Buffer_free().

◆ GWEN_Buffer_CacheFn_Attach()

GWENHYWFAR_API int GWENHYWFAR_CB GWEN_Buffer_CacheFn_Attach ( void * ptr)

This is a callback function to be used by GWEN_MULTICACHE (and only for that). It internally calls GWEN_Buffer_Attach().

◆ GWEN_Buffer_CacheFn_Free()

GWENHYWFAR_API int GWENHYWFAR_CB GWEN_Buffer_CacheFn_Free ( void * ptr)

This is a callback function to be used by GWEN_MULTICACHE (and only for that). It internally calls GWEN_Buffer_free().

◆ GWEN_Buffer_Crop()

GWENHYWFAR_API int GWEN_Buffer_Crop ( GWEN_BUFFER * bf,
uint32_t pos,
uint32_t l )

◆ GWEN_Buffer_DecrementPos()

GWENHYWFAR_API int GWEN_Buffer_DecrementPos ( GWEN_BUFFER * bf,
uint32_t i )

Move the position pointer backward by the given number i.

◆ GWEN_Buffer_Dump()

GWENHYWFAR_API void GWEN_Buffer_Dump ( GWEN_BUFFER * bf,
unsigned int insert )

Print the current content of buffer bf into the file f.

◆ GWEN_Buffer_dup()

GWENHYWFAR_API GWEN_BUFFER * GWEN_Buffer_dup ( GWEN_BUFFER * bf)

Create a new copy as a duplicate of the buffer bf.

◆ GWEN_Buffer_FillLeftWithBytes()

GWENHYWFAR_API int GWEN_Buffer_FillLeftWithBytes ( GWEN_BUFFER * bf,
unsigned char c,
uint32_t size )

◆ GWEN_Buffer_FillWithBytes()

GWENHYWFAR_API const char GWENHYWFAR_API int GWEN_Buffer_FillWithBytes ( GWEN_BUFFER * bf,
unsigned char c,
uint32_t size )

◆ GWEN_Buffer_free()

GWENHYWFAR_API void GWEN_Buffer_free ( GWEN_BUFFER * bf)

Frees the given buffer.

If the internal storage was allocated for this new buffer, then it will freed here. If the internal storage is used from a different buffer, then it will only be freed if the argument take_ownership of GWEN_Buffer_new() was nonzero.

◆ GWEN_Buffer_GetBookmark()

GWENHYWFAR_API uint32_t GWEN_Buffer_GetBookmark ( const GWEN_BUFFER * bf,
unsigned int idx )

Returns the given bookmark

◆ GWEN_Buffer_GetBytesLeft()

GWENHYWFAR_API uint32_t GWEN_Buffer_GetBytesLeft ( GWEN_BUFFER * bf)

Returns the number of bytes from pos to the end of the used area.

◆ GWEN_Buffer_GetHardLimit()

GWENHYWFAR_API uint32_t GWEN_Buffer_GetHardLimit ( GWEN_BUFFER * bf)

Returns the hard limit. This is the maximum size of a GWEN_BUFFER in dynamic mode.

◆ GWEN_Buffer_GetMaxUnsegmentedWrite()

GWENHYWFAR_API uint32_t GWEN_Buffer_GetMaxUnsegmentedWrite ( GWEN_BUFFER * bf)

Returns the maximum number of bytes which can be written to the buffer at once (i.e. without reallocation).

◆ GWEN_Buffer_GetMode()

GWENHYWFAR_API uint32_t GWEN_Buffer_GetMode ( GWEN_BUFFER * bf)

Returns the current mode of the buffer (such as GWEN_BUFFER_MODE_DYNAMIC).

◆ GWEN_Buffer_GetPos()

GWENHYWFAR_API uint32_t GWEN_Buffer_GetPos ( const GWEN_BUFFER * bf)

Returns the current position within the buffer. This pointer is adjusted by the various read and write functions.

◆ GWEN_Buffer_GetPosPointer()

GWENHYWFAR_API char * GWEN_Buffer_GetPosPointer ( const GWEN_BUFFER * bf)

Returns a pointer to the current position within the buffer.

◆ GWEN_Buffer_GetSize()

GWENHYWFAR_API uint32_t GWEN_Buffer_GetSize ( const GWEN_BUFFER * bf)

Returns the size of the buffer (i.e. the number of bytes allocated).

◆ GWEN_Buffer_GetStart()

GWENHYWFAR_API char * GWEN_Buffer_GetStart ( const GWEN_BUFFER * bf)

Returns the start of the buffer. You can use the function GWEN_Buffer_GetPos to navigate within the buffer.

◆ GWEN_Buffer_GetStep()

GWENHYWFAR_API uint32_t GWEN_Buffer_GetStep ( GWEN_BUFFER * bf)

In dynamic mode, whenever there is new data to allocate then this value specifies how much data to allocate in addition. The allocated data in total for this buffer will be aligned to this value.

◆ GWEN_Buffer_GetUsedBytes()

GWENHYWFAR_API uint32_t GWEN_Buffer_GetUsedBytes ( const GWEN_BUFFER * bf)

◆ GWEN_Buffer_IncrementPos()

GWENHYWFAR_API int GWEN_Buffer_IncrementPos ( GWEN_BUFFER * bf,
uint32_t i )

Move the position pointer forward by the given number i.

◆ GWEN_Buffer_InsertBuffer()

GWENHYWFAR_API int GWEN_Buffer_InsertBuffer ( GWEN_BUFFER * bf,
GWEN_BUFFER * sf )

Insert the content of the buffer sf into the buffer bf at the position of its current position pointer. The size of bf will be increased accordingly. Returns zero on success or nonzero if this failed (e.g. because of out of memory error).

◆ GWEN_Buffer_InsertByte()

GWENHYWFAR_API int GWEN_Buffer_InsertByte ( GWEN_BUFFER * bf,
char c )

Inserts a byte at the current position. If the current position is 0 and there is reserved space at the beginning of the buffer then that space will be used. Otherwise the data at the current position will be moved out of the way and the new byte inserted. The position pointer will not be altered, but after calling this function at that position there is the begin of the newly inserted byte. All pointers obtained from this module (e.g. via GWEN_Buffer_GetStart) become invalid ! This function updates the bookmarks accordingly.

◆ GWEN_Buffer_InsertBytes()

GWENHYWFAR_API int GWEN_Buffer_InsertBytes ( GWEN_BUFFER * bf,
const char * buffer,
uint32_t size )

Inserts multiple bytes at the current position. If the current position is 0 and there is reserved space at the beginning of the buffer then that space will be used. Otherwise the data at the current position will be moved out of the way and the new bytes inserted. The position pointer will not be altered, but all pointers obtained from this module (e.g. via GWEN_Buffer_GetStart) become invalid !

◆ GWEN_Buffer_InsertRoom()

GWENHYWFAR_API int GWEN_Buffer_InsertRoom ( GWEN_BUFFER * bf,
uint32_t size )

This function makes room for the given number of bytes at the current buffer position. It moves any existing data at the current position out of the way. The position pointer will not be altered, but after calling this function at that position there is the begin of the newly inserted room. All pointers obtained from this module (e.g. via GWEN_Buffer_GetStart) become invalid ! This function updates the bookmarks accordingly.

◆ GWEN_Buffer_InsertString()

GWENHYWFAR_API int GWEN_Buffer_InsertString ( GWEN_BUFFER * bf,
const char * buffer )

Inserts the given string at the current position (without the trailing null byte) The position pointer will not be altered, but after calling this function at that position there is the begin of the newly inserted string. All pointers obtained from this module (e.g. via GWEN_Buffer_GetStart) become invalid ! This function updates the bookmarks accordingly.

◆ GWEN_Buffer_KeepTextBetweenStrings()

GWENHYWFAR_API int GWEN_Buffer_KeepTextBetweenStrings ( GWEN_BUFFER * bf,
const char * openingString,
const char * closingString,
int onlyBetween )

Look for the openingString and the closingString in the buffer, if they exist remove all outside those strings, in some cases including the opening/closing string.

Returns
0 if okay, error code otherwise
Parameters
bfbuffer to operate on
openingStringstring which starts the area you are interested in
closingStringstring which ends the area you are interested in
onlyBetweenif !=0 the opening/closing string are also removed from the buffer

◆ GWEN_Buffer_new()

GWENHYWFAR_API GWEN_BUFFER * GWEN_Buffer_new ( char * buffer,
uint32_t size,
uint32_t used,
int take_ownership )

Creates a new GWEN_BUFFER, which is a dynamically resizeable text buffer.

Parameters
bufferIf non-NULL, then this buffer will be used as actual storage space. Otherwise a new buffer will be allocated (with size bytes)
sizeIf buffer was non-NULL, then this argument must specifiy the size of that buffer. If buffer was NULL, then this argument specifies the number of bytes that will be allocated.
usedNumber of bytes of the buffer actually used. This is interesting when reading from a buffer.
take_ownershipIf buffer was non-NULL and this argument is nonzero, then the new GWEN_BUFFER object takes over the ownership of the given buffer so that it will be freed on GWEN_Buffer_free(). If this argument is zero, the given buffer will not be freed. If buffer was NULL, this argument has no effect.

◆ GWEN_Buffer_OverwriteContent()

GWENHYWFAR_API void GWEN_Buffer_OverwriteContent ( GWEN_BUFFER * bf,
int c )

◆ GWEN_Buffer_PeekByte()

GWENHYWFAR_API int GWEN_Buffer_PeekByte ( GWEN_BUFFER * bf)

Returns the byte from the current position without changing the position pointer. So multiple calls to this function will result in returning the same character.

Returns
-1 on error, read char otherwise (in low byte)

◆ GWEN_Buffer_ReadByte()

GWENHYWFAR_API int GWEN_Buffer_ReadByte ( GWEN_BUFFER * bf)

Returns the byte from the current position. The position pointer is adjusted accordingly.

Returns
-1 on error, read char otherwise (in low byte)

◆ GWEN_Buffer_ReadBytes()

GWENHYWFAR_API int GWEN_Buffer_ReadBytes ( GWEN_BUFFER * bf,
char * buffer,
uint32_t * size )

Returns the bytes from the current position. The position pointer is adjusted accordingly.

Returns
-1 on error, 0 if ok

◆ GWEN_Buffer_Relinquish()

GWENHYWFAR_API int GWEN_Buffer_Relinquish ( GWEN_BUFFER * bf)

This function relinquishes ownership of the internal buffer if possible. It returns an error if this object does not own the buffer (it can't give you what it doesn't possess) or if the internal pointer to the memory allocated does not match the internal pointer to the current start of the buffer (this can be the case when GWEN_Buffer_ReserveBytes() of GWEN_Buffer_Crop() have been called).

◆ GWEN_Buffer_RemoveRoom()

GWENHYWFAR_API int GWEN_Buffer_RemoveRoom ( GWEN_BUFFER * bf,
uint32_t size )

This function removes the given number of bytes at the current buffer position. It moves any existing bytes behind the area to be removed to the current position. The position pointer will not be altered, but after calling this function at that position there is the begin of the data behind the removed area. All pointers obtained from this module (e.g. via GWEN_Buffer_GetStart) become invalid ! This function updates the bookmarks accordingly.

◆ GWEN_Buffer_ReplaceBytes()

GWENHYWFAR_API int GWEN_Buffer_ReplaceBytes ( GWEN_BUFFER * bf,
uint32_t rsize,
const char * buffer,
uint32_t size )

This function remplaces the given number of bytes at the current buffer position with some new bytes. If the number of bytes to be replaced does not equal the number of replacement bytes then the buffer is resized accordingly (e.g. shrunk or extended). The position pointer will not be altered. All pointers obtained from this module (e.g. via GWEN_Buffer_GetStart) become invalid ! This function updates the bookmarks accordingly.

◆ GWEN_Buffer_ReserveBytes()

GWENHYWFAR_API int GWEN_Buffer_ReserveBytes ( GWEN_BUFFER * bf,
uint32_t res )

Reserves the given amount of bytes at the beginning of the buffer. Please note that this most likely results in a shift of the current position inside the buffer, so after this call all pointers obtained from this module (e.g. via GWEN_Buffer_GetStart) are invalid ! You can use this function to save some memory copy actions when inserting bytes at the beginning of the buffer.

◆ GWEN_Buffer_Reset()

GWENHYWFAR_API void GWEN_Buffer_Reset ( GWEN_BUFFER * bf)

Resets the position pointer and the byte counter.

◆ GWEN_Buffer_Rewind()

GWENHYWFAR_API void GWEN_Buffer_Rewind ( GWEN_BUFFER * bf)

Resets the pos pointer

◆ GWEN_Buffer_SetBookmark()

GWENHYWFAR_API void GWEN_Buffer_SetBookmark ( GWEN_BUFFER * bf,
unsigned int idx,
uint32_t v )

Set a bookmark. These bookmarks are not used by the GWEN_BUFFER functions, but may be usefull for an application.

◆ GWEN_Buffer_SetHardLimit()

GWENHYWFAR_API void GWEN_Buffer_SetHardLimit ( GWEN_BUFFER * bf,
uint32_t l )

Changes the hard limit. This is the maximum size of a GWEN_BUFFER in dynamic mode.

◆ GWEN_Buffer_SetMode()

GWENHYWFAR_API void GWEN_Buffer_SetMode ( GWEN_BUFFER * bf,
uint32_t mode )

Changes the current mode of the buffer (such as GWEN_BUFFER_MODE_DYNAMIC).

◆ GWEN_Buffer_SetPos()

GWENHYWFAR_API int GWEN_Buffer_SetPos ( GWEN_BUFFER * bf,
uint32_t i )
Returns
0 if ok, !=0 on error

◆ GWEN_Buffer_SetStep()

GWENHYWFAR_API void GWEN_Buffer_SetStep ( GWEN_BUFFER * bf,
uint32_t step )

In dynamic mode, whenever there is new data to allocate then this value specifies how much data to allocate in addition. The allocated data in total for this buffer will be aligned to this value. 1024 is a reasonable value. This value NEEDS to be aligned 2^n (i.e. only ONE bit must be set !)

◆ GWEN_Buffer_SubMode()

GWENHYWFAR_API void GWEN_Buffer_SubMode ( GWEN_BUFFER * bf,
uint32_t mode )

Removes the give mode from the current mode of the buffer (such as GWEN_BUFFER_MODE_DYNAMIC).

◆ GWEN_FORMAT()

GWENHYWFAR_API GWEN_FORMAT ( printf ,
2 ,
3  )

Append strings to buffer with a sprintf()-like argument list.

Returns
0 if okay, error code otherwise
Parameters
bfbuffer to append data to
fmtformat string like that for sprintf().

Variable Documentation

◆ fmt

GWENHYWFAR_API const char* fmt

Definition at line 283 of file buffer.h.