corn/include/lib.h

171 lines
5.2 KiB
C
Raw Normal View History

2024-01-27 08:01:34 +00:00
#pragma once
2024-01-30 02:10:29 +00:00
#include <stddef.h>
2024-01-27 08:01:34 +00:00
/**
* The memcmp() function compares the first n bytes (each interpreted as unsigned char) of the memory
* areas s1 and s2.
*/
2024-01-30 02:10:29 +00:00
int memcmp(const void *restrict s1, const void *restrict s2, unsigned long n);
2024-01-27 08:01:34 +00:00
/**
* The memcpy() function copies n bytes from memory area src to memory area dest.
* The memory areas must not overlap.
*/
2024-01-30 02:10:29 +00:00
void *memcpy(void *restrict dest, const void *restrict src, unsigned long n);
2024-01-27 08:01:34 +00:00
/**
* The memmove() function copies n bytes from memory area src to memory area dest. The memory areas
* may overlap: copying takes place as though the bytes in src are first copied into a temporary array
* that does not overlap src or dest, and the bytes are then copied from the temporary array to dest.
*/
2024-01-30 02:10:29 +00:00
void *memmove(void *dest, const void *src, unsigned long n);
2024-01-27 08:01:34 +00:00
/**
* The memset() function fills the first n bytes of the memory area pointed to by s with the constant
* byte c.
*/
2024-01-30 02:10:29 +00:00
void *memset(void *restrict dest, int c, unsigned long n);
2024-01-27 07:14:19 +00:00
/**
* The strcmp() function compares the two strings s1 and s2. The locale is not taken into account
* (for a locale-aware comparison, see strcoll(3)). The comparison is done using unsigned characters.
*/
2024-01-30 02:10:29 +00:00
int strncmp(const char *restrict s1, const char *restrict s2, unsigned long n);
2024-01-27 07:14:19 +00:00
2024-01-27 08:38:27 +00:00
/**
* Copys the string pointed to by src , into a string at the buffer pointer to by dest.
* The dest buffer must be long enough to hold src.
*/
2024-01-30 02:10:29 +00:00
char *strcpy(char *restrict dest, const char *restrict src);
2024-01-27 08:38:27 +00:00
/**
* Copys the string pointed to by src , into a string at the buffer pointer to by dest.
* The dest buffer must be long enough to hold src or size n.
*/
2024-01-30 02:10:29 +00:00
char *strncpy(char *restrict dest, const char *restrict src, unsigned long n);
/**
* Calculates the length of the string pointed to by str, excluding
* the terminating null byte
* @param str - the string pointer
* @returns the length of the string in bytes
*/
size_t strlen(const char *str);
/**
* Concatenate the string pointed to by src after the string pointed
* to by dst.
* @param dst - the pointer to the destination string
* @param src - the pointer to the source string
* @returns dst
*/
char *strcat(char *restrict dst, const char *restrict src);
2024-01-27 08:38:27 +00:00
2024-01-27 07:14:19 +00:00
/**
2024-01-27 08:01:34 +00:00
* @returns 1 if c is a space
*/
2024-01-30 02:10:29 +00:00
int isspace(int c);
2024-01-27 08:01:34 +00:00
/**
* @returns 1 if c is a digit (0 - 9)
2024-01-27 07:14:19 +00:00
*/
2024-01-30 02:10:29 +00:00
int isdigit(int c);
2024-01-27 08:01:34 +00:00
2024-01-27 08:17:02 +00:00
/**
* converts single digit int to base 36
* @param i - int
* @returns c - base 36 char
*/
2024-01-30 02:10:29 +00:00
char itoc(int i);
2024-01-27 08:17:02 +00:00
/**
* converts single base 36 chat into int
* @param c - base 36 char
* @returns i - int
*/
2024-01-30 02:10:29 +00:00
int ctoi(char c);
2024-01-27 08:17:02 +00:00
/**
* Converts the initial portiion of the string pointed to by s to int.
* @param s - the string to convert
* @returns the number inside s or 0 on error
*/
2024-01-30 02:10:29 +00:00
int atoi(const char* s);
2024-01-27 08:01:34 +00:00
2024-01-27 08:17:02 +00:00
/**
* Converts the initial portiion of the string pointed to by s to long.
* @param s - the string to convert
* @returns the number inside s or 0 on error
*/
2024-01-30 02:10:29 +00:00
long int atol(const char* s);
2024-01-27 08:01:34 +00:00
2024-01-27 08:17:02 +00:00
/**
* Converts the initial portiion of the string pointed to by s to long long.
* @param s - the string to convert
* @returns the number inside s or 0 on error
*/
2024-01-30 02:10:29 +00:00
long long int atoll(const char* s);
2024-01-27 08:01:34 +00:00
2024-01-27 08:17:02 +00:00
/**
* Converts a integer to asci inside a string with a given radix (base).
* @param n - the number to conver
* @param buffer - the string buffer
* @param radix - the base to convert
*/
2024-01-30 02:10:29 +00:00
char *itoa(int n, char *buffer, int radix);
2024-01-27 08:01:34 +00:00
2024-01-27 08:17:02 +00:00
/**
* Converts a long to asci inside a string with a given radix (base).
* @param n - the number to conver
* @param buffer - the string buffer
* @param radix - the base to convert
*/
2024-01-30 02:10:29 +00:00
char *ltoa(long int n, char *buffer, int radix);
2024-01-27 08:17:02 +00:00
/**
* Converts a unsigned integer to asci inside a string with a given radix (base).
* @param n - the number to conver
* @param buffer - the string buffer
* @param radix - the base to convert
*/
2024-01-30 02:10:29 +00:00
char *utoa(unsigned int n, char *buffer, int radix);
2024-01-27 08:17:02 +00:00
/**
* Converts a unsigned long to asci inside a string with a given radix (base).
* @param n - the number to conver
* @param buffer - the string buffer
* @param radix - the base to convert
*/
2024-01-30 02:10:29 +00:00
char *ultoa(unsigned long int n, char *buffer, int radix);
2024-01-27 08:17:02 +00:00
/**
* Converts the string in str to an int value based on the given base.
* The endptr is updated to where the string was no longer valid.
* @param str - the string buffer
* @param endptr - the endptr
* @param base - the base to convert to
* @returns 0 on error or success, error if endptr is still equal to str
*/
2024-01-30 02:10:29 +00:00
int strtoi(const char *str, char **endptr, int base);
2024-01-27 08:17:02 +00:00
/**
* Converts the string in str to an long value based on the given base.
* The endptr is updated to where the string was no longer valid.
* @param str - the string buffer
* @param endptr - the endptr
* @param base - the base to convert to
* @returns 0 on error or success, error if endptr is still equal to str
*/
2024-01-30 02:10:29 +00:00
long int strtol(const char *str, char **endptr, int base);
2024-01-27 08:17:02 +00:00
/**
* Converts the string in str to an long long value based on the given base.
* The endptr is updated to where the string was no longer valid.
* @param str - the string buffer
* @param endptr - the endptr
* @param base - the base to convert to
* @returns 0 on error or success, error if endptr is still equal to str
*/
2024-01-30 02:10:29 +00:00
long long int strtoll(const char *str, char **endptr, int base);