From b12606899c98d7fc7a120c2b79797b5c45283ad2 Mon Sep 17 00:00:00 2001 From: zlago Date: Wed, 23 Oct 2024 19:17:26 +0200 Subject: hacky save system --- src/util.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'src/util.c') diff --git a/src/util.c b/src/util.c index 21aeb22..1f7a546 100644 --- a/src/util.c +++ b/src/util.c @@ -65,3 +65,19 @@ char *util_executableRelativePath(char const *const path, char const *const exec memcpy(filePath + dirLength, path, fileLength); return filePath; } + +int util_stringToColor(struct color *color, char const *const str) { + if (str[0] != '#' || strnlen(str, 10) != 9) { + return 1; + } + char *out; + unsigned long colorint = strtoul(str + 1, &out, 16); + if (out != str + 9) { + return 1; + } + color->r = colorint >> 24; + color->g = colorint >> 16; + color->b = colorint >> 8; + color->a = colorint >> 0; + return 0; +} -- cgit 1.4.1-2-gfad0