Skip to content
Extraits de code Groupes Projets
Vérifiée Valider 575db829 rédigé par Kubat's avatar Kubat
Parcourir les fichiers

HOOK: The only given argument is the server database

parent 003717f5
Aucune branche associée trouvée
Aucune étiquette associée trouvée
1 requête de fusion!116Hooks
...@@ -46,7 +46,6 @@ void config_default_file(char *dest, size_t len); ...@@ -46,7 +46,6 @@ void config_default_file(char *dest, size_t len);
#define env_get getenv #define env_get getenv
/* Handle everything for a hook */ /* Handle everything for a hook */
void config_handle_hook(volatile sqlite3 *db, const char *hook_name, int arg_count, ...); void config_handle_hook(volatile sqlite3 *db, const char *hook_name);
#define HANDLE_HOOK(db, n, ...) config_handle_hook(db, n, GET_VA_COUNT(__VA_ARGS__), __VA_ARGS__)
#endif /* __LKT_CONFIG_H__ */ #endif /* __LKT_CONFIG_H__ */
...@@ -164,7 +164,7 @@ command_next(struct lkt_state *srv, char __attribute__((unused)) *args[LKT_MESSA ...@@ -164,7 +164,7 @@ command_next(struct lkt_state *srv, char __attribute__((unused)) *args[LKT_MESSA
if (MOD_CALL(srv->window_mod, "load", filepath)) if (MOD_CALL(srv->window_mod, "load", filepath))
return false; return false;
else { else {
config_handle_hook(srv->db, "kara_load", 0); config_handle_hook(srv->db, "kara_load");
return true; return true;
} }
} }
...@@ -188,7 +188,7 @@ command_previous(struct lkt_state *srv, char __attribute__((unused)) *args[LKT_M ...@@ -188,7 +188,7 @@ command_previous(struct lkt_state *srv, char __attribute__((unused)) *args[LKT_M
if (MOD_CALL(srv->window_mod, "load", filepath)) if (MOD_CALL(srv->window_mod, "load", filepath))
return false; return false;
else { else {
config_handle_hook(srv->db, "kara_load", 0); config_handle_hook(srv->db, "kara_load");
return true; return true;
} }
} }
...@@ -223,8 +223,8 @@ command_play(struct lkt_state *srv, char __attribute__((unused)) *args[LKT_MESSA ...@@ -223,8 +223,8 @@ command_play(struct lkt_state *srv, char __attribute__((unused)) *args[LKT_MESSA
/* Hooks */ /* Hooks */
if (__play_that_file(srv, pos)) { if (__play_that_file(srv, pos)) {
config_handle_hook(srv->db, "queue_begin", 0); config_handle_hook(srv->db, "queue_begin");
config_handle_hook(srv->db, "kara_load", 0); config_handle_hook(srv->db, "kara_load");
return true; return true;
} else } else
return false; return false;
...@@ -258,8 +258,8 @@ command_playid(struct lkt_state *srv, char *args[LKT_MESSAGE_ARGS_MAX]) ...@@ -258,8 +258,8 @@ command_playid(struct lkt_state *srv, char *args[LKT_MESSAGE_ARGS_MAX])
/* Hooks */ /* Hooks */
if (__play_that_file(srv, pos)) { if (__play_that_file(srv, pos)) {
config_handle_hook(srv->db, "queue_begin", 0); config_handle_hook(srv->db, "queue_begin");
config_handle_hook(srv->db, "kara_load", 0); config_handle_hook(srv->db, "kara_load");
return true; return true;
} else } else
return false; return false;
......
...@@ -298,7 +298,7 @@ error: ...@@ -298,7 +298,7 @@ error:
} }
void void
config_handle_hook(volatile sqlite3 *db, const char *hook_name, int arg_count, ...) config_handle_hook(volatile sqlite3 *db, const char *hook_name)
{ {
char hook_handlers[LKT_LINE_MAX]; char hook_handlers[LKT_LINE_MAX];
if (!database_config_get_text_nospace(db, "hook", hook_name, hook_handlers, LKT_LINE_MAX)) { if (!database_config_get_text_nospace(db, "hook", hook_name, hook_handlers, LKT_LINE_MAX)) {
...@@ -306,9 +306,6 @@ config_handle_hook(volatile sqlite3 *db, const char *hook_name, int arg_count, . ...@@ -306,9 +306,6 @@ config_handle_hook(volatile sqlite3 *db, const char *hook_name, int arg_count, .
return; return;
} }
va_list va;
va_start(va, arg_count);
size_t save = 0; size_t save = 0;
char name[LKT_LINE_MAX]; char name[LKT_LINE_MAX];
int code; int code;
...@@ -318,11 +315,9 @@ config_handle_hook(volatile sqlite3 *db, const char *hook_name, int arg_count, . ...@@ -318,11 +315,9 @@ config_handle_hook(volatile sqlite3 *db, const char *hook_name, int arg_count, .
while (0 == (code = iter_string(hook_handlers, ",", name, LKT_LINE_MAX, &save))) { while (0 == (code = iter_string(hook_handlers, ",", name, LKT_LINE_MAX, &save))) {
if (STR_MATCH("none", name)) if (STR_MATCH("none", name))
continue; continue;
reg_call(server_reg, name, 1, va); reg_call(server_reg, name, 1, db);
} }
if (code == -1) if (code == -1)
LOG_ERROR("HOOK", "Failed to parse the handle list for hook '%s'", hook_name); LOG_ERROR("HOOK", "Failed to parse the handle list for hook '%s'", hook_name);
va_end(va);
} }
0% Chargement en cours ou .
You are about to add 0 people to the discussion. Proceed with caution.
Veuillez vous inscrire ou vous pour commenter