From 8ebf584bbb43584b671b79d5166e00268a7c9661 Mon Sep 17 00:00:00 2001 From: Marvin Borner Date: Wed, 25 Sep 2019 22:57:33 +0200 Subject: Fixed several TTY bugs and improved VESA detection --- src/kernel/lib/lib.h | 4 ++++ src/kernel/lib/string.c | 29 +++++++++++++++++++++++++++++ 2 files changed, 33 insertions(+) (limited to 'src/kernel/lib') diff --git a/src/kernel/lib/lib.h b/src/kernel/lib/lib.h index f0d7d1b..f83c7d5 100644 --- a/src/kernel/lib/lib.h +++ b/src/kernel/lib/lib.h @@ -9,10 +9,14 @@ size_t strcmp(const char *s1, const char *s2); char *strcat(char *dst, const char *src); +char *strcpy(char *dst, const char *src); + void *memory_copy(void *dest, const void *src, size_t count); void *memory_set(void *dest, char val, size_t count); int memory_compare(const void *a_ptr, const void *b_ptr, size_t size); +char *itoa(int i, char b[]); + #endif diff --git a/src/kernel/lib/string.c b/src/kernel/lib/string.c index 6ef0316..2b8cdfb 100644 --- a/src/kernel/lib/string.c +++ b/src/kernel/lib/string.c @@ -25,3 +25,32 @@ char *strcat(char *dst, const char *src) { dst[i + j] = 0; return dst; } + +char *strcpy(char *dst, const char *src) { + unsigned int i = 0; + for (i = 0; src[i] != 0; i++) { + dst[i] = src[i]; + } + dst[i] = 0; + return dst; +} + +char *itoa(int i, char b[]) { + char const digit[] = "0123456789"; + char *p = b; + if (i < 0) { + *p++ = '-'; + i *= -1; + } + int shifter = i; + do { + ++p; + shifter = shifter / 10; + } while (shifter); + *p = '\0'; + do { + *--p = digit[i % 10]; + i = i / 10; + } while (i); + return b; +} \ No newline at end of file -- cgit v1.2.3