Go to the documentation of this file.
25 #ifndef SPA_UTILS_STRING_H
26 #define SPA_UTILS_STRING_H
50 inline bool spa_streq(
const char *s1,
const char *s2)
52 return SPA_LIKELY(s1 && s2) ? strcmp(s1, s2) == 0 : s1 == s2;
60 inline bool spa_strneq(
const char *s1,
const char *s2,
size_t len)
62 return SPA_LIKELY(s1 && s2) ? strncmp(s1, s2, len) == 0 : s1 == s2;
78 return strncmp(s, prefix, strlen(prefix)) == 0;
98 return l1 >= l2 &&
spa_streq(s + l1 - l2, suffix);
109 inline bool spa_atoi32(
const char *str, int32_t *val,
int base)
114 if (!str || *str ==
'\0')
118 v = strtol(str, &endptr, base);
119 if (errno != 0 || *endptr !=
'\0')
137 inline bool spa_atou32(
const char *str, uint32_t *val,
int base)
140 unsigned long long v;
142 if (!str || *str ==
'\0')
146 v = strtoull(str, &endptr, base);
147 if (errno != 0 || *endptr !=
'\0')
150 if (v != (uint32_t)v)
165 inline bool spa_atoi64(
const char *str, int64_t *val,
int base)
170 if (!str || *str ==
'\0')
174 v = strtoll(str, &endptr, base);
175 if (errno != 0 || *endptr !=
'\0')
190 inline bool spa_atou64(
const char *str, uint64_t *val,
int base)
193 unsigned long long v;
195 if (!str || *str ==
'\0')
199 v = strtoull(str, &endptr, base);
200 if (errno != 0 || *endptr !=
'\0')
233 r = vsnprintf(
buffer, size, format, args);
255 va_start(args, format);
274 if (!str || *str ==
'\0')
278 v = strtof(str, &endptr);
279 if (errno != 0 || *endptr !=
'\0')
298 if (!str || *str ==
'\0')
302 v = strtod(str, &endptr);
303 if (errno != 0 || *endptr !=
'\0')
bool spa_strneq(const char *s1, const char *s2, size_t len)
Definition: string.h:60
int sm_streams_follow_default_start(struct sm_media_session *session)
Definition: streams-follow-default.c:45
#define spa_assert_se(expr)
Definition: defs.h:263
#define KEY_NAME
Definition: streams-follow-default.c:43
bool spa_streq(const char *s1, const char *s2)
Definition: string.h:50
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.
Definition: string.h:137
bool spa_strstartswith(const char *s, const char *prefix)
Definition: string.h:71
#define SPA_PRINTF_FUNC(fmt, arg1)
Definition: defs.h:205
#define SPA_LIKELY(x)
Definition: defs.h:234
bool spa_strendswith(const char *s, const char *suffix)
Definition: string.h:87
bool spa_atod(const char *str, double *val)
Convert str to a double and store the result in val.
Definition: string.h:293
int spa_scnprintf(char *buffer, size_t size, const char *format,...)
Definition: string.h:250
int spa_vscnprintf(char *buffer, size_t size, const char *format, va_list args)
Definition: string.h:227
bool spa_atof(const char *str, float *val)
Convert str to a float and store the result in val.
Definition: string.h:269
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.
Definition: string.h:109
int pw_properties_set(struct pw_properties *properties, const char *key, const char *value)
Set a property value.
Definition: properties.c:435
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.
Definition: string.h:165
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.
Definition: string.h:190
#define SPA_UNLIKELY(x)
Definition: defs.h:235
bool spa_atob(const char *str)
Convert str to a boolean.
Definition: string.h:213