#include "str.h" i32 strcopy(char *to, const char *from, u32 length) { u32 i; if (to == nil || from == nil) return -1; if (length == 0) {return 0;} for (i = 0; i < length - 1 && from[i] != '\0'; i++) { to[i] = from[i]; } to[i] = '\0'; return 0; } bool streq(const char *s1, const char *s2) { if (s1 == nil && s2 == nil) return true; if (s1 == nil || s2 == nil) return false; while (*s1 && *s2) { if (*s1 != *s2) return false; s1++; s2++; } return (*s1 == '\0' && *s2 == '\0'); } u32 strlen(const char *str) { u32 i; if (str == nil) {return 0;} for (i = 0; str[i] != '\0'; i++) { ; /* twiddle thumbs, 'i' is doing all the work*/ } return i; } u32 strnlen(const char *str, u32 max_len) { u32 i; if (str == nil) {return 0;} for (i = 0; i < max_len && str[i] != '\0'; i++) { ; /* twiddle thumbs, 'i' is doing all the work*/ } return i; }