summaryrefslogtreecommitdiff
path: root/usr/sdk
diff options
context:
space:
mode:
authorIan Moffett <ian@osmora.org>2025-12-21 23:10:02 -0500
committerIan Moffett <ian@osmora.org>2025-12-21 23:10:02 -0500
commit6bc908e3e7cfb13d4277aaa35846f72fd9df337c (patch)
tree233af837c39626439db34f0a84fd2d5faa31d295 /usr/sdk
parent7ab0d9d2e39ec529209d2af4cafa4db117779d6a (diff)
usr: sdk: Add strcmp() to sdk/string.h + sources
Signed-off-by: Ian Moffett <ian@osmora.org>
Diffstat (limited to 'usr/sdk')
-rw-r--r--usr/sdk/common/string/strcmp.c19
-rw-r--r--usr/sdk/inc/sdk/string.h11
2 files changed, 30 insertions, 0 deletions
diff --git a/usr/sdk/common/string/strcmp.c b/usr/sdk/common/string/strcmp.c
new file mode 100644
index 0000000..cb47cfb
--- /dev/null
+++ b/usr/sdk/common/string/strcmp.c
@@ -0,0 +1,19 @@
+/*
+ * Copyright (c) 2025, Ian Moffett.
+ * Provided under the BSD-3 clause.
+ */
+
+#include <sdk/string.h>
+#include <sdk/types.h>
+
+int
+strcmp(const char *s1, const char *s2)
+{
+ while (*s1 == *s2++) {
+ if (*s1++ == 0) {
+ return (0);
+ }
+ }
+
+ return (*(UBYTE *)s1 - *(UBYTE *)--s2);
+}
diff --git a/usr/sdk/inc/sdk/string.h b/usr/sdk/inc/sdk/string.h
index 965f66a..9e648d9 100644
--- a/usr/sdk/inc/sdk/string.h
+++ b/usr/sdk/inc/sdk/string.h
@@ -29,6 +29,17 @@ USIZE strlen(const char *str);
void *memcpy(void *dest, const void *src, USIZE count);
/*
+ * Compare two strings to see if they are equal.
+ *
+ * @s1: First string
+ * @s2: Second string
+ *
+ * Returns the differences between the two string, zero if
+ * equal.
+ */
+int strcmp(const char *s1, const char *s2);
+
+/*
* Convert a given value into a string based on a
* specific radix/base
*