ciabatta/inc/string.h

92 lines
3.1 KiB
C
Raw Permalink Normal View History

2022-06-11 04:49:07 +00:00
#pragma once
#if !defined(NULL)
2022-06-24 01:45:55 +00:00
#define NULL ((void *)0)
2022-06-11 04:49:07 +00:00
#endif
2022-08-04 09:47:38 +00:00
#if defined(_WIN32)
typedef unsigned long long size_t;
#else
typedef unsigned long size_t;
#endif
2022-06-11 04:49:07 +00:00
#if !defined(__STDC_LIB_EXT1__)
2022-06-24 01:45:55 +00:00
#define __STDC_LIB_EXT1__
typedef int errno_t;
typedef size_t rsize_t;
2022-06-11 04:49:07 +00:00
#endif
#if __STDC_WANT_SECURE_LIB__ == 1
2022-06-24 01:45:55 +00:00
#if !defined(__STDC_WANT_LIB_EXT1__)
#define __STDC_WANT_LIB_EXT1__ 1
#endif
2022-06-11 04:49:07 +00:00
#endif
2022-06-24 01:45:55 +00:00
#if !defined(__STDC_ALLOC_LIB__)
#define __STDC_ALLOC_LIB__
2022-06-11 04:49:07 +00:00
#endif
2022-06-27 03:10:39 +00:00
size_t strlen(const char *s);
char *strerror(int errnum);
// Copying
void *memset (void *s, int c, size_t n);
void *memmove (void *s1, const void *s2, size_t n);
void *memcpy (void *restrict s1, const void *restrict s2, size_t n);
char *strncpy (char *restrict s1, const char *restrict s2, size_t n);
char *strcpy (char *restrict s1, const char *restrict s2);
// Concat
char *strncat (char *restrict s1, const char *restrict s2, size_t n);
char *strcat (char *restrict s1, const char *restrict s2);
// Comparison
int memcmp (const void *s1, const void *s2, size_t n);
int strncmp (const char *s1, const char *s2, size_t n);
int strcmp (const char *s1, const char *s2);
// Collation/Localisation thingy
int strcoll (const char *s1, const char *s2);
size_t strxfrm (char *restrict s1, const char *restrict s2, size_t n);
// Tokenization and related stuff
void *memchr (const void *str, int c, size_t n);
char *strchr (const char *str, int c);
size_t strcspn(const char *str, const char *s);
char *strpbrk(const char *str, const char *s);
char *strrchr(const char *str, int c);
size_t strspn (const char *str, const char *s);
char *strstr (const char *str, const char *s);
char *strtok (char *restrict str, const char *restrict s);
2022-06-11 04:49:07 +00:00
// Linux extension: reentrant strtok
2022-06-27 03:10:39 +00:00
char *strtok_r(char *restrict s1, const char *restrict s2, char **restrict ctx);
2022-06-11 04:49:07 +00:00
2022-06-24 01:45:55 +00:00
// Extension 1
2022-06-11 04:49:07 +00:00
#if __STDC_WANT_LIB_EXT1__ == 1
2022-06-24 01:45:55 +00:00
2022-07-28 18:02:12 +00:00
size_t strnlen_s(const char *str, size_t strsz);
2022-06-27 03:10:39 +00:00
// Safe memory copies
errno_t memset_s (void *s, rsize_t smax, int c, rsize_t n);
errno_t memmove_s(void *s1, rsize_t s1max, const void *s2, rsize_t n);
errno_t memcpy_s (void *restrict s1, rsize_t s1max, const void *restrict s2, rsize_t n);
errno_t strncpy_s(char *restrict s1, rsize_t s1max, const char *restrict s2, rsize_t n);
errno_t strcpy_s (char *restrict s1, rsize_t s1max, const char *restrict s2);
// Safe concat et strtok
errno_t strcat_s (char *restrict s1, rsize_t s1max, const char *restrict s2);
errno_t strncat_s(char *restrict s1, rsize_t s1max, const char *restrict s2, rsize_t n);
char *strtok_s(char *restrict s1, rsize_t *restrict s1max, const char *restrict s2, char **restrict ptr);
2022-06-24 01:45:55 +00:00
2022-06-27 03:10:39 +00:00
// Safe error strings
errno_t strerror_s(char *s, rsize_t maxsize, errno_t errnum);
size_t strerrorlen_s(errno_t errnum);
2022-06-24 01:45:55 +00:00
#endif
// Extension 2
#if __STDC_WANT_LIB_EXT2__ == 1
2022-06-27 03:10:39 +00:00
char *strdup(const char *str1);
2022-06-11 04:49:07 +00:00
#endif