| 1 |
|
| 2 |
Ü |
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
|
| 20 |
|
| 21 |
|
| 22 |
#ifndef _USUAL_STRING_H_ |
| 23 |
#define _USUAL_STRING_H_ |
| 24 |
|
| 25 |
#include <usual/cxalloc.h> |
| 26 |
|
| 27 |
#include <string.h> |
| 28 |
|
| 29 |
|
| 30 |
|
| 31 |
|
| 32 |
|
| 33 |
|
| 34 |
|
| 35 |
typedef bool (*str_cb)(void *arg, const char *s); |
| 36 |
|
| 37 |
struct StrList; |
| 38 |
|
| 39 |
struct StrList *strlist_new(CxMem *ca); |
| 40 |
|
| 41 |
void strlist_free(struct StrList *slist); |
| 42 |
|
| 43 |
bool strlist_empty(struct StrList *slist); |
| 44 |
|
| 45 |
bool strlist_append(struct StrList *slist, const char *str); |
| 46 |
|
| 47 |
bool strlist_append_ref(struct StrList *slist, char *str); |
| 48 |
|
| 49 |
bool strlist_foreach(const struct StrList *slist, str_cb cb_func, void *cb_arg); |
| 50 |
|
| 51 |
char *strlist_pop(struct StrList *slist); |
| 52 |
|
| 53 |
|
| 54 |
|
| 55 |
bool parse_word_list(const char *s, str_cb cb_func, void *cb_arg); |
| 56 |
|
| 57 |
#ifndef HAVE_STRNLEN |
| 58 |
#undef strnlen |
| 59 |
#define strnlen(a,b) usual_strnlen(a,b) |
| 60 |
|
| 61 |
size_t strnlen(const char *string, size_t maxlen); |
| 62 |
#endif |
| 63 |
|
| 64 |
#ifndef HAVE_STRLCPY |
| 65 |
#undef strlcpy |
| 66 |
#define strlcpy(a,b,c) usual_strlcpy(a,b,c) |
| 67 |
|
| 68 |
size_t strlcpy(char *dst, const char *src, size_t n); |
| 69 |
#endif |
| 70 |
|
| 71 |
#ifndef HAVE_STRLCAT |
| 72 |
#undef strlcat |
| 73 |
#define strlcat(a,b,c) usual_strlcat(a,b,c) |
| 74 |
|
| 75 |
size_t strlcat(char *dst, const char *src, size_t n); |
| 76 |
#endif |
| 77 |
|
| 78 |
#undef strpcpy |
| 79 |
#define strpcpy(a,b,c) usual_strpcpy(a,b,c) |
| 80 |
|
| 81 |
|
| 82 |
|
| 83 |
|
| 84 |
|
| 85 |
|
| 86 |
|
| 87 |
|
| 88 |
char *strpcpy(char *dst, const char *src, size_t dstlen); |
| 89 |
|
| 90 |
#undef strpcat |
| 91 |
#define strpcat(a,b,c) usual_strpcat(a,b,c) |
| 92 |
|
| 93 |
|
| 94 |
|
| 95 |
|
| 96 |
|
| 97 |
|
| 98 |
|
| 99 |
|
| 100 |
char *strpcat(char *dst, const char *src, size_t dstlen); |
| 101 |
|
| 102 |
|
| 103 |
#ifndef HAVE_MEMRCHR |
| 104 |
#undef memrchr |
| 105 |
#define memrchr(a,b,c) usual_memrchr(a,b,c) |
| 106 |
|
| 107 |
void *memrchr(const void *s, int c, size_t n); |
| 108 |
#endif |
| 109 |
|
| 110 |
#ifndef HAVE_MEMMEM |
| 111 |
#undef memmem |
| 112 |
#define memmem(a,b,c,d) usual_memmem(a,b,c,d) |
| 113 |
|
| 114 |
void *memmem(const void *s, size_t slen, const void *q, size_t qlen); |
| 115 |
#endif |
| 116 |
|
| 117 |
#ifndef HAVE_MEMPCPY |
| 118 |
#undef mempcpy |
| 119 |
#define mempcpy(a,b,c) usual_mempcpy(a,b,c) |
| 120 |
|
| 121 |
void *mempcpy(void *dst, const void *src, size_t len); |
| 122 |
#endif |
| 123 |
|
| 124 |
|
| 125 |
void *mempbrk(const void *data, size_t dlen, const void *find, size_t flen); |
| 126 |
|
| 127 |
|
| 128 |
size_t memcspn(const void *data, size_t dlen, const void *reject, size_t rlen); |
| 129 |
|
| 130 |
|
| 131 |
size_t memspn(const void *data, size_t dlen, const void *accept, size_t alen); |
| 132 |
|
| 133 |
#ifndef HAVE_BASENAME |
| 134 |
#undef basename |
| 135 |
#define basename(a) usual_basename(a) |
| 136 |
|
| 137 |
|
| 138 |
const char *basename(const char *path); |
| 139 |
#endif |
| 140 |
|
| 141 |
#ifndef HAVE_DIRNAME |
| 142 |
#undef dirname |
| 143 |
#define dirname(a) usual_dirname(a) |
| 144 |
|
| 145 |
|
| 146 |
const char *dirname(const char *path); |
| 147 |
#endif |
| 148 |
|
| 149 |
#ifndef HAVE_EXPLICIT_BZERO |
| 150 |
#undef explicit_bzero |
| 151 |
#define explicit_bzero(a,b) usual_explicit_bzero(a,b) |
| 152 |
|
| 153 |
void explicit_bzero(void *buf, size_t len); |
| 154 |
#endif |
| 155 |
|
| 156 |
|
| 157 |
|
| 158 |
|
| 159 |
|
| 160 |
#ifdef WIN32 |
| 161 |
const char *win32_strerror(int e); |
| 162 |
|
| 163 |
#define strerror(x) win32_strerror(x) |
| 164 |
#endif |
| 165 |
|
| 166 |
const char *usual_strerror_r(int e, char *dst, size_t dstlen); |
| 167 |
|
| 168 |
#define strerror_r(a,b,c) usual_strerror_r(a,b,c) |
| 169 |
|
| 170 |
|
| 171 |
double strtod_dot(const char *s, char **tokend); |
| 172 |
|
| 173 |
|
| 174 |
ssize_t dtostr_dot(char *buf, size_t buflen, double val); |
| 175 |
|
| 176 |
#ifndef HAVE_STRTONUM |
| 177 |
#undef strtonum |
| 178 |
#define strtonum(a,b,c,d) usual_strtonum(a,b,c,d) |
| 179 |
|
| 180 |
|
| 181 |
|
| 182 |
|
| 183 |
|
| 184 |
|
| 185 |
|
| 186 |
|
| 187 |
|
| 188 |
|
| 189 |
|
| 190 |
long long strtonum(const char *s, long long minval, long long maxval, const char **errstr_p); |
| 191 |
#endif |
| 192 |
|
| 193 |
#ifndef HAVE_STRSEP |
| 194 |
#undef strsep |
| 195 |
#define strsep(a,b) usual_strsep(a,b) |
| 196 |
|
| 197 |
|
| 198 |
|
| 199 |
|
| 200 |
|
| 201 |
|
| 202 |
char *strsep(char **stringp, const char *delim); |
| 203 |
#endif |
| 204 |
|
| 205 |
#ifndef HAVE_ASPRINTF |
| 206 |
#undef asprintf |
| 207 |
#define asprintf(dst_p, fmt, ...) usual_asprintf(dst_p, fmt, __VA_ARGS__) |
| 208 |
int asprintf(char **dst_p, const char *fmt, ...) _PRINTF(2, 3); |
| 209 |
#endif |
| 210 |
|
| 211 |
#ifndef HAVE_VASPRINTF |
| 212 |
#undef vasprintf |
| 213 |
#define vasprintf(dst_p, fmt, ap) usual_vasprintf(dst_p, fmt, ap) |
| 214 |
int vasprintf(char **dst_p, const char *fmt, va_list ap) _PRINTF(2, 0); |
| 215 |
#endif |
| 216 |
|
| 217 |
#endif |