src/server/ucx/string.h

changeset 36
450d2d5f4735
parent 28
f387669912e8
child 51
b28cf69f42e8
equal deleted inserted replaced
35:4417619a9bbd 36:450d2d5f4735
6 */ 6 */
7 7
8 #ifndef _SSTRING_H 8 #ifndef _SSTRING_H
9 #define _SSTRING_H 9 #define _SSTRING_H
10 10
11 #include <stddef.h>
12
11 #include "mempool.h" 13 #include "mempool.h"
14 #include "../util/pool.h"
12 15
16 /* use macros for literals only */
13 #define S(s) { s, sizeof(s)-1 } 17 #define S(s) { s, sizeof(s)-1 }
14 #define ST(s) sstrn(s, sizeof(s)-1) 18 #define ST(s) sstrn(s, sizeof(s)-1)
15 19
16 #ifdef __cplusplus 20 #ifdef __cplusplus
17 extern "C" { 21 extern "C" {
64 sstr_t sstrsubs (sstr_t s, size_t start); 68 sstr_t sstrsubs (sstr_t s, size_t start);
65 69
66 /* 70 /*
67 * 71 *
68 */ 72 */
69 sstr_t sstrsubsl (sstr_t s, size_t start, size_t end); 73 sstr_t sstrsubsl (sstr_t s, size_t start, size_t length);
70 74
75 /*
76 * splits s into n parts
77 *
78 * s the string to split
79 * d the delimiter string
80 * n the maximum size of the resulting list
81 * a size of 0 indicates an unbounded list size
82 * the actual size of the list will be stored here
83 *
84 * Hint: use this value to avoid dynamic reallocation of the result list
85 *
86 * Returns a list of the split strings
87 * NOTE: this list needs to be freed manually after usage
88 *
89 * Returns NULL on error
90 */
91 sstr_t* sstrsplit(sstr_t s, sstr_t d, size_t *n);
71 92
72 int sstrcmp(sstr_t s1, sstr_t s2); 93 int sstrcmp(sstr_t s1, sstr_t s2);
73 94
74 sstr_t sstrdub(sstr_t s);
75 sstr_t sstrdup(sstr_t s); 95 sstr_t sstrdup(sstr_t s);
76 96
97 // webserver extension
77 sstr_t sstrtrim(sstr_t string); 98 sstr_t sstrtrim(sstr_t string);
78 sstr_t sstrdup_mp(UcxMempool *mp, sstr_t s); 99 sstr_t sstrdup_mp(UcxMempool *pool, sstr_t s);
100 sstr_t sstrdup_pool(pool_handle_t *pool, sstr_t s);
79 101
80 #ifdef __cplusplus 102 #ifdef __cplusplus
81 } 103 }
82 #endif 104 #endif
83 105

mercurial