1251881Speter/**
2251881Speter * @copyright
3251881Speter * ====================================================================
4251881Speter *    Licensed to the Apache Software Foundation (ASF) under one
5251881Speter *    or more contributor license agreements.  See the NOTICE file
6251881Speter *    distributed with this work for additional information
7251881Speter *    regarding copyright ownership.  The ASF licenses this file
8251881Speter *    to you under the Apache License, Version 2.0 (the
9251881Speter *    "License"); you may not use this file except in compliance
10251881Speter *    with the License.  You may obtain a copy of the License at
11251881Speter *
12251881Speter *      http://www.apache.org/licenses/LICENSE-2.0
13251881Speter *
14251881Speter *    Unless required by applicable law or agreed to in writing,
15251881Speter *    software distributed under the License is distributed on an
16251881Speter *    "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
17251881Speter *    KIND, either express or implied.  See the License for the
18251881Speter *    specific language governing permissions and limitations
19251881Speter *    under the License.
20251881Speter * ====================================================================
21251881Speter * @endcopyright
22251881Speter *
23251881Speter * @file svn_string.h
24251881Speter * @brief Counted-length strings for Subversion, plus some C string goodies.
25251881Speter *
26251881Speter * There are two string datatypes: @c svn_string_t and @c svn_stringbuf_t.
27251881Speter * The former is a simple pointer/length pair useful for passing around
28251881Speter * strings (or arbitrary bytes) with a counted length. @c svn_stringbuf_t is
29251881Speter * buffered to enable efficient appending of strings without an allocation
30251881Speter * and copy for each append operation.
31251881Speter *
32251881Speter * @c svn_string_t contains a <tt>const char *</tt> for its data, so it is
33251881Speter * most appropriate for constant data and for functions which expect constant,
34251881Speter * counted data. Functions should generally use <tt>const @c svn_string_t
35251881Speter * *</tt> as their parameter to indicate they are expecting a constant,
36251881Speter * counted string.
37251881Speter *
38251881Speter * @c svn_stringbuf_t uses a plain <tt>char *</tt> for its data, so it is
39251881Speter * most appropriate for modifiable data.
40251881Speter *
41251881Speter * <h3>Invariants</h3>
42251881Speter *
43251881Speter *   1. Null termination:
44251881Speter *
45251881Speter *      Both structures maintain a significant invariant:
46251881Speter *
47251881Speter *         <tt>s->data[s->len] == '\\0'</tt>
48251881Speter *
49251881Speter *      The functions defined within this header file will maintain
50251881Speter *      the invariant (which does imply that memory is
51251881Speter *      allocated/defined as @c len+1 bytes).  If code outside of the
52251881Speter *      @c svn_string.h functions manually builds these structures,
53251881Speter *      then they must enforce this invariant.
54251881Speter *
55251881Speter *      Note that an @c svn_string(buf)_t may contain binary data,
56251881Speter *      which means that strlen(s->data) does not have to equal @c
57251881Speter *      s->len. The null terminator is provided to make it easier to
58251881Speter *      pass @c s->data to C string interfaces.
59251881Speter *
60251881Speter *
61251881Speter *   2. Non-NULL input:
62251881Speter *
63251881Speter *      All the functions assume their input data pointer is non-NULL,
64251881Speter *      unless otherwise documented, and may seg fault if passed
65251881Speter *      NULL.  The input data may *contain* null bytes, of course, just
66251881Speter *      the data pointer itself must not be NULL.
67251881Speter *
68251881Speter * <h3>Memory allocation</h3>
69251881Speter *
70251881Speter *   All the functions make a deep copy of all input data, and never store
71251881Speter *   a pointer to the original input data.
72251881Speter */
73251881Speter
74251881Speter
75251881Speter#ifndef SVN_STRING_H
76251881Speter#define SVN_STRING_H
77251881Speter
78251881Speter#include <apr.h>          /* for apr_size_t */
79251881Speter#include <apr_pools.h>    /* for apr_pool_t */
80251881Speter#include <apr_tables.h>   /* for apr_array_header_t */
81251881Speter
82251881Speter#include "svn_types.h"    /* for svn_boolean_t, svn_error_t */
83251881Speter
84251881Speter#ifdef __cplusplus
85251881Speterextern "C" {
86251881Speter#endif /* __cplusplus */
87251881Speter
88251881Speter/**
89251881Speter * @defgroup svn_string String handling
90251881Speter * @{
91251881Speter */
92251881Speter
93251881Speter
94251881Speter
95251881Speter/** A simple counted string. */
96251881Spetertypedef struct svn_string_t
97251881Speter{
98251881Speter  const char *data; /**< pointer to the bytestring */
99251881Speter  apr_size_t len;   /**< length of bytestring */
100251881Speter} svn_string_t;
101251881Speter
102251881Speter/** A buffered string, capable of appending without an allocation and copy
103251881Speter * for each append. */
104251881Spetertypedef struct svn_stringbuf_t
105251881Speter{
106251881Speter  /** a pool from which this string was originally allocated, and is not
107251881Speter   * necessarily specific to this string.  This is used only for allocating
108251881Speter   * more memory from when the string needs to grow.
109251881Speter   */
110251881Speter  apr_pool_t *pool;
111251881Speter
112251881Speter  /** pointer to the bytestring */
113251881Speter  char *data;
114251881Speter
115251881Speter  /** length of bytestring */
116251881Speter  apr_size_t len;
117251881Speter
118251881Speter  /** total size of buffer allocated */
119251881Speter  apr_size_t blocksize;
120251881Speter} svn_stringbuf_t;
121251881Speter
122251881Speter
123251881Speter/**
124251881Speter * @defgroup svn_string_svn_string_t svn_string_t functions
125251881Speter * @{
126251881Speter */
127251881Speter
128251881Speter/** Create a new string copied from the null-terminated C string @a cstring.
129251881Speter */
130251881Spetersvn_string_t *
131251881Spetersvn_string_create(const char *cstring, apr_pool_t *pool);
132251881Speter
133251881Speter/** Create a new, empty string.
134251881Speter *
135251881Speter * @since New in 1.8.
136251881Speter */
137251881Spetersvn_string_t *
138251881Spetersvn_string_create_empty(apr_pool_t *pool);
139251881Speter
140251881Speter/** Create a new string copied from a generic string of bytes, @a bytes, of
141251881Speter * length @a size bytes.  @a bytes is NOT assumed to be null-terminated, but
142251881Speter * the new string will be.
143251881Speter */
144251881Spetersvn_string_t *
145251881Spetersvn_string_ncreate(const char *bytes, apr_size_t size, apr_pool_t *pool);
146251881Speter
147251881Speter/** Create a new string copied from the stringbuf @a strbuf.
148251881Speter */
149251881Spetersvn_string_t *
150251881Spetersvn_string_create_from_buf(const svn_stringbuf_t *strbuf, apr_pool_t *pool);
151251881Speter
152251881Speter/** Create a new string by printf-style formatting using @a fmt and the
153251881Speter * variable arguments, which are as appropriate for apr_psprintf().
154251881Speter */
155251881Spetersvn_string_t *
156251881Spetersvn_string_createf(apr_pool_t *pool, const char *fmt, ...)
157251881Speter  __attribute__((format(printf, 2, 3)));
158251881Speter
159251881Speter/** Create a new string by printf-style formatting using @c fmt and @a ap.
160251881Speter * This is the same as svn_string_createf() except for the different
161251881Speter * way of passing the variable arguments.
162251881Speter */
163251881Spetersvn_string_t *
164251881Spetersvn_string_createv(apr_pool_t *pool, const char *fmt, va_list ap)
165251881Speter  __attribute__((format(printf, 2, 0)));
166251881Speter
167251881Speter/** Return TRUE if @a str is empty (has length zero). */
168251881Spetersvn_boolean_t
169251881Spetersvn_string_isempty(const svn_string_t *str);
170251881Speter
171251881Speter/** Return a duplicate of @a original_string. */
172251881Spetersvn_string_t *
173251881Spetersvn_string_dup(const svn_string_t *original_string, apr_pool_t *pool);
174251881Speter
175251881Speter/** Return @c TRUE iff @a str1 and @a str2 have identical length and data. */
176251881Spetersvn_boolean_t
177251881Spetersvn_string_compare(const svn_string_t *str1, const svn_string_t *str2);
178251881Speter
179251881Speter/** Return offset of first non-whitespace character in @a str, or return
180251881Speter * @a str->len if none.
181251881Speter */
182251881Speterapr_size_t
183251881Spetersvn_string_first_non_whitespace(const svn_string_t *str);
184251881Speter
185251881Speter/** Return position of last occurrence of @a ch in @a str, or return
186251881Speter * @a str->len if no occurrence.
187251881Speter */
188251881Speterapr_size_t
189251881Spetersvn_string_find_char_backward(const svn_string_t *str, char ch);
190251881Speter
191251881Speter/** @} */
192251881Speter
193251881Speter
194251881Speter/**
195251881Speter * @defgroup svn_string_svn_stringbuf_t svn_stringbuf_t functions
196251881Speter * @{
197251881Speter */
198251881Speter
199251881Speter/** Create a new stringbuf copied from the null-terminated C string
200251881Speter * @a cstring.
201251881Speter */
202251881Spetersvn_stringbuf_t *
203251881Spetersvn_stringbuf_create(const char *cstring, apr_pool_t *pool);
204251881Speter
205251881Speter/** Create a new stringbuf copied from the generic string of bytes, @a bytes,
206251881Speter * of length @a size bytes.  @a bytes is NOT assumed to be null-terminated,
207251881Speter * but the new stringbuf will be.
208251881Speter */
209251881Spetersvn_stringbuf_t *
210251881Spetersvn_stringbuf_ncreate(const char *bytes, apr_size_t size, apr_pool_t *pool);
211251881Speter
212251881Speter/** Create a new, empty stringbuf.
213251881Speter *
214251881Speter * @since New in 1.8.
215251881Speter */
216251881Spetersvn_stringbuf_t *
217251881Spetersvn_stringbuf_create_empty(apr_pool_t *pool);
218251881Speter
219251881Speter/** Create a new, empty stringbuf with at least @a minimum_size bytes of
220251881Speter * space available in the memory block.
221251881Speter *
222251881Speter * The allocated string buffer will be at least one byte larger than
223251881Speter * @a minimum_size to account for a final '\\0'.
224251881Speter *
225251881Speter * @since New in 1.6.
226251881Speter */
227251881Spetersvn_stringbuf_t *
228251881Spetersvn_stringbuf_create_ensure(apr_size_t minimum_size, apr_pool_t *pool);
229251881Speter
230251881Speter/** Create a new stringbuf copied from the string @a str.
231251881Speter */
232251881Spetersvn_stringbuf_t *
233251881Spetersvn_stringbuf_create_from_string(const svn_string_t *str, apr_pool_t *pool);
234251881Speter
235251881Speter/** Create a new stringbuf by printf-style formatting using @a fmt and the
236251881Speter * variable arguments, which are as appropriate for apr_psprintf().
237251881Speter */
238251881Spetersvn_stringbuf_t *
239251881Spetersvn_stringbuf_createf(apr_pool_t *pool, const char *fmt, ...)
240251881Speter  __attribute__((format(printf, 2, 3)));
241251881Speter
242251881Speter/** Create a new stringbuf by printf-style formatting using @c fmt and @a ap.
243251881Speter * This is the same as svn_stringbuf_createf() except for the different
244251881Speter * way of passing the variable arguments.
245251881Speter */
246251881Spetersvn_stringbuf_t *
247251881Spetersvn_stringbuf_createv(apr_pool_t *pool, const char *fmt, va_list ap)
248251881Speter  __attribute__((format(printf, 2, 0)));
249251881Speter
250251881Speter/** Make sure that @a str has at least @a minimum_size
251251881Speter * bytes of space available in the memory block.
252251881Speter *
253251881Speter * The allocated string buffer will be at least one byte larger than
254251881Speter * @a minimum_size to account for a final '\\0'.
255251881Speter *
256251881Speter * @note: Before Subversion 1.8 this function did not ensure space for
257251881Speter * one byte more than @a minimum_size.  If compatibility with pre-1.8
258251881Speter * behaviour is required callers must assume space for only
259251881Speter * @a minimum_size-1 data bytes plus a final '\\0'.
260251881Speter */
261251881Spetervoid
262251881Spetersvn_stringbuf_ensure(svn_stringbuf_t *str, apr_size_t minimum_size);
263251881Speter
264251881Speter/** Set @a str to a copy of the null-terminated C string @a value. */
265251881Spetervoid
266251881Spetersvn_stringbuf_set(svn_stringbuf_t *str, const char *value);
267251881Speter
268251881Speter/** Set @a str to empty (zero length). */
269251881Spetervoid
270251881Spetersvn_stringbuf_setempty(svn_stringbuf_t *str);
271251881Speter
272251881Speter/** Return @c TRUE if @a str is empty (has length zero). */
273251881Spetersvn_boolean_t
274251881Spetersvn_stringbuf_isempty(const svn_stringbuf_t *str);
275251881Speter
276251881Speter/** Chop @a nbytes bytes off end of @a str, but not more than @a str->len. */
277251881Spetervoid
278251881Spetersvn_stringbuf_chop(svn_stringbuf_t *str, apr_size_t nbytes);
279251881Speter
280251881Speter/** Fill @a str with character @a c. */
281251881Spetervoid
282251881Spetersvn_stringbuf_fillchar(svn_stringbuf_t *str, unsigned char c);
283251881Speter
284251881Speter/** Append the single character @a byte onto @a targetstr.
285251881Speter *
286251881Speter * This is an optimized version of svn_stringbuf_appendbytes()
287251881Speter * that is much faster to call and execute. Gains vary with the ABI.
288251881Speter * The advantages extend beyond the actual call because the reduced
289251881Speter * register pressure allows for more optimization within the caller.
290251881Speter *
291251881Speter * reallocs if necessary. @a targetstr is affected, nothing else is.
292251881Speter * @since New in 1.7.
293251881Speter */
294251881Spetervoid
295251881Spetersvn_stringbuf_appendbyte(svn_stringbuf_t *targetstr,
296251881Speter                         char byte);
297251881Speter
298251881Speter/** Append an array of bytes onto @a targetstr.
299251881Speter *
300251881Speter * reallocs if necessary. @a targetstr is affected, nothing else is.
301251881Speter */
302251881Spetervoid
303251881Spetersvn_stringbuf_appendbytes(svn_stringbuf_t *targetstr,
304251881Speter                          const char *bytes,
305251881Speter                          apr_size_t count);
306251881Speter
307251881Speter/** Append the stringbuf @c appendstr onto @a targetstr.
308251881Speter *
309251881Speter * reallocs if necessary. @a targetstr is affected, nothing else is.
310251881Speter */
311251881Spetervoid
312251881Spetersvn_stringbuf_appendstr(svn_stringbuf_t *targetstr,
313251881Speter                        const svn_stringbuf_t *appendstr);
314251881Speter
315251881Speter/** Append the C string @a cstr onto @a targetstr.
316251881Speter *
317251881Speter * reallocs if necessary. @a targetstr is affected, nothing else is.
318251881Speter */
319251881Spetervoid
320251881Spetersvn_stringbuf_appendcstr(svn_stringbuf_t *targetstr,
321251881Speter                         const char *cstr);
322251881Speter
323251881Speter/** Read @a count bytes from @a bytes and insert them into @a str at
324251881Speter * position @a pos and following.  The resulting string will be
325251881Speter * @c count+str->len bytes long.  If @c pos is larger or equal to the
326251881Speter * number of bytes currently used in @a str,  simply append @a bytes.
327251881Speter *
328251881Speter * Reallocs if necessary. @a str is affected, nothing else is.
329251881Speter *
330251881Speter * @note The inserted string may be a sub-range if @a str.
331251881Speter *
332251881Speter * @since New in 1.8.
333251881Speter */
334251881Spetervoid
335251881Spetersvn_stringbuf_insert(svn_stringbuf_t *str,
336251881Speter                     apr_size_t pos,
337251881Speter                     const char *bytes,
338251881Speter                     apr_size_t count);
339251881Speter
340251881Speter/** Removes @a count bytes from @a str, starting at position @a pos.
341251881Speter * If that range exceeds the current string data,  @a str gets truncated
342251881Speter * at @a pos.  If the latter is larger or equal to @c str->pos, this will
343251881Speter * be a no-op.  Otherwise, the resulting string will be @c str->len-count
344251881Speter * bytes long.
345251881Speter *
346251881Speter * @since New in 1.8.
347251881Speter */
348251881Spetervoid
349251881Spetersvn_stringbuf_remove(svn_stringbuf_t *str,
350251881Speter                     apr_size_t pos,
351251881Speter                     apr_size_t count);
352251881Speter
353251881Speter/** Replace in @a str the substring which starts at @a pos and is @a
354251881Speter * old_count bytes long with a new substring @a bytes (which is @a
355251881Speter * new_count bytes long).
356251881Speter *
357251881Speter * This is faster but functionally equivalent to the following sequence:
358251881Speter * @code
359251881Speter     svn_stringbuf_remove(str, pos, old_count);
360251881Speter     svn_stringbuf_insert(str, pos, bytes, new_count);
361251881Speter * @endcode
362251881Speter *
363251881Speter * @since New in 1.8.
364251881Speter */
365251881Spetervoid
366251881Spetersvn_stringbuf_replace(svn_stringbuf_t *str,
367251881Speter                      apr_size_t pos,
368251881Speter                      apr_size_t old_count,
369251881Speter                      const char *bytes,
370251881Speter                      apr_size_t new_count);
371251881Speter
372251881Speter/** Return a duplicate of @a original_string. */
373251881Spetersvn_stringbuf_t *
374251881Spetersvn_stringbuf_dup(const svn_stringbuf_t *original_string, apr_pool_t *pool);
375251881Speter
376251881Speter/** Return @c TRUE iff @a str1 and @a str2 have identical length and data. */
377251881Spetersvn_boolean_t
378251881Spetersvn_stringbuf_compare(const svn_stringbuf_t *str1,
379251881Speter                      const svn_stringbuf_t *str2);
380251881Speter
381251881Speter/** Return offset of first non-whitespace character in @a str, or return
382251881Speter * @a str->len if none.
383251881Speter */
384251881Speterapr_size_t
385251881Spetersvn_stringbuf_first_non_whitespace(const svn_stringbuf_t *str);
386251881Speter
387251881Speter/** Strip whitespace from both sides of @a str (modified in place). */
388251881Spetervoid
389251881Spetersvn_stringbuf_strip_whitespace(svn_stringbuf_t *str);
390251881Speter
391251881Speter/** Return position of last occurrence of @a ch in @a str, or return
392251881Speter * @a str->len if no occurrence.
393251881Speter */
394251881Speterapr_size_t
395251881Spetersvn_stringbuf_find_char_backward(const svn_stringbuf_t *str, char ch);
396251881Speter
397251881Speter/** Return @c TRUE iff @a str1 and @a str2 have identical length and data. */
398251881Spetersvn_boolean_t
399251881Spetersvn_string_compare_stringbuf(const svn_string_t *str1,
400251881Speter                             const svn_stringbuf_t *str2);
401251881Speter
402251881Speter/** @} */
403251881Speter
404251881Speter
405251881Speter/**
406251881Speter * @defgroup svn_string_cstrings C string functions
407251881Speter * @{
408251881Speter */
409251881Speter
410251881Speter/** Divide @a input into substrings along @a sep_chars boundaries, return an
411251881Speter * array of copies of those substrings (plain const char*), allocating both
412251881Speter * the array and the copies in @a pool.
413251881Speter *
414251881Speter * None of the elements added to the array contain any of the
415251881Speter * characters in @a sep_chars, and none of the new elements are empty
416251881Speter * (thus, it is possible that the returned array will have length
417251881Speter * zero).
418251881Speter *
419251881Speter * If @a chop_whitespace is TRUE, then remove leading and trailing
420251881Speter * whitespace from the returned strings.
421251881Speter */
422251881Speterapr_array_header_t *
423251881Spetersvn_cstring_split(const char *input,
424251881Speter                  const char *sep_chars,
425251881Speter                  svn_boolean_t chop_whitespace,
426251881Speter                  apr_pool_t *pool);
427251881Speter
428251881Speter/** Like svn_cstring_split(), but append to existing @a array instead of
429251881Speter * creating a new one.  Allocate the copied substrings in @a pool
430251881Speter * (i.e., caller decides whether or not to pass @a array->pool as @a pool).
431251881Speter */
432251881Spetervoid
433251881Spetersvn_cstring_split_append(apr_array_header_t *array,
434251881Speter                         const char *input,
435251881Speter                         const char *sep_chars,
436251881Speter                         svn_boolean_t chop_whitespace,
437251881Speter                         apr_pool_t *pool);
438251881Speter
439251881Speter
440251881Speter/** Return @c TRUE iff @a str matches any of the elements of @a list, a list
441251881Speter * of zero or more glob patterns.
442251881Speter */
443251881Spetersvn_boolean_t
444251881Spetersvn_cstring_match_glob_list(const char *str, const apr_array_header_t *list);
445251881Speter
446251881Speter/** Return @c TRUE iff @a str exactly matches any of the elements of @a list.
447251881Speter *
448251881Speter * @since new in 1.7
449251881Speter */
450251881Spetersvn_boolean_t
451251881Spetersvn_cstring_match_list(const char *str, const apr_array_header_t *list);
452251881Speter
453251881Speter/**
454251881Speter * Get the next token from @a *str interpreting any char from @a sep as a
455251881Speter * token separator.  Separators at the beginning of @a str will be skipped.
456251881Speter * Returns a pointer to the beginning of the first token in @a *str or NULL
457251881Speter * if no token is left.  Modifies @a str such that the next call will return
458251881Speter * the next token.
459251881Speter *
460251881Speter * @note The content of @a *str may be modified by this function.
461251881Speter *
462251881Speter * @since New in 1.8.
463251881Speter */
464251881Speterchar *
465251881Spetersvn_cstring_tokenize(const char *sep, char **str);
466251881Speter
467251881Speter/**
468251881Speter * Return the number of line breaks in @a msg, allowing any kind of newline
469251881Speter * termination (CR, LF, CRLF, or LFCR), even inconsistent.
470251881Speter *
471251881Speter * @since New in 1.2.
472251881Speter */
473251881Speterint
474251881Spetersvn_cstring_count_newlines(const char *msg);
475251881Speter
476251881Speter/**
477251881Speter * Return a cstring which is the concatenation of @a strings (an array
478251881Speter * of char *) each followed by @a separator (that is, @a separator
479251881Speter * will also end the resulting string).  Allocate the result in @a pool.
480251881Speter * If @a strings is empty, then return the empty string.
481251881Speter *
482251881Speter * @since New in 1.2.
483251881Speter */
484251881Speterchar *
485251881Spetersvn_cstring_join(const apr_array_header_t *strings,
486251881Speter                 const char *separator,
487251881Speter                 apr_pool_t *pool);
488251881Speter
489251881Speter/**
490251881Speter * Compare two strings @a atr1 and @a atr2, treating case-equivalent
491251881Speter * unaccented Latin (ASCII subset) letters as equal.
492251881Speter *
493251881Speter * Returns in integer greater than, equal to, or less than 0,
494251881Speter * according to whether @a str1 is considered greater than, equal to,
495251881Speter * or less than @a str2.
496251881Speter *
497251881Speter * @since New in 1.5.
498251881Speter */
499251881Speterint
500251881Spetersvn_cstring_casecmp(const char *str1, const char *str2);
501251881Speter
502251881Speter/**
503251881Speter * Parse the C string @a str into a 64 bit number, and return it in @a *n.
504251881Speter * Assume that the number is represented in base @a base.
505251881Speter * Raise an error if conversion fails (e.g. due to overflow), or if the
506251881Speter * converted number is smaller than @a minval or larger than @a maxval.
507251881Speter *
508251881Speter * @since New in 1.7.
509251881Speter */
510251881Spetersvn_error_t *
511251881Spetersvn_cstring_strtoi64(apr_int64_t *n, const char *str,
512251881Speter                     apr_int64_t minval, apr_int64_t maxval,
513251881Speter                     int base);
514251881Speter
515251881Speter/**
516251881Speter * Parse the C string @a str into a 64 bit number, and return it in @a *n.
517251881Speter * Assume that the number is represented in base 10.
518251881Speter * Raise an error if conversion fails (e.g. due to overflow).
519251881Speter *
520251881Speter * @since New in 1.7.
521251881Speter */
522251881Spetersvn_error_t *
523251881Spetersvn_cstring_atoi64(apr_int64_t *n, const char *str);
524251881Speter
525251881Speter/**
526251881Speter * Parse the C string @a str into a 32 bit number, and return it in @a *n.
527251881Speter * Assume that the number is represented in base 10.
528251881Speter * Raise an error if conversion fails (e.g. due to overflow).
529251881Speter *
530251881Speter * @since New in 1.7.
531251881Speter */
532251881Spetersvn_error_t *
533251881Spetersvn_cstring_atoi(int *n, const char *str);
534251881Speter
535251881Speter/**
536251881Speter * Parse the C string @a str into an unsigned 64 bit number, and return
537251881Speter * it in @a *n. Assume that the number is represented in base @a base.
538251881Speter * Raise an error if conversion fails (e.g. due to overflow), or if the
539251881Speter * converted number is smaller than @a minval or larger than @a maxval.
540251881Speter *
541251881Speter * @since New in 1.7.
542251881Speter */
543251881Spetersvn_error_t *
544251881Spetersvn_cstring_strtoui64(apr_uint64_t *n, const char *str,
545251881Speter                      apr_uint64_t minval, apr_uint64_t maxval,
546251881Speter                      int base);
547251881Speter
548251881Speter/**
549251881Speter * Parse the C string @a str into an unsigned 64 bit number, and return
550251881Speter * it in @a *n. Assume that the number is represented in base 10.
551251881Speter * Raise an error if conversion fails (e.g. due to overflow).
552251881Speter *
553251881Speter * @since New in 1.7.
554251881Speter */
555251881Spetersvn_error_t *
556251881Spetersvn_cstring_atoui64(apr_uint64_t *n, const char *str);
557251881Speter
558251881Speter/**
559251881Speter * Parse the C string @a str into an unsigned 32 bit number, and return
560251881Speter * it in @a *n. Assume that the number is represented in base 10.
561251881Speter * Raise an error if conversion fails (e.g. due to overflow).
562251881Speter *
563251881Speter * @since New in 1.7.
564251881Speter */
565251881Spetersvn_error_t *
566251881Spetersvn_cstring_atoui(unsigned int *n, const char *str);
567251881Speter
568251881Speter/** @} */
569251881Speter
570251881Speter/** @} */
571251881Speter
572251881Speter
573251881Speter#ifdef __cplusplus
574251881Speter}
575251881Speter#endif /* __cplusplus */
576251881Speter
577251881Speter#endif  /* SVN_STRING_H */
578