aboutsummaryrefslogtreecommitdiff
path: root/src/lib/string.c
diff options
context:
space:
mode:
authorMarvin Borner2019-09-19 18:58:02 +0200
committerMarvin Borner2019-09-19 18:58:02 +0200
commit2a3620453de91e08b668ef21049058239c82d0a4 (patch)
tree8f64cce5d28c7f205dd1db8a9faa915db88a2280 /src/lib/string.c
parent68838789574c9a39b7382c67e8cc984a8c928fe6 (diff)
parentc33bc6864a3291dc72b2da071e52e481573f5459 (diff)
Fixed commands and added some more
Diffstat (limited to 'src/lib/string.c')
-rw-r--r--src/lib/string.c27
1 files changed, 27 insertions, 0 deletions
diff --git a/src/lib/string.c b/src/lib/string.c
new file mode 100644
index 0000000..6ef0316
--- /dev/null
+++ b/src/lib/string.c
@@ -0,0 +1,27 @@
+#include <stddef.h>
+
+size_t strlen(const char *str) {
+ size_t len = 0;
+ while (str[len])
+ len++;
+ return len;
+}
+
+size_t strcmp(const char *s1, const char *s2) {
+ while (*s1 && (*s1 == *s2)) {
+ s1++;
+ s2++;
+ }
+ return *(const unsigned char *) s1 - *(const unsigned char *) s2;
+}
+
+char *strcat(char *dst, const char *src) {
+ unsigned int i = 0;
+ unsigned int j = 0;
+ for (i = 0; dst[i] != 0; i++) {}
+ for (j = 0; src[j] != 0; j++) {
+ dst[i + j] = src[j];
+ }
+ dst[i + j] = 0;
+ return dst;
+}