Libecoli  0.11.3
Extensible COmmand LIne library
strvec.h
1 /* SPDX-License-Identifier: BSD-3-Clause
2  * Copyright 2016, Olivier MATZ <zer0@droids-corp.org>
3  */
4 
16 #pragma once
17 #include <stdio.h>
18 
20 struct ec_strvec;
21 
28 struct ec_strvec *ec_strvec(void);
29 
39 #define EC_STRVEC(args...) \
40  ({ \
41  const char *_arr[] = {args}; \
42  ec_strvec_from_array(_arr, EC_COUNT_OF(_arr)); \
43  })
57 struct ec_strvec *ec_strvec_from_array(const char *const *strarr, size_t n);
58 
62 typedef enum {
74 
80 #define EC_STRVEC_ATTR_START "start"
82 #define EC_STRVEC_ATTR_END "end"
83 
98 struct ec_strvec *
99 ec_strvec_sh_lex_str(const char *str, ec_strvec_flag_t flags, char *unclosed_quote);
100 
113 int ec_strvec_set(struct ec_strvec *strvec, size_t idx, const char *s);
114 
125 int ec_strvec_add(struct ec_strvec *strvec, const char *s);
126 
135 int ec_strvec_del_last(struct ec_strvec *strvec);
136 
147 struct ec_strvec *ec_strvec_dup(const struct ec_strvec *strvec);
148 
163 struct ec_strvec *ec_strvec_ndup(const struct ec_strvec *strvec, size_t off, size_t len);
164 
171 void ec_strvec_free(struct ec_strvec *strvec);
172 
181 size_t ec_strvec_len(const struct ec_strvec *strvec);
182 
194 const char *ec_strvec_val(const struct ec_strvec *strvec, size_t idx);
195 
207 const struct ec_dict *ec_strvec_get_attrs(const struct ec_strvec *strvec, size_t idx);
208 
222 int ec_strvec_set_attrs(struct ec_strvec *strvec, size_t idx, struct ec_dict *attrs);
223 
234 int ec_strvec_cmp(const struct ec_strvec *strvec1, const struct ec_strvec *strvec2);
235 
246 void ec_strvec_sort(struct ec_strvec *strvec, int (*str_cmp)(const char *s1, const char *s2));
247 
256 void ec_strvec_dump(FILE *out, const struct ec_strvec *strvec);
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)
const struct ec_dict * ec_strvec_get_attrs(const struct ec_strvec *strvec, size_t idx)
struct ec_strvec * ec_strvec_sh_lex_str(const char *str, ec_strvec_flag_t flags, char *unclosed_quote)
void ec_strvec_free(struct ec_strvec *strvec)
struct ec_strvec * ec_strvec_from_array(const char *const *strarr, size_t n)
int ec_strvec_set_attrs(struct ec_strvec *strvec, size_t idx, struct ec_dict *attrs)
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)
struct ec_strvec * ec_strvec(void)
void ec_strvec_dump(FILE *out, const struct ec_strvec *strvec)
ec_strvec_flag_t
Definition: strvec.h:62
int ec_strvec_add(struct ec_strvec *strvec, const char *s)
struct ec_strvec * ec_strvec_ndup(const struct ec_strvec *strvec, size_t off, size_t len)
struct ec_strvec * ec_strvec_dup(const struct ec_strvec *strvec)
size_t ec_strvec_len(const struct ec_strvec *strvec)
const char * ec_strvec_val(const struct ec_strvec *strvec, size_t idx)
@ EC_STRVEC_STRICT
Definition: strvec.h:67
@ EC_STRVEC_TRAILSP
Definition: strvec.h:72