1 /* SPDX-License-Identifier: BSD-3-Clause
2 * Copyright 2016, Olivier MATZ <zer0@droids-corp.org>
12 /* count the number of identical chars at the beginning of 2 strings */
13 size_t ec_strcmp_count(const char *s1, const char *s2);
15 /* return 1 if 's' starts with 'beginning' */
16 int ec_str_startswith(const char *s, const char *beginning);
18 /* like asprintf, but use libecoli allocator */
19 int ec_asprintf(char **buf, const char *fmt, ...);
21 /* like vasprintf, but use libecoli allocator */
22 int ec_vasprintf(char **buf, const char *fmt, va_list ap);
24 /* return true if string is only composed of spaces (' ', '\n', ...) */
25 bool ec_str_is_space(const char *s);
28 * Parse a string for a signed integer.
31 * The string to parse.
33 * The base (0 means "guess").
35 * The minimum allowed value.
37 * The maximum allowed value.
39 * The pointer to the value to be set on success.
41 * On success, return 0. Else, return -1 and set errno.
43 int ec_str_parse_llint(const char *str, unsigned int base, int64_t min,
44 int64_t max, int64_t *val);
47 * Parse a string for an unsigned integer.
50 * The string to parse.
52 * The base (0 means "guess").
54 * The minimum allowed value.
56 * The maximum allowed value.
58 * The pointer to the value to be set on success.
60 * On success, return 0. Else, return -1 and set errno.
62 int ec_str_parse_ullint(const char *str, unsigned int base, uint64_t min,
63 uint64_t max, uint64_t *val);