Strings
[C Runtime Library.]

Collaboration diagram for Strings:

Detailed Description

C Standard String Library.


Defines

#define wsize   sizeof(word)
#define wmask   (wsize - 1)

Typedefs

typedef long word
 Copy a string.
typedef unsigned char u_char

Functions

void * memchr (CONST void *s, int c, size_t n)
 Locate byte in a memory region.
int memcmp (CONST void *s1, CONST void *s2, size_t n)
 Compare memory regions.
void * memcpy (void *dst0, CONST void *src0, size_t length)
void * memset (void *dst, int c, size_t n)
 Fill memory region with a specific byte value.
char * strcat (char *dst, CONST char *src)
 Concatenate two strings.
char * strchr (CONST char *p, int ch)
 Locate the first occurrence of a character in a string.
int strcmp (CONST char *s1, CONST char *s2)
 Compare two strings.
char * strcpy (char *dst, CONST char *src)
 Copy a string.
char * strdup (CONST char *str)
 Create a copy of a string.
int stricmp (CONST char *s1, CONST char *s2)
 Compare two strings, ignoring case.
int strnicmp (CONST char *s1, CONST char *s2, size_t n)
 Compare two strings up to a given number of characters and ignoring case.
size_t strlen (CONST char *str)
 Compute the length of a NUL terminated string.
char * strncat (char *dst, CONST char *src, size_t n)
 Concatenate two strings up to a given number of characters.
int strncmp (CONST char *s1, CONST char *s2, size_t n)
 Compare two strings up to a given number of characters.
char * strncpy (char *dst, CONST char *src, size_t n)
 Copy a string up to a given number of characters.
char * strrchr (CONST char *p, int ch)
 Locate the last occurrence of a character in a NUL terminated string.
char * strstr (CONST char *s, CONST char *find)
 Locate a substring in a string.
char * strtok (char *s, CONST char *delim)
 Isolate sequential tokens in a NUL terminated string.
char * strtok_r (char *s, CONST char *delim, char **last)
 Isolate sequential tokens in a NUL terminated string.


Define Documentation

#define wsize   sizeof(word)

Definition at line 106 of file memcpy.c.

Referenced by memcpy().

#define wmask   (wsize - 1)

Definition at line 107 of file memcpy.c.

Referenced by memcpy().


Typedef Documentation

typedef long word

Copy a string.

Copies a source string including the terminating zero character to a destination string.

Note:
The function does not perform any overflow checking.
Parameters:
dst Pointer to the destination string.
src Pointer to the source string.
Returns:
The original destination pointer.

Definition at line 104 of file memcpy.c.

typedef unsigned char u_char

Definition at line 79 of file stricmp.c.


Function Documentation

void* memchr ( CONST void *  s,
int  c,
size_t  n 
)

Locate byte in a memory region.

This function locates the first occurrence of a byte in a memory region.

Parameters:
s Pointer to the start of the memory region.
c The byte to search for, converted to an unsigned character.
n Number of bytes to search.
Returns:
A pointer to the byte located, or NULL if no such byte exists.

Definition at line 91 of file memchr.c.

References CONST.

Referenced by _putf().

int memcmp ( CONST void *  s1,
CONST void *  s2,
size_t  n 
)

Compare memory regions.

Both memory regions are assumed to be of equal length.

Parameters:
s1 Pointer to first memory region.
s2 Pointer to second memory region.
n Number of bytes to compare.
Returns:
Zero if the two regions are identical, otherwise returns the difference between the first two differing bytes.

Definition at line 91 of file memcmp.c.

References CONST.

Referenced by At45dbParamWrite(), At49bvParamWrite(), At91EfcParamWrite(), NutDhcpIfConfig(), PhatDirRemove(), and SnmpOidEquals().

void* memcpy ( void *  dst0,
CONST void *  src0,
size_t  length 
)

Examples:
caltime/caltime.c, and tcps/tcps.c.

Definition at line 114 of file memcpy.c.

References CONST, TLOOP, TLOOP1, wmask, and wsize.

Referenced by AhdlcRx(), AsnBitStringBuild(), AsnBitStringParse(), AsnOctetStringBuild(), AsnOctetStringParse(), At45dbParamRead(), At45dbParamWrite(), At49bvParamWrite(), At49bvSectorRead(), At91EfcParamWrite(), At91EfcSectorRead(), AtCanSetAccCode(), AtCanSetAccMask(), cs8900Init(), CSNicInit(), DiscoveryResponder(), DS1307RamWrite(), FATFileRead(), GetParentPath(), LcpTxProtRej(), main(), NicInit(), NutArpAllocNetBuf(), NutArpCacheUpdate(), NutArpOutput(), NutDhcpIfConfig(), NutDiscoveryAnnTele(), NutDiscoveryAppConf(), NutEtherOutput(), NutIcmpResponse(), NutIpRouteList(), NutNetBufClone(), NutNetIfConfig2(), NutNetIfSetup(), NutTcpDeviceWrite(), NutTcpOutput(), NutTcpReceive(), NutThreadCreate(), NutUdpReceiveFrom(), NutUdpSendTo(), PapTxAuthReq(), PhatDirEntryUpdate(), PhatFileOpen(), PhatFileRead(), PhatFileWrite(), PhatVolMount(), SJASetAccCode(), SJASetAccMask(), SnmpMibFind(), SnmpMibRegister(), strdup(), UxmlNodeAddAttrib(), UxmlNodeCreate(), UxmlParseStream(), wlandrv_IOCTL(), wlandrv_PutPacket(), and X12EepromWrite().

void* memset ( void *  dst,
int  c,
size_t  n 
)

Fill memory region with a specific byte value.

Parameters:
dst Pointer to the memory region.
c Byte value.
n Number of bytes.
Returns:
The original destination pointer.
Examples:
canbus/candemo.c.

Definition at line 88 of file memset.c.

Referenced by AceInit(), AhdlcAvrInit(), AsixInit(), AsnOctetStringBuild(), At45dbSendCmd(), AtCanInit(), calloc(), cs8900Init(), CSNicInit(), DmInit(), DS1307RtcSetClock(), EmacInit(), ether_aton(), findenv(), GpioRegisterIrqHandler(), IDEInit(), LancInit(), main(), MakePhatName(), NicInit(), NutArpAllocNetBuf(), NutChatCreate(), NutDhcpIfConfig(), NutDiscoveryAnnTele(), NutEtherOutput(), NutFtpOpenSession(), NutHeapAllocClear(), NutIpOutput(), NutNetLoadConfig(), NutTcpDestroySocket(), NutWinsNameQuery(), opendir(), PcfRtcSetClock(), PhatDirCreate(), PhatDirEntryStatus(), PhatDirOpen(), PhatDirRead(), PhatFileOpen(), PhatVolMount(), setenv(), SJAInit(), SnmpAgent(), SnmpCommunityCreate(), SnmpViewCreate(), UartAvrInit(), UxmlNodeCreate(), wlandrv_Init(), wlandrv_IOCTL(), wlandrv_PutPacket(), WlanInit(), X12RtcGetAlarm(), X12RtcSetAlarm(), and X12RtcSetClock().

char* strcat ( char *  dst,
CONST char *  src 
)

Concatenate two strings.

Append a copy of a NUL terminated string to the end of another NUL terminated string.

Note:
The function does not perform any overflow checking.
Parameters:
dst Pointer to the destination string.
src Pointer to the source string.
Returns:
The original destination pointer.

Definition at line 91 of file strcat.c.

Referenced by ScanStreamHeader(), vsyslog(), and vsyslog_P().

char* strchr ( CONST char *  p,
int  ch 
)

Locate the first occurrence of a character in a string.

The terminating NUL character is considered part of the string.

Parameters:
p Pointer to the string.
ch Character to locate.
Returns:
A pointer to the located character or NULL if the character does not appear in the string.
Examples:
portdio/portdio.c, pppc/pppc.c, tcps/tcps.c, and uart/uart.c.

Definition at line 89 of file strchr.c.

Referenced by main(), MakePhatName(), NutHttpProcessRequest(), NutRegisterFtpRoot(), ProcessRequests(), and putenv().

int strcmp ( CONST char *  s1,
CONST char *  s2 
)

Compare two strings.

The strings are compared lexicographically.

Parameters:
s1 Pointer to the first string.
s2 Pointer to the second string.
Returns:
An integer greater than, equal to, or less than 0, according to whether the first string is greater than, equal to, or less than the second string.
Examples:
httpd/httpserv.c.

Definition at line 91 of file strcmp.c.

Referenced by ConfigLoad(), findenv(), GetThreadByName(), MmCardMount(), NutChatExpect(), NutDeviceLookup(), NutFtpProcessCwd(), NutFtpProcessPass(), NutFtpProcessUser(), NutHttpGetParameter(), NutNetLoadConfig(), NutWinsNameQuery(), rename(), RfcTimeParse(), setenv(), SnmpCommunityCreate(), SnmpCommunityFind(), SnmpViewCreate(), and SnmpViewFind().

char* strcpy ( char *  dst,
CONST char *  src 
)

Copy a string.

Copies a source string including the terminating zero character to a destination string.

Note:
The function does not perform any overflow checking.
Parameters:
dst Pointer to the destination string.
src Pointer to the source string.
Returns:
The original destination pointer.
Examples:
inetq/inetq.c.

Definition at line 89 of file strcpy.c.

Referenced by AsixInit(), basename(), ConfigLoad(), ConfigStation(), CreateFullPathName(), dirname(), DisplayEntry(), DisplayStatus(), findenv(), main(), NutChat(), NutDnsConfig2(), NutFtpProcessCwd(), NutHttpProcessRequest(), NutInit(), NutRegisterAuth(), NutRegisterFtpRoot(), NutRegisterFtpUser(), NutRegisterHttpRoot(), opendir(), openlog(), PhatDirRead(), putenv(), ScanStreamHeader(), setenv(), SnmpCommunityCreate(), and SnmpViewCreate().

char* strdup ( CONST char *  str  ) 

Create a copy of a string.

Allocates sufficient memory from heap for a copy of the string does the copy.

Parameters:
str Pointer to the string to copy.
Returns:
A pointer to the new string or NULL if allocating memory failed.

Definition at line 89 of file strdup.c.

References malloc, memcpy(), and strlen().

int stricmp ( CONST char *  s1,
CONST char *  s2 
)

Compare two strings, ignoring case.

The strings are compared lexicographically. The comparison is done using unsigned characters,

Parameters:
s1 Pointer to the first string.
s2 Pointer to the second string.
Returns:
An integer greater than, equal to, or less than 0, according to whether the first string is greater than, equal to, or less than the second string after translation of each corresponding character to lower-case.

Definition at line 135 of file stricmp.c.

References CONST.

int strnicmp ( CONST char *  s1,
CONST char *  s2,
size_t  n 
)

Compare two strings up to a given number of characters and ignoring case.

The strings are compared lexicographically. The comparison is done using unsigned characters,

Parameters:
s1 Pointer to the first string.
s2 Pointer to the second string.
n Number of bytes to compare.
Returns:
An integer greater than, equal to, or less than 0, according to whether the first string is greater than, equal to, or less than the second string after translation of each corresponding character to lower-case.

Definition at line 165 of file stricmp.c.

References CONST.

size_t strlen ( CONST char *  str  ) 

Compute the length of a NUL terminated string.

Parameters:
str Pointer to the string.
Returns:
The number of characters that precede the terminating NUL character.
Examples:
inetq/inetq.c, portdio/portdio.c, pppc/pppc.c, tcps/tcps.c, and uart/uart.c.

Definition at line 87 of file strlen.c.

References CONST.

Referenced by _putf(), basename(), ConfigLoad(), ConfigSize(), ConfigStation(), CreateFullPathName(), dirname(), Displayer(), fputs(), GetParentPath(), main(), NutChat(), NutChatSend(), NutDnsConfig2(), NutFtpProcessCwd(), NutFtpServerSession(), NutFtpTransferDirectory(), NutGetMimeHandler(), NutGetMimeType(), NutHttpProcessRequest(), NutHttpURLEncode(), NutRegisterAuth(), NutRegisterFtpRoot(), NutRegisterFtpUser(), NutRegisterHttpRoot(), NutWinsNameQuery(), opendir(), openlog(), PapTxAuthReq(), PhatDirRead(), ProcessRequests(), putenv(), ScanStreamHeader(), setenv(), SnmpCommunityCreate(), SnmpViewCreate(), strdup(), strstr(), UxmlNodeAddAttrib(), UxmlNodeCreate(), UxmlParseStream(), vsyslog(), vsyslog_P(), and wlandrv_IOCTL().

char* strncat ( char *  dst,
CONST char *  src,
size_t  n 
)

Concatenate two strings up to a given number of characters.

Append a copy of a NUL terminated string to the end of another NUL terminated string. Appends a copy of the source string including the terminating NUL character, if its length is lower than the given number of characters. Otherwise the destination string is left unterminated.

Parameters:
dst Pointer to the destination string.
src Pointer to the source string.
n Number of bytes appended at most.
Returns:
The original destination pointer.

Definition at line 94 of file strncat.c.

References CONST.

int strncmp ( CONST char *  s1,
CONST char *  s2,
size_t  n 
)

Compare two strings up to a given number of characters.

The strings are compared lexicographically. The comparison is done using unsigned characters,

Parameters:
s1 Pointer to the first string.
s2 Pointer to the second string.
n Number of bytes to compare.
Returns:
An integer greater than, equal to, or less than 0, according to whether the first string is greater than, equal to, or less than the second string after translation of each corresponding character to lower-case.
Examples:
portdio/portdio.c, pppc/pppc.c, and tcps/tcps.c.

Definition at line 96 of file strncmp.c.

Referenced by NutHttpAuthValidate(), ProcessRequests(), ScanStreamHeader(), and strstr().

char* strncpy ( char *  dst,
CONST char *  src,
size_t  n 
)

Copy a string up to a given number of characters.

Copies a source string including the terminating NUL character, if its length is lower than the given number of characters. Otherwise the destination string is left unterminated.

Parameters:
dst Pointer to the destination string.
src Pointer to the source string.
n Maximum number of characters to copy.
Returns:
The original destination pointer.

Definition at line 92 of file strncpy.c.

References CONST.

Referenced by dirname(), DisplayEntry(), DisplayStation(), and DisplayStatus().

char* strrchr ( CONST char *  p,
int  ch 
)

Locate the last occurrence of a character in a NUL terminated string.

The terminating NUL character is considered part of the string.

Parameters:
p Pointer to the string.
ch Character to locate.
Returns:
A pointer to the located character or NULL if the character does not appear in the string.

Definition at line 90 of file strrchr.c.

Referenced by GetParentPath(), NutHttpAuthValidate(), and NutHttpSendError().

char* strstr ( CONST char *  s,
CONST char *  find 
)

Locate a substring in a string.

Finds the first occurrence of a NUL terminated string in another NUL terminated string.

Parameters:
s Pointer to the string to be searched.
find Pointer to the string to look for.
Returns:
A pointer to the first occurrence of the substring. If the string to search is an empty string, then the original pointer is returned. If the substring does not occur in the string to be searched, then a null pointer is returned.

Definition at line 93 of file strstr.c.

References strlen(), and strncmp().

char* strtok ( char *  s,
CONST char *  delim 
)

Isolate sequential tokens in a NUL terminated string.

The tokens are separated in the string by at least one of the characters in the given separator string.

The first time this function is called, the string should be specified. Subsequent calls, wishing to obtain further tokens from the same string, should pass a null pointer instead.

The separator string must be supplied each time, and may change between calls.

Parameters:
s Pointer to the string to separate.
delim Pointer to the separator string.
Returns:
A pointer to the beginning of each subsequent token in the string, after replacing the separator character itself with a zero character. When no more tokens remain, a null pointer is returned.

Definition at line 100 of file strtok.c.

References strtok_r().

char* strtok_r ( char *  s,
CONST char *  delim,
char **  last 
)

Isolate sequential tokens in a NUL terminated string.

Similar to strtok(), but takes an explicit context argument and thus is reentrant.

Parameters:
s Pointer to the string to separate.
delim Pointer to the separator string.
last Used to store the current search context.
Returns:
A pointer to the beginning of each subsequent token in the string, after replacing the separator character itself with a zero character. When no more tokens remain, a null pointer is returned.

Definition at line 122 of file strtok.c.

Referenced by strtok().


© 2000-2007 by egnite Software GmbH - visit http://www.ethernut.de/