Linux Kernel  3.7.1
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
Functions
string.c File Reference
#include <linux/types.h>
#include <linux/string.h>
#include <linux/ctype.h>
#include <linux/kernel.h>
#include <linux/export.h>
#include <linux/bug.h>
#include <linux/errno.h>

Go to the source code of this file.

Functions

int strnicmp (const char *s1, const char *s2, size_t len)
 
 EXPORT_SYMBOL (strnicmp)
 
int strcasecmp (const char *s1, const char *s2)
 
 EXPORT_SYMBOL (strcasecmp)
 
int strncasecmp (const char *s1, const char *s2, size_t n)
 
 EXPORT_SYMBOL (strncasecmp)
 
charstrcpy (char *dest, const char *src)
 
 EXPORT_SYMBOL (strcpy)
 
charstrncpy (char *dest, const char *src, size_t count)
 
 EXPORT_SYMBOL (strncpy)
 
size_t strlcpy (char *dest, const char *src, size_t size)
 
 EXPORT_SYMBOL (strlcpy)
 
charstrcat (char *dest, const char *src)
 
 EXPORT_SYMBOL (strcat)
 
charstrncat (char *dest, const char *src, size_t count)
 
 EXPORT_SYMBOL (strncat)
 
size_t strlcat (char *dest, const char *src, size_t count)
 
 EXPORT_SYMBOL (strlcat)
 
int strcmp (const char *cs, const char *ct)
 
 EXPORT_SYMBOL (strcmp)
 
int strncmp (const char *cs, const char *ct, size_t count)
 
 EXPORT_SYMBOL (strncmp)
 
charstrchr (const char *s, int c)
 
 EXPORT_SYMBOL (strchr)
 
charstrrchr (const char *s, int c)
 
 EXPORT_SYMBOL (strrchr)
 
charstrnchr (const char *s, size_t count, int c)
 
 EXPORT_SYMBOL (strnchr)
 
charskip_spaces (const char *str)
 
 EXPORT_SYMBOL (skip_spaces)
 
charstrim (char *s)
 
 EXPORT_SYMBOL (strim)
 
size_t strlen (const char *s)
 
 EXPORT_SYMBOL (strlen)
 
size_t strnlen (const char *s, size_t count)
 
 EXPORT_SYMBOL (strnlen)
 
size_t strspn (const char *s, const char *accept)
 
 EXPORT_SYMBOL (strspn)
 
size_t strcspn (const char *s, const char *reject)
 
 EXPORT_SYMBOL (strcspn)
 
charstrpbrk (const char *cs, const char *ct)
 
 EXPORT_SYMBOL (strpbrk)
 
charstrsep (char **s, const char *ct)
 
 EXPORT_SYMBOL (strsep)
 
bool sysfs_streq (const char *s1, const char *s2)
 
 EXPORT_SYMBOL (sysfs_streq)
 
int strtobool (const char *s, bool *res)
 
 EXPORT_SYMBOL (strtobool)
 
voidmemset (void *s, int c, size_t count)
 
 EXPORT_SYMBOL (memset)
 
voidmemcpy (void *dest, const void *src, size_t count)
 
 EXPORT_SYMBOL (memcpy)
 
voidmemmove (void *dest, const void *src, size_t count)
 
 EXPORT_SYMBOL (memmove)
 
int memcmp (const void *cs, const void *ct, size_t count)
 
 EXPORT_SYMBOL (memcmp)
 
voidmemscan (void *addr, int c, size_t size)
 
 EXPORT_SYMBOL (memscan)
 
charstrstr (const char *s1, const char *s2)
 
 EXPORT_SYMBOL (strstr)
 
charstrnstr (const char *s1, const char *s2, size_t len)
 
 EXPORT_SYMBOL (strnstr)
 
voidmemchr (const void *s, int c, size_t n)
 
 EXPORT_SYMBOL (memchr)
 
voidmemchr_inv (const void *start, int c, size_t bytes)
 
 EXPORT_SYMBOL (memchr_inv)
 

Function Documentation

EXPORT_SYMBOL ( strnicmp  )
EXPORT_SYMBOL ( strcasecmp  )
EXPORT_SYMBOL ( strncasecmp  )
EXPORT_SYMBOL ( strcpy  )
EXPORT_SYMBOL ( strncpy  )
EXPORT_SYMBOL ( strlcpy  )
EXPORT_SYMBOL ( strcat  )
EXPORT_SYMBOL ( strncat  )
EXPORT_SYMBOL ( strlcat  )
EXPORT_SYMBOL ( strcmp  )
EXPORT_SYMBOL ( strncmp  )
EXPORT_SYMBOL ( strchr  )
EXPORT_SYMBOL ( strrchr  )
EXPORT_SYMBOL ( strnchr  )
EXPORT_SYMBOL ( skip_spaces  )
EXPORT_SYMBOL ( strim  )
EXPORT_SYMBOL ( strlen  )
EXPORT_SYMBOL ( strnlen  )
EXPORT_SYMBOL ( strspn  )
EXPORT_SYMBOL ( strcspn  )
EXPORT_SYMBOL ( strpbrk  )
EXPORT_SYMBOL ( strsep  )
EXPORT_SYMBOL ( sysfs_streq  )
EXPORT_SYMBOL ( strtobool  )
EXPORT_SYMBOL ( memset  )
EXPORT_SYMBOL ( memcpy  )
EXPORT_SYMBOL ( memmove  )
EXPORT_SYMBOL ( memcmp  )
EXPORT_SYMBOL ( memscan  )
EXPORT_SYMBOL ( strstr  )
EXPORT_SYMBOL ( strnstr  )
EXPORT_SYMBOL ( memchr  )
EXPORT_SYMBOL ( memchr_inv  )
void* memchr ( const void s,
int  c,
size_t  n 
)

memchr - Find a character in an area of memory. : The memory area : The byte to search for
: The size of the area.

returns the address of the first occurrence of , or NULL if is not found

Definition at line 749 of file string.c.

void* memchr_inv ( const void start,
int  c,
size_t  bytes 
)

memchr_inv - Find an unmatching character in an area of memory. : The memory area : Find a character other than c : The size of the area.

returns the address of the first character other than , or NULL if the whole buffer contains just .

Definition at line 782 of file string.c.

int memcmp ( const void cs,
const void ct,
size_t  count 
)

memcmp - Compare two areas of memory : One area of memory : Another area of memory : The size of the area.

Definition at line 651 of file string.c.

void* memcpy ( void dest,
const void src,
size_t  count 
)

memcpy - Copy one area of memory to another : Where to copy to : Where to copy from : The size of the area.

You should not use this function to access IO space, use memcpy_toio() or memcpy_fromio() instead.

Definition at line 599 of file string.c.

void* memmove ( void dest,
const void src,
size_t  count 
)

memmove - Copy one area of memory to another : Where to copy to : Where to copy from : The size of the area.

Unlike memcpy(), memmove() copes with overlapping areas.

Definition at line 620 of file string.c.

void* memscan ( void addr,
int  c,
size_t  size 
)

memscan - Find a character in an area of memory. : The memory area : The byte to search for : The size of the area.

returns the address of the first occurrence of , or 1 byte past the area if is not found

Definition at line 674 of file string.c.

void* memset ( void s,
int  c,
size_t  count 
)

memset - Fill a region of memory with the given value : Pointer to the start of the area. : The byte to fill the area with : The size of the area.

Do not use memset() to access IO space, use memset_io() instead.

Definition at line 578 of file string.c.

char* skip_spaces ( const char str)

skip_spaces - Removes leading whitespace from . : The string to be stripped.

Returns a pointer to the first non-whitespace character in .

Definition at line 345 of file string.c.

int strcasecmp ( const char s1,
const char s2 
)

Definition at line 63 of file string.c.

char* strcat ( char dest,
const char src 
)

strcat - Append one NUL-terminated string to another : The string to be appended to : The string to append to it

Definition at line 170 of file string.c.

char* strchr ( const char s,
int  c 
)

strchr - Find the first occurrence of a character in a string : The string to be searched : The character to search for

Definition at line 294 of file string.c.

int strcmp ( const char cs,
const char ct 
)

strcmp - Compare two strings : One string : Another string

Definition at line 246 of file string.c.

char* strcpy ( char dest,
const char src 
)

strcpy - Copy a NUL terminated string : Where to copy the string to : Where to copy the string from

Definition at line 97 of file string.c.

size_t strcspn ( const char s,
const char reject 
)

strcspn - Calculate the length of the initial substring of which does not contain letters in : The string to be searched : The string to avoid

Definition at line 445 of file string.c.

char* strim ( char s)

strim - Removes leading and trailing whitespace from . : The string to be stripped.

Note that the first trailing whitespace is replaced with a NUL-terminator in the given string . Returns a pointer to the first non-whitespace character in .

Definition at line 361 of file string.c.

size_t strlcat ( char dest,
const char src,
size_t  count 
)

strlcat - Append a length-limited, NUL-terminated string to another : The string to be appended to : The string to append to it : The size of the destination buffer.

Definition at line 219 of file string.c.

size_t strlcpy ( char dest,
const char src,
size_t  size 
)

strlcpy - Copy a NUL terminated string into a sized buffer : Where to copy the string to : Where to copy the string from : size of destination buffer

Compatible with *BSD: the result is always a valid NUL-terminated string that fits in the buffer (unless, of course, the buffer size is zero). It does not pad out the result like strncpy() does.

Definition at line 149 of file string.c.

size_t strlen ( const char s)

strlen - Find the length of a string : The string to be sized

Definition at line 384 of file string.c.

int strncasecmp ( const char s1,
const char s2,
size_t  n 
)

Definition at line 77 of file string.c.

char* strncat ( char dest,
const char src,
size_t  count 
)

strncat - Append a length-limited, NUL-terminated string to another : The string to be appended to : The string to append to it : The maximum numbers of bytes to copy

Note that in contrast to strncpy(), strncat() ensures the result is terminated.

Definition at line 193 of file string.c.

char* strnchr ( const char s,
size_t  count,
int  c 
)

strnchr - Find a character in a length limited string : The string to be searched : The number of characters to be searched : The character to search for

Definition at line 329 of file string.c.

int strncmp ( const char cs,
const char ct,
size_t  count 
)

strncmp - Compare two length-limited strings : One string : Another string : The maximum number of bytes to compare

Definition at line 270 of file string.c.

char* strncpy ( char dest,
const char src,
size_t  count 
)

strncpy - Copy a length-limited, NUL-terminated string : Where to copy the string to : Where to copy the string from : The maximum number of bytes to copy

The result is not NUL-terminated if the source exceeds bytes.

In the case where the length of is less than that of count, the remainder of will be padded with NUL.

Definition at line 122 of file string.c.

int strnicmp ( const char s1,
const char s2,
size_t  len 
)

strnicmp - Case insensitive, length-limited string comparison : One string : The other string : the maximum number of characters to compare

Definition at line 37 of file string.c.

size_t strnlen ( const char s,
size_t  count 
)

strnlen - Find the length of a length-limited string : The string to be sized : The maximum number of bytes to search

Definition at line 401 of file string.c.

char* strnstr ( const char s1,
const char s2,
size_t  len 
)

strnstr - Find the first substring in a length-limited string : The string to be searched : The string to search for : the maximum number of characters to search

Definition at line 721 of file string.c.

char* strpbrk ( const char cs,
const char ct 
)

strpbrk - Find the first occurrence of a set of characters : The string to be searched : The characters to search for

Definition at line 469 of file string.c.

char* strrchr ( const char s,
int  c 
)

strrchr - Find the last occurrence of a character in a string : The string to be searched : The character to search for

Definition at line 310 of file string.c.

char* strsep ( char **  s,
const char ct 
)

strsep - Split a string into tokens : The string to be searched : The characters to search for

strsep() updates to point after the token, ready for the next call.

It returns empty tokens, too, behaving exactly like the libc function of that name. In fact, it was stolen from glibc2 and de-fancy-fied. Same semantics, slimmer shape. ;)

Definition at line 496 of file string.c.

size_t strspn ( const char s,
const char accept 
)

strspn - Calculate the length of the initial substring of which only contain letters in : The string to be searched : The string to search for

Definition at line 418 of file string.c.

char* strstr ( const char s1,
const char s2 
)

strstr - Find the first substring in a NUL terminated string : The string to be searched : The string to search for

Definition at line 695 of file string.c.

int strtobool ( const char s,
bool res 
)

strtobool - convert common user inputs into boolean values : input string : result

This routine returns 0 iff the first character is one of 'Yy1Nn0'. Otherwise it will return -EINVAL. Value pointed to by res is updated upon finding a match.

Definition at line 549 of file string.c.

bool sysfs_streq ( const char s1,
const char s2 
)

sysfs_streq - return true if strings are equal, modulo trailing newline : one string : another string

This routine returns true iff two strings are equal, treating both NUL and newline-then-NUL as equivalent string terminations. It's geared for use with sysfs input strings, which generally terminate with newlines but are compared against values without newlines.

Definition at line 523 of file string.c.