doc
Data Structures | Macros | Typedefs | Functions | Variables
cynapses libc string functions

Data Structures

struct  c_strlist_s
 

Macros

#define c_free_locale_string(x)   (void)x
 

Typedefs

typedef struct c_strlist_s c_strlist_t
 

Functions

char * c_lowercase (const char *str)
 
int c_streq (const char *a, const char *b)
 
int c_strlist_add (c_strlist_t *strlist, const char *string)
 
void c_strlist_destroy (c_strlist_t *strlist)
 
c_strlist_tc_strlist_expand (c_strlist_t *strlist, size_t size)
 
c_strlist_tc_strlist_new (size_t size)
 
char * c_strreplace (char *src, const char *pattern, const char *repl)
 
char * c_uppercase (const char *str)
 
char * c_utf8_from_locale (const mbchar_t *str)
 
mbchar_tc_utf8_to_locale (const char *wstr)
 

Variables

size_t c_strlist_s::count
 
size_t c_strlist_s::size
 
char ** c_strlist_s::vector
 

Detailed Description

Macro Definition Documentation

◆ c_free_locale_string

#define c_free_locale_string (   x)    (void)x

Definition at line 214 of file c_string.h.

Typedef Documentation

◆ c_strlist_t

typedef struct c_strlist_s c_strlist_t

Definition at line 40 of file c_string.h.

Function Documentation

◆ c_lowercase()

char* c_lowercase ( const char *  str)

Lowercase a string.

Parameters
strThe String to lowercase.
Returns
The malloced lowered string or NULL on error.

◆ c_streq()

int c_streq ( const char *  a,
const char *  b 
)

Compare to strings if they are equal.

Parameters
aFirst string to compare.
bSecond string to compare.
Returns
1 if they are equal, 0 if not.

◆ c_strlist_add()

int c_strlist_add ( c_strlist_t strlist,
const char *  string 
)

Add a string to the stringlist.

Duplicates the string and stores it in the stringlist.

Parameters
strlistStringlist to add the string.
stringString to add.
Returns
0 on success, less than 0 and errno set if an error occured. ENOBUFS if the list is full.

◆ c_strlist_destroy()

void c_strlist_destroy ( c_strlist_t strlist)

Destroy the memory of the stringlist.

Frees the strings and the stringlist.

Parameters
strlistStringlist to destroy

◆ c_strlist_expand()

c_strlist_t* c_strlist_expand ( c_strlist_t strlist,
size_t  size 
)

Expand the stringlist.

Parameters
strlistStringlist to expand
sizeNew size of the strlinglist to expand
Returns
Pointer to the expanded stringlist. NULL if an error occured.

◆ c_strlist_new()

c_strlist_t* c_strlist_new ( size_t  size)

Create a new stringlist.

Parameters
sizeSize to allocate.
Returns
Pointer to the newly allocated stringlist. NULL if an error occured.

◆ c_strreplace()

char* c_strreplace ( char *  src,
const char *  pattern,
const char *  repl 
)

Replace a string with another string in a source string.

Parameters
srcString to search for pattern.
patternPattern to search for in the source string.
replThe string which which should replace pattern if found.
Returns
Return a pointer to the source string.

◆ c_uppercase()

char* c_uppercase ( const char *  str)

Uppercase a string.

Parameters
strThe String to uppercase.
Returns
The malloced uppered string or NULL on error.

◆ c_utf8_from_locale()

char* c_utf8_from_locale ( const mbchar_t str)

Convert a platform locale string to utf8.

This function is part of the multi platform abstraction of basic file operations to handle various platform encoding correctly.

Instead of using the standard file operations the multi platform aliases defined in c_private.h have to be used instead.

To convert path names returned by these functions to the internally used utf8 format this function has to be used. The returned string has to be freed by c_free_locale_string(). On some platforms this method allocates memory and on others not but it has never to be cared about.

Parameters
strThe multibyte encoded string to convert
Returns
The malloced converted string or NULL on error.
See also
c_free_locale_string()
c_utf8_to_locale()

◆ c_utf8_to_locale()

mbchar_t* c_utf8_to_locale ( const char *  wstr)

Convert a utf8 encoded string to platform specific locale.

This function is part of the multi platform abstraction of basic file operations to handle various platform encoding correctly.

Instead of using the standard file operations the multi platform aliases defined in c_private.h have to be used instead.

To convert path names as input for the cross platform functions from the internally used utf8 format, this function has to be used. The returned string has to be freed by c_free_locale_string(). On some platforms this method allocates memory and on others not but it has never sto be cared about.

Parameters
strThe utf8 string to convert.
Returns
The malloced converted multibyte string or NULL on error.
See also
c_free_locale_string()
c_utf8_from_locale()

Variable Documentation

◆ count

size_t c_strlist_s::count

The count of the strings saved in the vector.

Definition at line 57 of file c_string.h.

◆ size

size_t c_strlist_s::size

Size of strings allocated.

Definition at line 59 of file c_string.h.

◆ vector

char** c_strlist_s::vector

The string vector.

Definition at line 55 of file c_string.h.