PipeWire  0.3.45
String handling

String handling utilities. More...

Files

file  string.h
 spa/utils/string.h
 

Functions

static bool spa_streq (const char *s1, const char *s2)
 
static bool spa_strneq (const char *s1, const char *s2, size_t len)
 
static bool spa_strstartswith (const char *s, const char *prefix)
 
static bool spa_strendswith (const char *s, const char *suffix)
 
static bool spa_atoi32 (const char *str, int32_t *val, int base)
 Convert str to an int32_t with the given base and store the result in val. More...
 
static bool spa_atou32 (const char *str, uint32_t *val, int base)
 Convert str to an uint32_t with the given base and store the result in val. More...
 
static bool spa_atoi64 (const char *str, int64_t *val, int base)
 Convert str to an int64_t with the given base and store the result in val. More...
 
static bool spa_atou64 (const char *str, uint64_t *val, int base)
 Convert str to an uint64_t with the given base and store the result in val. More...
 
static bool spa_atob (const char *str)
 Convert str to a boolean. More...
 
static int spa_vscnprintf (char *buffer, size_t size, const char *format, va_list args)
 
static int spa_scnprintf (char *buffer, size_t size, const char *format,...)
 
static bool spa_atof (const char *str, float *val)
 Convert str to a float and store the result in val. More...
 
static bool spa_atod (const char *str, double *val)
 Convert str to a double and store the result in val. More...
 

Detailed Description

String handling utilities.

Function Documentation

◆ spa_streq()

static bool spa_streq ( const char *  s1,
const char *  s2 
)
inlinestatic
Returns
true if the two strings are equal, false otherwise

If both a and b are NULL, the two are considered equal.

Examples
bluez-session.c, spa/examples/adapter-control.c, spa/examples/example-control.c, spa/examples/local-libcamera.c, and spa/examples/local-v4l2.c.

◆ spa_strneq()

static bool spa_strneq ( const char *  s1,
const char *  s2,
size_t  len 
)
inlinestatic
Returns
true if the two strings are equal, false otherwise

If both a and b are NULL, the two are considered equal.

◆ spa_strstartswith()

static bool spa_strstartswith ( const char *  s,
const char *  prefix 
)
inlinestatic
Returns
true if s starts with the prefix or false otherwise. A s is NULL, it never starts with the given prefix. A prefix of NULL is a bug in the caller.

◆ spa_strendswith()

static bool spa_strendswith ( const char *  s,
const char *  suffix 
)
inlinestatic
Returns
true if s ends with the suffix or false otherwise. A s is NULL, it never ends with the given suffix. A suffix of NULL is a bug in the caller.

◆ spa_atoi32()

static bool spa_atoi32 ( const char *  str,
int32_t *  val,
int  base 
)
inlinestatic

Convert str to an int32_t with the given base and store the result in val.

On failure, the value of val is unmodified.

Returns
true on success, false otherwise

◆ spa_atou32()

static bool spa_atou32 ( const char *  str,
uint32_t *  val,
int  base 
)
inlinestatic

Convert str to an uint32_t with the given base and store the result in val.

On failure, the value of val is unmodified.

Returns
true on success, false otherwise

◆ spa_atoi64()

static bool spa_atoi64 ( const char *  str,
int64_t *  val,
int  base 
)
inlinestatic

Convert str to an int64_t with the given base and store the result in val.

On failure, the value of val is unmodified.

Returns
true on success, false otherwise

◆ spa_atou64()

static bool spa_atou64 ( const char *  str,
uint64_t *  val,
int  base 
)
inlinestatic

Convert str to an uint64_t with the given base and store the result in val.

On failure, the value of val is unmodified.

Returns
true on success, false otherwise

◆ spa_atob()

static bool spa_atob ( const char *  str)
inlinestatic

Convert str to a boolean.

Allowed boolean values are "true" and a literal "1", anything else is false.

Returns
true on success, false otherwise

◆ spa_vscnprintf()

static int spa_vscnprintf ( char *  buffer,
size_t  size,
const char *  format,
va_list  args 
)
inlinestatic

◆ spa_scnprintf()

static int spa_scnprintf ( char *  buffer,
size_t  size,
const char *  format,
  ... 
)
inlinestatic

◆ spa_atof()

static bool spa_atof ( const char *  str,
float *  val 
)
inlinestatic

Convert str to a float and store the result in val.

On failure, the value of val is unmodified.

Returns
true on success, false otherwise

◆ spa_atod()

static bool spa_atod ( const char *  str,
double *  val 
)
inlinestatic

Convert str to a double and store the result in val.

On failure, the value of val is unmodified.

Returns
true on success, false otherwise