Linux Kernel  3.7.1
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
Functions
string.h File Reference
#include <linux/compiler.h>
#include <linux/types.h>
#include <linux/stddef.h>
#include <stdarg.h>
#include <uapi/linux/string.h>
#include <asm/string.h>

Go to the source code of this file.

Functions

charstrndup_user (const char __user *, long)
 
voidmemdup_user (const void __user *, size_t)
 
charstrcpy (char *, const char *)
 
charstrncpy (char *, const char *, __kernel_size_t)
 
size_t strlcpy (char *, const char *, size_t)
 
charstrcat (char *, const char *)
 
charstrncat (char *, const char *, __kernel_size_t)
 
size_t strlcat (char *, const char *, __kernel_size_t)
 
int strcmp (const char *, const char *)
 
int strncmp (const char *, const char *, __kernel_size_t)
 
int strnicmp (const char *, const char *, __kernel_size_t)
 
int strcasecmp (const char *s1, const char *s2)
 
int strncasecmp (const char *s1, const char *s2, size_t n)
 
charstrchr (const char *, int)
 
charstrnchr (const char *, size_t, int)
 
charstrrchr (const char *, int)
 
char *__must_check skip_spaces (const char *)
 
charstrim (char *)
 
charstrstr (const char *, const char *)
 
charstrnstr (const char *, const char *, size_t)
 
__kernel_size_t strlen (const char *)
 
__kernel_size_t strnlen (const char *, __kernel_size_t)
 
charstrpbrk (const char *, const char *)
 
charstrsep (char **, const char *)
 
__kernel_size_t strspn (const char *, const char *)
 
__kernel_size_t strcspn (const char *, const char *)
 
voidmemset (void *, int, __kernel_size_t)
 
voidmemcpy (void *, const void *, __kernel_size_t)
 
voidmemmove (void *, const void *, __kernel_size_t)
 
voidmemscan (void *, int, __kernel_size_t)
 
int memcmp (const void *, const void *, __kernel_size_t)
 
voidmemchr (const void *, int, __kernel_size_t)
 
voidmemchr_inv (const void *s, int c, size_t n)
 
charkstrdup (const char *s, gfp_t gfp)
 
charkstrndup (const char *s, size_t len, gfp_t gfp)
 
voidkmemdup (const void *src, size_t len, gfp_t gfp)
 
char ** argv_split (gfp_t gfp, const char *str, int *argcp)
 
void argv_free (char **argv)
 
bool sysfs_streq (const char *s1, const char *s2)
 
int strtobool (const char *s, bool *res)
 
ssize_t memory_read_from_buffer (void *to, size_t count, loff_t *ppos, const void *from, size_t available)
 
size_t memweight (const void *ptr, size_t bytes)
 

Function Documentation

void argv_free ( char **  argv)

argv_free - free an argv - the argument vector to be freed

Frees an argv and the strings it points to.

Definition at line 40 of file argv_split.c.

char** argv_split ( gfp_t  gfp,
const char str,
int argcp 
)

argv_split - split a string at whitespace, returning an argv : the GFP mask used to allocate memory : the string to be split : returned argument count

Returns an array of pointers to strings which are split out from . This is performed by strictly splitting on white-space; no quote processing is performed. Multiple whitespace characters are considered to be a single argument separator. The returned array is always NULL-terminated. Returns NULL on memory allocation failure.

Definition at line 63 of file argv_split.c.

void* kmemdup ( const void src,
size_t  len,
gfp_t  gfp 
)

kmemdup - duplicate region of memory

: memory region to duplicate : memory region length : GFP mask to use

Definition at line 67 of file util.c.

char* kstrdup ( const char s,
gfp_t  gfp 
)

kstrdup - allocate space for and copy an existing string : the string to duplicate : the GFP mask used in the kmalloc() call when allocating memory

Definition at line 20 of file util.c.

char* kstrndup ( const char s,
size_t  max,
gfp_t  gfp 
)

kstrndup - allocate space for and copy an existing string : the string to duplicate : read at most chars from : the GFP mask used in the kmalloc() call when allocating memory

Definition at line 42 of file util.c.

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 96 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 68 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 151 of file memcpy.c.

void* memdup_user ( const void __user src,
size_t  len 
)

memdup_user - duplicate memory region from user space

: source address in user space : number of bytes to copy

Returns an ERR_PTR() on failure.

Definition at line 86 of file util.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 10 of file memmove.c.

ssize_t memory_read_from_buffer ( void to,
size_t  count,
loff_t *  ppos,
const void from,
size_t  available 
)

memory_read_from_buffer - copy data from the buffer : the kernel space buffer to read to : the maximum number of bytes to read : the current position in the buffer : the buffer to read from : the size of the buffer

The memory_read_from_buffer() function reads up to bytes from the buffer at offset into the kernel space address starting at .

On success, the number of bytes read is returned and the offset is advanced by this number, or negative value is returned on error.

Definition at line 652 of file libfs.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

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 332 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 116 of file string.c.

size_t memweight ( const void ptr,
size_t  bytes 
)

memweight - count the total number of bits set in memory area : pointer to the start of the area : the size of the area

Definition at line 10 of file memweight.c.

char* __must_check 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

returns a pointer to

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

Definition at line 18 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 106 of file string.c.

int strcmp ( const char cs,
const char ct 
)

strcmp - Compare two strings : One string : Another string

returns 0 if and are equal, < 0 if is less than > 0 if is greater than

strcmp - Compare two strings : One string : Another string

Definition at line 81 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

returns a pointer to

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

Definition at line 12 of file string.c.

__kernel_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.

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 154 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 94 of file string.c.

__kernel_size_t strlen ( const char s)

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

returns the length of

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

Definition at line 59 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

returns a pointer to

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

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 183 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 33 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.

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 116 of file string.c.

char* strndup_user ( const char __user ,
long   
)

Definition at line 204 of file util.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.

__kernel_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

returns the minimum of the length of and

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

Definition at line 15 of file stdio.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 226 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.

__kernel_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 244 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.