Loading...
Searching...
No Matches
C string functions
String handling

## Functions

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.
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.
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.
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.
char * | svn_cstring_tokenize (const char *sep, char **str)
| Get the next token from *str interpreting any char from sep as a token separator.
int | svn_cstring_count_newlines (const char *msg)
| Return the number of line breaks in msg, allowing any kind of newline termination (CR, LF, CRLF, or LFCR), even inconsistent.
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.
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.
int | svn_cstring_casecmp (const char *str1, const char *str2)
| Compare two strings atr1 and atr2, treating case-equivalent unaccented Latin (ASCII subset) letters as equal.
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.
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.
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_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.
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.
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.
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 the prefix.

## Detailed Description

## Function Documentation

## svn_cstring_atoi()

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.

Assume that the number is represented in base 10. Raise an error if conversion fails (e.g. due to overflow).

The behaviour otherwise is as described for svn_cstring_strtoi64().

Since
  New in 1.7.

References svn_cstring_atoi().

Referenced by svn_cstring_atoi().

## svn_cstring_atoi64()

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.

Assume that the number is represented in base 10. Raise an error if conversion fails (e.g. due to overflow).

The behaviour otherwise is as described for svn_cstring_strtoi64().

Since
  New in 1.7.

References svn_cstring_atoi64().

Referenced by svn_cstring_atoi64().

## svn_cstring_atoui()

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.

Assume that the number is represented in base 10. Raise an error if conversion fails (e.g. due to overflow).

The behaviour otherwise is as described for svn_cstring_strtoui64(), including the upper limit of APR_INT64_MAX.

Since
  New in 1.7.

References svn_cstring_atoui().

Referenced by svn_cstring_atoui().

## svn_cstring_atoui64()

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.

Assume that the number is represented in base 10. Raise an error if conversion fails (e.g. due to overflow).

The behaviour otherwise is as described for svn_cstring_strtoui64(), including the upper limit of APR_INT64_MAX.

Since
  New in 1.7.

References svn_cstring_atoui64().

Referenced by svn_cstring_atoui64().

## svn_cstring_casecmp()

int svn_cstring_casecmp | ( | const char * | str1,
|  | const char * | str2 )

Compare two strings atr1 and atr2, treating case-equivalent unaccented Latin (ASCII subset) letters as equal.

Returns in integer greater than, equal to, or less than 0, according to whether str1 is considered greater than, equal to, or less than str2.

Since
  New in 1.5.

References svn_cstring_casecmp().

Referenced by svn_cstring_casecmp().

## svn_cstring_count_newlines()

int svn_cstring_count_newlines | ( | const char * | msg | ) |

Return the number of line breaks in msg, allowing any kind of newline termination (CR, LF, CRLF, or LFCR), even inconsistent.

Since
  New in 1.2.

References svn_cstring_count_newlines().

Referenced by svn_cstring_count_newlines().

## svn_cstring_join()

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.

Since
  New in 1.2.

Deprecated
  Provided for backwards compatibility with the 1.9 API.

References svn_cstring_join().

Referenced by svn_cstring_join().

## svn_cstring_join2()

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.

Allocate the result in pool. If strings is empty, then return the empty string. If trailing_separator is non-zero, also append the separator after the last joined element.

Since
  New in 1.10.

References svn_cstring_join2(), and SVN_DEPRECATED.

Referenced by svn_cstring_join2().

## svn_cstring_match_list()

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.

Since
  new in 1.7

References svn_cstring_match_list().

Referenced by svn_cstring_match_list().

## svn_cstring_skip_prefix()

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 the prefix.

Return `NULL` if str does not start with prefix.

Since
  New in 1.9.

References svn_cstring_skip_prefix().

Referenced by svn_cstring_skip_prefix().

## svn_cstring_split()

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.

Return an array of copies of those substrings (plain const char*), allocating both the array and the copies in pool.

None of the elements added to the array contain any of the characters in sep_chars, and none of the new elements are empty (thus, it is possible that the returned array will have length zero).

If chop_whitespace is TRUE, then remove leading and trailing whitespace from the returned strings.

References svn_cstring_split().

Referenced by svn_cstring_split().

## svn_cstring_split_append()

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.

Allocate the copied substrings in pool (i.e., caller decides whether or not to pass array->pool as pool).

References svn_cstring_split_append().

Referenced by svn_cstring_split_append().

## svn_cstring_strtoi64()

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.

Assume that the number is represented in base base. Raise an error if conversion fails (e.g. due to overflow), or if the converted number is smaller than minval or larger than maxval.

Leading whitespace in str is skipped in a locale-dependent way. After that, the string may contain an optional '+' (positive, default) or '-' (negative) character, followed by an optional '0x' prefix if base is 0 or 16, followed by numeric digits appropriate for the base. If there are any more characters after the numeric digits, an error is returned.

If base is zero, then a leading '0x' or '0X' prefix means hexadecimal, else a leading '0' means octal (implemented, though not documented, in apr_strtoi64() in APR 0.9.0 through 1.5.0), else use base ten.

Since
  New in 1.7.

References svn_cstring_strtoi64().

Referenced by svn_cstring_strtoi64().

## svn_cstring_strtoui64()

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.

Assume that the number is represented in base base. Raise an error if conversion fails (e.g. due to overflow), or if the converted number is smaller than minval or larger than maxval.

Leading whitespace in str is skipped in a locale-dependent way. After that, the string may contain an optional '+' (positive, default) or '-' (negative) character, followed by an optional '0x' prefix if base is 0 or 16, followed by numeric digits appropriate for the base. If there are any more characters after the numeric digits, an error is returned.

If base is zero, then a leading '0x' or '0X' prefix means hexadecimal, else a leading '0' means octal (implemented, though not documented, in apr_strtoi64() in APR 0.9.0 through 1.5.0), else use base ten.

Warning
  The implementation used since version 1.7 returns an error if the parsed number is greater than APR_INT64_MAX, even if it is not greater than maxval.

Since
  New in 1.7.

References svn_cstring_strtoui64().

Referenced by svn_cstring_strtoui64().

## svn_cstring_tokenize()

char * svn_cstring_tokenize | ( | const char * | sep,
|  | char ** | str )

Get the next token from *str interpreting any char from sep as a token separator.

Separators at the beginning of str will be skipped. Returns a pointer to the beginning of the first token in *str or NULL if no token is left. Modifies str such that the next call will return the next token.

Note
  The content of *str may be modified by this function.

Since
  New in 1.8.

References svn_cstring_tokenize().

Referenced by svn_cstring_tokenize().