1ustr(3)                       Ustr String Library                      ustr(3)
2
3
4

NAME

6       ustr - ustr string library functions
7

SYNOPSIS

9  #include "ustr.h"
10
11
12  struct Ustr *USTR(void *);
13  struct Ustrp *USTRP(void *);
14  struct Ustr *USTR1(symbol, const char[]);
15  struct Ustr *USTR2(symbol, symbol, const char[]);
16  struct Ustr *USTR4(symbol, symbol, symbol, symbol, const char[]);
17  struct Ustr *USTR1_CHK(symbol, const char[]);
18  struct Ustr *USTR2_CHK(symbol, symbol, const char[]);
19  struct Ustr *USTR4_CHK(symbol, symbol, symbol, symbol, const char[]);
20  struct Ustr *USTRP1(symbol, const char[]);
21  struct Ustr *USTRP2(symbol, symbol, const char[]);
22  struct Ustrp *USTRP4(symbol, symbol, symbol, symbol, const char[]);
23  struct Ustr *USTRP1_CHK(symbol, const char[]);
24  struct Ustr *USTRP2_CHK(symbol, symbol, const char[]);
25  struct Ustrp *USTRP4_CHK(symbol, symbol, symbol, symbol, const char[]);
26
27  size_t USTR_SIZE_FIXED(size_t);
28  struct Ustr *ustr_init_fixed(void *, size_t, int, size_t);
29  struct Ustr *USTR_SC_INIT_AUTO(char[], int, size_t);
30  struct Ustr *USTR_SC_INIT_AUTO_OSTR(char[], int, size_t);
31
32  int ustr_assert_valid(Ustr *);
33  int ustr_assert_valid_subustr(Ustr *, size_t,  size_t);
34  int USTR_CNTL_MALLOC_CHECK_BEG(int);
35  int USTR_CNTL_MALLOC_CHECK_LVL(void);
36  int USTR_CNTL_MALLOC_CHECK_MEM(void *);
37  int USTR_CNTL_MALLOC_CHECK_MEM_SZ(void *, size_t);
38  int USTR_CNTL_MALLOC_CHECK_MEM_MINSZ(void *, size_t);
39  int USTR_CNTL_MALLOC_CHECK_MEM_USTR(Ustr *);
40  int USTR_CNTL_MALLOC_CHECK_MEM_USTRP(Ustrp *);
41  int USTR_CNTL_MALLOC_CHECK_END(void);
42  int USTR_CNTL_MALLOC_CHECK_ADD(int);
43  int USTR_CNTL_MALLOC_CHECK_DEL(int);
44
45  size_t  ustr_init_size(size_t, size_t, int, size_t);
46  struct  Ustr  *ustr_init_alloc(void  *,  size_t,  size_t,  size_t, int, int,
47                               size_t);
48  struct Ustr *ustr_dupx_empty(size_t, size_t, int, int);
49  struct Ustr *ustr_dup_empty(void);
50  struct Ustr *ustr_dupx_undef(size_t, size_t, int, int, size_t);
51  struct Ustr *ustr_dup_undef(size_t);
52  struct Ustr *ustr_dup(const struct Ustr *);
53  struct Ustr *ustr_dupx(size_t, size_t, int, int, const struct Ustr *);
54  struct Ustr *ustr_sc_dup(struct Ustr **);
55  struct Ustr *ustr_sc_dupx(size_t, size_t, int, int, struct Ustr **);
56  struct Ustr *ustr_dup_buf(const void *, size_t);
57  struct Ustr *ustr_dupx_buf(size_t, size_t, int, int, const void *, size_t);
58  struct Ustr *ustr_dup_cstr(const char *);
59  struct Ustr *ustr_dupx_cstr(size_t, size_t, int, int, const char *);
60  struct Ustr *USTR_DUP_OSTR(const char []);
61  struct Ustr *USTR_DUP_OBJ(...);
62  struct Ustr *ustr_dup_subustr(const struct Ustr *, size_t, size_t);
63  struct Ustr *ustr_dupx_subustr(size_t, size_t, int, int, const  struct  Ustr
64                                 *, size_t, size_t);
65  struct Ustr *ustr_dup_rep_chr(char, size_t);
66  struct Ustr *ustr_dupx_rep_chr(size_t, size_t, int, int, char, size_t);
67  struct  Ustr  *ustr_sc_vjoin(const struct Ustr *, const struct Ustr *, const
68                             struct Ustr *, va_list);
69  struct Ustr *ustr_sc_join(const struct Ustr *, const struct  Ustr  *,  const
70                            struct Ustr *, ...);
71  struct  Ustr  *ustr_sc_vjoinx(size_t, size_t, int, int, const struct Ustr *,
72                              const  struct  Ustr  *,  const  struct  Ustr  *,
73                              va_list);
74  struct  Ustr  *ustr_sc_joinx(size_t,  size_t, int, int, const struct Ustr *,
75                             const struct Ustr *, const struct Ustr *, ...);
76  struct Ustr *ustr_sc_vconcat(const struct Ustr *, va_list);
77  struct Ustr *ustr_sc_concat(const struct Ustr *, ...);
78  struct Ustr *ustr_sc_vconcatx(size_t, size_t, int, int, const struct Ustr *,
79                                va_list);
80  struct  Ustr *ustr_sc_concatx(size_t, size_t, int, int, const struct Ustr *,
81                               ...);
82
83  void  ustr_free(struct Ustr *);
84  void  ustrp_free(struct Ustr_pool *, struct Ustrp *);
85  void  ustr_sc_free(struct Ustr **);
86  void  ustr_sc_free2(struct Ustr **, struct Ustr *);
87  void  ustr_sc_free_shared(struct Ustr **);
88  int  ustr_del(struct Ustr **, size_t);
89  int  ustr_del_subustr(struct Ustr **, size_t,  size_t);
90  void  ustr_sc_del(struct Ustr **);
91
92  int ustr_add_undef(struct Ustr **, size_t);
93  int ustr_add_buf(struct Ustr **, const void *, size_t);
94  int  ustr_add_cstr(struct Ustr **, const char *);
95  int  USTR_ADD_OSTR(struct Ustr **, const char []);
96  int  USTR_ADD_OBJ(struct Ustr **, ...);
97  int  ustr_add(struct Ustr **, const struct Ustr *);
98  int  ustr_add_subustr(struct Ustr **, const struct Ustr *, size_t, size_t);
99  int  ustr_add_rep_chr(struct Ustr **, char, size_t);
100
101  int  ustr_set_undef(struct Ustr **,  size_t);
102  int ustr_set_empty(struct Ustr **);
103  int ustr_set_buf(struct Ustr **,  const void *, size_t);
104  int ustr_set_cstr(struct Ustr **, const char *);
105  int USTR_SET_OSTR(struct Ustr **, const char []);
106  int USTR_SET_OBJ(struct Ustr **, ...);
107  int ustr_set(struct Ustr **, const struct Ustr *);
108  int ustr_set_subustr(struct Ustr **, const struct Ustr *, size_t, size_t);
109  int ustr_set_rep_chr(struct Ustr **, char, size_t);
110
111  int ustr_ins_undef(struct Ustr **, size_t, size_t);
112  int ustr_ins_buf(struct Ustr **, size_t, const void *, size_t);
113  int  ustr_ins_cstr(struct Ustr **, size_t, const char *);
114  int  USTR_INS_OSTR(struct Ustr **, size_t, const char []);
115  int  USTR_INS_OBJ(struct Ustr **, size_t, ...);
116  int  ustr_ins(struct Ustr **, size_t, const struct Ustr *);
117  int  ustr_ins_subustr(struct Ustr **, size_t, const struct Ustr  *,  size_t,
118                        size_t);
119  int  ustr_ins_rep_chr(struct Ustr **, size_t, char, size_t);
120
121  int  ustr_add_vfmt_lim(struct Ustr **, size_t, const char *, va_list);
122  int  ustr_add_vfmt(struct Ustr **, const char *, va_list);
123  int  ustr_add_fmt_lim(struct Ustr **, size_t, const char *, ...);
124  int  ustr_add_fmt(struct Ustr **, const char *, ...);
125  struct Ustr *ustr_dup_vfmt_lim(size_t, const char *, va_list);
126  struct Ustr *ustr_dup_vfmt(size_t, const char *, va_list);
127  struct Ustr *ustr_dup_fmt_lim(size_t, const char *, ...);
128  struct Ustr *ustr_dup_fmt(const char *, ...);
129  struct  Ustr *ustr_dupx_fmt_lim(size_t, size_t, int, int, size_t, const char
130                                 *, ...);
131  struct Ustr *ustr_dupx_fmt(size_t, size_t, int, int, const char *, ...);
132  int  ustr_set_vfmt_lim(struct Ustr **, size_t, const char *, va_list);
133  int  ustr_set_vfmt(struct Ustr **, const char *, va_list);
134  int  ustr_set_fmt_lim(struct Ustr **, size_t, const char *, ...);
135  int  ustr_set_fmt(struct Ustr **, const char *, ...);
136  int   ustr_ins_vfmt_lim(struct  Ustr  **,  size_t,  size_t,  const  char  *,
137                         va_list);
138  int  ustr_ins_vfmt(struct Ustr **, size_t, const char *, va_list);
139  int  ustr_ins_fmt_lim(struct Ustr **, size_t, size_t, const char *, ...);
140  int  ustr_ins_fmt(struct Ustr **, size_t, const char *, ...);
141  int   ustr_sub_vfmt_lim(struct  Ustr  **,  size_t,  size_t,  const  char  *,
142                         va_list);
143  int  ustr_sub_vfmt(struct Ustr **, size_t, const char *, va_list);
144  int  ustr_sub_fmt_lim(struct Ustr **, size_t, size_t, const char *, ...);
145  int  ustr_sub_fmt(struct Ustr **, size_t, const char *, ...);
146  int  ustr_sc_sub_vfmt_lim(struct Ustr **, size_t, size_t, size_t, const char
147                            *, va_list);
148  int    ustr_sc_sub_vfmt(struct  Ustr  **,  size_t,  size_t,  const  char  *,
149                        va_list);
150  int  ustr_sc_sub_fmt_lim(struct Ustr **, size_t, size_t, size_t, const  char
151                           *, ...);
152  int  ustr_sc_sub_fmt(struct Ustr **, size_t, size_t, const char *, ...);
153
154  size_t  ustr_len(const struct Ustr *);
155  const char *ustr_cstr(const struct Ustr *);
156  char *ustr_wstr(struct Ustr *);
157  int ustr_alloc(const struct Ustr *);
158  int ustr_exact(const struct Ustr *);
159  int  ustr_sized(const struct Ustr *);
160  int ustr_ro(const struct Ustr *);
161  int  ustr_fixed(const struct Ustr *);
162  int  ustr_enomem(const struct Ustr *);
163  int  ustr_shared(const struct Ustr *);
164  int  ustr_limited(const struct Ustr *);
165  int  ustr_owner(const struct Ustr *);
166  size_t  ustr_size(const struct Ustr *);
167  size_t  ustr_size_alloc(const struct Ustr *);
168  size_t  ustr_size_overhead(const struct Ustr *);
169  void   ustr_conf(const  struct  Ustr *, size_t *, size_t *, int *, size_t *,
170                  size_t *);
171
172  int  ustr_setf_enomem_err(struct Ustr *);
173  int  ustr_setf_enomem_clr(struct Ustr *);
174  int  ustr_setf_share(struct Ustr *);
175  int  ustr_setf_owner(struct Ustr *);
176
177  int  ustr_cmp_buf(const struct Ustr *, const void *, size_t);
178  int  ustr_cmp(const struct Ustr *, const struct Ustr *);
179  int  ustr_cmp_subustr(const struct Ustr *,  const  struct  Ustr  *,  size_t,
180                        size_t);
181  int  ustr_cmp_cstr(const struct Ustr *, const char *);
182  int  ustr_cmp_fast_buf(const struct Ustr *, const void *, size_t);
183  int  ustr_cmp_fast(const struct Ustr *, const struct Ustr *);
184  int  ustr_cmp_fast_subustr(const struct Ustr *, const struct Ustr *, size_t,
185                             size_t);
186  int  ustr_cmp_fast_cstr(const struct Ustr *, const char *);
187  int  ustr_cmp_case_buf(const struct Ustr *, const void *, size_t);
188  int  ustr_cmp_case(const struct Ustr *, const struct Ustr *);
189  int  ustr_cmp_case_subustr(const struct Ustr *, const struct Ustr *, size_t,
190                             size_t);
191  int  ustr_cmp_case_cstr(const struct Ustr *, const char *);
192  int  ustr_cmp_eq(const struct Ustr *, const struct Ustr *);
193  int  ustr_cmp_buf_eq(const struct Ustr *, const void *, size_t);
194  int   ustr_cmp_subustr_eq(const  struct Ustr *, const struct Ustr *, size_t,
195                           size_t);
196  int  ustr_cmp_cstr_eq(const struct Ustr *, const char *);
197  int  ustr_cmp_case_eq(const struct Ustr *, const struct Ustr *);
198  int  ustr_cmp_case_buf_eq(const struct Ustr *, const void *, size_t);
199  int  ustr_cmp_case_subustr_eq(const struct Ustr  *,  const  struct  Ustr  *,
200                                size_t, size_t);
201  int  ustr_cmp_case_cstr_eq(const struct Ustr *, const char *);
202  int  ustr_cmp_prefix_eq(const struct Ustr *, const struct Ustr *);
203  int  ustr_cmp_prefix_buf_eq(const struct Ustr *, const void *, size_t);
204  int  ustr_cmp_prefix_cstr_eq(const struct Ustr *, const char *);
205  int   ustr_cmp_prefix_subustr_eq(const  struct  Ustr *, const struct Ustr *,
206                                  size_t, size_t);
207  int  ustr_cmp_case_prefix_eq(const struct Ustr *, const struct Ustr *);
208  int  ustr_cmp_case_prefix_buf_eq(const struct Ustr *, const void *, size_t);
209  int  ustr_cmp_case_prefix_cstr_eq(const struct Ustr *, const char *);
210  int  ustr_cmp_case_prefix_subustr_eq(const struct Ustr *, const struct  Ustr
211                                       *, size_t, size_t);
212  int  ustr_cmp_suffix_eq(const struct Ustr *, const struct Ustr *);
213  int  ustr_cmp_suffix_buf_eq(const struct Ustr *, const void *, size_t);
214  int  ustr_cmp_suffix_cstr_eq(const struct Ustr *, const char *);
215  int   ustr_cmp_suffix_subustr_eq(const  struct  Ustr *, const struct Ustr *,
216                                  size_t, size_t);
217  int  ustr_cmp_case_suffix_eq(const struct Ustr *, const struct Ustr *);
218  int  ustr_cmp_case_suffix_buf_eq(const struct Ustr *, const void *, size_t);
219  int  ustr_cmp_case_suffix_cstr_eq(const struct Ustr *, const char *);
220  int  ustr_cmp_case_suffix_subustr_eq(const struct Ustr *, const struct  Ustr
221                                       *, size_t, size_t);
222
223  size_t  ustr_srch_chr_fwd(const struct Ustr *, size_t, char);
224  size_t  ustr_srch_chr_rev(const struct Ustr *, size_t, char);
225  size_t   ustr_srch_buf_fwd(const  struct  Ustr  *,  size_t,  const  void  *,
226                            size_t);
227  size_t   ustr_srch_buf_rev(const  struct  Ustr  *,  size_t,  const  void  *,
228                            size_t);
229  size_t  ustr_srch_fwd(const struct Ustr *, size_t, const struct Ustr *);
230  size_t  ustr_srch_rev(const struct Ustr *, size_t, const struct Ustr *);
231  size_t  ustr_srch_cstr_fwd(const struct Ustr *, size_t, const char *);
232  size_t  ustr_srch_cstr_rev(const struct Ustr *, size_t, const char *);
233  size_t  ustr_srch_subustr_fwd(const struct Ustr *, size_t, const struct Ustr
234                                *, size_t, size_t);
235  size_t  ustr_srch_subustr_rev(const struct Ustr  *,   size_t,  const  struct
236                                Ustr *, size_t, size_t);
237  size_t  ustr_srch_case_chr_fwd(const struct Ustr *, size_t, char);
238  size_t  ustr_srch_case_chr_rev(const struct Ustr *, size_t, char);
239  size_t   ustr_srch_case_buf_fwd(const  struct  Ustr *, size_t, const void *,
240                                 size_t);
241  size_t  ustr_srch_case_buf_rev(const struct Ustr *, size_t,  const  void  *,
242                                 size_t);
243  size_t   ustr_srch_case_fwd(const  struct  Ustr *, size_t, const struct Ustr
244                             *);
245  size_t  ustr_srch_case_rev(const struct Ustr *, size_t,  const  struct  Ustr
246                             *);
247  size_t  ustr_srch_case_cstr_fwd(const struct Ustr *, size_t, const char *);
248  size_t  ustr_srch_case_cstr_rev(const struct Ustr *, size_t, const char *);
249  size_t  ustr_srch_case_subustr_fwd(const struct Ustr *, size_t, const struct
250                                     Ustr *, size_t, size_t);
251  size_t   ustr_srch_case_subustr_rev(const  struct  Ustr  *,   size_t,  const
252                                     struct Ustr *, size_t, size_t);
253
254  size_t  ustr_spn_chr_fwd(const struct Ustr *, size_t, char);
255  size_t  ustr_spn_chr_rev(const struct Ustr *, size_t, char);
256  size_t   ustr_spn_chrs_fwd(const  struct  Ustr  *,  size_t,  const  char  *,
257                            size_t);
258  size_t   ustr_spn_chrs_rev(const  struct  Ustr  *,  size_t,  const  char  *,
259                            size_t);
260  size_t  ustr_spn_fwd(const struct Ustr *, size_t, const struct Ustr *);
261  size_t  ustr_spn_rev(const struct Ustr *, size_t, const struct Ustr *);
262  size_t  ustr_spn_cstr_fwd(const struct Ustr *, size_t, const char *);
263  size_t  ustr_spn_cstr_rev(const struct Ustr *, size_t, const char *);
264  size_t  ustr_cspn_chr_fwd(const struct Ustr *, size_t, char);
265  size_t  ustr_cspn_chr_rev(const struct Ustr *, size_t, char);
266  size_t   ustr_cspn_chrs_fwd(const  struct  Ustr  *,  size_t,  const  char *,
267                             size_t);
268  size_t  ustr_cspn_chrs_rev(const  struct  Ustr  *,  size_t,  const  char  *,
269                             size_t);
270  size_t  ustr_cspn_fwd(const struct Ustr *, size_t, const struct Ustr *);
271  size_t  ustr_cspn_rev(const struct Ustr *, size_t, const struct Ustr *);
272  size_t  ustr_cspn_cstr_fwd(const struct Ustr *, size_t, const char *);
273  size_t  ustr_cspn_cstr_rev(const struct Ustr *, size_t, const char *);
274  size_t   ustr_utf8_spn_chrs_fwd(const  struct  Ustr *, size_t, const char *,
275                                 size_t);
276  size_t  ustr_utf8_spn_chrs_rev(const struct Ustr *, size_t,  const  char  *,
277                                 size_t);
278  size_t  ustr_utf8_spn_fwd(const struct Ustr *, size_t, const struct Ustr *);
279  size_t  ustr_utf8_spn_rev(const struct Ustr *, size_t, const struct Ustr *);
280  size_t  ustr_utf8_spn_cstr_fwd(const struct Ustr *, size_t, const char *);
281  size_t  ustr_utf8_spn_cstr_rev(const struct Ustr *, size_t, const char *);
282  size_t   ustr_utf8_cspn_chrs_fwd(const  struct Ustr *, size_t, const char *,
283                                  size_t);
284  size_t  ustr_utf8_cspn_chrs_rev(const struct Ustr *, size_t, const  char  *,
285                                  size_t);
286  size_t   ustr_utf8_cspn_fwd(const  struct  Ustr *, size_t, const struct Ustr
287                             *);
288  size_t  ustr_utf8_cspn_rev(const struct Ustr *, size_t,  const  struct  Ustr
289                             *);
290  size_t  ustr_utf8_cspn_cstr_fwd(const struct Ustr *, size_t, const char *);
291  size_t  ustr_utf8_cspn_cstr_rev(const struct Ustr *, size_t, const char *);
292
293  int  ustr_io_get(struct Ustr **, FILE *, size_t, size_t *);
294  int  ustr_io_getfile(struct Ustr **, FILE *);
295  int  ustr_io_getfilename(struct Ustr **, const char *);
296  int  ustr_io_getdelim(struct Ustr **, FILE *, char);
297  int  ustr_io_getline(struct Ustr **, FILE *);
298  int ustr_io_put(struct Ustr **, FILE *, size_t);
299  int  ustr_io_putline(struct Ustr **, FILE *, size_t);
300  int  ustr_io_putfile(struct Ustr **, FILE *);
301  int  ustr_io_putfileline(struct Ustr **, FILE *);
302  int  ustr_io_putfilename(struct Ustr **, const char *, const char *);
303
304  int  ustr_sub_undef(struct Ustr **, size_t, size_t);
305  int  ustr_sub_buf(struct Ustr **, size_t, const void *, size_t);
306  int  ustr_sub_cstr(struct Ustr **, size_t, const char *);
307  int  USTR_SUB_OSTR(struct Ustr **, size_t, const char []);
308  int  USTR_SUB_OBJ(struct Ustr **, size_t, ...);
309  int  ustr_sub(struct Ustr **, size_t, const struct Ustr *);
310  int   ustr_sub_subustr(struct  Ustr **, size_t, const struct Ustr *, size_t,
311                        size_t);
312  int  ustr_sc_sub_undef(struct Ustr **, size_t, size_t, size_t);
313  int  ustr_sc_sub_buf(struct Ustr **, size_t , size_t , const void *,  size_t
314                       );
315  int  ustr_sc_sub_cstr(struct Ustr **, size_t, size_t, const char *);
316  int  ustr_sc_sub(struct Ustr **, size_t, size_t, const struct Ustr *);
317  int   ustr_sc_sub_subustr(struct  Ustr **, size_t, size_t, const struct Ustr
318                           *, size_t, size_t);
319  int  USTR_SC_SUB_OSTR(struct Ustr **, size_t, size_t, const char []);
320  int  USTR_SC_SUB_OBJ(struct Ustr **, size_t, size_t, ...);
321  size_t  ustr_replace_buf(struct Ustr **, const void *, size_t, const void *,
322                           size_t, size_t);
323  size_t   ustr_replace_cstr(struct  Ustr  **,  const  char  *,  const char *,
324                            size_t);
325  int  ustr_replace(struct Ustr **, const struct Ustr *, const struct Ustr  *,
326                    size_t);
327  size_t  ustr_replace_rep_chr(struct  Ustr  **ps1, char, size_t, char, size_t
328                              nlen, size_t lim);
329
330  struct Ustr *ustr_split_buf(const struct Ustr *, size_t  *,  const  void  *,
331                              size_t, struct Ustr *, unsigned int);
332  struct  Ustr *ustr_split(const struct Ustr *, size_t *, const struct Ustr *,
333                          struct Ustr *, unsigned int);
334  struct Ustr *ustr_split_cstr(const struct Ustr *, size_t *,  const  char  *,
335                               struct Ustr *, unsigned int);
336  struct  Ustr  *ustr_split_spn_chrs(const struct Ustr *, size_t *, const char
337                                   *, size_t, struct Ustr *, unsigned int);
338  struct Ustr *ustr_split_spn_cstr(const struct Ustr *, size_t *,  const  char
339                                   *, struct Ustr *, unsigned int);
340  struct Ustr *ustr_split_spn(const struct Ustr *, size_t *, const struct Ustr
341                              *, struct Ustr *, unsigned int);
342
343  int  ustr_utf8_valid(const struct Ustr *);
344  size_t  ustr_utf8_len(const struct Ustr *);
345  ssize_t  ustr_utf8_width(const struct Ustr *);
346  size_t  ustr_utf8_chars2bytes(const struct Ustr *,  size_t,  size_t,  size_t
347                                *);
348  size_t   ustr_utf8_bytes2chars(const  struct  Ustr *, size_t, size_t, size_t
349                                *);
350  int ustr_sc_utf8_reverse(struct Ustr **);
351
352  uintmax_t  ustr_parse_uintmaxx(const struct Ustr *,  size_t,  unsigned  int,
353                                 uintmax_t, uintmax_t, const char *, size_t *,
354                                 unsigned int *);
355  uintmax_t  ustr_parse_uintmax(const struct Ustr  *,  size_t,  unsigned  int,
356                                size_t *, unsigned int *);
357  intmax_t   ustr_parse_intmax(const  struct  Ustr  *,  size_t,  unsigned int,
358                              size_t *, unsigned int *);
359  unsigned long  ustr_parse_ulongx(const struct  Ustr  *,   size_t,   unsigned
360                                   int,   unsigned long,  unsigned long, const
361                                   char *,  size_t *, unsigned int *);
362  unsigned long  ustr_parse_ulong(const struct Ustr *, size_t,  unsigned  int,
363                                  size_t *, unsigned int *);
364  long   ustr_parse_long(const  struct Ustr *, size_t, unsigned int, size_t *,
365                        unsigned int *);
366  unsigned int  ustr_parse_uint(const struct Ustr  *,  size_t,  unsigned  int,
367                                size_t *, unsigned int *);
368  int   ustr_parse_int(const  struct  Ustr  *, size_t, unsigned int, size_t *,
369                      unsigned int *);
370  unsigned short  ustr_parse_ushort(const struct Ustr *, size_t, unsigned int,
371                                    size_t *, unsigned int *);
372  short  ustr_parse_short(const struct Ustr *, size_t, unsigned int, size_t *,
373                          unsigned int *);
374
375  int  ustr_sc_ensure_owner(struct Ustr **);
376  char *ustr_sc_wstr(struct Ustr **);
377  char *ustr_sc_export_subustr(const  struct  Ustr  *,  size_t,  size_t,  void
378                               *(*)(size_t));
379  char *ustr_sc_export(const struct Ustr *, void *(*)(size_t));
380  char  *ustrp_sc_export_subustrp(struct  Ustr_pool  *,  const  struct Ustr *,
381                                 size_t, size_t, void *(*)(size_t));
382  char  *ustrp_sc_export(struct  Ustr_pool  *,  const  struct  Ustr  *,   void
383                        *(*)(size_t));
384  int  ustr_sc_reverse(struct Ustr **);
385  int  ustr_sc_tolower(struct Ustr **);
386  int  ustr_sc_toupper(struct Ustr **);
387  int  ustr_sc_ltrim_chrs(struct Ustr **, const char *, size_t);
388  int  ustr_sc_ltrim(struct Ustr **, const struct Ustr *);
389  int  ustr_sc_ltrim_cstr(struct Ustr **, const char *);
390  int  ustr_sc_rtrim_chrs(struct Ustr **, const char *, size_t);
391  int  ustr_sc_rtrim(struct Ustr **, const struct Ustr *);
392  int  ustr_sc_rtrim_cstr(struct Ustr **, const char *);
393  int  ustr_sc_trim_chrs(struct Ustr **, const char *, size_t);
394  int  ustr_sc_trim(struct Ustr **, const struct Ustr *);
395  int  ustr_sc_trim_cstr(struct Ustr **, const char *);
396
397  int  ustr_add_b_uint16(struct Ustr **, uint_least16_t);
398  int  ustr_add_b_uint32(struct Ustr **, uint_least32_t);
399  int  ustr_add_b_uint64(struct Ustr **, uint_least64_t);
400
401  uint_least16_t  ustr_parse_b_uint16(const struct Ustr *, size_t);
402  uint_least32_t  ustr_parse_b_uint32(const struct Ustr *, size_t);
403  uint_least64_t  ustr_parse_b_uint64(const struct Ustr *, size_t);
404
405  int ustr_realloc(struct Ustr **, size_t);
406  int  ustr_cntl_opt(int, ...);
407
408  struct Ustr_pool *ustr_pool_ll_make(void);
409  struct Ustr_pool *ustr_pool_make_subpool(struct Ustr_pool *);
410  void ustr_pool_free(struct Ustr_pool *);
411  void ustr_pool_clear(struct Ustr_pool *);
412
413

DESCRIPTION

415        A  very simple overview is that you can use ustr_dup_cstr() to convert
416       a C-style to a Ustr, and ustr_cstr() to convert it back. You  can  also
417       use    USTR1()    to    create    constant/read-only    strings,    and
418       USTR_SC_INIT_AUTO() to create strings that use stack space upto a  cer‐
419       tain amount.
420        Use is somewhat unique in that, by default, it has an average overhead
421       of only 55% overhead over strdup(), for strings in the range of 0 to 20
422       bytes. Or, to put it another way it only uses 8 bytes to store a 2 byte
423       string where strdup() uses 3.
424

Creating read-only Ustr functions

426     Function:  USTR()
427       Returns: Ustr string
428       Type: struct Ustr *
429
430       Parameter[1]: Pointer to Ustr data
431       Type[1]: void *
432
433       Explanation:
434
435         This macro function is normally used with the empty string "".
436
437       Note:
438
439         There is basically just a simple cast behind the macro.
440
441     Function:  USTRP()
442       Returns: Ustrp string
443       Type: struct Ustrp *
444
445       Parameter[1]: Pointer to Ustrp data
446       Type[1]: void *
447
448       Explanation:
449
450         This macro function is normally used with the empty string "".
451
452       Note:
453
454         There is basically just a simple cast behind the macro.
455
456     Function:  USTR1()
457       Returns: Ustr string
458       Type: struct Ustr *
459
460       Parameter[1]: Encoded number of the length of Ustr string
461       Type[1]: symbol
462
463       Parameter[2]: Data for Ustr string
464       Type[2]: const char[]
465
466       Explanation:
467
468         This  macro  function  simplifies  the  creation  of  read-only  Ustr
469       string's. And is normally used like...
470
471         USTR1(\x4, "abcd")
472
473        ...it is worth pointing out that running with debugging turned on
474        (USTR_CONF_USE_ASSERT)  will complain if the length isn't encoded cor‐
475       rectly, as in...
476
477         USTR1(\x3, "abcd")
478
479        ...here ustr_assert_valid() will fail, which  is  called  before  most
480       functions do
481        anything   in   debugging   mode.   Note  also  that  extra  debugging
482       (USTR_CONF_USE_EOS_MARK) will still catch cases like...
483
484         USTR1(\x3, "abc\0d")
485
486        ...at least using debugging is esp. important if you are putting UTF-8
487        characters into the strings.
488
489       Note:
490
491         Having ustr_ro() return true means that the Ustr cannot be written to
492       without  be  reallocated  into allocation space ... not that ustr_add()
493       etc. will fail.
494         There is now USTR1_CHK() which performs a compile time check  so  you
495       can never have an invalid ustr.
496
497     Function:  USTR2()
498       Returns: Ustr string
499       Type: struct Ustr *
500
501       Parameter[1]: Encoded 2nd byte of number of the length of Ustr string
502       Type[1]: symbol
503
504       Parameter[2]: Encoded 1st byte of number of the length of Ustr string
505       Type[2]: symbol
506
507       Parameter[3]: Data for Ustr string
508       Type[3]: const char[]
509
510       Explanation:
511
512         This  function  works in the same way as USTR1() but takes two length
513       bytes, so the read-only string can be upto 65,535 (2**16 - 1) bytes  in
514       length.
515
516     Function:  USTR4()
517       Returns: Ustr string
518       Type: struct Ustr *
519
520       Parameter[1]: Encoded 4th byte of number of the length of Ustr string
521       Type[1]: symbol
522
523       Parameter[2]: Encoded 3rd byte of number of the length of Ustr string
524       Type[2]: symbol
525
526       Parameter[3]: Encoded 2nd byte of number of the length of Ustr string
527       Type[3]: symbol
528
529       Parameter[4]: Encoded 1st byte of number of the length of Ustr string
530       Type[4]: symbol
531
532       Parameter[5]: Data for Ustr string
533       Type[5]: const char[]
534
535       Explanation:
536
537         This  function works in the same way as USTR1() but takes four length
538       bytes, so the read-only string can be upto 2**32 - 1 bytes in length.
539
540     Function:  USTR1_CHK()
541       Returns: Ustr string
542       Type: struct Ustr *
543
544       Parameter[1]: Encoded number of the length of Ustr string
545       Type[1]: symbol
546
547       Parameter[2]: Data for Ustr string
548       Type[2]: const char[]
549
550       Explanation:
551
552         This function works in the same way as USTR1() but it  does  a  check
553       against the length of (Parameter[2]) using sizeof() - 1.
554
555       Note:
556
557         If  the  check fails the returned Ustr * will be "", so you can check
558       ustr_len() to see if you screwed something up.
559
560     Function:  USTR2_CHK()
561       Returns: Ustr string
562       Type: struct Ustr *
563
564       Parameter[1]: Encoded 2nd byte of number of the length of Ustr string
565       Type[1]: symbol
566
567       Parameter[2]: Encoded 1st byte of number of the length of Ustr string
568       Type[2]: symbol
569
570       Parameter[3]: Data for Ustr string
571       Type[3]: const char[]
572
573       Explanation:
574
575         This function works in the same way as USTR2() but it  does  a  check
576       against the length of (Parameter[2]) using sizeof() - 1.
577
578       Note:
579
580         If the check fails the returned Ustr * will be "".
581
582     Function:  USTR4_CHK()
583       Returns: Ustr string
584       Type: struct Ustr *
585
586       Parameter[1]: Encoded 4th byte of number of the length of Ustr string
587       Type[1]: symbol
588
589       Parameter[2]: Encoded 3rd byte of number of the length of Ustr string
590       Type[2]: symbol
591
592       Parameter[3]: Encoded 2nd byte of number of the length of Ustr string
593       Type[3]: symbol
594
595       Parameter[4]: Encoded 1st byte of number of the length of Ustr string
596       Type[4]: symbol
597
598       Parameter[5]: Data for Ustr string
599       Type[5]: const char[]
600
601       Explanation:
602
603         This  function  works  in the same way as USTR4() but it does a check
604       against the length of (Parameter[2]) using sizeof() - 1.
605
606       Note:
607
608         If the check fails the returned Ustr * will be "".
609
610     Function:  USTRP1()
611       Returns: Ustr string
612       Type: struct Ustr *
613
614       Parameter[1]: Encoded number of the length of Ustr string
615       Type[1]: symbol
616
617       Parameter[2]: Data for Ustr string
618       Type[2]: const char[]
619
620       Explanation:
621
622         This function works like USTR1(), but returns a Ustrp instead.
623
624     Function:  USTRP2()
625       Returns: Ustr string
626       Type: struct Ustr *
627
628       Parameter[1]: Encoded 2nd byte of number of the length of Ustr string
629       Type[1]: symbol
630
631       Parameter[2]: Encoded 1st byte of number of the length of Ustr string
632       Type[2]: symbol
633
634       Parameter[3]: Data for Ustr string
635       Type[3]: const char[]
636
637       Explanation:
638
639         This function works like USTR4(), but returns a Ustrp instead.
640
641     Function:  USTRP4()
642       Returns: Ustrp string
643       Type: struct Ustrp *
644
645       Parameter[1]: Encoded 4th byte of number of the length of Ustrp string
646       Type[1]: symbol
647
648       Parameter[2]: Encoded 3rd byte of number of the length of Ustrp string
649       Type[2]: symbol
650
651       Parameter[3]: Encoded 2nd byte of number of the length of Ustrp string
652       Type[3]: symbol
653
654       Parameter[4]: Encoded 1st byte of number of the length of Ustrp string
655       Type[4]: symbol
656
657       Parameter[5]: Data for Ustr string
658       Type[5]: const char[]
659
660       Explanation:
661
662         This function works like USTR2(), but returns a Ustrp instead.
663
664     Function:  USTRP1_CHK()
665       Returns: Ustr string
666       Type: struct Ustr *
667
668       Parameter[1]: Encoded number of the length of Ustr string
669       Type[1]: symbol
670
671       Parameter[2]: Data for Ustr string
672       Type[2]: const char[]
673
674       Explanation:
675
676         This function works like USTR1_CHK(), but returns a Ustrp instead.
677
678     Function:  USTRP2_CHK()
679       Returns: Ustr string
680       Type: struct Ustr *
681
682       Parameter[1]: Encoded 2nd byte of number of the length of Ustr string
683       Type[1]: symbol
684
685       Parameter[2]: Encoded 1st byte of number of the length of Ustr string
686       Type[2]: symbol
687
688       Parameter[3]: Data for Ustr string
689       Type[3]: const char[]
690
691       Explanation:
692
693         This function works like USTR4_CHK(), but returns a Ustrp instead.
694
695     Function:  USTRP4_CHK()
696       Returns: Ustrp string
697       Type: struct Ustrp *
698
699       Parameter[1]: Encoded 4th byte of number of the length of Ustrp string
700       Type[1]: symbol
701
702       Parameter[2]: Encoded 3rd byte of number of the length of Ustrp string
703       Type[2]: symbol
704
705       Parameter[3]: Encoded 2nd byte of number of the length of Ustrp string
706       Type[3]: symbol
707
708       Parameter[4]: Encoded 1st byte of number of the length of Ustrp string
709       Type[4]: symbol
710
711       Parameter[5]: Data for Ustr string
712       Type[5]: const char[]
713
714       Explanation:
715
716         This function works like USTR2_CHK(), but returns a Ustrp instead.
717
718

Creating fixed Ustr functions

720     Function:  USTR_SIZE_FIXED()
721       Returns: Size of area of memory
722       Type: size_t
723
724       Parameter[1]: Size of area of memory
725       Type[1]: size_t
726
727       Explanation:
728
729         This macro function is replaced by a static conversion from  the  max
730       length  desired  (Parameter[1])  to  the  storage size needed. In other
731       words it works out what ustr_size_overhead() will  be,  and  adds  that
732       value.
733
734       Note:
735
736         This  is useful is you want a small fixed size allocation, as you can
737       declare it like so:
738
739         char buf[USTR_SIZE_FIXED(4)];
740        ...to give you exactly 4 bytes as a maximum, this is  esp.  useful  if
741       you want
742        a limited (ustr_limited() == USTR_TRUE) Ustr string.
743
744     Function:  ustr_init_fixed()
745       Returns: Ustr string
746       Type: struct Ustr *
747
748       Parameter[1]: Pointer to area of memory to use as a Ustr string
749       Type[1]: void *
750
751       Parameter[2]: Size of area of memory
752       Type[2]: size_t
753
754       Parameter[3]: Whether the fixed size Ustr should be limited
755       Type[3]: int
756
757       Parameter[4]: The initial length of the Ustr
758       Type[4]: size_t
759
760       Explanation:
761
762         This creates a new Ustr string, which is "fixed". This means the Ustr
763       storage is managed outside of the ustr_* API,  it  is  often  used  for
764       stack allocated strings.
765         As  you  add  data  to  the Ustr past the size allowed via. the fixed
766       storge the Ustr will automatically be converted into an allocated Ustr.
767       So if this is possible you should always call ustr_free(), as this does
768       nothing if given a fixed size Ustr.
769
770       Note:
771
772         For simplicity  you  probably  want  to  use  USTR_SC_INIT_AUTO()  or
773       USTR_SC_INIT_AUTO() when possible.
774
775     Function:  USTR_SC_INIT_AUTO()
776       Returns: Ustr string
777       Type: struct Ustr *
778
779       Parameter[1]: Area of memory to use as a Ustr string
780       Type[1]: char[]
781
782       Parameter[2]: Whether the fixed size Ustr should be limited
783       Type[2]: int
784
785       Parameter[3]: The initial length of the Ustr
786       Type[3]: size_t
787
788       Explanation:
789
790         This calls ustr_init_fixed() with sizeof() the area of memory (Param‐
791       eter[1]) as the second argument.
792
793       Note:
794
795         This does mean that the first argument must be the correct  size,  as
796       far as sizeof() is concerned, as in...
797
798        char buf_sz[1024];
799        Ustr *s1 = USTR_SC_INIT_AUTO(buf_sz, USTR_FALSE, 0);
800
801        ...so  passing  pointers  to  memory  from malloc() will probably just
802       return NULL.
803
804
805     Function:  USTR_SC_INIT_AUTO_OSTR()
806       Returns: Ustr string
807       Type: struct Ustr *
808
809       Parameter[1]: Area of memory to use as a Ustr string
810       Type[1]: char[]
811
812       Parameter[2]: Whether the fixed size Ustr should be limited
813       Type[2]: int
814
815       Parameter[3]: The initial string in the buffer, as a constant string
816       Type[3]: size_t
817
818       Explanation:
819
820         This calls ustr_init_fixed() with sizeof() the area of memory (Param‐
821       eter[1]) as the second argument, given as an "object string".
822
823       Note:
824
825         This  does  mean that the first argument must be the correct size, as
826       far as sizeof() is concerned, as in...
827
828        char buf_sz[1024] = USTR_BEG_FIXED2 "abcd";
829        Ustr *s1 = USTR_SC_INIT_AUTO_OSTR(buf_sz, USTR_FALSE, "abcd");
830
831        ...so passing pointers to memory  from  malloc()  will  probably  just
832       return NULL.
833
834
835

Debugging functions

837     Function:  ustr_assert_valid()
838       Returns: Success or failure
839       Type: int
840
841       Parameter[1]: Pointer to a Ustr string
842       Type[1]: Ustr *
843
844       Explanation:
845
846         This function asserts a few internal consistency checks, and can help
847       point out when a Ustr is invalid.
848
849       Note:
850
851         This calls ustr_assert_ret() so  that  when  USTR_DEBUG  if  off  the
852       checks are still performed and the result is returned.
853
854     Function:  ustr_assert_valid_subustr()
855       Returns: Success or failure
856       Type: int
857
858       Parameter[1]: Pointer to a Ustr string
859       Type[1]: Ustr *
860
861       Parameter[2]: Position in the Ustr
862       Type[2]: size_t
863
864       Parameter[3]: Length to delete from the Ustr
865       Type[3]:  size_t
866
867       Explanation:
868
869         This  function  calls  ustr_assert_valid()  and  also checks that the
870       position and length are within  the  Ustr.  If  they  aren't  valid  it
871       returns 0, if they are valid it returns ustr_len().
872
873     Function:  USTR_CNTL_MALLOC_CHECK_BEG()
874       Returns: Success or failure
875       Type: int
876
877       Parameter[1]: Condition for begin malloc checking or not
878       Type[1]: int
879
880
881       Explanation:
882
883         This  function  begins  malloc checking, meaning all ustr allocations
884       will go through the malloc check routines, but it fails if  the  condi‐
885       tion check (Parameter[1]) fails.
886
887       Note:
888
889         Turning malloc checking on after one or more allocations has happened
890       will lead to false failures unless you really known what you are doing.
891         You  can  automatically  turn  malloc  checking  on  by  giving   the
892       USTR_CNTL_MC environment variable the value of "1", "yes" or "on".
893
894     Function:  USTR_CNTL_MALLOC_CHECK_LVL()
895       Returns: Level of current malloc check
896       Type: int
897
898       Parameter[1]: Nothing
899       Type[1]: void
900
901       Explanation:
902
903         This function returns the current "level" of the malloc check, with 0
904       indicating that malloc check isn't enabled.
905         The level goes up by  one  whenever  USTR_CNTL_MALLOC_CHECK_BEG()  or
906       USTR_CNTL_MALLOC_CHECK_ADD()  returns  success,  and  goes  down by one
907       whenever USTR_CNTL_MALLOC_CHECK_DEL()  or  USTR_CNTL_MALLOC_CHECK_END()
908       returns success.
909
910     Function:  USTR_CNTL_MALLOC_CHECK_MEM()
911       Returns: Success or failure
912       Type: int
913
914       Parameter[1]: Pointer returned from malloc check
915       Type[1]: void *
916
917       Explanation:
918
919         This  function  asserts that the pointer (Parameter[1]) was allocated
920       from malloc checking.
921
922       Note:
923
924         Unless you are doing something special, or using a builtin  Ustr_pool
925       it   is   very   likely   you   want   to   just   call  USTR_CNTL_MAL‐
926       LOC_CHECK_MEM_USTR().
927
928     Function:  USTR_CNTL_MALLOC_CHECK_MEM_SZ()
929       Returns: Success or failure
930       Type: int
931
932       Parameter[1]: Pointer returned from malloc check
933       Type[1]: void *
934
935       Parameter[2]: Length of allocated memory
936       Type[2]: size_t
937
938       Explanation:
939
940         This function asserts that the pointer (Parameter[1])  was  allocated
941       from malloc checking, and has the specified size (Parameter[2]).
942
943       Note:
944
945         Unless  you are doing something special, or using a builtin Ustr_pool
946       it  is   very   likely   you   want   to   just   call   USTR_CNTL_MAL‐
947       LOC_CHECK_MEM_USTR().
948
949     Function:  USTR_CNTL_MALLOC_CHECK_MEM_MINSZ()
950       Returns: Success or failure
951       Type: int
952
953       Parameter[1]: Pointer returned from malloc check
954       Type[1]: void *
955
956       Parameter[2]: Length of allocated memory
957       Type[2]: size_t
958
959       Explanation:
960
961         This  function  asserts that the pointer (Parameter[1]) was allocated
962       from malloc checking, and has at  least  the  specified  size  (Parame‐
963       ter[2]).
964
965       Note:
966
967         Unless  you are doing something special, or using a builtin Ustr_pool
968       it  is   very   likely   you   want   to   just   call   USTR_CNTL_MAL‐
969       LOC_CHECK_MEM_USTR().
970
971     Function:  USTR_CNTL_MALLOC_CHECK_MEM_USTR()
972       Returns: Success or failure
973       Type: int
974
975       Parameter[1]: Pointer to a Ustr string
976       Type[1]: Ustr *
977
978       Explanation:
979
980         This function asserts that the pointer (Parameter[1]) is a Ustr allo‐
981       cated from malloc checking, if the Ustr is allocated (if not it returns
982       TRUE).
983
984       Note:
985
986         Because  of  the layering between the Ustr code and the pool code, if
987       you allocate an implicity sized Ustrp from a pool and then delete  some
988       data from it (which fails) the Ustr layer will think it has an implicit
989       less than the actual size so this function  will  fail.  This  is  what
990       USTR_CNTL_MALLOC_CHECK_MEM_USTRP() is for.
991
992     Function:  USTR_CNTL_MALLOC_CHECK_MEM_USTRP()
993       Returns: Success or failure
994       Type: int
995
996       Parameter[1]: Pointer to a Ustrp string
997       Type[1]: Ustrp *
998
999       Explanation:
1000
1001         This function asserts that the pointer (Parameter[1]) is a Ustr allo‐
1002       cated from a builtin pool using malloc checking, if the Ustr  is  allo‐
1003       cated (if not it returns TRUE).
1004
1005     Function:  USTR_CNTL_MALLOC_CHECK_END()
1006       Returns: Success or failure
1007       Type: int
1008
1009       Parameter[1]: Nothing
1010       Type[1]: void
1011
1012       Explanation:
1013
1014         This  macro  will cleanup any memory used by malloc check, and assert
1015       that no memory is left allocated.
1016
1017       Note:
1018
1019         If any memory is left allocated, each one found is output  to  stderr
1020       with the file/line/function of the level it was allocated from.
1021
1022     Function:  USTR_CNTL_MALLOC_CHECK_ADD()
1023       Returns: Success or failure
1024       Type: int
1025
1026       Parameter[1]: Condition to begin malloc checking or not
1027       Type[1]: int
1028
1029       Explanation:
1030
1031         This function works like USTR_CNTL_MALLOC_CHECK_END() but it fails if
1032       the  condition  check  (Parameter[1])  fails,  or   if   USTR_CNTL_MAL‐
1033       LOC_CHECK_LVL() is zero.
1034
1035     Function:  USTR_CNTL_MALLOC_CHECK_DEL()
1036       Returns: Success or failure
1037       Type: int
1038
1039       Parameter[1]: Condition to end malloc checking or not
1040       Type[1]: int
1041
1042       Explanation:
1043
1044         This function works like USTR_CNTL_MALLOC_CHECK_END() but it fails if
1045       the  condition  check  (Parameter[1])  fails,  or   if   USTR_CNTL_MAL‐
1046       LOC_CHECK_LVL() is one.
1047
1048       Note:
1049
1050         The condition (Parameter[1]) to this macro should almost certainly be
1051       the return value from USTR_CNTL_MALLOC_CHECK_ADD().
1052
1053

Creating allocated Ustr functions

1055     Function:  ustr_init_size()
1056       Returns: Size that needs to be allocated
1057       Type: size_t
1058
1059       Parameter[1]: Size of allocated storage
1060       Type[1]: size_t
1061
1062       Parameter[2]: Number of bytes to use for reference count
1063       Type[2]: size_t
1064
1065       Parameter[3]: Exact memory allocations
1066       Type[3]: int
1067
1068       Parameter[4]: Length of data in the Ustr
1069       Type[4]: size_t
1070
1071       Explanation:
1072
1073         This function finds out the exact size of memory needed to store  the
1074       specified Ustr of the given configuration.
1075
1076     Function:  ustr_init_alloc()
1077       Returns: Ustr string
1078       Type: struct Ustr *
1079
1080       Parameter[1]: Pointer to area of memory to use as a Ustr string
1081       Type[1]: void *
1082
1083       Parameter[2]: Size of area of memory
1084       Type[2]: size_t
1085
1086       Parameter[3]: Whether Ustr should store the size
1087       Type[3]: size_t
1088
1089       Parameter[4]: Number of bytes to use for references
1090       Type[4]: size_t
1091
1092       Parameter[5]: Whether the Ustr should use exact allocations
1093       Type[5]: int
1094
1095       Parameter[6]: Whether the Ustr should have the "enomem" flag set
1096       Type[6]: int
1097
1098       Parameter[7]: The initial length of the Ustr
1099       Type[7]: size_t
1100
1101       Explanation:
1102
1103         This  creates  a  new Ustr string, you should have allocated the data
1104       via.  USTR_CONF_MALLOC() or bad things will happen if the  Ustr  string
1105       is ever free'd or reallocated.
1106
1107     Function:  ustr_dupx_empty()
1108       Returns: Ustr string
1109       Type: struct Ustr *
1110
1111       Parameter[1]: Size of allocated storage
1112       Type[1]: size_t
1113
1114       Parameter[2]: Number of bytes to use for reference count
1115       Type[2]: size_t
1116
1117       Parameter[3]: Exact memory allocation flag
1118       Type[3]: int
1119
1120       Parameter[4]: ENOMEM, memory error flag
1121       Type[4]: int
1122
1123       Explanation:
1124
1125         This  function creates an empty Ustr, owned by you, that is allocated
1126       from system memory, or it returns NULL.
1127         The size is the desired allocation size for the entire Ustr,  includ‐
1128       ing  overhead  for metadata. This value will be rounded up, if it's too
1129       small, so passing 1 as the size means you want a  stored  size  but  to
1130       allocate the smallest amount of memory possible.
1131         The  exact memory allocation flag says if the Ustr should round allo‐
1132       cations up to the nearest half power of two or should be no  more  than
1133       needed.
1134         The ENOMEM memory error flag sets the iniital state of the user visi‐
1135       ble   flag   for   memory   allocation   errors.   Eg.   ustr_enomem(),
1136       ustr_setf_enomem_clr() and ustr_setf_enomem_err()
1137
1138       Note:
1139
1140         The  reference byte count can only be one of the following values: 0,
1141       1, 2 or 4, or 8 (on environments with a 64bit size_t).
1142         It can be useful to ensure that the Ustr is in system memory, so that
1143       you can add things to it and check for errors with ustr_enomem().
1144         If  you chose to store the allocated size in the Ustr then the number
1145       of bytes allocated for the reference count will be a minimum of 2.
1146
1147     Function:  ustr_dup_empty()
1148       Returns: Ustr string
1149       Type: struct Ustr *
1150
1151       Parameter[1]: Nothing
1152       Type[1]: void
1153
1154       Explanation:
1155
1156         This function is the same as calling ustr_dupx_empty() with the  cur‐
1157       rent set of default options.
1158
1159     Function:  ustr_dupx_undef()
1160       Returns: Ustr string
1161       Type: struct Ustr *
1162
1163       Parameter[1]: Size of allocated storage
1164       Type[1]: size_t
1165
1166       Parameter[2]: Number of bytes to use for reference count
1167       Type[2]: size_t
1168
1169       Parameter[3]: Exact memory allocations
1170       Type[3]: int
1171
1172       Parameter[4]: ENOMEM, memory error flag
1173       Type[4]: int
1174
1175       Parameter[5]: Length of new undefined data
1176       Type[5]: size_t
1177
1178       Explanation:
1179
1180         This  function  works  like  you  called  ustr_dupx_empty()  and then
1181       ustr_add_undef().
1182
1183     Function:  ustr_dup_undef()
1184       Returns: Pointer to a Ustr string
1185       Type: struct Ustr *
1186
1187       Parameter[1]: Length of new undefined data
1188       Type[1]: size_t
1189
1190       Explanation:
1191
1192         This function is the same as calling ustr_dupx_undef() with the  cur‐
1193       rent set of default options.
1194
1195     Function:  ustr_dup()
1196       Returns: A pointer to a Ustr string
1197       Type: struct Ustr *
1198
1199       Parameter[1]: Pointer to a constant Ustr string
1200       Type[1]: const struct Ustr *
1201
1202       Explanation:
1203
1204         This  function  tries  to  increase the reference count on the passed
1205       Ustr string, and if that succeeds returns that as an argument. If  that
1206       fails  it  tries  creates a new Ustr string that looks identical to the
1207       old Ustr string, apart from the reference count.
1208
1209       Note:
1210
1211         Because the new Ustr string is configured identically to the old Ustr
1212       string  this  means the result can be very different to what you get if
1213       you call ustr_dup_buf() with ustr_cstr() and ustr_len() from the origi‐
1214       nal string where the configuration would be whatever the default is.
1215         Esp.  worth  of  note is that if you ustr_dup() a Ustr string with an
1216       explicit size of 900 but a length of 1, and the reference count is full
1217       the returned Ustr string will have a size of 900 bytes and so will have
1218       allocated a little over that. ustr_dup_buf(), even with a sized config‐
1219       uration  would  only  allocate  about 12 bytes and have a size a little
1220       less than that.
1221
1222     Function:  ustr_dupx()
1223       Returns: Pointer to a Ustr string
1224       Type: struct Ustr *
1225
1226       Parameter[1]: Size of allocated storage
1227       Type[1]: size_t
1228
1229       Parameter[2]: Number of bytes to use for reference count
1230       Type[2]: size_t
1231
1232       Parameter[3]: Exact memory allocations
1233       Type[3]: int
1234
1235       Parameter[4]: ENOMEM, memory error flag
1236       Type[4]: int
1237
1238       Parameter[5]: Pointer to a constant Ustr string
1239       Type[5]: const struct Ustr *
1240
1241       Explanation:
1242
1243         This function tries to add a reference if the value of the size, ref‐
1244       erence bytes, exact memory allocations and ENOMEM are the same as those
1245       in the passed Ustr string (Parameter[5]). If the  comparison  fails  or
1246       the  addition  of a reference fails it works like ustr_dupx_buf() using
1247       ustr_cstr() and ustr_len().
1248
1249     Function:  ustr_sc_dup()
1250       Returns: A pointer to a Ustr string
1251       Type: struct Ustr *
1252
1253       Parameter[1]: A pointer to a pointer to a Ustr string
1254       Type[1]: struct Ustr **
1255
1256       Explanation:
1257
1258         This function works like calling ustr_dup(),  but  if  the  reference
1259       count  is  maxed  out  then and so a new Ustr string has been allocated
1260       then that is stored in the passed argument (Parameter[1]) and the "old"
1261       Ustr string is returned.
1262
1263       Note:
1264
1265         The  reason  to  use  this  is  that if you have a "main" Ustr string
1266       pointer that a lot of things are getting references too then  when  the
1267       reference  count  maxes  out  you'll  degrade into worst case behaviour
1268       which acts as though there are no reference counts. This function stops
1269       that problem.
1270         As  an example, if you have a 1 byte reference count and have 255 * 2
1271       references then using ustr_dup() will create  256  Ustr  strings  using
1272       this function will create 4 Ustr strings.
1273
1274     Function:  ustr_sc_dupx()
1275       Returns: Pointer to a Ustr string
1276       Type: struct Ustr *
1277
1278       Parameter[1]: Size of allocated storage
1279       Type[1]: size_t
1280
1281       Parameter[2]: Number of bytes to use for reference count
1282       Type[2]: size_t
1283
1284       Parameter[3]: Exact memory allocations
1285       Type[3]: int
1286
1287       Parameter[4]: ENOMEM, memory error flag
1288       Type[4]: int
1289
1290       Parameter[5]: A pointer to a pointer to a Ustr string
1291       Type[5]: struct Ustr **
1292
1293       Explanation:
1294
1295         This  function  works  like calling ustr_dupx(), but if the reference
1296       count is maxed out then and so a new Ustr string is allocated then that
1297       is  stored  in  the  passed  argument (Parameter[1]) and the "old" Ustr
1298       string is returned.
1299         If the configurations of the new Ustr string and the old Ustr  string
1300       are not the same, this function works identically to ustr_dupx().
1301
1302       Note:
1303
1304         The  reason  to  use  this  is  that if you have a "main" Ustr string
1305       pointer that a lot of things are getting references too then  when  the
1306       reference  count  maxes  out  you'll  degrade into worst case behaviour
1307       which acts as though there are no reference counts. This function stops
1308       that problem.
1309         As  an example, if you have a 1 byte reference count and have 255 * 2
1310       references then using ustr_dupx() will create 256  Ustr  strings  using
1311       this function will create 4 Ustr strings.
1312
1313     Function:  ustr_dup_buf()
1314       Returns: A pointer to a Ustr string
1315       Type: struct Ustr *
1316
1317       Parameter[1]: Pointer to data
1318       Type[1]: const void *
1319
1320       Parameter[2]: Length of data
1321       Type[2]: size_t
1322
1323       Explanation:
1324
1325         This  function  works  as if you had called ustr_dup_undef() and then
1326       copied the data into the new undefined space.
1327
1328     Function:  ustr_dupx_buf()
1329       Returns: Pointer to a Ustr string
1330       Type: struct Ustr *
1331
1332       Parameter[1]: Size of allocated storage
1333       Type[1]: size_t
1334
1335       Parameter[2]: Number of bytes to use for reference count
1336       Type[2]: size_t
1337
1338       Parameter[3]: Exact memory allocations
1339       Type[3]: int
1340
1341       Parameter[4]: ENOMEM, memory error flag
1342       Type[4]: int
1343
1344       Parameter[5]: Pointer to data
1345       Type[5]: const void *
1346
1347       Parameter[6]: Length of data
1348       Type[6]: size_t
1349
1350       Explanation:
1351
1352         This function works as if you had called ustr_dupx_undef()  and  then
1353       copied the data into the new undefined space.
1354
1355     Function:  ustr_dup_cstr()
1356       Returns: A pointer to a Ustr string
1357       Type: struct Ustr *
1358
1359       Parameter[1]: Pointer to constant C-style string
1360       Type[1]: const char *
1361
1362       Explanation:
1363
1364         This  function  works  as if you had called ustr_dup_buf() and passed
1365       strlen() as the length.
1366
1367     Function:  ustr_dupx_cstr()
1368       Returns: Pointer to a Ustr string
1369       Type: struct Ustr *
1370
1371       Parameter[1]: Size of allocated storage
1372       Type[1]: size_t
1373
1374       Parameter[2]: Number of bytes to use for reference count
1375       Type[2]: size_t
1376
1377       Parameter[3]: Exact memory allocations
1378       Type[3]: int
1379
1380       Parameter[4]: ENOMEM, memory error flag
1381       Type[4]: int
1382
1383       Parameter[5]: Pointer to constant C-style string
1384       Type[5]: const char *
1385
1386       Explanation:
1387
1388         This function works as if you had called ustr_dupx_buf()  and  passed
1389       strlen() as the length.
1390
1391     Function:  USTR_DUP_OSTR()
1392       Returns: A pointer to a Ustr string
1393       Type: struct Ustr *
1394
1395       Parameter[1]: A constant C-style string
1396       Type[1]: const char []
1397
1398       Explanation:
1399
1400         This  function  works  as if you had called ustr_dup_buf() and passed
1401       sizeof() - 1 as the length.
1402
1403     Function:  USTR_DUP_OBJ()
1404       Returns: A pointer to a Ustr string
1405       Type: struct Ustr *
1406
1407       Parameter[1]: A symbol
1408       Type[1]: ...
1409
1410       Explanation:
1411
1412         This function works as if you had called  ustr_dup_buf()  and  passed
1413       sizeof() as the length.
1414
1415       Note:
1416
1417         In most cases you'll want to use USTR_DUP_OSTR().
1418
1419     Function:  ustr_dup_subustr()
1420       Returns: A pointer to a Ustr string
1421       Type: struct Ustr *
1422
1423       Parameter[1]: A pointer to a constant Ustr string
1424       Type[1]: const struct Ustr *
1425
1426       Parameter[2]: Position in the Ustr
1427       Type[2]: size_t
1428
1429       Parameter[3]: Length to add from the Ustr
1430       Type[3]: size_t
1431
1432       Explanation:
1433
1434         This  function  mostly works as if you had called ustr_dup_buf() with
1435       the ustr_cstr() + position - 1 and length values of the Ustr string  to
1436       be added.
1437
1438       Note:
1439
1440         If  the position is 1 and the length is the length of the Ustr string
1441       then it just calls ustr_dup().
1442
1443     Function:  ustr_dupx_subustr()
1444       Returns: Pointer to a Ustr string
1445       Type: struct Ustr *
1446
1447       Parameter[1]: Size of allocated storage
1448       Type[1]: size_t
1449
1450       Parameter[2]: Number of bytes to use for reference count
1451       Type[2]: size_t
1452
1453       Parameter[3]: Exact memory allocations
1454       Type[3]: int
1455
1456       Parameter[4]: ENOMEM, memory error flag
1457       Type[4]: int
1458
1459       Parameter[5]: A pointer to a constant Ustr string
1460       Type[5]: const struct Ustr *
1461
1462       Parameter[6]: Position in the Ustr
1463       Type[6]: size_t
1464
1465       Parameter[7]: Length to add from the Ustr
1466       Type[7]: size_t
1467
1468       Explanation:
1469
1470         This function mostly works as if you had called ustr_dupx_buf()  with
1471       the  ustr_cstr() + position - 1 and length values of the Ustr string to
1472       be added.
1473
1474       Note:
1475
1476         If the position is 1 and the length is the length of the Ustr  string
1477       then it just calls ustr_dupx().
1478
1479     Function:  ustr_dup_rep_chr()
1480       Returns: A pointer to a Ustr string
1481       Type: struct Ustr *
1482
1483       Parameter[1]: Byte value of data
1484       Type[1]: char
1485
1486       Parameter[2]: Length of bytes as data
1487       Type[2]: size_t
1488
1489       Explanation:
1490
1491         This  function  works  as if you had called ustr_dup_undef() and then
1492       copied the byte value to each position.
1493
1494     Function:  ustr_dupx_rep_chr()
1495       Returns: Pointer to a Ustr string
1496       Type: struct Ustr *
1497
1498       Parameter[1]: Size of allocated storage
1499       Type[1]: size_t
1500
1501       Parameter[2]: Number of bytes to use for reference count
1502       Type[2]: size_t
1503
1504       Parameter[3]: Exact memory allocations
1505       Type[3]: int
1506
1507       Parameter[4]: ENOMEM, memory error flag
1508       Type[4]: int
1509
1510       Parameter[5]: Byte value of data
1511       Type[5]: char
1512
1513       Parameter[6]: Length of bytes as data
1514       Type[6]: size_t
1515
1516       Explanation:
1517
1518         This function works as if you had called ustr_dupx_undef()  and  then
1519       copied the byte value to each position.
1520
1521     Function:  ustr_sc_vjoin()
1522       Returns: Pointer to a Ustr string
1523       Type: struct Ustr *
1524
1525       Parameter[1]: Separator to go between Ustr strings
1526       Type[1]: const struct Ustr *
1527
1528       Parameter[2]: A pointer to the first constant Ustr string
1529       Type[2]: const struct Ustr *
1530
1531       Parameter[3]: A pointer to the second constant Ustr string
1532       Type[3]: const struct Ustr *
1533
1534       Parameter[4]: Variable argument list variable, from va_start()
1535       Type[4]: va_list
1536
1537       Explanation:
1538
1539         This  function  works  as  if you called ustr_dup() on the first Ustr
1540       string (Parameter[2]), and then ustr_add() on  the  separator  (Parame‐
1541       ter[1])  followed  by  ustr_add()  on  the  second Ustr string (Parame‐
1542       ter[3]). This process then repeats for all  the  Ustr  strings  in  the
1543       variable argument list (Parameter[4]) until a USTR_NULL is reached.
1544
1545       Note:
1546
1547         This  function  doesn't  guarantee to just take a reference to one of
1548       the passed Ustr strings, even if that  is  what  would  happen  if  you
1549       called the above manually.
1550
1551     Function:  ustr_sc_join()
1552       Returns: Pointer to a Ustr string
1553       Type: struct Ustr *
1554
1555       Parameter[1]: Separator to go between Ustr strings
1556       Type[1]: const struct Ustr *
1557
1558       Parameter[2]: A pointer to the first constant Ustr string
1559       Type[2]: const struct Ustr *
1560
1561       Parameter[3]: A pointer to the second constant Ustr string
1562       Type[3]: const struct Ustr *
1563
1564       Parameter[4]:  Zero  or more pointers to constant Ustr strings and then
1565       USTR_NULL
1566       Type[4]: ...
1567
1568       Explanation:
1569
1570         This function calls va_start() to get a variable  argument  list  and
1571       then calls ustr_sc_vjoin().
1572
1573       Note:
1574
1575         This  function  doesn't  guarantee to just take a reference to one of
1576       the passed Ustr strings, even if that  is  what  would  happen  if  you
1577       called the above manually.
1578
1579     Function:  ustr_sc_vjoinx()
1580       Returns: Pointer to a Ustr string
1581       Type: struct Ustr *
1582
1583       Parameter[1]: Size of allocated storage
1584       Type[1]: size_t
1585
1586       Parameter[2]: Number of bytes to use for reference count
1587       Type[2]: size_t
1588
1589       Parameter[3]: Exact memory allocations
1590       Type[3]: int
1591
1592       Parameter[4]: ENOMEM, memory error flag
1593       Type[4]: int
1594
1595       Parameter[5]: Separator to go between Ustr strings
1596       Type[5]: const struct Ustr *
1597
1598       Parameter[6]: A pointer to the first constant Ustr string
1599       Type[6]: const struct Ustr *
1600
1601       Parameter[7]: A pointer to the second constant Ustr string
1602       Type[7]: const struct Ustr *
1603
1604       Parameter[8]: Variable argument list variable, from va_start()
1605       Type[8]: va_list
1606
1607       Explanation:
1608
1609         This  function  works  as if you called ustr_dupx() on the first Ustr
1610       string (Parameter[2]), and then ustr_add() on  the  separator  (Parame‐
1611       ter[1])  followed  by  ustr_add()  on  the  second Ustr string (Parame‐
1612       ter[3]). This process then repeats for all  the  Ustr  strings  in  the
1613       variable argument list (Parameter[4]) until a USTR_NULL is reached.
1614
1615       Note:
1616
1617         This  function  doesn't  guarantee to just take a reference to one of
1618       the passed Ustr strings, even if that  is  what  would  happen  if  you
1619       called the above manually.
1620
1621     Function:  ustr_sc_joinx()
1622       Returns: Pointer to a Ustr string
1623       Type: struct Ustr *
1624
1625       Parameter[1]: Size of allocated storage
1626       Type[1]: size_t
1627
1628       Parameter[2]: Number of bytes to use for reference count
1629       Type[2]: size_t
1630
1631       Parameter[3]: Exact memory allocations
1632       Type[3]: int
1633
1634       Parameter[4]: ENOMEM, memory error flag
1635       Type[4]: int
1636
1637       Parameter[5]: Separator to go between Ustr strings
1638       Type[5]: const struct Ustr *
1639
1640       Parameter[6]: A pointer to the first constant Ustr string
1641       Type[6]: const struct Ustr *
1642
1643       Parameter[7]: A pointer to the second constant Ustr string
1644       Type[7]: const struct Ustr *
1645
1646       Parameter[8]:  Zero  or more pointers to constant Ustr strings and then
1647       USTR_NULL
1648       Type[8]: ...
1649
1650       Explanation:
1651
1652         This function calls va_start() to get a variable  argument  list  and
1653       then calls ustr_sc_vjoinx().
1654
1655     Function:  ustr_sc_vconcat()
1656       Returns: Pointer to a Ustr string
1657       Type: struct Ustr *
1658
1659       Parameter[1]: A pointer to the first constant Ustr string
1660       Type[1]: const struct Ustr *
1661
1662       Parameter[2]: Variable argument list variable, from va_start()
1663       Type[2]: va_list
1664
1665       Explanation:
1666
1667         This  function  works  as  if you called ustr_dup() on the first Ustr
1668       string (Parameter[1]), and then ustr_add() on the  second  Ustr  string
1669       (Parameter[3]).  This  process then repeats for all the Ustr strings in
1670       the variable argument list (Parameter[4]) until a USTR_NULL is reached.
1671
1672       Note:
1673
1674         This function doesn't guarantee to just take a reference  to  one  of
1675       the  passed  Ustr  strings,  even  if  that is what would happen if you
1676       called the above manually.
1677
1678     Function:  ustr_sc_concat()
1679       Returns: Pointer to a Ustr string
1680       Type: struct Ustr *
1681
1682       Parameter[1]: A pointer to the first constant Ustr string
1683       Type[1]: const struct Ustr *
1684
1685       Parameter[2]: Zero or more pointers to constant Ustr strings  and  then
1686       USTR_NULL
1687       Type[2]: ...
1688
1689       Explanation:
1690
1691         This  function  calls  va_start() to get a variable argument list and
1692       then calls ustr_sc_vconcat().
1693
1694     Function:  ustr_sc_vconcatx()
1695       Returns: Pointer to a Ustr string
1696       Type: struct Ustr *
1697
1698       Parameter[1]: Size of allocated storage
1699       Type[1]: size_t
1700
1701       Parameter[2]: Number of bytes to use for reference count
1702       Type[2]: size_t
1703
1704       Parameter[3]: Exact memory allocations
1705       Type[3]: int
1706
1707       Parameter[4]: ENOMEM, memory error flag
1708       Type[4]: int
1709
1710       Parameter[5]: A pointer to the first constant Ustr string
1711       Type[5]: const struct Ustr *
1712
1713       Parameter[6]: Variable argument list variable, from va_start()
1714       Type[6]: va_list
1715
1716       Explanation:
1717
1718         This function works as if you called ustr_dupx() on  the  first  Ustr
1719       string  (Parameter[1]),  and  then ustr_add() on the second Ustr string
1720       (Parameter[3]). This process then repeats for all the Ustr  strings  in
1721       the variable argument list (Parameter[4]) until a USTR_NULL is reached.
1722
1723       Note:
1724
1725         This  function  doesn't  guarantee to just take a reference to one of
1726       the passed Ustr strings, even if that  is  what  would  happen  if  you
1727       called the above manually.
1728
1729     Function:  ustr_sc_concatx()
1730       Returns: Pointer to a Ustr string
1731       Type: struct Ustr *
1732
1733       Parameter[1]: Size of allocated storage
1734       Type[1]: size_t
1735
1736       Parameter[2]: Number of bytes to use for reference count
1737       Type[2]: size_t
1738
1739       Parameter[3]: Exact memory allocations
1740       Type[3]: int
1741
1742       Parameter[4]: ENOMEM, memory error flag
1743       Type[4]: int
1744
1745       Parameter[5]: A pointer to the first constant Ustr string
1746       Type[5]: const struct Ustr *
1747
1748       Parameter[6]:  Zero  or more pointers to constant Ustr strings and then
1749       USTR_NULL
1750       Type[6]: ...
1751
1752       Explanation:
1753
1754         This function calls va_start() to get a variable  argument  list  and
1755       then calls ustr_sc_vconcatx().
1756
1757

Deleting a Ustr, or data within a Ustr

1759     Function:  ustr_free()
1760       Returns: Nothing
1761       Type: void
1762
1763       Parameter[1]: Pointer to a Ustr
1764       Type[1]: struct Ustr *
1765
1766       Explanation:
1767
1768         This  function  decrements the reference count on a Ustr, if there is
1769       one, and free's it if it is allocated and the reference  count  becomes
1770       zero.
1771
1772       Note:
1773
1774         This function does nothing if passed USTR_NULL.
1775
1776     Function:  ustrp_free()
1777       Returns: Nothing
1778       Type: void
1779
1780       Parameter[1]: Pointer to a Ustr pool object
1781       Type[1]: struct Ustr_pool *
1782
1783       Parameter[2]: Pointer to a Ustrp (pool allocated Ustr)
1784       Type[2]: struct Ustrp *
1785
1786       Explanation:
1787
1788         This  function  works like ustr_free() but calls the pool_free member
1789       function of the Ustr_pool (Parameter[1]) instead  of  the  ustr  system
1790       free.
1791
1792     Function:  ustr_sc_free()
1793       Returns: Nothing
1794       Type: void
1795
1796       Parameter[1]: A pointer to a pointer to a Ustr string
1797       Type[1]: struct Ustr **
1798
1799       Explanation:
1800
1801         This  function  calls  ustr_free() and then sets the pointer (Parame‐
1802       ter[1]) to USTR_NULL, which is a noop when passed to ustr_free().  This
1803       can be used to help prevent "double free" errors.
1804
1805       Note:
1806
1807         While  the  point to the pointer must be non-NULL, this function also
1808       accepts a NULL ustr and does nothing. So you can pass the same  pointer
1809       to  this  function  multiple  times and only the first one will do any‐
1810       thing.
1811
1812     Function:  ustr_sc_free2()
1813       Returns: Nothing
1814       Type: void
1815
1816       Parameter[1]: A pointer to a pointer to a Ustr string
1817       Type[1]: struct Ustr **
1818
1819       Parameter[2]: Pointer to a Ustr string
1820       Type[2]: struct Ustr *
1821
1822       Explanation:
1823
1824         This function works like ustr_sc_free() but instead  of  setting  the
1825       pointer  (Parameter[1])  to  USTR_NULL  it  sets  it to the Ustr string
1826       (Parameter[2]).
1827
1828       Note:
1829
1830         While the point to the pointer must be non-NULL, this  function  also
1831       accepts  a NULL ustr to be free'd and does nothing. So you can pass the
1832       same pointer to ustr_sc_free() and then this function safely.
1833         The passed value (Parameter[2]) shouldn't be USTR_NULL, and in debug‐
1834       ging mode the function will assert() that it isn't.
1835
1836     Function:  ustr_sc_free_shared()
1837       Returns: Nothing
1838       Type: void
1839
1840       Parameter[1]: A pointer to a pointer to a Ustr string
1841       Type[1]: struct Ustr **
1842
1843       Explanation:
1844
1845         This  function  is a simple way to "free" a Ustr string that has been
1846       shared  (ustr_shared()  returns  USTR_TRUE),  normally  ustr_free()  is
1847       ignored  on  a  shared Ustr string. It just calls ustr_setf_owner() and
1848       then ustr_sc_free().
1849
1850     Function:  ustr_del()
1851       Returns: Success or failure
1852       Type: int
1853
1854       Parameter[1]: Pointer to a pointer to a Ustr string
1855       Type[1]: struct Ustr **
1856
1857       Parameter[2]: Length to delete from the Ustr
1858       Type[2]: size_t
1859
1860       Explanation:
1861
1862         This function deletes data from the end of Ustr,  possibly  re-sizing
1863       the Ustr at the same time.
1864
1865       Note:
1866
1867         The Ustr is never re-sized when the size is stored explicitly, so the
1868       pointer never changes.
1869
1870     Function:  ustr_del_subustr()
1871       Returns: Success or failure
1872       Type: int
1873
1874       Parameter[1]: Pointer to a pointer to a Ustr string
1875       Type[1]: struct Ustr **
1876
1877       Parameter[2]: Position in the Ustr
1878       Type[2]: size_t
1879
1880       Parameter[3]: Length to delete from the Ustr
1881       Type[3]:  size_t
1882
1883       Explanation:
1884
1885         This function works like ustr_del() but can delete an arbitrary  sec‐
1886       tion of the Ustr.
1887
1888     Function:  ustr_sc_del()
1889       Returns: Nothing
1890       Type: void
1891
1892       Parameter[1]: A pointer to a pointer to a Ustr string
1893       Type[1]: struct Ustr **
1894
1895       Explanation:
1896
1897         This  function  is  like  calling  ustr_del()  with ustr_len() as the
1898       length, however if that fails it does a ustr_free() and then  sets  the
1899       pointer to USTR("").
1900
1901       Note:
1902
1903         While  the benifit is that you don't have to check for memory failure
1904       errors, if there is a memory failure and you have a non-default config‐
1905       uration the configuration will revert back to the default.
1906
1907

Adding data to a Ustr

1909     Function:  ustr_add_undef()
1910       Returns: Success or failure
1911       Type: int
1912
1913       Parameter[1]: A pointer to a pointer to a Ustr string
1914       Type[1]: struct Ustr **
1915
1916       Parameter[2]: Length of new undefined data
1917       Type[2]: size_t
1918
1919       Explanation:
1920
1921         The  Ustr  string  is  expanded (possibly reallocated) so that it can
1922       contain length (Parameter[2]) extra data, if the length is not zero the
1923       Ustr will be writable. Or it'll return USTR_FALSE (zero) on failure.
1924
1925     Function:  ustr_add_buf()
1926       Returns: Success or failure
1927       Type: int
1928
1929       Parameter[1]: Pointer to a pointer to a Ustr string
1930       Type[1]: struct Ustr **
1931
1932       Parameter[2]: Pointer to data
1933       Type[2]: const void *
1934
1935       Parameter[3]: Length of data
1936       Type[3]: size_t
1937
1938       Explanation:
1939
1940         This  function  works  as if you had called ustr_add_undef() and then
1941       copied the data into the new undefined space.
1942
1943     Function:  ustr_add_cstr()
1944       Returns: Success or failure
1945       Type: int
1946
1947       Parameter[1]: Pointer to a pointer to a Ustr string
1948       Type[1]: struct Ustr **
1949
1950       Parameter[2]: Pointer to constant C-style string
1951       Type[2]: const char *
1952
1953       Explanation:
1954
1955         This function works as if you had called  ustr_add_buf()  and  passed
1956       strlen() as the length.
1957
1958     Function:  USTR_ADD_OSTR()
1959       Returns: Success or failure
1960       Type: int
1961
1962       Parameter[1]: Pointer to a pointer to a Ustr string
1963       Type[1]: struct Ustr **
1964
1965       Parameter[2]: A constant C-style string
1966       Type[2]: const char []
1967
1968       Explanation:
1969
1970         This  function  works  as if you had called ustr_add_buf() and passed
1971       sizeof() - 1 as the length.
1972
1973     Function:  USTR_ADD_OBJ()
1974       Returns: Success or failure
1975       Type: int
1976
1977       Parameter[1]: Pointer to a pointer to a Ustr string
1978       Type[1]: struct Ustr **
1979
1980       Parameter[2]: A symbol
1981       Type[2]: ...
1982
1983       Explanation:
1984
1985         This function works as if you had called  ustr_add_buf()  and  passed
1986       sizeof() as the length.
1987
1988       Note:
1989
1990         In most cases you'll want to use USTR_ADD_OSTR().
1991
1992     Function:  ustr_add()
1993       Returns: Success or failure
1994       Type: int
1995
1996       Parameter[1]: Pointer to a pointer to a Ustr string
1997       Type[1]: struct Ustr **
1998
1999       Parameter[2]: A pointer to a constant Ustr string
2000       Type[2]: const struct Ustr *
2001
2002       Explanation:
2003
2004         This  function  mostly works as if you had called ustr_add_buf() with
2005       the ustr_cstr() and ustr_len() values of the Ustr string to be added.
2006
2007       Note:
2008
2009         If the Ustr string is zero length and isn't  writable  this  function
2010       may  just add a reference, this is fine for Ustr strings that are "con‐
2011       stant" because if the Ustr is read-only then the  memory  will  not  be
2012       written to.
2013
2014     Function:  ustr_add_subustr()
2015       Returns: Success or failure
2016       Type: int
2017
2018       Parameter[1]: Pointer to a pointer to a Ustr string
2019       Type[1]: struct Ustr **
2020
2021       Parameter[2]: A pointer to a constant Ustr string
2022       Type[2]: const struct Ustr *
2023
2024       Parameter[3]: Position in the Ustr
2025       Type[3]: size_t
2026
2027       Parameter[4]: Length to add from the Ustr
2028       Type[4]: size_t
2029
2030       Explanation:
2031
2032         This  function  mostly works as if you had called ustr_add_buf() with
2033       the ustr_cstr() + position - 1 and length values of the Ustr string  to
2034       be  added.  The exception being if you add a ustr to itself, while only
2035       having a single reference count,  the  simple  method  would  access  a
2036       free'd ustr, but this function just works.
2037
2038       Note:
2039
2040         If  the position is 1 and the length is the length of the Ustr string
2041       then it just calls ustr_add().
2042
2043     Function:  ustr_add_rep_chr()
2044       Returns: Success or failure
2045       Type: int
2046
2047       Parameter[1]: Pointer to a pointer to a Ustr string
2048       Type[1]: struct Ustr **
2049
2050       Parameter[2]: Byte value of data
2051       Type[2]: char
2052
2053       Parameter[3]: Length of bytes as data
2054       Type[3]: size_t
2055
2056       Explanation:
2057
2058         This function works as if you had called  ustr_add_undef()  and  then
2059       copied the byte value to each position.
2060
2061

Setting a Ustr to some data

2063     Function:  ustr_set_undef()
2064       Returns: Success or failure
2065       Type: int
2066
2067       Parameter[1]: Pointer to a pointer to a Ustr string
2068       Type[1]: struct Ustr **
2069
2070       Parameter[2]:  size_t
2071       Type[2]:  size_t
2072
2073       Explanation:
2074
2075         This  function  works  as if you had called ustr_del() for the entire
2076       string and the ustr_add_undef().
2077
2078     Function:  ustr_set_empty()
2079       Returns: Success or failure
2080       Type: int
2081
2082       Parameter[1]: Pointer to a pointer to a Ustr string
2083       Type[1]: struct Ustr **
2084
2085       Explanation:
2086
2087         This function works as if you had called ustr_del()  for  the  entire
2088       string, however the string will be allocated if this completes.
2089
2090     Function:  ustr_set_buf()
2091       Returns: Success or failure
2092       Type: int
2093
2094       Parameter[1]: Pointer to a pointer to a Ustr string
2095       Type[1]: struct Ustr **
2096
2097       Parameter[2]: Buffer containting data
2098       Type[2]:  const void *
2099
2100       Parameter[3]: Length of Buffer
2101       Type[3]: size_t
2102
2103       Explanation:
2104
2105         This  function  works  as if you had called ustr_del() for the entire
2106       string and the ustr_add_buf().
2107
2108     Function:  ustr_set_cstr()
2109       Returns: Success or failure
2110       Type: int
2111
2112       Parameter[1]: Pointer to a pointer to a Ustr string
2113       Type[1]: struct Ustr **
2114
2115       Parameter[2]: A pointer to a constant C-style string
2116       Type[2]: const char *
2117
2118       Explanation:
2119
2120         This function works as if you had called ustr_del()  for  the  entire
2121       string and then ustr_add_cstr().
2122
2123     Function:  USTR_SET_OSTR()
2124       Returns: Success or failure
2125       Type: int
2126
2127       Parameter[1]: Pointer to a pointer to a Ustr string
2128       Type[1]: struct Ustr **
2129
2130       Parameter[2]: A constant C-style string
2131       Type[2]: const char []
2132
2133       Explanation:
2134
2135         This  function  works  as if you had called ustr_del() for the entire
2136       string and then USTR_ADD_OSTR().
2137
2138     Function:  USTR_SET_OBJ()
2139       Returns: Success or failure
2140       Type: int
2141
2142       Parameter[1]: Pointer to a pointer to a Ustr string
2143       Type[1]: struct Ustr **
2144
2145       Parameter[2]: A symbol
2146       Type[2]: ...
2147
2148       Explanation:
2149
2150         This function works as if you had called ustr_del()  for  the  entire
2151       string and then USTR_ADD_OBJ().
2152
2153       Note:
2154
2155         In most cases you'll want to use USTR_SET_OSTR().
2156
2157     Function:  ustr_set()
2158       Returns: Success or failure
2159       Type: int
2160
2161       Parameter[1]: Pointer to a pointer to a Ustr string
2162       Type[1]: struct Ustr **
2163
2164       Parameter[2]: A pointer to a constant Ustr string
2165       Type[2]: const struct Ustr *
2166
2167       Explanation:
2168
2169         This  function  works  as if you had called ustr_del() for the entire
2170       string and the ustr_add().
2171
2172     Function:  ustr_set_subustr()
2173       Returns: Success or failure
2174       Type: int
2175
2176       Parameter[1]: Pointer to a pointer to a Ustr string
2177       Type[1]: struct Ustr **
2178
2179       Parameter[2]: A pointer to a constant Ustr string
2180       Type[2]: const struct Ustr *
2181
2182       Parameter[3]: Position in the Ustr
2183       Type[3]: size_t
2184
2185       Parameter[4]: Length to set from the Ustr
2186       Type[4]: size_t
2187
2188       Explanation:
2189
2190         This function works as if you had called ustr_del()  for  the  entire
2191       string  and  the  ustr_add_subustr().  The exception being if you set a
2192       ustr to itself, while only having a single reference count, the  simple
2193       method would access a free'd ustr data, but this function just works.
2194
2195     Function:  ustr_set_rep_chr()
2196       Returns: Success or failure
2197       Type: int
2198
2199       Parameter[1]: Pointer to a pointer to a Ustr string
2200       Type[1]: struct Ustr **
2201
2202       Parameter[2]: Byte value of data
2203       Type[2]: char
2204
2205       Parameter[3]: Length of bytes as data
2206       Type[3]: size_t
2207
2208       Explanation:
2209
2210         This  function  works  as if you had called ustr_del() for the entire
2211       string and the ustr_add_rep_chr().
2212
2213

Inserting data into a Ustr

2215     Function:  ustr_ins_undef()
2216       Returns: Success or failure
2217       Type: int
2218
2219       Parameter[1]: A pointer to a pointer to a Ustr string
2220       Type[1]: struct Ustr **
2221
2222       Parameter[2]: Position after which the data should be added
2223       Type[2]: size_t
2224
2225       Parameter[3]: Length of new undefined data
2226       Type[3]: size_t
2227
2228       Explanation:
2229
2230         The Ustr string is expanded (possibly reallocated)  so  that  it  can
2231       contain length (Parameter[2]) extra data, from after the required posi‐
2232       tion. If the length is not zero the Ustr will  be  writable.  Or  it'll
2233       return  USTR_FALSE  (zero) on failure. The data in the Ustr is moved as
2234       needed to put the new data at position (Parameter[2]) + 1.
2235
2236     Function:  ustr_ins_buf()
2237       Returns: Success or failure
2238       Type: int
2239
2240       Parameter[1]: Pointer to a pointer to a Ustr string
2241       Type[1]: struct Ustr **
2242
2243       Parameter[2]: Position after which the data should be added
2244       Type[2]: size_t
2245
2246       Parameter[3]: Pointer to data
2247       Type[3]: const void *
2248
2249       Parameter[4]: Length of data
2250       Type[4]: size_t
2251
2252       Explanation:
2253
2254         This function works as if you had called  ustr_ins_undef()  and  then
2255       copied the data into the new undefined space.
2256
2257     Function:  ustr_ins_cstr()
2258       Returns: Success or failure
2259       Type: int
2260
2261       Parameter[1]: Pointer to a pointer to a Ustr string
2262       Type[1]: struct Ustr **
2263
2264       Parameter[2]: Position after which the data should be added
2265       Type[2]: size_t
2266
2267       Parameter[3]: Pointer to constant C-style string
2268       Type[3]: const char *
2269
2270       Explanation:
2271
2272         This  function  works  as if you had called ustr_ins_buf() and passed
2273       strlen() as the length.
2274
2275     Function:  USTR_INS_OSTR()
2276       Returns: Success or failure
2277       Type: int
2278
2279       Parameter[1]: Pointer to a pointer to a Ustr string
2280       Type[1]: struct Ustr **
2281
2282       Parameter[2]: Position after which the data should be added
2283       Type[2]: size_t
2284
2285       Parameter[3]: A constant C-style string
2286       Type[3]: const char []
2287
2288       Explanation:
2289
2290         This function works as if you had called  ustr_ins_buf()  and  passed
2291       sizeof() - 1 as the length.
2292
2293     Function:  USTR_INS_OBJ()
2294       Returns: Success or failure
2295       Type: int
2296
2297       Parameter[1]: Pointer to a pointer to a Ustr string
2298       Type[1]: struct Ustr **
2299
2300       Parameter[2]: Position after which the data should be added
2301       Type[2]: size_t
2302
2303       Parameter[3]: A symbol
2304       Type[3]: ...
2305
2306       Explanation:
2307
2308         This  function  works  as if you had called ustr_ins_buf() and passed
2309       sizeof() as the length.
2310
2311       Note:
2312
2313         In most cases you'll want to use USTR_INS_OSTR().
2314
2315     Function:  ustr_ins()
2316       Returns: Success or failure
2317       Type: int
2318
2319       Parameter[1]: Pointer to a pointer to a Ustr string
2320       Type[1]: struct Ustr **
2321
2322       Parameter[2]: Position after which the data should be added
2323       Type[2]: size_t
2324
2325       Parameter[3]: A pointer to a constant Ustr string
2326       Type[3]: const struct Ustr *
2327
2328       Explanation:
2329
2330         This function works as if you  had  called  ustr_ins_buf()  with  the
2331       ustr_cstr() and ustr_len() values of the Ustr string to be added.
2332
2333     Function:  ustr_ins_subustr()
2334       Returns: Success or failure
2335       Type: int
2336
2337       Parameter[1]: Pointer to a pointer to a Ustr string
2338       Type[1]: struct Ustr **
2339
2340       Parameter[2]: Position after which the data should be added
2341       Type[2]: size_t
2342
2343       Parameter[2]: A pointer to a constant Ustr string
2344       Type[2]: const struct Ustr *
2345
2346       Parameter[3]: Position in the Ustr
2347       Type[3]: size_t
2348
2349       Parameter[4]: Length to ins from the Ustr
2350       Type[4]: size_t
2351
2352       Explanation:
2353
2354         This  function  mostly  as  if you had called ustr_ins_buf() with the
2355       ustr_cstr() + position - 1 and length values of the Ustr string  to  be
2356       insed.  The  exception being if you insert a ustr to itself, while only
2357       having a single reference count,  the  simple  method  would  access  a
2358       free'd ustr data, but this function just works.
2359
2360     Function:  ustr_ins_rep_chr()
2361       Returns: Success or failure
2362       Type: int
2363
2364       Parameter[1]: Pointer to a pointer to a Ustr string
2365       Type[1]: struct Ustr **
2366
2367       Parameter[2]: Position after which the data should be added
2368       Type[2]: size_t
2369
2370       Parameter[2]: Byte value of data
2371       Type[2]: char
2372
2373       Parameter[3]: Length of bytes as data
2374       Type[3]: size_t
2375
2376       Explanation:
2377
2378         This  function  works  as if you had called ustr_ins_undef() and then
2379       copied the byte value to each position.
2380
2381

Adding, duplicating and setting formatted data to a Ustr

2383     Function:  ustr_add_vfmt_lim()
2384       Returns: Success or failure
2385       Type: int
2386
2387       Parameter[1]: A pointer to a pointer to a Ustr string
2388       Type[1]: struct Ustr **
2389
2390       Parameter[2]: Limit of data to add
2391       Type[2]: size_t
2392
2393       Parameter[3]: A pointer to a constant C-style string
2394       Type[3]: const char *
2395
2396       Parameter[4]: Variable argument list variable, from va_start()
2397       Type[4]: va_list
2398
2399       Explanation:
2400
2401         This function works like calling  the  system  vsnprintf()  with  the
2402       limit  (Parameter[2])  as  the  limit  to  vsnprintf() and then calling
2403       ustr_add_buf().
2404
2405     Function:  ustr_add_vfmt()
2406       Returns: Success or failure
2407       Type: int
2408
2409       Parameter[1]: A pointer to a pointer to a Ustr string
2410       Type[1]: struct Ustr **
2411
2412       Parameter[2]: A pointer to a constant C-style string
2413       Type[2]: const char *
2414
2415       Parameter[3]: Variable argument list variable, from va_start()
2416       Type[3]: va_list
2417
2418       Explanation:
2419
2420         This function works like calling  the  system  vsnprintf()  and  then
2421       calling ustr_add_buf().
2422
2423     Function:  ustr_add_fmt_lim()
2424       Returns: Success or failure
2425       Type: int
2426
2427       Parameter[1]: A pointer to a pointer to a Ustr string
2428       Type[1]: struct Ustr **
2429
2430       Parameter[2]: Limit of data to add
2431       Type[2]: size_t
2432
2433       Parameter[3]: A pointer to a constant C-style string
2434       Type[3]: const char *
2435
2436       Parameter[4]: Options depending on value of Parameter[3]
2437       Type[4]: ...
2438
2439       Explanation:
2440
2441         This function works like calling the system snprintf() with the limit
2442       (Parameter[2])  as  the  limit   to   snprintf()   and   then   calling
2443       ustr_add_buf().
2444
2445     Function:  ustr_add_fmt()
2446       Returns: Success or failure
2447       Type: int
2448
2449       Parameter[1]: A pointer to a pointer to a Ustr string
2450       Type[1]: struct Ustr **
2451
2452       Parameter[2]: A pointer to a constant C-style string
2453       Type[2]: const char *
2454
2455       Parameter[3]: Options depending on value of Parameter[2]
2456       Type[3]: ...
2457
2458       Explanation:
2459
2460         This function works like calling the system snprintf() and then call‐
2461       ing ustr_add_buf().
2462
2463     Function:  ustr_dup_vfmt_lim()
2464       Returns: Pointer to a Ustr string
2465       Type: struct Ustr *
2466
2467       Parameter[1]: Limit of data to dup
2468       Type[1]: size_t
2469
2470       Parameter[2]: Pointer to a constant Ustr string
2471       Type[2]: const char *
2472
2473       Parameter[3]: Variable argument list variable, from va_start()
2474       Type[3]: va_list
2475
2476       Explanation:
2477
2478         This function works like calling  the  system  vsnprintf()  with  the
2479       limit  (Parameter[2])  as  the  limit  to  vsnprintf() and then calling
2480       ustr_dup_buf().
2481
2482     Function:  ustr_dup_vfmt()
2483       Returns: Pointer to a Ustr string
2484       Type: struct Ustr *
2485
2486       Parameter[1]: Limit of data to dup
2487       Type[1]: size_t
2488
2489       Parameter[2]: Pointer to a constant Ustr string
2490       Type[2]: const char *
2491
2492       Parameter[3]: Variable argument list variable, from va_start()
2493       Type[3]: va_list
2494
2495       Explanation:
2496
2497         This function works like calling  the  system  vsnprintf()  and  then
2498       calling ustr_dup_buf().
2499
2500     Function:  ustr_dup_fmt_lim()
2501       Returns: Pointer to a Ustr string
2502       Type: struct Ustr *
2503
2504       Parameter[1]: Limit of data to dup
2505       Type[1]: size_t
2506
2507       Parameter[2]: Pointer to a constant Ustr string
2508       Type[2]: const char *
2509
2510       Parameter[3]: Options depending on value of Parameter[2]
2511       Type[3]: ...
2512
2513       Explanation:
2514
2515         This function works like calling the system snprintf() with the limit
2516       (Parameter[2])  as  the  limit   to   snprintf()   and   then   calling
2517       ustr_dup_buf().
2518
2519     Function:  ustr_dup_fmt()
2520       Returns: Pointer to a Ustr string
2521       Type: struct Ustr *
2522
2523       Parameter[1]: Pointer to a constant Ustr string
2524       Type[1]: const char *
2525
2526       Parameter[2]: Options depending on value of Parameter[1]
2527       Type[2]: ...
2528
2529       Explanation:
2530
2531         This function works like calling the system snprintf() and then call‐
2532       ing ustr_dup_buf().
2533
2534     Function:  ustr_dupx_fmt_lim()
2535       Returns: Pointer to a Ustr string
2536       Type: struct Ustr *
2537
2538       Parameter[1]: Size of allocated storage
2539       Type[1]: size_t
2540
2541       Parameter[2]: Number of bytes to use for reference count
2542       Type[2]: size_t
2543
2544       Parameter[3]: Exact memory allocations
2545       Type[3]: int
2546
2547       Parameter[4]: ENOMEM, memory error flag
2548       Type[4]: int
2549
2550       Parameter[5]: Limit of data to dup
2551       Type[5]: size_t
2552
2553       Parameter[6]: Pointer to a constant Ustr string
2554       Type[6]: const char *
2555
2556       Parameter[7]: Options depending on value of Parameter[6]
2557       Type[7]: ...
2558
2559       Explanation:
2560
2561         This function works like calling the system snprintf() with the limit
2562       (Parameter[2])   as   the   limit   to   snprintf()  and  then  calling
2563       ustr_dupx_buf().
2564
2565     Function:  ustr_dupx_fmt()
2566       Returns: Pointer to a Ustr string
2567       Type: struct Ustr *
2568
2569       Parameter[1]: Size of allocated storage
2570       Type[1]: size_t
2571
2572       Parameter[2]: Number of bytes to use for reference count
2573       Type[2]: size_t
2574
2575       Parameter[3]: Exact memory allocations
2576       Type[3]: int
2577
2578       Parameter[4]: ENOMEM, memory error flag
2579       Type[4]: int
2580
2581       Parameter[5]: Pointer to a constant Ustr string
2582       Type[5]: const char *
2583
2584       Parameter[6]: Options depending on value of Parameter[5]
2585       Type[6]: ...
2586
2587       Explanation:
2588
2589         This function works like calling the system snprintf() and then call‐
2590       ing ustr_dup_bufx().
2591
2592     Function:  ustr_set_vfmt_lim()
2593       Returns: Success or failure
2594       Type: int
2595
2596       Parameter[1]: A pointer to a pointer to a Ustr string
2597       Type[1]: struct Ustr **
2598
2599       Parameter[2]: Limit of data to set
2600       Type[2]: size_t
2601
2602       Parameter[3]: A pointer to a constant C-style string
2603       Type[3]: const char *
2604
2605       Parameter[4]: Variable argument list variable, from va_start()
2606       Type[4]: va_list
2607
2608       Explanation:
2609
2610         This function works like calling ustr_del() for all the data and then
2611       ustr_add_vfmt_lim().
2612
2613     Function:  ustr_set_vfmt()
2614       Returns: Success or failure
2615       Type: int
2616
2617       Parameter[1]: A pointer to a pointer to a Ustr string
2618       Type[1]: struct Ustr **
2619
2620       Parameter[2]: A pointer to a constant C-style string
2621       Type[2]: const char *
2622
2623       Parameter[3]: Variable argument list variable, from va_start()
2624       Type[3]: va_list
2625
2626       Explanation:
2627
2628         This function works like calling ustr_del() for all the data and then
2629       ustr_add_vfmt().
2630
2631     Function:  ustr_set_fmt_lim()
2632       Returns: Success or failure
2633       Type: int
2634
2635       Parameter[1]: A pointer to a pointer to a Ustr string
2636       Type[1]: struct Ustr **
2637
2638       Parameter[2]: Limit of data to set
2639       Type[2]: size_t
2640
2641       Parameter[3]: A pointer to a constant C-style string
2642       Type[3]: const char *
2643
2644       Parameter[4]: Options depending on value of Parameter[3]
2645       Type[4]: ...
2646
2647       Explanation:
2648
2649         This function works like calling ustr_del() for all the data and then
2650       ustr_add_fmt_lim().
2651
2652     Function:  ustr_set_fmt()
2653       Returns: Success or failure
2654       Type: int
2655
2656       Parameter[1]: A pointer to a pointer to a Ustr string
2657       Type[1]: struct Ustr **
2658
2659       Parameter[2]: A pointer to a constant C-style string
2660       Type[2]: const char *
2661
2662       Parameter[3]: Options depending on value of Parameter[2]
2663       Type[3]: ...
2664
2665       Explanation:
2666
2667         This function works like calling ustr_del() for all the data and then
2668       ustr_add_fmt().
2669
2670     Function:  ustr_ins_vfmt_lim()
2671       Returns: Success or failure
2672       Type: int
2673
2674       Parameter[1]: A pointer to a pointer to a Ustr string
2675       Type[1]: struct Ustr **
2676
2677       Parameter[2]: Position after which the data should be added
2678       Type[2]: size_t
2679
2680       Parameter[3]: Limit of data to insert
2681       Type[3]: size_t
2682
2683       Parameter[4]: A pointer to a constant C-style string
2684       Type[4]: const char *
2685
2686       Parameter[5]: Variable argument list variable, from va_start()
2687       Type[5]: va_list
2688
2689       Explanation:
2690
2691         This  function  works  like  calling  the system vsnprintf() with the
2692       limit (Parameter[3]) as the  limit  to  vsnprintf()  and  then  calling
2693       ustr_ins_buf().
2694
2695     Function:  ustr_ins_vfmt()
2696       Returns: Success or failure
2697       Type: int
2698
2699       Parameter[1]: A pointer to a pointer to a Ustr string
2700       Type[1]: struct Ustr **
2701
2702       Parameter[2]: Position after which the data should be added
2703       Type[2]: size_t
2704
2705       Parameter[3]: A pointer to a constant C-style string
2706       Type[3]: const char *
2707
2708       Parameter[4]: Variable argument list variable, from va_start()
2709       Type[4]: va_list
2710
2711       Explanation:
2712
2713         This  function  works  like  calling  the system vsnprintf() and then
2714       calling ustr_ins_buf().
2715
2716     Function:  ustr_ins_fmt_lim()
2717       Returns: Success or failure
2718       Type: int
2719
2720       Parameter[1]: A pointer to a pointer to a Ustr string
2721       Type[1]: struct Ustr **
2722
2723       Parameter[2]: Position after which the data should be added
2724       Type[2]: size_t
2725
2726       Parameter[3]: Limit of data to insert
2727       Type[3]: size_t
2728
2729       Parameter[4]: A pointer to a constant C-style string
2730       Type[4]: const char *
2731
2732       Parameter[5]: Options depending on value of Parameter[4]
2733       Type[5]: ...
2734
2735       Explanation:
2736
2737         This function works like calling the system snprintf() with the limit
2738       (Parameter[3])   as   the   limit   to   snprintf()  and  then  calling
2739       ustr_ins_buf().
2740
2741     Function:  ustr_ins_fmt()
2742       Returns: Success or failure
2743       Type: int
2744
2745       Parameter[1]: A pointer to a pointer to a Ustr string
2746       Type[1]: struct Ustr **
2747
2748       Parameter[2]: Position after which the data should be added
2749       Type[2]: size_t
2750
2751       Parameter[3]: A pointer to a constant C-style string
2752       Type[3]: const char *
2753
2754       Parameter[4]: Options depending on value of Parameter[3]
2755       Type[4]: ...
2756
2757       Explanation:
2758
2759         This function works like calling the system snprintf() and then call‐
2760       ing ustr_ins_buf().
2761
2762     Function:  ustr_sub_vfmt_lim()
2763       Returns: Success or failure
2764       Type: int
2765
2766       Parameter[1]: A pointer to a pointer to a Ustr string
2767       Type[1]: struct Ustr **
2768
2769       Parameter[2]: Position where to start substitution
2770       Type[2]: size_t
2771
2772       Parameter[3]: Limit of data to substitute
2773       Type[3]: size_t
2774
2775       Parameter[4]: A pointer to a constant C-style string
2776       Type[4]: const char *
2777
2778       Parameter[5]: Variable argument list variable, from va_start()
2779       Type[5]: va_list
2780
2781       Explanation:
2782
2783         This  function  works  like  calling  the system vsnprintf() with the
2784       limit (Parameter[3]) as the  limit  to  vsnprintf()  and  then  calling
2785       ustr_sub_buf().
2786
2787     Function:  ustr_sub_vfmt()
2788       Returns: Success or failure
2789       Type: int
2790
2791       Parameter[1]: A pointer to a pointer to a Ustr string
2792       Type[1]: struct Ustr **
2793
2794       Parameter[2]: Position where to start substitution
2795       Type[2]: size_t
2796
2797       Parameter[3]: A pointer to a constant C-style string
2798       Type[3]: const char *
2799
2800       Parameter[4]: Variable argument list variable, from va_start()
2801       Type[4]: va_list
2802
2803       Explanation:
2804
2805         This  function  works  like  calling  the system vsnprintf() and then
2806       calling ustr_sub_buf().
2807
2808     Function:  ustr_sub_fmt_lim()
2809       Returns: Success or failure
2810       Type: int
2811
2812       Parameter[1]: A pointer to a pointer to a Ustr string
2813       Type[1]: struct Ustr **
2814
2815       Parameter[2]: Position where to start substitution
2816       Type[2]: size_t
2817
2818       Parameter[3]: Limit of data to substitute
2819       Type[3]: size_t
2820
2821       Parameter[4]: A pointer to a constant C-style string
2822       Type[4]: const char *
2823
2824       Parameter[5]: Options depending on value of Parameter[4]
2825       Type[5]: ...
2826
2827       Explanation:
2828
2829         This function works like calling the system snprintf() with the limit
2830       (Parameter[3])   as   the   limit   to   snprintf()  and  then  calling
2831       ustr_sub_buf().
2832
2833     Function:  ustr_sub_fmt()
2834       Returns: Success or failure
2835       Type: int
2836
2837       Parameter[1]: A pointer to a pointer to a Ustr string
2838       Type[1]: struct Ustr **
2839
2840       Parameter[2]: Position where to start substitution
2841       Type[2]: size_t
2842
2843       Parameter[3]: A pointer to a constant C-style string
2844       Type[3]: const char *
2845
2846       Parameter[4]: Options depending on value of Parameter[3]
2847       Type[4]: ...
2848
2849       Explanation:
2850
2851         This function works like calling the system snprintf() and then call‐
2852       ing ustr_sub_buf().
2853
2854     Function:  ustr_sc_sub_vfmt_lim()
2855       Returns: Success or failure
2856       Type: int
2857
2858       Parameter[1]: A pointer to a pointer to a Ustr string
2859       Type[1]: struct Ustr **
2860
2861       Parameter[2]: Position where to start substitution
2862       Type[2]: size_t
2863
2864       Parameter[3]: Length of substitution
2865       Type[3]: size_t
2866
2867       Parameter[4]: Limit of data to substitute
2868       Type[4]: size_t
2869
2870       Parameter[5]: A pointer to a constant C-style string
2871       Type[5]: const char *
2872
2873       Parameter[6]: Variable argument list variable, from va_start()
2874       Type[6]: va_list
2875
2876       Explanation:
2877
2878         This  function  works  like  calling  the system vsnprintf() with the
2879       limit (Parameter[4]) as the  limit  to  vsnprintf()  and  then  calling
2880       ustr_sc_sub_buf().
2881
2882     Function:  ustr_sc_sub_vfmt()
2883       Returns: Success or failure
2884       Type: int
2885
2886       Parameter[1]: A pointer to a pointer to a Ustr string
2887       Type[1]: struct Ustr **
2888
2889       Parameter[2]: Position where to start substitution
2890       Type[2]: size_t
2891
2892       Parameter[3]: Length of substitution
2893       Type[3]: size_t
2894
2895       Parameter[4]: A pointer to a constant C-style string
2896       Type[4]: const char *
2897
2898       Parameter[5]: Variable argument list variable, from va_start()
2899       Type[5]: va_list
2900
2901       Explanation:
2902
2903         This  function  works  like  calling  the system vsnprintf() and then
2904       calling ustr_sc_sub_buf().
2905
2906     Function:  ustr_sc_sub_fmt_lim()
2907       Returns: Success or failure
2908       Type: int
2909
2910       Parameter[1]: A pointer to a pointer to a Ustr string
2911       Type[1]: struct Ustr **
2912
2913       Parameter[2]: Position where to start substitution
2914       Type[2]: size_t
2915
2916       Parameter[3]: Length of substitution
2917       Type[3]: size_t
2918
2919       Parameter[4]: Limit of data to substitute
2920       Type[4]: size_t
2921
2922       Parameter[5]: A pointer to a constant C-style string
2923       Type[5]: const char *
2924
2925       Parameter[6]: Options depending on value of Parameter[5]
2926       Type[6]: ...
2927
2928       Explanation:
2929
2930         This function works like calling the system snprintf() with the limit
2931       (Parameter[3])   as   the   limit   to   snprintf()  and  then  calling
2932       ustr_sc_sub_buf().
2933
2934     Function:  ustr_sc_sub_fmt()
2935       Returns: Success or failure
2936       Type: int
2937
2938       Parameter[1]: A pointer to a pointer to a Ustr string
2939       Type[1]: struct Ustr **
2940
2941       Parameter[2]: Position where to start substitution
2942       Type[2]: size_t
2943
2944       Parameter[3]: Length of substitution
2945       Type[3]: size_t
2946
2947       Parameter[4]: A pointer to a constant C-style string
2948       Type[4]: const char *
2949
2950       Parameter[5]: Options depending on value of Parameter[5]
2951       Type[5]: ...
2952
2953       Explanation:
2954
2955         This function works like calling the system snprintf() and then call‐
2956       ing ustr_sc_sub_buf().
2957
2958

Accessing the variables of a Ustr

2960     Function:  ustr_len()
2961       Returns: The length of the Ustr
2962       Type: size_t
2963
2964       Parameter[1]: A pointer to a constant Ustr string
2965       Type[1]: const struct Ustr *
2966
2967       Explanation:
2968
2969         This  function  returns  the length of the data within the Ustr, much
2970       like strlen() but without getting the value wrong in the case of  extra
2971       NIL bytes.
2972
2973     Function:  ustr_cstr()
2974       Returns: Read-only pointer to the start of data in the Ustr
2975       Type: const char *
2976
2977       Parameter[1]: A pointer to a constant Ustr string
2978       Type[1]: const struct Ustr *
2979
2980       Explanation:
2981
2982         This function returns a read-only pointer to the start of the data of
2983       the Ustr string. Due to there always being a terminating NIL byte in  a
2984       Ustr, this is also a valid C-style string.
2985
2986     Function:  ustr_wstr()
2987       Returns: Writable pointer to the start of data in the Ustr, or NULL
2988       Type: char *
2989
2990       Parameter[1]: A pointer to a constant Ustr string
2991       Type[1]: struct Ustr *
2992
2993       Explanation:
2994
2995         This  function returns a writable pointer to the start of the data of
2996       the Ustr string. Due to there always being a terminating NIL byte in  a
2997       Ustr, this is also a valid C-style string.
2998         If  the ustr is read-only (ustr_ro() == USTR_TRUE) then this function
2999       will return NULL.
3000
3001       Note:
3002
3003         Unless the string is owned (ustr_owner() == USTR_TRUE) it  can  be  a
3004       very  bad  idea to use this to change data, as then all references will
3005       be updated. See ustr_sc_wstr().
3006
3007     Function:  ustr_alloc()
3008       Returns: A boolean flag of either USTR_TRUE or USTR_FALSE
3009       Type: int
3010
3011       Parameter[1]: A pointer to a constant Ustr string
3012       Type[1]: const struct Ustr *
3013
3014       Explanation:
3015
3016         This function says if the Ustr is currently in allocated storage.
3017
3018     Function:  ustr_exact()
3019       Returns: A boolean flag of either USTR_TRUE or USTR_FALSE
3020       Type: int
3021
3022       Parameter[1]: A pointer to a constant Ustr string
3023       Type[1]: const struct Ustr *
3024
3025       Explanation:
3026
3027         This function says if the Ustr is doing exact allocations, so as  the
3028       Ustr  grows it will only have storage allocated exactly as required and
3029       not in half powers of two.
3030
3031       Note:
3032
3033         This will always be USTR_FALSE for read-only Ustr strings  (ustr_ro()
3034       == USTR_TRUE), even though the default may be to used exact sized allo‐
3035       cations when  adding data to them etc.
3036
3037     Function:  ustr_sized()
3038       Returns: A boolean flag of either USTR_TRUE or USTR_FALSE
3039       Type: int
3040
3041       Parameter[1]: A pointer to a constant Ustr string
3042       Type[1]: const struct Ustr *
3043
3044       Explanation:
3045
3046         This function says if the Ustr stores an explicit allocation size, if
3047       not the size is implied as the next highest half power of two.
3048
3049     Function:  ustr_ro()
3050       Returns: A boolean flag of either USTR_TRUE or USTR_FALSE
3051       Type: int
3052
3053       Parameter[1]: A pointer to a constant Ustr string
3054       Type[1]: const struct Ustr *
3055
3056       Explanation:
3057
3058         This function says if the Ustr is current in read-only storage.
3059         Read-only  storage  is  not  writable  but  can  be  referenced  via.
3060       ustr_dup() an infinite amount of times.
3061
3062     Function:  ustr_fixed()
3063       Returns: A boolean flag of either USTR_TRUE or USTR_FALSE
3064       Type: int
3065
3066       Parameter[1]: A pointer to a constant Ustr string
3067       Type[1]: const struct Ustr *
3068
3069       Explanation:
3070
3071         This function says if the Ustr is current in fixed size storage.
3072         Fixed size storage is writable but cannot be referenced.
3073
3074       Note:
3075
3076         Fixed size storage always explicitly stores the size of the storage.
3077
3078     Function:  ustr_enomem()
3079       Returns: A boolean flag of either USTR_TRUE or USTR_FALSE
3080       Type: int
3081
3082       Parameter[1]: A pointer to a constant Ustr string
3083       Type[1]: const struct Ustr *
3084
3085       Explanation:
3086
3087         This function just returns the value of the user settable flag in the
3088       Ustr.  It  can  be  set  via.  ustr_setf_enomem_err()  and  cleared  by
3089       ustr_setf_enomem_clr().
3090         This function is automatically set to on whever a  memory  allocation
3091       failure happens for a Ustr.
3092
3093       Note:
3094
3095         If  a  Ustr is referenced multiple times, ustr_setf_enomem_err() will
3096       fail.
3097         This always fails for Ustr's in read-only storage.
3098
3099     Function:  ustr_shared()
3100       Returns: A boolean flag of either USTR_TRUE or USTR_FALSE
3101       Type: int
3102
3103       Parameter[1]: A pointer to a constant Ustr string
3104       Type[1]: const struct Ustr *
3105
3106       Explanation:
3107
3108         This function says if the Ustr is in the "shared" mode. It can be set
3109       via.  ustr_setf_shared()  and cleared by ustr_setf_owner() on allocated
3110       Ustr's.
3111         Shared mode means that a Ustr can be referenced and  unreferenced  an
3112       infinite number of times.
3113
3114       Note:
3115
3116         This always succeeds for Ustr's in read-only storage.
3117         This always fails for Ustr's in fixed size storage.
3118
3119     Function:  ustr_limited()
3120       Returns: A boolean flag of either USTR_TRUE or USTR_FALSE
3121       Type: int
3122
3123       Parameter[1]: A pointer to a constant Ustr string
3124       Type[1]: const struct Ustr *
3125
3126       Explanation:
3127
3128         This function says if the Ustr is currently in fixed size storage and
3129       cannot move to allocated storage.
3130
3131       Note:
3132
3133         This always fails for Ustr's in allocated storage.
3134         This always fails for Ustr's in read-only storage.
3135
3136     Function:  ustr_owner()
3137       Returns: A boolean flag of either USTR_TRUE or USTR_FALSE
3138       Type: int
3139
3140       Parameter[1]: A pointer to a constant Ustr string
3141       Type[1]: const struct Ustr *
3142
3143       Explanation:
3144
3145         This function says if there is only a single reference  to  the  Ustr
3146       string.
3147
3148       Note:
3149
3150         This always fails for Ustr's in read-only storage.
3151         This always succeeds for Ustr's in fixed size storage.
3152
3153     Function:  ustr_size()
3154       Returns: size_t
3155       Type: size_t
3156
3157       Parameter[1]: A pointer to a constant Ustr string
3158       Type[1]: const struct Ustr *
3159
3160       Explanation:
3161
3162         This  function  calculates  the  maximum amount of data that could be
3163       stored (Ie. the max ustr_len()) without  having  to  re-size  the  Ustr
3164       string.
3165
3166     Function:  ustr_size_alloc()
3167       Returns: size_t
3168       Type: size_t
3169
3170       Parameter[1]: A pointer to a constant Ustr string
3171       Type[1]: const struct Ustr *
3172
3173       Explanation:
3174
3175         This function returns the size of the storage for the Ustr.
3176
3177     Function:  ustr_size_overhead()
3178       Returns: size_t
3179       Type: size_t
3180
3181       Parameter[1]: A pointer to a constant Ustr string
3182       Type[1]: const struct Ustr *
3183
3184       Explanation:
3185
3186         This  function returns the difference between the size of the storage
3187       and the maximum amount of data that could be stored without  having  to
3188       re-size the Ustr string.
3189
3190     Function:  ustr_conf()
3191       Returns: Nothing
3192       Type: void
3193
3194       Parameter[1]: A pointer to a constant Ustr string
3195       Type[1]: const struct Ustr *
3196
3197       Parameter[2]: Return size allocated number
3198       Type[2]: size_t *
3199
3200       Parameter[3]: Return number of bytes used in the reference count
3201       Type[3]: size_t *
3202
3203       Parameter[4]: Return exact allocations flag
3204       Type[4]: int *
3205
3206       Parameter[5]: Return number of bytes used in the length
3207       Type[5]: size_t *
3208
3209       Parameter[5]: Return number of references to this Ustr
3210       Type[5]: size_t *
3211
3212       Explanation:
3213
3214         This  function  gives the configuration of the current Ustr needed to
3215       duplicate it via. the ustr_dupx_*() functions. It also gives the number
3216       of  bytes  used  for the length and the number of references, which are
3217       mainly informational.
3218
3219       Note:
3220
3221         This function differs from calling the ustr_exact() etc. functions in
3222       that  it  returns the global options if this Ustr isn't allocated, thus
3223       telling you what the configuration would be if the Ustr was turned into
3224       an allocated Ustr by adding data etc.
3225         Zero references for an allocated Ustr with a non-zero number of bytes
3226       for a reference count means it's in "shared" mode).
3227
3228

Setting the flags of a Ustr

3230     Function:  ustr_setf_enomem_err()
3231       Returns: Success or failure
3232       Type: int
3233
3234       Parameter[1]: A pointer to a Ustr string
3235       Type[1]: struct Ustr *
3236
3237       Explanation:
3238
3239         This function sets the enomem flag, which can be  observed  via.  the
3240       ustr_enomem() function.
3241         The  implication  of  setting  this  flag  is that a memory error has
3242       occured in a previous function call on this Ustr.
3243
3244       Note:
3245
3246         This function fails if ustr_owner() fails for the Ustr.
3247
3248     Function:  ustr_setf_enomem_clr()
3249       Returns: Success or failure
3250       Type: int
3251
3252       Parameter[1]: A pointer to a Ustr string
3253       Type[1]: struct Ustr *
3254
3255       Explanation:
3256
3257         This function clears the enomem flag, which can be observed via.  the
3258       ustr_enomem() function.
3259         The  implication  of  this  flag being set is that a memory error has
3260       occured in a previous function call on this Ustr, so  on  clearing  the
3261       flag you should know you have brought the Ustr back to a known state.
3262
3263       Note:
3264
3265         This function fails if ustr_owner() fails for the Ustr.
3266
3267     Function:  ustr_setf_share()
3268       Returns: Success or failure
3269       Type: int
3270
3271       Parameter[1]: A pointer to a Ustr string
3272       Type[1]: struct Ustr *
3273
3274       Explanation:
3275
3276         This  function  sets  the shared mode, which can be observed via. the
3277       ustr_shared() function.
3278         This is used on a Ustr so that it can have more references than it is
3279       able  to  hold in it's reference count. After this call the Ustr can be
3280       referenced and unreferenced an infinite number of times.
3281
3282       Note:
3283
3284         After  this   call   the   Ustr   will   never   be   deleted   until
3285       ustr_setf_owner() is called.
3286         This function fails if ustr_alloc() fails for the Ustr.
3287
3288     Function:  ustr_setf_owner()
3289       Returns: Success or failure
3290       Type: int
3291
3292       Parameter[1]: A pointer to a Ustr string
3293       Type[1]: struct Ustr *
3294
3295       Explanation:
3296
3297         This function removes the shared mode, which can be observed via. the
3298       ustr_shared() function.
3299         This is used so that a Ustr in shared mode can be free'd.
3300
3301       Note:
3302
3303         This function fails if ustr_alloc() fails for the Ustr.
3304
3305

Comparing data in a Ustr

3307     Function:  ustr_cmp_buf()
3308       Returns: Less then zero, zero or greater than zero depending on compar‐
3309       ison
3310       Type: int
3311
3312       Parameter[1]: A pointer to a constant Ustr string
3313       Type[1]: const struct Ustr *
3314
3315       Parameter[2]: A pointer to constant bytes, to compare
3316       Type[2]: const void *
3317
3318       Parameter[3]: Length of comparison bytes
3319       Type[3]: size_t
3320
3321       Explanation:
3322
3323         This function works like memcmp() on the Ustr and the passed data.
3324
3325     Function:  ustr_cmp()
3326       Returns: Less then zero, zero or greater than zero depending on compar‐
3327       ison
3328       Type: int
3329
3330       Parameter[1]: A pointer to a constant Ustr string
3331       Type[1]: const struct Ustr *
3332
3333       Parameter[2]: A pointer to a constant Ustr string
3334       Type[2]: const struct Ustr *
3335
3336       Explanation:
3337
3338         This function works  like  ustr_cmp_buf()  but  with  the  data  from
3339       ustr_cstr() and the length from ustr_len().
3340
3341     Function:  ustr_cmp_subustr()
3342       Returns: Less then zero, zero or greater than zero depending on compar‐
3343       ison
3344       Type: int
3345
3346       Parameter[1]: A pointer to a constant Ustr string
3347       Type[1]: const struct Ustr *
3348
3349       Parameter[2]: A pointer to a constant Ustr string
3350       Type[2]: const struct Ustr *
3351
3352       Parameter[3]: Position in the Ustr
3353       Type[3]: size_t
3354
3355       Parameter[4]: Length to compare from the Ustr
3356       Type[4]: size_t
3357
3358       Explanation:
3359
3360         This function works like ustr_cmp() but with a limit on the data  and
3361       length.
3362
3363     Function:  ustr_cmp_cstr()
3364       Returns: Less then zero, zero or greater than zero depending on compar‐
3365       ison
3366       Type: int
3367
3368       Parameter[1]: A pointer to a constant Ustr string
3369       Type[1]: const struct Ustr *
3370
3371       Parameter[2]: A pointer to a constant C-style string
3372       Type[2]: const char *
3373
3374       Explanation:
3375
3376         This function works  like  ustr_cmp_buf()  but  with  a  length  from
3377       strlen().
3378
3379     Function:  ustr_cmp_fast_buf()
3380       Returns: Less then zero, zero or greater than zero depending on compar‐
3381       ison
3382       Type: int
3383
3384       Parameter[1]: A pointer to a constant Ustr string
3385       Type[1]: const struct Ustr *
3386
3387       Parameter[2]: A pointer to constant bytes, to compare
3388       Type[2]: const void *
3389
3390       Parameter[3]: Length of comparison bytes
3391       Type[3]: size_t
3392
3393       Explanation:
3394
3395         This function works like ustr_cmp_buf() but the order  of  comparison
3396       is optimized for speed, but is much less friendly to humans.
3397
3398     Function:  ustr_cmp_fast()
3399       Returns: Less then zero, zero or greater than zero depending on compar‐
3400       ison
3401       Type: int
3402
3403       Parameter[1]: A pointer to a constant Ustr string
3404       Type[1]: const struct Ustr *
3405
3406       Parameter[2]: A pointer to a constant Ustr string
3407       Type[2]: const struct Ustr *
3408
3409       Explanation:
3410
3411         This function works like ustr_cmp_fast_buf() but with the  data  from
3412       ustr_cstr() and the length from ustr_len().
3413
3414     Function:  ustr_cmp_fast_subustr()
3415       Returns: Less then zero, zero or greater than zero depending on compar‐
3416       ison
3417       Type: int
3418
3419       Parameter[1]: A pointer to a constant Ustr string
3420       Type[1]: const struct Ustr *
3421
3422       Parameter[2]: A pointer to a constant Ustr string
3423       Type[2]: const struct Ustr *
3424
3425       Parameter[3]: Position in the Ustr
3426       Type[3]: size_t
3427
3428       Parameter[4]: Length to compare from the Ustr
3429       Type[4]: size_t
3430
3431       Explanation:
3432
3433         This function works like ustr_cmp_fast() but with a limit on the data
3434       and length.
3435
3436     Function:  ustr_cmp_fast_cstr()
3437       Returns: Less then zero, zero or greater than zero depending on compar‐
3438       ison
3439       Type: int
3440
3441       Parameter[1]: A pointer to a constant Ustr string
3442       Type[1]: const struct Ustr *
3443
3444       Parameter[2]: A pointer to a constant C-style string
3445       Type[2]: const char *
3446
3447       Explanation:
3448
3449         This function works like ustr_cmp_fast_buf() but with a  length  from
3450       strlen().
3451
3452     Function:  ustr_cmp_case_buf()
3453       Returns: Less then zero, zero or greater than zero depending on compar‐
3454       ison
3455       Type: int
3456
3457       Parameter[1]: A pointer to a constant Ustr string
3458       Type[1]: const struct Ustr *
3459
3460       Parameter[2]: A pointer to constant bytes, to compare
3461       Type[2]: const void *
3462
3463       Parameter[3]: Length of comparison bytes
3464       Type[3]: size_t
3465
3466       Explanation:
3467
3468         This function works like ustr_cmp_buf() but the order  of  comparison
3469       ignores ASCII case.
3470
3471     Function:  ustr_cmp_case()
3472       Returns: Less then zero, zero or greater than zero depending on compar‐
3473       ison
3474       Type: int
3475
3476       Parameter[1]: A pointer to a constant Ustr string
3477       Type[1]: const struct Ustr *
3478
3479       Parameter[2]: A pointer to a constant Ustr string
3480       Type[2]: const struct Ustr *
3481
3482       Explanation:
3483
3484         This function works like ustr_cmp_case_buf() but with the  data  from
3485       ustr_cstr() and the length from ustr_len().
3486
3487     Function:  ustr_cmp_case_subustr()
3488       Returns: Less then zero, zero or greater than zero depending on compar‐
3489       ison
3490       Type: int
3491
3492       Parameter[1]: A pointer to a constant Ustr string
3493       Type[1]: const struct Ustr *
3494
3495       Parameter[2]: A pointer to a constant Ustr string
3496       Type[2]: const struct Ustr *
3497
3498       Parameter[3]: Position in the Ustr
3499       Type[3]: size_t
3500
3501       Parameter[4]: Length to compare from the Ustr
3502       Type[4]: size_t
3503
3504       Explanation:
3505
3506         This function works like ustr_cmp_case() but with a limit on the data
3507       and length.
3508
3509     Function:  ustr_cmp_case_cstr()
3510       Returns: Less then zero, zero or greater than zero depending on compar‐
3511       ison
3512       Type: int
3513
3514       Parameter[1]: A pointer to a constant Ustr string
3515       Type[1]: const struct Ustr *
3516
3517       Parameter[2]: A pointer to a constant C-style string
3518       Type[2]: const char *
3519
3520       Explanation:
3521
3522         This function works like ustr_cmp_case_buf() but with a  length  from
3523       strlen().
3524
3525     Function:  ustr_cmp_eq()
3526       Returns: Success or failure
3527       Type: int
3528
3529       Parameter[1]: A pointer to a constant Ustr string
3530       Type[1]: const struct Ustr *
3531
3532       Parameter[2]: A pointer to a constant Ustr string
3533       Type[2]: const struct Ustr *
3534
3535       Explanation:
3536
3537         This function works like comparing ustr_cmp() against 0.
3538
3539     Function:  ustr_cmp_buf_eq()
3540       Returns: Success or failure
3541       Type: int
3542
3543       Parameter[1]: A pointer to a constant Ustr string
3544       Type[1]: const struct Ustr *
3545
3546       Parameter[2]: A pointer to constant bytes, to compare
3547       Type[2]: const void *
3548
3549       Parameter[3]: Length of comparison bytes
3550       Type[3]: size_t
3551
3552       Explanation:
3553
3554         This function works like comparing ustr_cmp_buf() against 0.
3555
3556     Function:  ustr_cmp_subustr_eq()
3557       Returns: Success or failure
3558       Type: int
3559
3560       Parameter[1]: A pointer to a constant Ustr string
3561       Type[1]: const struct Ustr *
3562
3563       Parameter[2]: A pointer to a constant Ustr string
3564       Type[2]: const struct Ustr *
3565
3566       Parameter[3]: Position in the Ustr
3567       Type[3]: size_t
3568
3569       Parameter[4]: Length to compare from the Ustr
3570       Type[4]: size_t
3571
3572       Explanation:
3573
3574         This function works like comparing ustr_cmp_subustr() against 0.
3575
3576     Function:  ustr_cmp_cstr_eq()
3577       Returns: Success or failure
3578       Type: int
3579
3580       Parameter[1]: A pointer to a constant Ustr string
3581       Type[1]: const struct Ustr *
3582
3583       Parameter[2]: A pointer to a constant C-style string
3584       Type[2]: const char *
3585
3586       Explanation:
3587
3588         This function works like comparing ustr_cmp_cstr() against 0.
3589
3590     Function:  ustr_cmp_case_eq()
3591       Returns: Success or failure
3592       Type: int
3593
3594       Parameter[1]: A pointer to a constant Ustr string
3595       Type[1]: const struct Ustr *
3596
3597       Parameter[2]: A pointer to a constant Ustr string
3598       Type[2]: const struct Ustr *
3599
3600       Explanation:
3601
3602         This function works like comparing ustr_cmp_case() against 0.
3603
3604     Function:  ustr_cmp_case_buf_eq()
3605       Returns: Success or failure
3606       Type: int
3607
3608       Parameter[1]: A pointer to a constant Ustr string
3609       Type[1]: const struct Ustr *
3610
3611       Parameter[2]: A pointer to constant bytes, to compare
3612       Type[2]: const void *
3613
3614       Parameter[3]: Length of comparison bytes
3615       Type[3]: size_t
3616
3617       Explanation:
3618
3619         This function works like comparing ustr_cmp_case_buf() against 0.
3620
3621     Function:  ustr_cmp_case_subustr_eq()
3622       Returns: Success or failure
3623       Type: int
3624
3625       Parameter[1]: A pointer to a constant Ustr string
3626       Type[1]: const struct Ustr *
3627
3628       Parameter[2]: A pointer to a constant Ustr string
3629       Type[2]: const struct Ustr *
3630
3631       Parameter[3]: Position in the Ustr
3632       Type[3]: size_t
3633
3634       Parameter[4]: Length to compare from the Ustr
3635       Type[4]: size_t
3636
3637       Explanation:
3638
3639         This function works like comparing ustr_cmp_case_subustr() against 0.
3640
3641     Function:  ustr_cmp_case_cstr_eq()
3642       Returns: Success or failure
3643       Type: int
3644
3645       Parameter[1]: A pointer to a constant Ustr string
3646       Type[1]: const struct Ustr *
3647
3648       Parameter[2]: A pointer to a constant C-style string
3649       Type[2]: const char *
3650
3651       Explanation:
3652
3653         This function works like comparing ustr_cmp_case_cstr() against 0.
3654
3655     Function:  ustr_cmp_prefix_eq()
3656       Returns: Success or failure
3657       Type: int
3658
3659       Parameter[1]: A pointer to a constant Ustr string
3660       Type[1]: const struct Ustr *
3661
3662       Parameter[2]: A pointer to a constant Ustr string
3663       Type[2]: const struct Ustr *
3664
3665       Explanation:
3666
3667         This function works like comparing ustr_cmp() against 0, but the com‐
3668       parison is limited to the length of the right hand side.
3669
3670     Function:  ustr_cmp_prefix_buf_eq()
3671       Returns: Success or failure
3672       Type: int
3673
3674       Parameter[1]: A pointer to a constant Ustr string
3675       Type[1]: const struct Ustr *
3676
3677       Parameter[2]: A pointer to constant bytes, to compare
3678       Type[2]: const void *
3679
3680       Parameter[3]: Length of comparison bytes
3681       Type[3]: size_t
3682
3683       Explanation:
3684
3685         This function works like comparing ustr_cmp_buf() against 0, but  the
3686       comparison  is  limited  to  the length of the right hand side (Parame‐
3687       ter[3]).
3688
3689     Function:  ustr_cmp_prefix_cstr_eq()
3690       Returns: Success or failure
3691       Type: int
3692
3693       Parameter[1]: A pointer to a constant Ustr string
3694       Type[1]: const struct Ustr *
3695
3696       Parameter[2]: A pointer to a constant C-style string
3697       Type[2]: const char *
3698
3699       Explanation:
3700
3701         This function works like comparing ustr_cmp_cstr() against 0, but the
3702       comparison is limited to the length of the right hand side.
3703
3704     Function:  ustr_cmp_prefix_subustr_eq()
3705       Returns: Success or failure
3706       Type: int
3707
3708       Parameter[1]: A pointer to a constant Ustr string
3709       Type[1]: const struct Ustr *
3710
3711       Parameter[2]: A pointer to a constant Ustr string
3712       Type[2]: const struct Ustr *
3713
3714       Parameter[3]: Position in the Ustr
3715       Type[3]: size_t
3716
3717       Parameter[4]: Length to compare from the Ustr
3718       Type[4]: size_t
3719
3720       Explanation:
3721
3722         This  function works like comparing ustr_cmp_subustr() against 0, but
3723       the comparison is limited to the given length (Parameter[4]).
3724
3725     Function:  ustr_cmp_case_prefix_eq()
3726       Returns: Success or failure
3727       Type: int
3728
3729       Parameter[1]: A pointer to a constant Ustr string
3730       Type[1]: const struct Ustr *
3731
3732       Parameter[2]: A pointer to a constant Ustr string
3733       Type[2]: const struct Ustr *
3734
3735       Explanation:
3736
3737         This function works like comparing ustr_cmp_case() against 0, but the
3738       comparison is limited to the length of the right hand side.
3739
3740     Function:  ustr_cmp_case_prefix_buf_eq()
3741       Returns: Success or failure
3742       Type: int
3743
3744       Parameter[1]: A pointer to a constant Ustr string
3745       Type[1]: const struct Ustr *
3746
3747       Parameter[2]: A pointer to constant bytes, to compare
3748       Type[2]: const void *
3749
3750       Parameter[3]: Length of comparison bytes
3751       Type[3]: size_t
3752
3753       Explanation:
3754
3755         This function works like comparing ustr_cmp_case_buf() against 0, but
3756       the comparison is limited to the length of the right hand side (Parame‐
3757       ter[3]).
3758
3759     Function:  ustr_cmp_case_prefix_cstr_eq()
3760       Returns: Success or failure
3761       Type: int
3762
3763       Parameter[1]: A pointer to a constant Ustr string
3764       Type[1]: const struct Ustr *
3765
3766       Parameter[2]: A pointer to a constant C-style string
3767       Type[2]: const char *
3768
3769       Explanation:
3770
3771         This  function  works  like comparing ustr_cmp_case_cstr() against 0,
3772       but the comparison is limited to the length of the right hand side.
3773
3774     Function:  ustr_cmp_case_prefix_subustr_eq()
3775       Returns: Success or failure
3776       Type: int
3777
3778       Parameter[1]: A pointer to a constant Ustr string
3779       Type[1]: const struct Ustr *
3780
3781       Parameter[2]: A pointer to a constant Ustr string
3782       Type[2]: const struct Ustr *
3783
3784       Parameter[3]: Position in the Ustr
3785       Type[3]: size_t
3786
3787       Parameter[4]: Length to compare from the Ustr
3788       Type[4]: size_t
3789
3790       Explanation:
3791
3792         This function works like comparing ustr_cmp_case_subustr() against 0,
3793       but the comparison is limited to the given length (Parameter[4]).
3794
3795     Function:  ustr_cmp_suffix_eq()
3796       Returns: Success or failure
3797       Type: int
3798
3799       Parameter[1]: A pointer to a constant Ustr string
3800       Type[1]: const struct Ustr *
3801
3802       Parameter[2]: A pointer to a constant Ustr string
3803       Type[2]: const struct Ustr *
3804
3805       Explanation:
3806
3807         This function works like ustr_cmp_prefix_eq() but compares the end of
3808       the left hand side.
3809
3810     Function:  ustr_cmp_suffix_buf_eq()
3811       Returns: Success or failure
3812       Type: int
3813
3814       Parameter[1]: A pointer to a constant Ustr string
3815       Type[1]: const struct Ustr *
3816
3817       Parameter[2]: A pointer to constant bytes, to compare
3818       Type[2]: const void *
3819
3820       Parameter[3]: Length of comparison bytes
3821       Type[3]: size_t
3822
3823       Explanation:
3824
3825         This function works like ustr_cmp_prefix_buf_eq()  but  compares  the
3826       end of the left hand side.
3827
3828     Function:  ustr_cmp_suffix_cstr_eq()
3829       Returns: Success or failure
3830       Type: int
3831
3832       Parameter[1]: A pointer to a constant Ustr string
3833       Type[1]: const struct Ustr *
3834
3835       Parameter[2]: A pointer to a constant C-style string
3836       Type[2]: const char *
3837
3838       Explanation:
3839
3840         This  function  works like ustr_cmp_prefix_cstr_eq() but compares the
3841       end of the left hand side.
3842
3843     Function:  ustr_cmp_suffix_subustr_eq()
3844       Returns: Success or failure
3845       Type: int
3846
3847       Parameter[1]: A pointer to a constant Ustr string
3848       Type[1]: const struct Ustr *
3849
3850       Parameter[2]: A pointer to a constant Ustr string
3851       Type[2]: const struct Ustr *
3852
3853       Parameter[3]: Position in the Ustr
3854       Type[3]: size_t
3855
3856       Parameter[4]: Length to compare from the Ustr
3857       Type[4]: size_t
3858
3859       Explanation:
3860
3861         This function works like comparing ustr_cmp_subustr() against 0,  but
3862       compares the end of the left hand side.
3863
3864     Function:  ustr_cmp_case_suffix_eq()
3865       Returns: Success or failure
3866       Type: int
3867
3868       Parameter[1]: A pointer to a constant Ustr string
3869       Type[1]: const struct Ustr *
3870
3871       Parameter[2]: A pointer to a constant Ustr string
3872       Type[2]: const struct Ustr *
3873
3874       Explanation:
3875
3876         This  function  works like ustr_cmp_case_prefix_eq() but compares the
3877       end of the left hand side.
3878
3879     Function:  ustr_cmp_case_suffix_buf_eq()
3880       Returns: Success or failure
3881       Type: int
3882
3883       Parameter[1]: A pointer to a constant Ustr string
3884       Type[1]: const struct Ustr *
3885
3886       Parameter[2]: A pointer to constant bytes, to compare
3887       Type[2]: const void *
3888
3889       Parameter[3]: Length of comparison bytes
3890       Type[3]: size_t
3891
3892       Explanation:
3893
3894         This function works like ustr_cmp_case_prefix_buf_eq()  but  compares
3895       the end of the left hand side.
3896
3897     Function:  ustr_cmp_case_suffix_cstr_eq()
3898       Returns: Success or failure
3899       Type: int
3900
3901       Parameter[1]: A pointer to a constant Ustr string
3902       Type[1]: const struct Ustr *
3903
3904       Parameter[2]: A pointer to a constant C-style string
3905       Type[2]: const char *
3906
3907       Explanation:
3908
3909         This  function works like ustr_cmp_case_prefix_cstr_eq() but compares
3910       the end of the left hand side.
3911
3912     Function:  ustr_cmp_case_suffix_subustr_eq()
3913       Returns: Success or failure
3914       Type: int
3915
3916       Parameter[1]: A pointer to a constant Ustr string
3917       Type[1]: const struct Ustr *
3918
3919       Parameter[2]: A pointer to a constant Ustr string
3920       Type[2]: const struct Ustr *
3921
3922       Parameter[3]: Position in the Ustr
3923       Type[3]: size_t
3924
3925       Parameter[4]: Length to compare from the Ustr
3926       Type[4]: size_t
3927
3928       Explanation:
3929
3930         This function works like comparing ustr_cmp_case_subustr() against 0,
3931       but compares the end of the left hand side.
3932
3933

Searching for data in a Ustr

3935     Function:  ustr_srch_chr_fwd()
3936       Returns: Position in the Ustr, or zero if not found
3937       Type: size_t
3938
3939       Parameter[1]: A pointer to a constant Ustr string
3940       Type[1]: const struct Ustr *
3941
3942       Parameter[2]: Offset within string to start searching at
3943       Type[2]: size_t
3944
3945       Parameter[3]: Byte data to search for
3946       Type[3]: char
3947
3948       Explanation:
3949
3950         This function searches for the data (Parameter[3]) in the Ustr, skip‐
3951       ping an offset (Parameter[2]) number of bytes.
3952
3953     Function:  ustr_srch_chr_rev()
3954       Returns: Position in the Ustr, or zero if not found
3955       Type: size_t
3956
3957       Parameter[1]: A pointer to a constant Ustr string
3958       Type[1]: const struct Ustr *
3959
3960       Parameter[2]: Offset within string to start searching at
3961       Type[2]: size_t
3962
3963       Parameter[3]: Byte data to search for
3964       Type[3]: char
3965
3966       Explanation:
3967
3968         This function works like ustr_srch_chr_fwd() but it searches from the
3969       end of the string to the beginning.
3970
3971       Note:
3972
3973         The searching starts from the end of the string, and so the offset is
3974       the offset from the end. However the position of a byte is always rela‐
3975       tive  to  the  begining,  so to do a loop you need to take the position
3976       from the length.
3977
3978     Function:  ustr_srch_buf_fwd()
3979       Returns: Position in the Ustr, or zero if not found
3980       Type: size_t
3981
3982       Parameter[1]: A pointer to a constant Ustr string
3983       Type[1]: const struct Ustr *
3984
3985       Parameter[2]: Offset within string to start searching at
3986       Type[2]: size_t
3987
3988       Parameter[3]: A pointer to data to search for
3989       Type[3]: const void *
3990
3991       Parameter[4]: Length of the data to search for
3992       Type[4]: size_t
3993
3994       Explanation:
3995
3996         This function searches for the data (Parameter[3]) of length (Parame‐
3997       ter[4]) in the Ustr, skipping an offset (Parameter[2]) number of bytes.
3998
3999     Function:  ustr_srch_buf_rev()
4000       Returns: Position in the Ustr, or zero if not found
4001       Type: size_t
4002
4003       Parameter[1]: A pointer to a constant Ustr string
4004       Type[1]: const struct Ustr *
4005
4006       Parameter[2]: Offset within string to start searching at
4007       Type[2]: size_t
4008
4009       Parameter[3]: A pointer to data to search for
4010       Type[3]: const void *
4011
4012       Parameter[4]: Length of the data to search for
4013       Type[4]: size_t
4014
4015       Explanation:
4016
4017         This function works like ustr_srch_buf_fwd() but it searches from the
4018       end of the string to the beginning.
4019
4020       Note:
4021
4022         The searching starts from the end of the string, and so the offset is
4023       the offset from the end. However the position of a byte is always rela‐
4024       tive to the begining, so to do a loop you need  to  take  the  position
4025       from the length.
4026
4027     Function:  ustr_srch_fwd()
4028       Returns: Position in the Ustr, or zero if not found
4029       Type: size_t
4030
4031       Parameter[1]: A pointer to a constant Ustr string
4032       Type[1]: const struct Ustr *
4033
4034       Parameter[2]: Offset within string to start searching at
4035       Type[2]: size_t
4036
4037       Parameter[3]: A pointer to a constant Ustr string, to search for
4038       Type[3]: const struct Ustr *
4039
4040       Explanation:
4041
4042         This  function  works  like  ustr_srch_buf_fwd() but it gets the data
4043       pointer by calling ustr_cstr() and the length by calling ustr_len()  on
4044       the passed Ustr (Parameter[3]).
4045
4046     Function:  ustr_srch_rev()
4047       Returns: Position in the Ustr, or zero if not found
4048       Type: size_t
4049
4050       Parameter[1]: A pointer to a constant Ustr string
4051       Type[1]: const struct Ustr *
4052
4053       Parameter[2]: Offset within string to start searching at
4054       Type[2]: size_t
4055
4056       Parameter[3]: A pointer to a constant Ustr string, to search for
4057       Type[3]: const struct Ustr *
4058
4059       Explanation:
4060
4061         This function works like ustr_srch_fwd() but it searches from the end
4062       of the string to the beginning.
4063
4064       Note:
4065
4066         The searching starts from the end of the string, and so the offset is
4067       the offset from the end. However the position of a byte is always rela‐
4068       tive to the begining, so to do a loop you need  to  take  the  position
4069       from the length.
4070
4071     Function:  ustr_srch_cstr_fwd()
4072       Returns: Position in the Ustr, or zero if not found
4073       Type: size_t
4074
4075       Parameter[1]: A pointer to a constant Ustr string
4076       Type[1]: const struct Ustr *
4077
4078       Parameter[2]: Offset within string to start searching at
4079       Type[2]: size_t
4080
4081       Parameter[3]: A pointer to C-style string data, to search for
4082       Type[3]: const char *
4083
4084       Explanation:
4085
4086         This  function  works like ustr_srch_buf_fwd() but it gets the length
4087       by calling strlen() on the passed data (Parameter[3]).
4088
4089     Function:  ustr_srch_cstr_rev()
4090       Returns: Position in the Ustr, or zero if not found
4091       Type: size_t
4092
4093       Parameter[1]: A pointer to a constant Ustr string
4094       Type[1]: const struct Ustr *
4095
4096       Parameter[2]: Offset within string to start searching at
4097       Type[2]: size_t
4098
4099       Parameter[3]: A pointer to C-style string data, to search for
4100       Type[3]: const char *
4101
4102       Explanation:
4103
4104         This function works like ustr_srch_cstr_fwd() but  it  searches  from
4105       the end of the string to the beginning.
4106
4107       Note:
4108
4109         The searching starts from the end of the string, and so the offset is
4110       the offset from the end. However the position of a byte is always rela‐
4111       tive  to  the  begining,  so to do a loop you need to take the position
4112       from the length.
4113
4114     Function:  ustr_srch_subustr_fwd()
4115       Returns: Position in the Ustr, or zero if not found
4116       Type: size_t
4117
4118       Parameter[1]: A pointer to a constant Ustr string
4119       Type[1]: const struct Ustr *
4120
4121       Parameter[2]: Offset within string to start searching at
4122       Type[2]: size_t
4123
4124       Parameter[3]: A pointer to a constant Ustr string
4125       Type[3]: const struct Ustr *
4126
4127       Parameter[4]: Position in the Ustr
4128       Type[4]: size_t
4129
4130       Parameter[5]: Length of data to search, from the Ustr
4131       Type[5]: size_t
4132
4133       Explanation:
4134
4135         This function works like ustr_srch_fwd() but it  moves  the  data  to
4136       start at the correct position and limits the length to the value speci‐
4137       fied.
4138
4139     Function:  ustr_srch_subustr_rev()
4140       Returns: Position in the Ustr, or zero if not found
4141       Type: size_t
4142
4143       Parameter[1]: A pointer to a constant Ustr string
4144       Type[1]: const struct Ustr *
4145
4146       Parameter[2]: Offset within string to start searching at
4147       Type[2]:  size_t
4148
4149       Parameter[3]: A pointer to a constant Ustr string
4150       Type[3]: const struct Ustr *
4151
4152       Parameter[4]: Position in the Ustr
4153       Type[4]: size_t
4154
4155       Parameter[5]: Length of data to search, from the Ustr
4156       Type[5]: size_t
4157
4158       Explanation:
4159
4160         This function works like ustr_srch_rev() but it  moves  the  data  to
4161       start at the correct position and limits the length to the value speci‐
4162       fied.
4163
4164       Note:
4165
4166         The searching starts from the end of the string, and so the offset is
4167       the offset from the end. However the position of a byte is always rela‐
4168       tive to the begining, so to do a loop you need  to  take  the  position
4169       from the length.
4170
4171     Function:  ustr_srch_case_chr_fwd()
4172       Returns: Position in the Ustr, or zero if not found
4173       Type: size_t
4174
4175       Parameter[1]: A pointer to a constant Ustr string
4176       Type[1]: const struct Ustr *
4177
4178       Parameter[2]: Offset within string to start searching at
4179       Type[2]: size_t
4180
4181       Parameter[3]: Byte data to search for
4182       Type[3]: char
4183
4184       Explanation:
4185
4186         This function works like ustr_srch_chr_fwd(), but treats ASCII upper‐
4187       case and lowercase as equivalent.
4188
4189     Function:  ustr_srch_case_chr_rev()
4190       Returns: Position in the Ustr, or zero if not found
4191       Type: size_t
4192
4193       Parameter[1]: A pointer to a constant Ustr string
4194       Type[1]: const struct Ustr *
4195
4196       Parameter[2]: Offset within string to start searching at
4197       Type[2]: size_t
4198
4199       Parameter[3]: Byte data to search for
4200       Type[3]: char
4201
4202       Explanation:
4203
4204         This function works like ustr_srch_chr_fwd(), but treats ASCII upper‐
4205       case and lowercase as equivalent.
4206
4207     Function:  ustr_srch_case_buf_fwd()
4208       Returns: Position in the Ustr, or zero if not found
4209       Type: size_t
4210
4211       Parameter[1]: A pointer to a constant Ustr string
4212       Type[1]: const struct Ustr *
4213
4214       Parameter[2]: Offset within string to start searching at
4215       Type[2]: size_t
4216
4217       Parameter[3]: A pointer to data to search for
4218       Type[3]: const void *
4219
4220       Parameter[4]: Length of the data to search for
4221       Type[4]: size_t
4222
4223       Explanation:
4224
4225         This function works like ustr_srch_buf_fwd(), but treats ASCII upper‐
4226       case and lowercase as equivalent.
4227
4228     Function:  ustr_srch_case_buf_rev()
4229       Returns: Position in the Ustr, or zero if not found
4230       Type: size_t
4231
4232       Parameter[1]: A pointer to a constant Ustr string
4233       Type[1]: const struct Ustr *
4234
4235       Parameter[2]: Offset within string to start searching at
4236       Type[2]: size_t
4237
4238       Parameter[3]: A pointer to data to search for
4239       Type[3]: const void *
4240
4241       Parameter[4]: Length of the data to search for
4242       Type[4]: size_t
4243
4244       Explanation:
4245
4246         This function works like ustr_srch_buf_rev(), but treats ASCII upper‐
4247       case and lowercase as equivalent.
4248
4249     Function:  ustr_srch_case_fwd()
4250       Returns: Position in the Ustr, or zero if not found
4251       Type: size_t
4252
4253       Parameter[1]: A pointer to a constant Ustr string
4254       Type[1]: const struct Ustr *
4255
4256       Parameter[2]: Offset within string to start searching at
4257       Type[2]: size_t
4258
4259       Parameter[3]: A pointer to a constant Ustr string, to search for
4260       Type[3]: const struct Ustr *
4261
4262       Explanation:
4263
4264         This  function works like ustr_srch_fwd(), but treats ASCII uppercase
4265       and lowercase as equivalent.
4266
4267     Function:  ustr_srch_case_rev()
4268       Returns: Position in the Ustr, or zero if not found
4269       Type: size_t
4270
4271       Parameter[1]: A pointer to a constant Ustr string
4272       Type[1]: const struct Ustr *
4273
4274       Parameter[2]: Offset within string to start searching at
4275       Type[2]: size_t
4276
4277       Parameter[3]: A pointer to a constant Ustr string, to search for
4278       Type[3]: const struct Ustr *
4279
4280       Explanation:
4281
4282         This function works like ustr_srch_rev(), but treats ASCII  uppercase
4283       and lowercase as equivalent.
4284
4285     Function:  ustr_srch_case_cstr_fwd()
4286       Returns: Position in the Ustr, or zero if not found
4287       Type: size_t
4288
4289       Parameter[1]: A pointer to a constant Ustr string
4290       Type[1]: const struct Ustr *
4291
4292       Parameter[2]: Offset within string to start searching at
4293       Type[2]: size_t
4294
4295       Parameter[3]: A pointer to C-style string data, to search for
4296       Type[3]: const char *
4297
4298       Explanation:
4299
4300         This  function  works  like  ustr_srch_cstr_fwd(),  but  treats ASCII
4301       uppercase and lowercase as equivalent.
4302
4303     Function:  ustr_srch_case_cstr_rev()
4304       Returns: Position in the Ustr, or zero if not found
4305       Type: size_t
4306
4307       Parameter[1]: A pointer to a constant Ustr string
4308       Type[1]: const struct Ustr *
4309
4310       Parameter[2]: Offset within string to start searching at
4311       Type[2]: size_t
4312
4313       Parameter[3]: A pointer to C-style string data, to search for
4314       Type[3]: const char *
4315
4316       Explanation:
4317
4318         This function  works  like  ustr_srch_cstr_rev(),  but  treats  ASCII
4319       uppercase and lowercase as equivalent.
4320
4321     Function:  ustr_srch_case_subustr_fwd()
4322       Returns: Position in the Ustr, or zero if not found
4323       Type: size_t
4324
4325       Parameter[1]: A pointer to a constant Ustr string
4326       Type[1]: const struct Ustr *
4327
4328       Parameter[2]: Offset within string to start searching at
4329       Type[2]: size_t
4330
4331       Parameter[3]: A pointer to a constant Ustr string
4332       Type[3]: const struct Ustr *
4333
4334       Parameter[4]: Position in the Ustr
4335       Type[4]: size_t
4336
4337       Parameter[5]: Length of data to search, from the Ustr
4338       Type[5]: size_t
4339
4340       Explanation:
4341
4342         This  function  works  like ustr_srch_subustr_fwd(), but treats ASCII
4343       uppercase and lowercase as equivalent.
4344
4345     Function:  ustr_srch_case_subustr_rev()
4346       Returns: Position in the Ustr, or zero if not found
4347       Type: size_t
4348
4349       Parameter[1]: A pointer to a constant Ustr string
4350       Type[1]: const struct Ustr *
4351
4352       Parameter[2]: Offset within string to start searching at
4353       Type[2]:  size_t
4354
4355       Parameter[3]: A pointer to a constant Ustr string
4356       Type[3]: const struct Ustr *
4357
4358       Parameter[4]: Position in the Ustr
4359       Type[4]: size_t
4360
4361       Parameter[5]: Length of data to search, from the Ustr
4362       Type[5]: size_t
4363
4364       Explanation:
4365
4366         This function works like ustr_srch_subustr_rev(),  but  treats  ASCII
4367       uppercase and lowercase as equivalent.
4368
4369

Span lengths of data in a Ustr

4371     Function:  ustr_spn_chr_fwd()
4372       Returns: Number of bytes in the span
4373       Type: size_t
4374
4375       Parameter[1]: A pointer to a constant Ustr string
4376       Type[1]: const struct Ustr *
4377
4378       Parameter[2]: Offset within string, to start spanning from
4379       Type[2]: size_t
4380
4381       Parameter[3]: Byte data
4382       Type[3]: char
4383
4384       Explanation:
4385
4386         This  function  returns  the length of the start of the Ustr (Parame‐
4387       ter[1]) that only contains bytes that are equal to  the  data  (Parame‐
4388       ter[3]), skipping offset (Parameter[2]) bytes.
4389
4390     Function:  ustr_spn_chr_rev()
4391       Returns: Number of bytes in the span
4392       Type: size_t
4393
4394       Parameter[1]: A pointer to a constant Ustr string
4395       Type[1]: const struct Ustr *
4396
4397       Parameter[2]: Offset within string, to start spanning from
4398       Type[2]: size_t
4399
4400       Parameter[3]: Byte data
4401       Type[3]: char
4402
4403       Explanation:
4404
4405         This  function  returns  the  length  of the end of the Ustr (Parame‐
4406       ter[1]) that only contains bytes that are equal to  the  data  (Parame‐
4407       ter[3]), skipping offset (Parameter[2]) bytes.
4408
4409     Function:  ustr_spn_chrs_fwd()
4410       Returns: Number of bytes in the span
4411       Type: size_t
4412
4413       Parameter[1]: A pointer to a constant Ustr string
4414       Type[1]: const struct Ustr *
4415
4416       Parameter[2]: Offset within string, to start spanning from
4417       Type[2]: size_t
4418
4419       Parameter[3]: Array of byte data, for spanning
4420       Type[3]: const char *
4421
4422       Parameter[4]: Length of byte data, for spanning
4423       Type[4]: size_t
4424
4425       Explanation:
4426
4427         This  function  returns  the length of the start of the Ustr (Parame‐
4428       ter[1]) that only contains bytes that are equal to any byte in the data
4429       (Parameter[3]), skipping offset (Parameter[2]) bytes.
4430
4431     Function:  ustr_spn_chrs_rev()
4432       Returns: Number of bytes in the span
4433       Type: size_t
4434
4435       Parameter[1]: A pointer to a constant Ustr string
4436       Type[1]: const struct Ustr *
4437
4438       Parameter[2]: Offset within string, to start spanning from
4439       Type[2]: size_t
4440
4441       Parameter[3]: Array of byte data
4442       Type[3]: const char *
4443
4444       Parameter[4]: Length of byte data
4445       Type[4]: size_t
4446
4447       Explanation:
4448
4449         This  function  returns  the  length  of the end of the Ustr (Parame‐
4450       ter[1]) that only contains bytes that are equal to any byte in the data
4451       (Parameter[3]), skipping offset (Parameter[2]) bytes.
4452
4453     Function:  ustr_spn_fwd()
4454       Returns: Number of bytes in the span
4455       Type: size_t
4456
4457       Parameter[1]: A pointer to a constant Ustr string
4458       Type[1]: const struct Ustr *
4459
4460       Parameter[2]: Offset within string, to start spanning from
4461       Type[2]: size_t
4462
4463       Parameter[3]:  A pointer to a constant Ustr string, containing spanning
4464       bytes
4465       Type[3]: const struct Ustr *
4466
4467       Explanation:
4468
4469         This function works like ustr_spn_buf_fwd() but  passing  ustr_cstr()
4470       and ustr_len()
4471
4472     Function:  ustr_spn_rev()
4473       Returns: Number of bytes in the span
4474       Type: size_t
4475
4476       Parameter[1]: A pointer to a constant Ustr string
4477       Type[1]: const struct Ustr *
4478
4479       Parameter[2]: Offset within string, to start spanning from
4480       Type[2]: size_t
4481
4482       Parameter[3]:  A pointer to a constant Ustr string, containing spanning
4483       bytes
4484       Type[3]: const struct Ustr *
4485
4486       Explanation:
4487
4488         This function works like ustr_spn_buf_rev() but  passing  ustr_cstr()
4489       and ustr_len()
4490
4491     Function:  ustr_spn_cstr_fwd()
4492       Returns: Number of bytes in the span
4493       Type: size_t
4494
4495       Parameter[1]: A pointer to a constant Ustr string
4496       Type[1]: const struct Ustr *
4497
4498       Parameter[2]: Offset within string, to start spanning from
4499       Type[2]: size_t
4500
4501       Parameter[3]:  A pointer to a constant C-style string, containing span‐
4502       ning bytes
4503       Type[3]: const char *
4504
4505       Explanation:
4506
4507         This function works like ustr_spn_buf_fwd() but passing strlen()  for
4508       the length.
4509
4510     Function:  ustr_spn_cstr_rev()
4511       Returns: Number of bytes in the span
4512       Type: size_t
4513
4514       Parameter[1]: A pointer to a constant Ustr string
4515       Type[1]: const struct Ustr *
4516
4517       Parameter[2]: Offset within string, to start spanning from
4518       Type[2]: size_t
4519
4520       Parameter[3]:  A pointer to a constant C-style string, containing span‐
4521       ning bytes
4522       Type[3]: const char *
4523
4524       Explanation:
4525
4526         This function works like ustr_spn_buf_rev() but passing strlen()  for
4527       the length.
4528
4529     Function:  ustr_cspn_chr_fwd()
4530       Returns: Number of bytes not in the span
4531       Type: size_t
4532
4533       Parameter[1]: A pointer to a constant Ustr string
4534       Type[1]: const struct Ustr *
4535
4536       Parameter[2]: Offset within string, to start compliment spanning from
4537       Type[2]: size_t
4538
4539       Parameter[3]: Byte data
4540       Type[3]: char
4541
4542       Explanation:
4543
4544         This  function  returns  the length of the start of the Ustr (Parame‐
4545       ter[1]) that only contains bytes that are not equal to the data (Param‐
4546       eter[3]), skipping offset (Parameter[2]) bytes.
4547
4548     Function:  ustr_cspn_chr_rev()
4549       Returns: Number of bytes not in the span
4550       Type: size_t
4551
4552       Parameter[1]: A pointer to a constant Ustr string
4553       Type[1]: const struct Ustr *
4554
4555       Parameter[2]: Offset within string, to start compliment spanning from
4556       Type[2]: size_t
4557
4558       Parameter[3]: Byte data
4559       Type[3]: char
4560
4561       Explanation:
4562
4563         This  function  returns  the  length  of the end of the Ustr (Parame‐
4564       ter[1]) that only contains bytes that are not equal to the data (Param‐
4565       eter[3]), skipping offset (Parameter[2]) bytes.
4566
4567     Function:  ustr_cspn_chrs_fwd()
4568       Returns: Number of bytes not in the span
4569       Type: size_t
4570
4571       Parameter[1]: A pointer to a constant Ustr string
4572       Type[1]: const struct Ustr *
4573
4574       Parameter[2]: Offset within string, to start compliment spanning from
4575       Type[2]: size_t
4576
4577       Parameter[3]: Array of byte data
4578       Type[3]: const char *
4579
4580       Parameter[4]: Length of byte data
4581       Type[4]: size_t
4582
4583       Explanation:
4584
4585         This  function  returns  the length of the start of the Ustr (Parame‐
4586       ter[1]) that only contains bytes that are not equal to any byte in  the
4587       data (Parameter[3]), skipping offset (Parameter[2]) bytes.
4588
4589     Function:  ustr_cspn_chrs_rev()
4590       Returns: Number of bytes not in the span
4591       Type: size_t
4592
4593       Parameter[1]: A pointer to a constant Ustr string
4594       Type[1]: const struct Ustr *
4595
4596       Parameter[2]: Offset within string, to start compliment spanning from
4597       Type[2]: size_t
4598
4599       Parameter[3]: Array of byte data
4600       Type[3]: const char *
4601
4602       Parameter[4]: Length of byte data
4603       Type[4]: size_t
4604
4605       Explanation:
4606
4607         This  function  returns  the  length  of the end of the Ustr (Parame‐
4608       ter[1]) that only contains bytes that are not equal to any byte in  the
4609       data (Parameter[3]), skipping offset (Parameter[2]) bytes.
4610
4611     Function:  ustr_cspn_fwd()
4612       Returns: Number of bytes not in the span
4613       Type: size_t
4614
4615       Parameter[1]: A pointer to a constant Ustr string
4616       Type[1]: const struct Ustr *
4617
4618       Parameter[2]: Offset within string, to start compliment spanning from
4619       Type[2]: size_t
4620
4621       Parameter[3]:  A pointer to a constant Ustr string, containing spanning
4622       bytes
4623       Type[3]: const struct Ustr *
4624
4625       Explanation:
4626
4627         This function works like ustr_cspn_buf_fwd() but passing  ustr_cstr()
4628       and ustr_len()
4629
4630     Function:  ustr_cspn_rev()
4631       Returns: Number of bytes not in the span
4632       Type: size_t
4633
4634       Parameter[1]: A pointer to a constant Ustr string
4635       Type[1]: const struct Ustr *
4636
4637       Parameter[2]: Offset within string, to start compliment spanning from
4638       Type[2]: size_t
4639
4640       Parameter[3]:  A pointer to a constant Ustr string, containing spanning
4641       bytes
4642       Type[3]: const struct Ustr *
4643
4644       Explanation:
4645
4646         This function works like ustr_cspn_buf_rev() but passing  ustr_cstr()
4647       and ustr_len()
4648
4649     Function:  ustr_cspn_cstr_fwd()
4650       Returns: Number of bytes not in the span
4651       Type: size_t
4652
4653       Parameter[1]: A pointer to a constant Ustr string
4654       Type[1]: const struct Ustr *
4655
4656       Parameter[2]: Offset within string, to start compliment spanning from
4657       Type[2]: size_t
4658
4659       Parameter[3]:  A pointer to a constant C-style string, containing span‐
4660       ning bytes
4661       Type[3]: const char *
4662
4663       Explanation:
4664
4665         This function works like ustr_cspn_buf_fwd() but passing strlen() for
4666       the length.
4667
4668     Function:  ustr_cspn_cstr_rev()
4669       Returns: Number of bytes not in the span
4670       Type: size_t
4671
4672       Parameter[1]: A pointer to a constant Ustr string
4673       Type[1]: const struct Ustr *
4674
4675       Parameter[2]: Offset within string, to start spanning from
4676       Type[2]: size_t
4677
4678       Parameter[3]:  A pointer to a constant C-style string, containing span‐
4679       ning bytes
4680       Type[3]: const char *
4681
4682       Explanation:
4683
4684         This function works like ustr_cspn_buf_rev() but passing strlen() for
4685       the length.
4686
4687     Function:  ustr_utf8_spn_chrs_fwd()
4688       Returns: Number of UTF-8 characters not in the span
4689       Type: size_t
4690
4691       Parameter[1]: A pointer to a constant Ustr UTF-8 string
4692       Type[1]: const struct Ustr *
4693
4694       Parameter[2]: Offset within string, in UTF-8 characters, to start span‐
4695       ning from
4696       Type[2]: size_t
4697
4698       Parameter[3]: A pointer to a constant C-style UTF-8 string
4699       Type[3]: const char *
4700
4701       Parameter[4]: Length of the C-style UTF-8 string
4702       Type[4]: size_t
4703
4704       Explanation:
4705
4706         This function works like ustr_spn_chrs_fwd() but  the  return  value,
4707       offset, and length all use UTF-8 characters and not bytes.
4708
4709       Note:
4710
4711         This  is  much  slower  than  ustr_spn_chrs_fwd() but given "xy" as a
4712       multi-byte UTF-8 character it understands that the span over "xyxz"  is
4713       1 UTF-8 character and not 3 bytes.
4714
4715     Function:  ustr_utf8_spn_chrs_rev()
4716       Returns: Number of UTF-8 characters not in the span
4717       Type: size_t
4718
4719       Parameter[1]: A pointer to a constant Ustr UTF-8 string
4720       Type[1]: const struct Ustr *
4721
4722       Parameter[2]: Offset within string, in UTF-8 characters, to start span‐
4723       ning from
4724       Type[2]: size_t
4725
4726       Parameter[3]: A pointer to a constant C-style UTF-8 string
4727       Type[3]: const char *
4728
4729       Parameter[4]:
4730       Type[4]: size_t
4731
4732       Explanation:
4733
4734         This function works like ustr_spn_chrs_rev() but  the  return  value,
4735       offset, and length all use UTF-8 characters and not bytes.
4736
4737       Note:
4738
4739         This  is  much  slower  than  ustr_spn_chrs_rev() but given "xy" as a
4740       multi-byte UTF-8 character it understands that the span over "xyxz"  is
4741       1 UTF-8 character and not 3 bytes.
4742
4743     Function:  ustr_utf8_spn_fwd()
4744       Returns: Number of UTF-8 characters not in the span
4745       Type: size_t
4746
4747       Parameter[1]: A pointer to a constant Ustr UTF-8 string
4748       Type[1]: const struct Ustr *
4749
4750       Parameter[2]: Offset within string, in UTF-8 characters, to start span‐
4751       ning from
4752       Type[2]: size_t
4753
4754       Parameter[3]: A pointer to a constant Ustr UTF-8 string
4755       Type[3]: const struct Ustr *
4756
4757       Explanation:
4758
4759         This function works like ustr_spn_fwd() but the return value, offset,
4760       and length all use UTF-8 characters and not bytes.
4761
4762       Note:
4763
4764         This  is  much  slower  than  ustr_spn_fwd()  but  given  "xy"  as  a
4765       multi-byte UTF-8 character it understands that the span over "xyxz"  is
4766       1 UTF-8 character and not 3 bytes.
4767
4768     Function:  ustr_utf8_spn_rev()
4769       Returns: Number of UTF-8 characters not in the span
4770       Type: size_t
4771
4772       Parameter[1]: A pointer to a constant Ustr UTF-8 string
4773       Type[1]: const struct Ustr *
4774
4775       Parameter[2]: Offset within string, in UTF-8 characters, to start span‐
4776       ning from
4777       Type[2]: size_t
4778
4779       Parameter[3]: A pointer to a constant Ustr UTF-8 string
4780       Type[3]: const struct Ustr *
4781
4782       Explanation:
4783
4784         This function works like ustr_spn_rev() but the return value, offset,
4785       and length all use UTF-8 characters and not bytes.
4786
4787       Note:
4788
4789         This  is  much  slower  than  ustr_spn_rev()  but  given  "xy"  as  a
4790       multi-byte UTF-8 character it understands that the span over "xyxz"  is
4791       1 UTF-8 character and not 3 bytes.
4792
4793     Function:  ustr_utf8_spn_cstr_fwd()
4794       Returns: Number of UTF-8 characters not in the span
4795       Type: size_t
4796
4797       Parameter[1]: A pointer to a constant Ustr UTF-8 string
4798       Type[1]: const struct Ustr *
4799
4800       Parameter[2]: Offset within string, in UTF-8 characters, to start span‐
4801       ning from
4802       Type[2]: size_t
4803
4804       Parameter[3]: A pointer to a constant C-style UTF-8 string
4805       Type[3]: const char *
4806
4807       Explanation:
4808
4809         This function works like ustr_spn_cstr_fwd() but  the  return  value,
4810       offset, and length all use UTF-8 characters and not bytes.
4811
4812       Note:
4813
4814         This  is  much  slower  than  ustr_spn_cstr_fwd() but given "xy" as a
4815       multi-byte UTF-8 character it understands that the span over "xyxz"  is
4816       1 UTF-8 character and not 3 bytes.
4817
4818     Function:  ustr_utf8_spn_cstr_rev()
4819       Returns: Number of UTF-8 characters not in the span
4820       Type: size_t
4821
4822       Parameter[1]: A pointer to a constant Ustr UTF-8 string
4823       Type[1]: const struct Ustr *
4824
4825       Parameter[2]: Offset within string, in UTF-8 characters, to start span‐
4826       ning from
4827       Type[2]: size_t
4828
4829       Parameter[3]: A pointer to a constant C-style UTF-8 string
4830       Type[3]: const char *
4831
4832       Explanation:
4833
4834         This function works like ustr_spn_cstr_rev() but  the  return  value,
4835       offset, and length all use UTF-8 characters and not bytes.
4836
4837       Note:
4838
4839         This  is  much  slower  than  ustr_spn_cstr_rev() but given "xy" as a
4840       multi-byte UTF-8 character it understands that the span over "xyxz"  is
4841       1 UTF-8 character and not 3 bytes.
4842
4843     Function:  ustr_utf8_cspn_chrs_fwd()
4844       Returns: Number of UTF-8 characters not in the span
4845       Type: size_t
4846
4847       Parameter[1]: A pointer to a constant Ustr UTF-8 string
4848       Type[1]: const struct Ustr *
4849
4850       Parameter[2]:  Offset within string, in UTF-8 characters, to start com‐
4851       pliment spanning from
4852       Type[2]: size_t
4853
4854       Parameter[3]: A pointer to a constant C-style UTF-8 string
4855       Type[3]: const char *
4856
4857       Parameter[4]: Length of the C-style UTF-8 string
4858       Type[4]: size_t
4859
4860       Explanation:
4861
4862         This function works like ustr_cspn_chrs_fwd() but the  return  value,
4863       offset, and length all use UTF-8 characters and not bytes.
4864
4865       Note:
4866
4867         This  is  much  slower  than ustr_cspn_chrs_fwd() but given "xy" as a
4868       multi-byte UTF-8 character it understands that the compliment span over
4869       "xzxy" is 1 UTF-8 character and not 0 bytes.
4870
4871     Function:  ustr_utf8_cspn_chrs_rev()
4872       Returns: Number of UTF-8 characters not in the span
4873       Type: size_t
4874
4875       Parameter[1]: A pointer to a constant Ustr UTF-8 string
4876       Type[1]: const struct Ustr *
4877
4878       Parameter[2]:  Offset within string, in UTF-8 characters, to start com‐
4879       pliment spanning from
4880       Type[2]: size_t
4881
4882       Parameter[3]: A pointer to a constant C-style UTF-8 string
4883       Type[3]: const char *
4884
4885       Parameter[4]: Length of the C-style UTF-8 string
4886       Type[4]: size_t
4887
4888       Explanation:
4889
4890         This function works like ustr_cspn_chrs_rev() but the  return  value,
4891       offset, and length all use UTF-8 characters and not bytes.
4892
4893       Note:
4894
4895         This  is  much  slower  than ustr_cspn_chrs_rev() but given "xy" as a
4896       multi-byte UTF-8 character it understands that the compliment span over
4897       "xzxy" is 1 UTF-8 character and not 0 bytes.
4898
4899     Function:  ustr_utf8_cspn_fwd()
4900       Returns: Number of UTF-8 characters not in the span
4901       Type: size_t
4902
4903       Parameter[1]: A pointer to a constant Ustr UTF-8 string
4904       Type[1]: const struct Ustr *
4905
4906       Parameter[2]:  Offset within string, in UTF-8 characters, to start com‐
4907       pliment spanning from
4908       Type[2]: size_t
4909
4910       Parameter[3]: A pointer to a constant  Ustr  UTF-8  string,  containing
4911       spanning data
4912       Type[3]: const struct Ustr *
4913
4914       Explanation:
4915
4916         This  function  works like ustr_cspn_fwd() but the return value, off‐
4917       set, and length all use UTF-8 characters and not bytes.
4918
4919       Note:
4920
4921         This is  much  slower  than  ustr_cspn_fwd()  but  given  "xy"  as  a
4922       multi-byte UTF-8 character it understands that the compliment span over
4923       "xzxy" is 1 UTF-8 character and not 0 bytes.
4924
4925     Function:  ustr_utf8_cspn_rev()
4926       Returns: Number of UTF-8 characters not in the span
4927       Type: size_t
4928
4929       Parameter[1]: A pointer to a constant Ustr UTF-8 string
4930       Type[1]: const struct Ustr *
4931
4932       Parameter[2]: Offset within string, in UTF-8 characters, to start  com‐
4933       pliment spanning from
4934       Type[2]: size_t
4935
4936       Parameter[3]:  A pointer to constant Ustr UTF-8 string data, containing
4937       spanning data
4938       Type[3]: const struct Ustr *
4939
4940       Explanation:
4941
4942         This function works like ustr_cspn_rev() but the return  value,  off‐
4943       set, and length all use UTF-8 characters and not bytes.
4944
4945       Note:
4946
4947         This  is  much  slower  than  ustr_cspn_rev()  but  given  "xy"  as a
4948       multi-byte UTF-8 character it understands that the compliment span over
4949       "xzxy" is 1 UTF-8 character and not 0 bytes.
4950
4951     Function:  ustr_utf8_cspn_cstr_fwd()
4952       Returns: Number of UTF-8 characters not in the span
4953       Type: size_t
4954
4955       Parameter[1]: A pointer to a constant Ustr UTF-8 string
4956       Type[1]: const struct Ustr *
4957
4958       Parameter[2]:  Offset within string, in UTF-8 characters, to start com‐
4959       pliment spanning from
4960       Type[2]: size_t
4961
4962       Parameter[3]: A pointer to constant C-style UTF-8 string data, contain‐
4963       ing spanning data
4964       Type[3]: const char *
4965
4966       Explanation:
4967
4968         This  function  works like ustr_cspn_cstr_fwd() but the return value,
4969       offset, and length all use UTF-8 characters and not bytes.
4970
4971       Note:
4972
4973         This is much slower than ustr_cspn_cstr_fwd() but  given  "xy"  as  a
4974       multi-byte UTF-8 character it understands that the compliment span over
4975       "xzxy" is 1 UTF-8 character and not 0 bytes.
4976
4977     Function:  ustr_utf8_cspn_cstr_rev()
4978       Returns: Number of UTF-8 characters not in the span
4979       Type: size_t
4980
4981       Parameter[1]: A pointer to a constant Ustr UTF-8 string
4982       Type[1]: const struct Ustr *
4983
4984       Parameter[2]: Offset within string, in UTF-8 characters, to start  com‐
4985       pliment spanning from
4986       Type[2]: size_t
4987
4988       Parameter[3]:  A pointer to C-style UTF-8 string data, containing span‐
4989       ning data
4990       Type[3]: const char *
4991
4992       Explanation:
4993
4994         This function works like ustr_cspn_cstr_rev() but the  return  value,
4995       offset, and length all use UTF-8 characters and not bytes.
4996
4997       Note:
4998
4999         This  is  much  slower  than  ustr_spn_cstr_rev() but given "xy" as a
5000       multi-byte UTF-8 character it understands that the compliment span over
5001       "xzxy" is 1 UTF-8 character and not 0 bytes.
5002
5003

Doing IO from or to a Ustr

5005     Function:  ustr_io_get()
5006       Returns: Success or failure
5007       Type: int
5008
5009       Parameter[1]: A pointer to a pointer to a Ustr string
5010       Type[1]: struct Ustr **
5011
5012       Parameter[2]: A pointer to a C file object
5013       Type[2]: FILE *
5014
5015       Parameter[3]: Number of bytes to read
5016       Type[3]: size_t
5017
5018       Parameter[4]: Returned number of bytes read
5019       Type[4]: size_t *
5020
5021       Explanation:
5022
5023         This  function  tries to read a minimum number of bytes from the file
5024       object, into the Ustr string. The exact number read is returned, unless
5025       (Parameter[4]) is NULL.
5026
5027     Function:  ustr_io_getfile()
5028       Returns: Success or failure
5029       Type: int
5030
5031       Parameter[1]: Pointer to a pointer to a Ustr string
5032       Type[1]: struct Ustr **
5033
5034       Parameter[2]: A pointer to a C file object
5035       Type[2]: FILE *
5036
5037       Explanation:
5038
5039         This function calls ustr_io_get() rpeatedly until EOF is encountered.
5040
5041       Note:
5042
5043         The errno value when this function ends could either be from fopen(),
5044       fread(), or if both of the those succeeded from fclose().
5045
5046     Function:  ustr_io_getfilename()
5047       Returns: Success or failure
5048       Type: int
5049
5050       Parameter[1]: Pointer to a pointer to a Ustr string
5051       Type[1]: struct Ustr **
5052
5053       Parameter[2]: A C-style string of a filename
5054       Type[2]: const char *
5055
5056       Explanation:
5057
5058         This function opens a specified file,  and  then  calls  ustr_io_get‐
5059       file(). Finally closing the FILE * object.
5060
5061     Function:  ustr_io_getdelim()
5062       Returns: Success or failure
5063       Type: int
5064
5065       Parameter[1]: Pointer to a pointer to a Ustr string
5066       Type[1]: struct Ustr **
5067
5068       Parameter[2]: A pointer to a C file object
5069       Type[2]: FILE *
5070
5071       Parameter[3]: A delimiter byte to stop reading at
5072       Type[3]: char
5073
5074       Explanation:
5075
5076         This  function  reads bytes from the file until it hits the delimiter
5077       byte.
5078
5079       Note:
5080
5081         The delimiter is included, use ustr_del() to remove 1 byte  from  the
5082       end if you don't want it.
5083         This function assumes a delimiter will happen every 80 bytes or so.
5084
5085     Function:  ustr_io_getline()
5086       Returns: Success or failure
5087       Type: int
5088
5089       Parameter[1]: Pointer to a pointer to a Ustr string
5090       Type[1]: struct Ustr **
5091
5092       Parameter[2]: A pointer to a C file object
5093       Type[2]: FILE *
5094
5095       Explanation:
5096
5097         This  function works like calling ustr_io_getdelim() with '\n' as the
5098       delimiter.
5099
5100     Function:  ustr_io_put()
5101       Returns: Success or failure
5102       Type: int
5103
5104       Parameter[1]: Pointer to a pointer to a Ustr string
5105       Type[1]: struct Ustr **
5106
5107       Parameter[2]: A pointer to a C file object
5108       Type[2]: FILE *
5109
5110       Parameter[3]: Number of bytes to write
5111       Type[3]: size_t
5112
5113       Explanation:
5114
5115         This function is the opposite of ustr_io_get(), taking bytes from the
5116       beginning of the Ustr and writting them to the file.
5117
5118       Note:
5119
5120         Deleting bytes from the begining of a Ustr string is the most ineffi‐
5121       cient thing to do, so it is recommended to use ustr_io_putfile().
5122
5123     Function:  ustr_io_putline()
5124       Returns: Success or failure
5125       Type: int
5126
5127       Parameter[1]: Pointer to a pointer to a Ustr string
5128       Type[1]: struct Ustr **
5129
5130       Parameter[2]: A pointer to a C file object
5131       Type[2]: FILE *
5132
5133       Parameter[3]: Number of bytes to write
5134       Type[3]: size_t
5135
5136       Explanation:
5137
5138         This function works like calling ustr_io_put(), and then  writting  a
5139       '\n' to the file.
5140
5141       Note:
5142
5143         This doesn't write a line from the Ustr to the file, if you want that
5144       call ustr_io_put() directly, using the return from  ustr_srch_chr_fwd()
5145       (with a '\n') as the number of bytes argument.
5146
5147     Function:  ustr_io_putfile()
5148       Returns: Success or failure
5149       Type: int
5150
5151       Parameter[1]: Pointer to a pointer to a Ustr string
5152       Type[1]: struct Ustr **
5153
5154       Parameter[2]: A pointer to a C file object
5155       Type[2]: FILE *
5156
5157       Explanation:
5158
5159         This function works like calling ustr_io_put() with ustr_len() as the
5160       number of bytes.
5161
5162     Function:  ustr_io_putfileline()
5163       Returns: Success or failure
5164       Type: int
5165
5166       Parameter[1]: Pointer to a pointer to a Ustr string
5167       Type[1]: struct Ustr **
5168
5169       Parameter[2]: A pointer to a C file object
5170       Type[2]: FILE *
5171
5172       Explanation:
5173
5174         This function works like calling ustr_io_putline() with ustr_len() as
5175       the number of bytes.
5176
5177     Function:  ustr_io_putfilename()
5178       Returns: Success or failure
5179       Type: int
5180
5181       Parameter[1]: Pointer to a pointer to a Ustr string
5182       Type[1]: struct Ustr **
5183
5184       Parameter[2]: A C-style string of a filename
5185       Type[2]: const char *
5186
5187       Parameter[3]:  A  C-style  string of a filemode (the second argument to
5188       fopen)
5189       Type[3]: const char *
5190
5191       Explanation:
5192
5193         This function opens a specified file,  and  then  calls  ustr_io_put‐
5194       file(). Finally closing the FILE * object.
5195
5196       Note:
5197
5198         The errno value when this function ends could either be from fopen(),
5199       fwrite(), or if both of the those succeeded from fclose().
5200
5201

String substitution/replacement

5203     Function:  ustr_sub_undef()
5204       Returns: Success or failure
5205       Type: int
5206
5207       Parameter[1]: Pointer to a pointer to a Ustr
5208       Type[1]: struct Ustr **
5209
5210       Parameter[2]: Position where to start substitution
5211       Type[2]: size_t
5212
5213       Parameter[3]: Length of undefined data
5214       Type[3]: size_t
5215
5216       Explanation:
5217
5218         The Ustr string is expanded as  required  (possibly  reallocated)  so
5219       that it can contain length (Parameter[2]) data, from the required posi‐
5220       tion. If the length is not zero the Ustr will  be  writable.  Or  it'll
5221       return USTR_FALSE (zero) on failure.
5222
5223       Note:
5224
5225         You can think of the operation as two seperate tasks, one which makes
5226       the current data in the Ustr undefined and the second which adds  unde‐
5227       fined data to the ustr to accomodate the desired length.
5228
5229     Function:  ustr_sub_buf()
5230       Returns: Success or failure
5231       Type: int
5232
5233       Parameter[1]: Pointer to a pointer to a Ustr
5234       Type[1]: struct Ustr **
5235
5236       Parameter[2]: Position where to start substitution
5237       Type[2]: size_t
5238
5239       Parameter[3]: Buffer containing substitution string
5240       Type[3]: const void *
5241
5242       Parameter[4]: Length of buffer
5243       Type[4]: size_t
5244
5245       Explanation:
5246
5247         This  function  works  as if you had called ustr_sub_undef() and then
5248       copied the data into the new undefined space.
5249
5250     Function:  ustr_sub_cstr()
5251       Returns: success or failure
5252       Type: int
5253
5254       Parameter[1]: Pointer to a pointer to a Ustr
5255       Type[1]: struct Ustr **
5256
5257       Parameter[2]: Position where to start substitution
5258       Type[2]: size_t
5259
5260       Parameter[3]: A pointer to a constant C-style string, which is the sub‐
5261       stitution
5262       Type[3]: const char *
5263
5264       Explanation:
5265
5266         This  function works like ustr_sub_buf() but the length is worked out
5267       automatically by strlen().
5268
5269     Function:  USTR_SUB_OSTR()
5270       Returns: Success or failure
5271       Type: int
5272
5273       Parameter[1]: Pointer to a pointer to a Ustr string
5274       Type[1]: struct Ustr **
5275
5276       Parameter[2]: Position where to start substitution
5277       Type[2]: size_t
5278
5279       Parameter[3]: A constant C-style string
5280       Type[3]: const char []
5281
5282       Explanation:
5283
5284         This function works as if you had called  ustr_sub_buf()  and  passed
5285       sizeof() - 1 as the length.
5286
5287     Function:  USTR_SUB_OBJ()
5288       Returns: Success or failure
5289       Type: int
5290
5291       Parameter[1]: Pointer to a pointer to a Ustr string
5292       Type[1]: struct Ustr **
5293
5294       Parameter[2]: Position where to start substitution
5295       Type[2]: size_t
5296
5297       Parameter[3]: A symbol
5298       Type[3]: ...
5299
5300       Explanation:
5301
5302         This  function  works  as if you had called ustr_sub_buf() and passed
5303       sizeof() as the length.
5304
5305       Note:
5306
5307         In most cases you'll want to use USTR_SUB_OSTR().
5308
5309     Function:  ustr_sub()
5310       Returns: Success or failure
5311       Type: int
5312
5313       Parameter[1]: Pointer to a pointer to a Ustr string
5314       Type[1]: struct Ustr **
5315
5316       Parameter[2]: Position where to start substitution
5317       Type[2]: size_t
5318
5319       Parameter[3]: A pointer to a constant Ustr string
5320       Type[3]: const struct Ustr *
5321
5322       Explanation:
5323
5324         This function works as if you  had  called  ustr_sub_buf()  with  the
5325       ustr_cstr()  and  ustr_len() values of the Ustr string to be added. The
5326       exception being if you substitute a ustr into itself, while only having
5327       a  single reference count, the simple method could access a free'd ustr
5328       data, but this function just works.
5329
5330     Function:  ustr_sub_subustr()
5331       Returns: Success or failure
5332       Type: int
5333
5334       Parameter[1]: Pointer to a pointer to a Ustr string
5335       Type[1]: struct Ustr **
5336
5337       Parameter[2]: Position where to start substitution
5338       Type[2]: size_t
5339
5340       Parameter[3]: A pointer to a constant Ustr string
5341       Type[3]: const struct Ustr *
5342
5343       Parameter[4]: Position in the Ustr
5344       Type[4]: size_t
5345
5346       Parameter[5]: Length to substitute from the Ustr
5347       Type[5]: size_t
5348
5349       Explanation:
5350
5351         This function mostly as if you had  called  ustr_sub_buf()  with  the
5352       ustr_cstr()  +  position - 1 and length values of the Ustr string to be
5353       insed. The exception being if you insert a ustr to itself,  while  only
5354       having  a  single  reference  count,  the  simple method would access a
5355       free'd ustr data, but this function just works.
5356
5357     Function:  ustr_sc_sub_undef()
5358       Returns: Success or failure
5359       Type: int
5360
5361       Parameter[1]: Pointer to a pointer to a Ustr
5362       Type[1]: struct Ustr **
5363
5364       Parameter[2]: Position where to start substitution
5365       Type[2]: size_t
5366
5367       Parameter[3]: Length of substitution
5368       Type[3]: size_t
5369
5370       Parameter[4]: Length of undefined data
5371       Type[4]: size_t
5372
5373       Explanation:
5374
5375         This function works as if you had done ustr_del_subustr() followed by
5376       ustr_ins_undef(), however it is significantly more efficient.
5377
5378     Function:  ustr_sc_sub_buf()
5379       Returns: Success or failure
5380       Type: int
5381
5382       Parameter[1]: Pointer to a pointer to a Ustr
5383       Type[1]: struct Ustr **
5384
5385       Parameter[2]: Position where to start substitution
5386       Type[2]: size_t
5387
5388       Parameter[3]: Length of substitution
5389       Type[3]: size_t
5390
5391       Parameter[4]: Buffer containting substitute data
5392       Type[4]: const void *
5393
5394       Parameter[5]: Length of Buffer
5395       Type[5]: size_t
5396
5397       Explanation:
5398
5399         This  function  will  substitute a specific number of characters in a
5400       Ustr with the data from a buffer, this function does the job of one  or
5401       more of ustr_add_buf(), ustr_sub_buf() and ustr_del().
5402
5403     Function:  ustr_sc_sub_cstr()
5404       Returns: Success or failure
5405       Type: int
5406
5407       Parameter[1]: Pointer to a pointer to a Ustr
5408       Type[1]: struct Ustr **
5409
5410       Parameter[2]: Position where to start replacement
5411       Type[2]: size_t
5412
5413       Parameter[3]: Length of substitution
5414       Type[3]: size_t
5415
5416       Parameter[4]:  A pointer to a constant C-style string, containing span‐
5417       ning bytes
5418       Type[4]: const char *
5419
5420       Explanation:
5421
5422         This function works like ustr_sc_sub_buf() but the length  is  worked
5423       out automatically by strlen().
5424
5425     Function:  ustr_sc_sub()
5426       Returns: success or failure
5427       Type: int
5428
5429       Parameter[1]: Pointer to a pointer to a Ustr
5430       Type[1]: struct Ustr **
5431
5432       Parameter[2]: Position where to start substitution
5433       Type[2]: size_t
5434
5435       Parameter[3]: Length of substitution
5436       Type[3]: size_t
5437
5438       Parameter[4]: Pointer to a Ustr containing the substitute string
5439       Type[4]: const struct Ustr *
5440
5441       Explanation:
5442
5443         This  function  works as if you had called ustr_sc_sub_buf() with the
5444       ustr_cstr() and ustr_len() values of the Ustr string to be  added.  The
5445       exception being if you substitute a ustr into itself, while only having
5446       a single reference count, the simple method could access a free'd  ustr
5447       data, but this function just works.
5448
5449     Function:  ustr_sc_sub_subustr()
5450       Returns: Success or failure
5451       Type: int
5452
5453       Parameter[1]: Pointer to a pointer to a Ustr
5454       Type[1]: struct Ustr **
5455
5456       Parameter[2]: Position where to start substitution
5457       Type[2]: size_t
5458
5459       Parameter[3]: Length of substitution
5460       Type[3]: size_t
5461
5462       Parameter[4]: A pointer to a constant Ustr string
5463       Type[4]: const struct Ustr *
5464
5465       Parameter[5]: Position in the Ustr
5466       Type[5]: size_t
5467
5468       Parameter[6]: Length to substitute from the Ustr
5469       Type[6]: size_t
5470
5471       Explanation:
5472
5473         This  function mostly as if you had called ustr_sc_sub_buf() with the
5474       ustr_cstr() + position - 1 and length values of the Ustr string  to  be
5475       insed.  The  exception being if you insert a ustr to itself, while only
5476       having a single reference count,  the  simple  method  would  access  a
5477       free'd ustr data, but this function just works.
5478
5479     Function:  USTR_SC_SUB_OSTR()
5480       Returns: Success or failure
5481       Type: int
5482
5483       Parameter[1]: Pointer to a pointer to a Ustr string
5484       Type[1]: struct Ustr **
5485
5486       Parameter[2]: Position where to start substitution
5487       Type[2]: size_t
5488
5489       Parameter[3]: Length of substitution
5490       Type[3]: size_t
5491
5492       Parameter[4]: A constant C-style string
5493       Type[4]: const char []
5494
5495       Explanation:
5496
5497         This function works as if you had called ustr_sc_sub_buf() and passed
5498       sizeof() - 1 as the length.
5499
5500     Function:  USTR_SC_SUB_OBJ()
5501       Returns: Success or failure
5502       Type: int
5503
5504       Parameter[1]: Pointer to a pointer to a Ustr string
5505       Type[1]: struct Ustr **
5506
5507       Parameter[2]: Position where to start substitution
5508       Type[2]: size_t
5509
5510       Parameter[3]: Length of substitution
5511       Type[3]: size_t
5512
5513       Parameter[4]: A symbol
5514       Type[4]: ...
5515
5516       Explanation:
5517
5518         This function works as if you had called ustr_sc_sub_buf() and passed
5519       sizeof() as the length.
5520
5521       Note:
5522
5523         In most cases you'll want to use USTR_SUB_OSTR().
5524
5525     Function:  ustr_replace_buf()
5526       Returns: Number of tokens replaced
5527       Type: size_t
5528
5529       Parameter[1]: Pointer to a pointer to a Ustr (haystack)
5530       Type[1]: struct Ustr **
5531
5532       Parameter[2]: Buffer containting search data
5533       Type[2]: const void *
5534
5535       Parameter[3]: Length of search buffer
5536       Type[3]: size_t
5537
5538       Parameter[4]: Buffer containting replacement data
5539       Type[4]: const void *
5540
5541       Parameter[5]: Length of replacement buffer
5542       Type[5]: size_t
5543
5544       Parameter[6]: Maximum number of matches to replace (0 for unlimited)
5545       Type[6]: size_t
5546
5547       Explanation:
5548
5549         This  function  scans  the  "haystack"  (Parameter[1])  for  "needle"
5550       (Parameter[2]) and  replaces  max_replacements  (Parameter[6])  matches
5551       with the "replacement" (Parameter[4]).
5552
5553       Note:
5554
5555         If  max_replacements  (Parameter[6]) is 0, this function will replace
5556       ALL occurrences.
5557
5558     Function:  ustr_replace_cstr()
5559       Returns: Number of tokens replaced
5560       Type: size_t
5561
5562       Parameter[1]: Pointer to a pointer to a Ustr (haystack)
5563       Type[1]: struct Ustr **
5564
5565       Parameter[2]: A pointer to a constant C-style string, containing search
5566       bytes
5567       Type[2]: const char *
5568
5569       Parameter[3]:  A  pointer  to  a  constant  C-style  string, containing
5570       replacement bytes
5571       Type[3]: const char *
5572
5573       Parameter[4]: Maximum number of matches to replace (0 for unlimited)
5574       Type[4]: size_t
5575
5576       Explanation:
5577
5578         This function works like ustr_replace_buf() but gets the lengths  for
5579       the buffer automatically from strlen().
5580
5581     Function:  ustr_replace()
5582       Returns: Number of tokens replaced
5583       Type: int
5584
5585       Parameter[1]: Pointer to a pointer to a Ustr (haystack)
5586       Type[1]: struct Ustr **
5587
5588       Parameter[2]: Ustr to search for (needle)
5589       Type[2]: const struct Ustr *
5590
5591       Parameter[3]: Ustr to replace needle with
5592       Type[3]: const struct Ustr *
5593
5594       Parameter[4]: Maximum number of matches to replace (0 for unlimited)
5595       Type[4]: size_t
5596
5597       Explanation:
5598
5599         This function works like ustr_replace_buf() but gets the lengths from
5600       the ustr automatically.
5601
5602     Function:  ustr_replace_rep_chr()
5603       Returns: number of replacements made
5604       Type: size_t
5605
5606       Parameter[1]: pointer to a pointer to a Ustr to be modified
5607       Type[1]: struct Ustr **ps1
5608
5609       Parameter[2]: character to replace
5610       Type[2]: char
5611
5612       Parameter[3]: number of characters to replace
5613       Type[3]: size_t
5614
5615       Parameter[4]: character to replace with
5616       Type[4]: char
5617
5618       Parameter[5]: number of characters to replace with
5619       Type[5]: size_t nlen
5620
5621       Parameter[6]: maximum number of replacements to make (use 0 for  unlim‐
5622       ited)
5623       Type[6]: size_t lim
5624
5625       Explanation:
5626
5627         This  function  replaces  a  repeating  sequence  of  characters with
5628       another repeating sequence of characters.
5629         For example...
5630
5631         Ustr *data = ustr_dup_cstr("xxxBxxCxDxxx");
5632         ustr_replace_rep_chr(&data,'x',2,'y',1, 0)
5633
5634        ...would change data to be "yxByCxDyx".
5635
5636
5637
5638       Note:
5639
5640         Changing the same letter the same number of  times  is  considered  a
5641       No-op  since  it is a vast performance improvement this way. So passing
5642       in  (&data,'y',2,'y',2 ,0) will have a return value of 0 and the string
5643       will be unchanged.
5644
5645

Splitting a Ustr

5647     Function:  ustr_split_buf()
5648       Returns: pointer to a Ustr representing the next token
5649       Type: struct Ustr *
5650
5651       Parameter[1]: Pointer to a constant Ustr to be split
5652       Type[1]: const struct Ustr *
5653
5654       Parameter[2]: Pointer to an offset
5655       Type[2]: size_t *
5656
5657       Parameter[3]: Buffer to use as split search pattern
5658       Type[3]: const void *
5659
5660       Parameter[4]: Length of buffer
5661       Type[4]: size_t
5662
5663       Parameter[5]: Pointer to a Ustr to be used as the return value
5664       Type[5]: struct Ustr *
5665
5666       Parameter[6]: Flags with the prefix USTR_FLAG_SPLIT_
5667       Type[6]: unsigned int
5668
5669       Explanation:
5670
5671         This  function  works  in a manner similar to strtok(). Each time the
5672       function is called, the string inside of the buffer  (Parameter[3])  is
5673       used  as  a  search  pattern  at  which to split. If the pattern is not
5674       found, the entire string will be returned.  A  USTR_NULL  return  value
5675       indicates there are no more tokens remaining.
5676         Parameter[5]  is a a pointer to a Ustr where the return value will be
5677       placed. Passing a USTR_NULL to this parameter will cause the string  to
5678       be  allocated  and  MUST  be freed manually. If, however, you pass in a
5679       non-null Ustr to this parameter, each  call  to  ustr_split_buf()  will
5680       free  what  is  in  this  pointer  and  place the new token there (when
5681       USTR_NULL is returned, nothing  needs  to  be  free'd).   For  example,
5682       given...
5683
5684         Ustr *data = ...;
5685         Ustr *tok = USTR_NULL;
5686         const char *sep = ",";
5687         size_t off = 0;
5688         unsigned int flags = USTR_FLAGS_SPLIT_DEF;
5689
5690        ...there are two options...
5691
5692         while  ((tok  =  ustr_split_buf(data,  &off,  sep,  strlen(sep), tok,
5693       flags)))
5694         {
5695           /* Do something with tok -- but next iteration  of  the  loop  will
5696       free
5697            * and overwrite tok, so you must ustr_dup() if you want to keep it
5698       */
5699         }
5700         /* tok is now NULL again after the loop */
5701
5702        ...or...
5703
5704         while ((tok = ustr_split_buf(data, &off, sep, strlen(sep), USTR_NULL,
5705       flags)))
5706         {
5707           /*  Do  something  with  tok,  and it will NOT be freed in the next
5708       iteration of
5709            * the loop */
5710             ustr_free(tok); /* have to free to avoid mem leaks */
5711         }
5712
5713        ...the former of which being the safer option.
5714
5715
5716       Note:
5717
5718         There are several flags that will alter the behaviour of  this  func‐
5719       tion,   all   of   which   have   a   common  with  the  default  being
5720       USTR_FLAG_SPLIT_DEF.
5721         If you are calling this function directly, it  is  very  likely  that
5722       you'd want to use ustr_split_cstr() instead.
5723
5724     Function:  ustr_split()
5725       Returns: Pointer to a Ustr representing the next token
5726       Type: struct Ustr *
5727
5728       Parameter[1]: Pointer to a constant Ustr to be split
5729       Type[1]: const struct Ustr *
5730
5731       Parameter[2]: Pointer to an offset variable
5732       Type[2]: size_t *
5733
5734       Parameter[3]:  Pointer  to  a  constant Ustr to use as the split search
5735       pattern
5736       Type[3]: const struct Ustr *
5737
5738       Parameter[4]: Pointer to a Ustr where the return value will be placed
5739       Type[4]: struct Ustr *
5740
5741       Parameter[5]: Flags
5742       Type[5]: unsigned int
5743
5744       Explanation:
5745
5746          Works like ustr_split_buf() but takes a Ustr  as  the  split  search
5747       pattern
5748         instead.
5749
5750     Function:  ustr_split_cstr()
5751       Returns: Pointer to a Ustr representing the next token
5752       Type: struct Ustr *
5753
5754       Parameter[1]: Pointer to a constant Ustr to be split
5755       Type[1]: const struct Ustr *
5756
5757       Parameter[2]: Pointer to an offset variable
5758       Type[2]: size_t *
5759
5760       Parameter[3]: C string to use as split search pattern
5761       Type[3]: const char *
5762
5763       Parameter[4]: Pointer to a Ustr where the return value will be placed
5764       Type[4]: struct Ustr *
5765
5766       Parameter[5]: Flags
5767       Type[5]: unsigned int
5768
5769       Explanation:
5770
5771         Works  like ustr_split_buf() but takes a C string as the split search
5772       pattern, and so gets the length via. strlen().
5773
5774     Function:  ustr_split_spn_chrs()
5775       Returns: Pointer to a Ustr representing the next token
5776       Type: struct Ustr *
5777
5778       Parameter[1]: Pointer to a Ustr to be split
5779       Type[1]: const struct Ustr *
5780
5781       Parameter[2]: Pointer to an offset variable
5782       Type[2]: size_t *
5783
5784       Parameter[3]: String representing a set of bytes to use as split chars
5785       Type[3]: const char *
5786
5787       Parameter[4]: Length of the string of set of bytes
5788       Type[4]: size_t
5789
5790       Parameter[5]: Pointer to a Ustr where the return value will be placed
5791       Type[5]: struct Ustr *
5792
5793       Parameter[6]: flags
5794       Type[6]: unsigned int
5795
5796       Explanation:
5797
5798         Works like ustr_split_buf() but uses the individual  ASCII  bytes  in
5799       the  separator  string (Parameter[3]) as search patterns. It will split
5800       if ANY of these individual characters are matched (much like strtok()).
5801       For  example:  if splitting "this, is,a test" with the separator string
5802       ", " the tokens returned would be {"this" "is" "a" "test"};
5803
5804       Note:
5805
5806         If you are calling this function directly, it  is  very  likely  that
5807       you'd want to use ustr_split_spn_cstr() instead.
5808
5809     Function:  ustr_split_spn_cstr()
5810       Returns: Pointer to a Ustr representing the next token
5811       Type: struct Ustr *
5812
5813       Parameter[1]: Pointer to a Ustr to be split
5814       Type[1]: const struct Ustr *
5815
5816       Parameter[2]: Pointer to an offset variable
5817       Type[2]: size_t *
5818
5819       Parameter[3]: String representing a set of bytes to use as split chars
5820       Type[3]: const char *
5821
5822       Parameter[4]: Pointer to a Ustr where the return value will be placed
5823       Type[4]: struct Ustr *
5824
5825       Parameter[5]: flags
5826       Type[5]: unsigned int
5827
5828       Explanation:
5829
5830         Works  like  ustr_split_spn_chrs()  but gets the length automatically
5831       via. strlen().
5832
5833     Function:  ustr_split_spn()
5834       Returns: Pointer to a Ustr representing the next token
5835       Type: struct Ustr *
5836
5837       Parameter[1]: Pointer to a constant Ustr to be split
5838       Type[1]: const struct Ustr *
5839
5840       Parameter[2]: Pointer to an offset variable
5841       Type[2]: size_t *
5842
5843       Parameter[3]: Pointer to a constant Ustr to use  as  the  split  search
5844       pattern
5845       Type[3]: const struct Ustr *
5846
5847       Parameter[4]: Pointer to a Ustr where the return value will be placed
5848       Type[4]: struct Ustr *
5849
5850       Parameter[5]: Flags
5851       Type[5]: unsigned int
5852
5853       Explanation:
5854
5855         Works  like ustr_split_spn_chrs() but takes a Ustr as the split chars
5856       instead.
5857
5858

Dealing with UTF-8 in a Ustr

5860     Function:  ustr_utf8_valid()
5861       Returns: A boolean flag of either USTR_TRUE or USTR_FALSE
5862       Type: int
5863
5864       Parameter[1]: A pointer to a constant Ustr string
5865       Type[1]: const struct Ustr *
5866
5867       Explanation:
5868
5869         This function tries it's best to find out if the string  is  a  valid
5870       utf-8 string.
5871
5872     Function:  ustr_utf8_len()
5873       Returns: The number of the utf-8 characters in the Ustr
5874       Type: size_t
5875
5876       Parameter[1]: A pointer to a constant Ustr string
5877       Type[1]: const struct Ustr *
5878
5879       Explanation:
5880
5881         This function counts the number of utf-8 characters inn the Ustr.
5882
5883       Note:
5884
5885         This  function  gives  undefined answers on strings that aren't utf-8
5886       valid.
5887
5888     Function:  ustr_utf8_width()
5889       Returns: ssize_t
5890       Type: ssize_t
5891
5892       Parameter[1]: A pointer to a constant Ustr string
5893       Type[1]: const struct Ustr *
5894
5895       Explanation:
5896
5897         This function returns the visible width of the string, assuming it is
5898       a  valid  utf-8  string. This is like converting to wide characters and
5899       using wcwidth().
5900
5901     Function:  ustr_utf8_chars2bytes()
5902       Returns: Length of span in bytes
5903       Type: size_t
5904
5905       Parameter[1]: A pointer to a constant Ustr string
5906       Type[1]: const struct Ustr *
5907
5908       Parameter[2]: Position of a span in utf-8 characters
5909       Type[2]: size_t
5910
5911       Parameter[3]: Length of a span in utf-8 characters
5912       Type[3]: size_t
5913
5914       Parameter[4]: Returns the position of the span in bytes
5915       Type[4]: size_t *
5916
5917       Explanation:
5918
5919         This function converts a span, in utf-8 characters, to the same  span
5920       in bytes.
5921
5922     Function:  ustr_utf8_bytes2chars()
5923       Returns: Returns the position of a span in utf-8 characters
5924       Type: size_t
5925
5926       Parameter[1]: A pointer to a constant Ustr string
5927       Type[1]: const struct Ustr *
5928
5929       Parameter[2]: Position of a span in bytes
5930       Type[2]: size_t
5931
5932       Parameter[3]: Length of a span in bytes
5933       Type[3]: size_t
5934
5935       Parameter[4]: Returns length of a span in utf-8 characters
5936       Type[4]: size_t *
5937
5938       Explanation:
5939
5940         This  function  converts  a span, in bytes, to the same span in utf-8
5941       characters.
5942
5943       Note:
5944
5945         Because a byte span can start or end within a utf-8  character,  con‐
5946       verting  the return values back into bytes via. ustr_utf8_chars2bytes()
5947       may make the span be slightly bigger (position  slightly  earlier,  and
5948       the length slightly longer).
5949
5950     Function:  ustr_sc_utf8_reverse()
5951       Returns: Success or failure
5952       Type: int
5953
5954       Parameter[1]: A pointer to a pointer to a Ustr string
5955       Type[1]: struct Ustr **
5956
5957       Explanation:
5958
5959         This  function  reverses  the  utf-8  characters  in the Ustr string,
5960       assuming it is a valid utf-8 string, so the last one becomes the  first
5961       and the second to last becomes the second etc.
5962
5963

Parsing ASCII integer numbers from a Ustr

5965     Function:  ustr_parse_uintmaxx()
5966       Returns: Parsed number, or zero on error
5967       Type: uintmax_t
5968
5969       Parameter[1]: A pointer to a constant Ustr string
5970       Type[1]: const struct Ustr *
5971
5972       Parameter[2]: Offset within string to start parsing at
5973       Type[2]: size_t
5974
5975       Parameter[3]: Base (2-36) and flags, starting with USTR_FLAG_PARSE_NUM_
5976       Type[3]: unsigned int
5977
5978       Parameter[4]: Absolute minimum value
5979       Type[4]: uintmax_t
5980
5981       Parameter[5]: Absolute maximum value
5982       Type[5]: uintmax_t
5983
5984       Parameter[6]: Thousands separator
5985       Type[6]: const char *
5986
5987       Parameter[7]: Return length of parsed number
5988       Type[7]: size_t *
5989
5990       Parameter[8]: Return error code, starting with USTR_TYPE_PARSE_NUM_ERR_
5991       Type[8]: unsigned int *
5992
5993       Explanation:
5994
5995         This  function parses an ASCII representation of a number from a Ustr
5996       (Parameter[1]) starting at the offset (Parameter[2]).
5997
5998       Note:
5999
6000         If stdint.h isn't available this function won't be available.
6001
6002     Function:  ustr_parse_uintmax()
6003       Returns: Parsed number, or zero on error
6004       Type: uintmax_t
6005
6006       Parameter[1]: A pointer to a constant Ustr string
6007       Type[1]: const struct Ustr *
6008
6009       Parameter[2]: Offset within string to start parsing at
6010       Type[2]: size_t
6011
6012       Parameter[3]: Base (2-36) and flags, starting with USTR_FLAG_PARSE_NUM_
6013       Type[3]: unsigned int
6014
6015       Parameter[4]: Return length of parsed number
6016       Type[4]: size_t *
6017
6018       Parameter[5]: Return error code, starting with USTR_TYPE_PARSE_NUM_ERR_
6019       Type[5]: unsigned int *
6020
6021       Explanation:
6022
6023         This function works like ustr_parse_uintmaxx() with the  minimum  and
6024       maximum  values taken as 0 and UINTMAX_MAX, and the thousands separator
6025       as "_".
6026
6027       Note:
6028
6029         If stdint.h isn't available this function won't be available.
6030
6031     Function:  ustr_parse_intmax()
6032       Returns: Parsed number, or zero on error
6033       Type: intmax_t
6034
6035       Parameter[1]: A pointer to a constant Ustr string
6036       Type[1]: const struct Ustr *
6037
6038       Parameter[2]: Offset within string to start parsing at
6039       Type[2]: size_t
6040
6041       Parameter[3]: Base (2-36) and flags, starting with USTR_FLAG_PARSE_NUM_
6042       Type[3]: unsigned int
6043
6044       Parameter[4]: Return length of parsed number
6045       Type[4]: size_t *
6046
6047       Parameter[5]: Return error code, starting with USTR_TYPE_PARSE_NUM_ERR_
6048       Type[5]: unsigned int *
6049
6050       Explanation:
6051
6052         This function works like ustr_parse_uintmaxx() with the  minimum  and
6053       maximum  values  taken as -INTMAX_MIN and INTMAX_MAX, and the thousands
6054       separator as "_".
6055
6056       Note:
6057
6058         If stdint.h isn't available this function won't be available.
6059
6060     Function:  ustr_parse_ulongx()
6061       Returns: Parsed number, or zero on error
6062       Type: unsigned long
6063
6064       Parameter[1]: A pointer to a constant Ustr string
6065       Type[1]: const struct Ustr *
6066
6067       Parameter[2]: Offset within string to start parsing at
6068       Type[2]:  size_t
6069
6070       Parameter[3]: Base (2-36) and flags, starting with USTR_FLAG_PARSE_NUM_
6071       Type[3]:  unsigned int
6072
6073       Parameter[4]: Absolute minimum value
6074       Type[4]:  unsigned long
6075
6076       Parameter[5]: Absolute maximum value
6077       Type[5]:  unsigned long
6078
6079       Parameter[6]: Thousands separator
6080       Type[6]: const char *
6081
6082       Parameter[7]: Return length of parsed number
6083       Type[7]:  size_t *
6084
6085       Parameter[8]: Return error code, starting with USTR_TYPE_PARSE_NUM_ERR_
6086       Type[8]: unsigned int *
6087
6088       Explanation:
6089
6090         This  function  works  like  ustr_parse_uintmaxx()  but  returns   an
6091       unsigned long, it is always available even when stdint.h isn't.
6092
6093     Function:  ustr_parse_ulong()
6094       Returns: Parsed number, or zero on error
6095       Type: unsigned long
6096
6097       Parameter[1]: A pointer to a constant Ustr string
6098       Type[1]: const struct Ustr *
6099
6100       Parameter[2]: Offset within string to start parsing at
6101       Type[2]: size_t
6102
6103       Parameter[3]: Base (2-36) and flags, starting with USTR_FLAG_PARSE_NUM_
6104       Type[3]: unsigned int
6105
6106       Parameter[4]: Return length of parsed number
6107       Type[4]: size_t *
6108
6109       Parameter[5]: Return error code, starting with USTR_TYPE_PARSE_NUM_ERR_
6110       Type[5]: unsigned int *
6111
6112       Explanation:
6113
6114         This  function  works  like  ustr_parse_ulongx() with the minimum and
6115       maximum values taken as 0 and ULONG_MAX, and the thousands separator as
6116       "_".
6117
6118     Function:  ustr_parse_long()
6119       Returns: Parsed number, or zero on error
6120       Type: long
6121
6122       Parameter[1]: A pointer to a constant Ustr string
6123       Type[1]: const struct Ustr *
6124
6125       Parameter[2]: Offset within string to start parsing at
6126       Type[2]: size_t
6127
6128       Parameter[3]: Base (2-36) and flags, starting with USTR_FLAG_PARSE_NUM_
6129       Type[3]: unsigned int
6130
6131       Parameter[4]: Return length of parsed number
6132       Type[4]: size_t *
6133
6134       Parameter[5]: Return error code, starting with USTR_TYPE_PARSE_NUM_ERR_
6135       Type[5]: unsigned int *
6136
6137       Explanation:
6138
6139         This  function  works  like  ustr_parse_ulongx() with the minimum and
6140       maximum values taken as -LONG_MIN and LONG_MAX, and the thousands sepa‐
6141       rator as "_".
6142
6143     Function:  ustr_parse_uint()
6144       Returns: Parsed number, or zero on error
6145       Type: unsigned int
6146
6147       Parameter[1]: A pointer to a constant Ustr string
6148       Type[1]: const struct Ustr *
6149
6150       Parameter[2]: Offset within string to start parsing at
6151       Type[2]: size_t
6152
6153       Parameter[3]: Base (2-36) and flags, starting with USTR_FLAG_PARSE_NUM_
6154       Type[3]: unsigned int
6155
6156       Parameter[4]: Return length of parsed number
6157       Type[4]: size_t *
6158
6159       Parameter[5]: Return error code, starting with USTR_TYPE_PARSE_NUM_ERR_
6160       Type[5]: unsigned int *
6161
6162       Explanation:
6163
6164         This  function  works  like  ustr_parse_ulongx() with the minimum and
6165       maximum values taken as 0 and UINT_MAX, and the thousands separator  as
6166       "_".
6167
6168     Function:  ustr_parse_int()
6169       Returns: Parsed number, or zero on error
6170       Type: int
6171
6172       Parameter[1]: A pointer to a constant Ustr string
6173       Type[1]: const struct Ustr *
6174
6175       Parameter[2]: Offset within string to start parsing at
6176       Type[2]: size_t
6177
6178       Parameter[3]: Base (2-36) and flags, starting with USTR_FLAG_PARSE_NUM_
6179       Type[3]: unsigned int
6180
6181       Parameter[4]: Return length of parsed number
6182       Type[4]: size_t *
6183
6184       Parameter[5]: Return error code, starting with USTR_TYPE_PARSE_NUM_ERR_
6185       Type[5]: unsigned int *
6186
6187       Explanation:
6188
6189         This  function  works  like  ustr_parse_ulongx() with the minimum and
6190       maximum values taken as -INT_MIN and INT_MAX, and the thousands separa‐
6191       tor as "_".
6192
6193     Function:  ustr_parse_ushort()
6194       Returns: Parsed number, or zero on error
6195       Type: unsigned short
6196
6197       Parameter[1]: A pointer to a constant Ustr string
6198       Type[1]: const struct Ustr *
6199
6200       Parameter[2]: Offset within string to start parsing at
6201       Type[2]: size_t
6202
6203       Parameter[3]: Base (2-36) and flags, starting with USTR_FLAG_PARSE_NUM_
6204       Type[3]: unsigned int
6205
6206       Parameter[4]: Return length of parsed number
6207       Type[4]: size_t *
6208
6209       Parameter[5]: Return error code, starting with USTR_TYPE_PARSE_NUM_ERR_
6210       Type[5]: unsigned int *
6211
6212       Explanation:
6213
6214         This  function  works  like  ustr_parse_ulongx() with the minimum and
6215       maximum values taken as 0 and USHRT_MAX, and the thousands separator as
6216       "_".
6217
6218     Function:  ustr_parse_short()
6219       Returns: Parsed number, or zero on error
6220       Type: short
6221
6222       Parameter[1]: A pointer to a constant Ustr string
6223       Type[1]: const struct Ustr *
6224
6225       Parameter[2]: Offset within string to start parsing at
6226       Type[2]: size_t
6227
6228       Parameter[3]: Base (2-36) and flags, starting with USTR_FLAG_PARSE_NUM_
6229       Type[3]: unsigned int
6230
6231       Parameter[4]: Return length of parsed number
6232       Type[4]: size_t *
6233
6234       Parameter[5]: Return error code, starting with USTR_TYPE_PARSE_NUM_ERR_
6235       Type[5]: unsigned int *
6236
6237       Explanation:
6238
6239         This  function  works  like  ustr_parse_ulongx() with the minimum and
6240       maximum values taken as -SHRT_MIN and SHRT_MAX, and the thousands sepa‐
6241       rator as "_".
6242
6243

Misc shortcut helper functions for Ustrs

6245     Function:  ustr_sc_ensure_owner()
6246       Returns: Success or failure
6247       Type: int
6248
6249       Parameter[1]: A pointer to a pointer to a Ustr string
6250       Type[1]: struct Ustr **
6251
6252       Explanation:
6253
6254         This  function  makes  sure  that  the  Ustr  string is owned when it
6255       returns (Ie. ustr_owner() returns USTR_TRUE), or it fails to allocate.
6256
6257     Function:  ustr_sc_wstr()
6258       Returns: Writable pointer to the start of data in the Ustr, or NULL
6259       Type: char *
6260
6261       Parameter[1]: A pointer to a pointer to a Ustr string
6262       Type[1]: struct Ustr **
6263
6264       Explanation:
6265
6266         This function works like calling ustr_sc_ensure_owner(), to make sure
6267       the   Ustr  string  is  writable,  and  if  that  succeeds  it  returns
6268       ustr_wstr(). On failure it returns NULL.
6269
6270     Function:  ustr_sc_export_subustr()
6271       Returns: A pointer to newly allocated block of memory
6272       Type: char *
6273
6274       Parameter[1]: A pointer to a constant Ustr string
6275       Type[1]: const struct Ustr *
6276
6277       Parameter[2]: Position in the Ustr
6278       Type[2]: size_t
6279
6280       Parameter[3]: Length to export from the Ustr
6281       Type[3]: size_t
6282
6283       Parameter[4]: Allocation function (like malloc)
6284       Type[4]: void *(*)(size_t)
6285
6286       Explanation:
6287
6288         This function allocates a block of memory  of  size  Length  (Parame‐
6289       ter[3])  + 1  using the provided allocation function (Parameter[4]) and
6290       copies the data starting from Position (Parameter[2]) within the ustr.
6291
6292     Function:  ustr_sc_export()
6293       Returns: A pointer to newly allocated block of memory
6294       Type: char *
6295
6296       Parameter[1]: A pointer to a constant Ustr string
6297       Type[1]: const struct Ustr *
6298
6299       Parameter[2]: Allocation function (like malloc)
6300       Type[2]: void *(*)(size_t)
6301
6302       Explanation:
6303
6304         This function works  like  calling  ustr_sc_export_subustr()  with  a
6305       position of 1 and a length of ustr_len().
6306
6307     Function:  ustrp_sc_export_subustrp()
6308       Returns: A pointer to newly allocated block of memory
6309       Type: char *
6310
6311       Parameter[1]: Pointer to a Ustr pool object
6312       Type[1]: struct Ustr_pool *
6313
6314       Parameter[2]: A pointer to a constant Ustr string
6315       Type[2]: const struct Ustr *
6316
6317       Parameter[3]: Position in the Ustr
6318       Type[3]: size_t
6319
6320       Parameter[4]: Length to export from the Ustr
6321       Type[4]: size_t
6322
6323       Parameter[5]: Allocation function (like malloc), or NULL
6324       Type[5]: void *(*)(size_t)
6325
6326       Explanation:
6327
6328         This  function  allocates  a  block of memory of size Length (Parame‐
6329       ter[4]) + 1  using either the  provided  allocation  function  (Parame‐
6330       ter[5]), or from the pool object if the allocation function is NUL, and
6331       copies the data starting from Position (Parameter[3]) within the ustr.
6332
6333     Function:  ustrp_sc_export()
6334       Returns: A pointer to newly allocated block of memory
6335       Type: char *
6336
6337       Parameter[1]: Pointer to a Ustr pool object
6338       Type[1]: struct Ustr_pool *
6339
6340       Parameter[2]: A pointer to a constant Ustr string
6341       Type[2]: const struct Ustr *
6342
6343       Parameter[3]: Allocation function (like malloc)
6344       Type[3]: void *(*)(size_t)
6345
6346       Explanation:
6347
6348         This function works like calling  ustrp_sc_export_subustrp()  with  a
6349       position of 1 and a length of ustrp_len().
6350
6351     Function:  ustr_sc_reverse()
6352       Returns: Success or failure
6353       Type: int
6354
6355       Parameter[1]: A pointer to a pointer to a Ustr string
6356       Type[1]: struct Ustr **
6357
6358       Explanation:
6359
6360         This  function reverses all the bytes in the Ustr string, so the last
6361       one becomes the first and the second to last becomes the second etc.
6362
6363     Function:  ustr_sc_tolower()
6364       Returns: Success or failure
6365       Type: int
6366
6367       Parameter[1]: A pointer to a pointer to a Ustr string
6368       Type[1]: struct Ustr **
6369
6370       Explanation:
6371
6372         This function changes any ASCII upper case  bytes  into  ASCII  lower
6373       case bytes.
6374
6375     Function:  ustr_sc_toupper()
6376       Returns: Success or failure
6377       Type: int
6378
6379       Parameter[1]: A pointer to a pointer to a Ustr string
6380       Type[1]: struct Ustr **
6381
6382       Explanation:
6383
6384         This  function  changes  any  ASCII lower case bytes into ASCII upper
6385       case bytes.
6386
6387     Function:  ustr_sc_ltrim_chrs()
6388       Returns: Success or failure
6389       Type: int
6390
6391       Parameter[1]: A pointer to a pointer to a Ustr string
6392       Type[1]: struct Ustr **
6393
6394       Parameter[2]: Array of bytes, containing trimming data
6395       Type[2]: const char *
6396
6397       Parameter[3]: Length of byte data
6398       Type[3]: size_t
6399
6400       Explanation:
6401
6402         This function deletes the bytes at the begining of the Ustr  (Parame‐
6403       ter[1])  that  are  in the span (Parameter[2]) of the specificed length
6404       (parameter[2]).
6405
6406     Function:  ustr_sc_ltrim()
6407       Returns: Success or failure
6408       Type: int
6409
6410       Parameter[1]: A pointer to a pointer to a Ustr string
6411       Type[1]: struct Ustr **
6412
6413       Parameter[2]: A pointer to a constant Ustr string, containing  trimming
6414       bytes
6415       Type[2]: const struct Ustr *
6416
6417       Explanation:
6418
6419         This  function  works  as  if you had called ustr_sc_ltrim_chrs() and
6420       passed ustr_cstr() and ustr_len() values of the  Ustr  string  (Parame‐
6421       ter[2]).
6422
6423     Function:  ustr_sc_ltrim_cstr()
6424       Returns: Success or failure
6425       Type: int
6426
6427       Parameter[1]: A pointer to a pointer to a Ustr string
6428       Type[1]: struct Ustr **
6429
6430       Parameter[2]:  A pointer to a constant C-style string, containing trim‐
6431       ming bytes
6432       Type[2]: const char *
6433
6434       Explanation:
6435
6436         This function works as if you  had  called  ustr_sc_ltrim_chrs()  and
6437       passed strlen() as the length.
6438
6439     Function:  ustr_sc_rtrim_chrs()
6440       Returns: Success or failure
6441       Type: int
6442
6443       Parameter[1]: A pointer to a pointer to a Ustr string
6444       Type[1]: struct Ustr **
6445
6446       Parameter[2]: Array of bytes, containing trimming data
6447       Type[2]: const char *
6448
6449       Parameter[3]: Length of byte data
6450       Type[3]: size_t
6451
6452       Explanation:
6453
6454         This function deletes the bytes at the end of the Ustr (Parameter[1])
6455       that are in the span (Parameter[2]) of the specificed  length  (parame‐
6456       ter[2]).
6457
6458     Function:  ustr_sc_rtrim()
6459       Returns: Success or failure
6460       Type: int
6461
6462       Parameter[1]: A pointer to a pointer to a Ustr string
6463       Type[1]: struct Ustr **
6464
6465       Parameter[2]:  A pointer to a constant Ustr string, containing trimming
6466       bytes
6467       Type[2]: const struct Ustr *
6468
6469       Explanation:
6470
6471         This function works as if you  had  called  ustr_sc_rtrim_chrs()  and
6472       passed  ustr_cstr()  and  ustr_len() values of the Ustr string (Parame‐
6473       ter[2]).
6474
6475     Function:  ustr_sc_rtrim_cstr()
6476       Returns: Success or failure
6477       Type: int
6478
6479       Parameter[1]: A pointer to a pointer to a Ustr string
6480       Type[1]: struct Ustr **
6481
6482       Parameter[2]: A pointer to a constant C-style string, containing  trim‐
6483       ming bytes
6484       Type[2]: const char *
6485
6486       Explanation:
6487
6488         This  function  works  as  if you had called ustr_sc_rtrim_chrs() and
6489       passed strlen() as the length.
6490
6491     Function:  ustr_sc_trim_chrs()
6492       Returns: Success or failure
6493       Type: int
6494
6495       Parameter[1]: A pointer to a pointer to a Ustr string
6496       Type[1]: struct Ustr **
6497
6498       Parameter[2]: Array of bytes, containing trimming data
6499       Type[2]: const char *
6500
6501       Parameter[3]: Length of byte data
6502       Type[3]: size_t
6503
6504       Explanation:
6505
6506         This function deletes the bytes at the begining or end  of  the  Ustr
6507       (Parameter[1])  that  are  in the span (Parameter[2]) of the specificed
6508       length (parameter[2]).
6509
6510       Note:
6511
6512         Calling  this  function  is  much   more   efficient   than   calling
6513       ustr_sc_rtrim_chrs()  and  then  ustr_sc_ltrim_chrs(), as both ends are
6514       trimmed in a single pass.
6515
6516     Function:  ustr_sc_trim()
6517       Returns: Success or failure
6518       Type: int
6519
6520       Parameter[1]: A pointer to a pointer to a Ustr string
6521       Type[1]: struct Ustr **
6522
6523       Parameter[2]: A pointer to a constant Ustr string, containing  trimming
6524       bytes
6525       Type[2]: const struct Ustr *
6526
6527       Explanation:
6528
6529         This  function  works  as  if  you had called ustr_sc_trim_chrs() and
6530       passed ustr_cstr() and ustr_len() values of the  Ustr  string  (Parame‐
6531       ter[2]).
6532
6533     Function:  ustr_sc_trim_cstr()
6534       Returns: Success or failure
6535       Type: int
6536
6537       Parameter[1]: A pointer to a pointer to a Ustr string
6538       Type[1]: struct Ustr **
6539
6540       Parameter[2]:  A pointer to a constant C-style string, containing trim‐
6541       ming bytes
6542       Type[2]: const char *
6543
6544       Explanation:
6545
6546         This function works as if  you  had  called  ustr_sc_trim_chrs()  and
6547       passed strlen() as the length.
6548
6549

Adding binary data to a Ustr

6551     Function:  ustr_add_b_uint16()
6552       Returns: Success or failure
6553       Type: int
6554
6555       Parameter[1]: Pointer to a pointer to a Ustr string
6556       Type[1]: struct Ustr **
6557
6558       Parameter[2]: Binary value to add to the Ustr
6559       Type[2]: uint_least16_t
6560
6561       Explanation:
6562
6563         This  function adds a binary representation of a value (Parameter[2])
6564       to the Ustr (Parameter[1]).
6565
6566     Function:  ustr_add_b_uint32()
6567       Returns: Success or failure
6568       Type: int
6569
6570       Parameter[1]: Pointer to a pointer to a Ustr string
6571       Type[1]: struct Ustr **
6572
6573       Parameter[2]: Binary value to add to the Ustr
6574       Type[2]: uint_least32_t
6575
6576       Explanation:
6577
6578         This function adds a binary representation of a value  (Parameter[2])
6579       to the Ustr (Parameter[1]).
6580
6581     Function:  ustr_add_b_uint64()
6582       Returns: Success or failure
6583       Type: int
6584
6585       Parameter[1]: Pointer to a pointer to a Ustr string
6586       Type[1]: struct Ustr **
6587
6588       Parameter[2]: Binary value to add to the Ustr
6589       Type[2]: uint_least64_t
6590
6591       Explanation:
6592
6593         This  function adds a binary representation of a value (Parameter[2])
6594       to the Ustr (Parameter[1]).
6595
6596

Parsing binary data from a Ustr

6598     Function:  ustr_parse_b_uint16()
6599       Returns: uint_least16_t
6600       Type: uint_least16_t
6601
6602       Parameter[1]: A pointer to a constant Ustr string
6603       Type[1]: const struct Ustr *
6604
6605       Parameter[2]: Offset within string to start parsing at
6606       Type[2]: size_t
6607
6608       Explanation:
6609
6610         This function parses a binary representation  from  a  Ustr  (Parame‐
6611       ter[1])  starting at the offset (Parameter[2]).
6612
6613     Function:  ustr_parse_b_uint32()
6614       Returns: uint_least32_t
6615       Type: uint_least32_t
6616
6617       Parameter[1]: A pointer to a constant Ustr string
6618       Type[1]: const struct Ustr *
6619
6620       Parameter[2]: Offset within string to start parsing at
6621       Type[2]: size_t
6622
6623       Explanation:
6624
6625         This  function  parses  a  binary representation from a Ustr (Parame‐
6626       ter[1])  starting at the offset (Parameter[2]).
6627
6628     Function:  ustr_parse_b_uint64()
6629       Returns: uint_least64_t
6630       Type: uint_least64_t
6631
6632       Parameter[1]: A pointer to a constant Ustr string
6633       Type[1]: const struct Ustr *
6634
6635       Parameter[2]: Offset within string to start parsing at
6636       Type[2]: size_t
6637
6638       Explanation:
6639
6640         This function parses a binary representation  from  a  Ustr  (Parame‐
6641       ter[1])  starting at the offset (Parameter[2]).
6642
6643

Misc. functions

6645     Function:  ustr_realloc()
6646       Returns: Success or failure
6647       Type: int
6648
6649       Parameter[1]: Pointer to a pointer to a Ustr string
6650       Type[1]: struct Ustr **
6651
6652       Parameter[2]: Size of allocation
6653       Type[2]: size_t
6654
6655       Explanation:
6656
6657         This  function  is  re-sizes  the Ustr to the specified size (Parame‐
6658       ter[2]).
6659         This is mostly used to shrink a sized Ustr that is now  significantly
6660       smaller than it once was. Although this function can also grow a Ustr.
6661
6662       Note:
6663
6664         To have a size that isn't implied from the length the Ustr must store
6665       a size value as well as a length (ustr_sized() must return USTR_TRUE).
6666
6667     Function:  ustr_cntl_opt()
6668       Returns: Success or failure
6669       Type: int
6670
6671       Parameter[1]: Optional value starting with USTR_CNTL_OPT_
6672       Type[1]: int
6673
6674       Parameter[2]: Arugments to option
6675       Type[2]: ...
6676
6677       Explanation:
6678
6679         This function views and/or changes global Ustr options, like  whether
6680       ustr's have an implicit or explicit size (USTR_CNTL_OPT_GET_HAS_SIZE).
6681
6682

Simple Ustr pool API

6684     Function:  ustr_pool_ll_make()
6685       Returns: Pointer to a Ustr pool object
6686       Type: struct Ustr_pool *
6687
6688       Parameter[1]: Nothing
6689       Type[1]: void
6690
6691       Explanation:
6692
6693         This  allocates  a  new  pool  using the "linked list" strategy, each
6694       allocation in the pool is added to a linked list ...  and  any  alloca‐
6695       tions  not  freed  directly are freed by the pool when it is cleared or
6696       freed.
6697
6698     Function:  ustr_pool_make_subpool()
6699       Returns: Pointer to a Ustr pool object
6700       Type: struct Ustr_pool *
6701
6702       Parameter[1]: struct Ustr_pool *
6703       Type[1]: struct Ustr_pool *
6704
6705       Explanation:
6706
6707         This allocates a new pool as a child of the passed in  pool  (Parame‐
6708       ter[1]),  The pool can be freed and cleared independantly of the parent
6709       pool however free and clear operations on the parent pool are automati‐
6710       cally applied to all child pools.
6711
6712     Function:  ustr_pool_free()
6713       Returns: Nothing
6714       Type: void
6715
6716       Parameter[1]: Pointer to a Ustr pool object
6717       Type[1]: struct Ustr_pool *
6718
6719       Explanation:
6720
6721         This deallocates a pool, and all sub-pools.
6722
6723       Note:
6724
6725         This also operates on all sub-pools.
6726
6727     Function:  ustr_pool_clear()
6728       Returns: Nothing
6729       Type: void
6730
6731       Parameter[1]: Pointer to a Ustr pool object
6732       Type[1]: struct Ustr_pool *
6733
6734       Explanation:
6735
6736         This  allows  all the data in the pool to be reused, it may also free
6737       some/all of the data in the pool, from the pool API.
6738
6739       Note:
6740
6741         This also operates on all sub-pools.
6742

SEE ALSO

6744       ustr_const(3)
6745
6746
6747
6748Ustr 1.0.4                        05-Mar-2008                          ustr(3)
Impressum