aboutsummaryrefslogtreecommitdiff
path: root/core/c/libc/string.odin
blob: d39b4ecb2dfd017757c2c455ecfcd70e3f8a5f13 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
package libc

// 7.24 String handling

when ODIN_OS == "windows" {
	foreign import libc "system:libucrt.lib"
} else {
	foreign import libc "system:c"
}

foreign libc {
	// 7.24.2 Copying functions
	memcpy   :: proc(s1, s2: rawptr, n: size_t) -> rawptr ---;
	memmove  :: proc(s1, s2: rawptr, n: size_t) -> rawptr ---;
	strcpy   :: proc(s1: ^char, s2: cstring) -> ^char ---;
	strncpy  :: proc(s1: ^char, s2: cstring, n: size_t) -> ^char ---;

	// 7.24.3 Concatenation functions
	strcat   :: proc(s1: ^char, s2: cstring) -> ^char ---;
	strncat  :: proc(s1: ^char, s2: cstring, n: size_t) -> ^char ---;

	// 7.24.4 Comparison functions
	memcmp   :: proc(s1, s2: rawptr, n: size_t) -> int ---;
	strcmp   :: proc(s1, s2: cstring) -> int ---;
	strcoll  :: proc(s1, s2: cstring) -> int ---;
	strncmp  :: proc(s1, s2: cstring, n: size_t) -> int ---;
	strxfrm  :: proc(s1: ^char, s2: cstring, n: size_t) -> size_t ---;

	// 7.24.5 Search functions
	memchr   :: proc(s: rawptr, c: int, n: size_t) -> rawptr ---;
	strchr   :: proc(s: cstring, c: int) -> ^char ---;
	strcspn  :: proc(s1, s2: cstring) -> size_t ---;
	strpbrk  :: proc(s1, s2: cstring) -> ^char ---;
	strrchr  :: proc(s: ^char, c: int) -> ^char ---;
	strcpn   :: proc(s1, s2: cstring) -> ^char ---;
	strtok   :: proc(s1: ^char, s2: cstring) -> ^char ---;

	// 7.24.6 Miscellaneous functions
	memset   :: proc(s: rawptr, c: int, n: size_t) -> rawptr ---;
	strerror :: proc(errnum: int) -> ^char ---;
	strlen   :: proc(s: cstring) -> size_t ---;
}