Libecoli 0.5.0
Extensible COmmand LIne library
Loading...
Searching...
No Matches
ecoli_strvec.h
1/* SPDX-License-Identifier: BSD-3-Clause
2 * Copyright 2016, Olivier MATZ <zer0@droids-corp.org>
3 */
4
15
16#ifndef ECOLI_STRVEC_
17#define ECOLI_STRVEC_
18
19#include <stdio.h>
20
22struct ec_strvec;
23
30struct ec_strvec *ec_strvec(void);
31
41#define EC_STRVEC(args...) ({ \
42 const char *_arr[] = {args}; \
43 ec_strvec_from_array(_arr, EC_COUNT_OF(_arr)); \
44 })
45
58struct ec_strvec *ec_strvec_from_array(const char * const *strarr,
59 size_t n);
60
76
91struct ec_strvec *ec_strvec_sh_lex_str(const char *str, ec_strvec_flag_t flags,
92 char *unclosed_quote);
93
106int ec_strvec_set(struct ec_strvec *strvec, size_t idx, const char *s);
107
118int ec_strvec_add(struct ec_strvec *strvec, const char *s);
119
128int ec_strvec_del_last(struct ec_strvec *strvec);
129
140struct ec_strvec *ec_strvec_dup(const struct ec_strvec *strvec);
141
156struct ec_strvec *ec_strvec_ndup(const struct ec_strvec *strvec,
157 size_t off, size_t len);
158
165void ec_strvec_free(struct ec_strvec *strvec);
166
175size_t ec_strvec_len(const struct ec_strvec *strvec);
176
188const char *ec_strvec_val(const struct ec_strvec *strvec, size_t idx);
189
201const struct ec_dict *ec_strvec_get_attrs(const struct ec_strvec *strvec,
202 size_t idx);
203
217int ec_strvec_set_attrs(struct ec_strvec *strvec, size_t idx,
218 struct ec_dict *attrs);
219
230int ec_strvec_cmp(const struct ec_strvec *strvec1,
231 const struct ec_strvec *strvec2);
232
243void ec_strvec_sort(struct ec_strvec *strvec,
244 int (*str_cmp)(const char *s1, const char *s2));
245
254void ec_strvec_dump(FILE *out, const struct ec_strvec *strvec);
255
256#endif
257
struct ec_dict * ec_dict(void)
int ec_strvec_set(struct ec_strvec *strvec, size_t idx, const char *s)
int ec_strvec_cmp(const struct ec_strvec *strvec1, const struct ec_strvec *strvec2)
struct ec_strvec * ec_strvec_from_array(const char *const *strarr, size_t n)
struct ec_strvec * ec_strvec_sh_lex_str(const char *str, ec_strvec_flag_t flags, char *unclosed_quote)
struct ec_strvec * ec_strvec_ndup(const struct ec_strvec *strvec, size_t off, size_t len)
void ec_strvec_free(struct ec_strvec *strvec)
int ec_strvec_set_attrs(struct ec_strvec *strvec, size_t idx, struct ec_dict *attrs)
const char * ec_strvec_val(const struct ec_strvec *strvec, size_t idx)
void ec_strvec_sort(struct ec_strvec *strvec, int(*str_cmp)(const char *s1, const char *s2))
int ec_strvec_del_last(struct ec_strvec *strvec)
void ec_strvec_dump(FILE *out, const struct ec_strvec *strvec)
ec_strvec_flag_t
struct ec_strvec * ec_strvec(void)
int ec_strvec_add(struct ec_strvec *strvec, const char *s)
const struct ec_dict * ec_strvec_get_attrs(const struct ec_strvec *strvec, size_t idx)
struct ec_strvec * ec_strvec_dup(const struct ec_strvec *strvec)
size_t ec_strvec_len(const struct ec_strvec *strvec)
@ EC_STRVEC_STRICT
@ EC_STRVEC_TRAILSP