summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 92cb9c4)
raw | patch | inline | side by side (parent: 92cb9c4)
author | Max Kellermann <max.kellermann@gmail.com> | |
Tue, 21 Mar 2017 20:42:27 +0000 (21:42 +0100) | ||
committer | Max Kellermann <max.kellermann@gmail.com> | |
Tue, 21 Mar 2017 20:47:17 +0000 (21:47 +0100) |
src/colors.c | patch | blob | history | |
src/colors.h | patch | blob | history | |
src/conf.c | patch | blob | history |
diff --git a/src/colors.c b/src/colors.c
index 1cf4c973cfc63c933b221b4384041764eb51beac..3b100bc22f3c06ea30614b69a48d0710a133f44d 100644 (file)
--- a/src/colors.c
+++ b/src/colors.c
/* This function is called from conf.c before curses have been started,
* it adds the definition to the color_definition_list and init_color() is
* done in colors_start() */
-int
+bool
colors_define(const char *name, short r, short g, short b)
{
int color = colors_str2color(name);
if (color < 0)
- return color;
+ return false;
color_definition_entry_t *entry =
g_malloc(sizeof(color_definition_entry_t));
color_definition_list = g_list_append(color_definition_list, entry);
- return 0;
+ return true;
}
-int
+bool
colors_assign(const char *name, const char *value)
{
color_entry_t *entry = colors_lookup_by_name(name);
if (!entry) {
fprintf(stderr, "%s: %s",
_("Unknown color field"), name);
- return -1;
+ return false;
}
const int color = colors_str2color(value);
if (color == COLOR_ERROR)
- return -1;
+ return false;
entry->color = color;
- return 0;
+ return true;
}
void
diff --git a/src/colors.h b/src/colors.h
index c166c363be4378e7c774eff76cc099a1b50a78a0..deb910561cfa24a7cf203393f20bf4fdb5c1510a 100644 (file)
--- a/src/colors.h
+++ b/src/colors.h
#include "ncmpc_curses.h"
#include "Compiler.h"
+#include <stdbool.h>
+
enum color {
COLOR_TITLE = 1,
COLOR_TITLE_BOLD,
int colors_str2color(const char *str);
#ifdef ENABLE_COLORS
-int colors_assign(const char *name, const char *value);
-int colors_define(const char *name, short r, short g, short b);
+bool
+colors_assign(const char *name, const char *value);
+
+bool
+colors_define(const char *name, short r, short g, short b);
void
colors_start(void);
diff --git a/src/conf.c b/src/conf.c
index 814a13b774486e2e204ee1d8bc61aba2ea12f8c6..496dcab6dc974cc429247fd0ee9fb54a1e9a92a2 100644 (file)
--- a/src/conf.c
+++ b/src/conf.c
return g_strchug(value);
}
-static int
+static bool
parse_color(char *str)
{
char *value = separate_value(str);
if (value == NULL)
- return -1;
+ return false;
return colors_assign(str, value);
}
return comma;
}
-static int
+static bool
parse_color_definition(char *str)
{
char *value = separate_value(str);
if (value == NULL)
- return -1;
+ return false;
/* get the command name */
short color = colors_str2color(str);
if (color < 0) {
char buf[MAX_LINE_LENGTH];
print_error(_("Bad color name"), buf);
- return -1;
+ return false;
}
/* parse r,g,b values */
char *next = after_comma(value), *endptr;
if (*value == 0) {
print_error(_("Incomplete color definition"), str);
- return -1;
+ return false;
}
rgb[i] = strtol(value, &endptr, 0);
if (endptr == value || *endptr != 0) {
print_error(_("Invalid number"), value);
- return -1;
+ return false;
}
value = next;
if (*value != 0) {
print_error(_("Malformed color definition"), str);
- return -1;
+ return false;
}
return colors_define(str, rgb[0], rgb[1], rgb[2]);