Libecoli 0.3.0
Extensible COmmand LIne library
Loading...
Searching...
No Matches
String manipulation

Helpers for strings manipulation. More...

Functions

size_t ec_strcmp_count (const char *s1, const char *s2)
 
int ec_str_startswith (const char *s, const char *beginning)
 
int ec_asprintf (char **buf, const char *fmt,...)
 
int ec_vasprintf (char **buf, const char *fmt, va_list ap)
 
bool ec_str_is_space (const char *s)
 
int ec_str_parse_llint (const char *str, unsigned int base, int64_t min, int64_t max, int64_t *val)
 
int ec_str_parse_ullint (const char *str, unsigned int base, uint64_t min, uint64_t max, uint64_t *val)
 

Detailed Description

Helpers for strings manipulation.

Function Documentation

◆ ec_strcmp_count()

size_t ec_strcmp_count ( const char * s1,
const char * s2 )

count the number of identical chars at the beginning of 2 strings

◆ ec_str_startswith()

int ec_str_startswith ( const char * s,
const char * beginning )

return 1 if 's' starts with 'beginning'

◆ ec_asprintf()

int ec_asprintf ( char ** buf,
const char * fmt,
... )

like asprintf, but use libecoli allocator

◆ ec_vasprintf()

int ec_vasprintf ( char ** buf,
const char * fmt,
va_list ap )

like vasprintf, but use libecoli allocator

◆ ec_str_is_space()

bool ec_str_is_space ( const char * s)

return true if string is only composed of spaces (' ', '
', ...)

◆ ec_str_parse_llint()

int ec_str_parse_llint ( const char * str,
unsigned int base,
int64_t min,
int64_t max,
int64_t * val )

Parse a string for a signed integer.

Parameters
strThe string to parse.
baseThe base (0 means "guess").
minThe minimum allowed value.
maxThe maximum allowed value.
valThe pointer to the value to be set on success.
Returns
On success, return 0. Else, return -1 and set errno.

◆ ec_str_parse_ullint()

int ec_str_parse_ullint ( const char * str,
unsigned int base,
uint64_t min,
uint64_t max,
uint64_t * val )

Parse a string for an unsigned integer.

Parameters
strThe string to parse.
baseThe base (0 means "guess").
minThe minimum allowed value.
maxThe maximum allowed value.
valThe pointer to the value to be set on success.
Returns
On success, return 0. Else, return -1 and set errno.