OurOS
0.1
Operating System built by McGill Students
Loading...
Searching...
No Matches
string.h
1
#ifndef _STRING_H
2
#define _STRING_H
3
4
#include <stdint.h>
5
#include <stdbool.h>
6
7
// returns 0 if equal
8
int
strcmp(
const
char
*str1,
const
char
*str2);
9
10
// Compare n characters of str1 and str2
11
// Returns: 0 if equal, < 0 if str1 < str2, > 0 if str1 > srt2
12
int
strncmp(
const
char
*str1,
const
char
*str2, uint64_t n);
13
14
// Find first occurence of character c in str
15
// Returns: pointer to first occurence
16
char
*strchr(
const
char
*str,
int
c);
17
18
// Find last occurence of character c in str
19
// Returns: pointer to last occurence
20
char
*strrchr(
const
char
*str,
char
c);
21
22
// Copy n characters of src into dst
23
// Returns: dst
24
char
*strncpy(
const
char
*src,
char
*dst, uint64_t n);
25
26
// Copy src into dst
27
// Returns: dest
28
char
*strcpy(
char
*dst,
const
char
*src);
29
30
// Copy src into dst
31
// Returns: pointer to the terminating null byte of the copied string
32
char
*stpcpy(
char
*dst,
const
char
*src);
33
34
// Concatenate src onto dst, adding it to the end of dst and null-terminating
35
// Returns: dst
36
char
*strcat(
char
*dst,
const
char
*src);
37
38
// Like strcmp, but ignores cases
39
int
strcasecmp(
const
char
*str1,
const
char
*str2);
40
41
// Get the length of a string, not including null-terminator and newlines
42
uint64_t strlen(
const
char
*str);
43
44
// The strtok() function breaks a string into a sequence of zero or more nonempty tokens. On the first call to strtok(),
45
// the string
46
// To be parsed should be specified in str. In each subsequent call that should parse the same string, str must be NULL.
47
//
48
// The delim argument specifies a set of bytes that delimit the tokens in the parsed string.
49
// The caller may specify different strings in delim in successive calls that parse the same string.
50
// Each call to strtok() returns a pointer to a null-terminated string containing the next token.
51
// This string does not include the delimiting byte. If no more tokens are found, strtok() returns NULL.
52
char
*strtok(
char
*str,
const
char
*delim);
53
54
// The strstr() returns the first occurence of substr string within the str string, otherwise returns NULL
55
char
*strstr(
const
char
*str,
const
char
*substr);
56
57
// The strpbrk() function locates the first occurrence in the string s of any of the bytes in the string accept.
58
char
*strpbrk(
const
char
*s,
const
char
*accept);
59
60
int
dec_to_str(
int
val,
char
*buf);
61
62
// hex_to_str() writes 0xXXXXXXXXXXXXXXXX into buf (19 bytes)
63
void
hex_to_str(uint64_t val,
char
*buf);
64
65
// Copy n bytes from src to dest
66
// Returns dest
67
void
*memcpy(
void
*dest,
const
void
*src, uint64_t n);
68
69
// Copy n bytes from src to dest
70
// Returns the last byte in dest
71
void
*mempcpy(
void
*dest,
const
void
*src, uint64_t n);
72
// Set n bytes of p to c
73
void
memset (
void
*p,
int
c, uint64_t n);
74
75
// Compare n bytes of p1 with p2. Returns whether they're equal
76
bool
memcmp (
void
*p1,
void
*p2, uint64_t n);
77
#endif
libc
string
string.h
Generated by
1.9.8