diff options
author | Christian Cunningham <cc@localhost> | 2021-12-19 21:21:36 -0800 |
---|---|---|
committer | Christian Cunningham <cc@localhost> | 2021-12-19 21:21:36 -0800 |
commit | 234616cc369e056db7987c8217cbee77443be97d (patch) | |
tree | 270f0dbe668e6dad0eec4626a022b4d218b247ae /src | |
parent | 0924065511087d9ef3cf84183029ce8e834ff84a (diff) |
Added strings
Diffstat (limited to 'src')
-rw-r--r-- | src/lib/strings.c | 20 | ||||
-rw-r--r-- | src/lib/strings.h | 7 | ||||
-rw-r--r-- | src/sys/core.c | 1 |
3 files changed, 28 insertions, 0 deletions
diff --git a/src/lib/strings.c b/src/lib/strings.c new file mode 100644 index 0000000..8f62391 --- /dev/null +++ b/src/lib/strings.c @@ -0,0 +1,20 @@ +#include "../lib/strings.h" + +unsigned long strlen(char* s) { + unsigned long len = 0; + while (s[len] != 0) { + len += 1; + } + return len; +} + +unsigned char strcmp(char* a, char* b) { + unsigned long idx = 0; + while (a[idx] != 0 && b[idx] != 0) { + if (a[idx] != b[idx]) { + return 0; + } + idx += 1; + } + return a[idx] == b[idx]; +} diff --git a/src/lib/strings.h b/src/lib/strings.h new file mode 100644 index 0000000..61dd316 --- /dev/null +++ b/src/lib/strings.h @@ -0,0 +1,7 @@ +#ifndef LIB_STRINGS_H +#define LIB_STRINGS_H + +unsigned long strlen(char* s); +unsigned char strcmp(char* a, char* b); + +#endif diff --git a/src/sys/core.c b/src/sys/core.c index 3bb9651..f4b0581 100644 --- a/src/sys/core.c +++ b/src/sys/core.c @@ -1,6 +1,7 @@ #include "../drivers/uart.a.h" #include "../drivers/uart.h" #include "../graphics/draw.h" +#include "../lib/strings.h" #include "../util/time.h" #include "../util/mutex.h" #include "../sys/core.h" |