String functions for Sofia-SIP. More...
#include <sofia-sip/su_config.h>
#include <string.h>
Go to the source code of this file.
Defines | |
#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. |
String functions for Sofia-SIP.
Various string comparison functions also accepting NULL pointer as empty string:
Also includes span functions testing at most n bytes:
#define SOFIA_SIP_SU_STRING_H |
Defined when <sofia-sip/su_string.h> is included.
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.
One | if first n bytes of s1 matches s2 | |
Zero | if first n bytes of s1 do not match s2 |
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().
One | if first n bytes of s1 matches s2 | |
Zero | if first n bytes of s1 do not match s2 |
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.
mem | pointer to memory area | |
memlen | size of mem in bytes | |
reject | pointer to table containing bytes to reject | |
rejectlen | size of reject table |
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.
mem | pointer to memory area | |
memlen | size of mem in bytes | |
accept | pointer to table containing bytes to accept | |
acceptlen | size of accept table |
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.
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 |
char* su_strcasestr | ( | const char * | haystack, | |
const char * | needle | |||
) |
ASCII-case-insensitive substring search.
Search for substring ASCII-case-insensitively.
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.
One | if s1 matches s2 | |
Zero | if s1 does not match s2 |
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.
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 |
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.
s | string to search for characters | |
n | limit of search length | |
reject | set of characters to reject |
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.
One | if first n bytes of s1 matches s2 | |
Zero | if first n bytes of s1 do not match s2 |
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.
s | string to search for characters | |
n | limit of search length | |
accept | set of characters to accept |