From f440095cd8923d0d644b60b9819b6f09d329f646 Mon Sep 17 00:00:00 2001
From: Kubat <mael.martin31@gmail.com>
Date: Fri, 10 Apr 2020 11:41:47 +0200
Subject: [PATCH] Grouping defines for a global use

---
 inc/lektor/bufferfd.h          |  3 +-
 inc/lektor/cmd.h               |  1 +
 inc/lektor/commands.h          | 45 +++++++++++++++---------------
 inc/lektor/config.h            |  1 +
 inc/lektor/database.h          | 11 +-------
 inc/lektor/defines.h           | 48 ++++++++++++++++++++++++++++++++
 inc/lektor/macro.h             |  3 --
 inc/lektor/mkv.h               |  2 +-
 inc/lektor/module/module_x11.h |  3 +-
 inc/lektor/net.h               | 28 ++-----------------
 inc/lektor/repo.h              |  3 +-
 inc/lektor/thread.h            |  1 +
 inc/lektor/uri.h               |  1 +
 inc/lektor/utils.h             |  1 +
 inc/lektor/window.h            |  3 +-
 src/commands.c                 | 50 +++++++++++++++++-----------------
 src/module/module_x11.c        |  4 +--
 src/net/listen.c               |  6 ++--
 18 files changed, 117 insertions(+), 97 deletions(-)
 create mode 100644 inc/lektor/defines.h

diff --git a/inc/lektor/bufferfd.h b/inc/lektor/bufferfd.h
index c46eb051..52649e15 100644
--- a/inc/lektor/bufferfd.h
+++ b/inc/lektor/bufferfd.h
@@ -23,11 +23,10 @@
 
 #pragma once
 
+#include <lektor/defines.h>
 #include <stdint.h>
 #include <stdlib.h>
 
-#define BUFFER_MAX  4096
-
 struct bufferfd {
     int fd;
     uint8_t buffer[BUFFER_MAX];
diff --git a/inc/lektor/cmd.h b/inc/lektor/cmd.h
index 5263469b..194881ed 100644
--- a/inc/lektor/cmd.h
+++ b/inc/lektor/cmd.h
@@ -1,5 +1,6 @@
 #pragma once
 
+#include <lektor/defines.h>
 #include <stdnoreturn.h>
 #include <stddef.h>
 
diff --git a/inc/lektor/commands.h b/inc/lektor/commands.h
index a923d806..424e6524 100644
--- a/inc/lektor/commands.h
+++ b/inc/lektor/commands.h
@@ -1,5 +1,6 @@
 #pragma once
 
+#include <lektor/defines.h>
 #include <lektor/net.h>
 #include <lektor/window.h>
 
@@ -17,42 +18,42 @@ bool command_currentsong(struct lkt_state *srv, size_t c);
 bool command_status(struct lkt_state *srv, size_t c);
 
 /* Controlling playback */
-bool command_next(sqlite3 *db, struct lkt_win *win, long long int *watch_mask_ptr);
-bool command_pause(sqlite3 *db, struct lkt_win *win, long long int *watch_mask_ptr);
-bool command_previous(sqlite3 *db, struct lkt_win *win, long long int *watch_mask_ptr);
+bool command_next(sqlite3 *db, struct lkt_win *win, enum mpd_idle_flag *watch_mask_ptr);
+bool command_pause(sqlite3 *db, struct lkt_win *win, enum mpd_idle_flag *watch_mask_ptr);
+bool command_previous(sqlite3 *db, struct lkt_win *win, enum mpd_idle_flag *watch_mask_ptr);
 bool command_play(sqlite3 *db, struct lkt_win *win, char *args[LKT_MESSAGE_ARGS_MAX],
-                  long long int *watch_mask_ptr);
-bool command_stop(sqlite3 *db, struct lkt_win *win, long long int *watch_mask_ptr);
+                  enum mpd_idle_flag *watch_mask_ptr);
+bool command_stop(sqlite3 *db, struct lkt_win *win, enum mpd_idle_flag *watch_mask_ptr);
 
-bool command_set_pos(sqlite3 *db, struct lkt_win *win, long long int *watch_mask_ptr, int index);
+bool command_set_pos(sqlite3 *db, struct lkt_win *win, enum mpd_idle_flag *watch_mask_ptr, int index);
 
 /* The queue */
 bool command_add(sqlite3 *db, struct lkt_win *win, char *args[LKT_MESSAGE_ARGS_MAX],
-                 long long int *watch_mask_ptr);
+                 enum mpd_idle_flag *watch_mask_ptr);
 bool command_addid(sqlite3 *db, struct lkt_win *win, char *args[LKT_MESSAGE_ARGS_MAX],
-                   long long int *watch_mask_ptr);
-bool command_del(sqlite3 *db, struct lkt_win *win, char *pos_range, long long int *watch_mask_ptr);
-bool command_delid(sqlite3 *db, struct lkt_win *win, char *id, long long int *watch_mask_ptr);
-bool command_clear(sqlite3 *db, long long int *watch_mask_ptr);
-bool command_crop(sqlite3 *db, long long int *watch_mask_ptr);
-bool command_move(sqlite3 *db, char *args[LKT_MESSAGE_ARGS_MAX], long long int *watch_mask_ptr);
-bool command_shuffle(sqlite3 *db, long long int *watch_mask_ptr);
+                   enum mpd_idle_flag *watch_mask_ptr);
+bool command_del(sqlite3 *db, struct lkt_win *win, char *pos_range, enum mpd_idle_flag *watch_mask_ptr);
+bool command_delid(sqlite3 *db, struct lkt_win *win, char *id, enum mpd_idle_flag *watch_mask_ptr);
+bool command_clear(sqlite3 *db, enum mpd_idle_flag *watch_mask_ptr);
+bool command_crop(sqlite3 *db, enum mpd_idle_flag *watch_mask_ptr);
+bool command_move(sqlite3 *db, char *args[LKT_MESSAGE_ARGS_MAX], enum mpd_idle_flag *watch_mask_ptr);
+bool command_shuffle(sqlite3 *db, enum mpd_idle_flag *watch_mask_ptr);
 bool command_queue_list(struct lkt_state *srv, size_t c, char *args[LKT_MESSAGE_ARGS_MAX]);
 
 /* The playlists */
-bool command_plt_create(sqlite3 *db, char *args[LKT_MESSAGE_ARGS_MAX], long long int *watch_mask_ptr);
-bool command_plt_remove(sqlite3 *db, char *args[LKT_MESSAGE_ARGS_MAX], long long int *watch_mask_ptr);
-bool command_plt_clear(sqlite3 *db, char *args[LKT_MESSAGE_ARGS_MAX], long long int *watch_mask_ptr);
-bool command_plt_rename(sqlite3 *db, char *args[LKT_MESSAGE_ARGS_MAX], long long int *watch_mask_ptr);
-bool command_plt_export(sqlite3 *db, char *args[LKT_MESSAGE_ARGS_MAX], long long int *watch_mask_ptr);
-bool command_plt_import(sqlite3 *db, char *args[LKT_MESSAGE_ARGS_MAX], long long int *watch_mask_ptr);
-bool command_plt_add(sqlite3 *db, char *args[LKT_MESSAGE_ARGS_MAX], long long int *watch_mask_ptr);
+bool command_plt_create(sqlite3 *db, char *args[LKT_MESSAGE_ARGS_MAX], enum mpd_idle_flag *watch_mask_ptr);
+bool command_plt_remove(sqlite3 *db, char *args[LKT_MESSAGE_ARGS_MAX], enum mpd_idle_flag *watch_mask_ptr);
+bool command_plt_clear(sqlite3 *db, char *args[LKT_MESSAGE_ARGS_MAX], enum mpd_idle_flag *watch_mask_ptr);
+bool command_plt_rename(sqlite3 *db, char *args[LKT_MESSAGE_ARGS_MAX], enum mpd_idle_flag *watch_mask_ptr);
+bool command_plt_export(sqlite3 *db, char *args[LKT_MESSAGE_ARGS_MAX], enum mpd_idle_flag *watch_mask_ptr);
+bool command_plt_import(sqlite3 *db, char *args[LKT_MESSAGE_ARGS_MAX], enum mpd_idle_flag *watch_mask_ptr);
+bool command_plt_add(sqlite3 *db, char *args[LKT_MESSAGE_ARGS_MAX], enum mpd_idle_flag *watch_mask_ptr);
 
 /* The help */
 bool command_help(struct lkt_state *srv, size_t c);
 
 /* Update the database */
-bool command_update(struct lkt_state *srv, long long int *watch_mask_ptr);
+bool command_update(struct lkt_state *srv, enum mpd_idle_flag *watch_mask_ptr);
 
 /* Respond to the idle command */
 bool command_idle(struct lkt_state *srv, size_t c, struct lkt_command *cmd);
diff --git a/inc/lektor/config.h b/inc/lektor/config.h
index 56c28206..52f5de2c 100644
--- a/inc/lektor/config.h
+++ b/inc/lektor/config.h
@@ -1,5 +1,6 @@
 #pragma once
 
+#include <lektor/defines.h>
 #include <stddef.h>
 #include <sqlite3.h>
 
diff --git a/inc/lektor/database.h b/inc/lektor/database.h
index dbd58d75..3f71c301 100644
--- a/inc/lektor/database.h
+++ b/inc/lektor/database.h
@@ -1,5 +1,6 @@
 #pragma once
 
+#include <lektor/defines.h>
 #include <lektor/mkv.h>
 #include <lektor/uri.h>
 
@@ -9,16 +10,6 @@
 #include <stdbool.h>
 #include <linux/limits.h>
 
-#define LKT_DATABASE_NAME_KID           "id"
-#define LKT_DATABASE_NAME_KNAME         "source_name"
-#define LKT_DATABASE_NAME_KTITLE        "song_title"
-#define LKT_DATABASE_NAME_KCAT          "song_type"
-#define LKT_DATABASE_NAME_KTYPE         "category"
-#define LKT_DATABASE_NAME_KAUTHOR       "author"
-#define LKT_DATABASE_NAME_KAUTHOR_YEAR  "author_year"
-#define LKT_DATABASE_NAME_KLANG         "language"
-#define LKT_DATABASE_KARA_COLUMNT_ANY   "any_col"
-
 struct lkt_queue_state {
     int volume;
     int paused;
diff --git a/inc/lektor/defines.h b/inc/lektor/defines.h
new file mode 100644
index 00000000..600d4b50
--- /dev/null
+++ b/inc/lektor/defines.h
@@ -0,0 +1,48 @@
+#pragma once
+
+#define LKT_MAX_SQLITE_STATEMENT    1024
+#define PROTECTED_DATABASE          "disk"
+#define BUFFER_MAX                  4096
+
+#define LKT_DATABASE_NAME_KID           "id"
+#define LKT_DATABASE_NAME_KNAME         "source_name"
+#define LKT_DATABASE_NAME_KTITLE        "song_title"
+#define LKT_DATABASE_NAME_KCAT          "song_type"
+#define LKT_DATABASE_NAME_KTYPE         "category"
+#define LKT_DATABASE_NAME_KAUTHOR       "author"
+#define LKT_DATABASE_NAME_KAUTHOR_YEAR  "author_year"
+#define LKT_DATABASE_NAME_KLANG         "language"
+#define LKT_DATABASE_KARA_COLUMNT_ANY   "any_col"
+
+#define LEKTOR_TAG_MAX 256
+
+#ifndef LKT_MESSAGE_ARGS_MAX
+#define LKT_MESSAGE_ARGS_MAX 32
+#endif
+
+#ifndef LKT_MESSAGE_MAX
+#define LKT_MESSAGE_MAX 2048
+#endif
+
+enum mpd_idle_flag {
+    MPD_IDLE_NONE               = 0,
+
+    MPD_IDLE_DATABASE           = ( 1 << 1  ),
+    MPD_IDLE_UPDATE             = ( 1 << 2  ),
+    MPD_IDLE_STORED_PLAYLIST    = ( 1 << 3  ),
+    MPD_IDLE_PLAYLIST           = ( 1 << 4  ),
+    MPD_IDLE_PLAYER             = ( 1 << 5  ),
+    MPD_IDLE_MIXER              = ( 1 << 6  ),
+    MPD_IDLE_OUTPUT             = ( 1 << 7  ),
+    MPD_IDLE_OPTIONS            = ( 1 << 8  ),
+    MPD_IDLE_PARTITION          = ( 1 << 9  ),
+    MPD_IDLE_STICKER            = ( 1 << 10 ),
+    MPD_IDLE_SUBSCRIPTION       = ( 1 << 11 ),
+    MPD_IDLE_MESSAGE            = ( 1 << 12 ),
+
+    MPD_IDLE_ALL =
+        MPD_IDLE_DATABASE | MPD_IDLE_UPDATE | MPD_IDLE_STORED_PLAYLIST  |
+        MPD_IDLE_PLAYLIST | MPD_IDLE_PLAYER | MPD_IDLE_MIXER            |
+        MPD_IDLE_OUTPUT | MPD_IDLE_OPTIONS | MPD_IDLE_PARTITION         |
+        MPD_IDLE_STICKER | MPD_IDLE_SUBSCRIPTION | MPD_IDLE_MESSAGE,
+};
diff --git a/inc/lektor/macro.h b/inc/lektor/macro.h
index c51ee074..3ac78e56 100644
--- a/inc/lektor/macro.h
+++ b/inc/lektor/macro.h
@@ -28,9 +28,6 @@
         goto error;                                                     \
     }
 
-#define LKT_MAX_SQLITE_STATEMENT    1024
-#define PROTECTED_DATABASE          "disk"
-
 #ifndef MAX
 #define MAX(a, b) ((a) < (b) ? (b) : (a))
 #endif /* MAX */
diff --git a/inc/lektor/mkv.h b/inc/lektor/mkv.h
index dbc23e50..447a58ee 100644
--- a/inc/lektor/mkv.h
+++ b/inc/lektor/mkv.h
@@ -23,9 +23,9 @@
  */
 #pragma once
 
+#include <lektor/defines.h>
 #include <linux/limits.h>
 #include <stddef.h>
-#define LEKTOR_TAG_MAX 256
 
 struct kara_metadata {
     char song_name[LEKTOR_TAG_MAX];
diff --git a/inc/lektor/module/module_x11.h b/inc/lektor/module/module_x11.h
index b4db36a2..5325fe48 100644
--- a/inc/lektor/module/module_x11.h
+++ b/inc/lektor/module/module_x11.h
@@ -1,5 +1,6 @@
 #pragma once
 
+#include <lektor/defines.h>
 #include <stdbool.h>
 #include <sqlite3.h>
 #include <lektor/window.h>
@@ -24,4 +25,4 @@ bool module_x11_is_paused(struct lkt_win *const win, bool *ret);
 bool module_x11_get_duration(struct lkt_win *const win, int *dur_sec);
 bool module_x11_get_elapsed(struct lkt_win *const win, int *elapsed_sec);
 
-bool module_x11_handle_events(struct lkt_win *const win, sqlite3 *db, long long int *mpd_idle_events);
+bool module_x11_handle_events(struct lkt_win *const win, sqlite3 *db, enum mpd_idle_flag *mpd_idle_events);
diff --git a/inc/lektor/net.h b/inc/lektor/net.h
index c4f3d86d..f862eb6d 100644
--- a/inc/lektor/net.h
+++ b/inc/lektor/net.h
@@ -1,5 +1,6 @@
 #pragma once
 
+#include <lektor/defines.h>
 #include <lektor/config.h>
 #include <lektor/window.h>
 #include <sqlite3.h>
@@ -7,29 +8,6 @@
 
 #include <stddef.h>
 
-#define MPD_IDLE_NONE               0x0
-#define MPD_IDLE_ALL                0x111111111111
-#define MPD_IDLE_DATABASE           0x000000000001
-#define MPD_IDLE_UPDATE             0x000000000010
-#define MPD_IDLE_STORED_PLAYLIST    0x000000000100
-#define MPD_IDLE_PLAYLIST           0x000000001000
-#define MPD_IDLE_PLAYER             0x000000010000
-#define MPD_IDLE_MIXER              0x000000100000
-#define MPD_IDLE_OUTPUT             0x000001000000
-#define MPD_IDLE_OPTIONS            0x000010000000
-#define MPD_IDLE_PARTITION          0x000100000000
-#define MPD_IDLE_STICKER            0x001000000000
-#define MPD_IDLE_SUBSCRIPTION       0x010000000000
-#define MPD_IDLE_MESSAGE            0x100000000000
-
-#ifndef LKT_MESSAGE_ARGS_MAX
-#define LKT_MESSAGE_ARGS_MAX 32
-#endif
-
-#ifndef LKT_MESSAGE_MAX
-#define LKT_MESSAGE_MAX 2048
-#endif
-
 struct lkt_command {
     char *name;
     char *args[LKT_MESSAGE_ARGS_MAX];
@@ -60,7 +38,7 @@ struct lkt_state {
     sqlite3 *db;
     const char *kara_prefix;
 
-    long long int mpd_idle_events;
+    enum mpd_idle_flag mpd_idle_events;
 
     struct lkt_win win;
 };
@@ -70,7 +48,7 @@ void lkt_state_send(struct lkt_state *srv, size_t c, struct lkt_message *msg);
 
 /* Get the mask to watch for events for a given client, to be used with the `idle` command.
  * Return a pointer to the client's mask */
-long long int *lkt_client_get_mask(struct lkt_state *srv, size_t c);
+enum mpd_idle_flag *lkt_client_get_mask(struct lkt_state *srv, size_t c);
 
 /* Register a client as authentificated. */
 bool lkt_client_auth(struct lkt_state *srv, size_t c, bool set_auth);
diff --git a/inc/lektor/repo.h b/inc/lektor/repo.h
index 829011b9..40953c69 100644
--- a/inc/lektor/repo.h
+++ b/inc/lektor/repo.h
@@ -1,7 +1,6 @@
 #pragma once
 
-#define LKT_MAX_PARALLEL_DOWNLOAD 10
-
+#include <lektor/defines.h>
 #include <lektor/mkv.h>
 #include <lektor/thread.h>
 #include <curl/curl.h>
diff --git a/inc/lektor/thread.h b/inc/lektor/thread.h
index 0c2a1da7..553333b8 100644
--- a/inc/lektor/thread.h
+++ b/inc/lektor/thread.h
@@ -1,5 +1,6 @@
 #pragma once
 
+#include <lektor/defines.h>
 #include <pthread.h>
 #include <sys/types.h>
 
diff --git a/inc/lektor/uri.h b/inc/lektor/uri.h
index 063a146f..4466334f 100644
--- a/inc/lektor/uri.h
+++ b/inc/lektor/uri.h
@@ -1,5 +1,6 @@
 #pragma once
 
+#include <lektor/defines.h>
 #include <stddef.h>
 #include <stddef.h>
 #include <stdbool.h>
diff --git a/inc/lektor/utils.h b/inc/lektor/utils.h
index 6ffd7127..27755675 100644
--- a/inc/lektor/utils.h
+++ b/inc/lektor/utils.h
@@ -1,6 +1,7 @@
 /* Random things. */
 #pragma once
 
+#include <lektor/defines.h>
 #include <stdint.h>
 #include <stdlib.h>
 
diff --git a/inc/lektor/window.h b/inc/lektor/window.h
index 4fe19817..f0f86b50 100644
--- a/inc/lektor/window.h
+++ b/inc/lektor/window.h
@@ -1,5 +1,6 @@
 #pragma once
 
+#include <lektor/defines.h>
 #include <stdbool.h>
 #include <sqlite3.h>
 
@@ -29,7 +30,7 @@ struct lkt_win {
     bool (*get_elapsed)(struct lkt_win *win, int *elapsed_sec);
 
     /* Handle loop event */
-    bool (*handle_events)(struct lkt_win *win, sqlite3 *db, long long int *mpd_idle_events);
+    bool (*handle_events)(struct lkt_win *win, sqlite3 *db, enum mpd_idle_flag *mpd_idle_events);
 };
 
 enum lkt_win_type {
diff --git a/src/commands.c b/src/commands.c
index 64aa02c7..0e1bcb87 100644
--- a/src/commands.c
+++ b/src/commands.c
@@ -155,7 +155,7 @@ command_status(struct lkt_state *srv, size_t c)
 }
 
 bool
-command_next(sqlite3 *db, struct lkt_win *win, long long int *watch_mask_ptr)
+command_next(sqlite3 *db, struct lkt_win *win, enum mpd_idle_flag *watch_mask_ptr)
 {
     *watch_mask_ptr |= MPD_IDLE_PLAYER;
     char filepath[PATH_MAX];
@@ -165,14 +165,14 @@ command_next(sqlite3 *db, struct lkt_win *win, long long int *watch_mask_ptr)
 }
 
 bool
-command_pause(sqlite3 *db, struct lkt_win *win, long long int *watch_mask_ptr)
+command_pause(sqlite3 *db, struct lkt_win *win, enum mpd_idle_flag *watch_mask_ptr)
 {
     *watch_mask_ptr |= MPD_IDLE_PLAYER;
     return database_queue_toggle_pause(db) && win->toggle_pause(win, NULL);
 }
 
 bool
-command_previous(sqlite3 *db, struct lkt_win *win, long long int *watch_mask_ptr)
+command_previous(sqlite3 *db, struct lkt_win *win, enum mpd_idle_flag *watch_mask_ptr)
 {
     *watch_mask_ptr |= MPD_IDLE_PLAYER;
     char filepath[PATH_MAX];
@@ -183,7 +183,7 @@ command_previous(sqlite3 *db, struct lkt_win *win, long long int *watch_mask_ptr
 
 bool
 command_play(sqlite3 *db, struct lkt_win *win, char *args[LKT_MESSAGE_ARGS_MAX],
-             long long int *watch_mask_ptr)
+             enum mpd_idle_flag *watch_mask_ptr)
 {
     *watch_mask_ptr |= MPD_IDLE_PLAYER;
     char filepath[PATH_MAX], *endptr;
@@ -239,7 +239,7 @@ error:
 }
 
 bool
-command_stop(sqlite3 *db, struct lkt_win *win, long long int *watch_mask_ptr)
+command_stop(sqlite3 *db, struct lkt_win *win, enum mpd_idle_flag *watch_mask_ptr)
 {
     *watch_mask_ptr |= MPD_IDLE_PLAYER;
     bool res = database_queue_stop(db);
@@ -251,7 +251,7 @@ command_stop(sqlite3 *db, struct lkt_win *win, long long int *watch_mask_ptr)
 }
 
 bool
-command_add(sqlite3 *db, struct lkt_win *win, char *args[LKT_MESSAGE_ARGS_MAX], long long int *watch_mask_ptr)
+command_add(sqlite3 *db, struct lkt_win *win, char *args[LKT_MESSAGE_ARGS_MAX], enum mpd_idle_flag *watch_mask_ptr)
 {
     if (args == NULL) {
         fprintf(stderr, " ! command_add: invalid NULL arguments\n");
@@ -311,7 +311,7 @@ command_add(sqlite3 *db, struct lkt_win *win, char *args[LKT_MESSAGE_ARGS_MAX],
 
 bool
 command_addid(sqlite3 *db, struct lkt_win *win, char *args[LKT_MESSAGE_ARGS_MAX],
-              long long int *watch_mask_ptr)
+              enum mpd_idle_flag *watch_mask_ptr)
 {
     (void) win;
     long id;
@@ -342,21 +342,21 @@ command_addid(sqlite3 *db, struct lkt_win *win, char *args[LKT_MESSAGE_ARGS_MAX]
 }
 
 bool
-command_clear(sqlite3 *db, long long int *watch_mask_ptr)
+command_clear(sqlite3 *db, enum mpd_idle_flag *watch_mask_ptr)
 {
     *watch_mask_ptr |= MPD_IDLE_PLAYLIST;
     return database_queue_clear(db);
 }
 
 bool
-command_crop(sqlite3 *db, long long int *watch_mask_ptr)
+command_crop(sqlite3 *db, enum mpd_idle_flag *watch_mask_ptr)
 {
     *watch_mask_ptr |= MPD_IDLE_PLAYLIST;
     return database_queue_crop(db);
 }
 
 bool
-command_del(sqlite3 *db, struct lkt_win *win, char *pos_range, long long int *watch_mask_ptr)
+command_del(sqlite3 *db, struct lkt_win *win, char *pos_range, enum mpd_idle_flag *watch_mask_ptr)
 {
     (void) win;
     long pos_lowwer, pos_upper = -1, i;
@@ -403,7 +403,7 @@ command_del(sqlite3 *db, struct lkt_win *win, char *pos_range, long long int *wa
 }
 
 bool
-command_delid(sqlite3 *db, struct lkt_win *win, char *id_str, long long int *watch_mask_ptr)
+command_delid(sqlite3 *db, struct lkt_win *win, char *id_str, enum mpd_idle_flag *watch_mask_ptr)
 {
     (void) win;
     long id;
@@ -427,7 +427,7 @@ command_delid(sqlite3 *db, struct lkt_win *win, char *id_str, long long int *wat
 }
 
 bool
-command_move(sqlite3 *db, char *args[LKT_MESSAGE_ARGS_MAX], long long int *watch_mask_ptr)
+command_move(sqlite3 *db, char *args[LKT_MESSAGE_ARGS_MAX], enum mpd_idle_flag *watch_mask_ptr)
 {
     long from, to;
     char *endptr;
@@ -486,7 +486,7 @@ command_help(struct lkt_state *srv, size_t c)
 }
 
 bool
-command_update(struct lkt_state *srv, long long int *watch_mask_ptr)
+command_update(struct lkt_state *srv, enum mpd_idle_flag *watch_mask_ptr)
 {
     *watch_mask_ptr |= MPD_IDLE_UPDATE;
     *watch_mask_ptr |= MPD_IDLE_DATABASE;
@@ -496,7 +496,7 @@ command_update(struct lkt_state *srv, long long int *watch_mask_ptr)
 bool
 command_idle(struct lkt_state *srv, size_t c, struct lkt_command *cmd)
 {
-    long long int *clt_mask = lkt_client_get_mask(srv, c);
+    enum mpd_idle_flag *clt_mask = lkt_client_get_mask(srv, c);
     bool once = false;
 
     for (size_t i = 0; cmd->args[i]; ++i) {
@@ -533,7 +533,7 @@ command_idle(struct lkt_state *srv, size_t c, struct lkt_command *cmd)
     if (!once)
         *clt_mask = MPD_IDLE_ALL;
 
-    fprintf(stderr, " * command_idle: idle mask for client number %ld is 0x%llX\n", c, *clt_mask);
+    fprintf(stderr, " * command_idle: idle mask for client number %ld is 0x%X\n", c, *clt_mask);
 
     return true;
 }
@@ -541,7 +541,7 @@ command_idle(struct lkt_state *srv, size_t c, struct lkt_command *cmd)
 bool
 command_noidle(struct lkt_state *srv, size_t c)
 {
-    long long int *clt_mask = lkt_client_get_mask(srv, c);
+    enum mpd_idle_flag *clt_mask = lkt_client_get_mask(srv, c);
     *clt_mask = MPD_IDLE_NONE;
 
     return true;
@@ -754,7 +754,7 @@ command_set_playback_option(struct lkt_state *srv, size_t c,
 }
 
 bool
-command_set_pos(sqlite3 *db, struct lkt_win *win, long long int *watch_mask_ptr, int index)
+command_set_pos(sqlite3 *db, struct lkt_win *win, enum mpd_idle_flag *watch_mask_ptr, int index)
 {
     char filepath[PATH_MAX];
     *watch_mask_ptr |= MPD_IDLE_PLAYER;
@@ -773,7 +773,7 @@ command_set_pos(sqlite3 *db, struct lkt_win *win, long long int *watch_mask_ptr,
 }
 
 bool
-command_plt_add(sqlite3 *db, char *args[LKT_MESSAGE_ARGS_MAX], long long int *watch_mask_ptr)
+command_plt_add(sqlite3 *db, char *args[LKT_MESSAGE_ARGS_MAX], enum mpd_idle_flag *watch_mask_ptr)
 {
     if (args == NULL || args[0] == NULL) {
         fprintf(stderr, " ! command_plt_add: Invalid argument\n");
@@ -809,7 +809,7 @@ end_plt_add_uri:
 }
 
 bool
-command_plt_remove(sqlite3 *db, char *args[LKT_MESSAGE_ARGS_MAX], long long int *watch_mask_ptr)
+command_plt_remove(sqlite3 *db, char *args[LKT_MESSAGE_ARGS_MAX], enum mpd_idle_flag *watch_mask_ptr)
 {
     char *endptr;
     long pos;
@@ -842,7 +842,7 @@ command_plt_remove(sqlite3 *db, char *args[LKT_MESSAGE_ARGS_MAX], long long int
 }
 
 bool
-command_plt_clear(sqlite3 *db, char *args[LKT_MESSAGE_ARGS_MAX], long long int *watch_mask_ptr)
+command_plt_clear(sqlite3 *db, char *args[LKT_MESSAGE_ARGS_MAX], enum mpd_idle_flag *watch_mask_ptr)
 {
     if (args == NULL || args[0] == NULL)
         return false;
@@ -856,7 +856,7 @@ command_plt_clear(sqlite3 *db, char *args[LKT_MESSAGE_ARGS_MAX], long long int *
 }
 
 bool
-command_plt_rename(sqlite3 *db, char *args[LKT_MESSAGE_ARGS_MAX], long long int *watch_mask_ptr)
+command_plt_rename(sqlite3 *db, char *args[LKT_MESSAGE_ARGS_MAX], enum mpd_idle_flag *watch_mask_ptr)
 {
     if (args == NULL || args[0] == NULL || args[1] == NULL)
         return false;
@@ -869,7 +869,7 @@ command_plt_rename(sqlite3 *db, char *args[LKT_MESSAGE_ARGS_MAX], long long int
 }
 
 bool
-command_plt_export(sqlite3 *db, char *args[LKT_MESSAGE_ARGS_MAX], long long int *watch_mask_ptr)
+command_plt_export(sqlite3 *db, char *args[LKT_MESSAGE_ARGS_MAX], enum mpd_idle_flag *watch_mask_ptr)
 {
     int ret = false;
 
@@ -893,7 +893,7 @@ error:
 }
 
 bool
-command_plt_import(sqlite3 *db, char *args[LKT_MESSAGE_ARGS_MAX], long long int *watch_mask_ptr)
+command_plt_import(sqlite3 *db, char *args[LKT_MESSAGE_ARGS_MAX], enum mpd_idle_flag *watch_mask_ptr)
 {
     int ret = false;
 
@@ -917,7 +917,7 @@ error:
 }
 
 bool
-command_plt_add_uri(sqlite3 *db, char *args[LKT_MESSAGE_ARGS_MAX], long long int *watch_mask_ptr)
+command_plt_add_uri(sqlite3 *db, char *args[LKT_MESSAGE_ARGS_MAX], enum mpd_idle_flag *watch_mask_ptr)
 {
     if (args == NULL || args[0] == NULL || args[1] == NULL)
         return false;
@@ -939,7 +939,7 @@ command_plt_add_uri(sqlite3 *db, char *args[LKT_MESSAGE_ARGS_MAX], long long int
 }
 
 bool
-command_shuffle(sqlite3 *db, long long int *watch_mask_ptr)
+command_shuffle(sqlite3 *db, enum mpd_idle_flag *watch_mask_ptr)
 {
     bool ret = database_queue_shuffle(db);
 
diff --git a/src/module/module_x11.c b/src/module/module_x11.c
index 25bcb20f..49a2e813 100644
--- a/src/module/module_x11.c
+++ b/src/module/module_x11.c
@@ -227,7 +227,7 @@ lmpv_free(mpv_handle **ctx)
 }
 
 static inline bool
-lmpv_handle(struct lkt_win *win, sqlite3 *db, long long int *mpd_idle_events)
+lmpv_handle(struct lkt_win *win, sqlite3 *db, enum mpd_idle_flag *mpd_idle_events)
 {
     int ao_volume;
     struct lkt_queue_state state;
@@ -594,7 +594,7 @@ module_x11_get_elapsed(struct lkt_win *const win, int *elapsed_sec)
 }
 
 bool
-module_x11_handle_events(struct lkt_win *const win, sqlite3 *db, long long int *mpd_idle_events)
+module_x11_handle_events(struct lkt_win *const win, sqlite3 *db, enum mpd_idle_flag *mpd_idle_events)
 {
     if (win == NULL || win->window == NULL)
         return false;
diff --git a/src/net/listen.c b/src/net/listen.c
index cade02db..049cf75e 100644
--- a/src/net/listen.c
+++ b/src/net/listen.c
@@ -50,7 +50,7 @@ struct lkt_client {
     size_t command_list_len;
     enum lkt_command_list_mode command_list_mode;
 
-    long long int mpd_idle_watch;
+    enum mpd_idle_flag mpd_idle_watch;
     bool request_close;
 
     bool authentificated;
@@ -582,7 +582,7 @@ handle_idle_events(struct lkt_state *srv)
 {
     struct lkt_client *current_client;
     struct lkt_message *msg;
-    long long int common_mask;
+    enum mpd_idle_flag common_mask;
     bool once = false;
 
     // No new events
@@ -646,7 +646,7 @@ handle_idle_events(struct lkt_state *srv)
     return 0;
 }
 
-long long int *
+enum mpd_idle_flag *
 lkt_client_get_mask(struct lkt_state *srv, size_t c)
 {
     return &(srv->clients[c - 1].mpd_idle_watch);
-- 
GitLab