summaryrefslogtreecommitdiffstats
path: root/lib/string.c
diff options
context:
space:
mode:
authorJon Santmyer <jon@jonsantmyer.com>2026-09-04 11:31:40 -0400
committerJon Santmyer <jon@jonsantmyer.com>2026-09-04 11:31:40 -0400
commit8251da342161767fe203627223ccd4a7026701c6 (patch)
treeaf2db0f11b0ea8ad35f88663a855bab39a80f679 /lib/string.c
downloadjove-kernel-8251da342161767fe203627223ccd4a7026701c6.tar.gz
jove-kernel-8251da342161767fe203627223ccd4a7026701c6.tar.bz2
jove-kernel-8251da342161767fe203627223ccd4a7026701c6.zip
initial commit. working on tasking
Diffstat (limited to 'lib/string.c')
-rw-r--r--lib/string.c50
1 files changed, 50 insertions, 0 deletions
diff --git a/lib/string.c b/lib/string.c
new file mode 100644
index 0000000..28436d5
--- /dev/null
+++ b/lib/string.c
@@ -0,0 +1,50 @@
+#include "string.h"
+
+void *memset(void *s, int c, size_t n)
+{
+ for(size_t i = 0; i < n; i++) {
+ ((char*)s)[i] = c;
+ }
+ return s;
+}
+void *memcpy(void *a, const void *b, size_t n)
+{
+ for(size_t i = 0; i < n; i++) {
+ ((char*)a)[i] = ((const char*)b)[i];
+ }
+ return a;
+}
+
+int memcmp(const void *a, const void *b, size_t n)
+{
+ const char *ca = a;
+ const char *cb = b;
+ for(size_t i = 0; i < n; i++) {
+ if(ca[i] != cb[i]) return ca[i] - cb[i];
+ }
+ return 0;
+}
+
+size_t strlen(const char *s)
+{
+ size_t i = 0;
+ for(; s[i]; i++);
+ return i;
+}
+
+char c_toupper(char c) {
+ return (c > 0x60 && c < 0x7B) ? (c - 0x20) : c;
+}
+
+char *str_toupper(char *s, size_t n)
+{
+ for(size_t i = 0; i < n; i++) {
+ s[i] = c_toupper(s[i]);
+ }
+ return s;
+}
+
+int strncmp(const char *s1, const char *s2, size_t n)
+{
+ return memcmp(s1, s2, n);
+}