Synesis Software

H:/freelibs/cstring/current/src/cstring.c File Reference


Detailed Description

The implementation of the cstring API.

#include <cstring/cstring.h>
#include <assert.h>
#include <stdlib.h>
#include <string.h>

Defines

#define CSTRING_ALLOC_GRANULARITY   (8)
#define CSTRING_OFFSET_SIZE   (16)
#define cstring_assert(expr)   assert(expr)

Functions

CSTRING_EXTERN_C CSTRING_RC cstring_apiInit (void)
CSTRING_EXTERN_C void cstring_apiUninit (void)
CSTRING_EXTERN_C char const * cstring_error (CSTRING_RC rc)
 Returns a non-NULL nul-terminated character string describing the given error code.
CSTRING_EXTERN_C CSTRING_RC cstring_init (struct cstring_t *pcs)
 Initialises a cstring instance to a default form.
CSTRING_EXTERN_C CSTRING_RC cstring_create (struct cstring_t *pcs, char const *s)
 Creates a cstring instance from a C-style string.
CSTRING_EXTERN_C CSTRING_RC cstring_createLen (struct cstring_t *pcs, char const *s, size_t len)
 Creates a cstring instance from a fixed number of characters.
CSTRING_EXTERN_C CSTRING_RC cstring_createEx (struct cstring_t *pcs, char const *s, cstring_flags_t flags, void *arena, size_t capacity)
 Creates a cstring instance with special characteristics from a C-style string.
CSTRING_EXTERN_C CSTRING_RC cstring_createLenEx (struct cstring_t *pcs, char const *s, size_t len, cstring_flags_t flags, void *arena, size_t capacity)
 Creates a cstring instance with special characteristics from a fixed number of characters.
CSTRING_EXTERN_C CSTRING_RC cstring_createLenFn (struct cstring_t *pcs, char const *s, size_t len, cstring_flags_t flags, void *arena, size_t capacity, cstring_allocFailHandler pfnAllocFailHandler, void *param)
 This is an experimental feature.
CSTRING_EXTERN_C CSTRING_RC cstring_destroy (struct cstring_t *pcs)
 Releases resources and resets the attributes of the cstring instance.
CSTRING_EXTERN_C CSTRING_RC cstring_yield (struct cstring_t *pcs, char **ppBuff)
CSTRING_EXTERN_C CSTRING_RC cstring_yield2 (struct cstring_t *pcs, char **pPayload, void **pRaw)
 Removes the allocated buffer from the cstring instance into a caller supplied pointer.
CSTRING_EXTERN_C CSTRING_RC cstring_setCapacity (struct cstring_t *pcs, size_t capacity)
 Sets the capacity of the cstring instance.
CSTRING_EXTERN_C CSTRING_RC cstring_setCapacityFn (struct cstring_t *pcs, size_t capacity, cstring_allocFailHandler pfnAllocFailHandler, void *param)
 This is an experimental feature.
CSTRING_EXTERN_C CSTRING_RC cstring_assign (struct cstring_t *pcs, char const *s)
 Assigns a C-style string to the cstring instance.
CSTRING_EXTERN_C CSTRING_RC cstring_assignFn (struct cstring_t *pcs, char const *s, cstring_allocFailHandler pfnAllocFailHandler, void *param)
 This is an experimental feature.
CSTRING_EXTERN_C CSTRING_RC cstring_assignLen (struct cstring_t *pcs, char const *s, size_t len)
 Assigns a fixed number of characters to the cstring instance.
CSTRING_EXTERN_C CSTRING_RC cstring_assignLenFn (struct cstring_t *pcs, char const *s, size_t len, cstring_allocFailHandler pfnAllocFailHandler, void *param)
 This is an experimental feature.
CSTRING_EXTERN_C CSTRING_RC cstring_copy (struct cstring_t *pcs, struct cstring_t const *pcsSrc)
 Copies the contents of one cstring instance to another.
CSTRING_EXTERN_C CSTRING_RC cstring_append (struct cstring_t *pcs, char const *s)
 Appends a C-style string to the cstring instance.
CSTRING_EXTERN_C CSTRING_RC cstring_appendFn (struct cstring_t *pcs, char const *s, cstring_allocFailHandler pfnAllocFailHandler, void *param)
 This is an experimental feature.
CSTRING_EXTERN_C CSTRING_RC cstring_appendLen (struct cstring_t *pcs, char const *s, size_t len)
 Appends a fixed number of characters to the cstring instance.
CSTRING_EXTERN_C CSTRING_RC cstring_appendLenFn (struct cstring_t *pcs, char const *s, size_t len, cstring_allocFailHandler pfnAllocFailHandler, void *param)
 This is an experimental feature.
CSTRING_EXTERN_C CSTRING_RC cstring_truncate (struct cstring_t *pcs, size_t len)
 Truncates the cstring instance.
CSTRING_EXTERN_C CSTRING_RC cstring_swap (struct cstring_t *pcs1, struct cstring_t *pcs2)
 Swaps the contents of the two cstring instances.


Define Documentation

#define CSTRING_ALLOC_GRANULARITY   (8)
 

#define cstring_assert expr   )     assert(expr)
 

#define CSTRING_OFFSET_SIZE   (16)
 


Function Documentation

CSTRING_EXTERN_C CSTRING_RC cstring_apiInit void   ) 
 

CSTRING_EXTERN_C void cstring_apiUninit void   ) 
 

CSTRING_EXTERN_C CSTRING_RC cstring_appendFn struct cstring_t pcs,
char const *  s,
cstring_allocFailHandler  pfnAllocFailHandler,
void *  param
 

This is an experimental feature.

CSTRING_EXTERN_C CSTRING_RC cstring_appendLenFn struct cstring_t pcs,
char const *  s,
size_t  len,
cstring_allocFailHandler  pfnAllocFailHandler,
void *  param
 

This is an experimental feature.

CSTRING_EXTERN_C CSTRING_RC cstring_assignFn struct cstring_t pcs,
char const *  s,
cstring_allocFailHandler  pfnAllocFailHandler,
void *  param
 

This is an experimental feature.

CSTRING_EXTERN_C CSTRING_RC cstring_assignLenFn struct cstring_t pcs,
char const *  s,
size_t  len,
cstring_allocFailHandler  pfnAllocFailHandler,
void *  param
 

This is an experimental feature.

CSTRING_EXTERN_C CSTRING_RC cstring_createLenFn struct cstring_t pcs,
char const *  s,
size_t  len,
cstring_flags_t  flags,
void *  arena,
size_t  capacity,
cstring_allocFailHandler  pfnAllocFailHandler,
void *  param
 

This is an experimental feature.

CSTRING_EXTERN_C CSTRING_RC cstring_setCapacityFn struct cstring_t pcs,
size_t  capacity,
cstring_allocFailHandler  pfnAllocFailHandler,
void *  param
 

This is an experimental feature.

CSTRING_EXTERN_C CSTRING_RC cstring_yield struct cstring_t pcs,
char **  ppBuff
 

Deprecated:

cstring Library documentation © Matthew Wilson and Synesis Software Pty Ltd, 1994-2005