Embedded Xinu Network Playground COSC3300Fall2012
Standard String Library

Provides a subset of the standard C string library functions for Xinu. More...

Functions

char * strncat (char *, char *, int)
char * strchr (const char *, int)
int strcmp (const char *, const char *)
int strncmp (char *, char *, int)
char * strcpy (char *, const char *)
char * strncpy (char *, char *, int)
int strlen (const char *)
int memcmp (const void *, const void *, int)
int memcpy (void *, void *, int)

Detailed Description

Provides a subset of the standard C string library functions for Xinu.


Function Documentation

int memcmp ( const void *  s1,
const void *  s2,
int  n 
)

Compare memory (ISO C89).

Assumes memory locations are same length

Parameters:
*s1first memory location
*s2second memory location
nlength to compare
Returns:
s1>s2: >0 s1==s2: 0 s1<s2: <0
int memcpy ( void *  dst,
void *  src,
int  n 
)

Memory copy, copy a location in memory from src to dst.

Parameters:
dstdestination location
srcsource location
namount of data (in bytes) to copy
Returns:
should equal n, if not something went wrong
char* strchr ( const char *  s,
int  c 
)

Returns a pointer to the location in a string at which which a particular character appears.

Parameters:
*sstring to search
ccharacter to locate
Returns:
the pointer in the string, NULL if character not found
int strcmp ( const char *  s1,
const char *  s2 
)

Compare strings.

Parameters:
*s1first memory location
*s2second memory location
Returns:
s1>s2: >0 s1==s2: 0 s1<s2: <0
char* strcpy ( char *  s1,
const char *  s2 
)

Copy string s2 to s1.

s1 must be large enough.

Parameters:
s1first string
s2second string
Returns:
s1
int strlen ( const char *  s)

Returns the number of non-NULL bytes in a string.

Parameters:
*sstring
Returns:
length of the string
char* strncat ( char *  s1,
char *  s2,
int  n 
)

Concatenate s2 on the end of s1.

S1's space must be large enough. At most n characters are moved.

Parameters:
*s1first string
*s2second string
nlength to concatenate
Returns:
s1
int strncmp ( char *  s1,
char *  s2,
int  n 
)

Compare strings (at most n bytes).

Parameters:
*s1first memory location
*s2second memory location
nlength to compare
Returns:
s1>s2: >0 s1==s2: 0 s1<s2: <0
char* strncpy ( char *  s1,
char *  s2,
int  n 
)

Copy string s2 to s1, truncating or null-padding to always copy n bytes.

Parameters:
s1first string
s2second string
nlength of s2 to copy
Returns:
s1