libtools
Functions
String routines

Functionality for creating SQL queries, making strong passwords, trimming a string if there are any space characters, parsing string as URL. More...

Collaboration diagram for String routines:

Functions

char * mkpasswd (char *s, size_t size)
 make strong password More...
 
int re_strcmp (const char *s, const char *mask)
 compare string with regular expression mask More...
 
char * str_cat (char **dest, const char *src)
 Concatenate dynamically allocated string with constant string. More...
 
char * str_ncat (char **dest, const char *src, size_t n)
 Similar to str_cat() except it will use at most n bytes from src. More...
 
char * str_replace (const char *search, const char *replace, const char *subject)
 Replace all occurrences of the search string with the replacement string. More...
 
size_t strlcpy (char *dst, const char *src, size_t size)
 Size-bounded string copying. More...
 
size_t strlcat (char *dst, const char *src, size_t size)
 Size-bounded string concatenation. More...
 
void trim (char *s)
 trim string More...
 
void ltrim (char *s)
 trim string from left More...
 
void rtrim (char *s)
 trim string from right More...
 

Detailed Description

Functionality for creating SQL queries, making strong passwords, trimming a string if there are any space characters, parsing string as URL.

Function Documentation

void ltrim ( char *  s)

trim string from left

Parameters
[in,out]spointer to string
char* mkpasswd ( char *  s,
size_t  size 
)

make strong password

Parameters
[out]sNULL-terminated string with password
[in]sizebuffer size at pointer s
Returns
pointer to s or NULL, if failed

This function use random(), so before using you should initialize random seed by some value, for example by this call srandom(time(NULL))

int re_strcmp ( const char *  s,
const char *  mask 
)

compare string with regular expression mask

Parameters
[in]sstring
[in]maskregular expression mask
Returns
zero if string is matched
void rtrim ( char *  s)

trim string from right

Parameters
[in,out]spointer to string
char* str_cat ( char **  dest,
const char *  src 
)

Concatenate dynamically allocated string with constant string.

Parameters
[in,out]destpointer to pointer of dynamically allocated string
[in]srcpointer to constant string
Returns
pointer to concatenated string
Return values
NULLerror occurred
Remarks
dest can point to NULL value
src can be NULL
char* str_ncat ( char **  dest,
const char *  src,
size_t  n 
)

Similar to str_cat() except it will use at most n bytes from src.

Parameters
[in,out]destpointer to pointer of dynamically allocated string
[in]srcpointer to constant string
[in]nlimit constant string length
Returns
pointer to concatenated string
Return values
NULLerror occurred
Remarks
dest can point to NULL value
src can be NULL
char* str_replace ( const char *  search,
const char *  replace,
const char *  subject 
)

Replace all occurrences of the search string with the replacement string.

Parameters
[in]searchvalue being searched for
[in]replacereplacement value that replaces found search values
[in]subjectstring being searched and replaced on
Returns
pointer to allocated string
Return values
NULLerror occurred
size_t strlcat ( char *  dst,
const char *  src,
size_t  size 
)

Size-bounded string concatenation.

Parameters
[in]dststring to be appended to
[in]srcstring to append to it
[in]sizesize of the destination buffer
Returns
total length of the string tried to create
size_t strlcpy ( char *  dst,
const char *  src,
size_t  size 
)

Size-bounded string copying.

Parameters
[in]dstwhere to copy the string to
[in]srcwhere to copy the string from
[in]sizesize of the destination buffer
Returns
total length of the string tried to create
void trim ( char *  s)

trim string

Parameters
[in,out]spointer to string