void read_custom_theme(const char *path) { puts("hello"); puts(path); FILE *f = fopen(path, "r"); if (!f) { perror("whad de fug DDD-xx"); return; } char buf[1024]; // 1024 ought to be enough for anyone while (!feof(f)) { fgets(buf, 1024, f); char *line = buf; while (*line != 0) { if (*line == '#') { *line = 0; break; } line++; } char *colour = strpbrk(buf, "="); if (!colour || colour == buf) continue; *colour++ = 0; uint32_t *colourp = find_colour_pointer(buf); if (!colourp) continue; int err = 0; uint32_t col = try_parse_hex_colour(colour, &err); if (err) { puts("error"); continue; } else { *colourp = COLOR_PROC(col); puts("set colour..."); } } return; }
static void read_custom_theme(const uint8_t *data, size_t length) { while (length) { char *line = (char *)data; while (*line != 0) { if (*line == '#') { *line = 0; break; } ++line; --length; } char *color = strpbrk(line, "="); if (!color || color == line) { continue; } *color++ = 0; uint32_t *colorp = find_colour_pointer(line); if (!colorp) { continue; } bool err = false; const uint32_t col = try_parse_hex_colour(color, &err); if (err) { LOG_ERR("Theme", "Error: Parsing hex color failed."); continue; } else { *colorp = COLOR_PROC(col); } } }