AquilaOS documentation
How it works, and its code
Loading...
Searching...
No Matches
string.h File Reference
#include <core/system.h>

Go to the source code of this file.

Functions

int snprintf (char *s, size_t n, const char *fmt,...)
 Formats a string into a buffer.
static void * memmove (void *dest, const void *src, size_t n)
 Copies n bytes from src to dest; the two may overlap.
static void * memcpy (void *dest, const void *src, size_t n)
 Copies n bytes from src to dest, which must not overlap.
static void * memset (void *s, int c, size_t n)
 Sets n bytes at s to c.
static int memcmp (const void *s1, const void *s2, size_t n)
 Compares n bytes: 0 if they're the same, else the difference of the first bytes that differ.
static int strcmp (const char *s1, const char *s2)
 Compares two strings, as the C library's strcmp().
static int strncmp (const char *s1, const char *s2, size_t n)
 Compares at most n characters of two strings.
static int strlen (const char *s)
 Returns the length of a string.
static size_t strnlen (const char *s, size_t max)
 Returns the length of a string, or max if there is no NUL in its first max bytes.
static char * strdup (const char *s)
 Returns a copy of a string, from kmalloc(), or NULL if there's no memory for it.
static char * strcpy (char *dst, const char *src)
 Copies a string, with its NUL, and returns dst.
static char * stpcpy (char *dst, const char *src)
 Copies a string, as strcpy(), but returns the end of dst (its NUL).
static char ** tokenize (const char *s, char c)
 Splits a string at each c, leading ones skipped.
static void free_tokens (char **ptr)
 Frees what tokenize() returned.

Function Documentation

◆ free_tokens()

void free_tokens ( char ** ptr)
inlinestatic

Frees what tokenize() returned.

Definition at line 205 of file string.h.

References kfree().

◆ memcmp()

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

Compares n bytes: 0 if they're the same, else the difference of the first bytes that differ.

Definition at line 53 of file string.h.

References memcmp().

◆ memcpy()

void * memcpy ( void * dest,
const void * src,
size_t n )
inlinestatic

Copies n bytes from src to dest, which must not overlap.

Definition at line 30 of file string.h.

References memcpy().

◆ memmove()

void * memmove ( void * dest,
const void * src,
size_t n )
inlinestatic

Copies n bytes from src to dest; the two may overlap.

Definition at line 12 of file string.h.

References memmove().

◆ memset()

void * memset ( void * s,
int c,
size_t n )
inlinestatic

Sets n bytes at s to c.

Definition at line 40 of file string.h.

References memset().

◆ snprintf()

int snprintf ( char * s,
size_t n,
const char * fmt,
... )

Formats a string into a buffer.

Parameters
sthe buffer
nits size: at most n - 1 characters are written, and a NUL after them (nothing at all if n is 0)
fmtthe format (see the top of this file for what it supports)
Returns
how many characters were written, not counting the NUL

Definition at line 226 of file snprintf.c.

References snprintf(), va_end, va_list, va_start, and vsnprintf().

Referenced by apic_describe(), arch_interrupts_info(), csi(), netif_register(), procfs_buddyinfo(), procfs_cmdline(), procfs_devices(), procfs_filesystems(), procfs_finddir(), procfs_kvmem(), procfs_meminfo(), procfs_mounts(), procfs_proc_maps(), procfs_proc_status(), procfs_proc_vmstats(), procfs_rdcmdline(), procfs_readdir(), procfs_uptime(), procfs_version(), pts_new(), pty_free(), and snprintf().

◆ stpcpy()

char * stpcpy ( char * dst,
const char * src )
inlinestatic

Copies a string, as strcpy(), but returns the end of dst (its NUL).

Definition at line 133 of file string.h.

References stpcpy().

Referenced by stpcpy().

◆ strcmp()

int strcmp ( const char * s1,
const char * s2 )
inlinestatic

Compares two strings, as the C library's strcmp().

A NULL string is the caller's bug: it faults, rather than comparing "equal".

Definition at line 66 of file string.h.

◆ strcpy()

char * strcpy ( char * dst,
const char * src )
inlinestatic

Copies a string, with its NUL, and returns dst.

Definition at line 119 of file string.h.

◆ strdup()

char * strdup ( const char * s)
inlinestatic

Returns a copy of a string, from kmalloc(), or NULL if there's no memory for it.

Definition at line 106 of file string.h.

References kmalloc(), memcpy(), NULL, and strlen().

Referenced by tokenize().

◆ strlen()

int strlen ( const char * s)
inlinestatic

Returns the length of a string.

Definition at line 88 of file string.h.

Referenced by strdup(), and tokenize().

◆ strncmp()

int strncmp ( const char * s1,
const char * s2,
size_t n )
inlinestatic

Compares at most n characters of two strings.

Definition at line 74 of file string.h.

◆ strnlen()

size_t strnlen ( const char * s,
size_t max )
inlinestatic

Returns the length of a string, or max if there is no NUL in its first max bytes.

Definition at line 97 of file string.h.

References strnlen().

Referenced by strnlen(), and unix_addr_check().

◆ tokenize()

char ** tokenize ( const char * s,
char c )
inlinestatic

Splits a string at each c, leading ones skipped.

Returns an array of the pieces, ended by NULL, which free_tokens() frees, or NULL if s is NULL or empty, or if there's no memory. The pieces all live in one copy of s.

Definition at line 147 of file string.h.

References kfree(), kmalloc(), NULL, strdup(), and strlen().