/** * @brief Utility functions. * * Kind of a barebones libc. * * @copyright * This file is part of ToaruOS and is released under the terms * of the NCSA / University of Illinois License - see LICENSE.md * Copyright (C) 2018-2021 K. Lange */ #include "util.h" int strcmp(const char * l, const char * r) { for (; *l == *r && *l; l++, r++); return *(unsigned char *)l - *(unsigned char *)r; } char * strchr(const char * s, int c) { while (*s) { if (*s == c) { return (char *)s; } s++; } return 0; } unsigned long strlen(const char *s) { unsigned long out = 0; while (*s) { out++; s++; } return out; } char * strcat(char *dest, const char *src) { char * end = dest; while (*end != '\0') { ++end; } while (*src) { *end = *src; end++; src++; } *end = '\0'; return dest; }