summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 1abf5e3)
raw | patch | inline | side by side (parent: 1abf5e3)
author | Max Kellermann <max@duempel.org> | |
Mon, 14 Jul 2014 08:51:59 +0000 (10:51 +0200) | ||
committer | Max Kellermann <max@duempel.org> | |
Mon, 14 Jul 2014 08:58:30 +0000 (10:58 +0200) |
src/command.c | patch | blob | history | |
src/command.h | patch | blob | history | |
src/conf.c | patch | blob | history | |
src/main.c | patch | blob | history | |
src/screen_keydef.c | patch | blob | history |
diff --git a/src/command.c b/src/command.c
index 62d68a5e056a65a0db46457ed283c2b0a10adbda..857bf48555477f4dc6c173ed99317c1f85ebce64 100644 (file)
--- a/src/command.c
+++ b/src/command.c
return get_key_command(key);
}
-int
+bool
assign_keys(command_t command, int keys[MAX_COMMAND_KEYS])
{
for (size_t i = 0; cmds[i].name; i++) {
#ifndef NCMPC_MINI
cmds[i].flags |= COMMAND_KEY_MODIFIED;
#endif
- return 0;
+ return true;
}
}
- return -1;
+ return false;
}
#ifndef NCMPC_MINI
-int
+bool
check_key_bindings(command_definition_t *cp, char *buf, size_t bufsize)
{
- int retval = 0;
+ bool success = true;
if (cp == NULL)
cp = cmds;
}
cp[i].flags |= COMMAND_KEY_CONFLICT;
set_key_flags(cp, cmd, COMMAND_KEY_CONFLICT);
- retval = -1;
+ success = false;
}
}
}
- return retval;
+ return success;
}
-int
+bool
write_key_bindings(FILE *f, int flags)
{
if (flags & KEYDEF_WRITE_HEADER)
}
}
- return ferror(f);
+ return ferror(f) == 0;
}
#endif /* NCMPC_MINI */
diff --git a/src/command.h b/src/command.h
index 307bba1d8359097882af779df0847b56c6f68a1a..e770a1d62aa96124f3443197bb9c31f6e1758f67 100644 (file)
--- a/src/command.h
+++ b/src/command.h
#ifndef NCMPC_MINI
-int check_key_bindings(command_definition_t *cmds, char *buf, size_t size);
-int write_key_bindings(FILE *f, int all);
+/**
+ * @return true on success, false on error
+ */
+bool
+check_key_bindings(command_definition_t *cmds, char *buf, size_t size);
+
+/**
+ * @return true on success, false on error
+ */
+bool
+write_key_bindings(FILE *f, int all);
#endif
command_t
get_key_command_from_name(const char *name);
-int assign_keys(command_t command, int keys[MAX_COMMAND_KEYS]);
+/**
+ * @return true on success, false on error
+ */
+bool
+assign_keys(command_t command, int keys[MAX_COMMAND_KEYS]);
gcc_pure
command_t get_keyboard_command(void);
diff --git a/src/conf.c b/src/conf.c
index 5d8ec5e8bcbd9937ee64067948c08be6de20c65c..03ba80dd7407baa7ef78bc898e57afd785974b89 100644 (file)
--- a/src/conf.c
+++ b/src/conf.c
}
}
-static int
+static bool
parse_key_definition(char *str)
{
/* get the command name */
/* the hotkey configuration contains an unknown
command */
print_error(_("Unknown command"), buf);
- return -1;
+ return false;
}
/* skip whitespace */
if (*buf == 0) {
/* the hotkey configuration line is incomplete */
print_error(_("Incomplete hotkey configuration"), str);
- return -1;
+ return false;
}
/* parse key values */
}
if (key < 0)
- return -1;
+ return false;
return assign_keys(cmd, keys);
}
diff --git a/src/main.c b/src/main.c
index 4c0f881e9d8311b564fa1b2e3782a5f6bb085b6e..341fb1733e121988f89d8bc1b5a8893c0da21f5b 100644 (file)
--- a/src/main.c
+++ b/src/main.c
#ifdef ENABLE_KEYDEF_SCREEN
char comment[64];
#endif
- gboolean key_error;
- key_error = check_key_bindings(NULL, buf, sizeof(buf));
- if (!key_error) {
+ if (check_key_bindings(NULL, buf, sizeof(buf))) {
/* no error: disable this timer for the rest of this
process */
check_key_bindings_source_id = 0;
diff --git a/src/screen_keydef.c b/src/screen_keydef.c
index dde5ce571321e56f8aebd75500a264424775799e..164cf6565822adc0d2f8f74df3b6748b76e435cd 100644 (file)
--- a/src/screen_keydef.c
+++ b/src/screen_keydef.c
}
if (write_key_bindings(f, KEYDEF_WRITE_HEADER))
- screen_status_printf(_("Error: %s - %s"), filename, strerror(errno));
- else
screen_status_printf(_("Wrote %s"), filename);
+ else
+ screen_status_printf(_("Error: %s - %s"), filename, strerror(errno));
g_free(filename);
return fclose(f);