su 1.12.11devel
Loading...
Searching...
No Matches
Macros | Functions
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:

Also includes span functions testing at most n bytes:

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
Oneif first n bytes of s1 matches s2
Zeroif 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
Oneif first n bytes of s1 matches s2
Zeroif 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
mempointer to memory area  
memlensize of mem in bytes
rejectpointer to table containing bytes to reject
rejectlensize 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
mempointer to memory area
memlensize of mem in bytes
acceptpointer to table containing bytes to accept
acceptlensize 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
Anint less than zero if s1 is less than s2
Zeroif s1 matches s2
Anint 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
Oneif s1 matches s2
Zeroif 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
Anint less than zero if first n bytes of s1 is less than s2
Zeroif first n bytes of s1 matches s2
Anint 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
sstring to search for characters
nlimit of search length
rejectset 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
Oneif first n bytes of s1 matches s2
Zeroif 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
sstring to search for characters
nlimit of search length
acceptset 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.