From 8a19547957a86bed3f58c9abc1ac218d04698faf Mon Sep 17 00:00:00 2001 From: Freya Murphy Date: Tue, 8 Apr 2025 10:39:48 -0400 Subject: break apart c libaray --- kernel/lib/ctoi.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 kernel/lib/ctoi.c (limited to 'kernel/lib/ctoi.c') diff --git a/kernel/lib/ctoi.c b/kernel/lib/ctoi.c new file mode 100644 index 0000000..09a9f10 --- /dev/null +++ b/kernel/lib/ctoi.c @@ -0,0 +1,14 @@ +#include + +int ctoi(char c) +{ + if (c >= '0' && c <= '9') { + return c - '0'; + } else if (c >= 'A' && c <= 'Z') { + return c - 'A' + 10; + } else if (c >= 'a' && c <= 'z') { + return c - 'a' + 10; + } else { + return -1; + } +} -- cgit v1.2.3-freya