1 : /* Copyright (c) 2007 James Antill -- See LICENSE file for terms. */
2 : #ifndef USTR_SC_H
3 : #define USTR_SC_H 1
4 :
5 : #ifndef USTR_MAIN_H
6 : # error " You should include ustr-main.h before this file, or just ustr.h"
7 : #endif
8 :
9 : USTR_CONF_E_PROTO
10 : struct Ustr *ustr_sc_dupx(size_t, size_t, int, int, struct Ustr **)
11 : USTR__COMPILE_ATTR_WARN_UNUSED_RET() USTR__COMPILE_ATTR_NONNULL_A();
12 : USTR_CONF_E_PROTO struct Ustr *ustr_sc_dup(struct Ustr **)
13 : USTR__COMPILE_ATTR_WARN_UNUSED_RET() USTR__COMPILE_ATTR_NONNULL_A();
14 :
15 : USTR_CONF_E_PROTO void ustr_sc_free_shared(struct Ustr **)
16 : USTR__COMPILE_ATTR_NONNULL_A();
17 : /* USTR_CONF_E_PROTO
18 : struct Ustr *ustr_sc_reconf(struct Ustr **, size_t, size_t, int, int)
19 : USTR__COMPILE_ATTR_WARN_UNUSED_RET() USTR__COMPILE_ATTR_NONNULL_L((6)); */
20 : USTR_CONF_E_PROTO int ustr_sc_reverse(struct Ustr **)
21 : USTR__COMPILE_ATTR_WARN_UNUSED_RET() USTR__COMPILE_ATTR_NONNULL_A();
22 : #ifdef USTR_UTF8_H
23 : USTR_CONF_E_PROTO
24 : int ustr_sc_utf8_reverse(struct Ustr **)
25 : USTR__COMPILE_ATTR_WARN_UNUSED_RET() USTR__COMPILE_ATTR_NONNULL_A();
26 : #endif
27 : USTR_CONF_E_PROTO int ustr_sc_tolower(struct Ustr **)
28 : USTR__COMPILE_ATTR_WARN_UNUSED_RET() USTR__COMPILE_ATTR_NONNULL_A();
29 : USTR_CONF_E_PROTO int ustr_sc_toupper(struct Ustr **)
30 : USTR__COMPILE_ATTR_WARN_UNUSED_RET() USTR__COMPILE_ATTR_NONNULL_A();
31 :
32 : USTR_CONF_E_PROTO char *ustr_sc_export_subustr(const struct Ustr*,size_t,size_t,
33 : void *(*)(size_t))
34 : USTR__COMPILE_ATTR_WARN_UNUSED_RET() USTR__COMPILE_ATTR_NONNULL_A();
35 : USTR_CONF_EI_PROTO char *ustr_sc_export(const struct Ustr *, void *(*)(size_t))
36 : USTR__COMPILE_ATTR_WARN_UNUSED_RET() USTR__COMPILE_ATTR_NONNULL_A();
37 :
38 : USTR_CONF_E_PROTO int ustr_sc_ltrim_chrs(struct Ustr **, const char *, size_t)
39 : USTR__COMPILE_ATTR_WARN_UNUSED_RET() USTR__COMPILE_ATTR_NONNULL_A();
40 : USTR_CONF_EI_PROTO int ustr_sc_ltrim(struct Ustr **, const struct Ustr *)
41 : USTR__COMPILE_ATTR_WARN_UNUSED_RET() USTR__COMPILE_ATTR_NONNULL_A();
42 : USTR_CONF_EI_PROTO int ustr_sc_ltrim_cstr(struct Ustr **, const char *)
43 : USTR__COMPILE_ATTR_WARN_UNUSED_RET() USTR__COMPILE_ATTR_NONNULL_A();
44 : USTR_CONF_E_PROTO int ustr_sc_rtrim_chrs(struct Ustr **, const char *, size_t)
45 : USTR__COMPILE_ATTR_WARN_UNUSED_RET() USTR__COMPILE_ATTR_NONNULL_A();
46 : USTR_CONF_EI_PROTO int ustr_sc_rtrim(struct Ustr **, const struct Ustr *)
47 : USTR__COMPILE_ATTR_WARN_UNUSED_RET() USTR__COMPILE_ATTR_NONNULL_A();
48 : USTR_CONF_EI_PROTO int ustr_sc_rtrim_cstr(struct Ustr **, const char *)
49 : USTR__COMPILE_ATTR_WARN_UNUSED_RET() USTR__COMPILE_ATTR_NONNULL_A();
50 : USTR_CONF_E_PROTO int ustr_sc_trim_chrs(struct Ustr **, const char *, size_t)
51 : USTR__COMPILE_ATTR_WARN_UNUSED_RET() USTR__COMPILE_ATTR_NONNULL_A();
52 : USTR_CONF_EI_PROTO int ustr_sc_trim(struct Ustr **, const struct Ustr *)
53 : USTR__COMPILE_ATTR_WARN_UNUSED_RET() USTR__COMPILE_ATTR_NONNULL_A();
54 : USTR_CONF_EI_PROTO int ustr_sc_trim_cstr(struct Ustr **, const char *)
55 : USTR__COMPILE_ATTR_WARN_UNUSED_RET() USTR__COMPILE_ATTR_NONNULL_A();
56 :
57 : USTR_CONF_E_PROTO
58 : struct Ustr *ustr_sc_vjoin(const struct Ustr *, const struct Ustr *,
59 : const struct Ustr *, va_list)
60 : USTR__COMPILE_ATTR_WARN_UNUSED_RET() USTR__COMPILE_ATTR_NONNULL_L((1, 2,3));
61 : USTR_CONF_E_PROTO
62 : struct Ustr *ustr_sc_join(const struct Ustr *, const struct Ustr *,
63 : const struct Ustr *, ...)
64 : USTR__COMPILE_ATTR_WARN_UNUSED_RET() USTR__COMPILE_ATTR_NONNULL_L((1, 2, 3))
65 : USTR__COMPILE_ATTR_SENTINEL(0);
66 : USTR_CONF_E_PROTO
67 : struct Ustr *ustr_sc_vjoinx(size_t, size_t, int, int,
68 : const struct Ustr *, const struct Ustr *,
69 : const struct Ustr *, va_list)
70 : USTR__COMPILE_ATTR_WARN_UNUSED_RET() USTR__COMPILE_ATTR_NONNULL_L((5, 6,7));
71 : USTR_CONF_E_PROTO
72 : struct Ustr *ustr_sc_joinx(size_t, size_t, int, int,
73 : const struct Ustr *, const struct Ustr *,
74 : const struct Ustr *, ...)
75 : USTR__COMPILE_ATTR_WARN_UNUSED_RET() USTR__COMPILE_ATTR_NONNULL_L((5, 6, 7))
76 : USTR__COMPILE_ATTR_SENTINEL(0);
77 :
78 : USTR_CONF_E_PROTO
79 : struct Ustr *ustr_sc_vconcat(const struct Ustr *, va_list)
80 : USTR__COMPILE_ATTR_WARN_UNUSED_RET() USTR__COMPILE_ATTR_NONNULL_L((1));
81 : USTR_CONF_E_PROTO
82 : struct Ustr *ustr_sc_concat(const struct Ustr *, ...)
83 : USTR__COMPILE_ATTR_WARN_UNUSED_RET() USTR__COMPILE_ATTR_NONNULL_L((1))
84 : USTR__COMPILE_ATTR_SENTINEL(0);
85 : USTR_CONF_E_PROTO
86 : struct Ustr *ustr_sc_vconcatx(size_t, size_t, int, int,
87 : const struct Ustr *, va_list)
88 : USTR__COMPILE_ATTR_WARN_UNUSED_RET() USTR__COMPILE_ATTR_NONNULL_L((5));
89 : USTR_CONF_E_PROTO
90 : struct Ustr *ustr_sc_concatx(size_t, size_t, int, int, const struct Ustr *, ...)
91 : USTR__COMPILE_ATTR_WARN_UNUSED_RET() USTR__COMPILE_ATTR_NONNULL_L((5))
92 : USTR__COMPILE_ATTR_SENTINEL(0);
93 :
94 : USTR_CONF_E_PROTO
95 : struct Ustrp *ustrp_sc_dupx(struct Ustr_pool *, size_t, size_t, int, int,
96 : struct Ustrp **)
97 : USTR__COMPILE_ATTR_WARN_UNUSED_RET() USTR__COMPILE_ATTR_NONNULL_L((6));
98 : USTR_CONF_E_PROTO struct Ustrp *ustrp_sc_dup(struct Ustr_pool *,struct Ustrp **)
99 : USTR__COMPILE_ATTR_WARN_UNUSED_RET() USTR__COMPILE_ATTR_NONNULL_L((2));
100 :
101 : USTR_CONF_E_PROTO void ustrp_sc_free_shared(struct Ustr_pool *, struct Ustrp **)
102 : USTR__COMPILE_ATTR_NONNULL_L((2));
103 : /* USTR_CONF_E_PROTO
104 : struct Ustrp *ustrp_sc_reconf(struct Ustr_pool *, struct Ustrp **,
105 : size_t, size_t, int, int)
106 : USTR__COMPILE_ATTR_WARN_UNUSED_RET() USTR__COMPILE_ATTR_NONNULL_L((6)); */
107 : USTR_CONF_E_PROTO int ustrp_sc_reverse(struct Ustr_pool *, struct Ustrp **)
108 : USTR__COMPILE_ATTR_WARN_UNUSED_RET() USTR__COMPILE_ATTR_NONNULL_A();
109 : #ifdef USTR_UTF8_H
110 : USTR_CONF_E_PROTO
111 : int ustrp_sc_utf8_reverse(struct Ustr_pool *, struct Ustrp **)
112 : USTR__COMPILE_ATTR_WARN_UNUSED_RET() USTR__COMPILE_ATTR_NONNULL_L((2));
113 : #endif
114 : USTR_CONF_E_PROTO int ustrp_sc_tolower(struct Ustr_pool *, struct Ustrp **)
115 : USTR__COMPILE_ATTR_WARN_UNUSED_RET() USTR__COMPILE_ATTR_NONNULL_A();
116 : USTR_CONF_E_PROTO int ustrp_sc_toupper(struct Ustr_pool *, struct Ustrp **)
117 : USTR__COMPILE_ATTR_WARN_UNUSED_RET() USTR__COMPILE_ATTR_NONNULL_A();
118 :
119 : USTR_CONF_E_PROTO
120 : char *ustrp_sc_export_subustrp(struct Ustr_pool *, const struct Ustrp *,
121 : size_t, size_t, void *(*)(size_t))
122 : USTR__COMPILE_ATTR_WARN_UNUSED_RET() USTR__COMPILE_ATTR_NONNULL_L((2));
123 : USTR_CONF_EI_PROTO
124 : char *ustrp_sc_export(struct Ustr_pool *p,const struct Ustrp*,void *(*)(size_t))
125 : USTR__COMPILE_ATTR_WARN_UNUSED_RET() USTR__COMPILE_ATTR_NONNULL_L((2));
126 :
127 : USTR_CONF_E_PROTO
128 : int ustrp_sc_ltrim_chrs(struct Ustr_pool *, struct Ustrp **,const char*,size_t)
129 : USTR__COMPILE_ATTR_WARN_UNUSED_RET() USTR__COMPILE_ATTR_NONNULL_L((2, 3));
130 : USTR_CONF_EI_PROTO int ustrp_sc_ltrim(struct Ustr_pool *, struct Ustrp **,
131 : const struct Ustrp *)
132 : USTR__COMPILE_ATTR_WARN_UNUSED_RET() USTR__COMPILE_ATTR_NONNULL_L((2, 3));
133 : USTR_CONF_EI_PROTO
134 : int ustrp_sc_ltrim_cstr(struct Ustr_pool *p, struct Ustrp **, const char *)
135 : USTR__COMPILE_ATTR_WARN_UNUSED_RET() USTR__COMPILE_ATTR_NONNULL_L((2, 3));
136 : USTR_CONF_E_PROTO
137 : int ustrp_sc_rtrim_chrs(struct Ustr_pool *, struct Ustrp **,const char*,size_t)
138 : USTR__COMPILE_ATTR_WARN_UNUSED_RET() USTR__COMPILE_ATTR_NONNULL_L((2, 3));
139 : USTR_CONF_EI_PROTO int ustrp_sc_rtrim(struct Ustr_pool *, struct Ustrp **,
140 : const struct Ustrp *)
141 : USTR__COMPILE_ATTR_WARN_UNUSED_RET() USTR__COMPILE_ATTR_NONNULL_L((2, 3));
142 : USTR_CONF_EI_PROTO
143 : int ustrp_sc_rtrim_cstr(struct Ustr_pool *p, struct Ustrp **, const char *)
144 : USTR__COMPILE_ATTR_WARN_UNUSED_RET() USTR__COMPILE_ATTR_NONNULL_L((2, 3));
145 : USTR_CONF_E_PROTO
146 : int ustrp_sc_trim_chrs(struct Ustr_pool *, struct Ustrp **,const char *,size_t)
147 : USTR__COMPILE_ATTR_WARN_UNUSED_RET() USTR__COMPILE_ATTR_NONNULL_L((2, 3));
148 : USTR_CONF_EI_PROTO int ustrp_sc_trim(struct Ustr_pool *, struct Ustrp **,
149 : const struct Ustrp *)
150 : USTR__COMPILE_ATTR_WARN_UNUSED_RET() USTR__COMPILE_ATTR_NONNULL_L((2, 3));
151 : USTR_CONF_EI_PROTO
152 : int ustrp_sc_trim_cstr(struct Ustr_pool *, struct Ustrp **, const char *)
153 : USTR__COMPILE_ATTR_WARN_UNUSED_RET() USTR__COMPILE_ATTR_NONNULL_L((2, 3));
154 :
155 : USTR_CONF_E_PROTO
156 : struct Ustrp *ustrp_sc_vjoin(struct Ustr_pool *, const struct Ustrp *,
157 : const struct Ustrp *, const struct Ustrp *,
158 : va_list)
159 : USTR__COMPILE_ATTR_WARN_UNUSED_RET() USTR__COMPILE_ATTR_NONNULL_L((2, 3,4));
160 : USTR_CONF_E_PROTO
161 : struct Ustrp *ustrp_sc_join(struct Ustr_pool *, const struct Ustrp *,
162 : const struct Ustrp *, const struct Ustrp *, ...)
163 : USTR__COMPILE_ATTR_WARN_UNUSED_RET() USTR__COMPILE_ATTR_NONNULL_L((2, 3, 4))
164 : USTR__COMPILE_ATTR_SENTINEL(0);
165 : USTR_CONF_E_PROTO
166 : struct Ustrp *ustrp_sc_vjoinx(struct Ustr_pool *, size_t,size_t,int,int,
167 : const struct Ustrp *, const struct Ustrp *,
168 : const struct Ustrp *, va_list)
169 : USTR__COMPILE_ATTR_WARN_UNUSED_RET() USTR__COMPILE_ATTR_NONNULL_L((6, 7,8));
170 : USTR_CONF_E_PROTO
171 : struct Ustrp *ustrp_sc_joinx(struct Ustr_pool *, size_t, size_t, int, int,
172 : const struct Ustrp *, const struct Ustrp *,
173 : const struct Ustrp *, ...)
174 : USTR__COMPILE_ATTR_WARN_UNUSED_RET() USTR__COMPILE_ATTR_NONNULL_L((6, 7, 8))
175 : USTR__COMPILE_ATTR_SENTINEL(0);
176 :
177 : USTR_CONF_E_PROTO
178 : struct Ustrp *ustrp_sc_vconcat(struct Ustr_pool *, const struct Ustrp *,va_list)
179 : USTR__COMPILE_ATTR_WARN_UNUSED_RET() USTR__COMPILE_ATTR_NONNULL_L((2));
180 : USTR_CONF_E_PROTO
181 : struct Ustrp *ustrp_sc_concat(struct Ustr_pool *, const struct Ustrp *, ...)
182 : USTR__COMPILE_ATTR_WARN_UNUSED_RET() USTR__COMPILE_ATTR_NONNULL_L((2))
183 : USTR__COMPILE_ATTR_SENTINEL(0);
184 : USTR_CONF_E_PROTO
185 : struct Ustrp *ustrp_sc_vconcatx(struct Ustr_pool *, size_t,size_t,int,int,
186 : const struct Ustrp *, va_list)
187 : USTR__COMPILE_ATTR_WARN_UNUSED_RET() USTR__COMPILE_ATTR_NONNULL_L((6));
188 : USTR_CONF_E_PROTO
189 : struct Ustrp *ustrp_sc_concatx(struct Ustr_pool *, size_t, size_t, int, int,
190 : const struct Ustrp *, ...)
191 : USTR__COMPILE_ATTR_WARN_UNUSED_RET() USTR__COMPILE_ATTR_NONNULL_L((6))
192 : USTR__COMPILE_ATTR_SENTINEL(0);
193 :
194 : #if USTR_CONF_INCLUDE_INTERNAL_HEADERS
195 : # include "ustr-sc-internal.h"
196 : #endif
197 :
198 : #if USTR_CONF_INCLUDE_CODEONLY_HEADERS
199 : # include "ustr-sc-code.h"
200 : #endif
201 :
202 : #if USTR_CONF_COMPILE_USE_INLINE
203 : USTR_CONF_II_PROTO
204 : char *ustr_sc_export(const struct Ustr *s1, void *(*my_alloc)(size_t))
205 8 : { return (ustr_sc_export_subustr(s1, 1, ustr_len(s1), my_alloc)); }
206 : USTR_CONF_II_PROTO
207 : char *ustrp_sc_export(struct Ustr_pool *p,
208 : const struct Ustrp *s1, void *(*my_alloc)(size_t))
209 15 : { return (ustrp_sc_export_subustrp(p, s1, 1, ustrp_len(s1), my_alloc)); }
210 :
211 : USTR_CONF_II_PROTO int ustr_sc_ltrim(struct Ustr **ps1, const struct Ustr *s2)
212 8 : { return (ustr_sc_ltrim_chrs(ps1, ustr_cstr(s2), ustr_len(s2))); }
213 : USTR_CONF_II_PROTO int ustr_sc_ltrim_cstr(struct Ustr **ps1, const char *cstr)
214 8 : { return (ustr_sc_ltrim_chrs(ps1, cstr, strlen(cstr))); }
215 :
216 : USTR_CONF_II_PROTO int ustr_sc_rtrim(struct Ustr **ps1, const struct Ustr *s2)
217 8 : { return (ustr_sc_rtrim_chrs(ps1, ustr_cstr(s2), ustr_len(s2))); }
218 : USTR_CONF_II_PROTO int ustr_sc_rtrim_cstr(struct Ustr **ps1, const char *cstr)
219 8 : { return (ustr_sc_rtrim_chrs(ps1, cstr, strlen(cstr))); }
220 :
221 : USTR_CONF_II_PROTO int ustr_sc_trim(struct Ustr **ps1, const struct Ustr *s2)
222 4 : { return (ustr_sc_trim_chrs(ps1, ustr_cstr(s2), ustr_len(s2))); }
223 : USTR_CONF_II_PROTO int ustr_sc_trim_cstr(struct Ustr **ps1, const char *cstr)
224 4 : { return (ustr_sc_trim_chrs(ps1, cstr, strlen(cstr))); }
225 :
226 : USTR_CONF_II_PROTO int ustrp_sc_ltrim(struct Ustr_pool *p, struct Ustrp **ps1,
227 : const struct Ustrp *s2)
228 10 : { return (ustrp_sc_ltrim_chrs(p, ps1, ustrp_cstr(s2), ustrp_len(s2))); }
229 : USTR_CONF_II_PROTO
230 : int ustrp_sc_ltrim_cstr(struct Ustr_pool *p, struct Ustrp **ps1, const char *c)
231 8 : { return (ustrp_sc_ltrim_chrs(p, ps1, c, strlen(c))); }
232 :
233 : USTR_CONF_II_PROTO int ustrp_sc_rtrim(struct Ustr_pool *p, struct Ustrp **ps1,
234 : const struct Ustrp *s2)
235 10 : { return (ustrp_sc_rtrim_chrs(p, ps1, ustrp_cstr(s2), ustrp_len(s2))); }
236 : USTR_CONF_II_PROTO
237 : int ustrp_sc_rtrim_cstr(struct Ustr_pool *p, struct Ustrp **ps1, const char *c)
238 8 : { return (ustrp_sc_rtrim_chrs(p, ps1, c, strlen(c))); }
239 :
240 : USTR_CONF_II_PROTO int ustrp_sc_trim(struct Ustr_pool *p, struct Ustrp **ps1,
241 : const struct Ustrp *s2)
242 10 : { return (ustrp_sc_trim_chrs(p, ps1, ustrp_cstr(s2), ustrp_len(s2))); }
243 : USTR_CONF_II_PROTO
244 : int ustrp_sc_trim_cstr(struct Ustr_pool *p, struct Ustrp **ps1, const char *c)
245 8 : { return (ustrp_sc_trim_chrs(p, ps1, c, strlen(c))); }
246 :
247 :
248 : #endif
249 :
250 :
251 : #endif
|