summaryrefslogtreecommitdiff
path: root/src/util.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/util.c')
-rw-r--r--src/util.c13
1 files changed, 13 insertions, 0 deletions
diff --git a/src/util.c b/src/util.c
index 9543875..7882642 100644
--- a/src/util.c
+++ b/src/util.c
@@ -276,6 +276,19 @@ char *util_str_trim(char *s)
return s;
}
+int util_hex_color_valid(const char *s)
+{
+ if (!s || s[0] != '#' || strlen(s) != 7)
+ return 0;
+ for (int i = 1; i < 7; i++) {
+ char c = s[i];
+ if (!((c >= '0' && c <= '9') || (c >= 'a' && c <= 'f') ||
+ (c >= 'A' && c <= 'F')))
+ return 0;
+ }
+ return 1;
+}
+
static int is_leap(int y)
{
return (y % 4 == 0 && y % 100 != 0) || y % 400 == 0;