Loading...
Searching...
No Matches
su_string.h File Reference

String functions for Sofia-SIP. More...

`#include <sofia-sip/su_config.h>`
`#include <string.h>`
Include dependency graph for su_string.h:

Go to the source code of this file.

## Macros

#define | SOFIA_SIP_SU_STRING_H
| Defined when <sofia-sip/su_string.h> is included.

## Functions

char * | su_strcasestr (const char *haystack, const char *needle)
| ASCII-case-insensitive substring search.
int | su_strcasecmp (char const *s1, char const *s2)
| ASCII-case-insensitive comparison.
int | su_strncasecmp (char const *s1, char const *s2, size_t n)
| ASCII-case-insensitive comparison.
int | su_strmatch (char const *str, char const *with)
| Check if two strings match.
int | su_strnmatch (char const *str, char const *with, size_t n)
| String prefix match.
int | su_casematch (char const *s1, char const *with)
| ASCII-case-insensitive string match.
int | su_casenmatch (char const *s1, char const *with, size_t n)
| ASCII-case-insensitive string match.
size_t | su_strnspn (char const *s, size_t size, char const *term)
| Search a string for a set of characters.
size_t | su_strncspn (char const *s, size_t ssize, char const *reject)
| Search a string for a set of characters.
size_t | su_memspn (const void *mem, size_t memlen, const void *accept, size_t acceptlen)
| Scan memory for a set of bytes.
size_t | su_memcspn (const void *mem, size_t memlen, const void *reject, size_t rejectlen)
| Search memory for bytes not in a given set.

## Detailed Description

String functions for Sofia-SIP.

Various string comparison functions also accepting NULL pointer as empty string:

- su_strcmp(),
- su_strncmp(),
- su_strcasecmp() (comparison with US-ASCII case folding to lower case),
- su_strncasecmp() (comparison with US-ASCII case folding to lower case)
- su_casematch() (match token with US-ASCII case folding to lower case)
- su_casenmatch() (match token with US-ASCII case folding to lower case)

Also includes span functions testing at most n bytes:

- su_strncspn()
- su_strnspn().

## Function Documentation

## su_casematch()

int su_casematch | ( | char const * | s1,
|  | char const * | s2 )

ASCII-case-insensitive string match.

Match two strings colliding upper case and lower case ASCII characters. Avoid using locale-dependent strncasecmp(). Accept NULL arguments: two NULL pointers match each other, but otherwise NULL pointer does not match anything else, not even empty string.

Return values

  One | if first n bytes of s1 matches s2
  Zero | if first n bytes of s1 do not match s2

## su_casenmatch()

int su_casenmatch | ( | char const * | s1,
|  | char const * | s2,
|  | size_t | n )

ASCII-case-insensitive string match.

Compare two strings colliding upper case and lower case ASCII characters. Avoid using locale-dependent strncasecmp().

Return values

  One | if first n bytes of s1 matches s2
  Zero | if first n bytes of s1 do not match s2

## su_memcspn()

size_t su_memcspn | ( | const void * | mem,
|  | size_t | memlen,
|  | const void * | reject,
|  | size_t | rejectlen )

Search memory for bytes not in a given set.

Calculates the length of the memory area mem which consists entirely of bytes not in reject.

Parameters

  mem | pointer to memory area
  memlen | size of mem in bytes
  reject | pointer to table containing bytes to reject
  rejectlen | size of reject table

Returns
  The number of consequtive bytes in the memory area which are not in reject.

  If rejectlen is 0, or reject is NULL, it returns memlen, size of the memory area.

## su_memspn()

size_t su_memspn | ( | const void * | mem,
|  | size_t | memlen,
|  | const void * | accept,
|  | size_t | acceptlen )

Scan memory for a set of bytes.

Calculates the length of the memory area mem which consists entirely o * of bytes in accept.

Parameters

  mem | pointer to memory area
  memlen | size of mem in bytes
  accept | pointer to table containing bytes to accept
  acceptlen | size of accept table

Returns
  The number of consequtive bytes in the memory area which consists entirely of bytes in accept.

## su_strcasecmp()

int su_strcasecmp | ( | char const * | s1,
|  | char const * | s2 )

ASCII-case-insensitive comparison.

Compare two strings colliding upper case and lower case ASCII chars. Avoid using locale-dependent strcasecmp(). A NULL pointer compares as an empty string.

Return values

  An | int less than zero if s1 is less than s2
  Zero | if s1 matches s2
  An | int greater than zero if s1 is greater than s2

## su_strcasestr()

char * su_strcasestr | ( | const char * | haystack,
|  | const char * | needle )

ASCII-case-insensitive substring search.

Search for substring ASCII-case-insensitively.

## su_strmatch()

int su_strmatch | ( | char const * | s1,
|  | char const * | s2 )

Check if two strings match.

Compare two strings. Accept NULL arguments: two NULL pointers match each other, but otherwise NULL pointer does not match anything else, not even empty string.

Return values

  One | if s1 matches s2
  Zero | if s1 does not match s2

## su_strncasecmp()

int su_strncasecmp | ( | char const * | s1,
|  | char const * | s2,
|  | size_t | n )

ASCII-case-insensitive comparison.

Compare first n bytes of two strings colliding upper case and lower case ASCII chars. Avoid using locale-dependent strncasecmp(). A NULL pointer compares as an empty string.

Return values

  An | int less than zero if first n bytes of s1 is less than s2
  Zero | if first n bytes of s1 matches s2
  An | int greater than zero if first n bytes of s1 is greater than s2

## su_strncspn()

size_t su_strncspn | ( | char const * | s,
|  | size_t | n,
|  | char const * | reject )

Search a string for a set of characters.

Calculate the length of the initial segment of first n bytes of s which does not constists of characters in reject.

Parameters

  s | string to search for characters
  n | limit of search length
  reject | set of characters to reject

Returns
  Number of characters in the prefix of s which are not in reject.

## su_strnmatch()

int su_strnmatch | ( | char const * | s1,
|  | char const * | s2,
|  | size_t | n )

String prefix match.

Match first n bytes of two strings. If n is 0, match always, even if arguments are NULL. Otherwise, accept NULL arguments: two NULL pointers match each other. NULL pointer does not match anything else, not even empty string.

Return values

  One | if first n bytes of s1 matches s2
  Zero | if first n bytes of s1 do not match s2

## su_strnspn()

size_t su_strnspn | ( | char const * | s,
|  | size_t | n,
|  | char const * | accept )

Search a string for a set of characters.

Calculate the length of the initial segment of first n bytes of s which consists entirely of characters in accept.

Parameters

  s | string to search for characters
  n | limit of search length
  accept | set of characters to accept

Returns
  Number of characters in the prefix of s which consists only of characters from accept.

Sofia-SIP 1.12.11devel - Copyright (C) 2006 Nokia Corporation. All rights reserved. Licensed under the terms of the GNU Lesser General Public License.