diff options
Diffstat (limited to 'include')
-rw-r--r-- | include/lib.h | 109 |
1 files changed, 94 insertions, 15 deletions
diff --git a/include/lib.h b/include/lib.h index 0651770..b368636 100644 --- a/include/lib.h +++ b/include/lib.h @@ -34,27 +34,106 @@ extern int strncmp(const char *restrict s1, const char *restrict s2, unsigned lo /** * @returns 1 if c is a space */ -int isspace(int c); +extern int isspace(int c); /** * @returns 1 if c is a digit (0 - 9) */ -int isdigit(int c); +extern int isdigit(int c); +/** + * converts single digit int to base 36 + * @param i - int + * @returns c - base 36 char + */ +extern char itoc(int i); + +/** + * converts single base 36 chat into int + * @param c - base 36 char + * @returns i - int + */ +extern int ctoi(char c); + +/** + * 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 + */ +extern int atoi(const char* s); -char itoc(int i); -int ctoi(char c); +/** + * 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 + */ +extern long int atol(const char* s); -int atoi(const char* s); -long int atol(const char* s); -long long int atoll(const char* s); +/** + * 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 + */ +extern long long int atoll(const char* s); -char *itoa(int n, char *buffer, int radix); -char *ltoa(long int n, char *buffer, int radix); -char *utoa(unsigned int n, char *buffer, int radix); -char *ultoa(unsigned long int n, char *buffer, int radix); -char *ftoa(float f, char *buffer); +/** + * 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 + */ +extern char *itoa(int n, char *buffer, int radix); -int strtoi(const char *str, char **endptr, int base); -long int strtol(const char *str, char **endptr, int base); -long long int strtoll(const char *str, char **endptr, int base); +/** + * 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 + */ +extern char *ltoa(long int n, char *buffer, int radix); + +/** + * 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 + */ +extern char *utoa(unsigned int n, char *buffer, int radix); + +/** + * 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 + */ +extern char *ultoa(unsigned long int n, char *buffer, int radix); + +/** + * 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 + */ +extern int strtoi(const char *str, char **endptr, int base); + +/** + * 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 + */ +extern long int strtol(const char *str, char **endptr, int base); + +/** + * 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 + */ +extern long long int strtoll(const char *str, char **endptr, int base); |