aboutsummaryrefslogtreecommitdiff
path: root/src/kernel/lib
diff options
context:
space:
mode:
Diffstat (limited to 'src/kernel/lib')
-rw-r--r--src/kernel/lib/lib.h4
-rw-r--r--src/kernel/lib/string.c29
2 files changed, 33 insertions, 0 deletions
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