build with C++ compiler
authorMax Kellermann <max@musicpd.org>
Sat, 17 Feb 2018 15:14:12 +0000 (16:14 +0100)
committerMax Kellermann <max@musicpd.org>
Sun, 18 Feb 2018 10:11:04 +0000 (11:11 +0100)
Yes, ncmpc is switching to C++.  A lot of code can be a lot simpler.
Once you have gotten used to C++ sugar, it's hard to go back to plain
C.

Interestingly, this commit makes the ncmpc binary *smaller* (by one
kilobyte, with GCC 7.3).

122 files changed:
README.rst
meson.build
src/Main.cxx [moved from src/main.c with 84% similarity]
src/aconnect.cxx [moved from src/aconnect.c with 92% similarity]
src/aconnect.hxx [moved from src/aconnect.h with 100% similarity]
src/callbacks.cxx [moved from src/callbacks.c with 88% similarity]
src/callbacks.hxx [moved from src/callbacks.h with 90% similarity]
src/charset.cxx [moved from src/charset.c with 89% similarity]
src/charset.hxx [moved from src/charset.h with 97% similarity]
src/colors.cxx [moved from src/colors.c with 76% similarity]
src/colors.hxx [moved from src/colors.h with 97% similarity]
src/command.cxx [moved from src/command.c with 98% similarity]
src/command.hxx [moved from src/command.h with 97% similarity]
src/conf.cxx [moved from src/conf.c with 92% similarity]
src/conf.h [deleted file]
src/conf.hxx [new file with mode: 0644]
src/db_completion.cxx [moved from src/db_completion.c with 90% similarity]
src/db_completion.hxx [moved from src/db_completion.h with 100% similarity]
src/defaults.hxx [moved from src/defaults.h with 97% similarity]
src/filelist.cxx [moved from src/filelist.c with 87% similarity]
src/filelist.hxx [moved from src/filelist.h with 96% similarity]
src/gidle.cxx [moved from src/gidle.c with 93% similarity]
src/gidle.hxx [moved from src/gidle.h with 98% similarity]
src/hscroll.cxx [moved from src/hscroll.c with 77% similarity]
src/hscroll.hxx [moved from src/hscroll.h with 100% similarity]
src/keyboard.cxx [moved from src/keyboard.c with 91% similarity]
src/keyboard.hxx [moved from src/keyboard.h with 97% similarity]
src/lirc.cxx [moved from src/lirc.c with 84% similarity]
src/lirc.hxx [moved from src/lirc.h with 95% similarity]
src/list_window.cxx [moved from src/list_window.c with 96% similarity]
src/list_window.hxx [moved from src/list_window.h with 98% similarity]
src/lyrics.cxx [moved from src/lyrics.c with 89% similarity]
src/lyrics.hxx [moved from src/lyrics.h with 93% similarity]
src/match.cxx [moved from src/match.c with 80% similarity]
src/match.hxx [moved from src/match.h with 95% similarity]
src/mpdclient.cxx [moved from src/mpdclient.c with 88% similarity]
src/mpdclient.hxx [moved from src/mpdclient.h with 95% similarity]
src/ncmpc.hxx [moved from src/ncmpc.h with 91% similarity]
src/ncu.cxx [moved from src/ncu.c with 87% similarity]
src/ncu.hxx [moved from src/ncu.h with 96% similarity]
src/net/async_connect.cxx [moved from src/net/async_connect.c with 98% similarity]
src/net/async_connect.hxx [moved from src/net/async_connect.h with 98% similarity]
src/net/async_rconnect.cxx [moved from src/net/async_rconnect.c with 93% similarity]
src/net/async_rconnect.hxx [moved from src/net/async_rconnect.h with 100% similarity]
src/net/resolver.cxx [moved from src/net/resolver.c with 88% similarity]
src/net/resolver.hxx [moved from src/net/resolver.h with 100% similarity]
src/net/socket.cxx [moved from src/net/socket.c with 99% similarity]
src/net/socket.hxx [moved from src/net/socket.h with 96% similarity]
src/net/types.hxx [moved from src/net/types.h with 100% similarity]
src/options.cxx [moved from src/options.c with 83% similarity]
src/options.hxx [moved from src/options.h with 75% similarity]
src/paint.hxx [moved from src/paint.h with 97% similarity]
src/player_command.cxx [moved from src/player_command.c with 87% similarity]
src/player_command.hxx [moved from src/player_command.h with 94% similarity]
src/playlist.cxx [moved from src/playlist.c with 95% similarity]
src/playlist.hxx [moved from src/playlist.h with 94% similarity]
src/plugin.cxx [moved from src/plugin.c with 82% similarity]
src/plugin.hxx [moved from src/plugin.h with 97% similarity]
src/progress_bar.cxx [moved from src/progress_bar.c with 95% similarity]
src/progress_bar.hxx [moved from src/progress_bar.h with 95% similarity]
src/save_playlist.cxx [moved from src/save_playlist.c with 86% similarity]
src/save_playlist.hxx [moved from src/save_playlist.h with 100% similarity]
src/screen.cxx [moved from src/screen.c with 88% similarity]
src/screen.hxx [moved from src/screen.h with 93% similarity]
src/screen_artist.cxx [moved from src/screen_artist.c with 84% similarity]
src/screen_artist.hxx [moved from src/screen_artist.h with 100% similarity]
src/screen_browser.cxx [moved from src/screen_browser.c with 88% similarity]
src/screen_browser.hxx [moved from src/screen_browser.h with 97% similarity]
src/screen_chat.cxx [moved from src/screen_chat.c with 86% similarity]
src/screen_chat.hxx [moved from src/screen_chat.h with 100% similarity]
src/screen_client.cxx [moved from src/screen_client.c with 89% similarity]
src/screen_client.hxx [moved from src/screen_client.h with 98% similarity]
src/screen_file.cxx [moved from src/screen_file.c with 88% similarity]
src/screen_file.hxx [moved from src/screen_file.h with 98% similarity]
src/screen_find.cxx [moved from src/screen_find.c with 90% similarity]
src/screen_find.hxx [moved from src/screen_find.h with 97% similarity]
src/screen_help.cxx [moved from src/screen_help.c with 59% similarity]
src/screen_help.hxx [moved from src/screen_help.h with 100% similarity]
src/screen_init.cxx [moved from src/screen_init.c with 88% similarity]
src/screen_interface.hxx [moved from src/screen_interface.h with 93% similarity]
src/screen_keydef.cxx [moved from src/screen_keydef.c with 91% similarity]
src/screen_keydef.hxx [moved from src/screen_keydef.h with 100% similarity]
src/screen_list.cxx [moved from src/screen_list.c with 85% similarity]
src/screen_list.hxx [moved from src/screen_list.h with 98% similarity]
src/screen_lyrics.cxx [moved from src/screen_lyrics.c with 81% similarity]
src/screen_lyrics.hxx [moved from src/screen_lyrics.h with 98% similarity]
src/screen_outputs.cxx [moved from src/screen_outputs.c with 80% similarity]
src/screen_outputs.hxx [moved from src/screen_outputs.h with 100% similarity]
src/screen_paint.cxx [moved from src/screen_paint.c with 88% similarity]
src/screen_queue.cxx [moved from src/screen_queue.c with 86% similarity]
src/screen_queue.hxx [moved from src/screen_queue.h with 100% similarity]
src/screen_search.cxx [moved from src/screen_search.c with 85% similarity]
src/screen_search.hxx [moved from src/screen_search.h with 100% similarity]
src/screen_song.cxx [moved from src/screen_song.c with 85% similarity]
src/screen_song.hxx [moved from src/screen_song.h with 100% similarity]
src/screen_status.cxx [moved from src/screen_status.c with 93% similarity]
src/screen_status.hxx [moved from src/screen_status.h with 96% similarity]
src/screen_text.cxx [moved from src/screen_text.c with 87% similarity]
src/screen_text.hxx [moved from src/screen_text.h with 97% similarity]
src/screen_utils.cxx [moved from src/screen_utils.c with 89% similarity]
src/screen_utils.hxx [moved from src/screen_utils.h with 95% similarity]
src/signals.cxx [moved from src/signals.c with 89% similarity]
src/signals.hxx [moved from src/signals.h with 98% similarity]
src/song_paint.cxx [moved from src/song_paint.c with 89% similarity]
src/song_paint.hxx [moved from src/song_paint.h with 98% similarity]
src/status_bar.cxx [moved from src/status_bar.c with 93% similarity]
src/status_bar.hxx [moved from src/status_bar.h with 97% similarity]
src/strfsong.cxx [moved from src/strfsong.c with 91% similarity]
src/strfsong.hxx [moved from src/strfsong.h with 100% similarity]
src/time_format.cxx [moved from src/time_format.c with 98% similarity]
src/time_format.hxx [moved from src/time_format.h with 100% similarity]
src/title_bar.cxx [moved from src/title_bar.c with 94% similarity]
src/title_bar.hxx [moved from src/title_bar.h with 97% similarity]
src/utils.cxx [moved from src/utils.c with 94% similarity]
src/utils.hxx [moved from src/utils.h with 100% similarity]
src/window.hxx [moved from src/window.h with 100% similarity]
src/wreadln.cxx [moved from src/wreadln.c with 90% similarity]
src/wreadln.hxx [moved from src/wreadln.h with 87% similarity]
src/xterm_title.cxx [moved from src/xterm_title.c with 90% similarity]
src/xterm_title.hxx [moved from src/xterm_title.h with 100% similarity]
test/meson.build
test/run_hscroll.cxx [moved from test/run_hscroll.c with 96% similarity]

index 4cc7da3..377072c 100644 (file)
@@ -10,7 +10,7 @@ How to compile and install ncmpc
 
 You need:
 
-- a C99 compliant compiler (e.g. gcc)
+- a C++14 compliant compiler (e.g. gcc or clang)
 - libmpdclient 2.9
 - `GLib 2.30 <https://developer.gnome.org/glib/>`__
 - `ncurses <https://www.gnu.org/software/ncurses/>`__
index 3c3b380..500ae5e 100644 (file)
@@ -1,12 +1,12 @@
-project('ncmpc', 'c',
+project('ncmpc', 'cpp',
   version: '0.30',
   default_options: [
-    'c_std=c99',
+    'cpp_std=c++14'
   ],
   license: 'GPLv2+',
 )
 
-cc = meson.get_compiler('c')
+cc = meson.get_compiler('cpp')
 
 conf = configuration_data()
 conf.set_quoted('PACKAGE', meson.project_name())
@@ -158,13 +158,16 @@ test_cflags = [
   '-Wall',
   '-Wextra',
   '-Wno-deprecated-declarations',
-  '-Wmissing-prototypes',
   '-Wshadow',
   '-Wpointer-arith',
-  '-Wstrict-prototypes',
   '-Wcast-qual',
+  '-Wcast-align',
   '-Wwrite-strings',
+  '-Wmissing-declarations', '-Wmissing-noreturn', '-Wmissing-format-attribute',
+  '-Wredundant-decls', '-Wundef',
   '-fvisibility=hidden',
+  '-fno-exceptions',
+  '-fno-rtti',
 ]
 
 test_ldflags = [
@@ -186,11 +189,11 @@ foreach f: test_cflags
   endif
 endforeach
 
-add_global_arguments(common_cflags, language: 'c')
+add_global_arguments(common_cflags, language: 'cpp')
 
 foreach f: test_ldflags
   if cc.has_argument(f)
-    add_global_link_arguments(f, language: 'c')
+    add_global_link_arguments(f, language: 'cpp')
   endif
 endforeach
 
@@ -211,70 +214,70 @@ need_plugin_library = false
 
 if host_machine.system() != 'windows'
   sources += [
-    'src/signals.c',
+    'src/signals.cxx',
   ]
 endif
 
 if not mini
   sources += [
-    'src/db_completion.c',
-    'src/xterm_title.c',
-    'src/hscroll.c',
-    'src/match.c',
-    'src/conf.c',
+    'src/db_completion.cxx',
+    'src/xterm_title.cxx',
+    'src/hscroll.cxx',
+    'src/match.cxx',
+    'src/conf.cxx',
   ]
 endif
 
 if async_connect
   sources += [
-    'src/net/socket.c',
-    'src/net/resolver.c',
-    'src/net/async_connect.c',
-    'src/net/async_rconnect.c',
-    'src/aconnect.c',
+    'src/net/socket.cxx',
+    'src/net/resolver.cxx',
+    'src/net/async_connect.cxx',
+    'src/net/async_rconnect.cxx',
+    'src/aconnect.cxx',
   ]
 endif
 
 if enable_lirc
   sources += [
-    'src/lirc.c',
+    'src/lirc.cxx',
   ]
 endif
 
 enable_help_screen = get_option('help_screen') and not mini
 conf.set('ENABLE_HELP_SCREEN', enable_help_screen)
 if enable_help_screen
-  sources += ['src/screen_help.c']
+  sources += ['src/screen_help.cxx']
 endif
 
 enable_artist_screen = get_option('artist_screen') and not mini
 conf.set('ENABLE_ARTIST_SCREEN', enable_artist_screen)
 if enable_artist_screen
-  sources += ['src/screen_artist.c']
+  sources += ['src/screen_artist.cxx']
 endif
 
 enable_search_screen = get_option('search_screen') and not mini
 conf.set('ENABLE_SEARCH_SCREEN', enable_search_screen)
 if enable_search_screen
-  sources += ['src/screen_search.c']
+  sources += ['src/screen_search.cxx']
 endif
 
 enable_song_screen = get_option('song_screen') and not mini
 conf.set('ENABLE_SONG_SCREEN', enable_song_screen)
 if enable_song_screen
-  sources += ['src/screen_song.c']
+  sources += ['src/screen_song.cxx']
 endif
 
 enable_keydef_screen = get_option('key_screen') and not mini
 conf.set('ENABLE_KEYDEF_SCREEN', enable_keydef_screen)
 if enable_keydef_screen
-  sources += ['src/screen_keydef.c']
+  sources += ['src/screen_keydef.cxx']
 endif
 
 enable_lyrics_screen = get_option('lyrics_screen') and not mini
 conf.set('ENABLE_LYRICS_SCREEN', enable_lyrics_screen)
 if enable_lyrics_screen
-  sources += ['src/screen_lyrics.c', 'src/lyrics.c']
+  sources += ['src/screen_lyrics.cxx', 'src/lyrics.cxx']
 
   lyrics_plugin_dir = get_option('lyrics_plugin_dir')
   if lyrics_plugin_dir == ''
@@ -294,18 +297,18 @@ endif
 enable_outputs_screen = get_option('outputs_screen') and not mini
 conf.set('ENABLE_OUTPUTS_SCREEN', enable_outputs_screen)
 if enable_outputs_screen
-  sources += ['src/screen_outputs.c']
+  sources += ['src/screen_outputs.cxx']
 endif
 
 enable_chat_screen = get_option('chat_screen') and not mini
 conf.set('ENABLE_CHAT_SCREEN', enable_chat_screen)
 if enable_chat_screen
-  sources += ['src/screen_chat.c']
+  sources += ['src/screen_chat.cxx']
   need_screen_text = true
 endif
 
 if need_screen_text
-  sources += ['src/screen_text.c']
+  sources += ['src/screen_text.cxx']
 endif
 
 if need_plugin_library
@@ -313,7 +316,7 @@ if need_plugin_library
     error('Plugins not yet compatible with Windows')
   endif
 
-  sources += ['src/plugin.c']
+  sources += ['src/plugin.cxx']
 endif
 
 if host_machine.system() == 'windows'
@@ -321,40 +324,40 @@ if host_machine.system() == 'windows'
 endif
 
 ncmpc = executable('ncmpc',
-  'src/main.c',
-  'src/gidle.c',
-  'src/mpdclient.c',
-  'src/callbacks.c',
-  'src/playlist.c',
-  'src/filelist.c',
-  'src/options.c',
-  'src/command.c',
-  'src/keyboard.c',
-  'src/ncu.c',
-  'src/player_command.c',
-  'src/title_bar.c',
-  'src/progress_bar.c',
-  'src/status_bar.c',
-  'src/screen.c',
-  'src/screen_init.c',
-  'src/screen_paint.c',
-  'src/screen_utils.c',
-  'src/screen_status.c',
-  'src/screen_list.c',
-  'src/screen_find.c',
-  'src/screen_client.c',
-  'src/screen_queue.c',
-  'src/screen_browser.c',
-  'src/screen_file.c',
-  'src/list_window.c',
-  'src/save_playlist.c',
-  'src/song_paint.c',
-  'src/colors.c',
-  'src/charset.c',
-  'src/wreadln.c',
-  'src/strfsong.c',
-  'src/time_format.c',
-  'src/utils.c',
+  'src/Main.cxx',
+  'src/gidle.cxx',
+  'src/mpdclient.cxx',
+  'src/callbacks.cxx',
+  'src/playlist.cxx',
+  'src/filelist.cxx',
+  'src/options.cxx',
+  'src/command.cxx',
+  'src/keyboard.cxx',
+  'src/ncu.cxx',
+  'src/player_command.cxx',
+  'src/title_bar.cxx',
+  'src/progress_bar.cxx',
+  'src/status_bar.cxx',
+  'src/screen.cxx',
+  'src/screen_init.cxx',
+  'src/screen_paint.cxx',
+  'src/screen_utils.cxx',
+  'src/screen_status.cxx',
+  'src/screen_list.cxx',
+  'src/screen_find.cxx',
+  'src/screen_client.cxx',
+  'src/screen_queue.cxx',
+  'src/screen_browser.cxx',
+  'src/screen_file.cxx',
+  'src/list_window.cxx',
+  'src/save_playlist.cxx',
+  'src/song_paint.cxx',
+  'src/colors.cxx',
+  'src/charset.cxx',
+  'src/wreadln.cxx',
+  'src/strfsong.cxx',
+  'src/time_format.cxx',
+  'src/utils.cxx',
   sources,
   include_directories: inc,
   dependencies: [
similarity index 84%
rename from src/main.c
rename to src/Main.cxx
index eccb5a0..6ca87ed 100644 (file)
  */
 
 #include "config.h"
-#include "ncmpc.h"
-#include "mpdclient.h"
-#include "callbacks.h"
-#include "charset.h"
-#include "options.h"
-#include "command.h"
-#include "ncu.h"
-#include "screen.h"
-#include "screen_status.h"
-#include "xterm_title.h"
-#include "strfsong.h"
+#include "ncmpc.hxx"
+#include "mpdclient.hxx"
+#include "callbacks.hxx"
+#include "charset.hxx"
+#include "options.hxx"
+#include "command.hxx"
+#include "ncu.hxx"
+#include "screen.hxx"
+#include "screen_status.hxx"
+#include "xterm_title.hxx"
+#include "strfsong.hxx"
 #include "i18n.h"
-#include "player_command.h"
-#include "keyboard.h"
-#include "lirc.h"
-#include "signals.h"
+#include "player_command.hxx"
+#include "keyboard.hxx"
+#include "lirc.hxx"
+#include "signals.hxx"
 
 #ifndef NCMPC_MINI
-#include "conf.h"
+#include "conf.hxx"
 #endif
 
 #ifdef ENABLE_LYRICS_SCREEN
-#include "lyrics.h"
+#include "lyrics.hxx"
 #endif
 
 #include <mpd/client.h>
@@ -60,7 +60,7 @@ static const guint update_interval = 500;
 
 #define BUFSIZE 1024
 
-static struct mpdclient *mpd = NULL;
+static struct mpdclient *mpd = nullptr;
 static GMainLoop *main_loop;
 static guint reconnect_source_id, update_source_id;
 
@@ -70,18 +70,18 @@ static guint check_key_bindings_source_id;
 
 #ifndef NCMPC_MINI
 static void
-update_xterm_title(void)
+update_xterm_title()
 {
        const struct mpd_song *song = mpd->song;
 
        char tmp[BUFSIZE];
-       const char *new_title = NULL;
+       const char *new_title = nullptr;
        if (options.xterm_title_format && mpd->playing && song)
                new_title = strfsong(tmp, BUFSIZE, options.xterm_title_format, song) > 0
                        ? tmp
-                       : NULL;
+                       : nullptr;
 
-       if (new_title == NULL)
+       if (new_title == nullptr)
                new_title = PACKAGE " version " VERSION;
 
        static char title[BUFSIZE];
@@ -96,17 +96,17 @@ static gboolean
 timer_mpd_update(gpointer data);
 
 static void
-enable_update_timer(void)
+enable_update_timer()
 {
        if (update_source_id != 0)
                return;
 
        update_source_id = g_timeout_add(update_interval,
-                                        timer_mpd_update, NULL);
+                                        timer_mpd_update, nullptr);
 }
 
 static void
-disable_update_timer(void)
+disable_update_timer()
 {
        if (update_source_id == 0)
                return;
@@ -116,13 +116,13 @@ disable_update_timer(void)
 }
 
 static bool
-should_enable_update_timer(void)
+should_enable_update_timer()
 {
        return mpd->playing;
 }
 
 static void
-auto_update_timer(void)
+auto_update_timer()
 {
        if (should_enable_update_timer())
                enable_update_timer();
@@ -131,7 +131,7 @@ auto_update_timer(void)
 }
 
 static void
-do_mpd_update(void)
+do_mpd_update()
 {
        if (mpdclient_is_connected(mpd) &&
            (mpd->events != 0 || mpd->playing))
@@ -143,7 +143,7 @@ do_mpd_update(void)
 #endif
 
        screen_update(mpd);
-       mpd->events = 0;
+       mpd->events = (enum mpd_idle)0;
 }
 
 /**
@@ -165,11 +165,11 @@ timer_reconnect(gcc_unused gpointer data)
 
        mpdclient_connect(mpd);
 
-       return FALSE;
+       return false;
 }
 
 void
-mpdclient_connected_callback(void)
+mpdclient_connected_callback()
 {
        assert(reconnect_source_id == 0);
 
@@ -187,7 +187,7 @@ mpdclient_connected_callback(void)
 
                /* try again after 30 seconds */
                reconnect_source_id =
-                       g_timeout_add_seconds(30, timer_reconnect, NULL);
+                       g_timeout_add_seconds(30, timer_reconnect, nullptr);
                return;
        }
 #endif
@@ -196,7 +196,7 @@ mpdclient_connected_callback(void)
        doupdate();
 
        /* update immediately */
-       mpd->events = MPD_IDLE_ALL;
+       mpd->events = (enum mpd_idle)MPD_IDLE_ALL;
 
        do_mpd_update();
 
@@ -204,22 +204,22 @@ mpdclient_connected_callback(void)
 }
 
 void
-mpdclient_failed_callback(void)
+mpdclient_failed_callback()
 {
        assert(reconnect_source_id == 0);
 
        /* try again in 5 seconds */
-       reconnect_source_id = g_timeout_add_seconds(5, timer_reconnect, NULL);
+       reconnect_source_id = g_timeout_add_seconds(5, timer_reconnect, nullptr);
 }
 
 void
-mpdclient_lost_callback(void)
+mpdclient_lost_callback()
 {
        assert(reconnect_source_id == 0);
 
        screen_update(mpd);
 
-       reconnect_source_id = g_timeout_add_seconds(1, timer_reconnect, NULL);
+       reconnect_source_id = g_timeout_add_seconds(1, timer_reconnect, nullptr);
 }
 
 /**
@@ -227,7 +227,7 @@ mpdclient_lost_callback(void)
  * idle event (or when the connection dies).
  */
 void
-mpdclient_idle_callback(gcc_unused enum mpd_idle events)
+mpdclient_idle_callback(gcc_unused unsigned events)
 {
 #ifndef NCMPC_MINI
        if (options.enable_xterm_title)
@@ -251,14 +251,14 @@ timer_mpd_update(gcc_unused gpointer data)
        }
 }
 
-void begin_input_event(void)
+void begin_input_event()
 {
 }
 
-void end_input_event(void)
+void end_input_event()
 {
        screen_update(mpd);
-       mpd->events = 0;
+       mpd->events = (enum mpd_idle)0;
 
        auto_update_timer();
 }
@@ -300,11 +300,11 @@ timer_check_key_bindings(gcc_unused gpointer data)
 {
        char buf[256];
 
-       if (check_key_bindings(NULL, buf, sizeof(buf))) {
+       if (check_key_bindings(nullptr, buf, sizeof(buf))) {
                /* no error: disable this timer for the rest of this
                   process */
                check_key_bindings_source_id = 0;
-               return FALSE;
+               return false;
        }
 
 #ifdef ENABLE_KEYDEF_SCREEN
@@ -323,7 +323,7 @@ timer_check_key_bindings(gcc_unused gpointer data)
        screen_status_printf("%s", buf);
 
        doupdate();
-       return TRUE;
+       return true;
 }
 #endif
 
@@ -334,7 +334,7 @@ main(int argc, const char *argv[])
 #ifndef ENABLE_NLS
        gcc_unused
 #endif
-       const char *charset = NULL;
+       const char *charset = nullptr;
        /* time and date formatting */
        setlocale(LC_TIME,"");
        /* care about sorting order etc */
@@ -367,7 +367,7 @@ main(int argc, const char *argv[])
        read_configuration();
 
        /* check key bindings */
-       check_key_bindings(NULL, NULL, 0);
+       check_key_bindings(nullptr, nullptr, 0);
 #endif
 
        /* parse command line options - 2 pass */
@@ -388,7 +388,7 @@ main(int argc, const char *argv[])
        screen_init(mpd);
 
        /* the main loop */
-       main_loop = g_main_loop_new(NULL, FALSE);
+       main_loop = g_main_loop_new(nullptr, false);
 
        /* watch out for keyboard input */
        keyboard_init();
@@ -399,13 +399,13 @@ main(int argc, const char *argv[])
        signals_init(main_loop, mpd);
 
        /* attempt to connect */
-       reconnect_source_id = g_idle_add(timer_reconnect, NULL);
+       reconnect_source_id = g_idle_add(timer_reconnect, nullptr);
 
        auto_update_timer();
 
 #ifndef NCMPC_MINI
        check_key_bindings_source_id =
-               g_timeout_add_seconds(10, timer_check_key_bindings, NULL);
+               g_timeout_add_seconds(10, timer_check_key_bindings, nullptr);
 #endif
 
        screen_paint(mpd, true);
similarity index 92%
rename from src/aconnect.c
rename to src/aconnect.cxx
index 82085ed..65615ed 100644 (file)
@@ -26,9 +26,9 @@
    SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 */
 
-#include "aconnect.h"
-#include "net/async_rconnect.h"
-#include "net/socket.h"
+#include "aconnect.hxx"
+#include "net/async_rconnect.hxx"
+#include "net/socket.hxx"
 #include "Compiler.h"
 
 #include <mpd/client.h>
@@ -56,7 +56,7 @@ aconnect_source_callback(gcc_unused GIOChannel *source,
                         gcc_unused GIOCondition condition,
                         gpointer data)
 {
-       struct aconnect *ac = data;
+       auto *ac = (struct aconnect *)data;
        assert(ac->source_id != 0);
        ac->source_id = 0;
 
@@ -83,7 +83,7 @@ aconnect_source_callback(gcc_unused GIOChannel *source,
        buffer[nbytes] = 0;
 
        struct mpd_async *async = mpd_async_new(ac->fd);
-       if (async == NULL) {
+       if (async == nullptr) {
                close_socket(ac->fd);
                ac->handler->error("Out of memory", ac->handler_ctx);
                g_free(ac);
@@ -91,7 +91,7 @@ aconnect_source_callback(gcc_unused GIOChannel *source,
        }
 
        struct mpd_connection *c = mpd_connection_new_async(async, buffer);
-       if (c == NULL) {
+       if (c == nullptr) {
                mpd_async_free(async);
                ac->handler->error("Out of memory", ac->handler_ctx);
                g_free(ac);
@@ -106,8 +106,8 @@ aconnect_source_callback(gcc_unused GIOChannel *source,
 static void
 aconnect_rconnect_success(int fd, void *ctx)
 {
-       struct aconnect *ac = ctx;
-       ac->rconnect = NULL;
+       auto *ac = (struct aconnect *)ctx;
+       ac->rconnect = nullptr;
 
        ac->fd = fd;
 
@@ -120,8 +120,8 @@ aconnect_rconnect_success(int fd, void *ctx)
 static void
 aconnect_rconnect_error(const char *message, void *ctx)
 {
-       struct aconnect *ac = ctx;
-       ac->rconnect = NULL;
+       auto *ac = (struct aconnect *)ctx;
+       ac->rconnect = nullptr;
 
        ac->handler->error(message, ac->handler_ctx);
        g_free(ac);
@@ -150,7 +150,7 @@ aconnect_start(struct aconnect **acp,
 void
 aconnect_cancel(struct aconnect *ac)
 {
-       if (ac->rconnect != NULL)
+       if (ac->rconnect != nullptr)
                async_rconnect_cancel(ac->rconnect);
        else {
                g_source_remove(ac->source_id);
similarity index 100%
rename from src/aconnect.h
rename to src/aconnect.hxx
similarity index 88%
rename from src/callbacks.c
rename to src/callbacks.cxx
index 90eb409..caa5367 100644 (file)
  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
  */
 
-#include "callbacks.h"
-#include "screen_utils.h"
-#include "screen_status.h"
-#include "mpdclient.h"
+#include "callbacks.hxx"
+#include "screen_utils.hxx"
+#include "screen_status.hxx"
+#include "mpdclient.hxx"
 
 static bool
 _mpdclient_auth_callback(struct mpdclient *c, gint recursion)
 {
        struct mpd_connection *connection = mpdclient_get_connection(c);
-       if (connection == NULL)
+       if (connection == nullptr)
                return false;
 
        mpd_connection_clear_error(connection);
        if (recursion > 2)
                return false;
 
-       char *password = screen_read_password(NULL);
-       if (password == NULL)
+       char *password = screen_read_password(nullptr);
+       if (password == nullptr)
                return false;
 
        mpd_send_password(connection, password);
similarity index 90%
rename from src/callbacks.h
rename to src/callbacks.hxx
index 6c315e4..857016d 100644 (file)
 
 #include <mpd/client.h>
 
-#include <stdbool.h>
-
 struct mpdclient;
 
 /**
  * A connection to MPD has been established.
  */
 void
-mpdclient_connected_callback(void);
+mpdclient_connected_callback();
 
 /**
  * An attempt to connect to MPD has failed.
  * mpdclient_error_callback() has been called already.
  */
 void
-mpdclient_failed_callback(void);
+mpdclient_failed_callback();
 
 /**
  * The connection to MPD was lost.  If this was due to an error, then
  * mpdclient_error_callback() has already been called.
  */
 void
-mpdclient_lost_callback(void);
+mpdclient_lost_callback();
 
 /**
  * To be implemented by the application: mpdclient.c calls this to
@@ -59,6 +57,6 @@ bool
 mpdclient_auth_callback(struct mpdclient *c);
 
 void
-mpdclient_idle_callback(enum mpd_idle events);
+mpdclient_idle_callback(unsigned events);
 
 #endif
similarity index 89%
rename from src/charset.c
rename to src/charset.cxx
index 61a34cb..e591a14 100644 (file)
@@ -17,7 +17,7 @@
  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
  */
 
-#include "charset.h"
+#include "charset.hxx"
 
 #include <assert.h>
 #include <string.h>
@@ -28,7 +28,7 @@ static bool noconvert = true;
 static const char *charset;
 
 const char *
-charset_init(void)
+charset_init()
 {
        noconvert = g_get_charset(&charset);
        return charset;
@@ -52,13 +52,13 @@ unicode_char_width(gunichar ch)
 unsigned
 utf8_width(const char *str)
 {
-       assert(str != NULL);
+       assert(str != nullptr);
 
 #if defined(ENABLE_MULTIBYTE) && !defined(HAVE_CURSES_ENHANCED)
        return g_utf8_strlen(str, -1);
 #else
 #ifdef HAVE_CURSES_ENHANCED
-       if (g_utf8_validate(str, -1, NULL)) {
+       if (g_utf8_validate(str, -1, nullptr)) {
                size_t len = g_utf8_strlen(str, -1);
                unsigned width = 0;
                gunichar c;
@@ -66,7 +66,7 @@ utf8_width(const char *str)
                while (len--) {
                        c = g_utf8_get_char(str);
                        width += unicode_char_width(c);
-                       str += g_unichar_to_utf8(c, NULL);
+                       str += g_unichar_to_utf8(c, nullptr);
                }
 
                return width;
@@ -137,7 +137,7 @@ wide_cut_width(char *p, unsigned max_width)
                        return prev_width;
                }
 
-               p += g_unichar_to_utf8(c, NULL);
+               p += g_unichar_to_utf8(c, nullptr);
        }
 
        return width;
@@ -146,10 +146,10 @@ wide_cut_width(char *p, unsigned max_width)
 unsigned
 utf8_cut_width(char *p, unsigned max_width)
 {
-       assert(p != NULL);
+       assert(p != nullptr);
 
 #ifdef HAVE_CURSES_ENHANCED
-       if (!g_utf8_validate(p, -1, NULL))
+       if (!g_utf8_validate(p, -1, nullptr))
                return ascii_cut_width(p, max_width);
 
        return wide_cut_width(p, max_width);
@@ -164,15 +164,15 @@ char *
 utf8_to_locale(const char *utf8str)
 {
 #ifdef ENABLE_LOCALE
-       assert(utf8str != NULL);
+       assert(utf8str != nullptr);
 
        if (noconvert)
                return g_strdup(utf8str);
 
        gchar *str = g_convert_with_fallback(utf8str, -1,
                                             charset, "utf-8",
-                                            NULL, NULL, NULL, NULL);
-       if (str == NULL)
+                                            nullptr, nullptr, nullptr, nullptr);
+       if (str == nullptr)
                return g_strdup(utf8str);
 
        return str;
@@ -185,15 +185,15 @@ char *
 locale_to_utf8(const char *localestr)
 {
 #ifdef ENABLE_LOCALE
-       assert(localestr != NULL);
+       assert(localestr != nullptr);
 
        if (noconvert)
                return g_strdup(localestr);
 
        gchar *str = g_convert_with_fallback(localestr, -1,
                                             "utf-8", charset,
-                                            NULL, NULL, NULL, NULL);
-       if (str == NULL)
+                                            nullptr, nullptr, nullptr, nullptr);
+       if (str == nullptr)
                return g_strdup(localestr);
 
        return str;
@@ -206,7 +206,7 @@ char *
 replace_utf8_to_locale(char *src)
 {
 #ifdef ENABLE_LOCALE
-       assert(src != NULL);
+       assert(src != nullptr);
 
        if (noconvert)
                return src;
@@ -222,7 +222,7 @@ char *
 replace_locale_to_utf8(char *src)
 {
 #ifdef ENABLE_LOCALE
-       assert(src != NULL);
+       assert(src != nullptr);
 
        if (noconvert)
                return src;
similarity index 97%
rename from src/charset.h
rename to src/charset.hxx
index b07d5fa..dbc0031 100644 (file)
 #include "config.h"
 #include "Compiler.h"
 
-#include <stdbool.h>
-
 #ifdef ENABLE_LOCALE
 const char *
-charset_init(void);
+charset_init();
 #endif
 
 /**
similarity index 76%
rename from src/colors.c
rename to src/colors.cxx
index 5a79fd9..aab2975 100644 (file)
  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
  */
 
-#include "colors.h"
+#include "colors.hxx"
 #include "i18n.h"
 #include "ncfix.h"
 
 #ifdef ENABLE_COLORS
-#include "options.h"
+#include "options.hxx"
 #endif
 
 #include <assert.h>
@@ -49,35 +49,36 @@ typedef struct {
 
 static color_entry_t colors[COLOR_END] = {
        /* color pair = field name, color, mono */
-       [COLOR_TITLE]        = {"title",             COLOR_YELLOW,          A_NORMAL},
-       [COLOR_TITLE_BOLD]   = {"title-bold",        COLOR_YELLOW | A_BOLD, A_BOLD  },
-       [COLOR_LINE]         = {"line",              COLOR_WHITE,           A_NORMAL},
-       [COLOR_LINE_BOLD]    = {"line-bold",         COLOR_WHITE  | A_BOLD, A_BOLD  },
-       [COLOR_LINE_FLAGS]   = {"line-flags",        COLOR_YELLOW,          A_NORMAL},
-       [COLOR_LIST]         = {"list",              COLOR_GREEN,           A_NORMAL},
-       [COLOR_LIST_BOLD]    = {"list-bold",         COLOR_GREEN  | A_BOLD, A_BOLD  },
-       [COLOR_PROGRESSBAR]  = {"progressbar",       COLOR_WHITE,           A_NORMAL},
-       [COLOR_STATUS]       = {"status-song",       COLOR_YELLOW,          A_NORMAL},
-       [COLOR_STATUS_BOLD]  = {"status-state",      COLOR_YELLOW | A_BOLD, A_BOLD  },
-       [COLOR_STATUS_TIME]  = {"status-time",       COLOR_RED,             A_NORMAL},
-       [COLOR_STATUS_ALERT] = {"alert",             COLOR_RED    | A_BOLD, A_BOLD  },
-       [COLOR_DIRECTORY]    = {"browser-directory", COLOR_YELLOW,          A_NORMAL},
-       [COLOR_PLAYLIST]     = {"browser-playlist",  COLOR_RED,             A_NORMAL},
-       [COLOR_BACKGROUND]   = {"background",        COLOR_BLACK,           A_NORMAL},
+       {nullptr, 0, 0},
+       {"title",             COLOR_YELLOW,          A_NORMAL},
+       {"title-bold",        COLOR_YELLOW | A_BOLD, A_BOLD  },
+       {"line",              COLOR_WHITE,           A_NORMAL},
+       {"line-bold",         COLOR_WHITE  | A_BOLD, A_BOLD  },
+       {"line-flags",        COLOR_YELLOW,          A_NORMAL},
+       {"list",              COLOR_GREEN,           A_NORMAL},
+       {"list-bold",         COLOR_GREEN  | A_BOLD, A_BOLD  },
+       {"progressbar",       COLOR_WHITE,           A_NORMAL},
+       {"status-song",       COLOR_YELLOW,          A_NORMAL},
+       {"status-state",      COLOR_YELLOW | A_BOLD, A_BOLD  },
+       {"status-time",       COLOR_RED,             A_NORMAL},
+       {"alert",             COLOR_RED    | A_BOLD, A_BOLD  },
+       {"browser-directory", COLOR_YELLOW,          A_NORMAL},
+       {"browser-playlist",  COLOR_RED,             A_NORMAL},
+       {"background",        COLOR_BLACK,           A_NORMAL},
 };
 
 #ifdef ENABLE_COLORS
 
-static GList *color_definition_list = NULL;
+static GList *color_definition_list = nullptr;
 
 static color_entry_t *
 colors_lookup_by_name(const char *name)
 {
-       for (enum color i = 1; i < COLOR_END; ++i)
+       for (unsigned i = 1; i < COLOR_END; ++i)
                if (!strcasecmp(colors[i].name, name))
                        return &colors[i];
 
-       return NULL;
+       return nullptr;
 }
 
 static void
@@ -173,8 +174,7 @@ colors_define(const char *name, short r, short g, short b)
        if (color < 0)
                return false;
 
-       color_definition_entry_t *entry =
-               g_malloc(sizeof(color_definition_entry_t));
+       auto *entry = g_new(color_definition_entry_t, 1);
        entry->color = color;
        entry->r = r;
        entry->g = g;
@@ -205,7 +205,7 @@ colors_assign(const char *name, const char *value)
 }
 
 void
-colors_start(void)
+colors_start()
 {
        if (has_colors()) {
                /* initialize color support */
@@ -216,7 +216,7 @@ colors_start(void)
                        GList *list = color_definition_list;
 
                        while (list) {
-                               color_definition_entry_t *entry = list->data;
+                               auto *entry = (color_definition_entry_t *)list->data;
 
                                if (entry->color <= COLORS)
                                        init_color(entry->color, entry->r,
@@ -228,9 +228,9 @@ colors_start(void)
                                _("Terminal lacks support for changing colors"));
 
                if (options.enable_colors) {
-                       for (enum color i = 1; i < COLOR_END; ++i)
+                       for (unsigned i = 1; i < COLOR_END; ++i)
                                /* update the color pairs */
-                               colors_update_pair(i);
+                               colors_update_pair((enum color)i);
                }
        } else if (options.enable_colors) {
                fprintf(stderr, "%s\n",
@@ -241,7 +241,7 @@ colors_start(void)
        /* free the color_definition_list */
        if (color_definition_list) {
                g_list_free_full(color_definition_list, g_free);
-               color_definition_list = NULL;
+               color_definition_list = nullptr;
        }
 }
 #endif
@@ -255,13 +255,13 @@ colors_use(WINDOW *w, enum color id)
 
        attr_t attrs;
        short pair;
-       fix_wattr_get(w, &attrs, &pair, NULL);
+       fix_wattr_get(w, &attrs, &pair, nullptr);
 
 #ifdef ENABLE_COLORS
        if (options.enable_colors) {
                /* color mode */
                if ((int)attrs != entry->color || (short)id != pair)
-                       wattr_set(w, entry->color, id, NULL);
+                       wattr_set(w, entry->color, id, nullptr);
        } else {
 #endif
                /* mono mode */
similarity index 97%
rename from src/colors.h
rename to src/colors.hxx
index deb9105..d6efb2c 100644 (file)
@@ -24,7 +24,6 @@
 #include "ncmpc_curses.h"
 #include "Compiler.h"
 
-#include <stdbool.h>
 
 enum color {
        COLOR_TITLE = 1,
@@ -56,7 +55,7 @@ bool
 colors_define(const char *name, short r, short g, short b);
 
 void
-colors_start(void);
+colors_start();
 #endif
 
 void
similarity index 98%
rename from src/command.c
rename to src/command.cxx
index f903165..0b46149 100644 (file)
@@ -17,7 +17,7 @@
  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
  */
 
-#include "command.h"
+#include "command.hxx"
 #include "i18n.h"
 #include "ncmpc_curses.h"
 
@@ -248,12 +248,12 @@ static command_definition_t cmds[] = {
          N_("Chat screen") },
 #endif
 
-       { { -1, -1, -1 }, 0, CMD_NONE, NULL, NULL }
+       { { -1, -1, -1 }, 0, CMD_NONE, nullptr, nullptr }
 };
 
 #ifdef ENABLE_KEYDEF_SCREEN
 command_definition_t *
-get_command_definitions(void)
+get_command_definitions()
 {
        return cmds;
 }
@@ -266,7 +266,7 @@ get_cmds_max_name_width(command_definition_t *c)
        if (max != 0)
                return max;
 
-       for (command_definition_t *p = c; p->name != NULL; p++) {
+       for (command_definition_t *p = c; p->name != nullptr; p++) {
                /*
                 * width and length are considered the same here, as command
                 * names are not translated.
@@ -339,7 +339,7 @@ key2str(int key)
 }
 
 void
-command_dump_keys(void)
+command_dump_keys()
 {
        for (size_t i = 0; cmds[i].description; i++)
                if (cmds[i].command != CMD_NONE)
@@ -382,7 +382,7 @@ get_key_names(command_t command, bool all)
                        return keystr;
                }
        }
-       return NULL;
+       return nullptr;
 }
 
 const char *
@@ -392,7 +392,7 @@ get_key_description(command_t command)
                if (cmds[i].command == command)
                        return _(cmds[i].description);
 
-       return NULL;
+       return nullptr;
 }
 
 const char *
@@ -402,7 +402,7 @@ get_key_command_name(command_t command)
                if (cmds[i].command == command)
                        return cmds[i].name;
 
-       return NULL;
+       return nullptr;
 }
 
 command_t
@@ -419,7 +419,7 @@ command_t
 find_key_command(int key, const command_definition_t *c)
 {
        assert(key != 0);
-       assert(c != NULL);
+       assert(c != nullptr);
 
        for (size_t i = 0; c[i].name; i++) {
                for (int j = 0; j < MAX_COMMAND_KEYS; j++)
@@ -459,7 +459,7 @@ check_key_bindings(command_definition_t *cp, char *buf, size_t bufsize)
 {
        bool success = true;
 
-       if (cp == NULL)
+       if (cp == nullptr)
                cp = cmds;
 
        for (size_t i = 0; cp[i].name; i++)
similarity index 97%
rename from src/command.h
rename to src/command.hxx
index aa794c6..2f67a37 100644 (file)
@@ -24,7 +24,6 @@
 #include "Compiler.h"
 
 #include <stddef.h>
-#include <stdbool.h>
 
 #ifndef NCMPC_MINI
 #include <stdio.h>
@@ -127,7 +126,7 @@ typedef struct  {
 } command_definition_t;
 
 #ifdef ENABLE_KEYDEF_SCREEN
-command_definition_t *get_command_definitions(void);
+command_definition_t *get_command_definitions();
 size_t get_cmds_max_name_width(command_definition_t *cmds);
 #endif
 
@@ -135,7 +134,7 @@ gcc_pure
 command_t
 find_key_command(int key, const command_definition_t *cmds);
 
-void command_dump_keys(void);
+void command_dump_keys();
 
 #ifndef NCMPC_MINI
 
similarity index 92%
rename from src/conf.c
rename to src/conf.cxx
index 81c280a..4de2412 100644 (file)
  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
  */
 
-#include "conf.h"
+#include "conf.hxx"
 #include "config.h"
-#include "defaults.h"
+#include "defaults.hxx"
 #include "i18n.h"
-#include "command.h"
-#include "colors.h"
-#include "screen_list.h"
-#include "options.h"
+#include "command.hxx"
+#include "colors.hxx"
+#include "screen_list.hxx"
+#include "options.hxx"
 
 #include <assert.h>
 #include <ctype.h>
@@ -133,7 +133,7 @@ after_unquoted_word(char *p)
 {
        if (!is_word_char(*p)) {
                print_error(_("Word expected"), p);
-               return NULL;
+               return nullptr;
        }
 
        ++p;
@@ -241,11 +241,11 @@ static char *
 separate_value(char *p)
 {
        char *value = strchr(p, '=');
-       if (value == NULL) {
+       if (value == nullptr) {
                /* an equals sign '=' was expected while parsing a
                   configuration file line */
                fprintf(stderr, "%s\n", _("Missing '='"));
-               return NULL;
+               return nullptr;
        }
 
        *value++ = 0;
@@ -258,7 +258,7 @@ static bool
 parse_color(char *str)
 {
        char *value = separate_value(str);
-       if (value == NULL)
+       if (value == nullptr)
                return false;
 
        return colors_assign(str, value);
@@ -274,7 +274,7 @@ after_comma(char *p)
 {
        char *comma = strchr(p, ',');
 
-       if (comma != NULL) {
+       if (comma != nullptr) {
                *comma++ = 0;
                comma = skip_spaces(comma);
        } else
@@ -288,7 +288,7 @@ static bool
 parse_color_definition(char *str)
 {
        char *value = separate_value(str);
-       if (value == NULL)
+       if (value == nullptr)
                return false;
 
        /* get the command name */
@@ -344,27 +344,27 @@ static char **
 check_screen_list(char *value)
 {
        char **tmp = g_strsplit_set(value, " \t,", 100);
-       char **screen = NULL;
+       char **screen = nullptr;
        int i = 0, j = 0;
 
        while( tmp && tmp[i] ) {
                char *name = g_ascii_strdown(tmp[i], -1);
                if (*name != '\0') {
-                       if (screen_lookup_name(name) == NULL) {
+                       if (screen_lookup_name(name) == nullptr) {
                                /* an unknown screen name was specified in the
                                   configuration file */
                                print_error(_("Unknown screen name"), name);
                                free(name);
                        } else {
-                               screen = g_realloc(screen, (j+2)*sizeof(char *));
+                               screen = (char **)g_realloc(screen, (j+2)*sizeof(char *));
                                screen[j++] = name;
-                               screen[j] = NULL;
+                               screen[j] = nullptr;
                        }
                }
                i++;
        }
        g_strfreev(tmp);
-       if( screen == NULL )
+       if( screen == nullptr )
                return g_strsplit_set(DEFAULT_SCREEN_LIST, " ", 0);
 
        return screen;
@@ -416,7 +416,7 @@ parse_line(char *line)
        /* get the name part */
        char *const name = line;
        char *const name_end = after_unquoted_word(line);
-       if (name_end == NULL)
+       if (name_end == nullptr)
                return false;
 
        line = skip_spaces(name_end);
@@ -604,16 +604,16 @@ parse_line(char *line)
 static int
 read_rc_file(char *filename)
 {
-       assert(filename != NULL);
+       assert(filename != nullptr);
 
        FILE *file = fopen(filename, "r");
-       if (file == NULL) {
+       if (file == nullptr) {
                perror(filename);
                return -1;
        }
 
        char line[MAX_LINE_LENGTH];
-       while (fgets(line, sizeof(line), file) != NULL) {
+       while (fgets(line, sizeof(line), file) != nullptr) {
                char *p = skip_spaces(line);
 
                if (*p != 0 && *p != COMMENT_TOKEN)
@@ -625,9 +625,9 @@ read_rc_file(char *filename)
 }
 
 bool
-check_user_conf_dir(void)
+check_user_conf_dir()
 {
-       char *directory = g_build_filename(g_get_home_dir(), "." PACKAGE, NULL);
+       char *directory = g_build_filename(g_get_home_dir(), "." PACKAGE, nullptr);
 
        if (g_file_test(directory, G_FILE_TEST_IS_DIR)) {
                g_free(directory);
@@ -640,25 +640,25 @@ check_user_conf_dir(void)
 }
 
 char *
-build_user_conf_filename(void)
+build_user_conf_filename()
 {
 #ifdef WIN32
-       return g_build_filename(g_get_user_config_dir(), PACKAGE, "ncmpc.conf", NULL);
+       return g_build_filename(g_get_user_config_dir(), PACKAGE, "ncmpc.conf", nullptr);
 #else
-       return g_build_filename(g_get_home_dir(), "." PACKAGE, "config", NULL);
+       return g_build_filename(g_get_home_dir(), "." PACKAGE, "config", nullptr);
 #endif
 }
 
 char *
-build_system_conf_filename(void)
+build_system_conf_filename()
 {
 #ifdef WIN32
        const gchar* const *system_data_dirs;
-       gchar *pathname = NULL;
+       gchar *pathname = nullptr;
 
-       for (system_data_dirs = g_get_system_config_dirs (); *system_data_dirs != NULL; system_data_dirs++)
+       for (system_data_dirs = g_get_system_config_dirs (); *system_data_dirs != nullptr; system_data_dirs++)
        {
-               pathname = g_build_filename(*system_data_dirs, PACKAGE, "ncmpc.conf", NULL);
+               pathname = g_build_filename(*system_data_dirs, PACKAGE, "ncmpc.conf", nullptr);
                if (g_file_test(pathname, G_FILE_TEST_EXISTS))
                {
                        break;
@@ -666,35 +666,35 @@ build_system_conf_filename(void)
                else
                {
                        g_free (pathname);
-                       pathname = NULL;
+                       pathname = nullptr;
                }
        }
        return pathname;
 #else
-       return g_build_filename(SYSCONFDIR, PACKAGE, "config", NULL);
+       return g_build_filename(SYSCONFDIR, PACKAGE, "config", nullptr);
 #endif
 }
 
 char *
-build_user_key_binding_filename(void)
+build_user_key_binding_filename()
 {
 #ifdef WIN32
-       return g_build_filename(g_get_user_config_dir(), PACKAGE, "keys.conf", NULL);
+       return g_build_filename(g_get_user_config_dir(), PACKAGE, "keys.conf", nullptr);
 #else
-       return g_build_filename(g_get_home_dir(), "." PACKAGE, "keys", NULL);
+       return g_build_filename(g_get_home_dir(), "." PACKAGE, "keys", nullptr);
 #endif
 }
 
 static char *
-g_build_system_key_binding_filename(void)
+g_build_system_key_binding_filename()
 {
 #ifdef WIN32
        const gchar* const *system_data_dirs;
-       gchar *pathname = NULL;
+       gchar *pathname = nullptr;
 
-       for (system_data_dirs = g_get_system_config_dirs (); *system_data_dirs != NULL; system_data_dirs++)
+       for (system_data_dirs = g_get_system_config_dirs (); *system_data_dirs != nullptr; system_data_dirs++)
        {
-               pathname = g_build_filename(*system_data_dirs, PACKAGE, "keys.conf", NULL);
+               pathname = g_build_filename(*system_data_dirs, PACKAGE, "keys.conf", nullptr);
                if (g_file_test(pathname, G_FILE_TEST_EXISTS))
                {
                        break;
@@ -702,20 +702,20 @@ g_build_system_key_binding_filename(void)
                else
                {
                        g_free (pathname);
-                       pathname = NULL;
+                       pathname = nullptr;
                }
        }
        return pathname;
 #else
-       return g_build_filename(SYSCONFDIR, PACKAGE, "keys", NULL);
+       return g_build_filename(SYSCONFDIR, PACKAGE, "keys", nullptr);
 #endif
 }
 
 static char *
-find_config_file(void)
+find_config_file()
 {
        /* check for command line configuration file */
-       if (options.config_file != NULL)
+       if (options.config_file != nullptr)
                return g_strdup(options.config_file);
 
        /* check for user configuration ~/.ncmpc/config */
@@ -731,14 +731,14 @@ find_config_file(void)
                return filename;
 
        g_free(filename);
-       return NULL;
+       return nullptr;
 }
 
 static char *
-find_keys_file(void)
+find_keys_file()
 {
        /* check for command line key binding file */
-       if (options.key_file != NULL)
+       if (options.key_file != nullptr)
                return g_strdup(options.key_file);
 
        /* check for  user key bindings ~/.ncmpc/keys */
@@ -754,22 +754,22 @@ find_keys_file(void)
                return filename;
 
        g_free(filename);
-       return NULL;
+       return nullptr;
 }
 
 void
-read_configuration(void)
+read_configuration()
 {
        /* load configuration */
        char *filename = find_config_file();
-       if (filename != NULL) {
+       if (filename != nullptr) {
                read_rc_file(filename);
                g_free(filename);
        }
 
        /* load key bindings */
        filename = find_keys_file();
-       if (filename != NULL) {
+       if (filename != nullptr) {
                read_rc_file(filename);
                g_free(filename);
        }
diff --git a/src/conf.h b/src/conf.h
deleted file mode 100644 (file)
index d3a2694..0000000
+++ /dev/null
@@ -1,31 +0,0 @@
-/* ncmpc (Ncurses MPD Client)
- * (c) 2004-2017 The Music Player Daemon Project
- * Project homepage: http://musicpd.org
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
- */
-
-#include <stdbool.h>
-
-bool
-check_user_conf_dir(void);
-
-char *build_user_conf_filename(void);
-char *build_system_conf_filename(void);
-
-char *build_user_key_binding_filename(void);
-
-void read_configuration(void);
-
diff --git a/src/conf.hxx b/src/conf.hxx
new file mode 100644 (file)
index 0000000..4247c32
--- /dev/null
@@ -0,0 +1,29 @@
+/* ncmpc (Ncurses MPD Client)
+ * (c) 2004-2017 The Music Player Daemon Project
+ * Project homepage: http://musicpd.org
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ */
+
+bool
+check_user_conf_dir();
+
+char *build_user_conf_filename();
+char *build_system_conf_filename();
+
+char *build_user_key_binding_filename();
+
+void read_configuration();
+
similarity index 90%
rename from src/db_completion.c
rename to src/db_completion.cxx
index 025b426..31c0f03 100644 (file)
  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
  */
 
-#include "db_completion.h"
-#include "charset.h"
-#include "mpdclient.h"
+#include "db_completion.hxx"
+#include "charset.hxx"
+#include "mpdclient.hxx"
 
 GList *
 gcmp_list_from_path(struct mpdclient *c, const gchar *path,
                    GList *list, gint types)
 {
        struct mpd_connection *connection = mpdclient_get_connection(c);
-       if (connection == NULL)
+       if (connection == nullptr)
                return list;
 
        mpd_send_list_meta(connection, path);
 
        struct mpd_entity *entity;
-       while ((entity = mpd_recv_entity(connection)) != NULL) {
+       while ((entity = mpd_recv_entity(connection)) != nullptr) {
                char *name;
 
                if (mpd_entity_get_type(entity) == MPD_ENTITY_TYPE_DIRECTORY &&
@@ -40,7 +40,7 @@ gcmp_list_from_path(struct mpdclient *c, const gchar *path,
                        const struct mpd_directory *dir =
                                mpd_entity_get_directory(entity);
                        gchar *tmp = utf8_to_locale(mpd_directory_get_path(dir));
-                       name = g_strconcat(tmp, "/", NULL);
+                       name = g_strconcat(tmp, "/", nullptr);
                        g_free(tmp);
                } else if (mpd_entity_get_type(entity) == MPD_ENTITY_TYPE_SONG &&
                           types & GCMP_TYPE_FILE) {
similarity index 100%
rename from src/db_completion.h
rename to src/db_completion.hxx
similarity index 97%
rename from src/defaults.h
rename to src/defaults.hxx
index 258a874..6a955a9 100644 (file)
@@ -34,7 +34,7 @@
 
 #define DEFAULT_LYRICS_TIMEOUT 100
 
-#define DEFAULT_SCROLL TRUE
+#define DEFAULT_SCROLL true
 #define DEFAULT_SCROLL_SEP " *** "
 
 #endif
similarity index 87%
rename from src/filelist.c
rename to src/filelist.cxx
index 0b85868..d6450b4 100644 (file)
  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
  */
 
-#include "filelist.h"
+#include "filelist.hxx"
 
 #include <mpd/client.h>
 
-#include <stdbool.h>
 #include <string.h>
 #include <assert.h>
 
 struct filelist *
-filelist_new(void)
+filelist_new()
 {
-       struct filelist *filelist = g_malloc(sizeof(*filelist));
+       struct filelist *filelist = g_new(struct filelist, 1);
 
        filelist->entries = g_ptr_array_new();
 
@@ -47,7 +46,7 @@ filelist_free(struct filelist *filelist)
                g_slice_free(struct filelist_entry, entry);
        }
 
-       g_ptr_array_free(filelist->entries, TRUE);
+       g_ptr_array_free(filelist->entries, true);
        g_free(filelist);
 }
 
@@ -77,7 +76,7 @@ filelist_move(struct filelist *filelist, struct filelist *from)
 static gint
 filelist_compare_indirect(gconstpointer ap, gconstpointer bp, gpointer data)
 {
-       GCompareFunc compare_func = data;
+       GCompareFunc compare_func = (GCompareFunc)data;
        gconstpointer a = *(const gconstpointer*)ap;
        gconstpointer b = *(const gconstpointer*)bp;
 
@@ -94,7 +93,7 @@ compare_filelist_entry_path(gconstpointer filelist_entry1,
        e2 = ((const struct filelist_entry *)filelist_entry2)->entity;
 
        int n = 0;
-       if (e1 != NULL && e2 != NULL &&
+       if (e1 != nullptr && e2 != nullptr &&
            mpd_entity_get_type(e1) == mpd_entity_get_type(e2)) {
                switch (mpd_entity_get_type(e1)) {
                case MPD_ENTITY_TYPE_UNKNOWN:
@@ -118,8 +117,8 @@ void
 filelist_sort_all(struct filelist *filelist, GCompareFunc compare_func)
 {
        g_ptr_array_sort_with_data(filelist->entries,
-                       filelist_compare_indirect,
-                       compare_func);
+                                  filelist_compare_indirect,
+                                  (gpointer)compare_func);
 }
 
 
@@ -135,9 +134,9 @@ filelist_sort_dir_play(struct filelist *filelist, GCompareFunc compare_func)
        if (filelist->entries->len < 2)
                return;
 
-       /* If the first entry is NULL, skip it, because NULL stands for "[..]" */
+       /* If the first entry is nullptr, skip it, because nullptr stands for "[..]" */
        iter = ((struct filelist_entry*) g_ptr_array_index(filelist->entries, 0))->entity;
-       unsigned first = iter == NULL ? 1 : 0, last;
+       unsigned first = iter == nullptr ? 1 : 0, last;
 
        /* find the last directory entry */
        for (last = first+1; last < filelist->entries->len; last++) {
@@ -150,8 +149,8 @@ filelist_sort_dir_play(struct filelist *filelist, GCompareFunc compare_func)
        /* sort the directories */
        if (last - first > 1)
                g_qsort_with_data(filelist->entries->pdata + first,
-                               last - first, sizeof(gpointer),
-                               filelist_compare_indirect, compare_func);
+                                 last - first, sizeof(gpointer),
+                                 filelist_compare_indirect, (gpointer)compare_func);
        /* find the first playlist entry */
        for (first = last; first < filelist->entries->len; first++) {
                iter = ((struct filelist_entry*) g_ptr_array_index(filelist->entries, first))->entity;
@@ -161,8 +160,9 @@ filelist_sort_dir_play(struct filelist *filelist, GCompareFunc compare_func)
        /* sort the playlist entries */
        if (filelist->entries->len - first > 1)
                g_qsort_with_data(filelist->entries->pdata + first,
-                               filelist->entries->len - first, sizeof(gpointer),
-                               filelist_compare_indirect, compare_func);
+                                 filelist->entries->len - first, sizeof(gpointer),
+                                 filelist_compare_indirect,
+                                 (gpointer)compare_func);
 }
 
 void
@@ -172,7 +172,7 @@ filelist_no_duplicates(struct filelist *filelist)
                struct filelist_entry *entry = filelist_get(filelist, i);
                const struct mpd_song *song;
 
-               if (entry->entity == NULL ||
+               if (entry->entity == nullptr ||
                    mpd_entity_get_type(entry->entity) != MPD_ENTITY_TYPE_SONG)
                        continue;
 
@@ -194,13 +194,13 @@ same_song(const struct mpd_song *a, const struct mpd_song *b)
 int
 filelist_find_song(const struct filelist *fl, const struct mpd_song *song)
 {
-       assert(song != NULL);
+       assert(song != nullptr);
 
        for (unsigned i = 0; i < filelist_length(fl); ++i) {
                struct filelist_entry *entry = filelist_get(fl, i);
                const struct mpd_entity *entity  = entry->entity;
 
-               if (entity != NULL &&
+               if (entity != nullptr &&
                    mpd_entity_get_type(entity) == MPD_ENTITY_TYPE_SONG) {
                        const struct mpd_song *song2 =
                                mpd_entity_get_song(entity);
@@ -216,13 +216,13 @@ filelist_find_song(const struct filelist *fl, const struct mpd_song *song)
 int
 filelist_find_directory(const struct filelist *filelist, const char *name)
 {
-       assert(name != NULL);
+       assert(name != nullptr);
 
        for (unsigned i = 0; i < filelist_length(filelist); ++i) {
                struct filelist_entry *entry = filelist_get(filelist, i);
                const struct mpd_entity *entity  = entry->entity;
 
-               if (entity != NULL &&
+               if (entity != nullptr &&
                    mpd_entity_get_type(entity) == MPD_ENTITY_TYPE_DIRECTORY &&
                    strcmp(mpd_directory_get_path(mpd_entity_get_directory(entity)),
                           name) == 0)
@@ -237,7 +237,7 @@ filelist_recv(struct filelist *filelist, struct mpd_connection *connection)
 {
        struct mpd_entity *entity;
 
-       while ((entity = mpd_recv_entity(connection)) != NULL)
+       while ((entity = mpd_recv_entity(connection)) != nullptr)
                filelist_append(filelist, entity);
 }
 
similarity index 96%
rename from src/filelist.h
rename to src/filelist.hxx
index f8ada59..63bbf39 100644 (file)
@@ -38,7 +38,7 @@ struct filelist {
 };
 
 struct filelist *
-filelist_new(void);
+filelist_new();
 
 void
 filelist_free(struct filelist *filelist);
@@ -59,7 +59,7 @@ gcc_pure
 static inline struct filelist_entry *
 filelist_get(const struct filelist *filelist, guint i)
 {
-       return g_ptr_array_index(filelist->entries, i);
+       return (struct filelist_entry *)g_ptr_array_index(filelist->entries, i);
 }
 
 struct filelist_entry *
similarity index 93%
rename from src/gidle.c
rename to src/gidle.cxx
index 0d18cf3..6913699 100644 (file)
@@ -26,7 +26,7 @@
    SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 */
 
-#include "gidle.h"
+#include "gidle.hxx"
 #include "Compiler.h"
 
 #include <mpd/async.h>
@@ -48,11 +48,11 @@ struct mpd_glib_source {
 
        GIOChannel *channel;
 
-       enum mpd_async_event io_events;
+       unsigned io_events;
 
        guint id;
 
-       enum mpd_idle idle_events;
+       unsigned idle_events;
 
        /**
         * This flag is a hack: it is set while mpd_glib_leave() is
@@ -80,7 +80,7 @@ mpd_glib_new(struct mpd_connection *connection,
        source->connection = connection;
        source->async = mpd_connection_get_async(connection);
        source->parser = mpd_parser_new();
-       /* XXX check source->parser!=NULL */
+       /* XXX check source->parser!=nullptr */
 
        source->callback = callback;
        source->callback_ctx = callback_ctx;
@@ -119,7 +119,8 @@ mpd_glib_invoke(const struct mpd_glib_source *source)
        assert(!source->destroyed);
 
        if (source->idle_events != 0)
-               source->callback(MPD_ERROR_SUCCESS, 0, NULL,
+               source->callback(MPD_ERROR_SUCCESS, (enum mpd_server_error)0,
+                                nullptr,
                                 source->idle_events, source->callback_ctx);
 }
 
@@ -140,7 +141,8 @@ mpd_glib_invoke_async_error(const struct mpd_glib_source *source)
 {
        assert(source->id == 0);
 
-       mpd_glib_invoke_error(source, mpd_async_get_error(source->async), 0,
+       mpd_glib_invoke_error(source, mpd_async_get_error(source->async),
+                             (enum mpd_server_error)0,
                              mpd_async_get_error_message(source->async));
 }
 
@@ -150,7 +152,7 @@ mpd_glib_invoke_async_error(const struct mpd_glib_source *source)
 static enum mpd_async_event
 g_io_condition_to_mpd_async_event(GIOCondition condition)
 {
-       enum mpd_async_event events = 0;
+       unsigned events = 0;
 
        if (condition & G_IO_IN)
                events |= MPD_ASYNC_EVENT_READ;
@@ -164,7 +166,7 @@ g_io_condition_to_mpd_async_event(GIOCondition condition)
        if (condition & G_IO_ERR)
                events |= MPD_ASYNC_EVENT_ERROR;
 
-       return events;
+       return (enum mpd_async_event)events;
 }
 
 /**
@@ -173,7 +175,7 @@ g_io_condition_to_mpd_async_event(GIOCondition condition)
 static GIOCondition
 mpd_async_events_to_g_io_condition(enum mpd_async_event events)
 {
-       GIOCondition condition = 0;
+       unsigned condition = 0;
 
        if (events & MPD_ASYNC_EVENT_READ)
                condition |= G_IO_IN;
@@ -187,7 +189,7 @@ mpd_async_events_to_g_io_condition(enum mpd_async_event events)
        if (events & MPD_ASYNC_EVENT_ERROR)
                condition |= G_IO_ERR;
 
-       return condition;
+       return GIOCondition(condition);
 }
 
 /**
@@ -206,7 +208,8 @@ mpd_glib_feed(struct mpd_glib_source *source, char *line)
                source->id = 0;
                source->io_events = 0;
 
-               mpd_glib_invoke_error(source, MPD_ERROR_MALFORMED, 0,
+               mpd_glib_invoke_error(source, MPD_ERROR_MALFORMED,
+                                     (enum mpd_server_error)0,
                                      "Malformed MPD response");
                return false;
 
@@ -247,7 +250,7 @@ static bool
 mpd_glib_recv(struct mpd_glib_source *source)
 {
        char *line;
-       while ((line = mpd_async_recv_line(source->async)) != NULL) {
+       while ((line = mpd_async_recv_line(source->async)) != nullptr) {
                if (!mpd_glib_feed(source, line))
                        return false;
        }
@@ -267,7 +270,7 @@ static gboolean
 mpd_glib_source_callback(gcc_unused GIOChannel *_source,
                         GIOCondition condition, gpointer data)
 {
-       struct mpd_glib_source *source = data;
+       auto *source = (struct mpd_glib_source *)data;
 
        assert(source->id != 0);
        assert(source->io_events != 0);
@@ -341,7 +344,7 @@ mpd_glib_enter(struct mpd_glib_source *source)
 
        source->idle_events = 0;
 
-       if (!mpd_async_send_command(source->async, "idle", NULL)) {
+       if (!mpd_async_send_command(source->async, "idle", nullptr)) {
                mpd_glib_invoke_async_error(source);
                return false;
        }
@@ -376,7 +379,7 @@ mpd_glib_leave(struct mpd_glib_source *source)
                enum mpd_server_error server_error =
                        error == MPD_ERROR_SERVER
                        ? mpd_connection_get_server_error(source->connection)
-                       : 0;
+                       : (enum mpd_server_error)0;
 
                mpd_glib_invoke_error(source, error, server_error,
                                      mpd_connection_get_error_message(source->connection));
similarity index 98%
rename from src/gidle.h
rename to src/gidle.hxx
index 1a59437..738f54e 100644 (file)
@@ -34,7 +34,7 @@
 typedef void (*mpd_glib_callback_t)(enum mpd_error error,
                                    enum mpd_server_error server_error,
                                    const char *message,
-                                   enum mpd_idle events, void *ctx);
+                                   unsigned events, void *ctx);
 
 struct mpd_glib_source;
 
similarity index 77%
rename from src/hscroll.c
rename to src/hscroll.cxx
index eae689e..5537143 100644 (file)
@@ -17,8 +17,8 @@
  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
  */
 
-#include "hscroll.h"
-#include "charset.h"
+#include "hscroll.hxx"
+#include "charset.hxx"
 #include "ncfix.h"
 
 #include <assert.h>
@@ -28,13 +28,13 @@ char *
 strscroll(struct hscroll *hscroll, const char *str, const char *separator,
          unsigned width)
 {
-       assert(hscroll != NULL);
-       assert(str != NULL);
-       assert(separator != NULL);
+       assert(hscroll != nullptr);
+       assert(str != nullptr);
+       assert(separator != nullptr);
 
        /* create a buffer containing the string and the separator */
        char *tmp = replace_locale_to_utf8(g_strconcat(str, separator,
-                                                      str, separator, NULL));
+                                                      str, separator, nullptr));
        if (hscroll->offset >= (unsigned)g_utf8_strlen(tmp, -1) / 2)
                hscroll->offset = 0;
 
@@ -54,7 +54,7 @@ strscroll(struct hscroll *hscroll, const char *str, const char *separator,
 static gboolean
 hscroll_timer_callback(gpointer data)
 {
-       struct hscroll *hscroll = data;
+       auto *hscroll = (struct hscroll *)data;
 
        hscroll_step(hscroll);
        hscroll_draw(hscroll);
@@ -66,11 +66,11 @@ void
 hscroll_set(struct hscroll *hscroll, unsigned x, unsigned y, unsigned width,
            const char *text)
 {
-       assert(hscroll != NULL);
-       assert(hscroll->w != NULL);
-       assert(text != NULL);
+       assert(hscroll != nullptr);
+       assert(hscroll->w != nullptr);
+       assert(text != nullptr);
 
-       if (hscroll->text != NULL && hscroll->x == x && hscroll->y == y &&
+       if (hscroll->text != nullptr && hscroll->x == x && hscroll->y == y &&
            hscroll->width == width && strcmp(hscroll->text, text) == 0)
                /* no change, do nothing (and, most importantly, do
                   not reset the current offset!) */
@@ -84,7 +84,7 @@ hscroll_set(struct hscroll *hscroll, unsigned x, unsigned y, unsigned width,
 
        /* obtain the ncurses attributes and the current color, store
           them */
-       fix_wattr_get(hscroll->w, &hscroll->attrs, &hscroll->pair, NULL);
+       fix_wattr_get(hscroll->w, &hscroll->attrs, &hscroll->pair, nullptr);
 
        hscroll->text = g_strdup(text);
        hscroll->offset = 0;
@@ -95,29 +95,29 @@ hscroll_set(struct hscroll *hscroll, unsigned x, unsigned y, unsigned width,
 void
 hscroll_clear(struct hscroll *hscroll)
 {
-       assert(hscroll != NULL);
+       assert(hscroll != nullptr);
 
-       if (hscroll->text == NULL)
+       if (hscroll->text == nullptr)
                return;
 
        g_source_remove(hscroll->source_id);
 
        g_free(hscroll->text);
-       hscroll->text = NULL;
+       hscroll->text = nullptr;
 }
 
 void
 hscroll_draw(struct hscroll *hscroll)
 {
-       assert(hscroll != NULL);
-       assert(hscroll->w != NULL);
-       assert(hscroll->text != NULL);
+       assert(hscroll != nullptr);
+       assert(hscroll->w != nullptr);
+       assert(hscroll->text != nullptr);
 
        /* set stored attributes and color */
        attr_t old_attrs;
        short old_pair;
-       fix_wattr_get(hscroll->w, &old_attrs, &old_pair, NULL);
-       wattr_set(hscroll->w, hscroll->attrs, hscroll->pair, NULL);
+       fix_wattr_get(hscroll->w, &old_attrs, &old_pair, nullptr);
+       wattr_set(hscroll->w, hscroll->attrs, hscroll->pair, nullptr);
 
        /* scroll the string, and draw it */
        char *p = strscroll(hscroll, hscroll->text, hscroll->separator,
@@ -126,5 +126,5 @@ hscroll_draw(struct hscroll *hscroll)
        g_free(p);
 
        /* restore previous attributes and color */
-       wattr_set(hscroll->w, old_attrs, old_pair, NULL);
+       wattr_set(hscroll->w, old_attrs, old_pair, nullptr);
 }
similarity index 100%
rename from src/hscroll.h
rename to src/hscroll.hxx
similarity index 91%
rename from src/keyboard.c
rename to src/keyboard.cxx
index 86f2afe..104f9ed 100644 (file)
  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
  */
 
-#include "keyboard.h"
-#include "command.h"
-#include "ncmpc.h"
+#include "keyboard.hxx"
+#include "command.hxx"
+#include "ncmpc.hxx"
 #include "ncmpc_curses.h"
-#include "screen.h"
+#include "screen.hxx"
 #include "Compiler.h"
 
 #include <glib.h>
@@ -76,17 +76,17 @@ keyboard_event(gcc_unused GIOChannel *source,
        begin_input_event();
 
        if (!do_input_event(cmd))
-               return FALSE;
+               return false;
 
        end_input_event();
-       return TRUE;
+       return true;
 }
 
 void
-keyboard_init(void)
+keyboard_init()
 {
        GIOChannel *channel = g_io_channel_unix_new(STDIN_FILENO);
-       g_io_add_watch(channel, G_IO_IN, keyboard_event, NULL);
+       g_io_add_watch(channel, G_IO_IN, keyboard_event, nullptr);
        g_io_channel_unref(channel);
 }
 
similarity index 97%
rename from src/keyboard.h
rename to src/keyboard.hxx
index e34b919..064458f 100644 (file)
@@ -21,7 +21,7 @@
 #define KEYBOARD_H
 
 void
-keyboard_init(void);
+keyboard_init();
 
 void
 keyboard_unread(int key);
similarity index 84%
rename from src/lirc.c
rename to src/lirc.cxx
index 965037b..1fe0e0c 100644 (file)
  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
  */
 
-#include "lirc.h"
-#include "ncmpc.h"
+#include "lirc.hxx"
+#include "ncmpc.hxx"
 #include "Compiler.h"
 
 #include <lirc/lirc_client.h>
 
 #include <glib.h>
 
-static struct lirc_config *lc = NULL;
+static struct lirc_config *lc = nullptr;
 
 static gboolean
 lirc_event(gcc_unused GIOChannel *source,
@@ -37,15 +37,15 @@ lirc_event(gcc_unused GIOChannel *source,
        begin_input_event();
 
        if (lirc_nextcode(&code) == 0) {
-               while (lirc_code2char(lc, code, &txt) == 0 && txt != NULL) {
+               while (lirc_code2char(lc, code, &txt) == 0 && txt != nullptr) {
                        cmd = get_key_command_from_name(txt);
                        if (!do_input_event(cmd))
-                               return FALSE;
+                               return false;
                }
        }
 
        end_input_event();
-       return TRUE;
+       return true;
 }
 
 void
@@ -57,13 +57,13 @@ ncmpc_lirc_init()
        if ((lirc_socket = lirc_init(prog, 0)) == -1)
                return;
 
-       if (lirc_readconfig(NULL, &lc, NULL)) {
+       if (lirc_readconfig(nullptr, &lc, nullptr)) {
                lirc_deinit();
                return;
        }
 
        GIOChannel *channel = g_io_channel_unix_new(lirc_socket);
-       g_io_add_watch(channel, G_IO_IN, lirc_event, NULL);
+       g_io_add_watch(channel, G_IO_IN, lirc_event, nullptr);
        g_io_channel_unref(channel);
 }
 
similarity index 95%
rename from src/lirc.h
rename to src/lirc.hxx
index 551879b..90a89a2 100644 (file)
 #ifdef ENABLE_LIRC
 
 void
-ncmpc_lirc_init(void);
+ncmpc_lirc_init();
 
 void
-ncmpc_lirc_deinit(void);
+ncmpc_lirc_deinit();
 
 #else
 
similarity index 96%
rename from src/list_window.c
rename to src/list_window.cxx
index 3fbe531..82e2068 100644 (file)
  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
  */
 
-#include "list_window.h"
+#include "list_window.hxx"
 #include "config.h"
-#include "options.h"
-#include "charset.h"
-#include "match.h"
-#include "command.h"
-#include "colors.h"
-#include "paint.h"
-#include "screen_status.h"
+#include "options.hxx"
+#include "charset.hxx"
+#include "match.hxx"
+#include "command.hxx"
+#include "colors.hxx"
+#include "paint.hxx"
+#include "screen_status.hxx"
 #include "i18n.h"
 
 #include <assert.h>
 #include <unistd.h>
 #include <string.h>
 
-extern void screen_bell(void);
+extern void screen_bell();
 
 struct list_window *
 list_window_init(WINDOW *w, unsigned width, unsigned height)
 {
-       struct list_window *lw;
-
-       lw = g_malloc0(sizeof(*lw));
+       auto *lw = g_new(struct list_window, 1);
        lw->w = w;
        lw->cols = width;
        lw->rows = height;
@@ -51,7 +49,7 @@ list_window_init(WINDOW *w, unsigned width, unsigned height)
 void
 list_window_free(struct list_window *lw)
 {
-       assert(lw != NULL);
+       assert(lw != nullptr);
 
        g_free(lw);
 }
@@ -359,7 +357,7 @@ list_window_paint(const struct list_window *lw,
                }
 
                const char *label = callback(lw->start + i, callback_data);
-               assert(label != NULL);
+               assert(label != nullptr);
 
                list_window_paint_row(lw->w, lw->cols,
                                      show_cursor &&
@@ -422,12 +420,12 @@ list_window_find(struct list_window *lw,
 {
        unsigned i = lw->selected + 1;
 
-       assert(str != NULL);
+       assert(str != nullptr);
 
        do {
                while (i < lw->length) {
                        const char *label = callback(i, callback_data);
-                       assert(label != NULL);
+                       assert(label != nullptr);
 
                        if (match_line(label, str)) {
                                list_window_move_cursor(lw, i);
@@ -460,7 +458,7 @@ list_window_rfind(struct list_window *lw,
 {
        int i = lw->selected - 1;
 
-       assert(str != NULL);
+       assert(str != nullptr);
 
        if (lw->length == 0)
                return false;
@@ -468,7 +466,7 @@ list_window_rfind(struct list_window *lw,
        do {
                while (i >= 0) {
                        const char *label = callback(i, callback_data);
-                       assert(label != NULL);
+                       assert(label != nullptr);
 
                        if (match_line(label, str)) {
                                list_window_move_cursor(lw, i);
@@ -496,11 +494,11 @@ list_window_jump(struct list_window *lw,
                 void *callback_data,
                 const char *str)
 {
-       assert(str != NULL);
+       assert(str != nullptr);
 
        for (unsigned i = 0; i < lw->length; i++) {
                const char *label = callback(i, callback_data);
-               assert(label != NULL);
+               assert(label != nullptr);
 
                if (g_ascii_strncasecmp(label, str, strlen(str)) == 0) {
                        list_window_move_cursor(lw, i);
@@ -516,15 +514,15 @@ list_window_jump(struct list_window *lw,
                 void *callback_data,
                 const char *str)
 {
-       assert(str != NULL);
+       assert(str != nullptr);
 
        GRegex *regex = compile_regex(str, options.jump_prefix_only);
-       if (regex == NULL)
+       if (regex == nullptr)
                return false;
 
        for (unsigned i = 0; i < lw->length; i++) {
                const char *label = callback(i, callback_data);
-               assert(label != NULL);
+               assert(label != nullptr);
 
                if (match_regex(regex, label)) {
                        g_regex_unref(regex);
@@ -673,7 +671,7 @@ list_window_scroll_cmd(struct list_window *lw, command_t cmd)
 bool
 list_window_mouse(struct list_window *lw, unsigned long bstate, int y)
 {
-       assert(lw != NULL);
+       assert(lw != nullptr);
 
        /* if the even occurred above the list window move up */
        if (y < 0) {
similarity index 98%
rename from src/list_window.h
rename to src/list_window.hxx
index 697e1e0..e1d02ec 100644 (file)
 #define LIST_WINDOW_H
 
 #include "config.h"
-#include "command.h"
-#include "colors.h"
+#include "command.hxx"
+#include "colors.hxx"
 #include "ncmpc_curses.h"
 
 #include <glib.h>
-#include <stdbool.h>
 
 typedef const char *
 (*list_window_callback_fn_t)(unsigned i, void *data);
similarity index 89%
rename from src/lyrics.c
rename to src/lyrics.cxx
index a23aa37..b5285b9 100644 (file)
  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
  */
 
-#include "lyrics.h"
+#include "lyrics.hxx"
 #include "config.h"
 
 #include <assert.h>
 
 static struct plugin_list empty, plugins;
 
-void lyrics_init(void)
+void lyrics_init()
 {
        plugin_list_init(&empty);
        plugin_list_init(&plugins);
        plugin_list_load_directory(&plugins, LYRICS_PLUGIN_DIR);
 }
 
-void lyrics_deinit(void)
+void lyrics_deinit()
 {
        plugin_list_deinit(&empty);
        plugin_list_deinit(&plugins);
@@ -41,9 +41,9 @@ struct plugin_cycle *
 lyrics_load(const char *artist, const char *title,
            plugin_callback_t callback, void *data)
 {
-       const char *args[3] = { artist, title, NULL };
+       const char *args[3] = { artist, title, nullptr };
 
-       if (artist == NULL || title == NULL)
+       if (artist == nullptr || title == nullptr)
                return plugin_run(&empty, args, callback, data);
 
        return plugin_run(&plugins, args, callback, data);
similarity index 93%
rename from src/lyrics.h
rename to src/lyrics.hxx
index 3a7a0be..71e47a4 100644 (file)
 #ifndef LYRICS_H
 #define LYRICS_H
 
-#include "plugin.h"
+#include "plugin.hxx"
 
-void lyrics_init(void);
+void lyrics_init();
 
-void lyrics_deinit(void);
+void lyrics_deinit();
 
 struct plugin_cycle *
 lyrics_load(const char *artist, const char *title,
similarity index 80%
rename from src/match.c
rename to src/match.cxx
index 9e4c391..bb02bad 100644 (file)
@@ -17,8 +17,8 @@
  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
  */
 
-#include "match.h"
-#include "charset.h"
+#include "match.hxx"
+#include "charset.hxx"
 
 #include <glib.h>
 #include <string.h>
@@ -37,14 +37,15 @@ locale_casefold(const char *src)
 GRegex *
 compile_regex(const char *src, bool anchor)
 {
-       GRegexCompileFlags compile_flags =
+       unsigned compile_flags =
                G_REGEX_CASELESS | G_REGEX_DOTALL | G_REGEX_OPTIMIZE;
        if (anchor)
                compile_flags |= G_REGEX_ANCHORED;
 
        char *src_folded = locale_casefold(src);
-       GRegex *regex = g_regex_new ((const gchar*)src_folded, compile_flags,
-                                    0, NULL);
+       GRegex *regex = g_regex_new ((const gchar*)src_folded,
+                                    GRegexCompileFlags(compile_flags),
+                                    GRegexMatchFlags(0), nullptr);
 
        g_free(src_folded);
 
@@ -56,7 +57,7 @@ match_regex(GRegex *regex, const char *line)
 {
        char *line_folded = locale_casefold(line);
        GMatchInfo *match_info;
-       g_regex_match(regex, line_folded, 0, &match_info);
+       g_regex_match(regex, line_folded, GRegexMatchFlags(0), &match_info);
        bool match = (bool)g_match_info_matches(match_info);
 
        g_match_info_free(match_info);
@@ -72,9 +73,9 @@ match_line(const char *line, const char *needle)
        char *needle_folded = locale_casefold(needle);
 
        bool ret = (bool)g_regex_match_simple((const gchar*)needle_folded,
-                       (const gchar*)line_folded,
-                       G_REGEX_CASELESS | G_REGEX_DOTALL | G_REGEX_OPTIMIZE,
-                       0);
+                                             (const gchar*)line_folded,
+                                             GRegexCompileFlags(G_REGEX_CASELESS | G_REGEX_DOTALL | G_REGEX_OPTIMIZE),
+                                             GRegexMatchFlags(0));
 
        g_free(line_folded);
        g_free(needle_folded);
similarity index 95%
rename from src/match.h
rename to src/match.hxx
index e1a6258..6703139 100644 (file)
@@ -23,8 +23,6 @@
 #include "config.h"
 #include "Compiler.h"
 
-#include <stdbool.h>
-
 #ifdef NCMPC_MINI
 
 #include <string.h>
@@ -32,7 +30,7 @@
 static inline bool
 match_line(const char *line, const char *needle)
 {
-       return strstr(line, needle) != NULL;
+       return strstr(line, needle) != nullptr;
 }
 #else
 
similarity index 88%
rename from src/mpdclient.c
rename to src/mpdclient.cxx
index 4114a31..a5d7ef7 100644 (file)
  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
  */
 
-#include "mpdclient.h"
-#include "callbacks.h"
-#include "filelist.h"
+#include "mpdclient.hxx"
+#include "callbacks.hxx"
+#include "filelist.hxx"
 #include "config.h"
-#include "gidle.h"
-#include "charset.h"
+#include "gidle.hxx"
+#include "charset.hxx"
 
 #ifdef ENABLE_ASYNC_CONNECT
-#include "aconnect.h"
+#include "aconnect.hxx"
 #endif
 
 #include <mpd/client.h>
@@ -35,9 +35,9 @@
 static gboolean
 mpdclient_enter_idle_callback(gpointer user_data)
 {
-       struct mpdclient *c = user_data;
+       auto *c = (struct mpdclient *)user_data;
        assert(c->enter_idle_source_id != 0);
-       assert(c->source != NULL);
+       assert(c->source != nullptr);
        assert(!c->idle);
 
        c->enter_idle_source_id = 0;
@@ -48,8 +48,8 @@ mpdclient_enter_idle_callback(gpointer user_data)
 static void
 mpdclient_schedule_enter_idle(struct mpdclient *c)
 {
-       assert(c != NULL);
-       assert(c->source != NULL);
+       assert(c != nullptr);
+       assert(c->source != nullptr);
 
        if (c->enter_idle_source_id == 0)
                /* automatically re-enter MPD "idle" mode */
@@ -75,7 +75,7 @@ mpdclient_invoke_error_callback(enum mpd_error error,
                /* server errors are UTF-8, the others are locale */
                message = allocated = utf8_to_locale(message);
        else
-               allocated = NULL;
+               allocated = nullptr;
 
        mpdclient_error_callback(message);
        g_free(allocated);
@@ -84,8 +84,8 @@ mpdclient_invoke_error_callback(enum mpd_error error,
 static void
 mpdclient_invoke_error_callback1(struct mpdclient *c)
 {
-       assert(c != NULL);
-       assert(c->connection != NULL);
+       assert(c != nullptr);
+       assert(c->connection != nullptr);
 
        struct mpd_connection *connection = c->connection;
 
@@ -99,10 +99,10 @@ mpdclient_invoke_error_callback1(struct mpdclient *c)
 static void
 mpdclient_gidle_callback(enum mpd_error error,
                         gcc_unused enum mpd_server_error server_error,
-                        const char *message, enum mpd_idle events,
+                        const char *message, unsigned events,
                         void *ctx)
 {
-       struct mpdclient *c = ctx;
+       auto *c = (struct mpdclient *)ctx;
 
        c->idle = false;
 
@@ -122,7 +122,7 @@ mpdclient_gidle_callback(enum mpd_error error,
 
        c->events = 0;
 
-       if (c->source != NULL)
+       if (c->source != nullptr)
                mpdclient_schedule_enter_idle(c);
 }
 
@@ -166,7 +166,7 @@ static bool
 settings_is_local_socket(const struct mpd_settings *settings)
 {
        const char *host = mpd_settings_get_host(settings);
-       return host != NULL && is_local_socket(host);
+       return host != nullptr && is_local_socket(host);
 }
 
 #endif
@@ -180,15 +180,15 @@ mpdclient_new(const gchar *host, unsigned port,
 
 #ifdef ENABLE_ASYNC_CONNECT
        c->settings = mpd_settings_new(host, port, timeout_ms,
-                                      NULL, NULL);
-       if (c->settings == NULL)
+                                      nullptr, nullptr);
+       if (c->settings == nullptr)
                g_error("Out of memory");
 
 #ifndef WIN32
-       c->settings2 = host == NULL && port == 0 &&
+       c->settings2 = host == nullptr && port == 0 &&
                settings_is_local_socket(c->settings)
-               ? mpd_settings_new(host, 6600, timeout_ms, NULL, NULL)
-               : NULL;
+               ? mpd_settings_new(host, 6600, timeout_ms, nullptr, nullptr)
+               : nullptr;
 #endif
 
 #else
@@ -218,7 +218,7 @@ mpdclient_free(struct mpdclient *c)
        mpd_settings_free(c->settings);
 
 #ifndef WIN32
-       if (c->settings2 != NULL)
+       if (c->settings2 != nullptr)
                mpd_settings_free(c->settings2);
 #endif
 #endif
@@ -229,10 +229,10 @@ mpdclient_free(struct mpdclient *c)
 static char *
 settings_name(const struct mpd_settings *settings)
 {
-       assert(settings != NULL);
+       assert(settings != nullptr);
 
        const char *host = mpd_settings_get_host(settings);
-       if (host == NULL)
+       if (host == nullptr)
                host = "unknown";
 
        if (host[0] == '/')
@@ -248,14 +248,14 @@ settings_name(const struct mpd_settings *settings)
 char *
 mpdclient_settings_name(const struct mpdclient *c)
 {
-       assert(c != NULL);
+       assert(c != nullptr);
 
 #ifdef ENABLE_ASYNC_CONNECT
        return settings_name(c->settings);
 #else
        struct mpd_settings *settings =
-               mpd_settings_new(c->host, c->port, 0, NULL, NULL);
-       if (settings == NULL)
+               mpd_settings_new(c->host, c->port, 0, nullptr, nullptr);
+       if (settings == nullptr)
                return g_strdup("unknown");
 
        char *name = settings_name(settings);
@@ -267,11 +267,11 @@ mpdclient_settings_name(const struct mpdclient *c)
 static void
 mpdclient_status_free(struct mpdclient *c)
 {
-       if (c->status == NULL)
+       if (c->status == nullptr)
                return;
 
        mpd_status_free(c->status);
-       c->status = NULL;
+       c->status = nullptr;
 
        c->volume = -1;
        c->playing = false;
@@ -281,17 +281,17 @@ void
 mpdclient_disconnect(struct mpdclient *c)
 {
 #ifdef ENABLE_ASYNC_CONNECT
-       if (c->async_connect != NULL) {
+       if (c->async_connect != nullptr) {
                aconnect_cancel(c->async_connect);
-               c->async_connect = NULL;
+               c->async_connect = nullptr;
        }
 #endif
 
        mpdclient_cancel_enter_idle(c);
 
-       if (c->source != NULL) {
+       if (c->source != nullptr) {
                mpd_glib_free(c->source);
-               c->source = NULL;
+               c->source = nullptr;
                c->idle = false;
        }
 
@@ -299,14 +299,14 @@ mpdclient_disconnect(struct mpdclient *c)
                mpd_connection_free(c->connection);
                ++c->connection_id;
        }
-       c->connection = NULL;
+       c->connection = nullptr;
 
        mpdclient_status_free(c);
 
        playlist_clear(&c->playlist);
 
        if (c->song)
-               c->song = NULL;
+               c->song = nullptr;
 
        /* everything has changed after a disconnect */
        c->events |= MPD_IDLE_ALL;
@@ -331,7 +331,7 @@ mpdclient_connected(struct mpdclient *c,
 #endif
 
        /* send password */
-       if (c->password != NULL &&
+       if (c->password != nullptr &&
            !mpd_run_password(connection, c->password)) {
                mpdclient_invoke_error_callback1(c);
                mpdclient_disconnect(c);
@@ -369,13 +369,13 @@ mpdclient_get_settings(const struct mpdclient *c)
 static void
 mpdclient_connect_success(struct mpd_connection *connection, void *ctx)
 {
-       struct mpdclient *c = ctx;
-       assert(c->async_connect != NULL);
-       c->async_connect = NULL;
+       auto *c = (struct mpdclient *)ctx;
+       assert(c->async_connect != nullptr);
+       c->async_connect = nullptr;
 
        const char *password =
                mpd_settings_get_password(mpdclient_get_settings(c));
-       if (password != NULL && !mpd_run_password(connection, password)) {
+       if (password != nullptr && !mpd_run_password(connection, password)) {
                mpdclient_error_callback(mpd_connection_get_error_message(connection));
                mpd_connection_free(connection);
                mpdclient_failed_callback();
@@ -388,12 +388,12 @@ mpdclient_connect_success(struct mpd_connection *connection, void *ctx)
 static void
 mpdclient_connect_error(const char *message, void *ctx)
 {
-       struct mpdclient *c = ctx;
-       assert(c->async_connect != NULL);
-       c->async_connect = NULL;
+       auto *c = (struct mpdclient *)ctx;
+       assert(c->async_connect != nullptr);
+       c->async_connect = nullptr;
 
 #ifndef WIN32
-       if (!c->connecting2 && c->settings2 != NULL) {
+       if (!c->connecting2 && c->settings2 != nullptr) {
                c->connecting2 = true;
                mpdclient_aconnect_start(c, c->settings2);
                return;
@@ -436,7 +436,7 @@ mpdclient_connect(struct mpdclient *c)
        /* connect to MPD */
        struct mpd_connection *connection =
                mpd_connection_new(c->host, c->port, c->timeout_ms);
-       if (connection == NULL)
+       if (connection == nullptr)
                g_error("Out of memory");
 
        mpdclient_connected(c, connection);
@@ -448,7 +448,7 @@ mpdclient_update(struct mpdclient *c)
 {
        struct mpd_connection *connection = mpdclient_get_connection(c);
 
-       if (connection == NULL)
+       if (connection == nullptr)
                return false;
 
        /* free the old status */
@@ -456,7 +456,7 @@ mpdclient_update(struct mpdclient *c)
 
        /* retrieve new status */
        c->status = mpd_run_status(connection);
-       if (c->status == NULL)
+       if (c->status == nullptr)
                return mpdclient_handle_error(c);
 
        c->volume = mpd_status_get_volume(c->status);
@@ -486,11 +486,11 @@ mpdclient_update(struct mpdclient *c)
 struct mpd_connection *
 mpdclient_get_connection(struct mpdclient *c)
 {
-       if (c->source != NULL && c->idle) {
+       if (c->source != nullptr && c->idle) {
                c->idle = false;
                mpd_glib_leave(c->source);
 
-               if (c->source != NULL)
+               if (c->source != nullptr)
                        mpdclient_schedule_enter_idle(c);
        }
 
@@ -500,15 +500,15 @@ mpdclient_get_connection(struct mpdclient *c)
 static struct mpd_status *
 mpdclient_recv_status(struct mpdclient *c)
 {
-       assert(c->connection != NULL);
+       assert(c->connection != nullptr);
 
        struct mpd_status *status = mpd_recv_status(c->connection);
-       if (status == NULL) {
+       if (status == nullptr) {
                mpdclient_handle_error(c);
-               return NULL;
+               return nullptr;
        }
 
-       if (c->status != NULL)
+       if (c->status != nullptr)
                mpd_status_free(c->status);
        return c->status = status;
 }
@@ -529,7 +529,7 @@ mpdclient_cmd_crop(struct mpdclient *c)
                return true;
 
        struct mpd_connection *connection = mpdclient_get_connection(c);
-       if (connection == NULL)
+       if (connection == nullptr)
                return false;
 
        mpd_command_list_begin(connection, false);
@@ -548,7 +548,7 @@ bool
 mpdclient_cmd_clear(struct mpdclient *c)
 {
        struct mpd_connection *connection = mpdclient_get_connection(c);
-       if (connection == NULL)
+       if (connection == nullptr)
                return false;
 
        /* send "clear" and "status" */
@@ -561,7 +561,7 @@ mpdclient_cmd_clear(struct mpdclient *c)
        /* receive the new status, store it in the mpdclient struct */
 
        struct mpd_status *status = mpdclient_recv_status(c);
-       if (status == NULL)
+       if (status == nullptr)
                return false;
 
        if (!mpd_response_finish(connection))
@@ -575,7 +575,7 @@ mpdclient_cmd_clear(struct mpdclient *c)
                   reducing the UI latency */
                playlist_clear(&c->playlist);
                c->playlist.version = mpd_status_get_queue_version(status);
-               c->song = NULL;
+               c->song = nullptr;
        }
 
        c->events |= MPD_IDLE_QUEUE;
@@ -586,7 +586,7 @@ bool
 mpdclient_cmd_volume(struct mpdclient *c, gint value)
 {
        struct mpd_connection *connection = mpdclient_get_connection(c);
-       if (connection == NULL)
+       if (connection == nullptr)
                return false;
 
        mpd_send_set_volume(connection, value);
@@ -600,7 +600,7 @@ mpdclient_cmd_volume_up(struct mpdclient *c)
                return true;
 
        struct mpd_connection *connection = mpdclient_get_connection(c);
-       if (connection == NULL)
+       if (connection == nullptr)
                return false;
 
        return mpdclient_cmd_volume(c, ++c->volume);
@@ -613,7 +613,7 @@ mpdclient_cmd_volume_down(struct mpdclient *c)
                return true;
 
        struct mpd_connection *connection = mpdclient_get_connection(c);
-       if (connection == NULL)
+       if (connection == nullptr)
                return false;
 
        return mpdclient_cmd_volume(c, --c->volume);
@@ -623,7 +623,7 @@ bool
 mpdclient_cmd_add_path(struct mpdclient *c, const gchar *path_utf8)
 {
        struct mpd_connection *connection = mpdclient_get_connection(c);
-       if (connection == NULL)
+       if (connection == nullptr)
                return false;
 
        return mpd_send_add(connection, path_utf8)?
@@ -633,11 +633,11 @@ mpdclient_cmd_add_path(struct mpdclient *c, const gchar *path_utf8)
 bool
 mpdclient_cmd_add(struct mpdclient *c, const struct mpd_song *song)
 {
-       assert(c != NULL);
-       assert(song != NULL);
+       assert(c != nullptr);
+       assert(song != nullptr);
 
        struct mpd_connection *connection = mpdclient_get_connection(c);
-       if (connection == NULL || c->status == NULL)
+       if (connection == nullptr || c->status == nullptr)
                return false;
 
        /* send the add command to mpd; at the same time, get the new
@@ -656,15 +656,15 @@ mpdclient_cmd_add(struct mpdclient *c, const struct mpd_song *song)
        c->events |= MPD_IDLE_QUEUE;
 
        struct mpd_status *status = mpdclient_recv_status(c);
-       if (status == NULL)
+       if (status == nullptr)
                return false;
 
        if (!mpd_response_next(connection))
                return mpdclient_handle_error(c);
 
        struct mpd_song *new_song = mpd_recv_song(connection);
-       if (!mpd_response_finish(connection) || new_song == NULL) {
-               if (new_song != NULL)
+       if (!mpd_response_finish(connection) || new_song == nullptr) {
+               if (new_song != nullptr)
                        mpd_song_free(new_song);
 
                return mpd_connection_clear_error(connection) ||
@@ -693,7 +693,7 @@ mpdclient_cmd_delete(struct mpdclient *c, gint idx)
 {
        struct mpd_connection *connection = mpdclient_get_connection(c);
 
-       if (connection == NULL || c->status == NULL)
+       if (connection == nullptr || c->status == nullptr)
                return false;
 
        if (idx < 0 || (guint)idx >= playlist_length(&c->playlist))
@@ -713,7 +713,7 @@ mpdclient_cmd_delete(struct mpdclient *c, gint idx)
        c->events |= MPD_IDLE_QUEUE;
 
        struct mpd_status *status = mpdclient_recv_status(c);
-       if (status == NULL)
+       if (status == nullptr)
                return false;
 
        if (!mpd_response_finish(connection))
@@ -731,7 +731,7 @@ mpdclient_cmd_delete(struct mpdclient *c, gint idx)
 
                /* remove references to the song */
                if (c->song == song)
-                       c->song = NULL;
+                       c->song = nullptr;
        }
 
        return true;
@@ -746,7 +746,7 @@ mpdclient_cmd_delete_range(struct mpdclient *c, unsigned start, unsigned end)
                return mpdclient_cmd_delete(c, start);
 
        struct mpd_connection *connection = mpdclient_get_connection(c);
-       if (connection == NULL)
+       if (connection == nullptr)
                return false;
 
        /* send the delete command to mpd; at the same time, get the
@@ -761,7 +761,7 @@ mpdclient_cmd_delete_range(struct mpdclient *c, unsigned start, unsigned end)
        c->events |= MPD_IDLE_QUEUE;
 
        struct mpd_status *status = mpdclient_recv_status(c);
-       if (status == NULL)
+       if (status == nullptr)
                return false;
 
        if (!mpd_response_finish(connection))
@@ -780,7 +780,7 @@ mpdclient_cmd_delete_range(struct mpdclient *c, unsigned start, unsigned end)
 
                        /* remove references to the song */
                        if (c->song == playlist_get(&c->playlist, end))
-                               c->song = NULL;
+                               c->song = nullptr;
 
                        playlist_remove(&c->playlist, end);
                }
@@ -796,7 +796,7 @@ mpdclient_cmd_move(struct mpdclient *c, unsigned dest_pos, unsigned src_pos)
                return true;
 
        struct mpd_connection *connection = mpdclient_get_connection(c);
-       if (connection == NULL)
+       if (connection == nullptr)
                return false;
 
        /* send the "move" command to MPD; at the same time, get the
@@ -811,7 +811,7 @@ mpdclient_cmd_move(struct mpdclient *c, unsigned dest_pos, unsigned src_pos)
        c->events |= MPD_IDLE_QUEUE;
 
        struct mpd_status *status = mpdclient_recv_status(c);
-       if (status == NULL)
+       if (status == nullptr)
                return false;
 
        if (!mpd_response_finish(connection))
@@ -838,7 +838,7 @@ mpdclient_cmd_subscribe(struct mpdclient *c, const char *channel)
 {
        struct mpd_connection *connection = mpdclient_get_connection(c);
 
-       if (connection == NULL)
+       if (connection == nullptr)
                return false;
 
        if (!mpd_send_subscribe(connection, channel))
@@ -851,7 +851,7 @@ bool
 mpdclient_cmd_unsubscribe(struct mpdclient *c, const char *channel)
 {
        struct mpd_connection *connection = mpdclient_get_connection(c);
-       if (connection == NULL)
+       if (connection == nullptr)
                return false;
 
        if (!mpd_send_unsubscribe(connection, channel))
@@ -865,7 +865,7 @@ mpdclient_cmd_send_message(struct mpdclient *c, const char *channel,
                           const char *text)
 {
        struct mpd_connection *connection = mpdclient_get_connection(c);
-       if (connection == NULL)
+       if (connection == nullptr)
                return false;
 
        if (!mpd_send_send_message(connection, channel, text))
@@ -878,7 +878,7 @@ bool
 mpdclient_send_read_messages(struct mpdclient *c)
 {
        struct mpd_connection *connection = mpdclient_get_connection(c);
-       if (connection == NULL)
+       if (connection == nullptr)
                return false;
 
        return mpd_send_read_messages(connection)?
@@ -889,11 +889,11 @@ struct mpd_message *
 mpdclient_recv_message(struct mpdclient *c)
 {
        struct mpd_connection *connection = mpdclient_get_connection(c);
-       if (connection == NULL)
-               return NULL;
+       if (connection == nullptr)
+               return nullptr;
 
        struct mpd_message *message = mpd_recv_message(connection);
-       if (message == NULL &&
+       if (message == nullptr &&
            mpd_connection_get_error(connection) != MPD_ERROR_SUCCESS)
                mpdclient_handle_error(c);
 
@@ -909,7 +909,7 @@ bool
 mpdclient_playlist_update(struct mpdclient *c)
 {
        struct mpd_connection *connection = mpdclient_get_connection(c);
-       if (connection == NULL)
+       if (connection == nullptr)
                return false;
 
        playlist_clear(&c->playlist);
@@ -925,7 +925,7 @@ mpdclient_playlist_update(struct mpdclient *c)
        }
 
        c->playlist.version = mpd_status_get_queue_version(c->status);
-       c->song = NULL;
+       c->song = nullptr;
 
        return mpdclient_finish_command(c);
 }
@@ -936,13 +936,13 @@ mpdclient_playlist_update_changes(struct mpdclient *c)
 {
        struct mpd_connection *connection = mpdclient_get_connection(c);
 
-       if (connection == NULL)
+       if (connection == nullptr)
                return false;
 
        mpd_send_queue_changes_meta(connection, c->playlist.version);
 
        struct mpd_song *song;
-       while ((song = mpd_recv_song(connection)) != NULL) {
+       while ((song = mpd_recv_song(connection)) != nullptr) {
                int pos = mpd_song_get_pos(song);
 
                if (pos >= 0 && (guint)pos < c->playlist.list->len) {
@@ -966,7 +966,7 @@ mpdclient_playlist_update_changes(struct mpdclient *c)
                playlist_remove(&c->playlist, pos);
        }
 
-       c->song = NULL;
+       c->song = nullptr;
        c->playlist.version = mpd_status_get_queue_version(c->status);
 
        return mpdclient_finish_command(c);
@@ -981,7 +981,7 @@ bool
 mpdclient_filelist_add_all(struct mpdclient *c, struct filelist *fl)
 {
        struct mpd_connection *connection = mpdclient_get_connection(c);
-       if (connection == NULL)
+       if (connection == nullptr)
                return false;
 
        if (filelist_is_empty(fl))
@@ -993,7 +993,7 @@ mpdclient_filelist_add_all(struct mpdclient *c, struct filelist *fl)
                struct filelist_entry *entry = filelist_get(fl, i);
                struct mpd_entity *entity  = entry->entity;
 
-               if (entity != NULL &&
+               if (entity != nullptr &&
                    mpd_entity_get_type(entity) == MPD_ENTITY_TYPE_SONG) {
                        const struct mpd_song *song =
                                mpd_entity_get_song(entity);
similarity index 95%
rename from src/mpdclient.h
rename to src/mpdclient.hxx
index 1d3b6e0..41befd4 100644 (file)
@@ -2,7 +2,7 @@
 #define MPDCLIENT_H
 
 #include "config.h"
-#include "playlist.h"
+#include "playlist.hxx"
 #include "Compiler.h"
 
 #include <mpd/client.h>
@@ -70,7 +70,7 @@ struct mpdclient {
        /**
         * A bit mask of idle events occurred since the last update.
         */
-       enum mpd_idle events;
+       unsigned events;
 
 #if defined(ENABLE_ASYNC_CONNECT) && !defined(WIN32)
        bool connecting2;
@@ -138,7 +138,7 @@ gcc_pure
 static inline bool
 mpdclient_is_connected(const struct mpdclient *c)
 {
-       return c->connection != NULL;
+       return c->connection != nullptr;
 }
 
 /**
@@ -149,9 +149,9 @@ gcc_pure
 static inline bool
 mpdclient_is_dead(const struct mpdclient *c)
 {
-       return c->connection == NULL
+       return c->connection == nullptr
 #ifdef ENABLE_ASYNC_CONNECT
-               && c->async_connect == NULL
+               && c->async_connect == nullptr
 #endif
                ;
 }
@@ -160,7 +160,7 @@ gcc_pure
 static inline bool
 mpdclient_is_playing(const struct mpdclient *c)
 {
-       return c->status != NULL &&
+       return c->status != nullptr &&
                (mpd_status_get_state(c->status) == MPD_STATE_PLAY ||
                 mpd_status_get_state(c->status) == MPD_STATE_PAUSE);
 }
@@ -169,9 +169,9 @@ gcc_pure
 static inline const struct mpd_song *
 mpdclient_get_current_song(const struct mpdclient *c)
 {
-       return c->song != NULL && mpdclient_is_playing(c)
+       return c->song != nullptr && mpdclient_is_playing(c)
                ? c->song
-               : NULL;
+               : nullptr;
 }
 
 void
similarity index 91%
rename from src/ncmpc.h
rename to src/ncmpc.hxx
index 2cc778f..c5ff5ff 100644 (file)
 #ifndef NCMPC_H
 #define NCMPC_H
 
-#include "command.h"
+#include "command.hxx"
 
 #ifdef HAVE_GETMOUSE
 #include "ncmpc_curses.h"
 #endif
 
-#include <stdbool.h>
 
-void begin_input_event(void);
-void end_input_event(void);
+void begin_input_event();
+void end_input_event();
 
 /**
  * @return false if the application shall quit
similarity index 87%
rename from src/ncu.c
rename to src/ncu.cxx
index 462cc75..019208a 100644 (file)
--- a/src/ncu.c
  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
  */
 
-#include "ncu.h"
+#include "ncu.hxx"
 #include "config.h"
 #include "ncmpc_curses.h"
 
 #ifdef ENABLE_COLORS
-#include "colors.h"
+#include "colors.hxx"
 #endif
 
 #ifdef HAVE_GETMOUSE
-#include "options.h"
+#include "options.hxx"
 #endif
 
 static SCREEN *ncu_screen;
 
 void
-ncu_init(void)
+ncu_init()
 {
        /* initialize the curses library */
-       ncu_screen = newterm(NULL, stdout, stdin);
+       ncu_screen = newterm(nullptr, stdout, stdin);
 
        /* initialize color support */
 #ifdef ENABLE_COLORS
@@ -52,19 +52,19 @@ ncu_init(void)
        curs_set(0);
 
        /* enable extra keys */
-       keypad(stdscr, TRUE);
+       keypad(stdscr, true);
 
        /* initialize mouse support */
 #ifdef HAVE_GETMOUSE
        if (options.enable_mouse)
-               mousemask(ALL_MOUSE_EVENTS, NULL);
+               mousemask(ALL_MOUSE_EVENTS, nullptr);
 #endif
 
        refresh();
 }
 
 void
-ncu_deinit(void)
+ncu_deinit()
 {
        endwin();
 
similarity index 96%
rename from src/ncu.h
rename to src/ncu.hxx
index dbe5dca..fbee55c 100644 (file)
--- a/src/ncu.h
@@ -25,9 +25,9 @@
 #define NCU_H
 
 void
-ncu_init(void);
+ncu_init();
 
 void
-ncu_deinit(void);
+ncu_deinit();
 
 #endif
similarity index 98%
rename from src/net/async_connect.c
rename to src/net/async_connect.cxx
index 350702c..ce76ec7 100644 (file)
@@ -26,7 +26,7 @@
    SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 */
 
-#include "async_connect.h"
+#include "async_connect.hxx"
 #include "../Compiler.h"
 
 #include <glib.h>
@@ -54,7 +54,7 @@ async_connect_source_callback(gcc_unused GIOChannel *source,
                              gcc_unused GIOCondition condition,
                              gpointer data)
 {
-       struct async_connect *ac = data;
+       auto *ac = (struct async_connect *)data;
 
        const int fd = ac->fd;
        const struct async_connect_handler *const handler = ac->handler;
similarity index 98%
rename from src/net/async_connect.h
rename to src/net/async_connect.hxx
index f56868c..803a8f7 100644 (file)
@@ -29,7 +29,7 @@
 #ifndef NET_ASYNC_CONNECT_H
 #define NET_ASYNC_CONNECT_H
 
-#include "socket.h"
+#include "socket.hxx"
 
 #include <stddef.h>
 
similarity index 93%
rename from src/net/async_rconnect.c
rename to src/net/async_rconnect.cxx
index 8986daa..3220413 100644 (file)
@@ -26,9 +26,9 @@
    SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 */
 
-#include "async_rconnect.h"
-#include "async_connect.h"
-#include "resolver.h"
+#include "async_rconnect.hxx"
+#include "async_connect.hxx"
+#include "resolver.hxx"
 #include "../Compiler.h"
 
 #include <glib.h>
@@ -55,7 +55,7 @@ async_rconnect_next(struct async_rconnect *rc);
 static void
 async_rconnect_success(socket_t fd, void *ctx)
 {
-       struct async_rconnect *rc = ctx;
+       auto *rc = (struct async_rconnect *)ctx;
 
        rc->handler->success(fd, rc->handler_ctx);
        g_free(rc->last_error);
@@ -66,7 +66,7 @@ async_rconnect_success(socket_t fd, void *ctx)
 static void
 async_rconnect_error(const char *message, void *ctx)
 {
-       struct async_rconnect *rc = ctx;
+       auto *rc = (struct async_rconnect *)ctx;
 
        g_free(rc->last_error);
        rc->last_error = g_strdup(message);
@@ -83,7 +83,7 @@ static void
 async_rconnect_next(struct async_rconnect *rc)
 {
        const struct resolver_address *a = resolver_next(rc->resolver);
-       if (a == NULL) {
+       if (a == nullptr) {
                char msg[256];
 
                if (rc->last_error == 0) {
@@ -113,10 +113,10 @@ async_rconnect_start(struct async_rconnect **rcp,
                     const struct async_rconnect_handler *handler, void *ctx)
 {
        struct resolver *r = resolver_new(host, port);
-       if (host == NULL)
+       if (host == nullptr)
                host = "[default]";
 
-       if (r == NULL) {
+       if (r == nullptr) {
                char msg[256];
                snprintf(msg, sizeof(msg), "Failed to resolve host '%s'",
                         host);
@@ -129,7 +129,7 @@ async_rconnect_start(struct async_rconnect **rcp,
        rc->handler_ctx = ctx;
        rc->host = host;
        rc->resolver = r;
-       rc->last_error = NULL;
+       rc->last_error = nullptr;
        *rcp = rc;
 
        async_rconnect_next(rc);
similarity index 88%
rename from src/net/resolver.c
rename to src/net/resolver.cxx
index 2df1b5a..bc22896 100644 (file)
    SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 */
 
-#include "resolver.h"
+#include "resolver.hxx"
 #include "config.h"
 
-#include <stdbool.h>
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
@@ -71,11 +70,9 @@ struct resolver {
 struct resolver *
 resolver_new(const char *host, unsigned port)
 {
-       struct resolver *resolver;
-
-       resolver = malloc(sizeof(*resolver));
-       if (resolver == NULL)
-               return NULL;
+       struct resolver *resolver = (struct resolver *)malloc(sizeof(*resolver));
+       if (resolver == nullptr)
+               return nullptr;
 
        if (host[0] == '/' || host[0] == '@') {
 #ifndef WIN32
@@ -85,7 +82,7 @@ resolver_new(const char *host, unsigned port)
                const size_t path_length = strlen(host) + !is_abstract;
                if (path_length > sizeof(resolver->saun.sun_path)) {
                        free(resolver);
-                       return NULL;
+                       return nullptr;
                }
 
                resolver->saun.sun_family = AF_UNIX;
@@ -100,11 +97,11 @@ resolver_new(const char *host, unsigned port)
                resolver->current.addrlen = sizeof(resolver->saun)
                        - sizeof(resolver->saun.sun_path) + path_length;
                resolver->current.addr = (const struct sockaddr *)&resolver->saun;
-               resolver->type = TYPE_ONE;
+               resolver->type = resolver::TYPE_ONE;
 #else /* WIN32 */
                /* there are no UNIX domain sockets on Windows */
                free(resolver);
-               return NULL;
+               return nullptr;
 #endif /* WIN32 */
        } else {
 #ifdef ENABLE_TCP
@@ -123,23 +120,23 @@ resolver_new(const char *host, unsigned port)
                ret = getaddrinfo(host, service, &hints, &resolver->ai);
                if (ret != 0) {
                        free(resolver);
-                       return NULL;
+                       return nullptr;
                }
 
                resolver->next = resolver->ai;
-               resolver->type = TYPE_ANY;
+               resolver->type = resolver::TYPE_ANY;
 #else
                const struct hostent *he;
 
                he = gethostbyname(host);
-               if (he == NULL) {
+               if (he == nullptr) {
                        free(resolver);
-                       return NULL;
+                       return nullptr;
                }
 
                if (he->h_addrtype != AF_INET) {
                        free(resolver);
-                       return NULL;
+                       return nullptr;
                }
 
 
@@ -159,7 +156,7 @@ resolver_new(const char *host, unsigned port)
 #else /* !ENABLE_TCP */
                (void)port;
                free(resolver);
-               return NULL;
+               return nullptr;
 #endif
        }
 
@@ -170,7 +167,7 @@ void
 resolver_free(struct resolver *resolver)
 {
 #if defined(ENABLE_TCP) && defined(HAVE_GETADDRINFO)
-       if (resolver->type == TYPE_ANY)
+       if (resolver->type == resolver::TYPE_ANY)
                freeaddrinfo(resolver->ai);
 #endif
        free(resolver);
@@ -179,17 +176,17 @@ resolver_free(struct resolver *resolver)
 const struct resolver_address *
 resolver_next(struct resolver *resolver)
 {
-       if (resolver->type == TYPE_ZERO)
-               return NULL;
+       if (resolver->type == resolver::TYPE_ZERO)
+               return nullptr;
 
-       if (resolver->type == TYPE_ONE) {
-               resolver->type = TYPE_ZERO;
+       if (resolver->type == resolver::TYPE_ONE) {
+               resolver->type = resolver::TYPE_ZERO;
                return &resolver->current;
        }
 
 #if defined(ENABLE_TCP) && defined(HAVE_GETADDRINFO)
-       if (resolver->next == NULL)
-               return NULL;
+       if (resolver->next == nullptr)
+               return nullptr;
 
        resolver->current.family = resolver->next->ai_family;
        resolver->current.protocol = resolver->next->ai_protocol;
@@ -200,6 +197,6 @@ resolver_next(struct resolver *resolver)
 
        return &resolver->current;
 #else
-       return NULL;
+       return nullptr;
 #endif
 }
similarity index 100%
rename from src/net/resolver.h
rename to src/net/resolver.hxx
similarity index 99%
rename from src/net/socket.c
rename to src/net/socket.cxx
index f47770b..e2736f2 100644 (file)
@@ -26,7 +26,7 @@
    SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 */
 
-#include "socket.h"
+#include "socket.hxx"
 
 #ifndef WIN32
 #include <fcntl.h>
similarity index 96%
rename from src/net/socket.h
rename to src/net/socket.hxx
index 099fcaa..5182843 100644 (file)
@@ -29,9 +29,7 @@
 #ifndef NET_SOCKET_H
 #define NET_SOCKET_H
 
-#include "types.h"
-
-#include <stdbool.h>
+#include "types.hxx"
 
 #ifndef WIN32
 #include <errno.h>
@@ -53,7 +51,7 @@ close_socket(socket_t s)
 }
 
 static inline int
-last_socket_error(void)
+last_socket_error()
 {
 #ifdef WIN32
        return WSAGetLastError();
similarity index 100%
rename from src/net/types.h
rename to src/net/types.hxx
similarity index 83%
rename from src/options.c
rename to src/options.cxx
index ca6d415..7d8b768 100644 (file)
  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
  */
 
-#include "options.h"
+#include "options.hxx"
 #include "config.h"
-#include "defaults.h"
-#include "charset.h"
-#include "command.h"
-#include "conf.h"
+#include "charset.hxx"
+#include "command.hxx"
+#include "conf.hxx"
 #include "i18n.h"
 
 #include <stdlib.h>
@@ -46,47 +45,25 @@ typedef struct {
 typedef void (*option_callback_fn_t)(int c, const char *arg);
 
 
-options_t options = {
-       .crossfade_time = DEFAULT_CROSSFADE_TIME,
-       .seek_time = 1,
-#ifdef ENABLE_LYRICS_SCREEN
-       .lyrics_timeout = DEFAULT_LYRICS_TIMEOUT,
-       .lyrics_autosave = false,
-       .lyrics_show_plugin = false,
-       .text_editor_ask = true,
-#endif
-       .find_wrap = true,
-       .scroll_offset = 0,
-       .wide_cursor = true,
-       .audible_bell = true,
-       .bell_on_wrap = true,
-       .status_message_time = 3,
-       .timeout_ms = 0,
-#ifndef NCMPC_MINI
-       .scroll = DEFAULT_SCROLL,
-       .welcome_screen_list = true,
-       .jump_prefix_only = true,
-       .second_column = true,
-#endif
-};
+options_t options;
 
 static const arg_opt_t option_table[] = {
-       { '?', "help", NULL, "Show this help message" },
-       { 'V', "version", NULL, "Display version information" },
-       { 'c', "colors", NULL, "Enable colors" },
-       { 'C', "no-colors", NULL, "Disable colors" },
+       { '?', "help", nullptr, "Show this help message" },
+       { 'V', "version", nullptr, "Display version information" },
+       { 'c', "colors", nullptr, "Enable colors" },
+       { 'C', "no-colors", nullptr, "Disable colors" },
 #ifdef HAVE_GETMOUSE
-       { 'm', "mouse", NULL, "Enable mouse" },
-       { 'M', "no-mouse", NULL, "Disable mouse" },
+       { 'm', "mouse", nullptr, "Enable mouse" },
+       { 'M', "no-mouse", nullptr, "Disable mouse" },
 #endif
-       { 'e', "exit", NULL, "Exit on connection errors" },
+       { 'e', "exit", nullptr, "Exit on connection errors" },
        { 'p', "port", "PORT", "Connect to server on port" },
        { 'h', "host", "HOST", "Connect to server on host" },
        { 'P', "password","PASSWORD", "Connect with password" },
        { 'f', "config", "FILE", "Read configuration from file" },
        { 'k', "key-file","FILE", "Read key bindings from file" },
 #ifndef NDEBUG
-       { 'K', "dump-keys", NULL, "Dump key bindings to stdout" },
+       { 'K', "dump-keys", nullptr, "Dump key bindings to stdout" },
 #endif
 };
 
@@ -104,7 +81,7 @@ lookup_option(int s, char *l)
                        return &option_table[i];
        }
 
-       return NULL;
+       return nullptr;
 }
 
 static void
@@ -132,7 +109,7 @@ option_error(int error, const char *option, const char *arg)
 }
 
 static void
-display_help(void)
+display_help()
 {
        printf("Usage: %s [OPTION]...\n", PACKAGE);
 
@@ -293,7 +270,7 @@ handle_option(int c, const char *arg)
 void
 options_parse(int argc, const char *argv[])
 {
-       const arg_opt_t *opt = NULL;
+       const arg_opt_t *opt = nullptr;
        option_callback_fn_t option_cb = handle_option;
 
        for (int i = 1; i < argc; i++) {
@@ -318,18 +295,18 @@ options_parse(int argc, const char *argv[])
                                name = g_strdup(arg);
 
                        /* check if the option exists */
-                       if( (opt=lookup_option(0, name+2)) == NULL )
-                               option_error(ERROR_UNKNOWN_OPTION, name, NULL);
+                       if( (opt=lookup_option(0, name+2)) == nullptr )
+                               option_error(ERROR_UNKNOWN_OPTION, name, nullptr);
                        g_free(name);
 
                        /* abort if we got an argument to the option and don't want one */
-                       if( value && opt->argument==NULL )
+                       if( value && opt->argument==nullptr )
                                option_error(ERROR_GOT_ARGUMENT, arg, value);
 
                        /* execute option callback */
-                       if (value || opt->argument==NULL) {
+                       if (value || opt->argument==nullptr) {
                                option_cb (opt->shortopt, value);
-                               opt = NULL;
+                               opt = nullptr;
                        }
                }
                /* check for short options */
@@ -343,27 +320,27 @@ options_parse(int argc, const char *argv[])
                                                     opt->longopt, opt->argument);
 
                                /* check if the option exists */
-                               if ((opt=lookup_option(arg[j], NULL)) == NULL)
-                                       option_error(ERROR_UNKNOWN_OPTION, arg, NULL);
+                               if ((opt=lookup_option(arg[j], nullptr)) == nullptr)
+                                       option_error(ERROR_UNKNOWN_OPTION, arg, nullptr);
 
                                /* if no option argument is needed execute callback */
-                               if (opt->argument == NULL) {
-                                       option_cb (opt->shortopt, NULL);
-                                       opt = NULL;
+                               if (opt->argument == nullptr) {
+                                       option_cb (opt->shortopt, nullptr);
+                                       opt = nullptr;
                                }
                        }
                } else {
                        /* is this a option argument? */
                        if (opt && opt->argument) {
                                option_cb (opt->shortopt, arg);
-                               opt = NULL;
+                               opt = nullptr;
                        } else
-                               option_error(ERROR_BAD_ARGUMENT, arg, NULL);
+                               option_error(ERROR_BAD_ARGUMENT, arg, nullptr);
                }
        }
 
-       if (opt && opt->argument == NULL)
-               option_cb (opt->shortopt, NULL);
+       if (opt && opt->argument == nullptr)
+               option_cb (opt->shortopt, nullptr);
        else if (opt && opt->argument)
                option_error(ERROR_MISSING_ARGUMENT, opt->longopt, opt->argument);
 
@@ -374,11 +351,11 @@ options_parse(int argc, const char *argv[])
 }
 
 void
-options_init(void)
+options_init()
 {
        /* default option values */
        options.list_format = g_strdup(DEFAULT_LIST_FORMAT);
-       options.search_format = NULL;
+       options.search_format = nullptr;
        options.status_format = g_strdup(DEFAULT_STATUS_FORMAT);
        options.screen_list = g_strsplit_set(DEFAULT_SCREEN_LIST, " ", 0);
 #ifndef NCMPC_MINI
@@ -387,7 +364,7 @@ options_init(void)
 }
 
 void
-options_deinit(void)
+options_deinit()
 {
        g_free(options.host);
        g_free(options.username);
similarity index 75%
rename from src/options.h
rename to src/options.hxx
index de7c24c..e40f938 100644 (file)
@@ -21,8 +21,8 @@
 #define OPTIONS_H
 
 #include "config.h"
+#include "defaults.hxx"
 
-#include <stdbool.h>
 #include <glib.h>
 
 typedef struct {
@@ -41,36 +41,36 @@ typedef struct {
        char **screen_list;
        bool display_remaining_time;
        int port;
-       int timeout_ms;
-       int crossfade_time;
+       int timeout_ms = 0;
+       int crossfade_time = DEFAULT_CROSSFADE_TIME;
        int search_mode;
        int hide_cursor;
-       int seek_time;
+       int seek_time = 1;
 #ifdef ENABLE_LYRICS_SCREEN
-       int lyrics_timeout;
-       bool lyrics_autosave;
-       bool lyrics_show_plugin;
+       int lyrics_timeout = DEFAULT_LYRICS_TIMEOUT;
+       bool lyrics_autosave = false;
+       bool lyrics_show_plugin = false;
        char *text_editor;
-       bool text_editor_ask;
+       bool text_editor_ask = false;
 #endif
 #ifdef ENABLE_CHAT_SCREEN
        char *chat_prefix;
 #endif
-       bool find_wrap;
+       bool find_wrap = true;
        bool find_show_last_pattern;
        bool list_wrap;
-       int scroll_offset;
+       int scroll_offset = 0;
        bool auto_center;
-       bool wide_cursor;
+       bool wide_cursor = true;
        bool hardware_cursor;
 
 #ifdef ENABLE_COLORS
        bool enable_colors;
 #endif
-       bool audible_bell;
+       bool audible_bell = true;
        bool visible_bell;
-       bool bell_on_wrap;
-       GTime status_message_time;
+       bool bell_on_wrap = true;
+       GTime status_message_time = 3;
 #ifndef NCMPC_MINI
        bool enable_xterm_title;
 #endif
@@ -78,18 +78,18 @@ typedef struct {
        bool enable_mouse;
 #endif
 #ifndef NCMPC_MINI
-       bool scroll;
+       bool scroll = DEFAULT_SCROLL;
        bool visible_bitrate;
-       bool welcome_screen_list;
-       bool jump_prefix_only;
-       bool second_column;
+       bool welcome_screen_list = true;
+       bool jump_prefix_only = true;
+       bool second_column = true;
 #endif
 } options_t;
 
 extern options_t options;
 
-void options_init(void);
-void options_deinit(void);
+void options_init();
+void options_deinit();
 
 void options_parse(int argc, const char **argv);
 
similarity index 97%
rename from src/paint.h
rename to src/paint.hxx
index d1da154..9882a92 100644 (file)
@@ -20,8 +20,8 @@
 #ifndef NCMPC_PAINT_H
 #define NCMPC_PAINT_H
 
-#include "colors.h"
-#include "options.h"
+#include "colors.hxx"
+#include "options.hxx"
 
 /**
  * Sets the specified color, and enables "reverse" mode if selected is
similarity index 87%
rename from src/player_command.c
rename to src/player_command.cxx
index 1a06bfa..a0725bd 100644 (file)
  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
  */
 
-#include "player_command.h"
-#include "mpdclient.h"
-#include "options.h"
+#include "player_command.hxx"
+#include "mpdclient.hxx"
+#include "options.hxx"
 #include "i18n.h"
-#include "screen_client.h"
-#include "screen_status.h"
+#include "screen_client.hxx"
+#include "screen_status.hxx"
 
 int seek_id = -1;
 int seek_target_time;
@@ -36,12 +36,12 @@ commit_seek(struct mpdclient *c)
                return;
 
        struct mpd_connection *connection = mpdclient_get_connection(c);
-       if (connection == NULL) {
+       if (connection == nullptr) {
                seek_id = -1;
                return;
        }
 
-       if (c->song != NULL && (unsigned)seek_id == mpd_song_get_id(c->song))
+       if (c->song != nullptr && (unsigned)seek_id == mpd_song_get_id(c->song))
                if (!mpd_run_seek_id(connection, seek_id, seek_target_time))
                        mpdclient_handle_error(c);
 
@@ -55,7 +55,7 @@ commit_seek(struct mpdclient *c)
 static gboolean
 seek_timer(gpointer data)
 {
-       struct mpdclient *c = data;
+       auto *c = (struct mpdclient *)data;
 
        seek_source_id = 0;
        commit_seek(c);
@@ -71,7 +71,7 @@ schedule_seek_timer(struct mpdclient *c)
 }
 
 void
-cancel_seek_timer(void)
+cancel_seek_timer()
 {
        if (seek_source_id != 0) {
                g_source_remove(seek_source_id);
@@ -98,7 +98,7 @@ setup_seek(struct mpdclient *c)
 bool
 handle_player_command(struct mpdclient *c, command_t cmd)
 {
-       if (!mpdclient_is_connected(c) || c->status == NULL)
+       if (!mpdclient_is_connected(c) || c->status == nullptr)
                return false;
 
        cancel_seek_timer();
@@ -113,7 +113,7 @@ handle_player_command(struct mpdclient *c, command_t cmd)
                */
        case CMD_PAUSE:
                connection = mpdclient_get_connection(c);
-               if (connection == NULL)
+               if (connection == nullptr)
                        break;
 
                if (!mpd_run_pause(connection,
@@ -122,7 +122,7 @@ handle_player_command(struct mpdclient *c, command_t cmd)
                break;
        case CMD_STOP:
                connection = mpdclient_get_connection(c);
-               if (connection == NULL)
+               if (connection == nullptr)
                        break;
 
                if (!mpd_run_stop(connection))
@@ -142,7 +142,7 @@ handle_player_command(struct mpdclient *c, command_t cmd)
 
        case CMD_TRACK_NEXT:
                connection = mpdclient_get_connection(c);
-               if (connection == NULL)
+               if (connection == nullptr)
                        break;
 
                if (!mpd_run_next(connection))
@@ -159,7 +159,7 @@ handle_player_command(struct mpdclient *c, command_t cmd)
 
        case CMD_TRACK_PREVIOUS:
                connection = mpdclient_get_connection(c);
-               if (connection == NULL)
+               if (connection == nullptr)
                        break;
 
                if (!mpd_run_previous(connection))
@@ -167,7 +167,7 @@ handle_player_command(struct mpdclient *c, command_t cmd)
                break;
        case CMD_SHUFFLE:
                connection = mpdclient_get_connection(c);
-               if (connection == NULL)
+               if (connection == nullptr)
                        break;
 
                if (mpd_run_shuffle(connection))
@@ -177,7 +177,7 @@ handle_player_command(struct mpdclient *c, command_t cmd)
                break;
        case CMD_CLEAR:
                connection = mpdclient_get_connection(c);
-               if (connection == NULL)
+               if (connection == nullptr)
                        break;
 
                if (mpdclient_cmd_clear(c))
@@ -185,7 +185,7 @@ handle_player_command(struct mpdclient *c, command_t cmd)
                break;
        case CMD_REPEAT:
                connection = mpdclient_get_connection(c);
-               if (connection == NULL)
+               if (connection == nullptr)
                        break;
 
                if (!mpd_run_repeat(connection,
@@ -194,7 +194,7 @@ handle_player_command(struct mpdclient *c, command_t cmd)
                break;
        case CMD_RANDOM:
                connection = mpdclient_get_connection(c);
-               if (connection == NULL)
+               if (connection == nullptr)
                        break;
 
                if (!mpd_run_random(connection,
@@ -203,7 +203,7 @@ handle_player_command(struct mpdclient *c, command_t cmd)
                break;
        case CMD_SINGLE:
                connection = mpdclient_get_connection(c);
-               if (connection == NULL)
+               if (connection == nullptr)
                        break;
 
                if (!mpd_run_single(connection,
@@ -212,7 +212,7 @@ handle_player_command(struct mpdclient *c, command_t cmd)
                break;
        case CMD_CONSUME:
                connection = mpdclient_get_connection(c);
-               if (connection == NULL)
+               if (connection == nullptr)
                        break;
 
                if (!mpd_run_consume(connection,
@@ -221,7 +221,7 @@ handle_player_command(struct mpdclient *c, command_t cmd)
                break;
        case CMD_CROSSFADE:
                connection = mpdclient_get_connection(c);
-               if (connection == NULL)
+               if (connection == nullptr)
                        break;
 
                if (!mpd_run_crossfade(connection,
@@ -230,7 +230,7 @@ handle_player_command(struct mpdclient *c, command_t cmd)
                        mpdclient_handle_error(c);
                break;
        case CMD_DB_UPDATE:
-               screen_database_update(c, NULL);
+               screen_database_update(c, nullptr);
                break;
        case CMD_VOLUME_UP:
                mpdclient_cmd_volume_up(c);
similarity index 94%
rename from src/player_command.h
rename to src/player_command.hxx
index 99f73e0..da5bf08 100644 (file)
@@ -20,9 +20,7 @@
 #ifndef NCMPC_PLAYER_COMMAND_H
 #define NCMPC_PLAYER_COMMAND_H
 
-#include "command.h"
-
-#include <stdbool.h>
+#include "command.hxx"
 
 struct mpdclient;
 
@@ -34,7 +32,7 @@ extern int seek_target_time;
  * seeking.
  */
 void
-cancel_seek_timer(void);
+cancel_seek_timer();
 
 bool
 handle_player_command(struct mpdclient *c, command_t cmd);
similarity index 95%
rename from src/playlist.c
rename to src/playlist.cxx
index 548bccc..4c12518 100644 (file)
@@ -17,7 +17,7 @@
  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
  */
 
-#include "playlist.h"
+#include "playlist.hxx"
 
 #include <string.h>
 
@@ -45,9 +45,9 @@ playlist_clear(struct mpdclient_playlist *playlist)
 gint
 mpdclient_playlist_free(struct mpdclient_playlist *playlist)
 {
-       if (playlist->list != NULL) {
+       if (playlist->list != nullptr) {
                playlist_clear(playlist);
-               g_ptr_array_free(playlist->list, TRUE);
+               g_ptr_array_free(playlist->list, true);
        }
 
        memset(playlist, 0, sizeof(*playlist));
@@ -58,7 +58,7 @@ const struct mpd_song *
 playlist_get_song(const struct mpdclient_playlist *playlist, gint idx)
 {
        if (idx < 0 || (guint)idx >= playlist_length(playlist))
-               return NULL;
+               return nullptr;
 
        return playlist_get(playlist, idx);
 }
@@ -67,7 +67,7 @@ void
 playlist_move(struct mpdclient_playlist *playlist,
              unsigned dest, unsigned src)
 {
-       assert(playlist != NULL);
+       assert(playlist != nullptr);
        assert(src < playlist_length(playlist));
        assert(dest < playlist_length(playlist));
        assert(src != dest);
@@ -96,7 +96,7 @@ playlist_lookup_song(const struct mpdclient_playlist *playlist, unsigned id)
                        return song;
        }
 
-       return NULL;
+       return nullptr;
 }
 
 gint
similarity index 94%
rename from src/playlist.h
rename to src/playlist.hxx
index e0d8ca5..d203b93 100644 (file)
@@ -49,13 +49,13 @@ mpdclient_playlist_free(struct mpdclient_playlist *playlist);
 static inline guint
 playlist_length(const struct mpdclient_playlist *playlist)
 {
-       assert(playlist != NULL);
-       assert(playlist->list != NULL);
+       assert(playlist != nullptr);
+       assert(playlist->list != nullptr);
 
        return playlist->list->len;
 }
 
-static inline gboolean
+static inline bool
 playlist_is_empty(const struct mpdclient_playlist *playlist)
 {
        return playlist_length(playlist) == 0;
@@ -66,7 +66,7 @@ playlist_get(const struct mpdclient_playlist *playlist, guint idx)
 {
        assert(idx < playlist_length(playlist));
 
-       return g_ptr_array_index(playlist->list, idx);
+       return (struct mpd_song *)g_ptr_array_index(playlist->list, idx);
 }
 
 static inline void
@@ -95,7 +95,7 @@ playlist_replace(struct mpdclient_playlist *playlist, guint idx,
 static inline struct mpd_song *
 playlist_remove_reuse(struct mpdclient_playlist *playlist, guint idx)
 {
-       return g_ptr_array_remove_index(playlist->list, idx);
+       return (struct mpd_song *)g_ptr_array_remove_index(playlist->list, idx);
 }
 
 static inline void
similarity index 82%
rename from src/plugin.c
rename to src/plugin.cxx
index f9049ec..bed36a0 100644 (file)
@@ -17,7 +17,7 @@
  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
  */
 
-#include "plugin.h"
+#include "plugin.hxx"
 #include "Compiler.h"
 
 #include <assert.h>
@@ -96,13 +96,13 @@ plugin_list_sort(struct plugin_list *list, GCompareFunc compare_func)
 bool
 plugin_list_load_directory(struct plugin_list *list, const char *path)
 {
-       GDir *dir = g_dir_open(path, 0, NULL);
-       if (dir == NULL)
+       GDir *dir = g_dir_open(path, 0, nullptr);
+       if (dir == nullptr)
                return false;
 
        const char *name;
-       while ((name = g_dir_read_name(dir)) != NULL) {
-               char *plugin = g_build_filename(path, name, NULL);
+       while ((name = g_dir_read_name(dir)) != nullptr) {
+               char *plugin = g_build_filename(path, name, nullptr);
                if (!register_plugin(list, plugin))
                        g_free(plugin);
        }
@@ -118,7 +118,7 @@ void plugin_list_deinit(struct plugin_list *list)
 {
        for (guint i = 0; i < list->plugins->len; ++i)
                free(g_ptr_array_index(list->plugins, i));
-       g_ptr_array_free(list->plugins, TRUE);
+       g_ptr_array_free(list->plugins, true);
 }
 
 static void
@@ -149,10 +149,10 @@ plugin_eof(struct plugin_cycle *cycle, struct plugin_pipe *p)
                                               cycle->pipe_stderr.data->str);
 
                /* the plugin has failed */
-               g_string_free(cycle->pipe_stdout.data, TRUE);
-               cycle->pipe_stdout.data = NULL;
-               g_string_free(cycle->pipe_stderr.data, TRUE);
-               cycle->pipe_stderr.data = NULL;
+               g_string_free(cycle->pipe_stdout.data, true);
+               cycle->pipe_stdout.data = nullptr;
+               g_string_free(cycle->pipe_stderr.data, true);
+               cycle->pipe_stderr.data = nullptr;
 
                next_plugin(cycle);
        } else {
@@ -166,11 +166,11 @@ static gboolean
 plugin_data(gcc_unused GIOChannel *source,
            gcc_unused GIOCondition condition, gpointer data)
 {
-       struct plugin_pipe *p = data;
+       auto *p = (struct plugin_pipe *)data;
        assert(p->fd >= 0);
 
        struct plugin_cycle *cycle = p->cycle;
-       assert(cycle != NULL);
+       assert(cycle != nullptr);
        assert(cycle->pid > 0);
 
        char buffer[256];
@@ -179,11 +179,11 @@ plugin_data(gcc_unused GIOChannel *source,
                : 0;
        if (nbytes <= 0) {
                plugin_eof(cycle, p);
-               return FALSE;
+               return false;
        }
 
        g_string_append_len(p->data, buffer, nbytes);
-       return TRUE;
+       return true;
 }
 
 /**
@@ -196,16 +196,16 @@ plugin_data(gcc_unused GIOChannel *source,
 static gboolean
 plugin_delayed_fail(gpointer data)
 {
-       struct plugin_cycle *cycle = data;
+       auto *cycle = (struct plugin_cycle *)data;
 
-       assert(cycle != NULL);
+       assert(cycle != nullptr);
        assert(cycle->pipe_stdout.fd < 0);
        assert(cycle->pipe_stderr.fd < 0);
        assert(cycle->pid < 0);
 
-       cycle->callback(cycle->all_errors, false, NULL, cycle->callback_data);
+       cycle->callback(cycle->all_errors, false, nullptr, cycle->callback_data);
 
-       return FALSE;
+       return false;
 }
 
 static void
@@ -213,9 +213,9 @@ plugin_fd_add(struct plugin_cycle *cycle, struct plugin_pipe *p, int fd)
 {
        p->cycle = cycle;
        p->fd = fd;
-       p->data = g_string_new(NULL);
+       p->data = g_string_new(nullptr);
        GIOChannel *channel = g_io_channel_unix_new(fd);
-       p->event_id = g_io_add_watch(channel, G_IO_IN|G_IO_HUP,
+       p->event_id = g_io_add_watch(channel, GIOCondition(G_IO_IN|G_IO_HUP),
                                     plugin_data, p);
        g_io_channel_unref(channel);
 }
@@ -223,12 +223,12 @@ plugin_fd_add(struct plugin_cycle *cycle, struct plugin_pipe *p, int fd)
 static int
 start_plugin(struct plugin_cycle *cycle, const char *plugin_path)
 {
-       assert(cycle != NULL);
+       assert(cycle != nullptr);
        assert(cycle->pid < 0);
        assert(cycle->pipe_stdout.fd < 0);
        assert(cycle->pipe_stderr.fd < 0);
-       assert(cycle->pipe_stdout.data == NULL);
-       assert(cycle->pipe_stderr.data == NULL);
+       assert(cycle->pipe_stdout.data == nullptr);
+       assert(cycle->pipe_stderr.data == nullptr);
 
        /* set new program name, but free the one from the previous
           plugin */
@@ -289,8 +289,8 @@ next_plugin(struct plugin_cycle *cycle)
        assert(cycle->pid < 0);
        assert(cycle->pipe_stdout.fd < 0);
        assert(cycle->pipe_stderr.fd < 0);
-       assert(cycle->pipe_stdout.data == NULL);
-       assert(cycle->pipe_stderr.data == NULL);
+       assert(cycle->pipe_stdout.data == nullptr);
+       assert(cycle->pipe_stderr.data == nullptr);
 
        if (cycle->next_plugin >= cycle->list->plugins->len) {
                /* no plugins left */
@@ -298,8 +298,8 @@ next_plugin(struct plugin_cycle *cycle)
                return;
        }
 
-       const char *plugin_path = g_ptr_array_index(cycle->list->plugins,
-                                                   cycle->next_plugin++);
+       const char *plugin_path = (const char *)
+               g_ptr_array_index(cycle->list->plugins, cycle->next_plugin++);
        if (start_plugin(cycle, plugin_path) < 0) {
                /* system error */
                g_idle_add(plugin_delayed_fail, cycle);
@@ -311,20 +311,20 @@ static char **
 make_argv(const char*const* args)
 {
        unsigned num = 0;
-       while (args[num] != NULL)
+       while (args[num] != nullptr)
                ++num;
        num += 2;
 
        char **ret = g_new(char *, num);
 
        /* reserve space for the program name */
-       *ret++ = NULL;
+       *ret++ = nullptr;
 
-       while (*args != NULL)
+       while (*args != nullptr)
                *ret++ = g_strdup(*args++);
 
        /* end of argument vector */
-       *ret++ = NULL;
+       *ret++ = nullptr;
 
        return ret - num;
 }
@@ -335,7 +335,7 @@ plugin_run(struct plugin_list *list, const char *const*args,
 {
        struct plugin_cycle *cycle = g_new(struct plugin_cycle, 1);
 
-       assert(args != NULL);
+       assert(args != nullptr);
 
        cycle->list = list;
        cycle->argv = make_argv(args);
@@ -345,10 +345,10 @@ plugin_run(struct plugin_list *list, const char *const*args,
        cycle->pid = -1;
        cycle->pipe_stdout.fd = -1;
        cycle->pipe_stderr.fd = -1;
-       cycle->pipe_stdout.data = NULL;
-       cycle->pipe_stderr.data = NULL;
+       cycle->pipe_stdout.data = nullptr;
+       cycle->pipe_stderr.data = nullptr;
 
-       cycle->all_errors = g_string_new(NULL);
+       cycle->all_errors = g_string_new(nullptr);
        next_plugin(cycle);
 
        return cycle;
@@ -378,15 +378,15 @@ plugin_stop(struct plugin_cycle *cycle)
        }
 
        /* free data that has been received */
-       if (cycle->pipe_stdout.data != NULL)
-               g_string_free(cycle->pipe_stdout.data, TRUE);
-       if (cycle->pipe_stderr.data != NULL)
-               g_string_free(cycle->pipe_stderr.data, TRUE);
-       if (cycle->all_errors != NULL)
-               g_string_free(cycle->all_errors, TRUE);
+       if (cycle->pipe_stdout.data != nullptr)
+               g_string_free(cycle->pipe_stdout.data, true);
+       if (cycle->pipe_stderr.data != nullptr)
+               g_string_free(cycle->pipe_stderr.data, true);
+       if (cycle->all_errors != nullptr)
+               g_string_free(cycle->all_errors, true);
 
        /* free argument list */
-       for (guint i = 0; i == 0 || cycle->argv[i] != NULL; ++i)
+       for (guint i = 0; i == 0 || cycle->argv[i] != nullptr; ++i)
                g_free(cycle->argv[i]);
        g_free(cycle->argv);
 
similarity index 97%
rename from src/plugin.h
rename to src/plugin.hxx
index 9f2d771..62639ab 100644 (file)
@@ -21,7 +21,6 @@
 #define PLUGIN_H
 
 #include <glib.h>
-#include <stdbool.h>
 
 /**
  * A list of registered plugins.
@@ -77,7 +76,7 @@ void plugin_list_deinit(struct plugin_list *list);
  * plugin list is exhausted).
  *
  * @param list the plugin list
- * @param args NULL terminated command line arguments passed to the
+ * @param args nullptr terminated command line arguments passed to the
  * plugin programs
  * @param callback the callback function which will be called when a
  * result is available
similarity index 95%
rename from src/progress_bar.c
rename to src/progress_bar.cxx
index 9df7a51..6dcad99 100644 (file)
  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
  */
 
-#include "progress_bar.h"
+#include "progress_bar.hxx"
 
 #include <assert.h>
 
 void
 progress_bar_paint(const struct progress_bar *p)
 {
-       assert(p != NULL);
+       assert(p != nullptr);
 
        mvwhline(p->window.w, 0, 0, ACS_HLINE, p->window.cols);
 
@@ -56,7 +56,7 @@ progress_bar_calc(struct progress_bar *p)
 void
 progress_bar_resize(struct progress_bar *p, unsigned width, int y, int x)
 {
-       assert(p != NULL);
+       assert(p != nullptr);
 
        p->window.cols = width;
        wresize(p->window.w, 1, width);
@@ -68,7 +68,7 @@ progress_bar_resize(struct progress_bar *p, unsigned width, int y, int x)
 bool
 progress_bar_set(struct progress_bar *p, unsigned current, unsigned max)
 {
-       assert(p != NULL);
+       assert(p != nullptr);
 
        if (current > max)
                current = max;
similarity index 95%
rename from src/progress_bar.h
rename to src/progress_bar.hxx
index 1c241ff..a39ffdb 100644 (file)
@@ -20,9 +20,7 @@
 #ifndef NCMPC_PROGRESS_BAR_H
 #define NCMPC_PROGRESS_BAR_H
 
-#include "window.h"
-
-#include <stdbool.h>
+#include "window.hxx"
 
 struct progress_bar {
        struct window window;
@@ -36,7 +34,7 @@ static inline void
 progress_bar_init(struct progress_bar *p, unsigned width, int y, int x)
 {
        window_init(&p->window, 1, width, y, x);
-       leaveok(p->window.w, TRUE);
+       leaveok(p->window.w, true);
 
        p->current = 0;
        p->max = 0;
similarity index 86%
rename from src/save_playlist.c
rename to src/save_playlist.cxx
index ed2134d..1a4daa7 100644 (file)
  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
  */
 
-#include "save_playlist.h"
-#include "db_completion.h"
-#include "screen_status.h"
+#include "save_playlist.hxx"
+#include "db_completion.hxx"
+#include "screen_status.hxx"
 #include "config.h"
 #include "i18n.h"
-#include "charset.h"
-#include "mpdclient.h"
-#include "utils.h"
-#include "wreadln.h"
-#include "screen_utils.h"
+#include "charset.hxx"
+#include "mpdclient.hxx"
+#include "utils.hxx"
+#include "wreadln.hxx"
+#include "screen_utils.hxx"
 #include "Compiler.h"
 
 #include <mpd/client.h>
@@ -62,9 +62,9 @@ save_pre_completion_cb(GCompletion *gcmp, gcc_unused gchar *line,
        GList **list = tmp->list;
        struct mpdclient *c = tmp->c;
 
-       if( *list == NULL ) {
+       if( *list == nullptr ) {
                /* create completion list */
-               *list = gcmp_list_from_path(c, "", NULL, GCMP_TYPE_PLAYLIST);
+               *list = gcmp_list_from_path(c, "", nullptr, GCMP_TYPE_PLAYLIST);
                g_completion_add_items(gcmp, *list);
        }
 }
@@ -91,11 +91,11 @@ playlist_save(struct mpdclient *c, char *name, char *defaultname)
 #endif
 
 #ifndef NCMPC_MINI
-       if (name == NULL) {
+       if (name == nullptr) {
                /* initialize completion support */
-               GCompletion *gcmp = g_completion_new(NULL);
+               GCompletion *gcmp = g_completion_new(nullptr);
                g_completion_set_compare(gcmp, completion_strncmp);
-               GList *list = NULL;
+               GList *list = nullptr;
                completion_callback_data_t data = {
                        .list = &list,
                        .c = c,
@@ -108,15 +108,15 @@ playlist_save(struct mpdclient *c, char *name, char *defaultname)
                /* query the user for a filename */
                filename = screen_readln(_("Save queue as"),
                                         defaultname,
-                                        NULL,
+                                        nullptr,
                                         gcmp);
-               if (filename == NULL)
+               if (filename == nullptr)
                        return -1;
 
                /* destroy completion support */
-               wrln_completion_callback_data = NULL;
-               wrln_pre_completion_callback = NULL;
-               wrln_post_completion_callback = NULL;
+               wrln_completion_callback_data = nullptr;
+               wrln_pre_completion_callback = nullptr;
+               wrln_post_completion_callback = nullptr;
                g_completion_free(gcmp);
                list = string_list_free(list);
                filename = g_strstrip(filename);
@@ -127,7 +127,7 @@ playlist_save(struct mpdclient *c, char *name, char *defaultname)
        /* send save command to mpd */
 
        connection = mpdclient_get_connection(c);
-       if (connection == NULL) {
+       if (connection == nullptr) {
                g_free(filename);
                return -1;
        }
similarity index 100%
rename from src/save_playlist.h
rename to src/save_playlist.hxx
similarity index 88%
rename from src/screen.c
rename to src/screen.cxx
index abd241d..08911e7 100644 (file)
  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
  */
 
-#include "screen.h"
-#include "screen_interface.h"
-#include "screen_list.h"
-#include "screen_status.h"
+#include "screen.hxx"
+#include "screen_interface.hxx"
+#include "screen_list.hxx"
+#include "screen_status.hxx"
 #include "config.h"
 #include "i18n.h"
-#include "charset.h"
-#include "mpdclient.h"
-#include "options.h"
-#include "player_command.h"
-#include "screen_help.h"
-#include "screen_queue.h"
-#include "screen_file.h"
-#include "screen_artist.h"
-#include "screen_search.h"
-#include "screen_song.h"
-#include "screen_keydef.h"
-#include "screen_lyrics.h"
-#include "screen_outputs.h"
-#include "screen_chat.h"
+#include "charset.hxx"
+#include "mpdclient.hxx"
+#include "options.hxx"
+#include "player_command.hxx"
+#include "screen_help.hxx"
+#include "screen_queue.hxx"
+#include "screen_file.hxx"
+#include "screen_artist.hxx"
+#include "screen_search.hxx"
+#include "screen_song.hxx"
+#include "screen_keydef.hxx"
+#include "screen_lyrics.hxx"
+#include "screen_outputs.hxx"
+#include "screen_chat.hxx"
 
 #include <mpd/client.h>
 
 
 /* screens */
 
-struct screen screen = {
-       .current_page = &screen_queue,
-};
+struct screen screen;
 
 static const struct screen_functions *mode_fn_prev = &screen_queue;
 
 void
 screen_switch(const struct screen_functions *sf, struct mpdclient *c)
 {
-       assert(sf != NULL);
+       assert(sf != nullptr);
 
        if (sf == screen.current_page)
                return;
@@ -64,14 +62,14 @@ screen_switch(const struct screen_functions *sf, struct mpdclient *c)
        mode_fn_prev = screen.current_page;
 
        /* close the old mode */
-       if (screen.current_page->close != NULL)
+       if (screen.current_page->close != nullptr)
                screen.current_page->close();
 
        /* get functions for the new mode */
        screen.current_page = sf;
 
        /* open the new mode */
-       if (sf->open != NULL)
+       if (sf->open != nullptr)
                sf->open(c);
 
        screen_paint(c, true);
@@ -80,7 +78,7 @@ screen_switch(const struct screen_functions *sf, struct mpdclient *c)
 void
 screen_swap(struct mpdclient *c, const struct mpd_song *song)
 {
-       if (song != NULL)
+       if (song != nullptr)
        {
                if (false)
                        { /* just a hack to make the ifdefs less ugly */ }
@@ -104,7 +102,7 @@ find_configured_screen(const char *name)
 {
        unsigned i;
 
-       for (i = 0; options.screen_list[i] != NULL; ++i)
+       for (i = 0; options.screen_list[i] != nullptr; ++i)
                if (strcmp(options.screen_list[i], name) == 0)
                        return i;
 
@@ -126,7 +124,7 @@ screen_next_mode(struct mpdclient *c, int offset)
 
        const struct screen_functions *sf =
                screen_lookup_name(options.screen_list[next]);
-       if (sf != NULL)
+       if (sf != nullptr)
                screen_switch(sf, c);
 }
 
@@ -143,7 +141,7 @@ screen_update(struct mpdclient *c)
        static unsigned crossfade;
 
        /* print a message if mpd status has changed */
-       if ((c->events & MPD_IDLE_OPTIONS) && c->status != NULL) {
+       if ((c->events & MPD_IDLE_OPTIONS) && c->status != nullptr) {
                if (!initialized) {
                        repeat = mpd_status_get_repeat(c->status);
                        random_enabled = mpd_status_get_random(c->status);
@@ -200,7 +198,7 @@ screen_update(struct mpdclient *c)
 #endif
 
        /* update the main window */
-       if (screen.current_page->update != NULL)
+       if (screen.current_page->update != nullptr)
                screen.current_page->update(c);
 
        screen_paint(c, false);
@@ -216,7 +214,7 @@ screen_cmd(struct mpdclient *c, command_t cmd)
        }
 #endif
 
-       if (screen.current_page->cmd != NULL &&
+       if (screen.current_page->cmd != nullptr &&
            screen.current_page->cmd(c, cmd))
                return;
 
@@ -292,7 +290,7 @@ screen_cmd(struct mpdclient *c, command_t cmd)
                break;
 #endif
        case CMD_SCREEN_SWAP:
-               screen_swap(c, NULL);
+               screen_swap(c, nullptr);
                break;
 
        default:
@@ -305,7 +303,7 @@ screen_cmd(struct mpdclient *c, command_t cmd)
 static bool
 screen_current_page_mouse(struct mpdclient *c, int x, int y, mmask_t bstate)
 {
-       if (screen.current_page->mouse == NULL)
+       if (screen.current_page->mouse == nullptr)
                return false;
 
        y -= screen.title_bar.window.rows;
similarity index 93%
rename from src/screen.h
rename to src/screen.hxx
index 3d7bc39..899c873 100644 (file)
 #define SCREEN_H
 
 #include "config.h"
-#include "command.h"
-#include "window.h"
-#include "title_bar.h"
-#include "progress_bar.h"
-#include "status_bar.h"
+#include "command.hxx"
+#include "window.hxx"
+#include "title_bar.hxx"
+#include "progress_bar.hxx"
+#include "status_bar.hxx"
 #include "ncmpc_curses.h"
 
 #include <mpd/client.h>
 
 #include <glib.h>
 
-#include <stdbool.h>
-
 struct mpdclient;
 struct screen_functions;
 
@@ -63,7 +61,7 @@ struct screen {
 extern struct screen screen;
 
 void screen_init(struct mpdclient *c);
-void screen_exit(void);
+void screen_exit();
 void screen_resize(struct mpdclient *c);
 
 void
similarity index 84%
rename from src/screen_artist.c
rename to src/screen_artist.cxx
index 672c93f..20df381 100644 (file)
  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
  */
 
-#include "screen_artist.h"
-#include "screen_interface.h"
-#include "screen_status.h"
-#include "screen_find.h"
-#include "screen_browser.h"
-#include "screen.h"
+#include "screen_artist.hxx"
+#include "screen_interface.hxx"
+#include "screen_status.hxx"
+#include "screen_find.hxx"
+#include "screen_browser.hxx"
+#include "screen.hxx"
 #include "i18n.h"
-#include "charset.h"
-#include "mpdclient.h"
-#include "screen_browser.h"
-#include "filelist.h"
-#include "options.h"
+#include "charset.hxx"
+#include "mpdclient.hxx"
+#include "screen_browser.hxx"
+#include "filelist.hxx"
+#include "options.hxx"
 
 #include <assert.h>
 #include <string.h>
@@ -40,8 +40,8 @@ typedef enum { LIST_ARTISTS, LIST_ALBUMS, LIST_SONGS } artist_mode_t;
 
 static artist_mode_t mode = LIST_ARTISTS;
 static GPtrArray *artist_list, *album_list;
-static char *artist = NULL;
-static char *album  = NULL;
+static char *artist = nullptr;
+static char *album  = nullptr;
 static char ALL_TRACKS[] = "";
 
 static struct screen_browser browser;
@@ -49,7 +49,7 @@ static struct screen_browser browser;
 static gint
 compare_utf8(gconstpointer s1, gconstpointer s2)
 {
-       const char *const*t1 = s1, *const*t2 = s2;
+       const char *const*t1 = (const char *const*)s1, *const*t2 = (const char *const*)s2;
 
        char *key1 = g_utf8_collate_key(*t1,-1);
        char *key2 = g_utf8_collate_key(*t2,-1);
@@ -63,7 +63,7 @@ compare_utf8(gconstpointer s1, gconstpointer s2)
 static const char *
 screen_artist_lw_callback(unsigned idx, void *data)
 {
-       GPtrArray *list = data;
+       GPtrArray *list = (GPtrArray *)data;
 
        if (mode == LIST_ALBUMS) {
                if (idx == 0)
@@ -76,8 +76,8 @@ screen_artist_lw_callback(unsigned idx, void *data)
 
        assert(idx < list->len);
 
-       char *str_utf8 = g_ptr_array_index(list, idx);
-       assert(str_utf8 != NULL);
+       const char *str_utf8 = (char *)g_ptr_array_index(list, idx);
+       assert(str_utf8 != nullptr);
 
        char *str = utf8_to_locale(str_utf8);
 
@@ -92,29 +92,29 @@ static void
 string_array_free(GPtrArray *array)
 {
        for (unsigned i = 0; i < array->len; ++i) {
-               char *value = g_ptr_array_index(array, i);
+               char *value = (char *)g_ptr_array_index(array, i);
                g_free(value);
        }
 
-       g_ptr_array_free(array, TRUE);
+       g_ptr_array_free(array, true);
 }
 
 static void
-free_lists(void)
+free_lists()
 {
-       if (artist_list != NULL) {
+       if (artist_list != nullptr) {
                string_array_free(artist_list);
-               artist_list = NULL;
+               artist_list = nullptr;
        }
 
-       if (album_list != NULL) {
+       if (album_list != nullptr) {
                string_array_free(album_list);
-               album_list = NULL;
+               album_list = nullptr;
        }
 
        if (browser.filelist) {
                filelist_free(browser.filelist);
-               browser.filelist = NULL;
+               browser.filelist = nullptr;
        }
 }
 
@@ -124,7 +124,7 @@ recv_tag_values(struct mpd_connection *connection, enum mpd_tag_type tag,
 {
        struct mpd_pair *pair;
 
-       while ((pair = mpd_recv_pair_tag(connection, tag)) != NULL) {
+       while ((pair = mpd_recv_pair_tag(connection, tag)) != nullptr) {
                g_ptr_array_add(list, g_strdup(pair->value));
                mpd_return_pair(connection, pair);
        }
@@ -136,15 +136,15 @@ load_artist_list(struct mpdclient *c)
        struct mpd_connection *connection = mpdclient_get_connection(c);
 
        assert(mode == LIST_ARTISTS);
-       assert(artist == NULL);
-       assert(album == NULL);
-       assert(artist_list == NULL);
-       assert(album_list == NULL);
-       assert(browser.filelist == NULL);
+       assert(artist == nullptr);
+       assert(album == nullptr);
+       assert(artist_list == nullptr);
+       assert(album_list == nullptr);
+       assert(browser.filelist == nullptr);
 
        artist_list = g_ptr_array_new();
 
-       if (connection != NULL) {
+       if (connection != nullptr) {
                mpd_search_db_tags(connection, MPD_TAG_ARTIST);
                mpd_search_commit(connection);
                recv_tag_values(connection, MPD_TAG_ARTIST, artist_list);
@@ -163,14 +163,14 @@ load_album_list(struct mpdclient *c)
        struct mpd_connection *connection = mpdclient_get_connection(c);
 
        assert(mode == LIST_ALBUMS);
-       assert(artist != NULL);
-       assert(album == NULL);
-       assert(album_list == NULL);
-       assert(browser.filelist == NULL);
+       assert(artist != nullptr);
+       assert(album == nullptr);
+       assert(album_list == nullptr);
+       assert(browser.filelist == nullptr);
 
        album_list = g_ptr_array_new();
 
-       if (connection != NULL) {
+       if (connection != nullptr) {
                mpd_search_db_tags(connection, MPD_TAG_ALBUM);
                mpd_search_add_tag_constraint(connection,
                                              MPD_OPERATOR_DEFAULT,
@@ -194,15 +194,15 @@ load_song_list(struct mpdclient *c)
        struct mpd_connection *connection = mpdclient_get_connection(c);
 
        assert(mode == LIST_SONGS);
-       assert(artist != NULL);
-       assert(album != NULL);
-       assert(browser.filelist == NULL);
+       assert(artist != nullptr);
+       assert(album != nullptr);
+       assert(browser.filelist == nullptr);
 
        browser.filelist = filelist_new();
        /* add a dummy entry for ".." */
-       filelist_append(browser.filelist, NULL);
+       filelist_append(browser.filelist, nullptr);
 
-       if (connection != NULL) {
+       if (connection != nullptr) {
                mpd_search_db_songs(connection, true);
                mpd_search_add_tag_constraint(connection, MPD_OPERATOR_DEFAULT,
                                              MPD_TAG_ARTIST, artist);
@@ -222,13 +222,13 @@ load_song_list(struct mpdclient *c)
 }
 
 static void
-free_state(void)
+free_state()
 {
        g_free(artist);
        if (album != ALL_TRACKS)
                g_free(album);
-       artist = NULL;
-       album = NULL;
+       artist = nullptr;
+       album = nullptr;
 
        free_lists();
 }
@@ -245,7 +245,7 @@ open_artist_list(struct mpdclient *c)
 static void
 open_album_list(struct mpdclient *c, char *_artist)
 {
-       assert(_artist != NULL);
+       assert(_artist != nullptr);
 
        free_state();
 
@@ -257,8 +257,8 @@ open_album_list(struct mpdclient *c, char *_artist)
 static void
 open_song_list(struct mpdclient *c, char *_artist, char *_album)
 {
-       assert(_artist != NULL);
-       assert(_album != NULL);
+       assert(_artist != nullptr);
+       assert(_album != nullptr);
 
        free_state();
 
@@ -293,12 +293,12 @@ screen_artist_init(WINDOW *w, unsigned cols, unsigned rows)
 {
        browser.lw = list_window_init(w, cols, rows);
        browser.song_format = options.list_format;
-       artist = NULL;
-       album = NULL;
+       artist = nullptr;
+       album = nullptr;
 }
 
 static void
-screen_artist_quit(void)
+screen_artist_quit()
 {
        free_state();
        list_window_free(browser.lw);
@@ -307,8 +307,8 @@ screen_artist_quit(void)
 static void
 screen_artist_open(struct mpdclient *c)
 {
-       if (artist_list == NULL && album_list == NULL &&
-           browser.filelist == NULL)
+       if (artist_list == nullptr && album_list == nullptr &&
+           browser.filelist == nullptr)
                reload_lists(c);
 }
 
@@ -326,8 +326,8 @@ paint_artist_callback(WINDOW *w, unsigned i,
                      gcc_unused unsigned y, unsigned width,
                      bool selected, const void *data)
 {
-       const GPtrArray *list = data;
-       char *p = utf8_to_locale(g_ptr_array_index(list, i));
+       const GPtrArray *list = (const GPtrArray *)data;
+       char *p = utf8_to_locale((const char *)g_ptr_array_index(list, i));
 
        screen_browser_paint_directory(w, width, selected, p);
        g_free(p);
@@ -344,30 +344,30 @@ paint_album_callback(WINDOW *w, unsigned i,
                     gcc_unused unsigned y, unsigned width,
                     bool selected, const void *data)
 {
-       const GPtrArray *list = data;
+       const GPtrArray *list = (const GPtrArray *)data;
        const char *p;
-       char *q = NULL;
+       char *q = nullptr;
 
        if (i == 0)
                p = "..";
        else if (i == list->len + 1)
                p = _("All tracks");
        else
-               p = q = utf8_to_locale(g_ptr_array_index(list, i - 1));
+               p = q = utf8_to_locale((const char *)g_ptr_array_index(list, i - 1));
 
        screen_browser_paint_directory(w, width, selected, p);
        g_free(q);
 }
 
 static void
-screen_artist_paint(void)
+screen_artist_paint()
 {
        if (browser.filelist) {
                screen_browser_paint(&browser);
-       } else if (album_list != NULL)
+       } else if (album_list != nullptr)
                list_window_paint2(browser.lw,
                                   paint_album_callback, album_list);
-       else if (artist_list != NULL)
+       else if (artist_list != nullptr)
                list_window_paint2(browser.lw,
                                   paint_artist_callback, artist_list);
        else {
@@ -415,7 +415,7 @@ screen_artist_get_title(char *str, size_t size)
 static void
 screen_artist_update(struct mpdclient *c)
 {
-       if (browser.filelist == NULL)
+       if (browser.filelist == nullptr)
                return;
 
        if (c->events & MPD_IDLE_DATABASE)
@@ -442,9 +442,9 @@ add_query(struct mpdclient *c, enum mpd_tag_type table, const char *_filter,
 {
        struct mpd_connection *connection = mpdclient_get_connection(c);
 
-       assert(_filter != NULL);
+       assert(_filter != nullptr);
 
-       if (connection == NULL)
+       if (connection == nullptr)
                return;
 
        char *str = utf8_to_locale(_filter);
@@ -504,7 +504,7 @@ screen_artist_cmd(struct mpdclient *c, command_t cmd)
 {
        switch(cmd) {
                struct list_window_range range;
-               char *selected;
+               const char *selected;
                char *old;
                char *old_ptr;
                int idx;
@@ -515,8 +515,8 @@ screen_artist_cmd(struct mpdclient *c, command_t cmd)
                        if (browser.lw->selected >= artist_list->len)
                                return true;
 
-                       selected = g_ptr_array_index(artist_list,
-                                                    browser.lw->selected);
+                       selected = (const char *)g_ptr_array_index(artist_list,
+                                                                  browser.lw->selected);
                        open_album_list(c, g_strdup(selected));
                        list_window_reset(browser.lw);
 
@@ -544,8 +544,8 @@ screen_artist_cmd(struct mpdclient *c, command_t cmd)
                                list_window_reset(browser.lw);
                        } else {
                                /* select album */
-                               selected = g_ptr_array_index(album_list,
-                                                            browser.lw->selected - 1);
+                               selected = (const char *)g_ptr_array_index(album_list,
+                                                                          browser.lw->selected - 1);
                                open_song_list(c, g_strdup(artist), g_strdup(selected));
                                list_window_reset(browser.lw);
                        }
@@ -651,8 +651,8 @@ screen_artist_cmd(struct mpdclient *c, command_t cmd)
 
                        list_window_get_range(browser.lw, &range);
                        for (unsigned i = range.start; i < range.end; ++i) {
-                               selected = g_ptr_array_index(artist_list, i);
-                               add_query(c, MPD_TAG_ARTIST, selected, NULL);
+                               selected = (const char *)g_ptr_array_index(artist_list, i);
+                               add_query(c, MPD_TAG_ARTIST, selected, nullptr);
                                cmd = CMD_LIST_NEXT; /* continue and select next item... */
                        }
                        break;
@@ -661,11 +661,11 @@ screen_artist_cmd(struct mpdclient *c, command_t cmd)
                        list_window_get_range(browser.lw, &range);
                        for (unsigned i = range.start; i < range.end; ++i) {
                                if(i == album_list->len + 1)
-                                       add_query(c, MPD_TAG_ARTIST, artist, NULL);
+                                       add_query(c, MPD_TAG_ARTIST, artist, nullptr);
                                else if (i > 0)
                                {
-                                       selected = g_ptr_array_index(album_list,
-                                                                    browser.lw->selected - 1);
+                                       selected = (const char *)g_ptr_array_index(album_list,
+                                                                                  browser.lw->selected - 1);
                                        add_query(c, MPD_TAG_ALBUM, selected, artist);
                                        cmd = CMD_LIST_NEXT; /* continue and select next item... */
                                }
@@ -759,6 +759,7 @@ const struct screen_functions screen_artist = {
        .init = screen_artist_init,
        .exit = screen_artist_quit,
        .open = screen_artist_open,
+       .close = nullptr,
        .resize = screen_artist_resize,
        .paint = screen_artist_paint,
        .update = screen_artist_update,
similarity index 100%
rename from src/screen_artist.h
rename to src/screen_artist.hxx
similarity index 88%
rename from src/screen_browser.c
rename to src/screen_browser.cxx
index e0c37cb..dedcd77 100644 (file)
  */
 
 #include "config.h"
-#include "screen_browser.h"
-#include "screen_file.h"
-#include "screen_song.h"
-#include "screen_lyrics.h"
-#include "screen_status.h"
-#include "screen_find.h"
-#include "screen.h"
+#include "screen_browser.hxx"
+#include "screen_file.hxx"
+#include "screen_song.hxx"
+#include "screen_lyrics.hxx"
+#include "screen_status.hxx"
+#include "screen_find.hxx"
+#include "screen.hxx"
 #include "i18n.h"
-#include "options.h"
-#include "charset.h"
-#include "strfsong.h"
-#include "mpdclient.h"
-#include "filelist.h"
-#include "colors.h"
-#include "paint.h"
-#include "song_paint.h"
+#include "options.hxx"
+#include "charset.hxx"
+#include "strfsong.hxx"
+#include "mpdclient.hxx"
+#include "filelist.hxx"
+#include "colors.hxx"
+#include "paint.hxx"
+#include "song_paint.hxx"
 
 #include <mpd/client.h>
 
@@ -56,7 +56,7 @@ screen_browser_sync_highlights(struct filelist *fl,
                struct filelist_entry *entry = filelist_get(fl, i);
                const struct mpd_entity *entity = entry->entity;
 
-               if (entity != NULL && mpd_entity_get_type(entity) == MPD_ENTITY_TYPE_SONG) {
+               if (entity != nullptr && mpd_entity_get_type(entity) == MPD_ENTITY_TYPE_SONG) {
                        const struct mpd_song *song =
                                mpd_entity_get_song(entity);
 
@@ -78,15 +78,15 @@ browser_lw_callback(unsigned idx, void *data)
        const struct filelist *fl = (const struct filelist *) data;
        static char buf[BUFSIZE];
 
-       assert(fl != NULL);
+       assert(fl != nullptr);
        assert(idx < filelist_length(fl));
 
        const struct filelist_entry *entry = filelist_get(fl, idx);
-       assert(entry != NULL);
+       assert(entry != nullptr);
 
        const struct mpd_entity *entity = entry->entity;
 
-       if( entity == NULL )
+       if( entity == nullptr )
                return "..";
 
        if (mpd_entity_get_type(entity) == MPD_ENTITY_TYPE_DIRECTORY) {
@@ -119,7 +119,7 @@ load_playlist(struct mpdclient *c, const struct mpd_playlist *playlist)
 {
        struct mpd_connection *connection = mpdclient_get_connection(c);
 
-       if (connection == NULL)
+       if (connection == nullptr)
                return false;
 
        if (mpd_run_load(connection, mpd_playlist_get_path(playlist))) {
@@ -139,7 +139,7 @@ static bool
 enqueue_and_play(struct mpdclient *c, struct filelist_entry *entry)
 {
        struct mpd_connection *connection = mpdclient_get_connection(c);
-       if (connection == NULL)
+       if (connection == nullptr)
                return false;
 
        const struct mpd_song *song = mpd_entity_get_song(entry->entity);
@@ -183,11 +183,11 @@ browser_get_selected_entry(const struct screen_browser *browser)
 
        list_window_get_range(browser->lw, &range);
 
-       if (browser->filelist == NULL ||
+       if (browser->filelist == nullptr ||
            range.end <= range.start ||
            range.end > range.start + 1 ||
            range.start >= filelist_length(browser->filelist))
-               return NULL;
+               return nullptr;
 
        return filelist_get(browser->filelist, range.start);
 }
@@ -197,9 +197,9 @@ browser_get_selected_entity(const struct screen_browser *browser)
 {
        const struct filelist_entry *entry = browser_get_selected_entry(browser);
 
-       return entry != NULL
+       return entry != nullptr
                ? entry->entity
-               : NULL;
+               : nullptr;
 }
 
 static const struct mpd_song *
@@ -207,18 +207,18 @@ browser_get_selected_song(const struct screen_browser *browser)
 {
        const struct mpd_entity *entity = browser_get_selected_entity(browser);
 
-       return entity != NULL &&
+       return entity != nullptr &&
                mpd_entity_get_type(entity) == MPD_ENTITY_TYPE_SONG
                ? mpd_entity_get_song(entity)
-               : NULL;
+               : nullptr;
 }
 
 static struct filelist_entry *
 browser_get_index(const struct screen_browser *browser, unsigned i)
 {
-       if (browser->filelist == NULL ||
+       if (browser->filelist == nullptr ||
            i >= filelist_length(browser->filelist))
-               return NULL;
+               return nullptr;
 
        return filelist_get(browser->filelist, i);
 }
@@ -227,11 +227,11 @@ static bool
 browser_handle_enter(struct screen_browser *browser, struct mpdclient *c)
 {
        struct filelist_entry *entry = browser_get_selected_entry(browser);
-       if (entry == NULL)
+       if (entry == nullptr)
                return false;
 
        struct mpd_entity *entity = entry->entity;
-       if (entity == NULL)
+       if (entity == nullptr)
                return false;
 
        if (mpd_entity_get_type(entity) == MPD_ENTITY_TYPE_PLAYLIST)
@@ -243,10 +243,10 @@ browser_handle_enter(struct screen_browser *browser, struct mpdclient *c)
 
 static bool
 browser_select_entry(struct mpdclient *c, struct filelist_entry *entry,
-                    gcc_unused gboolean toggle)
+                    gcc_unused bool toggle)
 {
-       assert(entry != NULL);
-       assert(entry->entity != NULL);
+       assert(entry != nullptr);
+       assert(entry->entity != nullptr);
 
        if (mpd_entity_get_type(entry->entity) == MPD_ENTITY_TYPE_PLAYLIST)
                return load_playlist(c, mpd_entity_get_playlist(entry->entity));
@@ -312,8 +312,8 @@ browser_handle_select(struct screen_browser *browser, struct mpdclient *c)
        list_window_get_range(browser->lw, &range);
        for (unsigned i = range.start; i < range.end; ++i) {
                struct filelist_entry *entry = browser_get_index(browser, i);
-               if (entry != NULL && entry->entity != NULL)
-                       success = browser_select_entry(c, entry, TRUE);
+               if (entry != nullptr && entry->entity != nullptr)
+                       success = browser_select_entry(c, entry, true);
        }
 
        return range.end == range.start + 1 && success;
@@ -328,8 +328,8 @@ browser_handle_add(struct screen_browser *browser, struct mpdclient *c)
        list_window_get_range(browser->lw, &range);
        for (unsigned i = range.start; i < range.end; ++i) {
                struct filelist_entry *entry = browser_get_index(browser, i);
-               if (entry != NULL && entry->entity != NULL)
-                       success = browser_select_entry(c, entry, FALSE) ||
+               if (entry != nullptr && entry->entity != nullptr)
+                       success = browser_select_entry(c, entry, false) ||
                                success;
        }
 
@@ -339,14 +339,14 @@ browser_handle_add(struct screen_browser *browser, struct mpdclient *c)
 static void
 browser_handle_select_all(struct screen_browser *browser, struct mpdclient *c)
 {
-       if (browser->filelist == NULL)
+       if (browser->filelist == nullptr)
                return;
 
        for (unsigned i = 0; i < filelist_length(browser->filelist); ++i) {
                struct filelist_entry *entry = filelist_get(browser->filelist, i);
 
-               if (entry != NULL && entry->entity != NULL)
-                       browser_select_entry(c, entry, FALSE);
+               if (entry != nullptr && entry->entity != nullptr)
+                       browser_select_entry(c, entry, false);
        }
 }
 
@@ -384,7 +384,7 @@ bool
 browser_cmd(struct screen_browser *browser,
            struct mpdclient *c, command_t cmd)
 {
-       if (browser->filelist == NULL)
+       if (browser->filelist == nullptr)
                return false;
 
        if (list_window_cmd(browser->lw, cmd))
@@ -411,7 +411,7 @@ browser_cmd(struct screen_browser *browser,
 #ifdef ENABLE_SONG_SCREEN
        case CMD_SCREEN_SONG:
                song = browser_get_selected_song(browser);
-               if (song == NULL)
+               if (song == nullptr)
                        return false;
 
                screen_song_switch(c, song);
@@ -421,7 +421,7 @@ browser_cmd(struct screen_browser *browser,
 #ifdef ENABLE_LYRICS_SCREEN
        case CMD_SCREEN_LYRICS:
                song = browser_get_selected_song(browser);
-               if (song == NULL)
+               if (song == nullptr)
                        return false;
 
                screen_lyrics_switch(c, song, false);
@@ -461,7 +461,7 @@ browser_cmd(struct screen_browser *browser,
 
        case CMD_LOCATE:
                song = browser_get_selected_song(browser);
-               if (song == NULL)
+               if (song == nullptr)
                        return false;
 
                screen_file_goto_song(c, song);
@@ -502,15 +502,15 @@ screen_browser_paint_callback(WINDOW *w, unsigned i,
 {
        const struct screen_browser *browser = (const struct screen_browser *) data;
 
-       assert(browser != NULL);
-       assert(browser->filelist != NULL);
+       assert(browser != nullptr);
+       assert(browser->filelist != nullptr);
        assert(i < filelist_length(browser->filelist));
 
        const struct filelist_entry *entry = filelist_get(browser->filelist, i);
-       assert(entry != NULL);
+       assert(entry != nullptr);
 
        const struct mpd_entity *entity = entry->entity;
-       if (entity == NULL) {
+       if (entity == nullptr) {
                screen_browser_paint_directory(w, width, selected, "..");
                return;
        }
@@ -535,7 +535,7 @@ screen_browser_paint_callback(WINDOW *w, unsigned i,
 
        case MPD_ENTITY_TYPE_SONG:
                paint_song_row(w, y, width, selected, highlight,
-                              mpd_entity_get_song(entity), NULL, browser->song_format);
+                              mpd_entity_get_song(entity), nullptr, browser->song_format);
                break;
 
        case MPD_ENTITY_TYPE_PLAYLIST:
similarity index 97%
rename from src/screen_browser.h
rename to src/screen_browser.hxx
index 82d6ffa..898a658 100644 (file)
 #ifndef SCREEN_BROWSER_H
 #define SCREEN_BROWSER_H
 
-#include "command.h"
+#include "command.hxx"
 #include "config.h"
 #include "ncmpc_curses.h"
 
-#include <stdbool.h>
-
 struct mpdclient;
 struct mpdclient_playlist;
 struct filelist;
similarity index 86%
rename from src/screen_chat.c
rename to src/screen_chat.cxx
index f79e73f..bceee9a 100644 (file)
  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
  */
 
-#include "screen_chat.h"
+#include "screen_chat.hxx"
 
-#include "screen_interface.h"
-#include "screen_utils.h"
-#include "screen_status.h"
-#include "screen_text.h"
-#include "mpdclient.h"
+#include "screen_interface.hxx"
+#include "screen_utils.hxx"
+#include "screen_status.hxx"
+#include "screen_text.hxx"
+#include "mpdclient.hxx"
 #include "i18n.h"
-#include "charset.h"
-#include "options.h"
+#include "charset.hxx"
+#include "options.hxx"
 
 #include <glib.h>
 #include <mpd/idle.h>
@@ -48,7 +48,7 @@ check_chat_support(struct mpdclient *c)
 
        last_connection_id = c->connection_id;
 
-       if (c->connection == NULL)
+       if (c->connection == nullptr)
                return (was_supported = false);
 
        if (mpd_connection_cmp_server_version(c->connection, 0, 17, 0) == -1) {
@@ -80,7 +80,7 @@ screen_chat_init(WINDOW *w, unsigned cols, unsigned rows)
 }
 
 static void
-screen_chat_exit(void)
+screen_chat_exit()
 {
        screen_text_deinit(&text);
 }
@@ -98,7 +98,7 @@ screen_chat_resize(unsigned cols, unsigned rows)
 }
 
 static void
-screen_chat_paint(void)
+screen_chat_paint()
 {
        screen_text_paint(&text);
 }
@@ -106,7 +106,7 @@ screen_chat_paint(void)
 static void
 process_message(struct mpd_message *message)
 {
-       assert(message != NULL);
+       assert(message != nullptr);
        /* You'll have to move this out of screen_chat, if you want to use
           client-to-client messages anywhere else */
        assert(g_strcmp0(mpd_message_get_channel(message), chat_channel) == 0);
@@ -126,7 +126,7 @@ screen_chat_update(struct mpdclient *c)
                        return;
 
                struct mpd_message *message;
-               while ((message = mpdclient_recv_message(c)) != NULL) {
+               while ((message = mpdclient_recv_message(c)) != nullptr) {
                        process_message(message);
                        mpd_message_free(message);
                }
@@ -138,9 +138,9 @@ screen_chat_update(struct mpdclient *c)
 }
 
 static char *
-screen_chat_get_prefix(void)
+screen_chat_get_prefix()
 {
-       static char *prefix = NULL;
+       static char *prefix = nullptr;
 
        if (prefix)
                return prefix;
@@ -151,7 +151,7 @@ screen_chat_get_prefix(void)
                return prefix;
        }
 
-       prefix = g_strconcat("<", g_get_user_name(), "> ", NULL);
+       prefix = g_strconcat("<", g_get_user_name(), "> ", nullptr);
        return prefix;
 }
 
@@ -160,7 +160,7 @@ screen_chat_send_message(struct mpdclient *c, char *msg)
 {
        char *utf8 = locale_to_utf8(msg);
        char *prefix = screen_chat_get_prefix();
-       char *full_msg = g_strconcat(prefix, utf8, NULL);
+       char *full_msg = g_strconcat(prefix, utf8, nullptr);
        g_free(utf8);
 
        (void) mpdclient_cmd_send_message(c, chat_channel, full_msg);
@@ -174,10 +174,10 @@ screen_chat_cmd(struct mpdclient *c, command_t cmd)
                return true;
 
        if (cmd == CMD_PLAY) {
-               char *message = screen_readln(_("Your message"), NULL, NULL, NULL);
+               char *message = screen_readln(_("Your message"), nullptr, nullptr, nullptr);
 
                /* the user entered an empty line */
-               if (message == NULL)
+               if (message == nullptr)
                        return true;
 
                if (check_chat_support(c))
@@ -203,10 +203,13 @@ const struct screen_functions screen_chat = {
        .init = screen_chat_init,
        .exit = screen_chat_exit,
        .open = screen_chat_open,
-       /* close */
+       .close = nullptr,
        .resize = screen_chat_resize,
        .paint = screen_chat_paint,
        .update = screen_chat_update,
        .cmd = screen_chat_cmd,
+#ifdef HAVE_GETMOUSE
+       .mouse = nullptr,
+#endif
        .get_title = screen_chat_title,
 };
similarity index 100%
rename from src/screen_chat.h
rename to src/screen_chat.hxx
similarity index 89%
rename from src/screen_client.c
rename to src/screen_client.cxx
index c70257f..5f8c169 100644 (file)
  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
  */
 
-#include "screen_client.h"
-#include "screen_status.h"
-#include "mpdclient.h"
+#include "screen_client.hxx"
+#include "screen_status.hxx"
+#include "mpdclient.hxx"
 #include "i18n.h"
-#include "charset.h"
+#include "charset.hxx"
 
 void
 screen_database_update(struct mpdclient *c, const char *path)
 {
-       assert(c != NULL);
+       assert(c != nullptr);
        assert(mpdclient_is_connected(c));
 
        struct mpd_connection *connection = mpdclient_get_connection(c);
-       if (connection == NULL)
+       if (connection == nullptr)
                return;
 
        unsigned id = mpd_run_update(connection, path);
@@ -44,7 +44,7 @@ screen_database_update(struct mpdclient *c, const char *path)
                return;
        }
 
-       if (path != NULL && *path != 0) {
+       if (path != nullptr && *path != 0) {
                char *path_locale = utf8_to_locale(path);
                screen_status_printf(_("Database update of %s started"), path);
                g_free(path_locale);
similarity index 98%
rename from src/screen_client.h
rename to src/screen_client.hxx
index 895010b..d6fd2b4 100644 (file)
@@ -20,7 +20,6 @@
 #ifndef NCMPC_SCREEN_CLIENT_H
 #define NCMPC_SCREEN_CLIENT_H
 
-#include <stdbool.h>
 
 struct mpdclient;
 
similarity index 88%
rename from src/screen_file.c
rename to src/screen_file.cxx
index d55684c..879d023 100644 (file)
  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
  */
 
-#include "screen_file.h"
-#include "screen_browser.h"
-#include "screen_interface.h"
-#include "screen_status.h"
-#include "save_playlist.h"
-#include "screen.h"
+#include "screen_file.hxx"
+#include "screen_browser.hxx"
+#include "screen_interface.hxx"
+#include "screen_status.hxx"
+#include "save_playlist.hxx"
+#include "screen.hxx"
 #include "config.h"
 #include "i18n.h"
-#include "charset.h"
-#include "mpdclient.h"
-#include "filelist.h"
-#include "screen_utils.h"
-#include "screen_client.h"
-#include "options.h"
+#include "charset.hxx"
+#include "mpdclient.hxx"
+#include "filelist.hxx"
+#include "screen_utils.hxx"
+#include "screen_client.hxx"
+#include "options.hxx"
 
 #include <mpd/client.h>
 
@@ -48,7 +48,7 @@ screen_file_load_list(struct mpdclient *c, struct filelist *filelist)
        struct mpd_connection *connection;
 
        connection = mpdclient_get_connection(c);
-       if (connection == NULL)
+       if (connection == nullptr)
                return;
 
        mpd_send_list_meta(connection, current_path);
@@ -61,13 +61,13 @@ screen_file_load_list(struct mpdclient *c, struct filelist *filelist)
 static void
 screen_file_reload(struct mpdclient *c)
 {
-       if (browser.filelist != NULL)
+       if (browser.filelist != nullptr)
                filelist_free(browser.filelist);
 
        browser.filelist = filelist_new();
        if (*current_path != 0)
                /* add a dummy entry for ./.. */
-               filelist_append(browser.filelist, NULL);
+               filelist_append(browser.filelist, nullptr);
 
        screen_file_load_list(c, browser.filelist);
 
@@ -90,7 +90,7 @@ change_directory(struct mpdclient *c, const char *new_path)
 
        list_window_reset(browser.lw);
 
-       return browser.filelist != NULL;
+       return browser.filelist != nullptr;
 }
 
 /**
@@ -104,7 +104,7 @@ change_to_parent(struct mpdclient *c)
                parent[0] = '\0';
 
        char *old_path = current_path;
-       current_path = NULL;
+       current_path = nullptr;
 
        bool success = change_directory(c, parent);
        g_free(parent);
@@ -130,9 +130,9 @@ change_to_parent(struct mpdclient *c)
 static bool
 change_to_entry(struct mpdclient *c, const struct filelist_entry *entry)
 {
-       assert(entry != NULL);
+       assert(entry != nullptr);
 
-       if (entry->entity == NULL)
+       if (entry->entity == nullptr)
                return change_to_parent(c);
        else if (mpd_entity_get_type(entry->entity) == MPD_ENTITY_TYPE_DIRECTORY)
                return change_directory(c, mpd_directory_get_path(mpd_entity_get_directory(entry->entity)));
@@ -145,7 +145,7 @@ screen_file_handle_enter(struct mpdclient *c)
 {
        const struct filelist_entry *entry = browser_get_selected_entry(&browser);
 
-       if (entry == NULL)
+       if (entry == nullptr)
                return false;
 
        return change_to_entry(c, entry);
@@ -155,7 +155,7 @@ static void
 handle_save(struct mpdclient *c)
 {
        struct list_window_range range;
-       const char *defaultname = NULL;
+       const char *defaultname = nullptr;
 
        list_window_get_range(browser.lw, &range);
        if (range.start == range.end)
@@ -174,10 +174,10 @@ handle_save(struct mpdclient *c)
                }
        }
 
-       char *defaultname_utf8 = NULL;
+       char *defaultname_utf8 = nullptr;
        if(defaultname)
                defaultname_utf8 = utf8_to_locale(defaultname);
-       playlist_save(c, NULL, defaultname_utf8);
+       playlist_save(c, nullptr, defaultname_utf8);
        g_free(defaultname_utf8);
 }
 
@@ -186,7 +186,7 @@ handle_delete(struct mpdclient *c)
 {
        struct mpd_connection *connection = mpdclient_get_connection(c);
 
-       if (connection == NULL)
+       if (connection == nullptr)
                return;
 
        struct list_window_range range;
@@ -194,7 +194,7 @@ handle_delete(struct mpdclient *c)
        for (unsigned i = range.start; i < range.end; ++i) {
                struct filelist_entry *entry =
                        filelist_get(browser.filelist, i);
-               if( entry==NULL || entry->entity==NULL )
+               if (entry == nullptr || entry->entity == nullptr)
                        continue;
 
                struct mpd_entity *entity = entry->entity;
@@ -212,10 +212,10 @@ handle_delete(struct mpdclient *c)
                char *str = utf8_to_locale(g_basename(mpd_playlist_get_path(playlist)));
                char *buf = g_strdup_printf(_("Delete playlist %s?"), str);
                g_free(str);
-               bool delete = screen_get_yesno(buf, false);
+               bool confirmed = screen_get_yesno(buf, false);
                g_free(buf);
 
-               if (!delete) {
+               if (!confirmed) {
                        /* translators: a dialog was aborted by the user */
                        screen_status_printf(_("Aborted"));
                        return;
@@ -250,7 +250,7 @@ screen_file_resize(unsigned cols, unsigned rows)
 }
 
 static void
-screen_file_exit(void)
+screen_file_exit()
 {
        if (browser.filelist)
                filelist_free(browser.filelist);
@@ -269,15 +269,15 @@ screen_file_open(struct mpdclient *c)
 static const char *
 screen_file_get_title(char *str, size_t size)
 {
-       const char *path = NULL, *prev = NULL, *slash = current_path;
+       const char *path = nullptr, *prev = nullptr, *slash = current_path;
 
        /* determine the last 2 parts of the path */
-       while ((slash = strchr(slash, '/')) != NULL) {
+       while ((slash = strchr(slash, '/')) != nullptr) {
                path = prev;
                prev = ++slash;
        }
 
-       if (path == NULL)
+       if (path == nullptr)
                /* fall back to full path */
                path = current_path;
 
@@ -290,7 +290,7 @@ screen_file_get_title(char *str, size_t size)
 }
 
 static void
-screen_file_paint(void)
+screen_file_paint()
 {
        screen_browser_paint(&browser);
 }
@@ -398,6 +398,7 @@ const struct screen_functions screen_browse = {
        .init = screen_file_init,
        .exit = screen_file_exit,
        .open = screen_file_open,
+       .close = nullptr,
        .resize = screen_file_resize,
        .paint = screen_file_paint,
        .update = screen_file_update,
@@ -412,20 +413,20 @@ bool
 screen_file_goto_song(struct mpdclient *c, const struct mpd_song *song)
 {
        const char *uri, *slash, *parent;
-       char *allocated = NULL;
+       char *allocated = nullptr;
 
-       assert(song != NULL);
+       assert(song != nullptr);
 
        uri = mpd_song_get_uri(song);
 
-       if (strstr(uri, "//") != NULL)
+       if (strstr(uri, "//") != nullptr)
                /* an URL? */
                return false;
 
        /* determine the song's parent directory and go there */
 
        slash = strrchr(uri, '/');
-       if (slash != NULL)
+       if (slash != nullptr)
                parent = allocated = g_strndup(uri, slash - uri);
        else
                parent = "";
similarity index 98%
rename from src/screen_file.h
rename to src/screen_file.hxx
index ededa09..4b4efdf 100644 (file)
@@ -20,7 +20,6 @@
 #ifndef NCMPC_SCREEN_FILE_H
 #define NCMPC_SCREEN_FILE_H
 
-#include <stdbool.h>
 
 struct mpdclient;
 struct mpd_song;
similarity index 90%
rename from src/screen_find.c
rename to src/screen_find.cxx
index b838421..f56d22c 100644 (file)
  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
  */
 
-#include "screen_find.h"
-#include "screen_utils.h"
-#include "screen_status.h"
-#include "screen.h"
-#include "keyboard.h"
+#include "screen_find.hxx"
+#include "screen_utils.hxx"
+#include "screen_status.hxx"
+#include "screen.hxx"
+#include "keyboard.hxx"
 #include "i18n.h"
-#include "options.h"
-#include "ncmpc.h"
+#include "options.hxx"
+#include "ncmpc.hxx"
 
 #define FIND_PROMPT  _("Find")
 #define RFIND_PROMPT _("Find backward")
@@ -49,7 +49,7 @@ screen_find(struct list_window *lw, command_t findcmd,
        case CMD_LIST_RFIND:
                if (screen.findbuf) {
                        g_free(screen.findbuf);
-                       screen.findbuf=NULL;
+                       screen.findbuf=nullptr;
        }
                /* fall through */
 
@@ -57,14 +57,14 @@ screen_find(struct list_window *lw, command_t findcmd,
        case CMD_LIST_RFIND_NEXT:
                if (!screen.findbuf) {
                        char *value = options.find_show_last_pattern
-                               ? (char *) -1 : NULL;
+                               ? (char *) -1 : nullptr;
                        screen.findbuf=screen_readln(prompt,
                                                     value,
                                                     &screen.find_history,
-                                                    NULL);
+                                                    nullptr);
                }
 
-               if (screen.findbuf == NULL)
+               if (screen.findbuf == nullptr)
                        return 1;
 
                found = reversed
@@ -102,9 +102,9 @@ screen_jump(struct list_window *lw,
 
        if (screen.findbuf) {
                g_free(screen.findbuf);
-               screen.findbuf = NULL;
+               screen.findbuf = nullptr;
        }
-       screen.findbuf = g_malloc0(WRLN_MAX_LINE_SIZE);
+       screen.findbuf = (char *)g_malloc0(WRLN_MAX_LINE_SIZE);
        /* In screen.findbuf is the whole string which is displayed in the status_window
         * and search_str is the string the user entered (without the prompt) */
        char *search_str = screen.findbuf + g_snprintf(screen.findbuf, WRLN_MAX_LINE_SIZE, "%s: ", JUMP_PROMPT);
@@ -133,7 +133,7 @@ screen_jump(struct list_window *lw,
                list_window_jump(lw, callback_fn, callback_data, search_str);
 
                /* repaint the list_window */
-               if (paint_callback != NULL)
+               if (paint_callback != nullptr)
                        list_window_paint2(lw, paint_callback, paint_data);
                else
                        list_window_paint(lw, callback_fn, callback_data);
similarity index 97%
rename from src/screen_find.h
rename to src/screen_find.hxx
index 788fdce..b9f2b35 100644 (file)
@@ -20,8 +20,8 @@
 #ifndef NCMPC_SCREEN_FIND_H
 #define NCMPC_SCREEN_FIND_H
 
-#include "command.h"
-#include "list_window.h"
+#include "command.hxx"
+#include "list_window.hxx"
 
 /**
  * query user for a string and find it in a list window
similarity index 59%
rename from src/screen_help.c
rename to src/screen_help.cxx
index 6ce641b..3a4bbfb 100644 (file)
  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
  */
 
-#include "screen_help.h"
-#include "screen_interface.h"
-#include "screen_find.h"
-#include "paint.h"
-#include "charset.h"
+#include "screen_help.hxx"
+#include "screen_interface.hxx"
+#include "screen_find.hxx"
+#include "paint.hxx"
+#include "charset.hxx"
 #include "config.h"
 #include "i18n.h"
 
@@ -37,128 +37,128 @@ struct help_text_row {
 
 static const struct help_text_row help_text[] = {
        { 1, CMD_NONE, N_("Movement") },
-       { 2, CMD_NONE, NULL },
-       { 0, CMD_LIST_PREVIOUS, NULL },
-       { 0, CMD_LIST_NEXT, NULL },
-       { 0, CMD_LIST_TOP, NULL },
-       { 0, CMD_LIST_MIDDLE, NULL },
-       { 0, CMD_LIST_BOTTOM, NULL },
-       { 0, CMD_LIST_PREVIOUS_PAGE, NULL },
-       { 0, CMD_LIST_NEXT_PAGE, NULL },
-       { 0, CMD_LIST_FIRST, NULL },
-       { 0, CMD_LIST_LAST, NULL },
-       { 0, CMD_LIST_RANGE_SELECT, NULL },
-       { 0, CMD_LIST_SCROLL_UP_LINE, NULL},
-       { 0, CMD_LIST_SCROLL_DOWN_LINE, NULL},
-       { 0, CMD_LIST_SCROLL_UP_HALF, NULL},
-       { 0, CMD_LIST_SCROLL_DOWN_HALF, NULL},
-       { 0, CMD_NONE, NULL },
-
-       { 0, CMD_SCREEN_PREVIOUS,NULL },
-       { 0, CMD_SCREEN_NEXT, NULL },
-       { 0, CMD_SCREEN_SWAP, NULL },
-       { 0, CMD_SCREEN_HELP, NULL },
-       { 0, CMD_SCREEN_PLAY, NULL },
-       { 0, CMD_SCREEN_FILE, NULL },
+       { 2, CMD_NONE, nullptr },
+       { 0, CMD_LIST_PREVIOUS, nullptr },
+       { 0, CMD_LIST_NEXT, nullptr },
+       { 0, CMD_LIST_TOP, nullptr },
+       { 0, CMD_LIST_MIDDLE, nullptr },
+       { 0, CMD_LIST_BOTTOM, nullptr },
+       { 0, CMD_LIST_PREVIOUS_PAGE, nullptr },
+       { 0, CMD_LIST_NEXT_PAGE, nullptr },
+       { 0, CMD_LIST_FIRST, nullptr },
+       { 0, CMD_LIST_LAST, nullptr },
+       { 0, CMD_LIST_RANGE_SELECT, nullptr },
+       { 0, CMD_LIST_SCROLL_UP_LINE, nullptr},
+       { 0, CMD_LIST_SCROLL_DOWN_LINE, nullptr},
+       { 0, CMD_LIST_SCROLL_UP_HALF, nullptr},
+       { 0, CMD_LIST_SCROLL_DOWN_HALF, nullptr},
+       { 0, CMD_NONE, nullptr },
+
+       { 0, CMD_SCREEN_PREVIOUS,nullptr },
+       { 0, CMD_SCREEN_NEXT, nullptr },
+       { 0, CMD_SCREEN_SWAP, nullptr },
+       { 0, CMD_SCREEN_HELP, nullptr },
+       { 0, CMD_SCREEN_PLAY, nullptr },
+       { 0, CMD_SCREEN_FILE, nullptr },
 #ifdef ENABLE_ARTIST_SCREEN
-       { 0, CMD_SCREEN_ARTIST, NULL },
+       { 0, CMD_SCREEN_ARTIST, nullptr },
 #endif
 #ifdef ENABLE_SEARCH_SCREEN
-       { 0, CMD_SCREEN_SEARCH, NULL },
+       { 0, CMD_SCREEN_SEARCH, nullptr },
 #endif
 #ifdef ENABLE_LYRICS_SCREEN
-       { 0, CMD_SCREEN_LYRICS, NULL },
+       { 0, CMD_SCREEN_LYRICS, nullptr },
 #endif
 #ifdef ENABLE_OUTPUTS_SCREEN
-       { 0, CMD_SCREEN_OUTPUTS, NULL },
+       { 0, CMD_SCREEN_OUTPUTS, nullptr },
 #endif
 #ifdef ENABLE_CHAT_SCREEN
-       { 0, CMD_SCREEN_CHAT, NULL },
+       { 0, CMD_SCREEN_CHAT, nullptr },
 #endif
 #ifdef ENABLE_KEYDEF_SCREEN
-       { 0, CMD_SCREEN_KEYDEF, NULL },
+       { 0, CMD_SCREEN_KEYDEF, nullptr },
 #endif
 
-       { 0, CMD_NONE, NULL },
-       { 0, CMD_NONE, NULL },
+       { 0, CMD_NONE, nullptr },
+       { 0, CMD_NONE, nullptr },
        { 1, CMD_NONE, N_("Global") },
-       { 2, CMD_NONE, NULL },
-       { 0, CMD_STOP, NULL },
-       { 0, CMD_PAUSE, NULL },
-       { 0, CMD_CROP, NULL },
-       { 0, CMD_TRACK_NEXT, NULL },
-       { 0, CMD_TRACK_PREVIOUS, NULL },
-       { 0, CMD_SEEK_FORWARD, NULL },
-       { 0, CMD_SEEK_BACKWARD, NULL },
-       { 0, CMD_VOLUME_DOWN, NULL },
-       { 0, CMD_VOLUME_UP, NULL },
-       { 0, CMD_NONE, NULL },
-       { 0, CMD_REPEAT, NULL },
-       { 0, CMD_RANDOM, NULL },
-       { 0, CMD_SINGLE, NULL },
-       { 0, CMD_CONSUME, NULL },
-       { 0, CMD_CROSSFADE, NULL },
-       { 0, CMD_SHUFFLE, NULL },
-       { 0, CMD_DB_UPDATE, NULL },
-       { 0, CMD_NONE, NULL },
-       { 0, CMD_LIST_FIND, NULL },
-       { 0, CMD_LIST_RFIND, NULL },
-       { 0, CMD_LIST_FIND_NEXT, NULL },
-       { 0, CMD_LIST_RFIND_NEXT, NULL },
-       { 0, CMD_LIST_JUMP, NULL },
-       { 0, CMD_TOGGLE_FIND_WRAP, NULL },
-       { 0, CMD_LOCATE, NULL },
+       { 2, CMD_NONE, nullptr },
+       { 0, CMD_STOP, nullptr },
+       { 0, CMD_PAUSE, nullptr },
+       { 0, CMD_CROP, nullptr },
+       { 0, CMD_TRACK_NEXT, nullptr },
+       { 0, CMD_TRACK_PREVIOUS, nullptr },
+       { 0, CMD_SEEK_FORWARD, nullptr },
+       { 0, CMD_SEEK_BACKWARD, nullptr },
+       { 0, CMD_VOLUME_DOWN, nullptr },
+       { 0, CMD_VOLUME_UP, nullptr },
+       { 0, CMD_NONE, nullptr },
+       { 0, CMD_REPEAT, nullptr },
+       { 0, CMD_RANDOM, nullptr },
+       { 0, CMD_SINGLE, nullptr },
+       { 0, CMD_CONSUME, nullptr },
+       { 0, CMD_CROSSFADE, nullptr },
+       { 0, CMD_SHUFFLE, nullptr },
+       { 0, CMD_DB_UPDATE, nullptr },
+       { 0, CMD_NONE, nullptr },
+       { 0, CMD_LIST_FIND, nullptr },
+       { 0, CMD_LIST_RFIND, nullptr },
+       { 0, CMD_LIST_FIND_NEXT, nullptr },
+       { 0, CMD_LIST_RFIND_NEXT, nullptr },
+       { 0, CMD_LIST_JUMP, nullptr },
+       { 0, CMD_TOGGLE_FIND_WRAP, nullptr },
+       { 0, CMD_LOCATE, nullptr },
 #ifdef ENABLE_SONG_SCREEN
-       { 0, CMD_SCREEN_SONG, NULL },
+       { 0, CMD_SCREEN_SONG, nullptr },
 #endif
-       { 0, CMD_NONE, NULL },
-       { 0, CMD_QUIT, NULL },
+       { 0, CMD_NONE, nullptr },
+       { 0, CMD_QUIT, nullptr },
 
-       { 0, CMD_NONE, NULL },
-       { 0, CMD_NONE, NULL },
+       { 0, CMD_NONE, nullptr },
+       { 0, CMD_NONE, nullptr },
        { 1, CMD_NONE, N_("Queue screen") },
-       { 2, CMD_NONE, NULL },
+       { 2, CMD_NONE, nullptr },
        { 0, CMD_PLAY, N_("Play") },
-       { 0, CMD_DELETE, NULL },
-       { 0, CMD_CLEAR, NULL },
+       { 0, CMD_DELETE, nullptr },
+       { 0, CMD_CLEAR, nullptr },
        { 0, CMD_LIST_MOVE_UP, N_("Move song up") },
        { 0, CMD_LIST_MOVE_DOWN, N_("Move song down") },
-       { 0, CMD_ADD, NULL },
-       { 0, CMD_SAVE_PLAYLIST, NULL },
+       { 0, CMD_ADD, nullptr },
+       { 0, CMD_SAVE_PLAYLIST, nullptr },
        { 0, CMD_SCREEN_UPDATE, N_("Center") },
-       { 0, CMD_SELECT_PLAYING, NULL },
-       { 0, CMD_TOGGLE_AUTOCENTER, NULL },
+       { 0, CMD_SELECT_PLAYING, nullptr },
+       { 0, CMD_TOGGLE_AUTOCENTER, nullptr },
 
-       { 0, CMD_NONE, NULL },
-       { 0, CMD_NONE, NULL },
+       { 0, CMD_NONE, nullptr },
+       { 0, CMD_NONE, nullptr },
        { 1, CMD_NONE, N_("Browse screen") },
-       { 2, CMD_NONE, NULL },
+       { 2, CMD_NONE, nullptr },
        { 0, CMD_PLAY, N_("Enter directory/Select and play song") },
-       { 0, CMD_SELECT, NULL },
+       { 0, CMD_SELECT, nullptr },
        { 0, CMD_ADD, N_("Append song to queue") },
-       { 0, CMD_SAVE_PLAYLIST, NULL },
+       { 0, CMD_SAVE_PLAYLIST, nullptr },
        { 0, CMD_DELETE, N_("Delete playlist") },
-       { 0, CMD_GO_PARENT_DIRECTORY, NULL },
-       { 0, CMD_GO_ROOT_DIRECTORY, NULL },
-       { 0, CMD_SCREEN_UPDATE, NULL },
+       { 0, CMD_GO_PARENT_DIRECTORY, nullptr },
+       { 0, CMD_GO_ROOT_DIRECTORY, nullptr },
+       { 0, CMD_SCREEN_UPDATE, nullptr },
 
 #ifdef ENABLE_SEARCH_SCREEN
-       { 0, CMD_NONE, NULL },
-       { 0, CMD_NONE, NULL },
+       { 0, CMD_NONE, nullptr },
+       { 0, CMD_NONE, nullptr },
        { 1, CMD_NONE, N_("Search screen") },
-       { 2, CMD_NONE, NULL },
+       { 2, CMD_NONE, nullptr },
        { 0, CMD_SCREEN_SEARCH, N_("Search") },
        { 0, CMD_PLAY, N_("Select and play") },
-       { 0, CMD_SELECT, NULL },
+       { 0, CMD_SELECT, nullptr },
        { 0, CMD_ADD, N_("Append song to queue") },
-       { 0, CMD_SELECT_ALL,     NULL },
-       { 0, CMD_SEARCH_MODE, NULL },
+       { 0, CMD_SELECT_ALL,     nullptr },
+       { 0, CMD_SEARCH_MODE, nullptr },
 #endif
 #ifdef ENABLE_LYRICS_SCREEN
-       { 0, CMD_NONE, NULL },
-       { 0, CMD_NONE, NULL },
+       { 0, CMD_NONE, nullptr },
+       { 0, CMD_NONE, nullptr },
        { 1, CMD_NONE, N_("Lyrics screen") },
-       { 2, CMD_NONE, NULL },
+       { 2, CMD_NONE, nullptr },
        { 0, CMD_SCREEN_LYRICS, N_("View Lyrics") },
        { 0, CMD_SELECT, N_("(Re)load lyrics") },
        /* to translators: this hotkey aborts the retrieval of lyrics
@@ -170,24 +170,24 @@ static const struct help_text_row help_text[] = {
        { 0, CMD_DELETE, N_("Delete saved lyrics") },
 #endif
 #ifdef ENABLE_OUTPUTS_SCREEN
-       { 0, CMD_NONE, NULL },
-       { 0, CMD_NONE, NULL },
+       { 0, CMD_NONE, nullptr },
+       { 0, CMD_NONE, nullptr },
        { 1, CMD_NONE, N_("Outputs screen") },
-       { 2, CMD_NONE, NULL },
+       { 2, CMD_NONE, nullptr },
        { 0, CMD_PLAY, N_("Enable/disable output") },
 #endif
 #ifdef ENABLE_CHAT_SCREEN
-       { 0, CMD_NONE, NULL },
-       { 0, CMD_NONE, NULL },
+       { 0, CMD_NONE, nullptr },
+       { 0, CMD_NONE, nullptr },
        { 1, CMD_NONE, N_("Chat screen") },
-       { 2, CMD_NONE, NULL },
+       { 2, CMD_NONE, nullptr },
        { 0, CMD_PLAY, N_("Write a message") },
 #endif
 #ifdef ENABLE_KEYDEF_SCREEN
-       { 0, CMD_NONE, NULL },
-       { 0, CMD_NONE, NULL },
+       { 0, CMD_NONE, nullptr },
+       { 0, CMD_NONE, nullptr },
        { 1, CMD_NONE, N_("Keydef screen") },
-       { 2, CMD_NONE, NULL },
+       { 2, CMD_NONE, nullptr },
        { 0, CMD_PLAY, N_("Edit keydefs for selected command") },
        { 0, CMD_DELETE, N_("Remove selected keydef") },
        { 0, CMD_ADD, N_("Add a keydef") },
@@ -205,7 +205,7 @@ list_callback(unsigned i, gcc_unused void *data)
 
        assert(i < G_N_ELEMENTS(help_text));
 
-       if (row->text != NULL)
+       if (row->text != nullptr)
                return _(row->text);
 
        if (row->command != CMD_NONE)
@@ -229,7 +229,7 @@ help_resize(unsigned cols, unsigned rows)
 }
 
 static void
-help_exit(void)
+help_exit()
 {
        list_window_free(lw);
 }
@@ -256,7 +256,7 @@ screen_help_paint_callback(WINDOW *w, unsigned i,
        wclrtoeol(w);
 
        if (row->command == CMD_NONE) {
-               if (row->text != NULL)
+               if (row->text != nullptr)
                        mvwaddstr(w, y, 6, _(row->text));
                else if (row->highlight == 2)
                        mvwhline(w, y, 3, '-', width - 6);
@@ -268,16 +268,16 @@ screen_help_paint_callback(WINDOW *w, unsigned i,
                waddstr(w, key);
                mvwaddch(w, y, 21, ':');
                mvwaddstr(w, y, 23,
-                         row->text != NULL
+                         row->text != nullptr
                          ? _(row->text)
                          : get_key_description(row->command));
        }
 }
 
 static void
-help_paint(void)
+help_paint()
 {
-       list_window_paint2(lw, screen_help_paint_callback, NULL);
+       list_window_paint2(lw, screen_help_paint_callback, nullptr);
 }
 
 static bool
@@ -289,7 +289,7 @@ help_cmd(gcc_unused struct mpdclient *c, command_t cmd)
        }
 
        list_window_set_cursor(lw, lw->start);
-       if (screen_find(lw,  cmd, list_callback, NULL)) {
+       if (screen_find(lw,  cmd, list_callback, nullptr)) {
                /* center the row */
                list_window_center(lw, lw->selected);
                help_paint();
@@ -302,8 +302,14 @@ help_cmd(gcc_unused struct mpdclient *c, command_t cmd)
 const struct screen_functions screen_help = {
        .init = help_init,
        .exit = help_exit,
+       .open = nullptr,
+       .close = nullptr,
        .resize = help_resize,
        .paint = help_paint,
+       .update = nullptr,
        .cmd = help_cmd,
+#ifdef HAVE_GETMOUSE
+       .mouse = nullptr,
+#endif
        .get_title = help_title,
 };
similarity index 100%
rename from src/screen_help.h
rename to src/screen_help.hxx
similarity index 88%
rename from src/screen_init.c
rename to src/screen_init.cxx
index 2f3b323..5c8c83a 100644 (file)
  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
  */
 
-#include "screen.h"
-#include "screen_interface.h"
-#include "screen_list.h"
+#include "screen.hxx"
+#include "screen_interface.hxx"
+#include "screen_list.hxx"
+#include "screen_queue.hxx"
 #include "config.h"
 #include "i18n.h"
-#include "utils.h"
-#include "options.h"
-#include "colors.h"
+#include "utils.hxx"
+#include "options.hxx"
+#include "colors.hxx"
 
 #include <stdlib.h>
 
@@ -38,9 +39,9 @@ static const unsigned SCREEN_MIN_COLS = 14;
 static const unsigned SCREEN_MIN_ROWS = 5;
 
 void
-screen_exit(void)
+screen_exit()
 {
-       if (screen.current_page->close != NULL)
+       if (screen.current_page->close != nullptr)
                screen.current_page->close();
 
        screen_list_exit();
@@ -91,7 +92,7 @@ screen_resize(struct mpdclient *c)
 
        screen.buf_size = cols;
        g_free(screen.buf);
-       screen.buf = g_malloc(cols);
+       screen.buf = (char *)g_malloc(cols);
 
        /* resize all screens */
        screen_list_resize(screen.main_window.cols, screen.main_window.rows);
@@ -107,7 +108,7 @@ screen_resize(struct mpdclient *c)
 static gboolean
 welcome_timer_callback(gpointer data)
 {
-       struct mpdclient *c = data;
+       auto *c = (struct mpdclient *)data;
 
        screen.welcome_source_id = 0;
 
@@ -127,9 +128,10 @@ screen_init(struct mpdclient *c)
                exit(EXIT_FAILURE);
        }
 
-       screen.buf = g_malloc(cols);
+       screen.current_page = &screen_queue;
+       screen.buf = (char *)g_malloc(cols);
        screen.buf_size = cols;
-       screen.findbuf = NULL;
+       screen.findbuf = nullptr;
 
 #ifndef NCMPC_MINI
        if (options.welcome_screen_list)
@@ -145,9 +147,9 @@ screen_init(struct mpdclient *c)
        window_init(&screen.main_window, rows - 4, cols, 2, 0);
 
        if (!options.hardware_cursor)
-               leaveok(screen.main_window.w, TRUE);
+               leaveok(screen.main_window.w, true);
 
-       keypad(screen.main_window.w, TRUE);
+       keypad(screen.main_window.w, true);
 
        /* create progress window */
        progress_bar_init(&screen.progress_bar, cols, rows - 2, 0);
@@ -172,6 +174,6 @@ screen_init(struct mpdclient *c)
        screen_list_init(screen.main_window.w,
                         screen.main_window.cols, screen.main_window.rows);
 
-       if (screen.current_page->open != NULL)
+       if (screen.current_page->open != nullptr)
                screen.current_page->open(c);
 }
similarity index 93%
rename from src/screen_interface.h
rename to src/screen_interface.hxx
index e11813a..3a2ee8a 100644 (file)
 #define NCMPC_SCREEN_INTERFACE_H
 
 #include "config.h"
-#include "command.h"
+#include "command.hxx"
 #include "ncmpc_curses.h"
 
-#include <stdbool.h>
 #include <stddef.h>
 
 struct mpdclient;
 
 struct screen_functions {
        void (*init)(WINDOW *w, unsigned cols, unsigned rows);
-       void (*exit)(void);
+       void (*exit)();
        void (*open)(struct mpdclient *c);
-       void (*close)(void);
+       void (*close)();
        void (*resize)(unsigned cols, unsigned rows);
-       void (*paint)(void);
+       void (*paint)();
        void (*update)(struct mpdclient *c);
 
        /**
similarity index 91%
rename from src/screen_keydef.c
rename to src/screen_keydef.cxx
index 9a76c1b..dd7feac 100644 (file)
  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
  */
 
-#include "screen_keydef.h"
-#include "screen_interface.h"
-#include "screen_status.h"
-#include "screen_find.h"
+#include "screen_keydef.hxx"
+#include "screen_interface.hxx"
+#include "screen_status.hxx"
+#include "screen_find.hxx"
 #include "i18n.h"
-#include "conf.h"
-#include "screen.h"
-#include "screen_utils.h"
-#include "options.h"
+#include "conf.hxx"
+#include "screen.hxx"
+#include "screen_utils.hxx"
+#include "options.hxx"
 #include "Compiler.h"
 
 #include <assert.h>
@@ -35,7 +35,7 @@
 
 static struct list_window *lw;
 
-static command_definition_t *cmds = NULL;
+static command_definition_t *cmds = nullptr;
 
 /** the number of commands */
 static unsigned command_n_commands = 0;
@@ -46,7 +46,7 @@ static unsigned command_n_commands = 0;
  */
 gcc_pure
 static inline unsigned
-command_item_apply(void)
+command_item_apply()
 {
        return command_n_commands;
 }
@@ -54,7 +54,7 @@ command_item_apply(void)
 /** the position of the "apply and save" item */
 gcc_pure
 static inline unsigned
-command_item_save(void)
+command_item_save()
 {
        return command_item_apply() + 1;
 }
@@ -62,7 +62,7 @@ command_item_save(void)
 /** the number of items in the "command" view */
 gcc_pure
 static inline unsigned
-command_length(void)
+command_length()
 {
        return command_item_save() + 1;
 }
@@ -80,7 +80,7 @@ static unsigned subcmd_n_keys = 0;
 /** The position of the up ("[..]") item */
 gcc_const
 static inline unsigned
-subcmd_item_up(void)
+subcmd_item_up()
 {
        return 0;
 }
@@ -88,7 +88,7 @@ subcmd_item_up(void)
 /** The position of the "add a key" item */
 gcc_pure
 static inline unsigned
-subcmd_item_add(void)
+subcmd_item_add()
 {
        return subcmd_n_keys + 1;
 }
@@ -96,7 +96,7 @@ subcmd_item_add(void)
 /** The number of items in the list_window, if there's a command being edited */
 gcc_pure
 static inline unsigned
-subcmd_length(void)
+subcmd_length()
 {
        return subcmd_item_add() + 1;
 }
@@ -122,7 +122,7 @@ subcmd_item_to_key_id(unsigned i)
 
 
 static int
-keybindings_changed(void)
+keybindings_changed()
 {
        command_definition_t *orginal_cmds = get_command_definitions();
        size_t size = command_n_commands * sizeof(command_definition_t);
@@ -131,7 +131,7 @@ keybindings_changed(void)
 }
 
 static void
-apply_keys(void)
+apply_keys()
 {
        if (keybindings_changed()) {
                command_definition_t *orginal_cmds = get_command_definitions();
@@ -144,11 +144,11 @@ apply_keys(void)
 }
 
 static int
-save_keys(void)
+save_keys()
 {
-       char *allocated = NULL;
+       char *allocated = nullptr;
        const char *filename = options.key_file;
-       if (filename == NULL) {
+       if (filename == nullptr) {
                if (!check_user_conf_dir()) {
                        screen_status_printf(_("Error: Unable to create directory ~/.ncmpc - %s"),
                                             strerror(errno));
@@ -160,7 +160,7 @@ save_keys(void)
        }
 
        FILE *f = fopen(filename, "w");
-       if (f == NULL) {
+       if (f == nullptr) {
                screen_status_printf(_("Error: %s - %s"), filename, strerror(errno));
                screen_bell();
                g_free(allocated);
@@ -178,7 +178,7 @@ save_keys(void)
 
 /* TODO: rename to check_n_keys / subcmd_count_keys? */
 static void
-check_subcmd_length(void)
+check_subcmd_length()
 {
        unsigned i;
 
@@ -193,7 +193,7 @@ check_subcmd_length(void)
 }
 
 static void
-keydef_paint(void);
+keydef_paint();
 
 /** lw->start the last time switch_to_subcmd_mode() was called */
 static unsigned saved_start = 0;
@@ -213,7 +213,7 @@ switch_to_subcmd_mode(int cmd)
 }
 
 static void
-switch_to_command_mode(void)
+switch_to_command_mode()
 {
        assert(subcmd != -1);
 
@@