summary refs log tree commit diff
path: root/src/util.c
diff options
context:
space:
mode:
authorzlago2024-10-23 19:17:26 +0200
committerzlago2024-10-23 19:17:26 +0200
commitb12606899c98d7fc7a120c2b79797b5c45283ad2 (patch)
treef210a037fee0f2346bae8a10d1edc1b445b4324f /src/util.c
parentaf6acead62498bc49065ef828e388bcd511ce54d (diff)
hacky save system
Diffstat (limited to 'src/util.c')
-rw-r--r--src/util.c16
1 files changed, 16 insertions, 0 deletions
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;
+}