From 8fd244cc61c74522b93b59e75594902a01f936b5 Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Mon, 15 Sep 2008 12:27:29 +0200 Subject: [PATCH] include cleanup A header should include all headers which he needs. Move local includes on top, and let foo.c include foo.h in the first line, to automatically test its dependencies. --- src/colors.c | 11 ++++------- src/colors.h | 2 ++ src/command.c | 14 ++++++-------- src/command.h | 4 ++++ src/conf.c | 17 +++++++---------- src/conf.h | 1 + src/easy_download.c | 11 +++++------ src/list_window.c | 12 +++++------- src/list_window.h | 5 ++++- src/lyrics_hd.c | 6 ++---- src/main.c | 13 +++++-------- src/mpdclient.c | 15 +++++++-------- src/mpdclient.h | 3 +++ src/options.c | 11 ++++------- src/options.h | 6 ++++++ src/screen.c | 19 ++++++++----------- src/screen.h | 6 +++++- src/screen_artist.c | 13 +++++++------ src/screen_clock.c | 13 +++++++------ src/screen_file.c | 12 ++++++------ src/screen_help.c | 10 +++++----- src/screen_keydef.c | 12 ++++++------ src/screen_lyrics.c | 20 ++++++++++---------- src/screen_play.c | 14 +++++++------- src/screen_search.c | 13 +++++++------ src/screen_utils.c | 15 +++++---------- src/screen_utils.h | 7 +++++++ src/src_lyrics.h | 5 +++-- src/strfsong.c | 11 ++--------- src/strfsong.h | 6 ++++++ src/support.c | 8 +++----- src/support.h | 2 ++ src/utils.c | 13 ++++--------- src/utils.h | 3 +++ src/wreadln.c | 4 ++-- src/wreadln.h | 3 +++ 36 files changed, 173 insertions(+), 167 deletions(-) diff --git a/src/colors.c b/src/colors.c index e60399e..9f4f6cd 100644 --- a/src/colors.c +++ b/src/colors.c @@ -18,18 +18,15 @@ * */ +#include "colors.h" +#include "ncmpc.h" +#include "options.h" + #include #include #include -#include #include -#include "config.h" -#include "ncmpc.h" -#include "options.h" -#include "support.h" -#include "colors.h" - #define COLOR_BRIGHT_MASK (1<<7) #define COLOR_BRIGHT_BLACK (COLOR_BLACK | COLOR_BRIGHT_MASK) diff --git a/src/colors.h b/src/colors.h index 4211630..a913021 100644 --- a/src/colors.h +++ b/src/colors.h @@ -1,6 +1,8 @@ #ifndef COLORS_H #define COLORS_H +#include + #define COLOR_TITLE 1 #define COLOR_TITLE_BOLD 2 #define COLOR_LINE 3 diff --git a/src/command.c b/src/command.c index 733bf6a..3a5e679 100644 --- a/src/command.c +++ b/src/command.c @@ -18,20 +18,18 @@ * */ +#include "command.h" +#include "config.h" +#include "ncmpc.h" +#include "mpdclient.h" +#include "screen.h" + #include -#include #include #include #include #include #include -#include - -#include "config.h" -#include "ncmpc.h" -#include "command.h" -#include "mpdclient.h" -#include "screen.h" #undef DEBUG_KEYS diff --git a/src/command.h b/src/command.h index 75886d5..9e3b839 100644 --- a/src/command.h +++ b/src/command.h @@ -1,6 +1,10 @@ #ifndef COMMAND_H #define COMMAND_H +#include +#include +#include + #define MAX_COMMAND_KEYS 3 /* commands */ diff --git a/src/conf.c b/src/conf.c index 0e477db..e4b6b70 100644 --- a/src/conf.c +++ b/src/conf.c @@ -18,6 +18,13 @@ * */ +#include "conf.h" +#include "config.h" +#include "ncmpc.h" +#include "support.h" +#include "command.h" +#include "colors.h" + #include #include #include @@ -28,16 +35,6 @@ #include #include -#include -#include -#include "config.h" -#include "ncmpc.h" -#include "options.h" -#include "support.h" -#include "command.h" -#include "colors.h" -#include "conf.h" - #define MAX_LINE_LENGTH 1024 #define COMMENT_TOKEN '#' diff --git a/src/conf.h b/src/conf.h index 20b4f5e..97e73b3 100644 --- a/src/conf.h +++ b/src/conf.h @@ -1,3 +1,4 @@ +#include "options.h" int check_user_conf_dir(void); diff --git a/src/easy_download.c b/src/easy_download.c index 83616cf..d572025 100644 --- a/src/easy_download.c +++ b/src/easy_download.c @@ -14,19 +14,18 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ - -# + +#include "ncmpc.h" + +#ifdef ENABLE_LYRICS_SCREEN +#include "easy_download.h" #include #include #include #include -#include "ncmpc.h" - -#ifdef ENABLE_LYRICS_SCREEN #include -#include "easy_download.h" static size_t write_data(void *buffer, size_t size, size_t nmemb, easy_download_struct *dld) diff --git a/src/list_window.c b/src/list_window.c index a6bc911..859652c 100644 --- a/src/list_window.c +++ b/src/list_window.c @@ -18,18 +18,16 @@ * */ -#include -#include -#include -#include -#include - +#include "list_window.h" #include "config.h" #include "options.h" #include "support.h" #include "command.h" #include "colors.h" -#include "list_window.h" + +#include +#include +#include extern void screen_bell(void); diff --git a/src/list_window.h b/src/list_window.h index 114f71e..ad66760 100644 --- a/src/list_window.h +++ b/src/list_window.h @@ -1,8 +1,11 @@ #ifndef LIST_WINDOW_H #define LIST_WINDOW_H +#include "command.h" + #include -#include +#include + #define LW_ROW(lw) (lw ? lw->selected-lw->start : 0) #define LW_HIDE_CURSOR 0x01 diff --git a/src/lyrics_hd.c b/src/lyrics_hd.c index 322160c..e7acfc2 100644 --- a/src/lyrics_hd.c +++ b/src/lyrics_hd.c @@ -1,10 +1,8 @@ -#include +#include "src_lyrics.h" + #include -#include #include -#include "src_lyrics.h" - char *check_lyr_hd(char *artist, char *title, int how) { //checking whether for lyrics file existence and proper access result |= 2; diff --git a/src/main.c b/src/main.c index 6a6ba34..97bfdd3 100644 --- a/src/main.c +++ b/src/main.c @@ -18,14 +18,6 @@ * */ -#include -#include -#include -#include -#include -#include -#include - #include "config.h" #include "ncmpc.h" #include "mpdclient.h" @@ -38,6 +30,11 @@ #include "screen_utils.h" #include "strfsong.h" +#include +#include +#include +#include + #define BUFSIZE 1024 static mpdclient_t *mpd = NULL; diff --git a/src/mpdclient.c b/src/mpdclient.c index 941c091..ab78573 100644 --- a/src/mpdclient.c +++ b/src/mpdclient.c @@ -18,20 +18,19 @@ * */ -#include -#include -#include -#include -#include -#include - +#include "mpdclient.h" +#include "screen_utils.h" #include "config.h" #include "ncmpc.h" #include "support.h" -#include "mpdclient.h" #include "options.h" #include "strfsong.h" +#include +#include +#include +#include + #undef ENABLE_FANCY_PLAYLIST_MANAGMENT_CMD_ADD /* broken with song id's */ #define ENABLE_FANCY_PLAYLIST_MANAGMENT_CMD_DELETE #define ENABLE_FANCY_PLAYLIST_MANAGMENT_CMD_MOVE diff --git a/src/mpdclient.h b/src/mpdclient.h index c8cb868..a93cec9 100644 --- a/src/mpdclient.h +++ b/src/mpdclient.h @@ -1,7 +1,10 @@ #ifndef MPDCLIENT_H #define MPDCLIENT_H + #include "libmpdclient.h" +#include + #define MPD_VERSION_EQ(c,x,y,z) (c->connection->version[0] == x && \ c->connection->version[1] == y && \ c->connection->version[2] == z ) diff --git a/src/options.c b/src/options.c index 668fe75..9b1aafe 100644 --- a/src/options.c +++ b/src/options.c @@ -18,19 +18,16 @@ * */ -#include -#include -#include -#include -#include - +#include "options.h" #include "config.h" #include "ncmpc.h" #include "support.h" -#include "options.h" #include "command.h" #include "conf.h" +#include +#include + #define MAX_LONGOPT_LENGTH 32 #define ERROR_UNKNOWN_OPTION 0x01 diff --git a/src/options.h b/src/options.h index e2b3b9b..380b43e 100644 --- a/src/options.h +++ b/src/options.h @@ -1,3 +1,7 @@ +#ifndef OPTIONS_H +#define OPTIONS_H + +#include #define MPD_HOST_ENV "MPD_HOST" #define MPD_PORT_ENV "MPD_PORT" @@ -39,3 +43,5 @@ extern options_t options; options_t *options_init(void); options_t *options_parse(int argc, const char **argv); + +#endif diff --git a/src/screen.c b/src/screen.c index 4624974..f9fa9b1 100644 --- a/src/screen.c +++ b/src/screen.c @@ -18,15 +18,8 @@ * */ -#include -#include -#include -#include -#include -#include -#include -#include - +#include "screen.h" +#include "screen_utils.h" #include "config.h" #include "ncmpc.h" #include "support.h" @@ -37,9 +30,13 @@ #include "colors.h" #include "strfsong.h" #include "wreadln.h" -#include "screen.h" -#include "screen_utils.h" +#include +#include +#include +#include +#include +#include #define SCREEN_PLAYLIST_ID 0 #define SCREEN_BROWSE_ID 1 diff --git a/src/screen.h b/src/screen.h index 0ecd9ef..d6f1620 100644 --- a/src/screen.h +++ b/src/screen.h @@ -1,7 +1,11 @@ #ifndef SCREEN_H #define SCREEN_H -#include + #include "list_window.h" +#include "mpdclient.h" + +#include +#include #define IS_PLAYING(s) (s==MPD_STATUS_STATE_PLAY) #define IS_PAUSED(s) (s==MPD_STATUS_STATE_PAUSE) diff --git a/src/screen_artist.c b/src/screen_artist.c index b9acd3e..fa42f1f 100644 --- a/src/screen_artist.c +++ b/src/screen_artist.c @@ -18,13 +18,8 @@ * */ -#include -#include -#include -#include -#include - #include "config.h" + #ifndef DISABLE_ARTIST_SCREEN #include "ncmpc.h" #include "options.h" @@ -37,6 +32,12 @@ #include "screen_utils.h" #include "screen_browse.h" +#include +#include +#include +#include +#include + #define BUFSIZE 1024 typedef enum { LIST_ARTISTS, LIST_ALBUMS, LIST_SONGS } artist_mode_t; diff --git a/src/screen_clock.c b/src/screen_clock.c index 0839304..a929532 100644 --- a/src/screen_clock.c +++ b/src/screen_clock.c @@ -5,12 +5,6 @@ * ncurses. */ -#include -#include -#include -#include -#include - #include "config.h" #ifndef DISABLE_CLOCK_SCREEN @@ -21,6 +15,13 @@ #include "screen.h" #include "screen_utils.h" +#include +#include +#include +#include +#include + + #define YDEPTH 5 #define BUFSIZE 64 diff --git a/src/screen_file.c b/src/screen_file.c index 0dbaab4..a9dec94 100644 --- a/src/screen_file.c +++ b/src/screen_file.c @@ -18,12 +18,6 @@ * */ -#include -#include -#include -#include -#include - #include "config.h" #include "ncmpc.h" #include "options.h" @@ -36,6 +30,12 @@ #include "screen_browse.h" #include "screen_play.h" +#include +#include +#include +#include +#include + #define USE_OLD_LAYOUT #undef USE_OLD_ADD diff --git a/src/screen_help.c b/src/screen_help.c index 80495a2..b62c618 100644 --- a/src/screen_help.c +++ b/src/screen_help.c @@ -18,11 +18,6 @@ * */ -#include -#include -#include -#include - #include "config.h" #include "ncmpc.h" #include "mpdclient.h" @@ -30,6 +25,11 @@ #include "screen.h" #include "screen_utils.h" +#include +#include +#include +#include + typedef struct { signed char highlight; diff --git a/src/screen_keydef.c b/src/screen_keydef.c index 8571ca2..11c0a4a 100644 --- a/src/screen_keydef.c +++ b/src/screen_keydef.c @@ -18,12 +18,6 @@ * */ -#include -#include -#include -#include -#include - #include "config.h" #ifndef DISABLE_KEYDEF_SCREEN @@ -35,6 +29,12 @@ #include "screen.h" #include "screen_utils.h" +#include +#include +#include +#include +#include + #define STATIC_ITEMS 0 #define STATIC_SUB_ITEMS 1 #define BUFSIZE 256 diff --git a/src/screen_lyrics.c b/src/screen_lyrics.c index 793eae7..2dd5e12 100644 --- a/src/screen_lyrics.c +++ b/src/screen_lyrics.c @@ -19,16 +19,6 @@ * */ -#define _GNU_SOURCE -#include -#include -#include -#include -#include -#include -#include -#include - #include "config.h" #ifndef DISABLE_LYRICS_SCREEN #include @@ -42,6 +32,16 @@ #include "strfsong.h" #include "src_lyrics.h" +#define _GNU_SOURCE +#include +#include +#include +#include +#include +#include +#include +#include + int src_selection; static void lyrics_paint(screen_t *screen, mpdclient_t *c); diff --git a/src/screen_play.c b/src/screen_play.c index 6cd28d6..736be92 100644 --- a/src/screen_play.c +++ b/src/screen_play.c @@ -18,13 +18,6 @@ * */ -#include -#include -#include -#include -#include -#include - #include "config.h" #include "ncmpc.h" #include "options.h" @@ -39,6 +32,13 @@ #include "screen_utils.h" #include "screen_play.h" +#include +#include +#include +#include +#include +#include + #define MAX_SONG_LENGTH 512 typedef struct diff --git a/src/screen_search.c b/src/screen_search.c index a74ef60..85dc5c7 100644 --- a/src/screen_search.c +++ b/src/screen_search.c @@ -18,13 +18,8 @@ * */ -#include -#include -#include -#include -#include - #include "config.h" + #ifndef DISABLE_SEARCH_SCREEN #include "ncmpc.h" #include "options.h" @@ -37,6 +32,12 @@ #include "screen_utils.h" #include "screen_browse.h" +#include +#include +#include +#include +#include + /* new search stuff with qball's libmpdclient */ #define FUTURE diff --git a/src/screen_utils.c b/src/screen_utils.c index 80a1b3f..d75116f 100644 --- a/src/screen_utils.c +++ b/src/screen_utils.c @@ -18,22 +18,17 @@ * */ -#include -#include -#include -#include -#include - +#include "screen_utils.h" #include "config.h" #include "ncmpc.h" -#include "mpdclient.h" #include "support.h" -#include "command.h" #include "options.h" -#include "list_window.h" #include "colors.h" #include "wreadln.h" -#include "screen.h" + +#include +#include +#include #define FIND_PROMPT _("Find: ") #define RFIND_PROMPT _("Find backward: ") diff --git a/src/screen_utils.h b/src/screen_utils.h index 0bb5226..6928ba8 100644 --- a/src/screen_utils.h +++ b/src/screen_utils.h @@ -1,6 +1,13 @@ #ifndef SCREEN_UTILS_H #define SCREEN_UTILS_H +#include "screen.h" +#include "list_window.h" +#include "mpdclient.h" +#include "command.h" + +#include + /* sound an audible and/or visible bell */ void screen_bell(void); diff --git a/src/src_lyrics.h b/src/src_lyrics.h index 7a2e7ea..941c4b6 100644 --- a/src/src_lyrics.h +++ b/src/src_lyrics.h @@ -1,10 +1,11 @@ #ifndef SOURCE_LYRICS #define SOURCE_LYRICS -#include -#include #include "list_window.h" #include "mpdclient.h" + +#include +#include #include typedef struct _formed_text diff --git a/src/strfsong.c b/src/strfsong.c index 22f2e2e..523c30d 100644 --- a/src/strfsong.c +++ b/src/strfsong.c @@ -22,17 +22,10 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ +#include "strfsong.h" +#include "support.h" -#include -#include -#include #include -#include - -#include "config.h" -#include "libmpdclient.h" -#include "support.h" -#include "strfsong.h" static const gchar * skip(const gchar * p) diff --git a/src/strfsong.h b/src/strfsong.h index 74f9d73..7c0361d 100644 --- a/src/strfsong.h +++ b/src/strfsong.h @@ -1,3 +1,9 @@ +#ifndef STRFSONG_H +#define STRFSONG_H + +#include +#include "libmpdclient.h" gsize strfsong(gchar *s, gsize max, const gchar *format, mpd_Song *song); +#endif diff --git a/src/support.c b/src/support.c index b7117e5..315c569 100644 --- a/src/support.c +++ b/src/support.c @@ -18,16 +18,14 @@ * */ +#include "support.h" +#include "ncmpc.h" + #include #include #include #include #include -#include - -#include "config.h" -#include "ncmpc.h" -#include "support.h" #define BUFSIZE 1024 diff --git a/src/support.h b/src/support.h index c9cfed0..8e868e7 100644 --- a/src/support.h +++ b/src/support.h @@ -1,6 +1,8 @@ #ifndef SUPPORT_H #define SUPPORT_H +#include + #ifdef HAVE_LIBGEN_H #include #endif diff --git a/src/utils.c b/src/utils.c index 5f7f5ef..ac836a2 100644 --- a/src/utils.c +++ b/src/utils.c @@ -18,19 +18,14 @@ * */ -#include -#include -#include -#include -#include - -#include "config.h" +#include "utils.h" #include "ncmpc.h" #include "options.h" #include "support.h" -#include "mpdclient.h" -#include "utils.h" +#include +#include +#include GList * string_list_free(GList *string_list) diff --git a/src/utils.h b/src/utils.h index fe913af..0fb1c68 100644 --- a/src/utils.h +++ b/src/utils.h @@ -1,6 +1,9 @@ #ifndef UTILS_H #define UTILS_H +#include "mpdclient.h" + +#include /* functions for lists containing strings */ GList *string_list_free(GList *string_list); diff --git a/src/wreadln.c b/src/wreadln.c index f6b848c..e6bc612 100644 --- a/src/wreadln.c +++ b/src/wreadln.c @@ -20,6 +20,8 @@ #include "config.h" +#include "wreadln.h" + #include #include #include @@ -30,8 +32,6 @@ #include #endif -#include "wreadln.h" - #define KEY_CTRL_A 1 #define KEY_CTRL_C 3 #define KEY_CTRL_D 4 diff --git a/src/wreadln.h b/src/wreadln.h index d448f41..2dd2191 100644 --- a/src/wreadln.h +++ b/src/wreadln.h @@ -1,6 +1,9 @@ #ifndef WREADLN_H #define WREADLN_H +#include +#include + /* max size allocated for a line */ extern guint wrln_max_line_size; -- 2.30.2