summaryrefslogtreecommitdiff
path: root/src/util.c
diff options
context:
space:
mode:
authorportix <portix@gmx.net>2011-01-07 21:53:30 +0100
committerportix <portix@gmx.net>2011-01-07 21:53:30 +0100
commit84e75be12a35c55486fdf27aa17c46d15d4d75e6 (patch)
tree4b3ffc49c29e7cfc0835ddc7bb9247f61c89af0b /src/util.c
parent99112cb5cf0f4fac0a2aca02de837fb177814f64 (diff)
downloaddwb-84e75be12a35c55486fdf27aa17c46d15d4d75e6.zip
renaming, replace enums by defines
Diffstat (limited to 'src/util.c')
-rw-r--r--src/util.c24
1 files changed, 12 insertions, 12 deletions
diff --git a/src/util.c b/src/util.c
index 082d105d..94b54aea 100644
--- a/src/util.c
+++ b/src/util.c
@@ -124,15 +124,15 @@ Arg *
dwb_util_char_to_arg(char *value, DwbType type) {
errno = 0;
Arg *ret = NULL;
- if (type == Boolean && !value) {
+ if (type == BOOLEAN && !value) {
Arg a = { .b = false };
ret = &a;
}
- else if (value || type == Char) {
+ else if (value || type == CHAR) {
if (value) {
g_strstrip(value);
if (strlen(value) == 0) {
- if (type == Char) {
+ if (type == CHAR) {
Arg a = { .p = NULL };
ret = &a;
return ret;
@@ -140,7 +140,7 @@ dwb_util_char_to_arg(char *value, DwbType type) {
return NULL;
}
}
- if (type == Boolean) {
+ if (type == BOOLEAN) {
if(!g_ascii_strcasecmp(value, "false") || !strcmp(value, "0")) {
Arg a = { .b = false };
ret = &a;
@@ -150,25 +150,25 @@ dwb_util_char_to_arg(char *value, DwbType type) {
ret = &a;
}
}
- else if (type == Integer) {
+ else if (type == INTEGER) {
int n = strtol(value, NULL, 10);
if (n != LONG_MAX && n != LONG_MIN && !errno ) {
Arg a = { .i = n };
ret = &a;
}
}
- else if (type == Double) {
+ else if (type == DOUBLE) {
double d;
if ((d = g_strtod(value, NULL)) ) {
Arg a = { .d = d };
ret = &a;
}
}
- else if (type == Char) {
+ else if (type == CHAR) {
Arg a = { .p = !value || (value && !strcmp(value, "null")) ? NULL : g_strdup(value) };
ret = &a;
}
- else if (type == ColorChar) {
+ else if (type == COLOR_CHAR) {
int length = strlen(value);
if (value[0] == '#' && (length == 4 || length == 7) && dwb_util_is_hex(&value[1])) {
Arg a = { .p = g_strdup(value) };
@@ -182,19 +182,19 @@ dwb_util_char_to_arg(char *value, DwbType type) {
char *
dwb_util_arg_to_char(Arg *arg, DwbType type) {
char *value = NULL;
- if (type == Boolean) {
+ if (type == BOOLEAN) {
if (arg->b)
value = g_strdup("true");
else
value = g_strdup("false");
}
- else if (type == Double) {
+ else if (type == DOUBLE) {
value = g_strdup_printf("%.2f", arg->d);
}
- else if (type == Integer) {
+ else if (type == INTEGER) {
value = g_strdup_printf("%d", arg->i);
}
- else if (type == Char || type == ColorChar) {
+ else if (type == CHAR || type == COLOR_CHAR) {
if (arg->p) {
char *tmp = (char*) arg->p;
value = g_strdup_printf(tmp);