2014-05-28 09:08:06 -04:00
|
|
|
/*
|
|
|
|
* str_array.h
|
2014-06-27 01:24:40 -04:00
|
|
|
* Copyright (C) 2014 c9s <yoanlin93@gmail.com>
|
2014-05-28 09:08:06 -04:00
|
|
|
*
|
|
|
|
* Distributed under terms of the MIT license.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef STR_ARRAY_H
|
|
|
|
#define STR_ARRAY_H
|
|
|
|
|
2016-03-21 22:23:37 -04:00
|
|
|
#include "memory.h"
|
|
|
|
|
2021-10-12 05:18:45 -04:00
|
|
|
#ifdef HAVE_STDBOOL_H
|
|
|
|
# include <stdbool.h>
|
|
|
|
#elif !defined(bool) && !defined(__cplusplus)
|
|
|
|
typedef unsigned char bool;
|
|
|
|
# define bool bool /* For redefinition guards */
|
|
|
|
# define false 0
|
|
|
|
# define true 1
|
|
|
|
#endif
|
|
|
|
|
2014-05-28 09:08:06 -04:00
|
|
|
typedef struct _str_array {
|
2016-03-21 22:23:37 -04:00
|
|
|
R3_VECTOR(r3_iovec_t) slugs;
|
|
|
|
R3_VECTOR(r3_iovec_t) tokens;
|
2014-05-28 09:08:06 -04:00
|
|
|
} str_array;
|
|
|
|
|
2018-02-20 12:18:43 -05:00
|
|
|
bool str_array_append(str_array * l, const char * token, unsigned int len);
|
2014-05-28 09:08:06 -04:00
|
|
|
|
|
|
|
void str_array_free(str_array *l);
|
|
|
|
|
2016-03-08 01:19:54 -05:00
|
|
|
void str_array_dump_slugs(const str_array *l);
|
|
|
|
|
2014-05-28 09:08:06 -04:00
|
|
|
void str_array_dump(const str_array *l);
|
|
|
|
|
2021-10-12 05:34:05 -04:00
|
|
|
#define str_array_fetch(t,i) t->tokens.entries[i]
|
|
|
|
#define str_array_len(t) t->tokens.size
|
|
|
|
#define str_array_cap(t) t->tokens.capacity
|
2014-05-28 09:08:06 -04:00
|
|
|
|
|
|
|
#endif /* !STR_ARRAY_H */
|