From 0ef870bef8b5cc804567d1683bba7625115702f5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tin=20=C5=A0vagelj?= Date: Mon, 16 Dec 2024 08:15:45 +0100 Subject: [PATCH] Fix build and includes after moving sources (#2119) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This is part 2 of #2119. The parent commit (ef6feef0) only moved files to retain their correct history, this commit fixes all the includes and build files. Signed-off-by: Tin Å vagelj --- .git-blame-ignore-revs | 5 + src/CMakeLists.txt | 280 +++++++++++++++------------ src/common.cc | 32 +-- src/common.h | 4 +- src/conky-imlib2.cc | 8 +- src/conky-imlib2.h | 4 +- src/conky.cc | 75 ++++--- src/conky.h | 49 +++-- src/content/algebra.cc | 4 +- src/content/colour-names-stub.hh | 2 +- src/content/colours.cc | 4 +- src/content/combine.cc | 4 +- src/content/gradient.cc | 8 +- src/content/gradient.hh | 2 +- src/content/scroll.cc | 10 +- src/content/specials.cc | 28 +-- src/content/specials.h | 2 +- src/content/temphelper.cc | 2 +- src/content/template.cc | 4 +- src/content/text_object.cc | 4 +- src/content/text_object.h | 2 +- src/core.cc | 134 +++++++------ src/data/audio/audacious.cc | 6 +- src/data/audio/cmus.cc | 8 +- src/data/audio/libmpdclient.cc | 112 +++++------ src/data/audio/mixer.cc | 8 +- src/data/audio/moc.cc | 8 +- src/data/audio/mpd.cc | 8 +- src/data/audio/pulseaudio.cc | 12 +- src/data/audio/pulseaudio.h | 2 +- src/data/audio/xmms2.cc | 24 +-- src/data/data-source.hh | 2 +- src/data/entropy.cc | 20 +- src/data/exec.cc | 18 +- src/data/exec.h | 2 +- src/data/fs.cc | 20 +- src/data/fs.h | 2 +- src/data/hardware/apcupsd.cc | 28 +-- src/data/hardware/bsdapm.cc | 4 +- src/data/hardware/cpu.cc | 4 +- src/data/hardware/diskio.cc | 16 +- src/data/hardware/hddtemp.cc | 10 +- src/data/hardware/i8k.cc | 8 +- src/data/hardware/ibm.cc | 8 +- src/data/hardware/intel_backlight.cc | 2 +- src/data/hardware/intel_backlight.h | 4 +- src/data/hardware/nvidia.cc | 46 ++--- src/data/hardware/nvidia.h | 2 +- src/data/hardware/smapi.cc | 8 +- src/data/hardware/sony.cc | 6 +- src/data/ical.cc | 4 +- src/data/iconv_tools.cc | 4 +- src/data/misc.cc | 12 +- src/data/misc.h | 2 +- src/data/mysql.cc | 6 +- src/data/network/ccurl_thread.cc | 10 +- src/data/network/ccurl_thread.h | 4 +- src/data/network/irc.cc | 6 +- src/data/network/mail.cc | 10 +- src/data/network/mail.h | 2 +- src/data/network/mboxscan.cc | 8 +- src/data/network/net_stat.cc | 22 +-- src/data/network/prss.cc | 36 ++-- src/data/network/read_tcpip.cc | 6 +- src/data/network/rss.cc | 14 +- src/data/network/tcp-portmon.cc | 24 +-- src/data/os/bsdcommon.cc | 6 +- src/data/os/bsdcommon.h | 2 +- src/data/{ => os}/darwin.h | 0 src/data/{ => os}/darwin.mm | 8 +- src/data/{ => os}/darwin_sip.h | 0 src/data/os/dragonfly.cc | 16 +- src/data/os/dragonfly.h | 2 +- src/data/os/freebsd.cc | 24 +-- src/data/os/freebsd.h | 2 +- src/data/os/haiku.cc | 10 +- src/data/os/haiku.h | 4 +- src/data/os/journal.cc | 12 +- src/data/os/linux.cc | 69 ++++--- src/data/os/linux.h | 2 +- src/data/os/netbsd.cc | 2 +- src/data/os/netbsd.h | 4 +- src/data/os/openbsd.cc | 14 +- src/data/os/openbsd.h | 2 +- src/data/os/solaris.cc | 12 +- src/data/proc.cc | 8 +- src/data/tailhead.cc | 16 +- src/data/timeinfo.cc | 6 +- src/data/timeinfo.h | 2 +- src/data/top.cc | 38 ++-- src/data/top.h | 4 +- src/data/user.cc | 4 +- src/data/users.cc | 2 +- src/lua/colour-settings.cc | 2 +- src/lua/colour-settings.hh | 2 +- src/lua/fonts.cc | 6 +- src/lua/fonts.h | 2 +- src/lua/llua.cc | 12 +- src/lua/llua.h | 4 +- src/lua/lua-config.cc | 2 +- src/lua/setting.hh | 2 +- src/lua/x11-settings.cc | 4 +- src/main.cc | 16 +- src/mouse-events.cc | 4 +- src/mouse-events.h | 5 +- src/output/display-console.cc | 2 +- src/output/display-console.hh | 2 +- src/output/display-file.cc | 2 +- src/output/display-file.hh | 2 +- src/output/display-http.cc | 2 +- src/output/display-http.hh | 2 +- src/output/display-ncurses.cc | 4 +- src/output/display-ncurses.hh | 4 +- src/output/display-output.hh | 6 +- src/output/display-wayland.cc | 24 +-- src/output/display-wayland.hh | 4 +- src/output/display-x11.cc | 18 +- src/output/display-x11.hh | 2 +- src/output/gui.cc | 11 +- src/output/gui.h | 6 +- src/output/nc.h | 2 +- src/output/wl.cc | 2 +- src/output/wl.h | 2 +- src/output/x11-color.cc | 2 +- src/output/x11.cc | 14 +- src/output/x11.h | 4 +- tests/test-algebra.cc | 2 +- tests/test-colours.cc | 2 +- tests/test-conky.cc | 5 +- tests/test-darwin.cc | 2 +- tests/test-diskio.cc | 2 +- tests/test-fs.cc | 2 +- tests/test-gradient.cc | 4 +- tests/test-graph.cc | 9 +- tests/test-linux.cc | 2 +- 135 files changed, 891 insertions(+), 823 deletions(-) rename src/data/{ => os}/darwin.h (100%) rename src/data/{ => os}/darwin.mm (99%) rename src/data/{ => os}/darwin_sip.h (100%) diff --git a/.git-blame-ignore-revs b/.git-blame-ignore-revs index 9edd12a346..e4ad49cfe5 100644 --- a/.git-blame-ignore-revs +++ b/.git-blame-ignore-revs @@ -57,3 +57,8 @@ cbebe447078e28c50957d568303f42d6b8aae126 # Includes changes to functionality so it can't be ignored: # color parsing, text alignment, output registration # 6adf6b9dd4d368640bf7ef57f3e6199d83154d78 + +### Move sources into appropriate subdirectories (#2119) +# Performed no changes to the source files, only moved them. +# Child commit addressed the issues caused by the move. +6a27b1afa35ed5829d36a71b3226b9bd44e7f080 diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 486b877d6b..172f0784f8 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -66,80 +66,80 @@ set(conky_sources ${conky_sources} c++wrap.cc c++wrap.hh - colour-settings.cc - colour-settings.h - colours.cc - colours.h - combine.cc - combine.h + lua/colour-settings.cc + lua/colour-settings.hh + content/colours.cc + content/colours.hh + content/combine.cc + content/combine.h common.cc common.h conky.cc conky.h core.cc core.h - cpu.cc - cpu.h - diskio.cc - diskio.h - entropy.cc - entropy.h - exec.cc - exec.h - fs.cc - fs.h - gradient.cc - gradient.h - mail.cc - mail.h - misc.cc - misc.h - net_stat.cc - net_stat.h - template.cc - template.h - mboxscan.cc - mboxscan.h - read_tcpip.cc - read_tcpip.h - scroll.cc - scroll.h - specials.cc - specials.h - tailhead.cc - tailhead.h - temphelper.cc - temphelper.h - text_object.cc - text_object.h - timeinfo.cc - timeinfo.h - top.cc - top.h - algebra.cc - algebra.h + data/hardware/cpu.cc + data/hardware/cpu.h + data/hardware/diskio.cc + data/hardware/diskio.h + data/entropy.cc + data/entropy.h + data/exec.cc + data/exec.h + data/fs.cc + data/fs.h + content/gradient.cc + content/gradient.hh + data/network/mail.cc + data/network/mail.h + data/misc.cc + data/misc.h + data/network/net_stat.cc + data/network/net_stat.h + content/template.cc + content/template.h + data/network/mboxscan.cc + data/network/mboxscan.h + data/network/read_tcpip.cc + data/network/read_tcpip.h + content/scroll.cc + content/scroll.h + content/specials.cc + content/specials.h + data/tailhead.cc + data/tailhead.h + content/temphelper.cc + content/temphelper.h + content/text_object.cc + content/text_object.h + data/timeinfo.cc + data/timeinfo.h + data/top.cc + data/top.h + content/algebra.cc + content/algebra.h prioqueue.cc prioqueue.h - proc.cc - proc.h - user.cc - user.h - luamm.cc - luamm.hh - data-source.cc - data-source.hh - display-output.cc - display-output.hh - display-console.cc - display-console.hh - display-file.cc - display-file.hh - lua-config.cc - lua-config.hh - setting.cc - setting.hh - llua.cc - llua.h + data/proc.cc + data/proc.h + data/user.cc + data/user.h + lua/luamm.cc + lua/luamm.hh + data/data-source.cc + data/data-source.hh + output/display-output.cc + output/display-output.hh + output/display-console.cc + output/display-console.hh + output/display-file.cc + output/display-file.hh + lua/lua-config.cc + lua/lua-config.hh + lua/setting.cc + lua/setting.hh + lua/llua.cc + lua/llua.h update-cb.cc update-cb.hh logging.h @@ -148,122 +148,152 @@ set(conky_sources # Platform specific sources if(OS_LINUX) - set(linux linux.cc linux.h users.cc users.h sony.cc sony.h i8k.cc i8k.h) - set(optional_sources ${optional_sources} ${linux}) + set(linux_sources + data/os/linux.cc + data/os/linux.h + data/users.cc + data/users.h + data/hardware/sony.cc + data/hardware/sony.h + data/hardware/i8k.cc + data/hardware/i8k.h + ) + set(optional_sources ${optional_sources} ${linux_sources}) endif(OS_LINUX) if(OS_FREEBSD) - set(freebsd freebsd.cc freebsd.h bsdapm.cc bsdapm.h) - set(optional_sources ${optional_sources} ${freebsd}) + set(freebsd_sources + data/os/freebsd.cc + data/os/freebsd.h + data/hardware/bsdapm.cc + data/hardware/bsdapm.h + ) + set(optional_sources ${optional_sources} ${freebsd_sources}) endif(OS_FREEBSD) if(OS_DRAGONFLY) - set(dragonfly dragonfly.cc dragonfly.h bsdapm.cc bsdapm.h) - set(optional_sources ${optional_sources} ${dragonfly}) + set(dragonfly_sources + data/os/dragonfly.cc + data/os/dragonfly.h + data/hardware/bsdapm.cc + data/hardware/bsdapm.h + ) + set(optional_sources ${optional_sources} ${dragonfly_sources}) endif(OS_DRAGONFLY) if(OS_OPENBSD) - set(openbsd openbsd.cc openbsd.h bsdapm.cc bsdapm.h) - set(optional_sources ${optional_sources} ${openbsd}) + set(openbsd_sources + data/os/openbsd.cc + data/os/openbsd.h + data/hardware/bsdapm.cc + data/hardware/bsdapm.h + ) + set(optional_sources ${optional_sources} ${openbsd_sources}) endif(OS_OPENBSD) # These below are not actually supported. No idea what their status is. if(OS_SOLARIS) - set(solaris solaris.cc solaris.h) - set(optional_sources ${optional_sources} ${solaris}) + set(solaris_sources data/os/solaris.cc data/os/solaris.h) + set(optional_sources ${optional_sources} ${solaris_sources}) endif(OS_SOLARIS) if(OS_NETBSD) - set(netbsd netbsd.cc netbsd.h bsdcommon.cc bsdcommon.h) - set(optional_sources ${optional_sources} ${netbsd}) + set(netbsd_sources data/os/netbsd.cc data/os/netbsd.h data/os/bsdcommon.cc data/os/bsdcommon.h) + set(optional_sources ${optional_sources} ${netbsd_sources}) endif(OS_NETBSD) if(OS_HAIKU) - set(haiku haiku.cc haiku.h) - set(optional_sources ${optional_sources} ${haiku}) + set(haiku_sources data/os/haiku.cc data/os/haiku.h) + set(optional_sources ${optional_sources} ${haiku_sources}) endif(OS_HAIKU) if(OS_DARWIN) - set(darwin darwin.mm darwin.h darwin_sip.h i18n.h) - set(optional_sources ${optional_sources} ${darwin}) + set(darwin_sources data/os/darwin.mm data/os/darwin.h data/os/darwin_sip.h i18n.h) + set(optional_sources ${optional_sources} ${darwin_sources}) endif(OS_DARWIN) # Optional sources if(HAVE_SOUNDCARD_H) - set(mixer mixer.cc mixer.h) + set(mixer data/audio/mixer.cc data/audio/mixer.h) set(optional_sources ${optional_sources} ${mixer}) endif(HAVE_SOUNDCARD_H) if(BUILD_AUDACIOUS) - set(audacious audacious.cc audacious.h) + set(audacious data/audio/audacious.cc data/audio/audacious.h) set(optional_sources ${optional_sources} ${audacious}) endif(BUILD_AUDACIOUS) if(BUILD_IBM) - set(ibm ibm.cc ibm.h smapi.cc smapi.h) + set(ibm data/hardware/ibm.cc data/hardware/ibm.h data/hardware/smapi.cc data/hardware/smapi.h) set(optional_sources ${optional_sources} ${ibm}) endif(BUILD_IBM) if(BUILD_MPD) - set(mpd mpd.cc mpd.h libmpdclient.cc libmpdclient.h) + set(mpd data/audio/mpd.cc data/audio/mpd.h data/audio/libmpdclient.cc data/audio/libmpdclient.h) set(optional_sources ${optional_sources} ${mpd}) endif(BUILD_MPD) if(BUILD_MYSQL) - set(mysql mysql.cc mysql.h) + set(mysql data/mysql.cc data/mysql.h) set(optional_sources ${optional_sources} ${mysql}) endif(BUILD_MYSQL) if(BUILD_MOC) - set(moc moc.cc moc.h) + set(moc data/audio/moc.cc data/audio/moc.h) set(optional_sources ${optional_sources} ${moc}) endif(BUILD_MOC) if(BUILD_CMUS) - set(cmus cmus.cc cmus.h) + set(cmus data/audio/cmus.cc data/audio/cmus.h) set(optional_sources ${optional_sources} ${cmus}) endif(BUILD_CMUS) if(BUILD_JOURNAL) - set(journal journal.cc journal.h) + set(journal data/os/journal.cc data/os/journal.h) set(optional_sources ${optional_sources} ${journal}) endif(BUILD_JOURNAL) if(BUILD_XMMS2) - set(xmms2 xmms2.cc xmms2.h) + set(xmms2 data/audio/xmms2.cc data/audio/xmms2.h) set(optional_sources ${optional_sources} ${xmms2}) endif(BUILD_XMMS2) if(BUILD_PORT_MONITORS) - add_library(tcp-portmon libtcp-portmon.cc libtcp-portmon.h) + add_library(tcp-portmon + data/network/libtcp-portmon.cc + data/network/libtcp-portmon.h + ) set(conky_libs ${conky_libs} tcp-portmon) - set(port_monitors tcp-portmon.cc tcp-portmon.h) + set(port_monitors + data/network/tcp-portmon.cc + data/network/tcp-portmon.h + ) set(optional_sources ${optional_sources} ${port_monitors}) endif(BUILD_PORT_MONITORS) if(BUILD_HTTP) set(http - display-http.cc - display-http.hh + output/display-http.cc + output/display-http.hh ) set(optional_sources ${optional_sources} ${http}) endif(BUILD_HTTP) if(BUILD_X11) set(x11 - display-x11.cc - display-x11.hh - x11-settings.cc - x11-settings.h - x11-color.cc - x11.cc - x11.h + output/display-x11.cc + output/display-x11.hh + lua/x11-settings.cc + lua/x11-settings.h + output/x11-color.cc + output/x11.cc + output/x11.h ) set(optional_sources ${optional_sources} ${x11}) endif(BUILD_X11) if(BUILD_GUI) - set(gui fonts.cc fonts.h gui.cc gui.h) + set(gui lua/fonts.cc lua/fonts.h output/gui.cc output/gui.h) set(optional_sources ${optional_sources} ${gui}) if(BUILD_MOUSE_EVENTS OR BUILD_XINPUT) @@ -274,10 +304,10 @@ endif(BUILD_GUI) if(BUILD_WAYLAND) set(wl_sources - wl.cc - wl.h - display-wayland.cc - display-wayland.hh + output/wl.cc + output/wl.h + output/display-wayland.cc + output/display-wayland.hh xdg-shell-protocol.c wlr-layer-shell-protocol.c ) @@ -340,22 +370,30 @@ if(BUILD_WAYLAND) endif(BUILD_WAYLAND) if(BUILD_HDDTEMP) - set(hddtemp hddtemp.cc hddtemp.h) + set(hddtemp data/hardware/hddtemp.cc data/hardware/hddtemp.h) set(optional_sources ${optional_sources} ${hddtemp}) endif(BUILD_HDDTEMP) if(BUILD_CURL) - set(ccurl_thread ccurl_thread.cc ccurl_thread.h) + set(ccurl_thread + data/network/ccurl_thread.cc + data/network/ccurl_thread.h + ) set(optional_sources ${optional_sources} ${ccurl_thread}) endif(BUILD_CURL) if(BUILD_RSS) - set(rss rss.cc rss.h prss.cc prss.h) + set(rss + data/network/rss.cc + data/network/rss.h + data/network/prss.cc + data/network/prss.h + ) set(optional_sources ${optional_sources} ${rss}) endif(BUILD_RSS) if(BUILD_NVIDIA) - set(nvidia nvidia.cc nvidia.h) + set(nvidia data/hardware/nvidia.cc data/hardware/nvidia.h) set(optional_sources ${optional_sources} ${nvidia}) endif(BUILD_NVIDIA) @@ -365,42 +403,42 @@ if(BUILD_IMLIB2) endif(BUILD_IMLIB2) if(BUILD_APCUPSD) - set(apcupsd apcupsd.cc apcupsd.h) + set(apcupsd data/hardware/apcupsd.cc data/hardware/apcupsd.h) set(optional_sources ${optional_sources} ${apcupsd}) endif(BUILD_APCUPSD) if(BUILD_ICAL) - set(ical ical.cc ical.h) + set(ical data/ical.cc data/ical.h) set(optional_sources ${optional_sources} ${ical}) endif(BUILD_ICAL) if(BUILD_IRC) - set(irc irc.cc irc.h) + set(irc data/network/irc.cc data/network/irc.h) set(optional_sources ${optional_sources} ${irc}) endif(BUILD_IRC) if(BUILD_ICONV) - set(iconv iconv_tools.cc iconv_tools.h) + set(iconv data/iconv_tools.cc data/iconv_tools.h) set(optional_sources ${optional_sources} ${iconv}) endif(BUILD_ICONV) if(BUILD_NCURSES) set(ncurses_srcs - nc.cc - nc.h - display-ncurses.cc - display-ncurses.hh + output/nc.cc + output/nc.h + output/display-ncurses.cc + output/display-ncurses.hh ) set(optional_sources ${optional_sources} ${ncurses_srcs}) endif(BUILD_NCURSES) if(BUILD_PULSEAUDIO) - set(pulseaudio pulseaudio.cc pulseaudio.h) + set(pulseaudio data/audio/pulseaudio.cc data/audio/pulseaudio.h) set(optional_sources ${optional_sources} ${pulseaudio}) endif(BUILD_PULSEAUDIO) if(BUILD_INTEL_BACKLIGHT) - set(intel_backlight intel_backlight.cc intel_backlight.h) + set(intel_backlight data/hardware/intel_backlight.cc data/hardware/intel_backlight.h) set(optional_sources ${optional_sources} ${intel_backlight}) endif(BUILD_INTEL_BACKLIGHT) diff --git a/src/common.cc b/src/common.cc index ae4e26b32c..335b02fb24 100644 --- a/src/common.cc +++ b/src/common.cc @@ -47,14 +47,14 @@ #include "config.h" #include "conky.h" #include "core.h" -#include "fs.h" +#include "data/fs.h" #include "logging.h" -#include "misc.h" -#include "net_stat.h" -#include "specials.h" -#include "temphelper.h" -#include "timeinfo.h" -#include "top.h" +#include "data/misc.h" +#include "data/network/net_stat.h" +#include "content/specials.h" +#include "content/temphelper.h" +#include "data/timeinfo.h" +#include "data/top.h" #if defined(_POSIX_C_SOURCE) && !defined(__OpenBSD__) && !defined(__HAIKU__) #include @@ -62,23 +62,23 @@ /* check for OS and include appropriate headers */ #if defined(__linux__) -#include "linux.h" +#include "data/os/linux.h" #elif defined(__FreeBSD__) || defined(__FreeBSD_kernel__) -#include "freebsd.h" +#include "data/os/freebsd.h" #elif defined(__DragonFly__) -#include "dragonfly.h" +#include "data/os/dragonfly.h" #elif defined(__OpenBSD__) -#include "openbsd.h" +#include "data/os/openbsd.h" #elif defined(__NetBSD__) -#include "netbsd.h" +#include "data/os/netbsd.h" #elif defined(__APPLE__) && defined(__MACH__) -#include "darwin.h" // strings.h +#include "data/os/darwin.h" // strings.h #endif #include "update-cb.hh" #ifdef BUILD_CURL -#include "ccurl_thread.h" +#include "data/network/ccurl_thread.h" #endif /* BUILD_CURL */ /* folds a string over top of itself, like so: @@ -501,7 +501,7 @@ void print_no_update(struct text_object *obj, char *p, #ifdef BUILD_GUI void scan_loadgraph_arg(struct text_object *obj, const char *arg) { - scan_graph(obj, arg, 0, FALSE); + scan_graph(obj, arg, 0, false); } double loadgraphval(struct text_object *obj) { @@ -915,7 +915,7 @@ void print_github(struct text_object *obj, char *p, unsigned int p_max_size) { CURL *curl = nullptr; CURLcode res; - if (0 == strcmp(github_token.get(*state).c_str(), "")) { + if (streq(github_token.get(*state).c_str(), "")) { NORM_ERR( "${github_notifications} requires token. " "Go ahead and generate one " NEW_TOKEN diff --git a/src/common.h b/src/common.h index 472f35d2fb..5064077516 100644 --- a/src/common.h +++ b/src/common.h @@ -33,8 +33,8 @@ #include #include -#include "setting.hh" -#include "text_object.h" +#include "lua/setting.hh" +#include "content/text_object.h" char *readfile(const char *filename, int *total_read, char showerror); diff --git a/src/conky-imlib2.cc b/src/conky-imlib2.cc index 64d4ce6f78..a039433a04 100644 --- a/src/conky-imlib2.cc +++ b/src/conky-imlib2.cc @@ -24,9 +24,9 @@ #include "conky-imlib2.h" #include "common.h" -#include "display-output.hh" +#include "output/display-output.hh" #include "logging.h" -#include "text_object.h" +#include "content/text_object.h" #include #include @@ -35,8 +35,8 @@ #include #include -#include "x11-settings.h" -#include "x11.h" +#include "lua/x11-settings.h" +#include "output/x11.h" struct image_list_s { char name[1024]; diff --git a/src/conky-imlib2.h b/src/conky-imlib2.h index 11a166979c..c557289fdd 100644 --- a/src/conky-imlib2.h +++ b/src/conky-imlib2.h @@ -24,8 +24,8 @@ #ifndef _CONKY_IMBLI2_H_ #define _CONKY_IMBLI2_H_ -#include "setting.hh" -#include "text_object.h" +#include "lua/setting.hh" +#include "content/text_object.h" #include diff --git a/src/conky.cc b/src/conky.cc index 889109c113..6bc3c6717e 100644 --- a/src/conky.cc +++ b/src/conky.cc @@ -37,6 +37,7 @@ #include #include #include +#include #include #include #include @@ -49,6 +50,7 @@ #include #include #include +#include #include #include #include @@ -66,15 +68,15 @@ #endif /* HAVE_DIRENT_H */ #include "common.h" -#include "text_object.h" +#include "content/text_object.h" #ifdef BUILD_WAYLAND -#include "wl.h" +#include "output/wl.h" #endif /* BUILD_WAYLAND */ #ifdef BUILD_X11 -#include "x11-settings.h" -#include "x11.h" +#include "lua/x11-settings.h" +#include "output/x11.h" #pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Wvariadic-macros" @@ -101,57 +103,57 @@ #endif /* BUILD_RSS */ /* local headers */ -#include "colours.h" +#include "content/colours.hh" #include "core.h" -#include "diskio.h" -#include "exec.h" +#include "data/exec.h" +#include "data/hardware/diskio.h" #ifdef BUILD_GUI -#include "fonts.h" -#include "gui.h" +#include "lua/fonts.h" +#include "output/gui.h" #endif /* BUILD_GUI */ -#include "fs.h" +#include "data/fs.h" #ifdef BUILD_ICONV -#include "iconv_tools.h" +#include "data/iconv_tools.h" #endif /* BUILD_ICONV */ -#include "llua.h" +#include "content/specials.h" +#include "content/temphelper.h" +#include "content/template.h" +#include "data/network/mail.h" +#include "data/network/net_stat.h" +#include "data/timeinfo.h" +#include "data/top.h" #include "logging.h" -#include "mail.h" -#include "nc.h" -#include "net_stat.h" -#include "specials.h" -#include "temphelper.h" -#include "template.h" -#include "timeinfo.h" -#include "top.h" +#include "lua/llua.h" +#include "output/nc.h" #ifdef BUILD_MYSQL -#include "mysql.h" +#include "data/mysql.h" #endif /* BUILD_MYSQL */ #ifdef BUILD_NVIDIA -#include "nvidia.h" +#include "data/hardware/nvidia.h" #endif /* BUILD_NVIDIA */ #ifdef BUILD_CURL -#include "ccurl_thread.h" +#include "data/network/ccurl_thread.h" #endif /* BUILD_CURL */ -#include "display-output.hh" -#include "lua-config.hh" -#include "setting.hh" +#include "lua/lua-config.hh" +#include "lua/setting.hh" +#include "output/display-output.hh" /* check for OS and include appropriate headers */ #if defined(__linux__) -#include "linux.h" +#include "data/os/linux.h" #elif defined(__FreeBSD__) || defined(__FreeBSD_kernel__) -#include "freebsd.h" +#include "data/os/freebsd.h" #elif defined(__DragonFly__) -#include "dragonfly.h" +#include "data/os/dragonfly.h" #elif defined(__OpenBSD__) -#include "openbsd.h" +#include "data/os/openbsd.h" #elif defined(__NetBSD__) -#include "netbsd.h" +#include "data/os/netbsd.h" #endif -#include "gradient.h" +#include "content/gradient.hh" #ifdef BUILD_OLD_CONFIG #include "convertconf.h" @@ -177,6 +179,15 @@ const char builtin_config_magic[] = "==builtin=="; /* debugging level, used by logging.h */ int global_debug_level = 0; +bool strneq(const char *a, const char *b, std::size_t length, + bool ignore_case) { + if (ignore_case) { + return strncasecmp(a, b, length) == 0; + } else { + return strncmp(a, b, length) == 0; + } +} + /* disable inotify auto reload feature if desired */ static conky::simple_config_setting disable_auto_reload( "disable_auto_reload", false, false); diff --git a/src/conky.h b/src/conky.h index efb8633f9e..208cfd442c 100644 --- a/src/conky.h +++ b/src/conky.h @@ -30,6 +30,8 @@ #ifndef _conky_h_ #define _conky_h_ +#include +#include #define __STDC_FORMAT_MACROS #include "config.h" @@ -40,21 +42,36 @@ #include #include #include +#include -#include "colours.h" +#include "content/colours.hh" #include "common.h" /* at least for struct dns_data */ -#include "luamm.hh" +#include "lua/luamm.hh" #if defined(HAS_MCHECK_H) #include #endif /* HAS_MCHECK_H */ -#undef EQUAL -#undef FALSE -#undef TRUE -#define EQUAL 0 // returnvalue of strcmp-variants when strings are equal -#define FALSE 0 -#define TRUE 1 +/** + * @brief Checks whether two strings are equal. + * + * @param a first input. + * @param b second input. + * @param length maximum string length. + * @param ignore_case whether letter case should be ignored when doing the + * comparison. + * @return true if two strings are equal + */ +bool strneq(const char *a, const char *b, std::size_t length, bool ignore_case); +inline bool streq(const char *a, const char *b, bool ignore_case) { + return strneq(a, b, std::numeric_limits::max(), ignore_case); +} +inline bool strneq(const char *a, const char *b, std::size_t length) { + return strneq(a, b, length, false); +} +inline bool streq(const char *a, const char *b) { + return strneq(a, b, std::numeric_limits::max(), false); +} #define DEFAULT_BAR_WIDTH_NO_X 10 @@ -76,35 +93,35 @@ char *strndup(const char *s, size_t n); struct text_object; #ifdef BUILD_HDDTEMP -#include "hddtemp.h" +#include "data/hardware/hddtemp.h" #endif /* BUILD_HDDTEMP */ #ifdef BUILD_MOC -#include "moc.h" +#include "data/audio/moc.h" #endif /* BUILD_MOC */ #ifdef BUILD_MPD -#include "mpd.h" +#include "data/audio/mpd.h" #endif /* BUILD_MPD */ #ifdef BUILD_MYSQL -#include "mysql.h" +#include "data/mysql.h" #endif /* BUILD_MYSQL */ #ifdef BUILD_PORT_MONITORS -#include "tcp-portmon.h" +#include "data/network/tcp-portmon.h" #endif #ifdef BUILD_XMMS2 -#include "xmms2.h" +#include "data/audio/xmms2.h" #endif /* BUILD_XMMS2 */ #ifdef BUILD_APCUPSD -#include "apcupsd.h" +#include "data/hardware/apcupsd.h" #endif /* BUILD_APCUPSD */ /* sony support */ -#include "sony.h" +#include "data/hardware/sony.h" /* A size for temporary, static buffers to use when * one doesn't know what to choose. Defaults to 256. */ diff --git a/src/content/algebra.cc b/src/content/algebra.cc index 58b9a548f9..2b067654a7 100644 --- a/src/content/algebra.cc +++ b/src/content/algebra.cc @@ -33,8 +33,8 @@ #include #include #include "config.h" -#include "conky.h" -#include "logging.h" +#include "../conky.h" +#include "../logging.h" /* find the operand in the given expression * returns the index of the first op character or -1 on error diff --git a/src/content/colour-names-stub.hh b/src/content/colour-names-stub.hh index 7008d07658..1b8f01c321 100644 --- a/src/content/colour-names-stub.hh +++ b/src/content/colour-names-stub.hh @@ -8,7 +8,7 @@ #include -#include "logging.h" +#include "../logging.h" struct rgb { const char *name; diff --git a/src/content/colours.cc b/src/content/colours.cc index 8af0f83c42..b069682e61 100644 --- a/src/content/colours.cc +++ b/src/content/colours.cc @@ -27,9 +27,9 @@ * */ -#include "colours.h" +#include "colours.hh" -#include "logging.h" +#include "../logging.h" #include #include diff --git a/src/content/combine.cc b/src/content/combine.cc index 40ab534b13..67c216c2bc 100644 --- a/src/content/combine.cc +++ b/src/content/combine.cc @@ -29,8 +29,8 @@ #include -#include "core.h" -#include "logging.h" +#include "../core.h" +#include "../logging.h" #include "text_object.h" struct combine_data { diff --git a/src/content/gradient.cc b/src/content/gradient.cc index d646520a5c..cbed22d228 100644 --- a/src/content/gradient.cc +++ b/src/content/gradient.cc @@ -26,10 +26,10 @@ * along with this program. If not, see . * */ -#include "gradient.h" -#include "colours.h" -#include "conky.h" -#include "logging.h" +#include "gradient.hh" +#include "../conky.h" +#include "../logging.h" +#include "colours.hh" namespace conky { gradient_factory::gradient_factory(int width, Colour first_colour, diff --git a/src/content/gradient.hh b/src/content/gradient.hh index f861ba74d7..bf697e8fa6 100644 --- a/src/content/gradient.hh +++ b/src/content/gradient.hh @@ -31,7 +31,7 @@ #define _GRADIENT_H #include -#include "colours.h" +#include "colours.hh" namespace conky { class gradient_factory { diff --git a/src/content/scroll.cc b/src/content/scroll.cc index 0d4065e576..246f09db82 100644 --- a/src/content/scroll.cc +++ b/src/content/scroll.cc @@ -27,11 +27,11 @@ * */ #include -#include "colours.h" -#include "conky.h" -#include "core.h" -#include "display-output.hh" -#include "logging.h" +#include "../conky.h" +#include "../core.h" +#include "../logging.h" +#include "../output/display-output.hh" +#include "colours.hh" #include "specials.h" #include "text_object.h" diff --git a/src/content/specials.cc b/src/content/specials.cc index 1278e711ca..1948640623 100644 --- a/src/content/specials.cc +++ b/src/content/specials.cc @@ -26,14 +26,14 @@ * along with this program. If not, see . * */ -#include "conky.h" +#include "../conky.h" #ifdef BUILD_GUI -#include "fonts.h" -#include "gui.h" +#include "../lua/fonts.h" +#include "../output/gui.h" #endif /* BUILD_GUI */ #include -#include "logging.h" -#include "nc.h" +#include "../logging.h" +#include "../output/nc.h" #include "specials.h" #ifdef HAVE_SYS_PARAM_H #include @@ -41,10 +41,10 @@ #include #include #include -#include "colours.h" -#include "common.h" -#include "conky.h" -#include "display-output.hh" +#include "../common.h" +#include "../conky.h" +#include "../output/display-output.hh" +#include "colours.hh" struct special_node *specials = nullptr; @@ -277,11 +277,11 @@ bool scan_graph(struct text_object *obj, const char *argstr, double defscale, ch g->first_colour = Colour(); g->last_colour = Colour(); g->scale = defscale; - g->tempgrad = FALSE; - g->invertflag = FALSE; + g->tempgrad = false; + g->invertflag = false; g->minheight = 0; if (speedGraph) { - g->speedgraph = TRUE; + g->speedgraph = true; } if (argstr == nullptr) return false; @@ -289,7 +289,7 @@ bool scan_graph(struct text_object *obj, const char *argstr, double defscale, ch * It doesn't matter where the argument is exactly. */ if ((strstr(argstr, " " TEMPGRAD) != nullptr) || strncmp(argstr, TEMPGRAD, strlen(TEMPGRAD)) == 0) { - g->tempgrad = TRUE; + g->tempgrad = true; } /* set showlog flag if '-l' specified. * It doesn't matter where the argument is exactly. */ @@ -697,7 +697,7 @@ void new_graph(struct text_object *obj, char *buf, int buf_max_size, s->inverty = 1; } if (g->speedgraph) { - s->speedgraph = TRUE; + s->speedgraph = true; } if (store_graph_data_explicitly.get(*state)) { diff --git a/src/content/specials.h b/src/content/specials.h index c7a8799ba5..250b49d53f 100644 --- a/src/content/specials.h +++ b/src/content/specials.h @@ -30,7 +30,7 @@ #define _SPECIALS_H #include -#include "colours.h" +#include "colours.hh" /* special stuff in text_buffer */ diff --git a/src/content/temphelper.cc b/src/content/temphelper.cc index 45cb474c36..b37b566b4b 100644 --- a/src/content/temphelper.cc +++ b/src/content/temphelper.cc @@ -27,7 +27,7 @@ #include #include #include "config.h" -#include "conky.h" +#include "../conky.h" template <> conky::lua_traits::Map conky::lua_traits::map = { diff --git a/src/content/template.cc b/src/content/template.cc index 6045fe8dcc..e7a212c69e 100644 --- a/src/content/template.cc +++ b/src/content/template.cc @@ -29,8 +29,8 @@ #include #include #include -#include "conky.h" -#include "logging.h" +#include "../conky.h" +#include "../logging.h" namespace { conky::simple_config_setting _template[10] = { diff --git a/src/content/text_object.cc b/src/content/text_object.cc index 9a34eac028..ecd9b4e619 100644 --- a/src/content/text_object.cc +++ b/src/content/text_object.cc @@ -30,8 +30,8 @@ #include #include #include "config.h" -#include "conky.h" -#include "logging.h" +#include "../conky.h" +#include "../logging.h" void gen_free_opaque(struct text_object *obj) { free_and_zero(obj->data.opaque); diff --git a/src/content/text_object.h b/src/content/text_object.h index b6f3c6d5b6..f2a8087a30 100644 --- a/src/content/text_object.h +++ b/src/content/text_object.h @@ -31,7 +31,7 @@ #include "config.h" -#include "exec.h" +#include "../data/exec.h" #include "specials.h" /* enum special_types */ #include /* uint8_t */ diff --git a/src/core.cc b/src/core.cc index d7aa10b4cc..684098fbb9 100644 --- a/src/core.cc +++ b/src/core.cc @@ -30,100 +30,100 @@ #include "config.h" /* local headers */ -#include "algebra.h" +#include "content/algebra.h" #include "core.h" -#include "bsdapm.h" #include "build.h" -#include "colour-settings.h" -#include "colours.h" -#include "combine.h" -#include "diskio.h" -#include "entropy.h" -#include "exec.h" -#include "i8k.h" -#include "misc.h" -#include "proc.h" -#include "text_object.h" +#include "lua/colour-settings.hh" +#include "content/colours.hh" +#include "content/combine.h" +#include "content/text_object.h" +#include "data/entropy.h" +#include "data/exec.h" +#include "data/hardware/bsdapm.h" +#include "data/hardware/diskio.h" +#include "data/hardware/i8k.h" +#include "data/misc.h" +#include "data/proc.h" #ifdef BUILD_IMLIB2 #include "conky-imlib2.h" #endif /* BUILD_IMLIB2 */ #ifdef BUILD_MYSQL -#include "mysql.h" +#include "data/mysql.h" #endif /* BUILD_MYSQL */ #ifdef BUILD_ICAL -#include "ical.h" +#include "data/ical.h" #endif /* BUILD_ICAL */ #ifdef BUILD_IRC -#include "irc.h" +#include "data/network/irc.h" #endif /* BUILD_IRC */ #ifdef BUILD_GUI -#include "fonts.h" -#include "gui.h" +#include "lua/fonts.h" +#include "output/gui.h" #endif /* BUILD_GUI */ -#include "fs.h" +#include "data/fs.h" #ifdef BUILD_IBM -#include "ibm.h" -#include "smapi.h" +#include "data/hardware/ibm.h" +#include "data/hardware/smapi.h" #endif /* BUILD_IBM */ #ifdef BUILD_ICONV -#include "iconv_tools.h" +#include "data/iconv_tools.h" #endif /* BUILD_ICONV */ -#include "llua.h" +#include "data/audio/mixer.h" +#include "data/network/mail.h" +#include "data/network/mboxscan.h" +#include "data/network/net_stat.h" #include "logging.h" -#include "mail.h" -#include "mboxscan.h" -#include "mixer.h" -#include "nc.h" -#include "net_stat.h" +#include "lua/llua.h" +#include "output/nc.h" #ifdef BUILD_NVIDIA -#include "nvidia.h" +#include "data/hardware/nvidia.h" #endif /* BUILD_NVIDIA */ #include -#include "cpu.h" -#include "read_tcpip.h" -#include "scroll.h" -#include "specials.h" -#include "tailhead.h" -#include "temphelper.h" -#include "template.h" -#include "timeinfo.h" -#include "top.h" -#include "user.h" -#include "users.h" +#include "content/scroll.h" +#include "content/specials.h" +#include "content/temphelper.h" +#include "content/template.h" +#include "data/hardware/cpu.h" +#include "data/network/read_tcpip.h" +#include "data/tailhead.h" +#include "data/timeinfo.h" +#include "data/top.h" +#include "data/user.h" +#include "data/users.h" #ifdef BUILD_CURL -#include "ccurl_thread.h" +#include "data/network/ccurl_thread.h" #endif /* BUILD_CURL */ #ifdef BUILD_RSS -#include "rss.h" +#include "data/network/rss.h" #endif /* BUILD_RSS */ #ifdef BUILD_AUDACIOUS -#include "audacious.h" +#include "data/audio/audacious.h" #endif /* BUILD_AUDACIOUS */ #ifdef BUILD_CMUS -#include "cmus.h" +#include "data/audio/cmus.h" #endif /* BUILD_CMUS */ #ifdef BUILD_JOURNAL -#include "journal.h" +#include "data/os/journal.h" #endif /* BUILD_JOURNAL */ #ifdef BUILD_PULSEAUDIO -#include "pulseaudio.h" +#include "data/audio/pulseaudio.h" #endif /* BUILD_PULSEAUDIO */ #ifdef BUILD_INTEL_BACKLIGHT -#include "intel_backlight.h" +#include "data/hardware/intel_backlight.h" #endif /* BUILD_INTEL_BACKLIGHT */ /* check for OS and include appropriate headers */ #if defined(__linux__) -#include "linux.h" +#include "data/os/linux.h" #elif defined(__FreeBSD__) || defined(__FreeBSD_kernel__) -#include "freebsd.h" +#include "data/os/freebsd.h" #elif defined(__DragonFly__) -#include "dragonfly.h" +#include "data/os/dragonfly.h" #elif defined(__OpenBSD__) -#include "openbsd.h" +#include "data/os/openbsd.h" #elif defined(__APPLE__) && defined(__MACH__) -#include "darwin.h" +#include "data/os/darwin.h" #endif #define STRNDUP_ARG strndup(arg ? arg : "", text_buffer_size.get(*state)) @@ -371,6 +371,7 @@ legacy_cb_handle *create_cb_handle(int (*fn)()) { { return nullptr; } } +// clang-format off /* construct_text_object() creates a new text_object */ struct text_object *construct_text_object(char *s, const char *arg, long line, void **ifblock_opaque, @@ -382,7 +383,7 @@ struct text_object *construct_text_object(char *s, const char *arg, long line, /* helper defines for internal use only */ #define __OBJ_HEAD(a, n) \ - if (!strcmp(s, #a)) { \ + if (streq(s, #a)) { \ obj->cb_handle = create_cb_handle(n); #define __OBJ_IF obj_be_ifblock_if(ifblock_opaque, obj) #define __OBJ_ARG(...) \ @@ -654,18 +655,12 @@ struct text_object *construct_text_object(char *s, const char *arg, long line, obj->callbacks.print = &print_ioscheduler; obj->callbacks.free = &gen_free_opaque; END OBJ(laptop_mode, 0) obj->callbacks.print = &print_laptop_mode; - END OBJ_ARG( - pb_battery, 0, - "pb_battery: needs one argument: status, percent or time") if (strcmp(arg, - "st" - "at" - "u" - "s") == - EQUAL) { + END OBJ_ARG(pb_battery, 0, "pb_battery: needs one argument: status, percent or time") + if (streq(arg, "status")) { obj->data.i = PB_BATT_STATUS; } - else if (strcmp(arg, "percent") == EQUAL) { obj->data.i = PB_BATT_PERCENT; } - else if (strcmp(arg, "time") == EQUAL) { obj->data.i = PB_BATT_TIME; } + else if (streq(arg, "percent")) { obj->data.i = PB_BATT_PERCENT; } + else if (streq(arg, "time")) { obj->data.i = PB_BATT_TIME; } else { NORM_ERR("pb_battery: illegal argument '%s', defaulting to status", arg); obj->data.i = PB_BATT_STATUS; @@ -730,7 +725,7 @@ struct text_object *construct_text_object(char *s, const char *arg, long line, #ifdef BUILD_GUI END OBJ(cpugraph, &update_cpu_usage) get_cpu_count(); SCAN_CPU(arg, obj->data.i); - scan_graph(obj, arg, 1, FALSE); + scan_graph(obj, arg, 1, false); DBGP2("Adding $cpugraph for CPU %d", obj->data.i); obj->callbacks.graphval = &cpu_barval; obj->callbacks.free = &free_cpu; @@ -1058,7 +1053,7 @@ struct text_object *construct_text_object(char *s, const char *arg, long line, * special handler. */ /* XXX: maybe fiddle them apart later, as print_top() does * nothing else than just that, using an ugly switch(). */ - if (strncmp(s, "top", 3) == EQUAL) { + if (strneq(s, "top", 3)) { if (parse_top_args(s, arg, obj) != 0) { obj->cb_handle = create_cb_handle(update_top); } else { @@ -1242,9 +1237,9 @@ struct text_object *construct_text_object(char *s, const char *arg, long line, END OBJ(memwithbuffersbar, &update_meminfo) scan_bar(obj, arg, 1); obj->callbacks.barval = &mem_with_buffers_barval; #ifdef BUILD_GUI - END OBJ(memgraph, &update_meminfo) scan_graph(obj, arg, 1, FALSE); + END OBJ(memgraph, &update_meminfo) scan_graph(obj, arg, 1, false); obj->callbacks.graphval = &mem_barval; - END OBJ(memwithbuffersgraph, &update_meminfo) scan_graph(obj, arg, 1, FALSE); + END OBJ(memwithbuffersgraph, &update_meminfo) scan_graph(obj, arg, 1, false); obj->callbacks.graphval = &mem_with_buffers_barval; #endif /* BUILD_GUI*/ #ifdef HAVE_SOUNDCARD_H @@ -1826,7 +1821,7 @@ struct text_object *construct_text_object(char *s, const char *arg, long line, "lua_graph needs arguments: [height],[width] [gradient " "colour 1] [gradient colour 2] [scale] [-t] [-l]") auto [buf, skip] = scan_command(arg); - scan_graph(obj, arg + skip, 100, FALSE); + scan_graph(obj, arg + skip, 100, false); if (buf != nullptr) { obj->data.s = buf; } else { @@ -1969,7 +1964,7 @@ struct text_object *construct_text_object(char *s, const char *arg, long line, END OBJ(apcupsd_loadbar, &update_apcupsd) scan_bar(obj, arg, 100); obj->callbacks.barval = &apcupsd_loadbarval; #ifdef BUILD_GUI - END OBJ(apcupsd_loadgraph, &update_apcupsd) scan_graph(obj, arg, 100, FALSE); + END OBJ(apcupsd_loadgraph, &update_apcupsd) scan_graph(obj, arg, 100, false); obj->callbacks.graphval = &apcupsd_loadbarval; END OBJ(apcupsd_loadgauge, &update_apcupsd) scan_gauge(obj, arg, 100); obj->callbacks.gaugeval = &apcupsd_loadbarval; @@ -2051,6 +2046,7 @@ struct text_object *construct_text_object(char *s, const char *arg, long line, return obj; } +// clang-format on /* * - assumes that *string is '#' @@ -2102,7 +2098,7 @@ int extract_variable_text_internal(struct text_object *retval, } s = orig_p = p; - if (static_cast(strcmp(p, const_p) != 0) != 0) { + if (!streq(p, const_p)) { DBGP2("replaced all templates in text: input is\n'%s'\noutput is\n'%s'", const_p, p); } else { diff --git a/src/data/audio/audacious.cc b/src/data/audio/audacious.cc index cb99d7d4ba..b3dc3d9e34 100644 --- a/src/data/audio/audacious.cc +++ b/src/data/audio/audacious.cc @@ -27,9 +27,9 @@ #include #include "audacious.h" -#include "conky.h" -#include "logging.h" -#include "update-cb.hh" +#include "../../conky.h" +#include "../../logging.h" +#include "../../update-cb.hh" #include #ifdef NEW_AUDACIOUS_FOUND diff --git a/src/data/audio/cmus.cc b/src/data/audio/cmus.cc index 1b78d20959..61ce401854 100644 --- a/src/data/audio/cmus.cc +++ b/src/data/audio/cmus.cc @@ -20,9 +20,9 @@ * */ -#include "conky.h" -#include "logging.h" -#include "text_object.h" +#include "../../conky.h" +#include "../../logging.h" +#include "../../content/text_object.h" #include #include @@ -31,7 +31,7 @@ #include #include -#include "update-cb.hh" +#include "../../update-cb.hh" namespace { struct cmus_result { diff --git a/src/data/audio/libmpdclient.cc b/src/data/audio/libmpdclient.cc index c7060b77e0..a0050614e9 100644 --- a/src/data/audio/libmpdclient.cc +++ b/src/data/audio/libmpdclient.cc @@ -34,7 +34,7 @@ */ #include "libmpdclient.h" -#include "conky.h" +#include "../../conky.h" #include #include @@ -597,7 +597,7 @@ static void mpd_getNextReturnElement(mpd_Connection *connection) { output = connection->buffer + connection->bufstart; connection->bufstart = rt - connection->buffer + 1; - if (strcmp(output, "OK") == 0) { + if (streq(output, "OK")) { if (connection->listOks > 0) { strncpy(connection->errorStr, "expected more list_OK's", MPD_ERRORSTR_MAX_LENGTH); @@ -609,7 +609,7 @@ static void mpd_getNextReturnElement(mpd_Connection *connection) { return; } - if (strcmp(output, "list_OK") == 0) { + if (streq(output, "list_OK")) { if (connection->listOks == 0) { strncpy(connection->errorStr, "got an unexpected list_OK", MPD_ERRORSTR_MAX_LENGTH); @@ -730,33 +730,33 @@ mpd_Status *mpd_getStatus(mpd_Connection *connection) { while (connection->returnElement != nullptr) { mpd_ReturnElement *re = connection->returnElement; - if (strcmp(re->name, "volume") == 0) { + if (streq(re->name, "volume")) { status->volume = strtol(re->value, nullptr, 10); - } else if (strcmp(re->name, "repeat") == 0) { + } else if (streq(re->name, "repeat")) { status->repeat = strtol(re->value, nullptr, 10); - } else if (strcmp(re->name, "random") == 0) { + } else if (streq(re->name, "random")) { status->random = strtol(re->value, nullptr, 10); - } else if (strcmp(re->name, "playlist") == 0) { + } else if (streq(re->name, "playlist")) { status->playlist = strtol(re->value, nullptr, 10); - } else if (strcmp(re->name, "playlistlength") == 0) { + } else if (streq(re->name, "playlistlength")) { status->playlistLength = strtol(re->value, nullptr, 10); - } else if (strcmp(re->name, "bitrate") == 0) { + } else if (streq(re->name, "bitrate")) { status->bitRate = strtol(re->value, nullptr, 10); - } else if (strcmp(re->name, "state") == 0) { - if (strcmp(re->value, "play") == 0) { + } else if (streq(re->name, "state")) { + if (streq(re->value, "play")) { status->state = MPD_STATUS_STATE_PLAY; - } else if (strcmp(re->value, "stop") == 0) { + } else if (streq(re->value, "stop")) { status->state = MPD_STATUS_STATE_STOP; - } else if (strcmp(re->value, "pause") == 0) { + } else if (streq(re->value, "pause")) { status->state = MPD_STATUS_STATE_PAUSE; } else { status->state = MPD_STATUS_STATE_UNKNOWN; } - } else if (strcmp(re->name, "song") == 0) { + } else if (streq(re->name, "song")) { status->song = strtol(re->value, nullptr, 10); - } else if (strcmp(re->name, "songid") == 0) { + } else if (streq(re->name, "songid")) { status->songid = strtol(re->value, nullptr, 10); - } else if (strcmp(re->name, "time") == 0) { + } else if (streq(re->name, "time")) { char *tok = strchr(re->value, ':'); /* the second strchr below is a safety check */ @@ -765,13 +765,13 @@ mpd_Status *mpd_getStatus(mpd_Connection *connection) { status->elapsedTime = strtol(re->value, nullptr, 10); status->totalTime = strtol(tok + 1, nullptr, 10); } - } else if (strcmp(re->name, "error") == 0) { + } else if (streq(re->name, "error")) { status->error = strndup(re->value, text_buffer_size.get(*state)); - } else if (strcmp(re->name, "xfade") == 0) { + } else if (streq(re->name, "xfade")) { status->crossfade = strtol(re->value, nullptr, 10); - } else if (strcmp(re->name, "updating_db") == 0) { + } else if (streq(re->name, "updating_db")) { status->updatingDb = strtol(re->value, nullptr, 10); - } else if (strcmp(re->name, "audio") == 0) { + } else if (streq(re->name, "audio")) { char *tok = strchr(re->value, ':'); if ((tok != nullptr) && (strchr(tok, 0) > (tok + 1))) { @@ -847,19 +847,19 @@ mpd_Stats *mpd_getStats(mpd_Connection *connection) { while (connection->returnElement != nullptr) { mpd_ReturnElement *re = connection->returnElement; - if (strcmp(re->name, "artists") == 0) { + if (streq(re->name, "artists")) { stats->numberOfArtists = strtol(re->value, nullptr, 10); - } else if (strcmp(re->name, "albums") == 0) { + } else if (streq(re->name, "albums")) { stats->numberOfAlbums = strtol(re->value, nullptr, 10); - } else if (strcmp(re->name, "songs") == 0) { + } else if (streq(re->name, "songs")) { stats->numberOfSongs = strtol(re->value, nullptr, 10); - } else if (strcmp(re->name, "uptime") == 0) { + } else if (streq(re->name, "uptime")) { stats->uptime = strtol(re->value, nullptr, 10); - } else if (strcmp(re->name, "db_update") == 0) { + } else if (streq(re->name, "db_update")) { stats->dbUpdateTime = strtol(re->value, nullptr, 10); - } else if (strcmp(re->name, "playtime") == 0) { + } else if (streq(re->name, "playtime")) { stats->playTime = strtol(re->value, nullptr, 10); - } else if (strcmp(re->name, "db_playtime") == 0) { + } else if (streq(re->name, "db_playtime")) { stats->dbPlayTime = strtol(re->value, nullptr, 10); } @@ -902,9 +902,9 @@ mpd_SearchStats *mpd_getSearchStats(mpd_Connection *connection) { while (connection->returnElement != nullptr) { re = connection->returnElement; - if (strcmp(re->name, "songs") == 0) { + if (streq(re->name, "songs")) { stats->numberOfSongs = strtol(re->value, nullptr, 10); - } else if (strcmp(re->name, "playtime") == 0) { + } else if (streq(re->name, "playtime")) { stats->playTime = strtol(re->value, nullptr, 10); } @@ -1130,25 +1130,25 @@ mpd_InfoEntity *mpd_getNextInfoEntity(mpd_Connection *connection) { } if (connection->returnElement != nullptr) { - if (strcmp(connection->returnElement->name, "file") == 0) { + if (streq(connection->returnElement->name, "file")) { entity = mpd_newInfoEntity(); entity->type = MPD_INFO_ENTITY_TYPE_SONG; entity->info.song = mpd_newSong(); entity->info.song->file = strndup(connection->returnElement->value, text_buffer_size.get(*state)); - } else if (strcmp(connection->returnElement->name, "directory") == 0) { + } else if (streq(connection->returnElement->name, "directory")) { entity = mpd_newInfoEntity(); entity->type = MPD_INFO_ENTITY_TYPE_DIRECTORY; entity->info.directory = mpd_newDirectory(); entity->info.directory->path = strndup(connection->returnElement->value, text_buffer_size.get(*state)); - } else if (strcmp(connection->returnElement->name, "playlist") == 0) { + } else if (streq(connection->returnElement->name, "playlist")) { entity = mpd_newInfoEntity(); entity->type = MPD_INFO_ENTITY_TYPE_PLAYLISTFILE; entity->info.playlistFile = mpd_newPlaylistFile(); entity->info.playlistFile->path = strndup( connection->returnElement->value, text_buffer_size.get(*state)); - } else if (strcmp(connection->returnElement->name, "cpos") == 0) { + } else if (streq(connection->returnElement->name, "cpos")) { entity = mpd_newInfoEntity(); entity->type = MPD_INFO_ENTITY_TYPE_SONG; entity->info.song = mpd_newSong(); @@ -1168,68 +1168,68 @@ mpd_InfoEntity *mpd_getNextInfoEntity(mpd_Connection *connection) { while (connection->returnElement != nullptr) { mpd_ReturnElement *re = connection->returnElement; - if (strcmp(re->name, "file") == 0) { return entity; } - if (strcmp(re->name, "directory") == 0) { return entity; } - if (strcmp(re->name, "playlist") == 0) { return entity; } - if (strcmp(re->name, "cpos") == 0) { return entity; } + if (streq(re->name, "file")) { return entity; } + if (streq(re->name, "directory")) { return entity; } + if (streq(re->name, "playlist")) { return entity; } + if (streq(re->name, "cpos")) { return entity; } if (entity->type == MPD_INFO_ENTITY_TYPE_SONG && (strlen(re->value) != 0u)) { if ((entity->info.song->artist == nullptr) && - strcmp(re->name, "Artist") == 0) { + streq(re->name, "Artist")) { entity->info.song->artist = strndup(re->value, text_buffer_size.get(*state)); } else if ((entity->info.song->albumartist == nullptr) && - strcmp(re->name, "AlbumArtist") == 0) { + streq(re->name, "AlbumArtist")) { entity->info.song->albumartist = strndup(re->value, text_buffer_size.get(*state)); } else if ((entity->info.song->album == nullptr) && - strcmp(re->name, "Album") == 0) { + streq(re->name, "Album")) { entity->info.song->album = strndup(re->value, text_buffer_size.get(*state)); } else if ((entity->info.song->title == nullptr) && - strcmp(re->name, "Title") == 0) { + streq(re->name, "Title")) { entity->info.song->title = strndup(re->value, text_buffer_size.get(*state)); } else if ((entity->info.song->track == nullptr) && - strcmp(re->name, "Track") == 0) { + streq(re->name, "Track")) { entity->info.song->track = strndup(re->value, text_buffer_size.get(*state)); } else if ((entity->info.song->name == nullptr) && - strcmp(re->name, "Name") == 0) { + streq(re->name, "Name")) { entity->info.song->name = strndup(re->value, text_buffer_size.get(*state)); } else if (entity->info.song->time == MPD_SONG_NO_TIME && - strcmp(re->name, "Time") == 0) { + streq(re->name, "Time")) { entity->info.song->time = strtol(re->value, nullptr, 10); } else if (entity->info.song->pos == MPD_SONG_NO_NUM && - strcmp(re->name, "Pos") == 0) { + streq(re->name, "Pos")) { entity->info.song->pos = strtol(re->value, nullptr, 10); } else if (entity->info.song->id == MPD_SONG_NO_ID && - strcmp(re->name, "Id") == 0) { + streq(re->name, "Id")) { entity->info.song->id = strtol(re->value, nullptr, 10); } else if ((entity->info.song->date == nullptr) && - strcmp(re->name, "Date") == 0) { + streq(re->name, "Date")) { entity->info.song->date = strndup(re->value, text_buffer_size.get(*state)); } else if ((entity->info.song->genre == nullptr) && - strcmp(re->name, "Genre") == 0) { + streq(re->name, "Genre")) { entity->info.song->genre = strndup(re->value, text_buffer_size.get(*state)); } else if ((entity->info.song->composer == nullptr) && - strcmp(re->name, "Composer") == 0) { + streq(re->name, "Composer")) { entity->info.song->composer = strndup(re->value, text_buffer_size.get(*state)); } else if ((entity->info.song->performer == nullptr) && - strcmp(re->name, "Performer") == 0) { + streq(re->name, "Performer")) { entity->info.song->performer = strndup(re->value, text_buffer_size.get(*state)); } else if ((entity->info.song->disc == nullptr) && - strcmp(re->name, "Disc") == 0) { + streq(re->name, "Disc")) { entity->info.song->disc = strndup(re->value, text_buffer_size.get(*state)); } else if ((entity->info.song->comment == nullptr) && - strcmp(re->name, "Comment") == 0) { + streq(re->name, "Comment")) { entity->info.song->comment = strndup(re->value, text_buffer_size.get(*state)); } @@ -1254,7 +1254,7 @@ static char *mpd_getNextReturnElementNamed(mpd_Connection *connection, while (connection->returnElement != nullptr) { mpd_ReturnElement *re = connection->returnElement; - if (strcmp(re->name, name) == 0) { + if (streq(re->name, name)) { return strndup(re->value, text_buffer_size.get(*state)); } mpd_getNextReturnElement(connection); @@ -1739,12 +1739,12 @@ mpd_OutputEntity *mpd_getNextOutput(mpd_Connection *connection) { while (connection->returnElement != nullptr) { mpd_ReturnElement *re = connection->returnElement; - if (strcmp(re->name, "outputid") == 0) { + if (streq(re->name, "outputid")) { if (output != nullptr && output->id >= 0) { return output; } output->id = strtol(re->value, nullptr, 10); - } else if (strcmp(re->name, "outputname") == 0) { + } else if (streq(re->name, "outputname")) { output->name = strndup(re->value, text_buffer_size.get(*state)); - } else if (strcmp(re->name, "outputenabled") == 0) { + } else if (streq(re->name, "outputenabled")) { output->enabled = strtol(re->value, nullptr, 10); } diff --git a/src/data/audio/mixer.cc b/src/data/audio/mixer.cc index 6dad8dec26..ca59a10f55 100644 --- a/src/data/audio/mixer.cc +++ b/src/data/audio/mixer.cc @@ -31,10 +31,10 @@ #include #include #include -#include "conky.h" -#include "logging.h" -#include "specials.h" -#include "text_object.h" +#include "../../conky.h" +#include "../../logging.h" +#include "../../content/specials.h" +#include "../../content/text_object.h" #ifdef HAVE_SOUNDCARD_H #if defined(__linux__) diff --git a/src/data/audio/moc.cc b/src/data/audio/moc.cc index 1804bb248c..065a0a5a72 100644 --- a/src/data/audio/moc.cc +++ b/src/data/audio/moc.cc @@ -20,9 +20,9 @@ * */ -#include "conky.h" -#include "logging.h" -#include "text_object.h" +#include "../../conky.h" +#include "../../logging.h" +#include "../../content/text_object.h" #include #include @@ -30,7 +30,7 @@ #include #include -#include "update-cb.hh" +#include "../../update-cb.hh" namespace { struct moc_result { diff --git a/src/data/audio/mpd.cc b/src/data/audio/mpd.cc index 478f7a5bc9..251a7fdfa2 100644 --- a/src/data/audio/mpd.cc +++ b/src/data/audio/mpd.cc @@ -29,11 +29,11 @@ #include "mpd.h" #include #include -#include "conky.h" +#include "../../conky.h" #include "libmpdclient.h" -#include "logging.h" -#include "timeinfo.h" -#include "update-cb.hh" +#include "../../logging.h" +#include "../timeinfo.h" +#include "../../update-cb.hh" namespace { diff --git a/src/data/audio/pulseaudio.cc b/src/data/audio/pulseaudio.cc index 0869ed0abf..431b8e5e14 100644 --- a/src/data/audio/pulseaudio.cc +++ b/src/data/audio/pulseaudio.cc @@ -30,13 +30,13 @@ #include "pulseaudio.h" #include #include -#include "common.h" +#include "../../common.h" #include "config.h" -#include "conky.h" -#include "core.h" -#include "logging.h" -#include "specials.h" -#include "text_object.h" +#include "../../conky.h" +#include "../../core.h" +#include "../../logging.h" +#include "../../content/specials.h" +#include "../../content/text_object.h" struct pulseaudio_default_results get_result_copy(); diff --git a/src/data/audio/pulseaudio.h b/src/data/audio/pulseaudio.h index 9df07ae05a..213774e71a 100644 --- a/src/data/audio/pulseaudio.h +++ b/src/data/audio/pulseaudio.h @@ -32,7 +32,7 @@ #include #include -#include "text_object.h" +#include "../../content/text_object.h" void init_pulseaudio(struct text_object *obj); void free_pulseaudio(struct text_object *obj); diff --git a/src/data/audio/xmms2.cc b/src/data/audio/xmms2.cc index 69af7c1011..89733ba5af 100644 --- a/src/data/audio/xmms2.cc +++ b/src/data/audio/xmms2.cc @@ -26,7 +26,7 @@ * */ -#include "conky.h" +#include "../../conky.h" xmmsc_connection_t *xmms2_conn; @@ -120,7 +120,7 @@ int handle_curent_id(xmmsv_t *value, void *p) { if (xmmsv_get_error(value, &errbuf)) { fprintf(stderr, "XMMS2 server error. %s\n", errbuf); - return TRUE; + return true; } if (xmmsv_get_int(value, ¤t_id) && current_id > 0) { @@ -130,7 +130,7 @@ int handle_curent_id(xmmsv_t *value, void *p) { if (xmmsv_get_error(val, &errbuf)) { fprintf(stderr, "XMMS2 server error. %s\n", errbuf); - return TRUE; + return true; } xmms_alloc(ptr); @@ -190,7 +190,7 @@ int handle_curent_id(xmmsv_t *value, void *p) { xmmsv_unref(infos); xmmsc_result_unref(res); } - return TRUE; + return true; } int handle_playtime(xmmsv_t *value, void *p) { @@ -200,7 +200,7 @@ int handle_playtime(xmmsv_t *value, void *p) { if (xmmsv_get_error(value, &errbuf)) { fprintf(stderr, "XMMS2 server error. %s\n", errbuf); - return TRUE; + return true; } if (xmmsv_get_int(value, &play_time)) { @@ -209,7 +209,7 @@ int handle_playtime(xmmsv_t *value, void *p) { ptr->xmms2.percent = (int)(ptr->xmms2.progress * 100); } - return TRUE; + return true; } int handle_playback_state_change(xmmsv_t *value, void *p) { @@ -219,7 +219,7 @@ int handle_playback_state_change(xmmsv_t *value, void *p) { if (xmmsv_get_error(value, &errbuf)) { fprintf(stderr, "XMMS2 server error. %s\n", errbuf); - return TRUE; + return true; } if (ptr->xmms2.status == nullptr) { @@ -243,7 +243,7 @@ int handle_playback_state_change(xmmsv_t *value, void *p) { strncpy(ptr->xmms2.status, "Unknown", text_buffer_size.get(*state) - 1); } } - return TRUE; + return true; } int handle_playlist_loaded(xmmsv_t *value, void *p) { @@ -252,7 +252,7 @@ int handle_playlist_loaded(xmmsv_t *value, void *p) { if (xmmsv_get_error(value, &errbuf)) { fprintf(stderr, "XMMS2 server error. %s\n", errbuf); - return TRUE; + return true; } if (ptr->xmms2.playlist == nullptr) { @@ -263,7 +263,7 @@ int handle_playlist_loaded(xmmsv_t *value, void *p) { if (xmmsv_get_string(value, &c)) { strncpy(ptr->xmms2.playlist, c, text_buffer_size.get(*state) - 1); } - return TRUE; + return true; } int handle_medialib_changed(xmmsv_t *value, void *p) { @@ -273,7 +273,7 @@ int handle_medialib_changed(xmmsv_t *value, void *p) { if (xmmsv_get_error(value, &errbuf)) { fprintf(stderr, "XMMS2 server error. %s\n", errbuf); - return TRUE; + return true; } if (xmmsv_get_int(value, ¤t_id) && current_id > 0 && @@ -281,7 +281,7 @@ int handle_medialib_changed(xmmsv_t *value, void *p) { return handle_curent_id(value, ptr); } - return TRUE; + return true; } int update_xmms2(void) { diff --git a/src/data/data-source.hh b/src/data/data-source.hh index cdc6a739be..861839bac6 100644 --- a/src/data/data-source.hh +++ b/src/data/data-source.hh @@ -27,7 +27,7 @@ #include #include -#include "luamm.hh" +#include "../lua/luamm.hh" namespace conky { diff --git a/src/data/entropy.cc b/src/data/entropy.cc index e0711864b9..1e9c1595ea 100644 --- a/src/data/entropy.cc +++ b/src/data/entropy.cc @@ -30,26 +30,26 @@ #include #include #include "config.h" -#include "conky.h" -#include "text_object.h" +#include "../conky.h" +#include "../content/text_object.h" /* check for OS and include appropriate headers */ #if defined(__linux__) -#include "linux.h" +#include "os/linux.h" #elif defined(__FreeBSD__) || defined(__FreeBSD_kernel__) -#include "freebsd.h" +#include "os/freebsd.h" #elif defined(__DragonFly__) -#include "dragonfly.h" +#include "os/dragonfly.h" #elif defined(__OpenBSD__) -#include "openbsd.h" +#include "os/openbsd.h" #elif defined(__NetBSD__) -#include "netbsd.h" +#include "os/netbsd.h" #elif defined(__sun) -#include "solaris.h" +#include "os/solaris.h" #elif defined(__HAIKU__) -#include "haiku.h" +#include "os/haiku.h" #elif defined(__APPLE__) && defined(__MACH__) -#include "darwin.h" +#include "os/darwin.h" #endif struct _entropy { diff --git a/src/data/exec.cc b/src/data/exec.cc index 81cf486cfe..97b3ebeed3 100644 --- a/src/data/exec.cc +++ b/src/data/exec.cc @@ -35,12 +35,12 @@ #include #include #include -#include "conky.h" -#include "core.h" -#include "logging.h" -#include "specials.h" -#include "text_object.h" -#include "update-cb.hh" +#include "../conky.h" +#include "../core.h" +#include "../logging.h" +#include "../content/specials.h" +#include "../content/text_object.h" +#include "../update-cb.hh" struct execi_data { float interval{0}; @@ -88,11 +88,11 @@ static FILE *pid_popen(const char *command, const char *mode, pid_t *child) { // by running pipe after the strcmp's we make sure that we don't have to // create a pipe and close the ends if mode is something illegal - if (strcmp(mode, "r") == 0) { + if (streq(mode, "r")) { if (pipe(ends) != 0) { return nullptr; } parentend = ends[0]; childend = ends[1]; - } else if (strcmp(mode, "w") == 0) { + } else if (streq(mode, "w")) { if (pipe(ends) != 0) { return nullptr; } parentend = ends[1]; childend = ends[0]; @@ -275,7 +275,7 @@ void scan_exec_arg(struct text_object *obj, const char *arg, cmd = scan_gauge(obj, cmd, 100); } else if ((execflag & EF_GRAPH) != 0u) { auto [buf, skip] = scan_command(cmd); - scan_graph(obj, cmd + skip, 100, FALSE); + scan_graph(obj, cmd + skip, 100, false); cmd = buf; if (cmd == nullptr) { NORM_ERR("error parsing arguments to execgraph object"); diff --git a/src/data/exec.h b/src/data/exec.h index 4b045dbd72..478130a4b3 100644 --- a/src/data/exec.h +++ b/src/data/exec.h @@ -30,7 +30,7 @@ #ifndef _EXEC_H #define _EXEC_H -#include "update-cb.hh" +#include "../update-cb.hh" /** * A callback that executes a command and stores the output as a std::string. diff --git a/src/data/fs.cc b/src/data/fs.cc index c3850537ee..9d024e50e6 100644 --- a/src/data/fs.cc +++ b/src/data/fs.cc @@ -33,10 +33,10 @@ #include #include #include -#include "conky.h" -#include "logging.h" -#include "specials.h" -#include "text_object.h" +#include "../conky.h" +#include "../logging.h" +#include "../content/specials.h" +#include "../content/text_object.h" #ifdef HAVE_SYS_STATFS_H #include @@ -48,17 +48,17 @@ #endif #if defined(__FreeBSD__) -#include "freebsd.h" +#include "os/freebsd.h" #elif defined(__OpenBSD__) -#include "openbsd.h" +#include "os/openbsd.h" #elif defined(__DragonFly__) -#include "dragonfly.h" +#include "os/dragonfly.h" #elif defined(__NetBSD__) -#include "netbsd.h" +#include "os/netbsd.h" #elif defined(__HAIKU__) -#include "haiku.h" +#include "os/haiku.h" #elif defined(__APPLE__) && defined(__MACH__) -#include "darwin.h" +#include "os/darwin.h" #endif #if !defined(HAVE_STRUCT_STATFS_F_FSTYPENAME) && !defined(__OpenBSD__) && \ diff --git a/src/data/fs.h b/src/data/fs.h index 41d3a4d33f..431a4dcbdc 100644 --- a/src/data/fs.h +++ b/src/data/fs.h @@ -30,7 +30,7 @@ #ifndef _FS_H #define _FS_H -#include "conky.h" /* DEFAULT_TEXT_BUFFER_SIZE */ +#include "../conky.h" /* DEFAULT_TEXT_BUFFER_SIZE */ /* needed here and by fs.c */ struct fs_stat { diff --git a/src/data/hardware/apcupsd.cc b/src/data/hardware/apcupsd.cc index 0c739be81d..fd825c0aee 100644 --- a/src/data/hardware/apcupsd.cc +++ b/src/data/hardware/apcupsd.cc @@ -22,9 +22,9 @@ */ #include "apcupsd.h" -#include "conky.h" -#include "logging.h" -#include "text_object.h" +#include "../../conky.h" +#include "../../logging.h" +#include "../../content/text_object.h" #include #include @@ -157,17 +157,17 @@ static int fill_items(int sock, PAPCUPSD_S apc) { int len; while ((len = get_line(sock, line, sizeof(line))) != 0) { // fill the right types in - FILL("UPSNAME", APCUPSD_NAME, FALSE); - FILL("MODEL", APCUPSD_MODEL, FALSE); - FILL("UPSMODE", APCUPSD_UPSMODE, FALSE); - FILL("CABLE", APCUPSD_CABLE, FALSE); - FILL("STATUS", APCUPSD_STATUS, TRUE); - FILL("LINEV", APCUPSD_LINEV, TRUE); - FILL("LOADPCT", APCUPSD_LOAD, TRUE); - FILL("BCHARGE", APCUPSD_CHARGE, TRUE); - FILL("TIMELEFT", APCUPSD_TIMELEFT, TRUE); - FILL("ITEMP", APCUPSD_TEMP, TRUE); - FILL("LASTXFER", APCUPSD_LASTXFER, FALSE); + FILL("UPSNAME", APCUPSD_NAME, false); + FILL("MODEL", APCUPSD_MODEL, false); + FILL("UPSMODE", APCUPSD_UPSMODE, false); + FILL("CABLE", APCUPSD_CABLE, false); + FILL("STATUS", APCUPSD_STATUS, true); + FILL("LINEV", APCUPSD_LINEV, true); + FILL("LOADPCT", APCUPSD_LOAD, true); + FILL("BCHARGE", APCUPSD_CHARGE, true); + FILL("TIMELEFT", APCUPSD_TIMELEFT, true); + FILL("ITEMP", APCUPSD_TEMP, true); + FILL("LASTXFER", APCUPSD_LASTXFER, false); } return static_cast(len == 0); diff --git a/src/data/hardware/bsdapm.cc b/src/data/hardware/bsdapm.cc index 7891df23b7..99013a5dea 100644 --- a/src/data/hardware/bsdapm.cc +++ b/src/data/hardware/bsdapm.cc @@ -31,8 +31,8 @@ #include #include "config.h" -#include "conky.h" -#include "text_object.h" +#include "../../conky.h" +#include "../../content/text_object.h" #if defined(__OpenBSD__) #include diff --git a/src/data/hardware/cpu.cc b/src/data/hardware/cpu.cc index f2548d9e92..2d15c1af42 100644 --- a/src/data/hardware/cpu.cc +++ b/src/data/hardware/cpu.cc @@ -34,8 +34,8 @@ #include #include #include "config.h" -#include "conky.h" -#include "text_object.h" +#include "../../conky.h" +#include "../../content/text_object.h" #ifdef __x86_64__ #define CPU_FEATURE(x, z) __asm__ __volatile__("cpuid" : "=a"(z) : "a"(x)) diff --git a/src/data/hardware/diskio.cc b/src/data/hardware/diskio.cc index 130ff45c50..11cb2f694e 100644 --- a/src/data/hardware/diskio.cc +++ b/src/data/hardware/diskio.cc @@ -31,13 +31,13 @@ #include #include #include -#include "common.h" +#include "../../common.h" #include "config.h" -#include "conky.h" /* text_buffer_size */ -#include "core.h" -#include "logging.h" -#include "specials.h" -#include "text_object.h" +#include "../../conky.h" /* text_buffer_size */ +#include "../../core.h" +#include "../../logging.h" +#include "../../content/specials.h" +#include "../../content/text_object.h" /* this is the root of all per disk stats, * also containing the totals. */ @@ -113,7 +113,7 @@ struct diskio_stat *prepare_diskio_stat(const char *s) { /* lookup existing */ while (cur->next != nullptr) { cur = cur->next; - if (strcmp(cur->dev, &(device_name[0])) == 0) { return cur; } + if (streq(cur->dev, &(device_name[0]))) { return cur; } } /* no existing found, make a new one */ @@ -173,7 +173,7 @@ void print_diskio_write(struct text_object *obj, char *p, #ifdef BUILD_GUI void parse_diskiograph_arg(struct text_object *obj, const char *arg) { auto [buf, skip] = scan_command(arg); - scan_graph(obj, arg + skip, 0, FALSE); + scan_graph(obj, arg + skip, 0, false); obj->data.opaque = prepare_diskio_stat(dev_name(buf)); free_and_zero(buf); diff --git a/src/data/hardware/hddtemp.cc b/src/data/hardware/hddtemp.cc index e2bab99f13..2dc91f7e9b 100644 --- a/src/data/hardware/hddtemp.cc +++ b/src/data/hardware/hddtemp.cc @@ -34,10 +34,10 @@ #include #include #include -#include "conky.h" -#include "logging.h" -#include "temphelper.h" -#include "text_object.h" +#include "../../conky.h" +#include "../../logging.h" +#include "../../content/temphelper.h" +#include "../../content/text_object.h" #define BUFLEN 512 @@ -217,7 +217,7 @@ static int get_hddtemp_info(const char *dev, short *val, char *unit) { /* if no dev is given, just use hdd_info_head->next */ while (dev && hdi) { - if (!strcmp(dev, hdi->dev)) break; + if (streq(dev, hdi->dev)) break; hdi = hdi->next; } if (!hdi) return 1; diff --git a/src/data/hardware/i8k.cc b/src/data/hardware/i8k.cc index fed53983e2..1edd6f93fa 100644 --- a/src/data/hardware/i8k.cc +++ b/src/data/hardware/i8k.cc @@ -31,10 +31,10 @@ #include #include #include -#include "conky.h" -#include "logging.h" -#include "temphelper.h" -#include "text_object.h" +#include "../../conky.h" +#include "../../logging.h" +#include "../../content/temphelper.h" +#include "../../content/text_object.h" struct _i8k { char *version; diff --git a/src/data/hardware/ibm.cc b/src/data/hardware/ibm.cc index 5b44487532..d8a244a125 100644 --- a/src/data/hardware/ibm.cc +++ b/src/data/hardware/ibm.cc @@ -35,9 +35,9 @@ #include #include #include "config.h" -#include "conky.h" -#include "logging.h" -#include "temphelper.h" +#include "../../conky.h" +#include "../../logging.h" +#include "../../content/temphelper.h" static int ibm_acpi_temps[8]; @@ -199,7 +199,7 @@ void get_ibm_acpi_volume(struct text_object *obj, char *p, fclose(fp); - if (strcmp(mute, "on") == 0) + if (streq(mute, "on")) snprintf(p, p_max_size, "%s", "mute"); else snprintf(p, p_max_size, "%d", vol); diff --git a/src/data/hardware/intel_backlight.cc b/src/data/hardware/intel_backlight.cc index 92852cf75d..ff8f2a4d0f 100644 --- a/src/data/hardware/intel_backlight.cc +++ b/src/data/hardware/intel_backlight.cc @@ -26,7 +26,7 @@ */ #include "intel_backlight.h" -#include "logging.h" +#include "../../logging.h" #define FS_BRIGHTNESS_MAX "/sys/class/backlight/intel_backlight/max_brightness" #define FS_BRIGHTNESS_CURRENT "/sys/class/backlight/intel_backlight/brightness" diff --git a/src/data/hardware/intel_backlight.h b/src/data/hardware/intel_backlight.h index 6c22382394..2881118dc9 100644 --- a/src/data/hardware/intel_backlight.h +++ b/src/data/hardware/intel_backlight.h @@ -28,8 +28,8 @@ #ifndef _INTEL_BACKLIGHT_H #define _INTEL_BACKLIGHT_H -#include "conky.h" -#include "text_object.h" +#include "../../conky.h" +#include "../../content/text_object.h" void init_intel_backlight(struct text_object *obj); void free_intel_backlight(struct text_object *obj); diff --git a/src/data/hardware/nvidia.cc b/src/data/hardware/nvidia.cc index 7637205111..3b2d957a8e 100644 --- a/src/data/hardware/nvidia.cc +++ b/src/data/hardware/nvidia.cc @@ -96,12 +96,12 @@ #include #include "NVCtrl/NVCtrl.h" #include "NVCtrl/NVCtrlLib.h" -#include "conky.h" -#include "logging.h" -#include "temphelper.h" +#include "../../conky.h" +#include "../../logging.h" +#include "../../content/temphelper.h" // Current implementation uses X11 specific system utils -#include "x11.h" +#include "../../output/x11.h" #include @@ -440,7 +440,7 @@ int set_nvidia_query(struct text_object *obj, const char *arg, char *p = strrchr(strbuf, ' '); if (p && *(p + 1)) { nvs->target_id = atoi(p + 1); - if ((nvs->target_id > 0) || !strcmp(p + 1, "0")) { + if ((nvs->target_id > 0) || !streq(p + 1, "0")) { ilen = strlen(strbuf); ilen = ilen - strlen(p); strbuf[ilen] = 0; @@ -458,7 +458,7 @@ int set_nvidia_query(struct text_object *obj, const char *arg, break; case text_node_t::GRAPH: { auto [buf, skip] = scan_command(arg); - scan_graph(obj, arg + skip, 100, FALSE); + scan_graph(obj, arg + skip, 100, false); arg = buf; } break; case text_node_t::GAUGE: @@ -477,7 +477,7 @@ int set_nvidia_query(struct text_object *obj, const char *arg, // Translate parameter to id for (aid = 0; aid < ARG_UNKNOWN; aid++) { - if (strcmp(arg, translate_module_argument[aid]) == 0) break; + if (streq(arg, translate_module_argument[aid])) break; } // free the string buffer after arg is not anymore needed @@ -810,26 +810,26 @@ static char *get_nvidia_string(TARGET_ID tid, ATTR_ID aid, int gid, void cache_nvidia_string_value_update(nvidia_c_string *ac_string, char *token, SEARCH_ID search, int *value, int gid) { - if (strcmp(token, (char *)"nvclockmin") == 0 && + if (streq(token, (char *)"nvclockmin") && ac_string[gid].nvclockmin < 0) { ac_string[gid].nvclockmin = *value; - } else if (strcmp(token, (char *)"nvclockmax") == 0 && + } else if (streq(token, (char *)"nvclockmax") && ac_string[gid].nvclockmax < 0) { ac_string[gid].nvclockmax = *value; - } else if (strcmp(token, (char *)"memclockmin") == 0 && + } else if (streq(token, (char *)"memclockmin") && ac_string[gid].memclockmin < 0) { ac_string[gid].memclockmin = *value; - } else if (strcmp(token, (char *)"memclockmax") == 0 && + } else if (streq(token, (char *)"memclockmax") && ac_string[gid].memclockmax < 0) { ac_string[gid].memclockmax = *value; - } else if (strcmp(token, (char *)"memTransferRatemin") == 0 && + } else if (streq(token, (char *)"memTransferRatemin") && ac_string[gid].memTransferRatemin < 0) { ac_string[gid].memTransferRatemin = *value; - } else if (strcmp(token, (char *)"memTransferRatemax") == 0 && + } else if (streq(token, (char *)"memTransferRatemax") && ac_string[gid].memTransferRatemax < 0) { ac_string[gid].memTransferRatemax = *value; - } else if (strcmp(token, (char *)"perf") == 0) { + } else if (streq(token, (char *)"perf")) { if (search == SEARCH_MIN && ac_string[gid].perfmin < 0) { ac_string[gid].perfmin = *value; @@ -842,20 +842,20 @@ void cache_nvidia_string_value_update(nvidia_c_string *ac_string, char *token, void cache_nvidia_string_value_noupdate(nvidia_c_string *ac_string, char *token, SEARCH_ID search, int *value, int gid) { - if (strcmp(token, (char *)"nvclockmin") == 0) { + if (streq(token, (char *)"nvclockmin")) { *value = ac_string[gid].nvclockmin; - } else if (strcmp(token, (char *)"nvclockmax") == 0) { + } else if (streq(token, (char *)"nvclockmax")) { *value = ac_string[gid].nvclockmax; - } else if (strcmp(token, (char *)"memclockmin") == 0) { + } else if (streq(token, (char *)"memclockmin")) { *value = ac_string[gid].memclockmin; - } else if (strcmp(token, (char *)"memclockmax") == 0) { + } else if (streq(token, (char *)"memclockmax")) { *value = ac_string[gid].memclockmax; - } else if (strcmp(token, (char *)"memTransferRatemin") == 0) { + } else if (streq(token, (char *)"memTransferRatemin")) { *value = ac_string[gid].memTransferRatemin; - } else if (strcmp(token, (char *)"memTransferRatemax") == 0) { + } else if (streq(token, (char *)"memTransferRatemax")) { *value = ac_string[gid].memTransferRatemax; - } else if (strcmp(token, (char *)"perf") == 0) { + } else if (streq(token, (char *)"perf")) { if (search == SEARCH_MIN) { *value = ac_string[gid].perfmin; } else if (search == SEARCH_MAX) { @@ -907,7 +907,7 @@ static int get_nvidia_string_value(TARGET_ID tid, ATTR_ID aid, char *token, while (kvp) { key = strtok_r(kvp, NV_KEYVAL_SEPARATORS, &saveptr2); val = strtok_r(nullptr, NV_KEYVAL_SEPARATORS, &saveptr2); - if (key && val && (strcmp(token, key) == 0)) { + if (key && val && streq(token, key)) { temp = (int)strtol(val, nullptr, 0); if (search == SEARCH_FIRST) { value = temp; @@ -1151,7 +1151,7 @@ double get_nvidia_barval(struct text_object *obj) { value = ((float)temp1 * 100 / (float)temp2) + 0.5; break; case ATTR_FREQS_STRING: // mtrfreq (calculate out of memfreqmax) - if (strcmp(nvs->token, "memTransferRate") != 0) { + if (!streq(nvs->token, "memTransferRate")) { // Just in case error for silly devs CRIT_ERR( "%s: attribute is 'ATTR_FREQS_STRING' but token is not " diff --git a/src/data/hardware/nvidia.h b/src/data/hardware/nvidia.h index 492274d7ac..47cf9d7f3d 100644 --- a/src/data/hardware/nvidia.h +++ b/src/data/hardware/nvidia.h @@ -30,7 +30,7 @@ #ifndef NVIDIA_CONKY_H #define NVIDIA_CONKY_H -#include "specials.h" +#include "../../content/specials.h" int set_nvidia_query(struct text_object *, const char *, text_node_t); void print_nvidia_value(struct text_object *, char *, unsigned int); diff --git a/src/data/hardware/smapi.cc b/src/data/hardware/smapi.cc index bc86c076b6..546b7a33b1 100644 --- a/src/data/hardware/smapi.cc +++ b/src/data/hardware/smapi.cc @@ -26,9 +26,9 @@ #include #include #include -#include "conky.h" /* text_buffer_size, PACKAGE_NAME, maybe more */ -#include "logging.h" -#include "temphelper.h" +#include "../../conky.h" /* text_buffer_size, PACKAGE_NAME, maybe more */ +#include "../../logging.h" +#include "../../content/temphelper.h" #define SYS_SMAPI_PATH "/sys/devices/platform/smapi" @@ -105,7 +105,7 @@ static char *smapi_get_val(const char *args) { if (!args || sscanf(args, "%127s", str) <= 0) return nullptr; - if (!strcmp(str, "bat")) return smapi_get_bat_val(args + 4); + if (streq(str, "bat")) return smapi_get_bat_val(args + 4); return smapi_get_str(str); } diff --git a/src/data/hardware/sony.cc b/src/data/hardware/sony.cc index 8bda0fd8c7..58208b9f3b 100644 --- a/src/data/hardware/sony.cc +++ b/src/data/hardware/sony.cc @@ -34,9 +34,9 @@ #include #include #include "config.h" -#include "conky.h" -#include "logging.h" -#include "text_object.h" +#include "../../conky.h" +#include "../../logging.h" +#include "../../content/text_object.h" #define SONY_LAPTOP_DIR "/sys/devices/platform/sony-laptop" diff --git a/src/data/ical.cc b/src/data/ical.cc index fb39ac1ed6..53b40d8624 100644 --- a/src/data/ical.cc +++ b/src/data/ical.cc @@ -23,8 +23,8 @@ */ #include -#include "conky.h" -#include "logging.h" +#include "../conky.h" +#include "../logging.h" struct ical_event { icaltimetype start; diff --git a/src/data/iconv_tools.cc b/src/data/iconv_tools.cc index 5e4d99dc27..d1d77f3cfd 100644 --- a/src/data/iconv_tools.cc +++ b/src/data/iconv_tools.cc @@ -32,8 +32,8 @@ #include #include #include "config.h" -#include "logging.h" -#include "text_object.h" +#include "../logging.h" +#include "../content/text_object.h" #define ICONV_CODEPAGE_LENGTH 20 diff --git a/src/data/misc.cc b/src/data/misc.cc index c945633ccb..a5446710e7 100644 --- a/src/data/misc.cc +++ b/src/data/misc.cc @@ -34,11 +34,11 @@ #include #include #include -#include "conky.h" -#include "core.h" -#include "logging.h" -#include "specials.h" -#include "text_object.h" +#include "../conky.h" +#include "../core.h" +#include "../logging.h" +#include "../content/specials.h" +#include "../content/text_object.h" static inline void read_file(const char *data, char *buf, const int size) { FILE *fp; @@ -131,6 +131,6 @@ void strip_trailing_whitespace(struct text_object *obj, char *p, long long int apply_base_multiplier(const char *s, long long int num) { long long int base = 1024LL; - if (*s && (0 == (strcmp(s, "si")))) { base = 1000LL; } + if (*s && streq(s, "si")) { base = 1000LL; } return (num * base); } diff --git a/src/data/misc.h b/src/data/misc.h index 5a813d22b0..9033409663 100644 --- a/src/data/misc.h +++ b/src/data/misc.h @@ -31,7 +31,7 @@ #ifndef _MISC_H #define _MISC_H -#include "text_object.h" +#include "../content/text_object.h" void print_cat(struct text_object *, char *, unsigned int); void print_catp(struct text_object *, char *, unsigned int); diff --git a/src/data/mysql.cc b/src/data/mysql.cc index fa31c74f6a..f2f94da336 100644 --- a/src/data/mysql.cc +++ b/src/data/mysql.cc @@ -27,12 +27,12 @@ */ #include "mysql.h" -#include "conky.h" -#include "logging.h" +#include "../conky.h" +#include "../logging.h" #include -#include "setting.hh" +#include "../lua/setting.hh" namespace { conky::simple_config_setting host("mysql_host", "localhost", diff --git a/src/data/network/ccurl_thread.cc b/src/data/network/ccurl_thread.cc index fc4caa63ac..96d33356d1 100644 --- a/src/data/network/ccurl_thread.cc +++ b/src/data/network/ccurl_thread.cc @@ -25,9 +25,9 @@ #include "ccurl_thread.h" #include #include -#include "conky.h" -#include "logging.h" -#include "text_object.h" +#include "../../conky.h" +#include "../../logging.h" +#include "../../content/text_object.h" #ifdef DEBUG #include @@ -55,9 +55,9 @@ size_t curl_internal::parse_header_cb(void *ptr, size_t size, size_t nmemb, --realsize; } - if (strncmp(value, "Last-Modified: ", 15) == EQUAL) { + if (strneq(value, "Last-Modified: ", 15)) { obj->last_modified = std::string(value + 15, realsize - 15); - } else if (strncmp(value, "ETag: ", 6) == EQUAL) { + } else if (strneq(value, "ETag: ", 6)) { obj->etag = std::string(value + 6, realsize - 6); } diff --git a/src/data/network/ccurl_thread.h b/src/data/network/ccurl_thread.h index da54272ec3..ee5dd21adf 100644 --- a/src/data/network/ccurl_thread.h +++ b/src/data/network/ccurl_thread.h @@ -27,8 +27,8 @@ #include -#include "logging.h" -#include "update-cb.hh" +#include "../../logging.h" +#include "../../update-cb.hh" namespace priv { // factored out stuff that does not depend on the template parameters diff --git a/src/data/network/irc.cc b/src/data/network/irc.cc index 90cd2b95d0..4389f622dc 100644 --- a/src/data/network/irc.cc +++ b/src/data/network/irc.cc @@ -26,9 +26,9 @@ #include #include #include -#include "conky.h" -#include "logging.h" -#include "text_object.h" +#include "../../conky.h" +#include "../../logging.h" +#include "../../content/text_object.h" struct ll_text { char *text; diff --git a/src/data/network/mail.cc b/src/data/network/mail.cc index d17e84d5b5..55e7aff86b 100644 --- a/src/data/network/mail.cc +++ b/src/data/network/mail.cc @@ -31,10 +31,10 @@ #include "mail.h" -#include "common.h" -#include "conky.h" -#include "logging.h" -#include "text_object.h" +#include "../../common.h" +#include "../../conky.h" +#include "../../logging.h" +#include "../../content/text_object.h" #include #include @@ -57,7 +57,7 @@ #include #include -#include "update-cb.hh" +#include "../../update-cb.hh" struct local_mail_s { char *mbox; diff --git a/src/data/network/mail.h b/src/data/network/mail.h index c3c71765a3..7cd16aeb2a 100644 --- a/src/data/network/mail.h +++ b/src/data/network/mail.h @@ -25,7 +25,7 @@ #ifndef _MAIL_H #define _MAIL_H -#include "setting.hh" +#include "../../lua/setting.hh" void parse_local_mail_args(struct text_object *, const char *); diff --git a/src/data/network/mboxscan.cc b/src/data/network/mboxscan.cc index 5682418922..356f340526 100644 --- a/src/data/network/mboxscan.cc +++ b/src/data/network/mboxscan.cc @@ -31,10 +31,10 @@ #include #include #include -#include "conky.h" -#include "logging.h" +#include "../../conky.h" +#include "../../logging.h" #include "mail.h" -#include "text_object.h" +#include "../../content/text_object.h" #define FROM_WIDTH 10 #define SUBJECT_WIDTH 22 @@ -144,7 +144,7 @@ static void mbox_scan(char *args, char *output, size_t max_len) { } /* allowing $MAIL in the config */ - if (strcmp(mbox_mail_spool, "$MAIL") == 0) { + if (streq(mbox_mail_spool, "$MAIL")) { strncpy(mbox_mail_spool, current_mail_spool.get(*state).c_str(), DEFAULT_TEXT_BUFFER_SIZE); } diff --git a/src/data/network/net_stat.cc b/src/data/network/net_stat.cc index 4cfc55c6f7..2c6a6f2bc0 100644 --- a/src/data/network/net_stat.cc +++ b/src/data/network/net_stat.cc @@ -34,11 +34,11 @@ #include #include #include -#include "conky.h" -#include "logging.h" +#include "../../conky.h" +#include "../../logging.h" #include "net/if.h" -#include "specials.h" -#include "text_object.h" +#include "../../content/specials.h" +#include "../../content/text_object.h" #if defined(__sun) #include #endif @@ -51,7 +51,7 @@ #endif /* SOCK_CLOEXEC */ #if defined(__linux__) -#include "linux.h" +#include "../os/linux.h" #else static char e_iface[50] = "empty"; static char interfaces_arr[MAX_NET_INTERFACES][64] = {""}; @@ -90,7 +90,7 @@ struct net_stat *get_net_stat(const char *dev, void * /*free_at_crash1*/, /* find interface stat */ for (i = 0; i < MAX_NET_INTERFACES; i++) { - if ((netstats[i].dev != nullptr) && strcmp(netstats[i].dev, dev) == 0) { + if ((netstats[i].dev != nullptr) && streq(netstats[i].dev, dev)) { return &netstats[i]; } } @@ -133,7 +133,7 @@ void parse_net_stat_arg(struct text_object *obj, const char *arg, if (arg == nullptr) { arg = DEFAULTNETDEV; } - if (0 == (strcmp("$gw_iface", arg)) || 0 == (strcmp("${gw_iface}", arg))) { + if (streq("$gw_iface", arg) || streq("${gw_iface}", arg)) { #if defined(__linux__) update_gateway_info(); #endif @@ -158,9 +158,9 @@ void parse_net_stat_arg(struct text_object *obj, const char *arg, while (sscanf(arg + i, " %20s", nextarg) == 1) { #ifdef BUILD_IPV6 - if (strcmp(nextarg, "-n") == 0 || strcmp(nextarg, "--netmask") == 0) { + if (streq(nextarg, "-n") || streq(nextarg, "--netmask")) { shownetmask = true; - } else if (strcmp(nextarg, "-s") == 0 || strcmp(nextarg, "--scope") == 0) { + } else if (streq(nextarg, "-s") || streq(nextarg, "--scope")) { showscope = true; } else if (nextarg[0] == '-') { // multiple flags in 1 arg for (int j = 1; nextarg[j] != 0; j++) { @@ -334,12 +334,12 @@ void parse_net_stat_graph_arg(struct text_object *obj, const char *arg, void *free_at_crash) { /* scan arguments and get interface name back */ auto [buf, skip] = scan_command(arg); - scan_graph(obj, arg + skip, 0, TRUE); + scan_graph(obj, arg + skip, 0, true); // default to DEFAULTNETDEV if (buf != nullptr) { #if defined(__linux__) - if (0 == (strcmp("$gw_iface", buf)) || 0 == (strcmp("${gw_iface}", buf))) { + if (streq("$gw_iface", buf) || streq("${gw_iface}", buf)) { update_gateway_info(); obj->data.opaque = get_net_stat(e_iface, obj, free_at_crash); free(buf); diff --git a/src/data/network/prss.cc b/src/data/network/prss.cc index 600ecea8c4..a0f1fefebc 100644 --- a/src/data/network/prss.cc +++ b/src/data/network/prss.cc @@ -20,8 +20,8 @@ #include "prss.h" #include #include -#include "conky.h" -#include "logging.h" +#include "../../conky.h" +#include "../../logging.h" #ifndef PARSE_OPTIONS #define PARSE_OPTIONS 0 @@ -106,11 +106,11 @@ static inline void read_item(PRSS_Item *res, xmlNodePtr data) { if (!child) { continue; } -#define ASSIGN(a) \ - if (strcasecmp((const char *)data->name, #a) == EQUAL) { \ - free_and_zero(res->a); \ - res->a = strdup((const char *)child->content); \ - continue; \ +#define ASSIGN(a) \ + if (streq((const char *)data->name, #a, true)) { \ + free_and_zero(res->a); \ + res->a = strdup((const char *)child->content); \ + continue; \ } ASSIGN(title); ASSIGN(link); @@ -129,11 +129,11 @@ static inline void read_element(PRSS *res, xmlNodePtr n) { if (!child) { return; } -#define ASSIGN(a) \ - if (strcasecmp((const char *)n->name, #a) == EQUAL) { \ - free_and_zero(res->a); \ - res->a = strdup((const char *)child->content); \ - return; \ +#define ASSIGN(a) \ + if (streq((const char *)n->name, #a, true)) { \ + free_and_zero(res->a); \ + res->a = strdup((const char *)child->content); \ + return; \ } ASSIGN(title); ASSIGN(link); @@ -161,13 +161,13 @@ static inline int parse_rss_2_0(PRSS *res, xmlNodePtr root) { DBGP("parsing rss 2.0 or <1 doc"); while (channel && (channel->type != XML_ELEMENT_NODE || - strcmp((const char *)channel->name, "channel"))) { + !streq((const char *)channel->name, "channel"))) { channel = channel->next; } if (!channel) { return 0; } for (n = channel->children; n; n = n->next) { - if (n->type == XML_ELEMENT_NODE && !strcmp((const char *)n->name, "item")) { + if (n->type == XML_ELEMENT_NODE && streq((const char *)n->name, "item")) { ++items; } } @@ -190,9 +190,9 @@ static inline int parse_rss_1_0(PRSS *res, xmlNodePtr root) { for (n = root->children; n; n = n->next) { if (n->type == XML_ELEMENT_NODE) { - if (!strcmp((const char *)n->name, "item")) { + if (streq((const char *)n->name, "item")) { ++items; - } else if (!strcmp((const char *)n->name, "channel")) { + } else if (streq((const char *)n->name, "channel")) { xmlNodePtr i; for (i = n->children; i; i = i->next) { read_element(res, i); } @@ -220,11 +220,11 @@ void prss_parse_doc(PRSS *result, xmlDocPtr doc) { do { if (root->type == XML_ELEMENT_NODE) { - if (!strcmp((const char *)root->name, "RDF")) { + if (streq((const char *)root->name, "RDF")) { // RSS 1.0 document parse_rss_1_0(result, root); return; - } else if (!strcmp((const char *)root->name, "rss")) { + } else if (streq((const char *)root->name, "rss")) { // RSS 2.0 or <1.0 document parse_rss_2_0(result, root); return; diff --git a/src/data/network/read_tcpip.cc b/src/data/network/read_tcpip.cc index dccd30106c..f08a68cd73 100644 --- a/src/data/network/read_tcpip.cc +++ b/src/data/network/read_tcpip.cc @@ -36,9 +36,9 @@ #include #include #include -#include "conky.h" -#include "logging.h" -#include "text_object.h" +#include "../../conky.h" +#include "../../logging.h" +#include "../../content/text_object.h" #ifndef SOCK_CLOEXEC #define SOCK_CLOEXEC O_CLOEXEC diff --git a/src/data/network/rss.cc b/src/data/network/rss.cc index d858319777..2fcd6670e1 100644 --- a/src/data/network/rss.cc +++ b/src/data/network/rss.cc @@ -28,10 +28,10 @@ #include #include #include "ccurl_thread.h" -#include "conky.h" -#include "logging.h" +#include "../../conky.h" +#include "../../logging.h" #include "prss.h" -#include "text_object.h" +#include "../../content/text_object.h" struct rss_data { char uri[128]; @@ -81,14 +81,14 @@ static void rss_process_info(char *p, int p_max_size, const std::string &uri, * XXX: Refactor this so that we can retrieve any of the fields in the * PRSS struct (in prss.h). */ - if (strcmp(action, "feed_title") == EQUAL) { + if (streq(action, "feed_title")) { str = data->title; if (str && strlen(str) > 0) { // remove trailing new line if one exists if (str[strlen(str) - 1] == '\n') { str[strlen(str) - 1] = 0; } snprintf(p, p_max_size, "%s", str); } - } else if (strcmp(action, "item_title") == EQUAL) { + } else if (streq(action, "item_title")) { if (act_par < data->item_count) { str = data->items[act_par].title; // remove trailing new line if one exists @@ -97,7 +97,7 @@ static void rss_process_info(char *p, int p_max_size, const std::string &uri, snprintf(p, p_max_size, "%s", str); } } - } else if (strcmp(action, "item_desc") == EQUAL) { + } else if (streq(action, "item_desc")) { if (act_par < data->item_count) { str = data->items[act_par].description; // remove trailing new line if one exists @@ -106,7 +106,7 @@ static void rss_process_info(char *p, int p_max_size, const std::string &uri, snprintf(p, p_max_size, "%s", str); } } - } else if (strcmp(action, "item_titles") == EQUAL) { + } else if (streq(action, "item_titles")) { if (data->item_count > 0) { int itmp; int show; diff --git a/src/data/network/tcp-portmon.cc b/src/data/network/tcp-portmon.cc index c8554faa0a..ecc54baccf 100644 --- a/src/data/network/tcp-portmon.cc +++ b/src/data/network/tcp-portmon.cc @@ -18,10 +18,10 @@ * */ #include "tcp-portmon.h" -#include "conky.h" +#include "../../conky.h" #include "libtcp-portmon.h" -#include "logging.h" -#include "text_object.h" +#include "../../logging.h" +#include "../../content/text_object.h" static tcp_port_monitor_collection_t *pmc = nullptr; @@ -53,23 +53,23 @@ int tcp_portmon_init(struct text_object *obj, const char *arg) { if (port_begin > port_end) { CRIT_ERR("tcp_portmon: starting port must be <= ending port"); } - if (strncmp(itembuf, "count", 31) == EQUAL) { + if (strneq(itembuf, "count", 31)) { item = COUNT; - } else if (strncmp(itembuf, "rip", 31) == EQUAL) { + } else if (strneq(itembuf, "rip", 31)) { item = REMOTEIP; - } else if (strncmp(itembuf, "rhost", 31) == EQUAL) { + } else if (strneq(itembuf, "rhost", 31)) { item = REMOTEHOST; - } else if (strncmp(itembuf, "rport", 31) == EQUAL) { + } else if (strneq(itembuf, "rport", 31)) { item = REMOTEPORT; - } else if (strncmp(itembuf, "rservice", 31) == EQUAL) { + } else if (strneq(itembuf, "rservice", 31)) { item = REMOTESERVICE; - } else if (strncmp(itembuf, "lip", 31) == EQUAL) { + } else if (strneq(itembuf, "lip", 31)) { item = LOCALIP; - } else if (strncmp(itembuf, "lhost", 31) == EQUAL) { + } else if (strneq(itembuf, "lhost", 31)) { item = LOCALHOST; - } else if (strncmp(itembuf, "lport", 31) == EQUAL) { + } else if (strneq(itembuf, "lport", 31)) { item = LOCALPORT; - } else if (strncmp(itembuf, "lservice", 31) == EQUAL) { + } else if (strneq(itembuf, "lservice", 31)) { item = LOCALSERVICE; } else { CRIT_ERR("tcp_portmon: invalid item specified"); diff --git a/src/data/os/bsdcommon.cc b/src/data/os/bsdcommon.cc index e70e14aaab..2193d1b679 100644 --- a/src/data/os/bsdcommon.cc +++ b/src/data/os/bsdcommon.cc @@ -23,7 +23,7 @@ */ #include "bsdcommon.h" -#include "logging.h" +#include "../../logging.h" #include @@ -37,7 +37,7 @@ #include #endif -#include "top.h" +#include "../top.h" static kvm_t *kd = nullptr; static char kvm_errbuf[_POSIX2_LINE_MAX]; @@ -325,7 +325,7 @@ void bsdcommon::update_top_info() { static bool is_process(BSD_COMMON_PROC_STRUCT *p, const char *name) { #if defined(__NetBSD__) - return p->p_comm[0] != 0 && strcmp(p->p_comm, name) == 0; + return p->p_comm[0] != 0 && streq(p->p_comm, name); #else #error Not supported BSD system #endif diff --git a/src/data/os/bsdcommon.h b/src/data/os/bsdcommon.h index b167de881b..dac5bfd60b 100644 --- a/src/data/os/bsdcommon.h +++ b/src/data/os/bsdcommon.h @@ -40,7 +40,7 @@ #include -#include "conky.h" +#include "../../conky.h" namespace bsdcommon { struct cpu_load { diff --git a/src/data/darwin.h b/src/data/os/darwin.h similarity index 100% rename from src/data/darwin.h rename to src/data/os/darwin.h diff --git a/src/data/darwin.mm b/src/data/os/darwin.mm similarity index 99% rename from src/data/darwin.mm rename to src/data/os/darwin.mm index ebdc182fb2..51c6ca6aa3 100644 --- a/src/data/darwin.mm +++ b/src/data/os/darwin.mm @@ -42,7 +42,7 @@ *is available. patched the _csr_check function to return the bool bit instead. */ -#include "conky.h" // for struct info +#include "../../conky.h" // for struct info #include "darwin.h" #include @@ -64,7 +64,7 @@ #include "top.h" // get_top_info #include // update_net_stats -#include "net_stat.h" // update_net_stats +#include "network/net_stat.h" // update_net_stats #include "darwin_sip.h" // sip status @@ -422,7 +422,7 @@ int check_mount(struct text_object *obj) { } for (int i = 0; i < num_mounts; i++) { - if (strcmp(mounts[i].f_mntonname, obj->data.s) == 0) { return 1; } + if (streq(mounts[i].f_mntonname, obj->data.s)) { return 1; } } return 0; @@ -745,7 +745,7 @@ int update_net_stats() { if (ifa->ifa_addr->sa_family != AF_LINK) { continue; } for (iftmp = ifa->ifa_next; - iftmp != nullptr && strcmp(ifa->ifa_name, iftmp->ifa_name) == 0; + iftmp != nullptr && streq(ifa->ifa_name, iftmp->ifa_name); iftmp = iftmp->ifa_next) { if (iftmp->ifa_addr->sa_family == AF_INET) { memcpy(&(ns->addr), iftmp->ifa_addr, iftmp->ifa_addr->sa_len); diff --git a/src/data/darwin_sip.h b/src/data/os/darwin_sip.h similarity index 100% rename from src/data/darwin_sip.h rename to src/data/os/darwin_sip.h diff --git a/src/data/os/dragonfly.cc b/src/data/os/dragonfly.cc index b7743091aa..5fba053fe3 100644 --- a/src/data/os/dragonfly.cc +++ b/src/data/os/dragonfly.cc @@ -51,12 +51,12 @@ #include -#include "conky.h" -#include "diskio.h" +#include "../../conky.h" +#include "../hardware/diskio.h" #include "dragonfly.h" -#include "logging.h" -#include "net_stat.h" -#include "top.h" +#include "../../logging.h" +#include "../network/net_stat.h" +#include "../top.h" #define GETSYSCTL(name, var) getsysctl(name, &(var), sizeof(var)) #define KELVTOC(x) ((x - 2732) / 10.0) @@ -126,7 +126,7 @@ int check_mount(char *s) { mntsize = getmntinfo(&mntbuf, MNT_NOWAIT); for (i = mntsize - 1; i >= 0; i--) { - if (strcmp(mntbuf[i].f_mntonname, s) == 0) { return 1; } + if (streq(mntbuf[i].f_mntonname, s)) { return 1; } } return 0; @@ -194,7 +194,7 @@ int update_net_stats(void) { if (ifa->ifa_addr->sa_family != AF_LINK) { continue; } for (iftmp = ifa->ifa_next; - iftmp != nullptr && strcmp(ifa->ifa_name, iftmp->ifa_name) == 0; + iftmp != nullptr && streq(ifa->ifa_name, iftmp->ifa_name); iftmp = iftmp->ifa_next) { if (iftmp->ifa_addr->sa_family == AF_INET) { memcpy(&(ns->addr), iftmp->ifa_addr, iftmp->ifa_addr->sa_len); @@ -612,7 +612,7 @@ int update_diskio(void) { total_reads += (reads = dev->bytes_read / 512); total_writes += (writes = dev->bytes_written / 512); for (cur = stats.next; cur; cur = cur->next) { - if (cur->dev && !strcmp(device_name, cur->dev)) { + if (cur->dev && streq(device_name, cur->dev)) { update_diskio_values(cur, reads, writes); break; } diff --git a/src/data/os/dragonfly.h b/src/data/os/dragonfly.h index 52a39cc54c..93cd8a92e4 100644 --- a/src/data/os/dragonfly.h +++ b/src/data/os/dragonfly.h @@ -8,7 +8,7 @@ #include #include #include -#include "common.h" +#include "../../common.h" #if (defined(i386) || defined(__i386__)) #include #endif /* i386 || __i386__ */ diff --git a/src/data/os/freebsd.cc b/src/data/os/freebsd.cc index f5913c55c1..88ea530a51 100644 --- a/src/data/os/freebsd.cc +++ b/src/data/os/freebsd.cc @@ -56,13 +56,13 @@ #include -#include "conky.h" -#include "diskio.h" +#include "../../conky.h" +#include "../hardware/diskio.h" #include "freebsd.h" -#include "logging.h" -#include "net_stat.h" -#include "text_object.h" -#include "top.h" +#include "../../logging.h" +#include "../network/net_stat.h" +#include "../../content/text_object.h" +#include "../top.h" #define GETSYSCTL(name, var) getsysctl(name, &(var), sizeof(var)) #define KELVTOC(x) ((x - 2732) / 10.0) @@ -143,7 +143,7 @@ int check_mount(struct text_object *obj) { mntsize = getmntinfo(&mntbuf, MNT_NOWAIT); for (i = mntsize - 1; i >= 0; i--) { - if (strcmp(mntbuf[i].f_mntonname, obj->data.s) == 0) { return 1; } + if (streq(mntbuf[i].f_mntonname, obj->data.s)) { return 1; } } return 0; @@ -235,7 +235,7 @@ int update_net_stats(void) { if (ifa->ifa_addr->sa_family != AF_LINK) { continue; } for (iftmp = ifa->ifa_next; - iftmp != nullptr && strcmp(ifa->ifa_name, iftmp->ifa_name) == 0; + iftmp != nullptr && streq(ifa->ifa_name, iftmp->ifa_name); iftmp = iftmp->ifa_next) { if (iftmp->ifa_addr->sa_family == AF_INET) { memcpy(&(ns->addr), iftmp->ifa_addr, iftmp->ifa_addr->sa_len); @@ -681,7 +681,7 @@ int update_diskio(void) { total_reads += (reads = dev->bytes[DEVSTAT_READ] / 512); total_writes += (writes = dev->bytes[DEVSTAT_WRITE] / 512); for (cur = stats.next; cur; cur = cur->next) { - if (cur->dev && !strcmp(device_name, cur->dev)) { + if (cur->dev && streq(device_name, cur->dev)) { update_diskio_values(cur, reads, writes); break; } @@ -761,7 +761,7 @@ void print_sysctlbyname(struct text_object *obj, char *p, size_t len = sizeof(val); size_t len2 = sizeof(buf); - if (0 == strcmp(obj->data.s, "")) { + if (streq(obj->data.s, "")) { snprintf(p, p_max_size, "%s", "sysctlbyname takes an argument"); return; } @@ -773,7 +773,7 @@ void print_sysctlbyname(struct text_object *obj, char *p, } } - if (0 != strcmp(buf, "")) { + if (!streq(buf, "")) { snprintf(p, p_max_size, "%s", buf); } else { snprintf(p, p_max_size, "%lu", (unsigned long)val[0]); @@ -805,7 +805,7 @@ bool is_conky_already_running(void) { } for (int i = 0; i < entries && instances < 2; ++i) { - if (!strcmp("conky", kp[i].ki_comm)) { + if (streq("conky", kp[i].ki_comm)) { ++instances; } } diff --git a/src/data/os/freebsd.h b/src/data/os/freebsd.h index d64cf569ca..82d1600b60 100644 --- a/src/data/os/freebsd.h +++ b/src/data/os/freebsd.h @@ -36,7 +36,7 @@ #include #include #include -#include "common.h" +#include "../../common.h" #if (defined(i386) || defined(__i386__)) #include #endif /* i386 || __i386__ */ diff --git a/src/data/os/haiku.cc b/src/data/os/haiku.cc index 7029df1927..79cfbe2073 100644 --- a/src/data/os/haiku.cc +++ b/src/data/os/haiku.cc @@ -29,10 +29,10 @@ #include -#include "conky.h" +#include "../../conky.h" #include "haiku.h" -#include "net_stat.h" -#include "top.h" +#include "../network/net_stat.h" +#include "../top.h" static short cpu_setup = 0; @@ -262,9 +262,7 @@ bool is_conky_already_running(void) { while (get_next_team_info(&team_cookie, &team_info) >= B_OK) { while (get_next_thread_info(team_info.team, &thread_cookie, &thread_info) >= B_OK) { - if (!strcmp("conky", thread_info.name)) { - ++instances; - } + if (strneq("conky", thread_info.name)) { ++instances; } } } return instances > 1; diff --git a/src/data/os/haiku.h b/src/data/os/haiku.h index 84c93208c6..965a882da2 100644 --- a/src/data/os/haiku.h +++ b/src/data/os/haiku.h @@ -20,8 +20,8 @@ #include -#include "common.h" -#include "conky.h" +#include "../../common.h" +#include "../../conky.h" int get_entropy_avail(unsigned int *); int get_entropy_poolsize(unsigned int *); diff --git a/src/data/os/journal.cc b/src/data/os/journal.cc index 3695ae9300..ec3c8adc13 100644 --- a/src/data/os/journal.cc +++ b/src/data/os/journal.cc @@ -33,11 +33,11 @@ #include #include #include -#include "common.h" +#include "../../common.h" #include "config.h" -#include "conky.h" -#include "logging.h" -#include "text_object.h" +#include "../../conky.h" +#include "../../logging.h" +#include "../../content/text_object.h" #define MAX_JOURNAL_LINES 200 @@ -74,10 +74,10 @@ void init_journal(const char *type, const char *arg, struct text_object *obj, } if (j->wantedlines > 0 && j->wantedlines <= MAX_JOURNAL_LINES) { if (args > 1) { - if (strcmp(tmp.get(), "system") == 0) { + if (streq(tmp.get(), "system")) { j->flags |= SD_JOURNAL_SYSTEM; #ifdef SD_JOURNAL_CURRENT_USER // not present in older version of systemd - } else if (strcmp(tmp.get(), "user") == 0) { + } else if (streq(tmp.get(), "user")) { j->flags |= SD_JOURNAL_CURRENT_USER; #endif /* SD_JOURNAL_CURRENT_USER */ } else { diff --git a/src/data/os/linux.cc b/src/data/os/linux.cc index 4bf689a104..f502314c7a 100644 --- a/src/data/os/linux.cc +++ b/src/data/os/linux.cc @@ -33,13 +33,13 @@ #include #include #include -#include "common.h" -#include "conky.h" -#include "diskio.h" -#include "logging.h" -#include "net_stat.h" -#include "proc.h" -#include "temphelper.h" +#include "../../common.h" +#include "../../conky.h" +#include "../hardware/diskio.h" +#include "../../logging.h" +#include "../network/net_stat.h" +#include "../proc.h" +#include "../../content/temphelper.h" #ifndef HAVE_CLOCK_GETTIME #include #endif @@ -48,8 +48,8 @@ // #include #include #include -#include "setting.hh" -#include "top.h" +#include "../../lua/setting.hh" +#include "../top.h" #include #include @@ -158,7 +158,7 @@ int check_mount(struct text_object *obj) { while (fgets(buf1, 256, mtab)) { sscanf(buf1, "%*s %128s", buf2); - if (!strcmp(obj->data.s, buf2)) { + if (streq(obj->data.s, buf2)) { ret = 1; break; } @@ -327,7 +327,7 @@ class gw_info_s { static gw_info_s gw_info; char *save_set_string(char *x, char *y) { - if (x != nullptr && strcmp((char *)x, (char *)y)) { + if (x != nullptr && !streq((char *)x, (char *)y)) { free_and_zero(x); x = strndup("multiple", text_buffer_size.get(*state)); } else if (x == nullptr && y != nullptr) { @@ -390,7 +390,7 @@ int update_gateway_info2(void) { if (1U == x) { snprintf(interfaces_arr[x++], iface_len, "%s", iface); continue; - } else if (0 == strcmp(iface, interfaces_arr[x - 1])) { + } else if (streq(iface, interfaces_arr[x - 1])) { continue; } for (z = 1; z < iface_len - 1 && strcmpreturn == 1; z++) { @@ -461,9 +461,9 @@ void print_gateway_iface2(struct text_object *obj, char *p, char buf[iface_len * iface_len] = {""}; char *buf_ptr = buf; - if (0 == strcmp(obj->data.s, "")) { + if (streq(obj->data.s, "")) { for (; x < iface_len - 1; x++) { - if (0 == strcmp("", interfaces_arr[x])) { break; } + if (streq("", interfaces_arr[x])) { break; } buf_ptr += snprintf(buf_ptr, iface_len - 1, "%s, ", interfaces_arr[x]); found = 1; } @@ -1258,14 +1258,14 @@ static int open_sysfs_sensor(const char *dir, const char *dev, const char *type, memset(buf, 0, sizeof(buf)); /* if device is nullptr or *, get first */ - if (dev == nullptr || strcmp(dev, "*") == 0) { + if (dev == nullptr || streq(dev, "*")) { static int reported = 0; if (!get_first_file_in_a_directory(dir, buf, &reported)) { return -1; } dev = buf; } - if (strcmp(dir, "/sys/class/hwmon/") == 0) { + if (streq(dir, "/sys/class/hwmon/")) { if (*buf) { /* buf holds result from get_first_file_in_a_directory() above, * e.g. "hwmon0" -- append "/device" */ @@ -1288,11 +1288,11 @@ static int open_sysfs_sensor(const char *dir, const char *dev, const char *type, } /* change vol to in, tempf to temp */ - if (strcmp(type, "vol") == 0) { + if (streq(type, "vol")) { type = "in"; - } else if (strcmp(type, "tempf") == 0) { + } else if (streq(type, "tempf")) { type = "temp"; - } else if (strcmp(type, "temp2") == 0) { + } else if (streq(type, "temp2")) { type = "temp"; } @@ -1318,17 +1318,16 @@ static int open_sysfs_sensor(const char *dir, const char *dev, const char *type, strncpy(devtype, path, 255); - if (strcmp(type, "in") == 0 || strcmp(type, "temp") == 0 || - strcmp(type, "tempf") == 0) { + if (streq(type, "in") || streq(type, "temp") || streq(type, "tempf")) { *divisor = 1; } else { *divisor = 0; } /* fan does not use *_div as a read divisor */ - if (strcmp("fan", type) == 0) { return fd; } + if (streq("fan", type)) { return fd; } /* test if *_div file exist, open it and use it as divisor */ - if (strcmp(type, "tempf") == 0) { + if (streq(type, "tempf")) { snprintf(path, 255, "%s%s/%s%d_div", dir, "one", "two", n); } else { snprintf(path, 255, "%s%s/%s%d_div", dir, dev, type, n); @@ -1390,12 +1389,12 @@ static double get_sysfs_info(int *fd, int divisor, char *devtype, char *type) { /* divide voltage and temperature by 1000 */ /* or if any other divisor is given, use that */ - if (0 == (strcmp(type, "temp2"))) { + if (streq(type, "temp2")) { temp2 = "temp2"; } else { temp2 = "empty"; } - if (strcmp(type, "tempf") == 0) { + if (streq(type, "tempf")) { if (divisor > 1) { return ((val / divisor + 40) * 9.0 / 5) - 40; } else if (divisor) { @@ -1484,9 +1483,9 @@ void print_sysfs_sensor(struct text_object *obj, char *p, r = r * sf->factor + sf->offset; - if (0 == (strcmp(temp2, "temp2"))) { + if (streq(temp2, "temp2")) { temp_print(p, p_max_size, r, TEMP_CELSIUS, 0); - } else if (!strncmp(sf->type, "temp", 4)) { + } else if (strneq(sf->type, "temp", std::size_t(4))) { temp_print(p, p_max_size, r, TEMP_CELSIUS, 1); } else if (r >= 100.0 || r == 0) { snprintf(p, p_max_size, "%d", (int)r); @@ -1827,7 +1826,7 @@ int open_acpi_temperature(const char *name) { char path[256]; int fd; - if (name == nullptr || strcmp(name, "*") == 0) { + if (name == nullptr || streq(name, "*")) { snprintf(path, 255, ACPI_THERMAL_FORMAT, ACPI_THERMAL_ZONE_DEFAULT); } else { snprintf(path, 255, ACPI_THERMAL_FORMAT, name); @@ -1988,7 +1987,7 @@ int get_battery_idx(const char *bat) { int idx; for (idx = 0; idx < MAX_BATTERY_COUNT; idx++) { - if (!strlen(batteries[idx]) || !strcmp(batteries[idx], bat)) { break; } + if (!strlen(batteries[idx]) || streq(batteries[idx], bat)) { break; } } /* if not found, enter a new entry */ @@ -2080,11 +2079,11 @@ void get_battery_stuff(char *buffer, unsigned int n, const char *bat, acpi_last_full[idx] = remaining_capacity; /* normalize to 100% */ /* not present */ - if (strcmp(present, "No") == 0) { + if (streq(present, "No")) { strncpy(last_battery_str[idx], "not present", 64); } /* charging */ - else if (strcmp(charging_state, "Charging") == 0) { + else if (streq(charging_state, "Charging")) { if (acpi_last_full[idx] != 0 && present_rate > 0) { /* e.g. charging 75% */ snprintf( @@ -2214,10 +2213,10 @@ void get_battery_stuff(char *buffer, unsigned int n, const char *bat, } /* not present */ - if (strcmp(present, "no") == 0) { + if (streq(present, "no")) { strncpy(last_battery_str[idx], "not present", 64); /* charging */ - } else if (strcmp(charging_state, "charging") == 0) { + } else if (streq(charging_state, "charging")) { if (acpi_last_full[idx] != 0 && present_rate > 0) { /* e.g. charging 75% */ snprintf(last_battery_str[idx], sizeof(last_battery_str[idx]) - 1, @@ -2508,7 +2507,7 @@ int get_battery_perct(const char *bat) { init_batteries(); /* Check if user asked for the mean percentage of all batteries. */ - if (!strcmp(bat, "all")) { + if (streq(bat, "all")) { for (idx = 0; idx < MAX_BATTERY_COUNT; idx++) { snprintf(battery, BATTERY_LEN - 1, "BAT%d", idx); #undef BATTERY_LEN @@ -2777,7 +2776,7 @@ int update_diskio(void) { if (col_count != 5) { continue; } } cur = stats.next; - while (cur && strcmp(devbuf, cur->dev)) cur = cur->next; + while (cur && !streq(devbuf, cur->dev)) cur = cur->next; if (cur) update_diskio_values(cur, reads, writes); } diff --git a/src/data/os/linux.h b/src/data/os/linux.h index f5b9f40978..aabf77932a 100644 --- a/src/data/os/linux.h +++ b/src/data/os/linux.h @@ -25,7 +25,7 @@ #ifndef _LINUX_H #define _LINUX_H -#include "common.h" +#include "../../common.h" void print_disk_protect_queue(struct text_object *, char *, unsigned int); diff --git a/src/data/os/netbsd.cc b/src/data/os/netbsd.cc index 1da8a9cd17..e16dacc7bf 100644 --- a/src/data/os/netbsd.cc +++ b/src/data/os/netbsd.cc @@ -28,7 +28,7 @@ */ #include "netbsd.h" -#include "net_stat.h" +#include "../network/net_stat.h" #include "bsdcommon.h" #include diff --git a/src/data/os/netbsd.h b/src/data/os/netbsd.h index e9fb7deb98..384dc1c8be 100644 --- a/src/data/os/netbsd.h +++ b/src/data/os/netbsd.h @@ -12,8 +12,8 @@ #include #include -#include "common.h" -#include "conky.h" +#include "../../common.h" +#include "../../conky.h" #include "bsdcommon.h" diff --git a/src/data/os/openbsd.cc b/src/data/os/openbsd.cc index 0343654c44..3fb3bb0f1e 100644 --- a/src/data/os/openbsd.cc +++ b/src/data/os/openbsd.cc @@ -58,13 +58,13 @@ #include #include -#include "conky.h" -#include "diskio.h" -#include "logging.h" -#include "net_stat.h" +#include "../../conky.h" +#include "../hardware/diskio.h" +#include "../../logging.h" +#include "../network/net_stat.h" #include "openbsd.h" -#include "temphelper.h" -#include "top.h" +#include "../../content/temphelper.h" +#include "../top.h" #define MAXSHOWDEVS 16 @@ -226,7 +226,7 @@ int update_net_stats() { if (ifa->ifa_addr->sa_family != AF_LINK) { continue; } for (iftmp = ifa->ifa_next; - iftmp != nullptr && strcmp(ifa->ifa_name, iftmp->ifa_name) == 0; + iftmp != nullptr && streq(ifa->ifa_name, iftmp->ifa_name); iftmp = iftmp->ifa_next) { if (iftmp->ifa_addr->sa_family == AF_INET) { memcpy(&(ns->addr), iftmp->ifa_addr, iftmp->ifa_addr->sa_len); diff --git a/src/data/os/openbsd.h b/src/data/os/openbsd.h index 56d9496874..93be602336 100644 --- a/src/data/os/openbsd.h +++ b/src/data/os/openbsd.h @@ -10,7 +10,7 @@ #include #include -#include "common.h" +#include "../../common.h" void parse_obsd_sensor(struct text_object *, const char *); void print_obsd_sensors_temp(struct text_object *, char *, unsigned int); diff --git a/src/data/os/solaris.cc b/src/data/os/solaris.cc index 35a0e322da..e4634e7177 100644 --- a/src/data/os/solaris.cc +++ b/src/data/os/solaris.cc @@ -40,14 +40,14 @@ #include #include #include -#include "common.h" -#include "conky.h" -#include "diskio.h" -#include "top.h" +#include "../../common.h" +#include "../../conky.h" +#include "../hardware/diskio.h" +#include "../top.h" #include -#include "net_stat.h" +#include "../network/net_stat.h" #include "solaris.h" static kstat_ctl_t *kstat; @@ -245,7 +245,7 @@ int update_net_stats(void) { memcpy(&(ns->addr), &ifr->ifr_addr, sizeof(ifr->ifr_addr)); /* Skip the loopback interface, it does not have kstat data */ - if (ifr->ifr_flags & IFF_LOOPBACK || strcmp(ifr->ifr_name, "lo0") == 0) + if (ifr->ifr_flags & IFF_LOOPBACK || streq(ifr->ifr_name, "lo0")) continue; last_recv = ns->recv; last_trans = ns->trans; diff --git a/src/data/proc.cc b/src/data/proc.cc index 2807b4c1d4..afb109cba7 100644 --- a/src/data/proc.cc +++ b/src/data/proc.cc @@ -33,9 +33,9 @@ #include #include #include -#include "conky.h" -#include "core.h" -#include "logging.h" +#include "../conky.h" +#include "../core.h" +#include "../logging.h" char *readfile(const char *filename, int *total_read, char showerror) { FILE *file; @@ -95,7 +95,7 @@ int inlist(struct ll_string *front, char *string) { struct ll_string *current; for (current = front; current != nullptr; current = current->next) { - if (strcmp(current->string, string) == 0) { return 1; } + if (streq(current->string, string)) { return 1; } } return 0; } diff --git a/src/data/tailhead.cc b/src/data/tailhead.cc index 9733986591..f014dd52f4 100644 --- a/src/data/tailhead.cc +++ b/src/data/tailhead.cc @@ -33,11 +33,11 @@ #include #include #include -#include "common.h" +#include "../common.h" #include "config.h" -#include "conky.h" -#include "logging.h" -#include "text_object.h" +#include "../conky.h" +#include "../logging.h" +#include "../content/text_object.h" #define MAX_HEADTAIL_LINES 30 #define DEFAULT_MAX_HEADTAIL_USES 2 @@ -138,13 +138,13 @@ static void print_tailhead(const char *type, struct text_object *obj, char *p, if (S_ISFIFO(st.st_mode)) { fd = open_fifo(ht->logfile.c_str(), &ht->reported); if (fd != -1) { - if (strcmp(type, "head") == 0) { + if (streq(type, "head")) { for (i = 0; linescounted < ht->wantedlines; i++) { if (read(fd, p + i, 1) <= 0) { break; } if (p[i] == '\n') { linescounted++; } } p[i] = 0; - } else if (strcmp(type, "tail") == 0) { + } else if (streq(type, "tail")) { i = read(fd, p, p_max_size - 1); tailstring(p, i, ht->wantedlines); } else { @@ -157,7 +157,7 @@ static void print_tailhead(const char *type, struct text_object *obj, char *p, } else { fp = open_file(ht->logfile.c_str(), &ht->reported); if (fp != nullptr) { - if (strcmp(type, "head") == 0) { + if (streq(type, "head")) { for (i = 0; i < ht->wantedlines; i++) { if (fgets(p + endofstring, p_max_size - endofstring, fp) == nullptr) { @@ -165,7 +165,7 @@ static void print_tailhead(const char *type, struct text_object *obj, char *p, } endofstring = strlen(p); } - } else if (strcmp(type, "tail") == 0) { + } else if (streq(type, "tail")) { fseek(fp, -static_cast(p_max_size), SEEK_END); i = fread(p, 1, p_max_size - 1, fp); tailstring(p, i, ht->wantedlines); diff --git a/src/data/timeinfo.cc b/src/data/timeinfo.cc index bd6665b61a..56aca995f5 100644 --- a/src/data/timeinfo.cc +++ b/src/data/timeinfo.cc @@ -36,9 +36,9 @@ #include #include #include -#include "conky.h" -#include "logging.h" -#include "text_object.h" +#include "../conky.h" +#include "../logging.h" +#include "../content/text_object.h" #include diff --git a/src/data/timeinfo.h b/src/data/timeinfo.h index ccf958816f..afe9e227af 100644 --- a/src/data/timeinfo.h +++ b/src/data/timeinfo.h @@ -29,7 +29,7 @@ #ifndef _TIMEINFO_H #define _TIMEINFO_H -#include "setting.hh" +#include "../lua/setting.hh" extern conky::simple_config_setting times_in_seconds; diff --git a/src/data/top.cc b/src/data/top.cc index 493e8b152b..773135a1fa 100644 --- a/src/data/top.cc +++ b/src/data/top.cc @@ -29,8 +29,8 @@ */ #include "top.h" -#include "logging.h" -#include "prioqueue.h" +#include "../logging.h" +#include "../prioqueue.h" /* hash table size - always a power of 2 */ #define HTABSIZE 256 @@ -124,8 +124,8 @@ struct process *get_process_by_name(const char *name) { /* Try matching against the full command line first. If that fails, * fall back to the basename. */ - if (((p->name != nullptr) && (strcmp(p->name, name) == 0)) || - ((p->basename != nullptr) && (strcmp(p->basename, name) == 0))) { + if (((p->name != nullptr) && streq(p->name, name)) || + ((p->basename != nullptr) && streq(p->basename, name))) { return p; } p = p->next; @@ -574,14 +574,14 @@ int parse_top_args(const char *s, const char *arg, struct text_object *obj) { if (s[3] == 0) { td->list = info.cpu; top_cpu = 1; - } else if (strcmp(&s[3], "_mem") == EQUAL) { + } else if (streq(&s[3], "_mem")) { td->list = info.memu; top_mem = 1; - } else if (strcmp(&s[3], "_time") == EQUAL) { + } else if (streq(&s[3], "_time")) { td->list = info.time; top_time = 1; #ifdef BUILD_IOSTATS - } else if (strcmp(&s[3], "_io") == EQUAL) { + } else if (streq(&s[3], "_io")) { td->list = info.io; top_io = 1; #endif /* BUILD_IOSTATS */ @@ -598,30 +598,30 @@ int parse_top_args(const char *s, const char *arg, struct text_object *obj) { td->s = strndup(arg, text_buffer_size.get(*state)); if (sscanf(arg, "%63s %i", buf, &n) == 2) { - if (strcmp(buf, "name") == EQUAL) { + if (streq(buf, "name")) { obj->callbacks.print = &print_top_name; - } else if (strcmp(buf, "cpu") == EQUAL) { + } else if (streq(buf, "cpu")) { obj->callbacks.print = &print_top_cpu; - } else if (strcmp(buf, "pid") == EQUAL) { + } else if (streq(buf, "pid")) { obj->callbacks.print = &print_top_pid; - } else if (strcmp(buf, "mem") == EQUAL) { + } else if (streq(buf, "mem")) { obj->callbacks.print = &print_top_mem; - } else if (strcmp(buf, "time") == EQUAL) { + } else if (streq(buf, "time")) { obj->callbacks.print = &print_top_time; - } else if (strcmp(buf, "mem_res") == EQUAL) { + } else if (streq(buf, "mem_res")) { obj->callbacks.print = &print_top_mem_res; - } else if (strcmp(buf, "mem_vsize") == EQUAL) { + } else if (streq(buf, "mem_vsize")) { obj->callbacks.print = &print_top_mem_vsize; - } else if (strcmp(buf, "uid") == EQUAL) { + } else if (streq(buf, "uid")) { obj->callbacks.print = &print_top_uid; - } else if (strcmp(buf, "user") == EQUAL) { + } else if (streq(buf, "user")) { obj->callbacks.print = &print_top_user; #ifdef BUILD_IOSTATS - } else if (strcmp(buf, "io_read") == EQUAL) { + } else if (streq(buf, "io_read")) { obj->callbacks.print = &print_top_read_bytes; - } else if (strcmp(buf, "io_write") == EQUAL) { + } else if (streq(buf, "io_write")) { obj->callbacks.print = &print_top_write_bytes; - } else if (strcmp(buf, "io_perc") == EQUAL) { + } else if (streq(buf, "io_perc")) { obj->callbacks.print = &print_top_io_perc; #endif /* BUILD_IOSTATS */ } else { diff --git a/src/data/top.h b/src/data/top.h index 41a05244d5..b19a61eb10 100644 --- a/src/data/top.h +++ b/src/data/top.h @@ -40,8 +40,8 @@ * Includes * ******************************************/ -#include "conky.h" -#include "text_object.h" +#include "../conky.h" +#include "../content/text_object.h" #define CPU_THRESHHOLD 0 /* threshold for the cpu diff to appear */ #include #include diff --git a/src/data/user.cc b/src/data/user.cc index c5912262f0..8fb037bdcb 100644 --- a/src/data/user.cc +++ b/src/data/user.cc @@ -33,8 +33,8 @@ #include #include #include -#include "conky.h" -#include "logging.h" +#include "../conky.h" +#include "../logging.h" void print_uid_name(struct text_object *obj, char *p, unsigned int p_max_size) { struct passwd *pw; diff --git a/src/data/users.cc b/src/data/users.cc index f0d2921a3c..76389d96a5 100644 --- a/src/data/users.cc +++ b/src/data/users.cc @@ -30,7 +30,7 @@ #include #include #include -#include "conky.h" +#include "../conky.h" #define BUFLEN 512 diff --git a/src/lua/colour-settings.cc b/src/lua/colour-settings.cc index b17fd1ba4d..a95c357722 100644 --- a/src/lua/colour-settings.cc +++ b/src/lua/colour-settings.cc @@ -24,7 +24,7 @@ #include -#include "colour-settings.h" +#include "colour-settings.hh" namespace priv { void colour_setting::lua_setter(lua::state &l, bool init) { diff --git a/src/lua/colour-settings.hh b/src/lua/colour-settings.hh index 3af8fac1b0..873580720e 100644 --- a/src/lua/colour-settings.hh +++ b/src/lua/colour-settings.hh @@ -23,7 +23,7 @@ */ #pragma once -#include "colours.h" +#include "../content/colours.hh" #include "config.h" #include "setting.hh" diff --git a/src/lua/fonts.cc b/src/lua/fonts.cc index 0cfadba4e0..501ea308ff 100644 --- a/src/lua/fonts.cc +++ b/src/lua/fonts.cc @@ -28,9 +28,9 @@ */ #include "fonts.h" -#include "display-output.hh" -#include "gui.h" -#include "logging.h" +#include "../output/display-output.hh" +#include "../output/gui.h" +#include "../logging.h" unsigned int selected_font = 0; std::vector fonts; diff --git a/src/lua/fonts.h b/src/lua/fonts.h index fde446761c..0e2deeb19f 100644 --- a/src/lua/fonts.h +++ b/src/lua/fonts.h @@ -31,7 +31,7 @@ #include -#include "conky.h" +#include "../conky.h" /* for fonts */ struct font_list { diff --git a/src/lua/llua.cc b/src/lua/llua.cc index ab1516c095..f6557eb275 100644 --- a/src/lua/llua.cc +++ b/src/lua/llua.cc @@ -23,21 +23,21 @@ #include "config.h" #include "build.h" -#include "conky.h" -#include "geometry.h" +#include "../conky.h" +#include "../geometry.h" #include "llua.h" -#include "logging.h" +#include "../logging.h" #ifdef BUILD_GUI -#include "gui.h" +#include "../output/gui.h" #ifdef BUILD_X11 #include "x11-settings.h" -#include "x11.h" +#include "../output/x11.h" #endif /* BUILD_X11 */ #ifdef BUILD_MOUSE_EVENTS -#include "mouse-events.h" +#include "../mouse-events.h" #endif /* BUILD_MOUSE_EVENTS */ #endif /* BUILD_GUI */ diff --git a/src/lua/llua.h b/src/lua/llua.h index f901ba0823..282f035aad 100644 --- a/src/lua/llua.h +++ b/src/lua/llua.h @@ -31,10 +31,10 @@ extern "C" { } #include -#include "geometry.h" +#include "../geometry.h" #ifdef BUILD_MOUSE_EVENTS -#include "mouse-events.h" +#include "../mouse-events.h" #endif /* BUILD_MOUSE_EVENTS */ #define LUAPREFIX "conky_" diff --git a/src/lua/lua-config.cc b/src/lua/lua-config.cc index b05ee4e566..2da47e59fd 100644 --- a/src/lua/lua-config.cc +++ b/src/lua/lua-config.cc @@ -24,7 +24,7 @@ #include "lua-config.hh" -#include "data-source.hh" +#include "../data/data-source.hh" #include "setting.hh" namespace conky { diff --git a/src/lua/setting.hh b/src/lua/setting.hh index 195dccbbd4..c964ace6ef 100644 --- a/src/lua/setting.hh +++ b/src/lua/setting.hh @@ -27,7 +27,7 @@ #include #include -#include "logging.h" +#include "../logging.h" #include "luamm.hh" namespace conky { diff --git a/src/lua/x11-settings.cc b/src/lua/x11-settings.cc index 63e971b425..9307860808 100644 --- a/src/lua/x11-settings.cc +++ b/src/lua/x11-settings.cc @@ -1,8 +1,8 @@ #include "x11-settings.h" -#include "x11.h" +#include "../output/x11.h" -#include "conky-imlib2.h" +#include "../conky-imlib2.h" #include diff --git a/src/main.cc b/src/main.cc index b7a8545fed..2a557100b0 100644 --- a/src/main.cc +++ b/src/main.cc @@ -33,31 +33,31 @@ #include "build.h" #include "config.h" #include "conky.h" -#include "display-output.hh" -#include "lua-config.hh" +#include "output/display-output.hh" +#include "lua/lua-config.hh" #ifdef BUILD_X11 -#include "x11.h" +#include "output/x11.h" #endif /* BUILD_X11 */ #ifdef BUILD_CURL -#include "ccurl_thread.h" +#include "data/network/ccurl_thread.h" #endif /* BUILD_CURL */ #if defined(__linux__) -#include "linux.h" +#include "data/os/linux.h" #endif /* Linux */ #if defined(__FreeBSD__) || defined(__FreeBSD_kernel__) -#include "freebsd.h" +#include "data/os/freebsd.h" #endif /* FreeBSD */ #if defined(__NetBSD__) -#include "netbsd.h" +#include "data/os/netbsd.h" #endif /* NetBSD */ #if defined(__HAIKU__) -#include "haiku.h" +#include "data/os/haiku.h" #endif /* Haiku */ #ifdef BUILD_BUILTIN_CONFIG diff --git a/src/mouse-events.cc b/src/mouse-events.cc index afdab5a0b7..ee5c0adf96 100644 --- a/src/mouse-events.cc +++ b/src/mouse-events.cc @@ -343,9 +343,9 @@ bool fixed_valuator_relative(Display *display, XIDeviceInfo *device, for (auto c = value; *c; ++c) *c = tolower(*c); bool relative = false; - if (strcmp(reinterpret_cast(value), "relative") == 0) { + if (streq(reinterpret_cast(value), "relative")) { relative = true; - } else if (strcmp(reinterpret_cast(value), "absolute") != 0) { + } else if (!streq(reinterpret_cast(value), "absolute")) { NORM_ERR( "unknown '%s' option value: '%s', expected 'absolute' or " "'relative'; " diff --git a/src/mouse-events.h b/src/mouse-events.h index 8ef4822931..116fee63ab 100644 --- a/src/mouse-events.h +++ b/src/mouse-events.h @@ -39,10 +39,13 @@ #include #endif /* BUILD_XINPUT */ -extern "C" { #ifdef BUILD_X11 #include +#endif /* BUILD_X11 */ +extern "C" { + +#ifdef BUILD_X11 #ifdef BUILD_XINPUT #include #include diff --git a/src/output/display-console.cc b/src/output/display-console.cc index 0a08980916..293cfff4ad 100644 --- a/src/output/display-console.cc +++ b/src/output/display-console.cc @@ -26,7 +26,7 @@ #include -#include "conky.h" +#include "../conky.h" #include "display-console.hh" #include "nc.h" diff --git a/src/output/display-console.hh b/src/output/display-console.hh index d366c1220c..e977a0bc90 100644 --- a/src/output/display-console.hh +++ b/src/output/display-console.hh @@ -28,7 +28,7 @@ #include #include "display-output.hh" -#include "luamm.hh" +#include "../lua/luamm.hh" namespace conky { diff --git a/src/output/display-file.cc b/src/output/display-file.cc index aed6a6c394..af7809205e 100644 --- a/src/output/display-file.cc +++ b/src/output/display-file.cc @@ -26,7 +26,7 @@ #include -#include "conky.h" +#include "../conky.h" #include "display-file.hh" #include "nc.h" diff --git a/src/output/display-file.hh b/src/output/display-file.hh index bc64372913..901cbdc8b1 100644 --- a/src/output/display-file.hh +++ b/src/output/display-file.hh @@ -28,7 +28,7 @@ #include #include "display-output.hh" -#include "luamm.hh" +#include "../lua/luamm.hh" namespace conky { diff --git a/src/output/display-http.cc b/src/output/display-http.cc index c93e8e6b52..cb6d0fadbe 100644 --- a/src/output/display-http.cc +++ b/src/output/display-http.cc @@ -26,7 +26,7 @@ #include -#include "conky.h" +#include "../conky.h" #include "display-http.hh" #include diff --git a/src/output/display-http.hh b/src/output/display-http.hh index 3000286005..36b241c765 100644 --- a/src/output/display-http.hh +++ b/src/output/display-http.hh @@ -30,7 +30,7 @@ #include #include "display-output.hh" -#include "luamm.hh" +#include "../lua/luamm.hh" namespace conky { diff --git a/src/output/display-ncurses.cc b/src/output/display-ncurses.cc index 05f8540350..87d4dc535b 100644 --- a/src/output/display-ncurses.cc +++ b/src/output/display-ncurses.cc @@ -26,8 +26,8 @@ #include -#include "colours.h" -#include "conky.h" +#include "../conky.h" +#include "../content/colours.hh" #include "display-ncurses.hh" #include "gui.h" #include "nc.h" diff --git a/src/output/display-ncurses.hh b/src/output/display-ncurses.hh index 2d1c1a0b87..619939b923 100644 --- a/src/output/display-ncurses.hh +++ b/src/output/display-ncurses.hh @@ -29,9 +29,9 @@ #include #include -#include "colours.h" +#include "../content/colours.hh" +#include "../lua/luamm.hh" #include "display-console.hh" -#include "luamm.hh" namespace conky { diff --git a/src/output/display-output.hh b/src/output/display-output.hh index 55cc83b61a..8d5bfe80c8 100644 --- a/src/output/display-output.hh +++ b/src/output/display-output.hh @@ -30,9 +30,9 @@ #include #include -#include "colours.h" -#include "logging.h" -#include "luamm.hh" +#include "../content/colours.hh" +#include "../logging.h" +#include "../lua/luamm.hh" namespace conky { diff --git a/src/output/display-wayland.cc b/src/output/display-wayland.cc index f7c7a5009c..2de5bf9317 100644 --- a/src/output/display-wayland.cc +++ b/src/output/display-wayland.cc @@ -47,19 +47,19 @@ #include #include -#include "conky.h" +#include "../conky.h" #include "display-output.hh" -#include "geometry.h" +#include "../geometry.h" #include "gui.h" -#include "llua.h" -#include "logging.h" +#include "../lua/llua.h" +#include "../logging.h" -#include "fonts.h" +#include "../lua/fonts.h" #ifdef BUILD_MOUSE_EVENTS #include #include -#include "mouse-events.h" +#include "../mouse-events.h" #endif #pragma GCC diagnostic ignored "-Wunused-parameter" @@ -353,24 +353,24 @@ const struct wl_output_listener output_listener = { void registry_handle_global(void *data, struct wl_registry *registry, uint32_t name, const char *interface, uint32_t version) { - if (strcmp(interface, "wl_compositor") == 0) { + if (streq(interface, "wl_compositor")) { wl_globals.compositor = static_cast( wl_registry_bind(registry, name, &wl_compositor_interface, 3)); - } else if (strcmp(interface, "wl_shm") == 0) { + } else if (streq(interface, "wl_shm")) { wl_globals.shm = static_cast( wl_registry_bind(registry, name, &wl_shm_interface, 1)); - } else if (strcmp(interface, "wl_seat") == 0) { + } else if (streq(interface, "wl_seat")) { wl_globals.seat = static_cast( wl_registry_bind(registry, name, &wl_seat_interface, 1)); - } else if (strcmp(interface, "wl_output") == 0) { + } else if (streq(interface, "wl_output")) { wl_globals.output = static_cast( wl_registry_bind(registry, name, &wl_output_interface, 2)); wl_output_add_listener(wl_globals.output, &output_listener, nullptr); - } else if (strcmp(interface, "xdg_wm_base") == 0) { + } else if (streq(interface, "xdg_wm_base")) { wl_globals.shell = static_cast( wl_registry_bind(registry, name, &xdg_wm_base_interface, 1)); xdg_wm_base_add_listener(wl_globals.shell, &xdg_wm_base_listener, nullptr); - } else if (strcmp(interface, "zwlr_layer_shell_v1") == 0) { + } else if (streq(interface, "zwlr_layer_shell_v1")) { wl_globals.layer_shell = static_cast( wl_registry_bind(registry, name, &zwlr_layer_shell_v1_interface, 1)); } diff --git a/src/output/display-wayland.hh b/src/output/display-wayland.hh index 0cc2098b4f..d8dfbbf038 100644 --- a/src/output/display-wayland.hh +++ b/src/output/display-wayland.hh @@ -29,9 +29,9 @@ #include #include -#include "colours.h" +#include "../content/colours.hh" +#include "../lua/luamm.hh" #include "display-output.hh" -#include "luamm.hh" #include "wl.h" namespace conky { diff --git a/src/output/display-x11.cc b/src/output/display-x11.cc index 1f0e741992..1e3a580685 100644 --- a/src/output/display-x11.cc +++ b/src/output/display-x11.cc @@ -39,12 +39,12 @@ #ifdef BUILD_XDAMAGE #include #endif /* BUILD_XDAMAGE */ -#include "fonts.h" +#include "../lua/fonts.h" #ifdef BUILD_IMLIB2 -#include "conky-imlib2.h" +#include "../conky-imlib2.h" #endif /* BUILD_IMLIB2 */ #if defined(BUILD_MOUSE_EVENTS) || defined(BUILD_XINPUT) -#include "mouse-events.h" +#include "../mouse-events.h" #endif /* BUILD_MOUSE_EVENTS || BUILD_XINPUT */ #ifdef BUILD_XINPUT #include @@ -61,14 +61,14 @@ #include #include -#include "colours.h" -#include "conky.h" -#include "geometry.h" +#include "../conky.h" +#include "../content/colours.hh" +#include "../geometry.h" +#include "../logging.h" +#include "../lua/llua.h" #include "gui.h" -#include "llua.h" -#include "logging.h" -#include "x11-settings.h" +#include "../lua/x11-settings.h" #include "x11.h" // TODO: cleanup externs (move to conky.h ?) diff --git a/src/output/display-x11.hh b/src/output/display-x11.hh index c483739730..58379195e5 100644 --- a/src/output/display-x11.hh +++ b/src/output/display-x11.hh @@ -30,7 +30,7 @@ #include #include "display-output.hh" -#include "luamm.hh" +#include "../lua/luamm.hh" namespace conky { diff --git a/src/output/gui.cc b/src/output/gui.cc index f73265d0a5..7e063736b4 100644 --- a/src/output/gui.cc +++ b/src/output/gui.cc @@ -27,14 +27,13 @@ * */ #include "gui.h" -#include "colour-settings.h" -#include "common.h" +#include "../common.h" #include "config.h" -#include "conky.h" -#include "logging.h" +#include "../conky.h" +#include "../logging.h" #ifdef BUILD_X11 -#include "x11-settings.h" +#include "../lua/x11-settings.h" #endif /* BUILD_X11 */ #ifdef BUILD_WAYLAND @@ -42,7 +41,7 @@ #endif /* BUILD_WAYLAND */ // #ifdef BUILD_IMLIB2 -// #include "conky-imlib2.h" +// #include "../conky-imlib2.h" // #endif /* BUILD_IMLIB2 */ #ifndef OWN_WINDOW #include diff --git a/src/output/gui.h b/src/output/gui.h index 98ffaf5a8a..6ae1d53227 100644 --- a/src/output/gui.h +++ b/src/output/gui.h @@ -26,10 +26,10 @@ #include "config.h" -#include "geometry.h" -#include "setting.hh" +#include "../geometry.h" +#include "../lua/setting.hh" -#include "colour-settings.h" +#include "../lua/colour-settings.hh" /// @brief Represents alignment on a single axis. enum class axis_align : uint8_t { diff --git a/src/output/nc.h b/src/output/nc.h index ee4030c1b5..1d2f5fe7bd 100644 --- a/src/output/nc.h +++ b/src/output/nc.h @@ -32,7 +32,7 @@ #include -#include "setting.hh" +#include "../lua/setting.hh" #ifdef LEAKFREE_NCURSES extern "C" { diff --git a/src/output/wl.cc b/src/output/wl.cc index d5487cea2e..1ddac006fc 100644 --- a/src/output/wl.cc +++ b/src/output/wl.cc @@ -30,7 +30,7 @@ #include #include -#include "conky.h" +#include "../conky.h" #include "wl.h" #ifdef BUILD_WAYLAND diff --git a/src/output/wl.h b/src/output/wl.h index 6123680ddc..e693e27bf9 100644 --- a/src/output/wl.h +++ b/src/output/wl.h @@ -38,7 +38,7 @@ #include -#include "setting.hh" +#include "../lua/setting.hh" namespace priv { class out_to_wayland_setting : public conky::simple_config_setting { diff --git a/src/output/x11-color.cc b/src/output/x11-color.cc index fa081abf70..08d7a0fe6a 100644 --- a/src/output/x11-color.cc +++ b/src/output/x11-color.cc @@ -1,4 +1,4 @@ -#include "colours.h" +#include "../content/colours.hh" #include diff --git a/src/output/x11.cc b/src/output/x11.cc index db6c7a5aca..88c5209c41 100644 --- a/src/output/x11.cc +++ b/src/output/x11.cc @@ -29,7 +29,7 @@ #include "config.h" -#include "x11-settings.h" +#include "../lua/x11-settings.h" #include "x11.h" #include @@ -38,14 +38,14 @@ #undef max #include -#include "common.h" -#include "conky.h" -#include "geometry.h" +#include "../common.h" +#include "../conky.h" +#include "../geometry.h" #include "gui.h" -#include "logging.h" +#include "../logging.h" #ifdef BUILD_XINPUT -#include "mouse-events.h" +#include "../mouse-events.h" #include #endif @@ -75,7 +75,7 @@ extern "C" { #include #ifdef BUILD_IMLIB2 -#include "conky-imlib2.h" +#include "../conky-imlib2.h" #endif /* BUILD_IMLIB2 */ #ifdef BUILD_XFT #include diff --git a/src/output/x11.h b/src/output/x11.h index 7108cfc410..02dc17bc06 100644 --- a/src/output/x11.h +++ b/src/output/x11.h @@ -49,9 +49,9 @@ #include // TODO: remove lua requirement from x11_init_window -#include "llua.h" +#include "../lua/llua.h" -#include "geometry.h" +#include "../geometry.h" #include "gui.h" /* true if use_argb_visual=true and argb visual was found*/ diff --git a/tests/test-algebra.cc b/tests/test-algebra.cc index fcd0d48f96..6f7c787bc8 100644 --- a/tests/test-algebra.cc +++ b/tests/test-algebra.cc @@ -1,6 +1,6 @@ #include "catch2/catch.hpp" -#include +#include #include TEST_CASE("GetMatchTypeTest - ValidOperators") { diff --git a/tests/test-colours.cc b/tests/test-colours.cc index 886f13b898..ecd3191385 100644 --- a/tests/test-colours.cc +++ b/tests/test-colours.cc @@ -1,6 +1,6 @@ #include "catch2/catch.hpp" -#include +#include #include TEST_CASE("parse_color correctly parses colours", "[colours][parse_color]") { diff --git a/tests/test-conky.cc b/tests/test-conky.cc index a1d841b0c9..f4c32fa02d 100644 --- a/tests/test-conky.cc +++ b/tests/test-conky.cc @@ -27,8 +27,9 @@ */ #include "catch2/catch.hpp" -#include "conky.h" -#include "lua-config.hh" +// must be separate; X11 breaks global namespace with Always and None (again) +#include +#include TEST_CASE("Expressions can be evaluated", "[evaluate]") { state = std::make_unique(); diff --git a/tests/test-darwin.cc b/tests/test-darwin.cc index b598706d47..96cdc62e64 100644 --- a/tests/test-darwin.cc +++ b/tests/test-darwin.cc @@ -28,7 +28,7 @@ #include "catch2/catch.hpp" -#include +#include TEST_CASE("get_entropy_avail returns 1", "[get_entropy_avail]") { unsigned int unused = 0; diff --git a/tests/test-diskio.cc b/tests/test-diskio.cc index e5312834c0..d094e6cf9a 100644 --- a/tests/test-diskio.cc +++ b/tests/test-diskio.cc @@ -30,7 +30,7 @@ #include #include -#include +#include #if BUILD_X11 TEST_CASE("diskiographval returns correct value") { diff --git a/tests/test-fs.cc b/tests/test-fs.cc index 5533f807c0..977d8fbc20 100644 --- a/tests/test-fs.cc +++ b/tests/test-fs.cc @@ -28,7 +28,7 @@ #include "catch2/catch.hpp" -#include +#include TEST_CASE("fs_free_percentage returns correct value") { struct text_object obj; diff --git a/tests/test-gradient.cc b/tests/test-gradient.cc index fee3247ac5..40812d3873 100644 --- a/tests/test-gradient.cc +++ b/tests/test-gradient.cc @@ -28,9 +28,9 @@ #include "catch2/catch.hpp" -#include #include -#include +#include +#include #include #include diff --git a/tests/test-graph.cc b/tests/test-graph.cc index 4478b001d1..5a1707e30b 100644 --- a/tests/test-graph.cc +++ b/tests/test-graph.cc @@ -28,9 +28,10 @@ #include #include "catch2/catch.hpp" -#include "conky.h" -#include "lua-config.hh" -#include "specials.h" + +#include +#include +#include #ifdef BUILD_GUI @@ -54,7 +55,7 @@ struct graph { static std::pair test_parse(const char *s) { struct text_object obj; - bool result = scan_graph(&obj, s, default_scale,FALSE); + bool result = scan_graph(&obj, s, default_scale, false); auto g = static_cast(obj.special_data); struct graph graph = *g; free(g); diff --git a/tests/test-linux.cc b/tests/test-linux.cc index 79ef452382..a3b0b787d3 100644 --- a/tests/test-linux.cc +++ b/tests/test-linux.cc @@ -28,7 +28,7 @@ #include "catch2/catch.hpp" -#include +#include TEST_CASE("get_entropy_avail returns 0", "[get_entropy_avail]") { unsigned int unused = 0;