Subversion
svn_string.h
Go to the documentation of this file.
1 /**
2  * @copyright
3  * ====================================================================
4  * Licensed to the Apache Software Foundation (ASF) under one
5  * or more contributor license agreements. See the NOTICE file
6  * distributed with this work for additional information
7  * regarding copyright ownership. The ASF licenses this file
8  * to you under the Apache License, Version 2.0 (the
9  * "License"); you may not use this file except in compliance
10  * with the License. You may obtain a copy of the License at
11  *
12  * http://www.apache.org/licenses/LICENSE-2.0
13  *
14  * Unless required by applicable law or agreed to in writing,
15  * software distributed under the License is distributed on an
16  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
17  * KIND, either express or implied. See the License for the
18  * specific language governing permissions and limitations
19  * under the License.
20  * ====================================================================
21  * @endcopyright
22  *
23  * @file svn_string.h
24  * @brief Counted-length strings for Subversion, plus some C string goodies.
25  *
26  * There are two string datatypes: @c svn_string_t and @c svn_stringbuf_t.
27  * The former is a simple pointer/length pair useful for passing around
28  * strings (or arbitrary bytes) with a counted length. @c svn_stringbuf_t is
29  * buffered to enable efficient appending of strings without an allocation
30  * and copy for each append operation.
31  *
32  * @c svn_string_t contains a <tt>const char *</tt> for its data, so it is
33  * most appropriate for constant data and for functions which expect constant,
34  * counted data. Functions should generally use <tt>const @c svn_string_t
35  * *</tt> as their parameter to indicate they are expecting a constant,
36  * counted string.
37  *
38  * @c svn_stringbuf_t uses a plain <tt>char *</tt> for its data, so it is
39  * most appropriate for modifiable data.
40  *
41  * <h3>Invariants</h3>
42  *
43  * 1. Null termination:
44  *
45  * Both structures maintain a significant invariant:
46  *
47  * <tt>s->data[s->len] == '\\0'</tt>
48  *
49  * The functions defined within this header file will maintain
50  * the invariant (which does imply that memory is
51  * allocated/defined as @c len+1 bytes). If code outside of the
52  * @c svn_string.h functions manually builds these structures,
53  * then they must enforce this invariant.
54  *
55  * Note that an @c svn_string(buf)_t may contain binary data,
56  * which means that strlen(s->data) does not have to equal @c
57  * s->len. The null terminator is provided to make it easier to
58  * pass @c s->data to C string interfaces.
59  *
60  *
61  * 2. Non-NULL input:
62  *
63  * All the functions assume their input data pointer is non-NULL,
64  * unless otherwise documented, and may seg fault if passed
65  * NULL. The input data may *contain* null bytes, of course, just
66  * the data pointer itself must not be NULL.
67  *
68  * <h3>Memory allocation</h3>
69  *
70  * All the functions make a deep copy of all input data, and never store
71  * a pointer to the original input data.
72  */
73 
74 
75 #ifndef SVN_STRING_H
76 #define SVN_STRING_H
77 
78 #include <apr.h> /* for apr_size_t */
79 #include <apr_pools.h> /* for apr_pool_t */
80 #include <apr_tables.h> /* for apr_array_header_t */
81 
82 #include "svn_types.h" /* for svn_boolean_t, svn_error_t */
83 
84 #ifdef __cplusplus
85 extern "C" {
86 #endif /* __cplusplus */
87 
88 /**
89  * @defgroup svn_string String handling
90  * @{
91  */
92 
93 
94 
95 /** A simple counted string. */
96 typedef struct svn_string_t
97 {
98  const char *data; /**< pointer to the bytestring */
99  apr_size_t len; /**< length of bytestring */
100 } svn_string_t;
101 
102 /** A buffered string, capable of appending without an allocation and copy
103  * for each append. */
104 typedef struct svn_stringbuf_t
105 {
106  /** a pool from which this string was originally allocated, and is not
107  * necessarily specific to this string. This is used only for allocating
108  * more memory from when the string needs to grow.
109  */
110  apr_pool_t *pool;
111 
112  /** pointer to the bytestring */
113  char *data;
114 
115  /** length of bytestring */
116  apr_size_t len;
117 
118  /** total size of buffer allocated */
119  apr_size_t blocksize;
121 
122 
123 /**
124  * @defgroup svn_string_svn_string_t svn_string_t functions
125  * @{
126  */
127 
128 /** Create a new string copied from the null-terminated C string @a cstring.
129  */
130 svn_string_t *
131 svn_string_create(const char *cstring, apr_pool_t *pool);
132 
133 /** Create a new, empty string.
134  *
135  * @since New in 1.8.
136  */
137 svn_string_t *
138 svn_string_create_empty(apr_pool_t *pool);
139 
140 /** Create a new string copied from a generic string of bytes, @a bytes, of
141  * length @a size bytes. @a bytes is NOT assumed to be null-terminated, but
142  * the new string will be.
143  *
144  * @since Since 1.9, @a bytes can be NULL if @a size is zero.
145  */
146 svn_string_t *
147 svn_string_ncreate(const char *bytes, apr_size_t size, apr_pool_t *pool);
148 
149 /** Create a new string copied from the stringbuf @a strbuf.
150  */
151 svn_string_t *
152 svn_string_create_from_buf(const svn_stringbuf_t *strbuf, apr_pool_t *pool);
153 
154 /** Create a new string by printf-style formatting using @a fmt and the
155  * variable arguments, which are as appropriate for apr_psprintf().
156  */
157 svn_string_t *
158 svn_string_createf(apr_pool_t *pool, const char *fmt, ...)
159  __attribute__((format(printf, 2, 3)));
160 
161 /** Create a new string by printf-style formatting using @c fmt and @a ap.
162  * This is the same as svn_string_createf() except for the different
163  * way of passing the variable arguments.
164  */
165 svn_string_t *
166 svn_string_createv(apr_pool_t *pool, const char *fmt, va_list ap)
167  __attribute__((format(printf, 2, 0)));
168 
169 /** Return TRUE if @a str is empty (has length zero). */
171 svn_string_isempty(const svn_string_t *str);
172 
173 /** Return a duplicate of @a original_string.
174  *
175  * @since Since 1.9, @a original_string can be NULL in which case NULL will
176  * be returned.
177  */
178 svn_string_t *
179 svn_string_dup(const svn_string_t *original_string, apr_pool_t *pool);
180 
181 /** Return @c TRUE iff @a str1 and @a str2 have identical length and data. */
183 svn_string_compare(const svn_string_t *str1, const svn_string_t *str2);
184 
185 /** Return offset of first non-whitespace character in @a str, or return
186  * @a str->len if none.
187  */
188 apr_size_t
190 
191 /** Return position of last occurrence of @a ch in @a str, or return
192  * @a str->len if no occurrence.
193  */
194 apr_size_t
195 svn_string_find_char_backward(const svn_string_t *str, char ch);
196 
197 /** @} */
198 
199 
200 /**
201  * @defgroup svn_string_svn_stringbuf_t svn_stringbuf_t functions
202  * @{
203  */
204 
205 /** Create a new stringbuf copied from the null-terminated C string
206  * @a cstring.
207  */
209 svn_stringbuf_create(const char *cstring, apr_pool_t *pool);
210 
211 /** Create a new stringbuf copied from the generic string of bytes, @a bytes,
212  * of length @a size bytes. @a bytes is NOT assumed to be null-terminated,
213  * but the new stringbuf will be.
214  *
215  * @since Since 1.9, @a bytes can be NULL if @a size is zero.
216  */
218 svn_stringbuf_ncreate(const char *bytes, apr_size_t size, apr_pool_t *pool);
219 
220 /** Create a new, empty stringbuf.
221  *
222  * @since New in 1.8.
223  */
225 svn_stringbuf_create_empty(apr_pool_t *pool);
226 
227 /** Create a new, empty stringbuf with at least @a minimum_size bytes of
228  * space available in the memory block.
229  *
230  * The allocated string buffer will be at least one byte larger than
231  * @a minimum_size to account for a final '\\0'.
232  *
233  * @since New in 1.6.
234  */
236 svn_stringbuf_create_ensure(apr_size_t minimum_size, apr_pool_t *pool);
237 
238 /** Create a new stringbuf copied from the string @a str.
239  */
241 svn_stringbuf_create_from_string(const svn_string_t *str, apr_pool_t *pool);
242 
243 /** Create a new stringbuf using the given @a str as initial buffer.
244  * Allocate the result in @a pool. In contrast to #svn_stringbuf_create,
245  * the contents of @a str may change when the stringbuf gets modified.
246  *
247  * @since New in 1.9
248  */
250 svn_stringbuf_create_wrap(char *str, apr_pool_t *pool);
251 
252 /** Create a new stringbuf by printf-style formatting using @a fmt and the
253  * variable arguments, which are as appropriate for apr_psprintf().
254  */
256 svn_stringbuf_createf(apr_pool_t *pool, const char *fmt, ...)
257  __attribute__((format(printf, 2, 3)));
258 
259 /** Create a new stringbuf by printf-style formatting using @c fmt and @a ap.
260  * This is the same as svn_stringbuf_createf() except for the different
261  * way of passing the variable arguments.
262  */
264 svn_stringbuf_createv(apr_pool_t *pool, const char *fmt, va_list ap)
265  __attribute__((format(printf, 2, 0)));
266 
267 /** Make sure that @a str has at least @a minimum_size
268  * bytes of space available in the memory block.
269  *
270  * The allocated string buffer will be at least one byte larger than
271  * @a minimum_size to account for a final '\\0'.
272  *
273  * @note: Before Subversion 1.8 this function did not ensure space for
274  * one byte more than @a minimum_size. If compatibility with pre-1.8
275  * behaviour is required callers must assume space for only
276  * @a minimum_size-1 data bytes plus a final '\\0'.
277  */
278 void
279 svn_stringbuf_ensure(svn_stringbuf_t *str, apr_size_t minimum_size);
280 
281 /** Set @a str to a copy of the null-terminated C string @a value. */
282 void
283 svn_stringbuf_set(svn_stringbuf_t *str, const char *value);
284 
285 /** Set @a str to empty (zero length). */
286 void
288 
289 /** Return @c TRUE if @a str is empty (has length zero). */
292 
293 /** Chop @a nbytes bytes off end of @a str, but not more than @a str->len. */
294 void
295 svn_stringbuf_chop(svn_stringbuf_t *str, apr_size_t nbytes);
296 
297 /**
298  * Chop @a nbytes bytes off the start of @a str, but not more than @a str->len.
299  *
300  * @since New in 1.10.
301  */
302 void
303 svn_stringbuf_leftchop(svn_stringbuf_t *str, apr_size_t nbytes);
304 
305 /** Fill @a str with character @a c. */
306 void
307 svn_stringbuf_fillchar(svn_stringbuf_t *str, unsigned char c);
308 
309 /** Append the single character @a byte onto @a targetstr.
310  *
311  * This is an optimized version of svn_stringbuf_appendbytes()
312  * that is much faster to call and execute. Gains vary with the ABI.
313  * The advantages extend beyond the actual call because the reduced
314  * register pressure allows for more optimization within the caller.
315  *
316  * Reallocs if necessary. @a targetstr is affected, nothing else is.
317  * @since New in 1.7.
318  */
319 void
321  char byte);
322 
323 /** Append the array of bytes @a bytes of length @a count onto @a targetstr.
324  *
325  * Reallocs if necessary. @a targetstr is affected, nothing else is.
326  *
327  * @since 1.9 @a bytes can be NULL if @a count is zero.
328  */
329 void
331  const char *bytes,
332  apr_size_t count);
333 
334 /** Append @a byte @a count times onto @a targetstr.
335  *
336  * Reallocs if necessary. @a targetstr is affected, nothing else is.
337  * @since New in 1.9.
338  */
339 void
341  char byte,
342  apr_size_t count);
343 
344 /** Append the stringbuf @c appendstr onto @a targetstr.
345  *
346  * Reallocs if necessary. @a targetstr is affected, nothing else is.
347  */
348 void
350  const svn_stringbuf_t *appendstr);
351 
352 /** Append the C string @a cstr onto @a targetstr.
353  *
354  * Reallocs if necessary. @a targetstr is affected, nothing else is.
355  */
356 void
358  const char *cstr);
359 
360 /** Insert into @a str at position @a pos an array of bytes @a bytes
361  * which is @a count bytes long.
362  *
363  * The resulting string will be @c count+str->len bytes long. If
364  * @a pos is larger than or equal to @c str->len, simply append @a bytes.
365  *
366  * Reallocs if necessary. @a str is affected, nothing else is.
367  *
368  * @note The inserted string may be a sub-range of @a str.
369  *
370  * @since New in 1.8.
371  *
372  * @since Since 1.9, @a bytes can be NULL if @a count is zero.
373  */
374 void
376  apr_size_t pos,
377  const char *bytes,
378  apr_size_t count);
379 
380 /** Remove @a count bytes from @a str, starting at position @a pos.
381  *
382  * If that range exceeds the current string data, truncate @a str at
383  * @a pos. If @a pos is larger than or equal to @c str->len, this will
384  * be a no-op. Otherwise, the resulting string will be @c str->len-count
385  * bytes long.
386  *
387  * @since New in 1.8.
388  */
389 void
391  apr_size_t pos,
392  apr_size_t count);
393 
394 /** Replace in @a str the substring which starts at @a pos and is @a
395  * old_count bytes long with a new substring @a bytes which is @a
396  * new_count bytes long.
397  *
398  * This is faster but functionally equivalent to the following sequence:
399  * @code
400  svn_stringbuf_remove(str, pos, old_count);
401  svn_stringbuf_insert(str, pos, bytes, new_count);
402  * @endcode
403  *
404  * @since New in 1.8.
405  *
406  * @since Since 1.9, @a bytes can be NULL if @a new_count is zero.
407  */
408 void
410  apr_size_t pos,
411  apr_size_t old_count,
412  const char *bytes,
413  apr_size_t new_count);
414 
415 /** Replace all occurrences of @a to_find in @a str with @a replacement.
416  * Return the number of replacements made.
417  *
418  * @since New in 1.10.
419  */
420 apr_size_t
422  const char *to_find,
423  const char *replacement);
424 
425 /** Return a duplicate of @a original_string. */
427 svn_stringbuf_dup(const svn_stringbuf_t *original_string, apr_pool_t *pool);
428 
429 /** Return @c TRUE iff @a str1 and @a str2 have identical length and data. */
432  const svn_stringbuf_t *str2);
433 
434 /** Return offset of first non-whitespace character in @a str, or return
435  * @a str->len if none.
436  */
437 apr_size_t
439 
440 /** Strip whitespace from both sides of @a str (modified in place). */
441 void
443 
444 /** Return position of last occurrence of @a ch in @a str, or return
445  * @a str->len if no occurrence.
446  */
447 apr_size_t
449 
450 /** Return @c TRUE iff @a str1 and @a str2 have identical length and data. */
453  const svn_stringbuf_t *str2);
454 
455 /** @} */
456 
457 
458 /**
459  * @defgroup svn_string_cstrings C string functions
460  * @{
461  */
462 
463 /** Divide @a input into substrings, interpreting any char from @a sep
464  * as a token separator.
465  *
466  * Return an array of copies of those substrings (plain const char*),
467  * allocating both the array and the copies in @a pool.
468  *
469  * None of the elements added to the array contain any of the
470  * characters in @a sep_chars, and none of the new elements are empty
471  * (thus, it is possible that the returned array will have length
472  * zero).
473  *
474  * If @a chop_whitespace is TRUE, then remove leading and trailing
475  * whitespace from the returned strings.
476  */
477 apr_array_header_t *
478 svn_cstring_split(const char *input,
479  const char *sep_chars,
480  svn_boolean_t chop_whitespace,
481  apr_pool_t *pool);
482 
483 /** Like svn_cstring_split(), but append to existing @a array instead of
484  * creating a new one. Allocate the copied substrings in @a pool
485  * (i.e., caller decides whether or not to pass @a array->pool as @a pool).
486  */
487 void
488 svn_cstring_split_append(apr_array_header_t *array,
489  const char *input,
490  const char *sep_chars,
491  svn_boolean_t chop_whitespace,
492  apr_pool_t *pool);
493 
494 
495 /** Return @c TRUE iff @a str matches any of the elements of @a list, a list
496  * of zero or more glob patterns.
497  */
499 svn_cstring_match_glob_list(const char *str, const apr_array_header_t *list);
500 
501 /** Return @c TRUE iff @a str exactly matches any of the elements of @a list.
502  *
503  * @since new in 1.7
504  */
506 svn_cstring_match_list(const char *str, const apr_array_header_t *list);
507 
508 /**
509  * Get the next token from @a *str interpreting any char from @a sep as a
510  * token separator. Separators at the beginning of @a str will be skipped.
511  * Returns a pointer to the beginning of the first token in @a *str or NULL
512  * if no token is left. Modifies @a str such that the next call will return
513  * the next token.
514  *
515  * @note The content of @a *str may be modified by this function.
516  *
517  * @since New in 1.8.
518  */
519 char *
520 svn_cstring_tokenize(const char *sep, char **str);
521 
522 /**
523  * Return the number of line breaks in @a msg, allowing any kind of newline
524  * termination (CR, LF, CRLF, or LFCR), even inconsistent.
525  *
526  * @since New in 1.2.
527  */
528 int
529 svn_cstring_count_newlines(const char *msg);
530 
531 /**
532  * Return a cstring which is the concatenation of @a strings (an array
533  * of char *) joined by @a separator. Allocate the result in @a pool.
534  * If @a strings is empty, then return the empty string.
535  * If @a trailing_separator is non-zero, also append the separator
536  * after the last joined element.
537  *
538  * @since New in 1.10.
539  */
540 char *
541 svn_cstring_join2(const apr_array_header_t *strings,
542  const char *separator,
543  svn_boolean_t trailing_separator,
544  apr_pool_t *pool);
545 
546 /**
547  * Similar to svn_cstring_join2(), but always includes the trailing
548  * separator.
549  *
550  * @since New in 1.2.
551  * @deprecated Provided for backwards compatibility with the 1.9 API.
552  */
554 char *
555 svn_cstring_join(const apr_array_header_t *strings,
556  const char *separator,
557  apr_pool_t *pool);
558 
559 /**
560  * Compare two strings @a atr1 and @a atr2, treating case-equivalent
561  * unaccented Latin (ASCII subset) letters as equal.
562  *
563  * Returns in integer greater than, equal to, or less than 0,
564  * according to whether @a str1 is considered greater than, equal to,
565  * or less than @a str2.
566  *
567  * @since New in 1.5.
568  */
569 int
570 svn_cstring_casecmp(const char *str1, const char *str2);
571 
572 /**
573  * Parse the C string @a str into a 64 bit number, and return it in @a *n.
574  * Assume that the number is represented in base @a base.
575  * Raise an error if conversion fails (e.g. due to overflow), or if the
576  * converted number is smaller than @a minval or larger than @a maxval.
577  *
578  * Leading whitespace in @a str is skipped in a locale-dependent way.
579  * After that, the string may contain an optional '+' (positive, default)
580  * or '-' (negative) character, followed by an optional '0x' prefix if
581  * @a base is 0 or 16, followed by numeric digits appropriate for the base.
582  * If there are any more characters after the numeric digits, an error is
583  * returned.
584  *
585  * If @a base is zero, then a leading '0x' or '0X' prefix means hexadecimal,
586  * else a leading '0' means octal (implemented, though not documented, in
587  * apr_strtoi64() in APR 0.9.0 through 1.5.0), else use base ten.
588  *
589  * @since New in 1.7.
590  */
591 svn_error_t *
592 svn_cstring_strtoi64(apr_int64_t *n, const char *str,
593  apr_int64_t minval, apr_int64_t maxval,
594  int base);
595 
596 /**
597  * Parse the C string @a str into a 64 bit number, and return it in @a *n.
598  * Assume that the number is represented in base 10.
599  * Raise an error if conversion fails (e.g. due to overflow).
600  *
601  * The behaviour otherwise is as described for svn_cstring_strtoi64().
602  *
603  * @since New in 1.7.
604  */
605 svn_error_t *
606 svn_cstring_atoi64(apr_int64_t *n, const char *str);
607 
608 /**
609  * Parse the C string @a str into a 32 bit number, and return it in @a *n.
610  * Assume that the number is represented in base 10.
611  * Raise an error if conversion fails (e.g. due to overflow).
612  *
613  * The behaviour otherwise is as described for svn_cstring_strtoi64().
614  *
615  * @since New in 1.7.
616  */
617 svn_error_t *
618 svn_cstring_atoi(int *n, const char *str);
619 
620 /**
621  * Parse the C string @a str into an unsigned 64 bit number, and return
622  * it in @a *n. Assume that the number is represented in base @a base.
623  * Raise an error if conversion fails (e.g. due to overflow), or if the
624  * converted number is smaller than @a minval or larger than @a maxval.
625  *
626  * Leading whitespace in @a str is skipped in a locale-dependent way.
627  * After that, the string may contain an optional '+' (positive, default)
628  * or '-' (negative) character, followed by an optional '0x' prefix if
629  * @a base is 0 or 16, followed by numeric digits appropriate for the base.
630  * If there are any more characters after the numeric digits, an error is
631  * returned.
632  *
633  * If @a base is zero, then a leading '0x' or '0X' prefix means hexadecimal,
634  * else a leading '0' means octal (implemented, though not documented, in
635  * apr_strtoi64() in APR 0.9.0 through 1.5.0), else use base ten.
636  *
637  * @warning The implementation used since version 1.7 returns an error
638  * if the parsed number is greater than APR_INT64_MAX, even if it is not
639  * greater than @a maxval.
640  *
641  * @since New in 1.7.
642  */
643 svn_error_t *
644 svn_cstring_strtoui64(apr_uint64_t *n, const char *str,
645  apr_uint64_t minval, apr_uint64_t maxval,
646  int base);
647 
648 /**
649  * Parse the C string @a str into an unsigned 64 bit number, and return
650  * it in @a *n. Assume that the number is represented in base 10.
651  * Raise an error if conversion fails (e.g. due to overflow).
652  *
653  * The behaviour otherwise is as described for svn_cstring_strtoui64(),
654  * including the upper limit of APR_INT64_MAX.
655  *
656  * @since New in 1.7.
657  */
658 svn_error_t *
659 svn_cstring_atoui64(apr_uint64_t *n, const char *str);
660 
661 /**
662  * Parse the C string @a str into an unsigned 32 bit number, and return
663  * it in @a *n. Assume that the number is represented in base 10.
664  * Raise an error if conversion fails (e.g. due to overflow).
665  *
666  * The behaviour otherwise is as described for svn_cstring_strtoui64(),
667  * including the upper limit of APR_INT64_MAX.
668  *
669  * @since New in 1.7.
670  */
671 svn_error_t *
672 svn_cstring_atoui(unsigned int *n, const char *str);
673 
674 /**
675  * Skip the common prefix @a prefix from the C string @a str, and return
676  * a pointer to the next character after the prefix.
677  * Return @c NULL if @a str does not start with @a prefix.
678  *
679  * @since New in 1.9.
680  */
681 const char *
682 svn_cstring_skip_prefix(const char *str, const char *prefix);
683 
684 /** @} */
685 
686 /** @} */
687 
688 
689 #ifdef __cplusplus
690 }
691 #endif /* __cplusplus */
692 
693 #endif /* SVN_STRING_H */
svn_string_t * svn_string_createv(apr_pool_t *pool, const char *fmt, va_list ap)
Create a new string by printf-style formatting using fmt and ap.
apr_size_t svn_string_first_non_whitespace(const svn_string_t *str)
Return offset of first non-whitespace character in str, or return str->len if none.
svn_boolean_t svn_stringbuf_compare(const svn_stringbuf_t *str1, const svn_stringbuf_t *str2)
Return TRUE iff str1 and str2 have identical length and data.
char * svn_cstring_join(const apr_array_header_t *strings, const char *separator, apr_pool_t *pool)
Similar to svn_cstring_join2(), but always includes the trailing separator.
apr_array_header_t * svn_cstring_split(const char *input, const char *sep_chars, svn_boolean_t chop_whitespace, apr_pool_t *pool)
Divide input into substrings, interpreting any char from sep as a token separator.
apr_size_t svn_stringbuf_find_char_backward(const svn_stringbuf_t *str, char ch)
Return position of last occurrence of ch in str, or return str->len if no occurrence.
void svn_stringbuf_leftchop(svn_stringbuf_t *str, apr_size_t nbytes)
Chop nbytes bytes off the start of str, but not more than str->len.
void svn_stringbuf_ensure(svn_stringbuf_t *str, apr_size_t minimum_size)
Make sure that str has at least minimum_size bytes of space available in the memory block...
void svn_stringbuf_appendfill(svn_stringbuf_t *targetstr, char byte, apr_size_t count)
Append byte count times onto targetstr.
svn_stringbuf_t * svn_stringbuf_ncreate(const char *bytes, apr_size_t size, apr_pool_t *pool)
Create a new stringbuf copied from the generic string of bytes, bytes, of length size bytes...
apr_size_t blocksize
total size of buffer allocated
Definition: svn_string.h:119
svn_boolean_t svn_cstring_match_glob_list(const char *str, const apr_array_header_t *list)
Return TRUE iff str matches any of the elements of list, a list of zero or more glob patterns...
void svn_stringbuf_strip_whitespace(svn_stringbuf_t *str)
Strip whitespace from both sides of str (modified in place).
svn_string_t * svn_string_create_empty(apr_pool_t *pool)
Create a new, empty string.
svn_stringbuf_t * svn_stringbuf_create(const char *cstring, apr_pool_t *pool)
Create a new stringbuf copied from the null-terminated C string cstring.
apr_size_t len
length of bytestring
Definition: svn_string.h:116
svn_boolean_t svn_string_compare_stringbuf(const svn_string_t *str1, const svn_stringbuf_t *str2)
Return TRUE iff str1 and str2 have identical length and data.
svn_string_t * svn_string_create(const char *cstring, apr_pool_t *pool)
Create a new string copied from the null-terminated C string cstring.
void svn_stringbuf_set(svn_stringbuf_t *str, const char *value)
Set str to a copy of the null-terminated C string value.
svn_stringbuf_t * svn_stringbuf_create_empty(apr_pool_t *pool)
Create a new, empty stringbuf.
char * data
pointer to the bytestring
Definition: svn_string.h:113
A simple counted string.
Definition: svn_string.h:96
svn_error_t * svn_cstring_atoui(unsigned int *n, const char *str)
Parse the C string str into an unsigned 32 bit number, and return it in *n.
apr_size_t len
length of bytestring
Definition: svn_string.h:99
svn_boolean_t svn_string_isempty(const svn_string_t *str)
Return TRUE if str is empty (has length zero).
Subversion error object.
Definition: svn_types.h:180
svn_boolean_t svn_cstring_match_list(const char *str, const apr_array_header_t *list)
Return TRUE iff str exactly matches any of the elements of list.
void svn_stringbuf_setempty(svn_stringbuf_t *str)
Set str to empty (zero length).
struct svn_string_t svn_string_t
A simple counted string.
svn_stringbuf_t * svn_stringbuf_dup(const svn_stringbuf_t *original_string, apr_pool_t *pool)
Return a duplicate of original_string.
int svn_cstring_casecmp(const char *str1, const char *str2)
Compare two strings atr1 and atr2, treating case-equivalent unaccented Latin (ASCII subset) letters a...
char * svn_cstring_tokenize(const char *sep, char **str)
Get the next token from *str interpreting any char from sep as a token separator. ...
svn_error_t * svn_cstring_atoi64(apr_int64_t *n, const char *str)
Parse the C string str into a 64 bit number, and return it in *n.
void svn_stringbuf_appendbytes(svn_stringbuf_t *targetstr, const char *bytes, apr_size_t count)
Append the array of bytes bytes of length count onto targetstr.
void svn_stringbuf_fillchar(svn_stringbuf_t *str, unsigned char c)
Fill str with character c.
void svn_cstring_split_append(apr_array_header_t *array, const char *input, const char *sep_chars, svn_boolean_t chop_whitespace, apr_pool_t *pool)
Like svn_cstring_split(), but append to existing array instead of creating a new one.
void svn_stringbuf_chop(svn_stringbuf_t *str, apr_size_t nbytes)
Chop nbytes bytes off end of str, but not more than str->len.
svn_stringbuf_t * svn_stringbuf_create_from_string(const svn_string_t *str, apr_pool_t *pool)
Create a new stringbuf copied from the string str.
void svn_stringbuf_appendbyte(svn_stringbuf_t *targetstr, char byte)
Append the single character byte onto targetstr.
void svn_stringbuf_replace(svn_stringbuf_t *str, apr_size_t pos, apr_size_t old_count, const char *bytes, apr_size_t new_count)
Replace in str the substring which starts at pos and is old_count bytes long with a new substring byt...
void svn_stringbuf_insert(svn_stringbuf_t *str, apr_size_t pos, const char *bytes, apr_size_t count)
Insert into str at position pos an array of bytes bytes which is count bytes long.
svn_string_t * svn_string_ncreate(const char *bytes, apr_size_t size, apr_pool_t *pool)
Create a new string copied from a generic string of bytes, bytes, of length size bytes.
Subversion&#39;s data types.
int svn_cstring_count_newlines(const char *msg)
Return the number of line breaks in msg, allowing any kind of newline termination (CR...
svn_error_t * svn_cstring_atoui64(apr_uint64_t *n, const char *str)
Parse the C string str into an unsigned 64 bit number, and return it in *n.
#define SVN_DEPRECATED
Macro used to mark deprecated functions.
Definition: svn_types.h:62
struct svn_stringbuf_t svn_stringbuf_t
A buffered string, capable of appending without an allocation and copy for each append.
svn_string_t * svn_string_create_from_buf(const svn_stringbuf_t *strbuf, apr_pool_t *pool)
Create a new string copied from the stringbuf strbuf.
svn_stringbuf_t * svn_stringbuf_createf(apr_pool_t *pool, const char *fmt,...)
Create a new stringbuf by printf-style formatting using fmt and the variable arguments, which are as appropriate for apr_psprintf().
const char * svn_cstring_skip_prefix(const char *str, const char *prefix)
Skip the common prefix prefix from the C string str, and return a pointer to the next character after...
svn_error_t * svn_cstring_strtoui64(apr_uint64_t *n, const char *str, apr_uint64_t minval, apr_uint64_t maxval, int base)
Parse the C string str into an unsigned 64 bit number, and return it in *n.
void svn_stringbuf_appendstr(svn_stringbuf_t *targetstr, const svn_stringbuf_t *appendstr)
Append the stringbuf appendstr onto targetstr.
svn_string_t * svn_string_createf(apr_pool_t *pool, const char *fmt,...)
Create a new string by printf-style formatting using fmt and the variable arguments, which are as appropriate for apr_psprintf().
svn_stringbuf_t * svn_stringbuf_create_wrap(char *str, apr_pool_t *pool)
Create a new stringbuf using the given str as initial buffer.
void svn_stringbuf_appendcstr(svn_stringbuf_t *targetstr, const char *cstr)
Append the C string cstr onto targetstr.
apr_pool_t * pool
a pool from which this string was originally allocated, and is not necessarily specific to this strin...
Definition: svn_string.h:110
svn_stringbuf_t * svn_stringbuf_createv(apr_pool_t *pool, const char *fmt, va_list ap)
Create a new stringbuf by printf-style formatting using fmt and ap.
svn_boolean_t svn_stringbuf_isempty(const svn_stringbuf_t *str)
Return TRUE if str is empty (has length zero).
svn_string_t * svn_string_dup(const svn_string_t *original_string, apr_pool_t *pool)
Return a duplicate of original_string.
apr_size_t svn_stringbuf_replace_all(svn_stringbuf_t *str, const char *to_find, const char *replacement)
Replace all occurrences of to_find in str with replacement.
svn_boolean_t svn_string_compare(const svn_string_t *str1, const svn_string_t *str2)
Return TRUE iff str1 and str2 have identical length and data.
int svn_boolean_t
YABT: Yet Another Boolean Type.
Definition: svn_types.h:141
svn_error_t * svn_cstring_atoi(int *n, const char *str)
Parse the C string str into a 32 bit number, and return it in *n.
svn_stringbuf_t * svn_stringbuf_create_ensure(apr_size_t minimum_size, apr_pool_t *pool)
Create a new, empty stringbuf with at least minimum_size bytes of space available in the memory block...
svn_error_t * svn_cstring_strtoi64(apr_int64_t *n, const char *str, apr_int64_t minval, apr_int64_t maxval, int base)
Parse the C string str into a 64 bit number, and return it in *n.
char * svn_cstring_join2(const apr_array_header_t *strings, const char *separator, svn_boolean_t trailing_separator, apr_pool_t *pool)
Return a cstring which is the concatenation of strings (an array of char *) joined by separator...
void svn_stringbuf_remove(svn_stringbuf_t *str, apr_size_t pos, apr_size_t count)
Remove count bytes from str, starting at position pos.
apr_size_t svn_string_find_char_backward(const svn_string_t *str, char ch)
Return position of last occurrence of ch in str, or return str->len if no occurrence.
A buffered string, capable of appending without an allocation and copy for each append.
Definition: svn_string.h:104
const char * data
pointer to the bytestring
Definition: svn_string.h:98
apr_size_t svn_stringbuf_first_non_whitespace(const svn_stringbuf_t *str)
Return offset of first non-whitespace character in str, or return str->len if none.