Reformatted all code
authorKevin Lyles <iqgryn@users.sourceforge.net>
Wed, 20 Feb 2008 20:30:45 +0000 (20:30 +0000)
committerKevin Lyles <iqgryn@users.sourceforge.net>
Wed, 20 Feb 2008 20:30:45 +0000 (20:30 +0000)
git-svn-id: https://conky.svn.sourceforge.net/svnroot/conky/trunk/conky1@1007 7f574dfc-610e-0410-a909-a81674777703

51 files changed:
AUTHORS
ChangeLog
NEWS
README.cvs-version
autogen.sh
configure.ac.in
debian/copyright
doc/Makefile.am
doc/README.docs
doc/command_options.xml
doc/config_settings.xml
doc/config_settings.xsl
doc/conky.1
doc/docs.xml
doc/variables.xml
doc/variables.xsl
extras/nano/README
extras/vim/syntax/conkyrc.vim
m4/pkg.m4
src/Makefile.am
src/audacious.c
src/audacious.h
src/bmpx.c
src/common.c
src/conky.c
src/conky.h
src/freebsd.c
src/fs.c
src/hddtemp.c
src/libmpdclient.c
src/libmpdclient.h
src/libtcp-portmon.c
src/libtcp-portmon.h
src/linux.c
src/mail.c
src/mboxscan.c
src/mboxscan.h
src/mixer.c
src/mpd.c
src/netbsd.c
src/openbsd.c
src/prss.c
src/prss.h
src/rss.c
src/solaris.c
src/timed_thread.c
src/timed_thread.h
src/top.c
src/top.h
src/x11.c
src/xmms2.c

diff --git a/AUTHORS b/AUTHORS
index 77d1d18..2ab67bd 100644 (file)
--- a/AUTHORS
+++ b/AUTHORS
@@ -194,8 +194,8 @@ Peter Tarjan <ptarjan at citromail dot hu>
   IBM acpi support patch
   SMP support for freq stuff
   CPU voltage patch
-  
-Petr Holub <hopet@users.sourceforge.net>  
+
+Petr Holub <hopet@users.sourceforge.net>
   fix autotools on FreeBSD in autogen.sh
   Improved battery readout on FreeBSD
 
index e4ef730..c54a935 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
                cumulative CPU time of a process.
                4) Simplified integer rounding.
                5) Fixed the window width when a goto is used.
-               6) Fixed the window width when an offset is used.               
+               6) Fixed the window width when an offset is used.
                (thanks Kevin Lyles).
 
 2007-12-31
-       * Applied submitted patches: 
+       * Applied submitted patches:
                1) to suport Debian's kFreeBSD;
-               2) to use realtime clock in timed threads and 
-               3) to fix get_ibm_acpi_volume zero value bug 
+               2) to use realtime clock in timed threads and
+               3) to fix get_ibm_acpi_volume zero value bug
                (thanks Kapil Hari Paranjape).
 
 2007-11-22
@@ -33,7 +33,7 @@
        * Added Gentoo USE flag audacious-legacy for Audacious legacy support.
 
 2007-11-16
-       * Added support for Audacious 1.4.0 and legacy versions via 
+       * Added support for Audacious 1.4.0 and legacy versions via
                        --enable-audacious=yes|no|legacy.
 
 2007-11-14
@@ -70,7 +70,7 @@
 2007-09-01
        * Improved performance slightly.
        * Added 'music_player_interval' config option to specify an update interval for
-                       music player threads (currently honored by mpd and audacious).
+                       music player threads (currently honored by mpd and audacious).
        * Fixed some minor memory leaks associated with SIGUSR1.
        * Zero out imap and pop3 stuff when the connection fails.
 
 2006-12-22
        * client/server infrastructure and prototype for linux only (so far):
                - requires libdexter (http://sourceforge.net/projects/libdexter)
-               and the dxt-sysinfo plugin (svn only at the moment).
+               and the dxt-sysinfo plugin (svn only at the moment).
        * new config items:
                - dexter_client yes/no
                - dexter_server yes/no
                - wm_class_name (use own_window_class, same function)
        * configure changes:
          --disable-network (default=yes) with auto-detection for libdexter.
-               - remove useless --enable-proc-uptime (PROC_UPTIME never referenced).  
+               - remove useless --enable-proc-uptime (PROC_UPTIME never referenced).
                        HAVE_SYSINFO and others determine if /proc/uptime is used.
                - silently disable xft, double-buffer and xdamage if no x11.
                - change enable/disable labels to reflect defaults accurately.
                  them into AC_CHECK_FUNCS.
        * allow decorated, own_window=yes windows to be given input focus by WM:
                - do not pass button clicks through to desktop in this scenario as conky
-                 immediately loses focus.  
+                 immediately loses focus.
 
 2006-12-13
        * Clarify LGPL license on timed_thread modules.
 2006-12-09
        * Replaced hash module used by libtcp-portmon with GLib's GHashTable,
        due to licensing issue noted by Fedora Core packagers.
-       * Eliminated config items: 
+       * Eliminated config items:
                min_port_monitors,
                min_port_monitor_connections
        * Added config item:
        feature request #1600631.
 
 2006-11-28
-       * Rearrange retry attempts in pop3 and imap code, removing sleep() 
+       * Rearrange retry attempts in pop3 and imap code, removing sleep()
        calls which cause the whole process to sleep, not just the thread.
 
 2006-11-22
 
 2006-11-13
        * Use pthread_cond_timedwait() instead of sleep() in audacious
-       thread.  Will convert all worker threads to this timing method.  
+       thread.  Will convert all worker threads to this timing method.
 
 2006-11-12
        * Fix freebsd build error.
        * Added Hellf[i]re's nano syntax coloring script to svn.
 
 2006-11-03
-       * Removed support for Xmms, BMP and Infopipe from conky.  
-       The Xmms and Bmp players are projects are dead and distros such 
-       as Gentoo are slating them for removal.  
+       * Removed support for Xmms, BMP and Infopipe from conky.
+       The Xmms and Bmp players are projects are dead and distros such
+       as Gentoo are slating them for removal.
        * Added support for Audacious using new audacious vars.
 
 2006-10-18
 
 2006-09-28
        * Use pkg-config instead of xft-config.
-       * Fix last line bug which had required padding text with extra blank line 
+       * Fix last line bug which had required padding text with extra blank line
        to see text on last line.
 
 2006-09-01
        Holub <hopet@users.sourceforge.net>)
 
 2006-03-15
-       * Removed bmp-infopipe dependency from 1.4.1 and 1.9999 ebuilds for Gentoo 
+       * Removed bmp-infopipe dependency from 1.4.1 and 1.9999 ebuilds for Gentoo
        (Gentoo bug# 125226).
        * Fixed subversion ebuild for conky1 (1.9999) so it pulls the new trunk
        path for conky1.
        * on_bottom and wm_class_name deprecated (they do nothing)
 
 2006-02-13
-       * Fixed typo bug in portmon code that caused incorrect monitor data 
+       * Fixed typo bug in portmon code that caused incorrect monitor data
        to be displayed.
 
 2006-02-12
        * Added freedesktop.org extended window manager hints (EWMH)
        for window type NORMAL and state's STICKY/SKIP_PAGER/SKIP_TASKBAR.
        Fixes stacking order issues with freedesktop-compliant wm's,
-       such as XFCE4+. 
+       such as XFCE4+.
 
 2006-01-25
        * Fixed stupid graph code (it still sucks) sf.net bug 1372962
        * Fixed sf.net bug 1367745
 
 2005-11-30
-       * Fixed sf.net bugs 1369607, 1367735 and gentoo bug 113921, 
+       * Fixed sf.net bugs 1369607, 1367735 and gentoo bug 113921,
          all variations of the same array out of bounds issue.
        * "Fixed" code in fs.c and conky.c to make fs stats match those displayed by df (affects reporting against ext3 filesystems only)
 
-2005-11-27 
+2005-11-27
        * new code in linux.c and top.c to calculate CPU % correctly on 2.6 kernels.
 
 2005-11-24
 2005-11-12
        * Replaced bitwise copy of tcp_connection_t with function
        copy_tcp_connection().
-       * Changed call interfaces for get_acpi_fan(), get_acpi_ac_adapter(),   
+       * Changed call interfaces for get_acpi_fan(), get_acpi_ac_adapter(),
        get_freq(), get_freq_dynamic(), get_adt746x_cpu(), get_adt746x_fan(),
        eliminating all mallocs.  pkovacs.  See bug 1355470.
 
        options $addr and $linkstatus (please test!), as well as fixed a mem
        leak in this patch
        * adt746x fix, thanks to dan-h on sf.net
-       * Added mldonkey support patch, thanks Lucas Brutschy on sf.net 
+       * Added mldonkey support patch, thanks Lucas Brutschy on sf.net
        * Added patch to allow hex colour values, thanks roiban adi on sf.net
        * Added if constructs patch, thanks Lucas Brutschy on sf.net
        * Fixed bug in tab code (hopefully for the last time)
 
 =========================================================================
 =========================================================================
-       
+
 2005-07-05
        * Conky 1.1 released
 
 
 =========================================================================
 =========================================================================
-       
+
 2005-06-21
        * Version 1.0. Conky is born from the ashes of torsmo. Main site:
        http://conky.sf.net/
diff --git a/NEWS b/NEWS
index 9b5dc4b..cb6bcce 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -1,31 +1,31 @@
 Summary of changes for Conky release 1.4.5:
 -------------------------------------------
-Added config items: 
-- max_specials 
-- max_port_monitor_connections 
-Removed config items: 
-- min_port_monitors 
-- min_port_monitor_connections 
-Added variables: 
-- entropy_avail 
-- entropy_poolsize 
-- entropy_bar 
-Added length specifier to audacious_title. 
-Split battery var into: 
-- battery and battery_time 
-Fixed broken texeci variable. 
-Fixed build error with --disable-x11. 
-Fixed build error with --disable-xdamage. 
-Fixed acpi battery issues. 
-Fixed mem var overflows when >= 4GB. 
-Close pop3/imap sockets properly. 
-Improved internal thread handling. 
-Converted tcp_portmon internal hash to GLib  
+Added config items:
+- max_specials
+- max_port_monitor_connections
+
+Removed config items:
+- min_port_monitors
+- min_port_monitor_connections
+
+Added variables:
+- entropy_avail
+- entropy_poolsize
+- entropy_bar
+
+Added length specifier to audacious_title.
+
+Split battery var into:
+- battery and battery_time
+
+Fixed broken texeci variable.
+Fixed build error with --disable-x11.
+Fixed build error with --disable-xdamage.
+Fixed acpi battery issues.
+Fixed mem var overflows when >= 4GB.
+Close pop3/imap sockets properly.
+Improved internal thread handling.
+Converted tcp_portmon internal hash to GLib
 for GPL compatibility.
 
 
@@ -42,10 +42,10 @@ Summary of changes for Conky release 1.4.3:
 
 * Removed support for dead projects: Xmms 1, Beep Media Player (BMP) and the Infopipe plugin.
   - Removed the following related configuration items:
-       - xmms_player
+       - xmms_player
   - Removed the following related variables:
        - xmms_bar
-       - xmms_bitrate
+       - xmms_bitrate
        - xmms_channels
        - xmms_filename
        - xmms_frequency
index 58e2f9c..f187228 100644 (file)
@@ -1,29 +1,29 @@
 THESE INSTRUCTIONS ARE ONLY IF "sh autogen.sh" DOESN'T WORK!!!
 
-First, read the README. This contains instructions specific to building conky 
-fresh from a CVS checkout: 
+First, read the README. This contains instructions specific to building conky
+fresh from a CVS checkout:
 
-* As the README says, you need to have the X   development libraries installed. 
+* As the README says, you need to have the X   development libraries installed.
        This should be a package along the lines of libx11-dev or xorg-x11-dev .
 * Conky requires three "auto-tools", with at least the specific version numbers.
        Make sure these are installed:
-       
+
        aclocal-1.9
        automake-1.9
        autoconf-2.59
 
-* In the directory where you checked out conky from CVS, 
-       run "aclocal", "automake", and then "autoconf". 
+* In the directory where you checked out conky from CVS,
+       run "aclocal", "automake", and then "autoconf".
        Make sure you run those commands with the latest versions...
-       it is very possible that older versions are installed, and 
+       it is very possible that older versions are installed, and
        plain "automake" really means automake-1.4, not what we want,
        but "automake-1.9" instead.
        Use the "--version" option to check the program version, i.e.
-       "autoconf --version". 
-* After that, it's the familiar 
+       "autoconf --version".
+* After that, it's the familiar
 
-       ./configure 
-       make 
+       ./configure
+       make
        make install
 
        You might have to do the last step as root.
index 8ff0c33..53dbb88 100755 (executable)
@@ -38,7 +38,7 @@ LIBTOOLIZE=${LIBTOOLIZE:-libtoolize}
 if test "$1" != "" && test -d "$1/.svn"; then
     revision=`LC_ALL=C svn info $1 | awk '/^Revision: / {printf "%05d\n", $2}'`;
 elif test -d ".svn"; then
-    revision=`LC_ALL=C svn info | awk '/^Revision: / {printf "%05d\n", $2}'`; 
+    revision=`LC_ALL=C svn info | awk '/^Revision: / {printf "%05d\n", $2}'`;
 else
     revision="NONE"; fi
 
index edd9933..5a5f11f 100644 (file)
@@ -1,4 +1,4 @@
-dnl $Id$ 
+dnl $Id$
 
 dnl major, minor and micro version macros.
 m4_define([conky_version_major], [1])
@@ -6,9 +6,9 @@ m4_define([conky_version_minor], [5])
 m4_define([conky_version_micro], [0])
 m4_define([conky_version_tag], [svn]) dnl [] for releases
 m4_define([conky_version_revision],[r@REVISION@])
-m4_define([conky_version], 
+m4_define([conky_version],
     [conky_version_major().conky_version_minor().conky_version_micro()ifelse(
-      conky_version_tag(), [svn], 
+      conky_version_tag(), [svn],
       [-conky_version_tag()-conky_version_revision()],
       [ifelse(conky_version_tag(), [], [], [-conky_version_tag()])])])
 
@@ -94,7 +94,7 @@ dnl OWN_WINDOW option
 dnl
 
 AC_ARG_ENABLE([own_window],
-              AC_HELP_STRING([--disable-own-window], 
+              AC_HELP_STRING([--disable-own-window],
                              [disable if you do not want support for creating own window @<:@default=yes@:>@]),
               [dah="$enableval"], [dah=yes])
 
@@ -108,7 +108,7 @@ dnl Audacious Media Player
 dnl
 
 AC_ARG_ENABLE([audacious],
-              AC_HELP_STRING([--enable-audacious=[[yes|no|legacy]]], 
+              AC_HELP_STRING([--enable-audacious=[[yes|no|legacy]]],
                              [enable audacious player support @<:@default=no@:>@]),
               [want_audacious="$enableval"], [want_audacious=no])
 
@@ -119,7 +119,7 @@ if test x$want_audacious = xyes; then
       LIBS="$LIBS $AUDACIOUS_LIBS"
       save_CPPFLAGS="$CPPFLAGS"
       CPPFLAGS="$AUDACIOUS_CFLAGS -I`pkg-config --variable=audacious_include_dir audacious`/audacious"
-      AC_CHECK_HEADERS([audacious/audctrl.h audacious/dbus.h glib.h glib-object.h], 
+      AC_CHECK_HEADERS([audacious/audctrl.h audacious/dbus.h glib.h glib-object.h],
                        [], AC_MSG_ERROR([required header(s) not found]))
       CPPFLAGS="$save_CPPFLAGS"
       AC_DEFINE(AUDACIOUS, 1, [Define for Audacious support])
@@ -159,7 +159,7 @@ dnl Hddtemp
 dnl
 
 AC_ARG_ENABLE([hddtemp],
-              AC_HELP_STRING([--disable-hddtemp], 
+              AC_HELP_STRING([--disable-hddtemp],
                              [disable if you do not want hddtemp support @<:@default=yes@:>@]),
               [want_hddtemp="$enableval"], [want_hddtemp=yes])
 
@@ -257,7 +257,7 @@ dnl PORT_MONITORS
 dnl
 
 AC_ARG_ENABLE([portmon],
-              AC_HELP_STRING([--disable-portmon], 
+              AC_HELP_STRING([--disable-portmon],
                              [disable if you do not want tcp (ip4) port monitoring @<:@default=yes@:>@]),
               [want_portmon="$enableval"], [want_portmon=yes])
 
@@ -266,7 +266,7 @@ if test x"$want_portmon" = xyes; then
       AC_MSG_NOTICE([port monitors not supported on $uname... disabling])
       want_portmon=no
   else
-        AC_CHECK_HEADERS([netdb.h netinet/in.h netinet/tcp.h sys/socket.h arpa/inet.h], [], 
+        AC_CHECK_HEADERS([netdb.h netinet/in.h netinet/tcp.h sys/socket.h arpa/inet.h], [],
            [PORT_MONITORS_MISSING=yes])
         if test x"$PORT_MONITORS_MISSING" = xyes; then
               AC_MSG_ERROR([missing a needed network header for port monitoring])
@@ -293,7 +293,7 @@ dnl
 dnl debug
 dnl
 
-AC_ARG_ENABLE([debug], 
+AC_ARG_ENABLE([debug],
               AC_HELP_STRING([--enable-debug], [compile with debug symbols @<:@default=no@:>@]),
               [want_debug="$enableval"], [want_debug=no])
 
@@ -330,14 +330,14 @@ if test "x$want_x11" = "xyes"; then
     fi
     AC_DEFINE(X11, 1, [Define if you want to use X11])
 fi
-  
+
 
 dnl
 dnl Xext Double-buffering Extension
 dnl
 
 AC_ARG_ENABLE([double_buffer],
-              AC_HELP_STRING([--disable-double-buffer], 
+              AC_HELP_STRING([--disable-double-buffer],
                              [disable for no Xdbe double-buffering support @<:@default=yes@:>@]),
               [want_double_buffer="$enableval"], [want_double_buffer=yes])
 
@@ -345,14 +345,14 @@ if test "x$want_double_buffer" = "xyes"; then
     if test "x$want_x11" != "xyes"; then
       dnl silently disable if no x11
       want_double_buffer=no
-    else 
+    else
       if $PKG_CONFIG --exists xext; then
         PKG_CHECK_MODULES([XEXT],[xext])
         CFLAGS="$CFLAGS $XEXT_CFLAGS"
         LIBS="$LIBS $XEXT_LIBS"
       else
         dnl non-modular X11 installation
-        AC_CHECK_LIB([Xext], [XdbeQueryExtension], [LIBS="$LIBS -lXext"], 
+        AC_CHECK_LIB([Xext], [XdbeQueryExtension], [LIBS="$LIBS -lXext"],
                     AC_MSG_ERROR([Could not find XdbeQueryExtension in -lXext]))
       fi
       AC_DEFINE(HAVE_XDBE, 1, [Define for X11 double-buffering])
@@ -365,7 +365,7 @@ dnl Xdamage Extension
 dnl
 
 AC_ARG_ENABLE([xdamage],
-              AC_HELP_STRING([--disable-xdamage], 
+              AC_HELP_STRING([--disable-xdamage],
                              [disable if you do not want Xdamage support @<:@default=yes@:>@]),
               [want_xdamage="$enableval"], [want_xdamage=yes])
 
@@ -373,7 +373,7 @@ if test "x$want_xdamage" = "xyes"; then
     if test "x$want_x11" != "xyes"; then
       dnl silently disable if no x11
       want_xdamage=no
-    else 
+    else
       if $PKG_CONFIG --exists xdamage; then
         PKG_CHECK_MODULES([XDAMAGE],[xdamage])
         CFLAGS="$CFLAGS $XDAMAGE_CFLAGS"
@@ -400,7 +400,7 @@ if test x$want_xft = "xyes"; then
     if test "x$want_x11" != "xyes"; then
       dnl silently disable if no x11
       want_xft=no
-    else 
+    else
       PKG_CHECK_MODULES(XFT, [xft])
       CFLAGS="$CFLAGS $XFT_CFLAGS"
       LIBS="$LIBS $XFT_LIBS"
@@ -470,7 +470,7 @@ dnl Some functions
 dnl
 
 AC_CHECK_FUNCS([calloc malloc free popen sysinfo getloadavg memrchr])
-AC_SEARCH_LIBS(clock_gettime, [rt], 
+AC_SEARCH_LIBS(clock_gettime, [rt],
                [AC_DEFINE(HAVE_CLOCK_GETTIME, 1, [Define if you have clock_gettime()])],
                [AC_CHECK_FUNCS([gettimeofday], [], [AC_MSG_ERROR([gettimeofday() not available!])])], [])
 
@@ -580,7 +580,7 @@ $PACKAGE $VERSION configured successfully:
 
  * general:
   hddtemp:          $want_hddtemp
-  portmon:          $want_portmon  
+  portmon:          $want_portmon
   rss:              $want_rss
   wireless:         $want_wlan
 EOF
index 49c2f65..ab76554 100644 (file)
@@ -7,6 +7,6 @@ Copyright: This software is copyright (c) 2004-2005 by Brenden Matthews.
 
 Upstream Author: Brenden Matthews <brenden@rty.ca>
 
-You are free to distribute this software under the terms of the BSD License. 
-On Debian systems, the complete text of the BSD License can be found in the 
-file `/usr/share/common-licenses/BSD'.
\ No newline at end of file
+You are free to distribute this software under the terms of the BSD License.
+On Debian systems, the complete text of the BSD License can be found in the
+file `/usr/share/common-licenses/BSD'.
index c45f0f8..28e0e52 100644 (file)
@@ -8,7 +8,7 @@ clean-am: clean-generic mostlyclean-am
        rm -f variables.html
        rm -f config_settings.html
 
-conky.1: command_options.xml config_settings.xml docs.xml variables.xml 
+conky.1: command_options.xml config_settings.xml docs.xml variables.xml
        ${db2x_xsltproc_cmd} -s man ${srcdir}/docs.xml -o docs.mxml
        ${db2x_manxml_cmd} docs.mxml
        ${xsltproc_cmd} http://docbook.sourceforge.net/release/xsl/current/html/docbook.xsl ${srcdir}/docs.xml > docs.html
index cc21f95..340728a 100644 (file)
@@ -1,25 +1,25 @@
 DA DOCS. YO.
 ============
-The main file that contains the bulk of our documentation is docs.xml . 
-We use the DocBook format, which is a really kickass xml-based way of 
-writing documentation, heavily oriented towards programming and computer 
-stuff. There are tags like <command> and <option> that marks up your 
-content without actually having to mark it up, which is why something 
-that's of the <command> shows up in some cool style regardless of 
-whether it's in a man page or a web page. DocBook has been around for 
-10 years, and there's TONS of resources online about the different 
-tags and the stuff that can be done. 
+The main file that contains the bulk of our documentation is docs.xml .
+We use the DocBook format, which is a really kickass xml-based way of
+writing documentation, heavily oriented towards programming and computer
+stuff. There are tags like <command> and <option> that marks up your
+content without actually having to mark it up, which is why something
+that's of the <command> shows up in some cool style regardless of
+whether it's in a man page or a web page. DocBook has been around for
+10 years, and there's TONS of resources online about the different
+tags and the stuff that can be done.
 
 FILE ORGANIZATION
 =================
-For the sake of making things readable and organized, 
-docs.xml "includes" three other files, as of 8/18/05. 
-These are config_settings.xml, command_options.xml, and variables.xml . 
-Their names are pretty self-explanatory, and what the "include" essentially 
-does is stick their contents into docs.xml at the appropriate locations 
-when it's time to produce a man page or html file. So if you wanted to 
-add a variable or explain a command line option better, you'd look in 
-variables.xml and command_options.xml. If you wanted to change the authors 
+For the sake of making things readable and organized,
+docs.xml "includes" three other files, as of 8/18/05.
+These are config_settings.xml, command_options.xml, and variables.xml .
+Their names are pretty self-explanatory, and what the "include" essentially
+does is stick their contents into docs.xml at the appropriate locations
+when it's time to produce a man page or html file. So if you wanted to
+add a variable or explain a command line option better, you'd look in
+variables.xml and command_options.xml. If you wanted to change the authors
 or something, look in docs.xml
 
 BUILDING DA DOCS
index acd06ce..7a0cbed 100644 (file)
       Text alignment on screen, {top,bottom}_{left,right} or none
     <para></para></listitem>
   </varlistentry>
-  
+
   <varlistentry>
     <term><command><option>-b | --double-buffer</option></command></term>
     <listitem>
       Use double buffering (eliminates "flicker")
     <para></para></listitem>
   </varlistentry>
-        
+
   <varlistentry>
     <term><command><option>-c | --config=</option></command><option>FILE</option></term>
     <listitem>
       Config file to load instead of $HOME/.conkyrc
     <para></para></listitem>
   </varlistentry>
-  
+
   <varlistentry>
     <term><command><option>-d | --daemonize</option></command></term>
     <listitem>
       Font to use
     <para></para></listitem>
   </varlistentry>
-  
+
   <varlistentry>
     <term><command><option>-h | --help</option></command></term>
     <listitem>
       Prints command line help and exits
     <para></para></listitem>
   </varlistentry>
-        
+
   <varlistentry>
     <term><command><option>-o | --own-window</option></command></term>
     <listitem>
@@ -61,7 +61,7 @@
       Text to render, remember single quotes, like -t &apos; $uptime &apos;
     <para></para></listitem>
   </varlistentry>
-  
+
   <varlistentry>
     <term><command><option>-u | --interval=</option></command><option>SECONDS</option></term>
     <listitem>
       Window id to draw
     <para></para></listitem>
   </varlistentry>
-  
+
   <varlistentry>
-    <term><command><option>-x </option></command><option>X_COORDINATE</option></term> 
+    <term><command><option>-x </option></command><option>X_COORDINATE</option></term>
     <listitem>
       X position
     <para></para></listitem>
   </varlistentry>
-  
+
   <varlistentry>
-    <term><command><option>-y </option></command><option>Y_COORDINATE</option></term> 
+    <term><command><option>-y </option></command><option>Y_COORDINATE</option></term>
     <listitem>
       Y position
     <para></para></listitem>
-  </varlistentry>                                 
+  </varlistentry>
 
 </variablelist>
index 67994e0..9bf9f5f 100644 (file)
                 <option>undecorated,below,above,sticky,skip_taskbar,skip_pager</option>
        </term>
        <listitem>
-               If own_window is yes, you may use these window manager hints to affect the way Conky displays.  
+               If own_window is yes, you may use these window manager hints to affect the way Conky displays.
                Notes: Use own_window_type desktop as another way to implement many of these hints implicitly.
                If you use own_window_type override, window manager hints have no meaning and are ignored.
        <para></para></listitem>
        <term><command><option>own_window_type</option></command></term>
        <listitem>
                if own_window is yes, you may specify type normal, desktop or override (default: normal).
-               Desktop windows are special windows that have no window decorations; are always visible 
+               Desktop windows are special windows that have no window decorations; are always visible
                on your desktop; do not appear in your pager or taskbar; and are sticky across all workspaces.
                Override windows are not under the control of the window manager.  Hints are ignored. This type
                of window can be useful for certain situations.
index 9eb64bc..aecc4cd 100644 (file)
@@ -1,10 +1,10 @@
 <?xml version="1.0" encoding="utf-8"?>
 <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
   version="1.0">
-  
-  <!--jtan325 created this-->  
+
+  <!--jtan325 created this-->
   <xsl:output method="html"/>
-  
+
   <xsl:template match="/">
     <html>
       <head>
@@ -23,9 +23,9 @@
         <th>Variable</th>
         <th>Explanation</th>
       </tr>
-       
+
       <xsl:for-each select="varlistentry">
-                               <xsl:variable name="row_bg">
+                               <xsl:variable name="row_bg">
                                        <xsl:choose>
                                                <xsl:when test="position() mod 2 = 1">#fffafa</xsl:when>
                                                <xsl:otherwise>#b4cdcd</xsl:otherwise>
@@ -42,5 +42,5 @@
       </xsl:for-each>
     </table>
   </xsl:template>
-  
-</xsl:stylesheet>
\ No newline at end of file
+
+</xsl:stylesheet>
index 8984f9e..fb14f37 100644 (file)
@@ -20,45 +20,45 @@ conky \- A system monitor for X originally based on the torsmo code, but more ki
 .ad b
 'hy
 .SH DESCRIPTION
-Conky is a system monitor for X originally based on the torsmo code. 
-Since it's original conception, Conky has changed a fair bit from it's predecessor. 
-Conky can display just about anything, either on your root desktop or in it's own window. 
-Conky has many built-in objects, as well as the ability to execute programs and scripts, 
+Conky is a system monitor for X originally based on the torsmo code.
+Since it's original conception, Conky has changed a fair bit from it's predecessor.
+Conky can display just about anything, either on your root desktop or in it's own window.
+Conky has many built-in objects, as well as the ability to execute programs and scripts,
 then display the output from stdout.
 .PP
-We are always looking for help, and anyone interested in becoming a developer is welcome. 
+We are always looking for help, and anyone interested in becoming a developer is welcome.
 Please use the facilities at SourceForge to make bug reports, feature requests, and submit patches.
 .PP
 Thanks for your interest in Conky.
 .SH COMPILING
-For users compiling from source, make sure you have the X development libraries installed. 
-This should be a package along the lines of "libx11-dev or xorg-x11-dev". 
+For users compiling from source, make sure you have the X development libraries installed.
+This should be a package along the lines of "libx11-dev or xorg-x11-dev".
 .PP
 Gentoo users -- Conky is in Gentoo's Portage... simply use "emerge app-admin/conky" for installation.
 There is also usually an up-to-date ebuild within Conky's package or in Svn.
 .PP
-Debian,etc. users -- Conky will be in Debian's repositories soon (by mid-September, hopefully), and then 
-Ubuntu shortly thereafter. Until then, "dpkg -i" the .deb package to install. 
+Debian,etc. users -- Conky will be in Debian's repositories soon (by mid-September, hopefully), and then
+Ubuntu shortly thereafter. Until then, "dpkg -i" the .deb package to install.
 .PP
 Example to compile and run Conky with all optional components (note that some configure options may differ for your system):
-.TP 
-\fB\*(T<\fBsh autogen.sh\fR\*(T>\fR \*(T<\fB# Only required if building from Svn\fR\*(T> 
-.TP 
-\fB\*(T<\fB\&./configure \fR\*(T>\fR\*(T<\fB\-\-prefix=/usr \-\-mandir=/usr/share/man \-\-infodir=/usr/share/info \-\-datadir=/usr/share \-\-sysconfdir=/etc \-\-localstatedir=/var/lib \-\-disable\-own\-window \-\-enable\-audacious[=yes|no|legacy] \-\-enable\-bmpx \-\-disable\-hddtemp \-\-disable\-mpd \-\-enable\-xmms2 \-\-disable\-portmon \-\-disable\-network \-\-enable\-debug \-\-disable\-x11 \-\-disable\-double\-buffer \-\-disable\-xdamage \-\-disable\-xft\fR\*(T> 
-.TP 
-\fB\*(T<\fBmake\fR\*(T>\fR 
-.TP 
-\fB\*(T<\fBmake install\fR\*(T>\fR \*(T<\fB# Optional\fR\*(T> 
-.TP 
-\fB\*(T<\fBsrc/conky\fR\*(T>\fR 
+.TP
+\fB\*(T<\fBsh autogen.sh\fR\*(T>\fR \*(T<\fB# Only required if building from Svn\fR\*(T>
+.TP
+\fB\*(T<\fB\&./configure \fR\*(T>\fR\*(T<\fB\-\-prefix=/usr \-\-mandir=/usr/share/man \-\-infodir=/usr/share/info \-\-datadir=/usr/share \-\-sysconfdir=/etc \-\-localstatedir=/var/lib \-\-disable\-own\-window \-\-enable\-audacious[=yes|no|legacy] \-\-enable\-bmpx \-\-disable\-hddtemp \-\-disable\-mpd \-\-enable\-xmms2 \-\-disable\-portmon \-\-disable\-network \-\-enable\-debug \-\-disable\-x11 \-\-disable\-double\-buffer \-\-disable\-xdamage \-\-disable\-xft\fR\*(T>
+.TP
+\fB\*(T<\fBmake\fR\*(T>\fR
+.TP
+\fB\*(T<\fBmake install\fR\*(T>\fR \*(T<\fB# Optional\fR\*(T>
+.TP
+\fB\*(T<\fBsrc/conky\fR\*(T>\fR
 .PP
-Conky probably doesn't compile with compilers other than gcc and icc. 
+Conky probably doesn't compile with compilers other than gcc and icc.
 It doesn't compile with C89 compiler and not even with pure C99.
-It uses a few things that might not exist: strdup(), strcasecmp(), strncasecmp(), 
+It uses a few things that might not exist: strdup(), strcasecmp(), strncasecmp(),
 optarg variable with getopt() and long long (not in C89). Crashes in file system
 statistics stuff when compiled with icc, I don't know exactly why.
 .PP
-You can disable 'drawing to own window' feature in case you don't need it by passing 
+You can disable 'drawing to own window' feature in case you don't need it by passing
 --disable-own-window to configure -script.
 .PP
 .SH "YOU SHOULD KNOW"
@@ -66,329 +66,329 @@ Conky is generally very good on resources. However, certain objects in
 Conky are harder on resources then others. In particular, the $tail,
 $top, $font, and $graph objects are quite costly in comparison to the rest of Conky.
 .PP
-If you do use them, please do not complain about memory or CPU usage, 
+If you do use them, please do not complain about memory or CPU usage,
 unless you think something's seriously wrong (mem leak, etc.).
 .PP
 An easy way to force Conky to reload your ~/.conkyrc: "killall -SIGUSR1 conky".
 Saves you the trouble of having to kill and then restart.
 .PP
-IMPORTANT: For previous Conky users, Conky 1.3 no longer supports the metar stuff. 
+IMPORTANT: For previous Conky users, Conky 1.3 no longer supports the metar stuff.
 mdsplib was causing way too many problems. Hopefully there'll be a better solution in Conky 2.x...
 .SH OPTIONS
 Command line options override configurations defined in configuration file.
-.TP 
+.TP
 \fB\*(T<\fB\-v | \-V | \-\-verbose\fR\*(T>\fR
 Prints version and exits
 
-.TP 
+.TP
 \fB\*(T<\fB\-a | \-\-alignment=\fR\*(T>\fR\*(T<\fBALIGNMENT\fR\*(T>
 Text alignment on screen, {top,bottom}_{left,right} or none
 
-.TP 
+.TP
 \fB\*(T<\fB\-b | \-\-double\-buffer\fR\*(T>\fR
 Use double buffering (eliminates "flicker")
 
-.TP 
+.TP
 \fB\*(T<\fB\-c | \-\-config=\fR\*(T>\fR\*(T<\fBFILE\fR\*(T>
 Config file to load instead of $HOME/.conkyrc
 
-.TP 
+.TP
 \fB\*(T<\fB\-d | \-\-daemonize\fR\*(T>\fR
 Daemonize Conky, aka fork to background
 
-.TP 
+.TP
 \fB\*(T<\fB\-f | \-\-font=\fR\*(T>\fR\*(T<\fBFONT\fR\*(T>
 Font to use
 
-.TP 
+.TP
 \fB\*(T<\fB\-h | \-\-help\fR\*(T>\fR
 Prints command line help and exits
 
-.TP 
+.TP
 \fB\*(T<\fB\-o | \-\-own\-window\fR\*(T>\fR
 Create own window to draw
 
-.TP 
+.TP
 \fB\*(T<\fB\-t | \-\-text=\fR\*(T>\fR\*(T<\fBTEXT\fR\*(T>
 Text to render, remember single quotes, like -t ' $uptime '
 
-.TP 
+.TP
 \fB\*(T<\fB\-u | \-\-interval=\fR\*(T>\fR\*(T<\fBSECONDS\fR\*(T>
 Update interval
 
-.TP 
+.TP
 \fB\*(T<\fB\-w | \-\-window\-id=\fR\*(T>\fR\*(T<\fBWIN_ID\fR\*(T>
 Window id to draw
 
-.TP 
+.TP
 \fB\*(T<\fB\-x \fR\*(T>\fR\*(T<\fBX_COORDINATE\fR\*(T>
 X position
 
-.TP 
+.TP
 \fB\*(T<\fB\-y \fR\*(T>\fR\*(T<\fBY_COORDINATE\fR\*(T>
 Y position
 
 .SH "CONFIGURATION SETTINGS"
 Default configuration file is $HOME/.conkyrc (can be changed from
-conky.c among other things). See conkyrc.sample. If installing from Debian package, 
+conky.c among other things). See conkyrc.sample. If installing from Debian package,
 this should be in /usr/share/doc/conky/examples ("gunzip conkyrc.sample.gz" to get conkyrc.sample).
 .PP
 You might want to copy it to $HOME/.conkyrc and then start modifying it.
 Other configs can be found at http://conky.sf.net
-.TP 
+.TP
 \fB\*(T<\fBalignment\fR\*(T>\fR
 Aligned position on screen, may be top_left, top_right, bottom_left, bottom_right, or none
 
-.TP 
+.TP
 \fB\*(T<\fBbackground\fR\*(T>\fR
 Boolean value, if true, Conky will be forked to background when started
 
-.TP 
+.TP
 \fB\*(T<\fBborder_margin\fR\*(T>\fR
 Border margin in pixels
 
-.TP 
+.TP
 \fB\*(T<\fBborder_width\fR\*(T>\fR
 Border width in pixels
 
-.TP 
+.TP
 \fB\*(T<\fBcolor0\fR\*(T>\fR
 A color variable for use inside TEXT segments
 
-.TP 
+.TP
 \fB\*(T<\fBcolor1\fR\*(T>\fR
 A color variable for use inside TEXT segments
 
-.TP 
+.TP
 \fB\*(T<\fBcolor2\fR\*(T>\fR
 A color variable for use inside TEXT segments
 
-.TP 
+.TP
 \fB\*(T<\fBcolor3\fR\*(T>\fR
 A color variable for use inside TEXT segments
 
-.TP 
+.TP
 \fB\*(T<\fBcolor4\fR\*(T>\fR
 A color variable for use inside TEXT segments
 
-.TP 
+.TP
 \fB\*(T<\fBcolor5\fR\*(T>\fR
 A color variable for use inside TEXT segments
 
-.TP 
+.TP
 \fB\*(T<\fBcolor6\fR\*(T>\fR
 A color variable for use inside TEXT segments
 
-.TP 
+.TP
 \fB\*(T<\fBcolor7\fR\*(T>\fR
 A color variable for use inside TEXT segments
 
-.TP 
+.TP
 \fB\*(T<\fBcolor8\fR\*(T>\fR
 A color variable for use inside TEXT segments
 
-.TP 
+.TP
 \fB\*(T<\fBcolor9\fR\*(T>\fR
 A color variable for use inside TEXT segments
 
-.TP 
+.TP
 \fB\*(T<\fBcpu_avg_samples\fR\*(T>\fR
 The number of samples to average for CPU monitoring
 
-.TP 
+.TP
 \fB\*(T<\fBtop_cpu_separate\fR\*(T>\fR
 If true, cpu in top will show usage of one processor's power. If false, cpu in top will show the usage of all processors' power combined.
 
-.TP 
+.TP
 \fB\*(T<\fBdefault_color\fR\*(T>\fR
 Default color and border color
 
-.TP 
+.TP
 \fB\*(T<\fBdefault_outline_color\fR\*(T>\fR
 Default outline color
 
-.TP 
+.TP
 \fB\*(T<\fBdefault_shade_color\fR\*(T>\fR
 Default shading color and border's shading color
 
-.TP 
+.TP
 \fB\*(T<\fBdouble_buffer\fR\*(T>\fR
 Use the Xdbe extension? (eliminates flicker) It is highly recommended to use own window with this one so double buffer won't be so big.
 
-.TP 
+.TP
 \fB\*(T<\fBdraw_borders\fR\*(T>\fR
 Draw borders around text?
 
-.TP 
+.TP
 \fB\*(T<\fBdraw_graph_borders\fR\*(T>\fR
 Draw borders around graphs?
 
-.TP 
+.TP
 \fB\*(T<\fBdraw_outline\fR\*(T>\fR
 Draw outlines?
 
-.TP 
+.TP
 \fB\*(T<\fBdraw_shades\fR\*(T>\fR
 Draw shades?
 
-.TP 
+.TP
 \fB\*(T<\fBfont\fR\*(T>\fR
 Font name in X, xfontsel can be used to get a nice font
 
-.TP 
+.TP
 \fB\*(T<\fBgap_x\fR\*(T>\fR
 Gap, in pixels, between right or left border of screen, same as passing -x at command line,
 e.g. gap_x 10
 
-.TP 
+.TP
 \fB\*(T<\fBgap_y\fR\*(T>\fR
 Gap, in pixels, between top or bottom border of screen, same as passing -y at command line,
 e.g. gap_y 10.
 
-.TP 
+.TP
 \fB\*(T<\fBimap\fR\*(T>\fR
 Default global IMAP server. Arguments are: "host user pass [-i interval] [-f folder] [-p port] [-e command]". Default port is 143, default folder is 'INBOX', default interval is 5 minutes. If the password is supplied as '*', you will be prompted to enter the password when Conky starts.
 
-.TP 
+.TP
 \fB\*(T<\fBmail_spool\fR\*(T>\fR
 Mail spool for mail checking
 
-.TP 
+.TP
 \fB\*(T<\fBmax_port_monitor_connections\fR\*(T>\fR
 Allow each port monitor to track at most this many connections (if 0 or not set, default is 256)
 
-.TP 
+.TP
 \fB\*(T<\fBmax_specials\fR\*(T>\fR
 Maximum number of special things, e.g. fonts, offsets, aligns, etc. (default is 512)
 
-.TP 
-\fB\*(T<\fBmax_user_text\fR\*(T>\fR \*(T<\fBbytes\fR\*(T> 
+.TP
+\fB\*(T<\fBmax_user_text\fR\*(T>\fR \*(T<\fBbytes\fR\*(T>
 Maximum size of user text buffer, i.e. layout below TEXT line in config file
 (default is 16384 bytes)
 
-.TP 
-\fB\*(T<\fBtext_buffer_size\fR\*(T>\fR \*(T<\fBbytes\fR\*(T> 
+.TP
+\fB\*(T<\fBtext_buffer_size\fR\*(T>\fR \*(T<\fBbytes\fR\*(T>
 Size of the standard text buffer (default is 1280 bytes).
 
-.TP 
-\fB\*(T<\fBmaximum_width\fR\*(T>\fR \*(T<\fBpixels\fR\*(T> 
+.TP
+\fB\*(T<\fBmaximum_width\fR\*(T>\fR \*(T<\fBpixels\fR\*(T>
 Maximum width of window
 
-.TP 
-\fB\*(T<\fBminimum_size\fR\*(T>\fR \*(T<\fBwidth (height)\fR\*(T> 
+.TP
+\fB\*(T<\fBminimum_size\fR\*(T>\fR \*(T<\fBwidth (height)\fR\*(T>
 Minimum size of window
 
-.TP 
+.TP
 \fB\*(T<\fBmpd_host\fR\*(T>\fR
 Host of MPD server
 
-.TP 
+.TP
 \fB\*(T<\fBmpd_port\fR\*(T>\fR
 Port of MPD server
 
-.TP 
+.TP
 \fB\*(T<\fBmpd_password\fR\*(T>\fR
 MPD server password
 
-.TP 
+.TP
 \fB\*(T<\fBmusic_player_interval\fR\*(T>\fR
 Music player thread update interval (defaults to Conky's update interval)
 
-.TP 
+.TP
 \fB\*(T<\fBnet_avg_samples\fR\*(T>\fR
 The number of samples to average for net data
 
-.TP 
+.TP
 \fB\*(T<\fBno_buffers\fR\*(T>\fR
 Substract (file system) buffers from used memory?
 
-.TP 
+.TP
 \fB\*(T<\fBoverride_utf8_locale\fR\*(T>\fR
 Force UTF8? requires XFT
 
-.TP 
+.TP
 \fB\*(T<\fBown_window\fR\*(T>\fR
 Boolean, create own window to draw?
 
-.TP 
+.TP
 \fB\*(T<\fBown_window_class\fR\*(T>\fR
 Manually set the WM_CLASS name. Defaults to "Conky".
 
-.TP 
-\fB\*(T<\fBown_window_colour\fR\*(T>\fR \*(T<\fBcolour\fR\*(T> 
+.TP
+\fB\*(T<\fBown_window_colour\fR\*(T>\fR \*(T<\fBcolour\fR\*(T>
 If own_window_transparent no, set a specified background colour (defaults to black). Takes either a hex value (#ffffff) or a valid RGB name (see /usr/lib/X11/rgb.txt)
 
-.TP 
-\fB\*(T<\fBown_window_hints\fR\*(T>\fR \*(T<\fBundecorated,below,above,sticky,skip_taskbar,skip_pager\fR\*(T> 
-If own_window is yes, you may use these window manager hints to affect the way Conky displays. 
+.TP
+\fB\*(T<\fBown_window_hints\fR\*(T>\fR \*(T<\fBundecorated,below,above,sticky,skip_taskbar,skip_pager\fR\*(T>
+If own_window is yes, you may use these window manager hints to affect the way Conky displays.
 Notes: Use own_window_type desktop as another way to implement many of these hints implicitly.
 If you use own_window_type override, window manager hints have no meaning and are ignored.
 
-.TP 
+.TP
 \fB\*(T<\fBown_window_title\fR\*(T>\fR
 Manually set the window name. Defaults to "<hostname> - conky".
 
-.TP 
+.TP
 \fB\*(T<\fBown_window_transparent\fR\*(T>\fR
 Boolean, set pseudo-transparency?
 
-.TP 
+.TP
 \fB\*(T<\fBown_window_type\fR\*(T>\fR
 if own_window is yes, you may specify type normal, desktop or override (default: normal).
-Desktop windows are special windows that have no window decorations; are always visible 
+Desktop windows are special windows that have no window decorations; are always visible
 on your desktop; do not appear in your pager or taskbar; and are sticky across all workspaces.
 Override windows are not under the control of the window manager. Hints are ignored. This type
 of window can be useful for certain situations.
 
-.TP 
-\fB\*(T<\fBout_to_console\fR\*(T>\fR 
+.TP
+\fB\*(T<\fBout_to_console\fR\*(T>\fR
 Print text to stdout.
 
-.TP 
+.TP
 \fB\*(T<\fBpad_percents\fR\*(T>\fR
 Pad percentages to this many decimals (0 = no padding)
 
-.TP 
+.TP
 \fB\*(T<\fBpop3\fR\*(T>\fR
 Default global POP3 server. Arguments are: "host user pass [-i interval] [-p port] [-e command]". Default port is 110, default interval is 5 minutes. If the password is supplied as '*', you will be prompted to enter the password when Conky starts.
 
-.TP 
+.TP
 \fB\*(T<\fBshort_units\fR\*(T>\fR
 Shortens units to a single character (kiB->k, GiB->G, etc.). Default is off.
 
-.TP 
+.TP
 \fB\*(T<\fBstippled_borders\fR\*(T>\fR
 Border stippling (dashing) in pixels
 
-.TP 
+.TP
 \fB\*(T<\fBtotal_run_times\fR\*(T>\fR
 Total number of times for Conky to update before quitting. Zero makes Conky run forever
 
-.TP 
+.TP
 \fB\*(T<\fBupdate_interval\fR\*(T>\fR
 Update interval in seconds
 
-.TP 
+.TP
 \fB\*(T<\fBuppercase\fR\*(T>\fR
 Boolean value, if true, text is rendered in upper case
 
-.TP 
+.TP
 \fB\*(T<\fBuse_spacer\fR\*(T>\fR
 Adds spaces around certain objects to stop them from moving other things around. Arguments are left, right, and none (default). The old true/false values are deprecated and default to right/none respectively. Note that this only helps if you are using a mono font, such as Bitstream Vera Sans Mono.
 
-.TP 
+.TP
 \fB\*(T<\fBuse_xft\fR\*(T>\fR
 Use Xft (anti-aliased font and stuff)
 
-.TP 
+.TP
 \fB\*(T<\fBxftalpha\fR\*(T>\fR
 Alpha of Xft font. Must be a value at or between 1 and 0.
 
-.TP 
+.TP
 \fB\*(T<\fBxftfont\fR\*(T>\fR
 Xft font to use.
 
-.TP 
+.TP
 \fB\*(T<\fBTEXT\fR\*(T>\fR
 After this begins text to be formatted on screen
 
@@ -398,570 +398,570 @@ Colors are parsed using XParsecolor(), there might be a list of them:
 Color can be also in #rrggbb format (hex).
 Note that when displaying bytes, power is 1024 and not 1000 so 1M really
 means 1024*1024 bytes and not 1000*1000.
-.TP 
-\fB\*(T<\fBaddr\fR\*(T>\fR \*(T<\fBinterface\fR\*(T> 
+.TP
+\fB\*(T<\fBaddr\fR\*(T>\fR \*(T<\fBinterface\fR\*(T>
 IP address for an interface
 
-.TP 
-\fB\*(T<\fBacpiacadapter\fR\*(T>\fR 
+.TP
+\fB\*(T<\fBacpiacadapter\fR\*(T>\fR
 ACPI ac adapter state.
 
-.TP 
-\fB\*(T<\fBacpifan\fR\*(T>\fR 
+.TP
+\fB\*(T<\fBacpifan\fR\*(T>\fR
 ACPI fan state
 
-.TP 
-\fB\*(T<\fBacpitemp\fR\*(T>\fR 
+.TP
+\fB\*(T<\fBacpitemp\fR\*(T>\fR
 ACPI temperature in C.
 
-.TP 
-\fB\*(T<\fBacpitempf\fR\*(T>\fR 
+.TP
+\fB\*(T<\fBacpitempf\fR\*(T>\fR
 ACPI temperature in F.
 
-.TP 
-\fB\*(T<\fBadt746xcpu\fR\*(T>\fR 
+.TP
+\fB\*(T<\fBadt746xcpu\fR\*(T>\fR
 CPU temperature from therm_adt746x
 
-.TP 
-\fB\*(T<\fBadt746xfan\fR\*(T>\fR 
+.TP
+\fB\*(T<\fBadt746xfan\fR\*(T>\fR
 Fan speed from therm_adt746x
 
-.TP 
-\fB\*(T<\fBalignr\fR\*(T>\fR \*(T<\fB(num)\fR\*(T> 
+.TP
+\fB\*(T<\fBalignr\fR\*(T>\fR \*(T<\fB(num)\fR\*(T>
 Right-justify text, with space of N
 
-.TP 
-\fB\*(T<\fBalignc\fR\*(T>\fR \*(T<\fB(num)\fR\*(T> 
+.TP
+\fB\*(T<\fBalignc\fR\*(T>\fR \*(T<\fB(num)\fR\*(T>
 Align text to centre
 
-.TP 
-\fB\*(T<\fBapm_adapter\fR\*(T>\fR 
+.TP
+\fB\*(T<\fBapm_adapter\fR\*(T>\fR
 Display APM AC adapter status (FreeBSD only)
 
-.TP 
-\fB\*(T<\fBapm_battery_life\fR\*(T>\fR 
+.TP
+\fB\*(T<\fBapm_battery_life\fR\*(T>\fR
 Display APM battery life in percent (FreeBSD only)
 
-.TP 
-\fB\*(T<\fBapm_battery_time\fR\*(T>\fR 
+.TP
+\fB\*(T<\fBapm_battery_time\fR\*(T>\fR
 Display remaining APM battery life in hh:mm:ss or "unknown" if
 AC adapterstatus is on-line or charging (FreeBSD only)
 
-.TP 
-\fB\*(T<\fBaudacious_bar\fR\*(T>\fR \*(T<\fB(height),(width)\fR\*(T> 
+.TP
+\fB\*(T<\fBaudacious_bar\fR\*(T>\fR \*(T<\fB(height),(width)\fR\*(T>
 Progress bar
 
-.TP 
-\fB\*(T<\fBaudacious_bitrate\fR\*(T>\fR 
+.TP
+\fB\*(T<\fBaudacious_bitrate\fR\*(T>\fR
 Bitrate of current tune
 
-.TP 
-\fB\*(T<\fBaudacious_channels\fR\*(T>\fR 
+.TP
+\fB\*(T<\fBaudacious_channels\fR\*(T>\fR
 Number of audio channels of current tune
 
-.TP 
-\fB\*(T<\fBaudacious_filename\fR\*(T>\fR 
+.TP
+\fB\*(T<\fBaudacious_filename\fR\*(T>\fR
 Full path and filename of current tune
 
-.TP 
-\fB\*(T<\fBaudacious_frequency\fR\*(T>\fR 
+.TP
+\fB\*(T<\fBaudacious_frequency\fR\*(T>\fR
 Sampling frequency of current tune
 
-.TP 
-\fB\*(T<\fBaudacious_length\fR\*(T>\fR 
+.TP
+\fB\*(T<\fBaudacious_length\fR\*(T>\fR
 Total length of current tune as MM:SS
 
-.TP 
-\fB\*(T<\fBaudacious_length_seconds\fR\*(T>\fR 
+.TP
+\fB\*(T<\fBaudacious_length_seconds\fR\*(T>\fR
 Total length of current tune in seconds
 
-.TP 
-\fB\*(T<\fBaudacious_playlist_position\fR\*(T>\fR 
+.TP
+\fB\*(T<\fBaudacious_playlist_position\fR\*(T>\fR
 Playlist position of current tune
 
-.TP 
-\fB\*(T<\fBaudacious_playlist_length\fR\*(T>\fR 
+.TP
+\fB\*(T<\fBaudacious_playlist_length\fR\*(T>\fR
 Number of tunes in playlist
 
-.TP 
-\fB\*(T<\fBaudacious_position\fR\*(T>\fR 
+.TP
+\fB\*(T<\fBaudacious_position\fR\*(T>\fR
 Position of current tune (MM:SS)
 
-.TP 
-\fB\*(T<\fBaudacious_position_seconds\fR\*(T>\fR 
+.TP
+\fB\*(T<\fBaudacious_position_seconds\fR\*(T>\fR
 Position of current tune in seconds
 
-.TP 
-\fB\*(T<\fBaudacious_status\fR\*(T>\fR 
+.TP
+\fB\*(T<\fBaudacious_status\fR\*(T>\fR
 Player status (Playing/Paused/Stopped/Not running)
 
-.TP 
-\fB\*(T<\fBaudacious_title\fR\*(T>\fR \*(T<\fB(max length)\fR\*(T> 
+.TP
+\fB\*(T<\fBaudacious_title\fR\*(T>\fR \*(T<\fB(max length)\fR\*(T>
 Title of current tune with optional maximum length specifier
 
-.TP 
-\fB\*(T<\fBbattery\fR\*(T>\fR \*(T<\fB(num)\fR\*(T> 
+.TP
+\fB\*(T<\fBbattery\fR\*(T>\fR \*(T<\fB(num)\fR\*(T>
 Battery status and remaining percentage capacity of ACPI or APM battery. ACPI battery number can be given as argument (default is BAT0).
 
-.TP 
-\fB\*(T<\fBbattery_bar\fR\*(T>\fR \*(T<\fB(height),(width) (num)\fR\*(T> 
+.TP
+\fB\*(T<\fBbattery_bar\fR\*(T>\fR \*(T<\fB(height),(width) (num)\fR\*(T>
 Battery percentage remaining of ACPI battery in a bar. ACPI battery number can be given as argument (default is BAT0).
 
-.TP 
-\fB\*(T<\fBbattery_percent\fR\*(T>\fR \*(T<\fB(num)\fR\*(T> 
+.TP
+\fB\*(T<\fBbattery_percent\fR\*(T>\fR \*(T<\fB(num)\fR\*(T>
 Battery percentage remaining for ACPI battery. ACPI battery number can be given as argument (default is BAT0).
 
-.TP 
-\fB\*(T<\fBbattery_time\fR\*(T>\fR \*(T<\fB(num)\fR\*(T> 
+.TP
+\fB\*(T<\fBbattery_time\fR\*(T>\fR \*(T<\fB(num)\fR\*(T>
 Battery charge/discharge time remaining of ACPI battery. ACPI battery number can be given as argument (default is BAT0).
 
-.TP 
-\fB\*(T<\fBbmpx_artist\fR\*(T>\fR 
+.TP
+\fB\*(T<\fBbmpx_artist\fR\*(T>\fR
 Artist in current BMPx track
 
-.TP 
-\fB\*(T<\fBbmpx_album\fR\*(T>\fR 
+.TP
+\fB\*(T<\fBbmpx_album\fR\*(T>\fR
 Album in current BMPx track
 
-.TP 
-\fB\*(T<\fBbmpx_title\fR\*(T>\fR 
+.TP
+\fB\*(T<\fBbmpx_title\fR\*(T>\fR
 Title of the current BMPx track
 
-.TP 
-\fB\*(T<\fBbmpx_track\fR\*(T>\fR 
+.TP
+\fB\*(T<\fBbmpx_track\fR\*(T>\fR
 Track number of the current BMPx track
 
-.TP 
-\fB\*(T<\fBbmpx_bitrate\fR\*(T>\fR 
+.TP
+\fB\*(T<\fBbmpx_bitrate\fR\*(T>\fR
 Bitrate of the current BMPx track
 
-.TP 
-\fB\*(T<\fBbmpx_uri\fR\*(T>\fR 
+.TP
+\fB\*(T<\fBbmpx_uri\fR\*(T>\fR
 URI of the current BMPx track
 
-.TP 
-\fB\*(T<\fBbuffers\fR\*(T>\fR 
+.TP
+\fB\*(T<\fBbuffers\fR\*(T>\fR
 Amount of memory buffered
 
-.TP 
-\fB\*(T<\fBcached\fR\*(T>\fR 
+.TP
+\fB\*(T<\fBcached\fR\*(T>\fR
 Amount of memory cached
 
-.TP 
-\fB\*(T<\fBcolor\fR\*(T>\fR \*(T<\fB(color)\fR\*(T> 
+.TP
+\fB\*(T<\fBcolor\fR\*(T>\fR \*(T<\fB(color)\fR\*(T>
 Change drawing color to color
 
-.TP 
-\fB\*(T<\fBcolor0\fR\*(T>\fR 
+.TP
+\fB\*(T<\fBcolor0\fR\*(T>\fR
 Change drawing color to color0 configuration option
 
-.TP 
-\fB\*(T<\fBcolor1\fR\*(T>\fR 
+.TP
+\fB\*(T<\fBcolor1\fR\*(T>\fR
 Change drawing color to color1 configuration option
 
-.TP 
-\fB\*(T<\fBcolor2\fR\*(T>\fR 
+.TP
+\fB\*(T<\fBcolor2\fR\*(T>\fR
 Change drawing color to color2 configuration option
 
-.TP 
-\fB\*(T<\fBcolor3\fR\*(T>\fR 
+.TP
+\fB\*(T<\fBcolor3\fR\*(T>\fR
 Change drawing color to color3 configuration option
 
-.TP 
-\fB\*(T<\fBcolor4\fR\*(T>\fR 
+.TP
+\fB\*(T<\fBcolor4\fR\*(T>\fR
 Change drawing color to color4 configuration option
 
-.TP 
-\fB\*(T<\fBcolor5\fR\*(T>\fR 
+.TP
+\fB\*(T<\fBcolor5\fR\*(T>\fR
 Change drawing color to color5 configuration option
 
-.TP 
-\fB\*(T<\fBcolor6\fR\*(T>\fR 
+.TP
+\fB\*(T<\fBcolor6\fR\*(T>\fR
 Change drawing color to color6 configuration option
 
-.TP 
-\fB\*(T<\fBcolor7\fR\*(T>\fR 
+.TP
+\fB\*(T<\fBcolor7\fR\*(T>\fR
 Change drawing color to color7 configuration option
 
-.TP 
-\fB\*(T<\fBcolor8\fR\*(T>\fR 
+.TP
+\fB\*(T<\fBcolor8\fR\*(T>\fR
 Change drawing color to color8 configuration option
 
-.TP 
-\fB\*(T<\fBcolor9\fR\*(T>\fR 
+.TP
+\fB\*(T<\fBcolor9\fR\*(T>\fR
 Change drawing color to color9 configuration option
 
-.TP 
-\fB\*(T<\fBcpu\fR\*(T>\fR \*(T<\fB(cpuN)\fR\*(T> 
+.TP
+\fB\*(T<\fBcpu\fR\*(T>\fR \*(T<\fB(cpuN)\fR\*(T>
 CPU usage in percents. For SMP machines, the CPU number can be provided as an argument. ${cpu cpu0} is the total usage, and ${cpu cpuX} (X >= 1) are individual CPUs.
 
-.TP 
-\fB\*(T<\fBcpubar\fR\*(T>\fR \*(T<\fB(cpu number) (height),(width)\fR\*(T> 
+.TP
+\fB\*(T<\fBcpubar\fR\*(T>\fR \*(T<\fB(cpu number) (height),(width)\fR\*(T>
 Bar that shows CPU usage, height is bar's height in pixels. See $cpu for more info on SMP.
 
-.TP 
-\fB\*(T<\fBcpugraph\fR\*(T>\fR \*(T<\fB(cpu number) (height),(width) (gradient colour 1) (gradient colour 2)\fR\*(T> 
+.TP
+\fB\*(T<\fBcpugraph\fR\*(T>\fR \*(T<\fB(cpu number) (height),(width) (gradient colour 1) (gradient colour 2)\fR\*(T>
 CPU usage graph, with optional colours in hex, minus the #. See $cpu for more info on SMP.
 
-.TP 
-\fB\*(T<\fBdiskio\fR\*(T>\fR \*(T<\fB(device)\fR\*(T> 
+.TP
+\fB\*(T<\fBdiskio\fR\*(T>\fR \*(T<\fB(device)\fR\*(T>
 Displays current disk IO. Device is optional, and takes the form of sda for /dev/sda. Individual partitions are allowed.
 
-.TP 
-\fB\*(T<\fBdiskiograph\fR\*(T>\fR \*(T<\fB(device) (height),(width) (gradient colour 1) (gradient colour 2) (scale)\fR\*(T> 
+.TP
+\fB\*(T<\fBdiskiograph\fR\*(T>\fR \*(T<\fB(device) (height),(width) (gradient colour 1) (gradient colour 2) (scale)\fR\*(T>
 Disk IO graph, colours defined in hex, minus the #. If scale is non-zero, it becomes the scale for the graph.
 
-.TP 
-\fB\*(T<\fBdiskio_read\fR\*(T>\fR \*(T<\fB(device)\fR\*(T> 
+.TP
+\fB\*(T<\fBdiskio_read\fR\*(T>\fR \*(T<\fB(device)\fR\*(T>
 Displays current disk IO for reads. Device as in diskio.
 
-.TP 
-\fB\*(T<\fBdiskiograph_read\fR\*(T>\fR \*(T<\fB(device) (height),(width) (gradient colour 1) (gradient colour 2) (scale)\fR\*(T> 
+.TP
+\fB\*(T<\fBdiskiograph_read\fR\*(T>\fR \*(T<\fB(device) (height),(width) (gradient colour 1) (gradient colour 2) (scale)\fR\*(T>
 Disk IO graph for reads, colours defined in hex, minus the #. If scale is non-zero, it becomes the scale for the graph. Device as in diskio.
 
-.TP 
-\fB\*(T<\fBdiskio_write\fR\*(T>\fR \*(T<\fB(device)\fR\*(T> 
+.TP
+\fB\*(T<\fBdiskio_write\fR\*(T>\fR \*(T<\fB(device)\fR\*(T>
 Displays current disk IO for writes. Device as in diskio.
 
-.TP 
-\fB\*(T<\fBdiskiograph_write\fR\*(T>\fR \*(T<\fB(device) (height),(width) (gradient colour 1) (gradient colour 2) (scale)\fR\*(T> 
+.TP
+\fB\*(T<\fBdiskiograph_write\fR\*(T>\fR \*(T<\fB(device) (height),(width) (gradient colour 1) (gradient colour 2) (scale)\fR\*(T>
 Disk IO graph for writes, colours defined in hex, minus the #. If scale is non-zero, it becomes the scale for the graph. Device as in diskio.
 
-.TP 
-\fB\*(T<\fBdownspeed\fR\*(T>\fR \*(T<\fBnet\fR\*(T> 
+.TP
+\fB\*(T<\fBdownspeed\fR\*(T>\fR \*(T<\fBnet\fR\*(T>
 Download speed in kilobytes
 
-.TP 
-\fB\*(T<\fBdownspeedf\fR\*(T>\fR \*(T<\fBnet\fR\*(T> 
+.TP
+\fB\*(T<\fBdownspeedf\fR\*(T>\fR \*(T<\fBnet\fR\*(T>
 Download speed in kilobytes with one decimal
 
-.TP 
-\fB\*(T<\fBdownspeedgraph\fR\*(T>\fR \*(T<\fBnet (height),(width) (gradient colour 1) (gradient colour 2) (scale)\fR\*(T> 
+.TP
+\fB\*(T<\fBdownspeedgraph\fR\*(T>\fR \*(T<\fBnet (height),(width) (gradient colour 1) (gradient colour 2) (scale)\fR\*(T>
 Download speed graph, colours defined in hex, minus the #. If scale is non-zero, it becomes the scale for the graph.
 
-.TP 
-\fB\*(T<\fBelse\fR\*(T>\fR 
+.TP
+\fB\*(T<\fBelse\fR\*(T>\fR
 Text to show if any of the above are not true
 
-.TP 
-\fB\*(T<\fBentropy_avail\fR\*(T>\fR 
+.TP
+\fB\*(T<\fBentropy_avail\fR\*(T>\fR
 Current entropy available for crypto freaks
 
-.TP 
-\fB\*(T<\fBentropy_bar\fR\*(T>\fR \*(T<\fB(height),(width)\fR\*(T> 
+.TP
+\fB\*(T<\fBentropy_bar\fR\*(T>\fR \*(T<\fB(height),(width)\fR\*(T>
 Normalized bar of available entropy for crypto freaks
 
-.TP 
-\fB\*(T<\fBentropy_poolsize\fR\*(T>\fR 
+.TP
+\fB\*(T<\fBentropy_poolsize\fR\*(T>\fR
 Total size of system entropy pool for crypto freaks
 
-.TP 
-\fB\*(T<\fBexec\fR\*(T>\fR \*(T<\fBcommand\fR\*(T> 
+.TP
+\fB\*(T<\fBexec\fR\*(T>\fR \*(T<\fBcommand\fR\*(T>
 Executes a shell command and displays the output in conky. warning: this takes a lot more resources than other variables. I'd recommend coding wanted behaviour in C and posting a patch.
 
-.TP 
-\fB\*(T<\fBexecbar\fR\*(T>\fR \*(T<\fBcommand\fR\*(T> 
+.TP
+\fB\*(T<\fBexecbar\fR\*(T>\fR \*(T<\fBcommand\fR\*(T>
 Same as exec, except if the first value return is a value between 0-100, it will use that number for a bar. The size for the bar is currently fixed, but that may change in the future.
 
-.TP 
-\fB\*(T<\fBexecgraph\fR\*(T>\fR \*(T<\fBcommand\fR\*(T> 
+.TP
+\fB\*(T<\fBexecgraph\fR\*(T>\fR \*(T<\fBcommand\fR\*(T>
 Same as execbar, but graphs values.
 
-.TP 
-\fB\*(T<\fBexeci\fR\*(T>\fR \*(T<\fBinterval command\fR\*(T> 
+.TP
+\fB\*(T<\fBexeci\fR\*(T>\fR \*(T<\fBinterval command\fR\*(T>
 Same as exec but with specific interval. Interval can't be less than update_interval in configuration. See also $texeci
 
-.TP 
-\fB\*(T<\fBexecibar\fR\*(T>\fR \*(T<\fBinterval command\fR\*(T> 
+.TP
+\fB\*(T<\fBexecibar\fR\*(T>\fR \*(T<\fBinterval command\fR\*(T>
 Same as execbar, except with an interval
 
-.TP 
-\fB\*(T<\fBexecigraph\fR\*(T>\fR \*(T<\fBinterval command\fR\*(T> 
+.TP
+\fB\*(T<\fBexecigraph\fR\*(T>\fR \*(T<\fBinterval command\fR\*(T>
 Same as execigraph, but takes an interval arg graphs values
 
-.TP 
-\fB\*(T<\fBfont\fR\*(T>\fR \*(T<\fB(font)\fR\*(T> 
+.TP
+\fB\*(T<\fBfont\fR\*(T>\fR \*(T<\fB(font)\fR\*(T>
 Specify a different font. This new font will apply to the current line and everything following. You can use a $font with no arguments to change back to the default font (much like with $color)
 
-.TP 
-\fB\*(T<\fBfreq\fR\*(T>\fR \*(T<\fB(n)\fR\*(T> 
+.TP
+\fB\*(T<\fBfreq\fR\*(T>\fR \*(T<\fB(n)\fR\*(T>
 Returns CPU #n's frequency in MHz. CPUs are
 counted from 1. If omitted, the parameter
 defaults to 1.
 
-.TP 
-\fB\*(T<\fBfreq_g\fR\*(T>\fR \*(T<\fB(n)\fR\*(T> 
+.TP
+\fB\*(T<\fBfreq_g\fR\*(T>\fR \*(T<\fB(n)\fR\*(T>
 Returns CPU #n's frequency in GHz. CPUs are
 counted from 1. If omitted, the parameter
 defaults to 1.
 
-.TP 
-\fB\*(T<\fBfreq_dyn\fR\*(T>\fR 
+.TP
+\fB\*(T<\fBfreq_dyn\fR\*(T>\fR
 Returns CPU frequency in MHz, but is calculated by counting to clock cycles to complete an instruction. Only available for x86/amd64.
 
-.TP 
-\fB\*(T<\fBfreq_dyn_g\fR\*(T>\fR 
+.TP
+\fB\*(T<\fBfreq_dyn_g\fR\*(T>\fR
 Returns CPU frequency in GHz, but is calculated by counting to clock cycles to complete an instruction. Only available for x86/amd64.
 
-.TP 
-\fB\*(T<\fBfs_bar\fR\*(T>\fR \*(T<\fB(height),(width) fs\fR\*(T> 
+.TP
+\fB\*(T<\fBfs_bar\fR\*(T>\fR \*(T<\fB(height),(width) fs\fR\*(T>
 Bar that shows how much space is used on a file system. height is the height in pixels. fs is any file on that file system.
 
-.TP 
-\fB\*(T<\fBfs_free\fR\*(T>\fR \*(T<\fB(fs)\fR\*(T> 
+.TP
+\fB\*(T<\fBfs_free\fR\*(T>\fR \*(T<\fB(fs)\fR\*(T>
 Free space on a file system available for users.
 
-.TP 
-\fB\*(T<\fBfs_free_perc\fR\*(T>\fR \*(T<\fB(fs)\fR\*(T> 
+.TP
+\fB\*(T<\fBfs_free_perc\fR\*(T>\fR \*(T<\fB(fs)\fR\*(T>
 Free percentage of space on a file system available for users.
 
-.TP 
-\fB\*(T<\fBfs_size\fR\*(T>\fR \*(T<\fB(fs)\fR\*(T> 
+.TP
+\fB\*(T<\fBfs_size\fR\*(T>\fR \*(T<\fB(fs)\fR\*(T>
 File system size
 
-.TP 
-\fB\*(T<\fBfs_used\fR\*(T>\fR \*(T<\fB(fs)\fR\*(T> 
+.TP
+\fB\*(T<\fBfs_used\fR\*(T>\fR \*(T<\fB(fs)\fR\*(T>
 File system used space
 
-.TP 
-\fB\*(T<\fBgoto\fR\*(T>\fR \*(T<\fBx\fR\*(T> 
+.TP
+\fB\*(T<\fBgoto\fR\*(T>\fR \*(T<\fBx\fR\*(T>
 The next element will be printed at position 'x'.
 
-.TP 
-\fB\*(T<\fBhddtemp\fR\*(T>\fR \*(T<\fBdev, (host,(port))\fR\*(T> 
+.TP
+\fB\*(T<\fBhddtemp\fR\*(T>\fR \*(T<\fBdev, (host,(port))\fR\*(T>
 Displays temperature of a selected hard disk drive as reported by the hddtemp daemon running on host:port.
 Default host is 127.0.0.1, default port is 7634.
 
-.TP 
-\fB\*(T<\fBhead\fR\*(T>\fR \*(T<\fBlogfile lines (interval)\fR\*(T> 
+.TP
+\fB\*(T<\fBhead\fR\*(T>\fR \*(T<\fBlogfile lines (interval)\fR\*(T>
 Displays first N lines of supplied text text file. If interval is not supplied, Conky assumes 2x Conky's interval. Max of 30 lines can be displayed, or until the text buffer is filled.
 
-.TP 
-\fB\*(T<\fBhr\fR\*(T>\fR \*(T<\fB(height)\fR\*(T> 
+.TP
+\fB\*(T<\fBhr\fR\*(T>\fR \*(T<\fB(height)\fR\*(T>
 Horizontal line, height is the height in pixels
 
-.TP 
-\fB\*(T<\fBhwmon\fR\*(T>\fR \*(T<\fB(dev) type n\fR\*(T> 
+.TP
+\fB\*(T<\fBhwmon\fR\*(T>\fR \*(T<\fB(dev) type n\fR\*(T>
 Hwmon sensor from sysfs (Linux 2.6). Parameter dev may be omitted if you have only one hwmon device. Parameter type is either 'in' or 'vol' meaning voltage; 'fan' meaning fan; 'temp' (Celsius) or 'tempf' (Fahrenheit) meaning temperature. Parameter n is number of the sensor. See /sys/class/hwmon/ on your local computer.
 
-.TP 
-\fB\*(T<\fBiconv_start\fR\*(T>\fR \*(T<\fBcodeset_from codeset_to\fR\*(T> 
+.TP
+\fB\*(T<\fBiconv_start\fR\*(T>\fR \*(T<\fBcodeset_from codeset_to\fR\*(T>
 Convert text from one codeset to another using GNU iconv. Needs to be stopped with iconv_stop.
 
-.TP 
-\fB\*(T<\fBiconv_stop\fR\*(T>\fR 
+.TP
+\fB\*(T<\fBiconv_stop\fR\*(T>\fR
 Stop iconv codeset conversion.
 
-.TP 
-\fB\*(T<\fBi2c\fR\*(T>\fR \*(T<\fB(dev) type n\fR\*(T> 
+.TP
+\fB\*(T<\fBi2c\fR\*(T>\fR \*(T<\fB(dev) type n\fR\*(T>
 I2C sensor from sysfs (Linux 2.6). Parameter dev may be omitted if you have only one I2C device. Parameter type is either 'in' or 'vol' meaning voltage; 'fan' meaning fan; 'temp' (Celsius) or 'tempf' (Fahrenheit) meaning temperature. Parameter n is number of the sensor. See /sys/bus/i2c/devices/ on your local computer.
 
-.TP 
-\fB\*(T<\fBi8k_ac_status\fR\*(T>\fR 
+.TP
+\fB\*(T<\fBi8k_ac_status\fR\*(T>\fR
 If running the i8k kernel driver for Inspiron laptops, displays whether ac power is on, as listed in /proc/i8k (translated to human-readable). Beware that this is by default not enabled by i8k itself.
 
-.TP 
-\fB\*(T<\fBi8k_bios\fR\*(T>\fR 
+.TP
+\fB\*(T<\fBi8k_bios\fR\*(T>\fR
 If running the i8k kernel driver for Inspiron laptops, displays the bios version as listed in /proc/i8k.
 
-.TP 
-\fB\*(T<\fBi8k_buttons_status\fR\*(T>\fR 
+.TP
+\fB\*(T<\fBi8k_buttons_status\fR\*(T>\fR
 If running the i8k kernel driver for Inspiron laptops, displays the volume buttons status as listed in /proc/i8k.
 
-.TP 
-\fB\*(T<\fBi8k_cpu_temp\fR\*(T>\fR 
+.TP
+\fB\*(T<\fBi8k_cpu_temp\fR\*(T>\fR
 If running the i8k kernel driver for Inspiron laptops, displays the cpu temperature in Celsius, as reported by /proc/i8k.
 
-.TP 
-\fB\*(T<\fBi8k_cpu_tempf\fR\*(T>\fR 
+.TP
+\fB\*(T<\fBi8k_cpu_tempf\fR\*(T>\fR
 If running the i8k kernel driver for Inspiron laptops, displays the cpu temperature in Fahrenheit, as reported by /proc/i8k.
 
-.TP 
-\fB\*(T<\fBi8k_left_fan_rpm\fR\*(T>\fR 
+.TP
+\fB\*(T<\fBi8k_left_fan_rpm\fR\*(T>\fR
 If running the i8k kernel driver for Inspiron laptops, displays the left fan's rate of rotation, in revolutions per minute as listed in /proc/i8k. Beware, some laptops i8k reports these fans in reverse order.
 
-.TP 
-\fB\*(T<\fBi8k_left_fan_status\fR\*(T>\fR 
+.TP
+\fB\*(T<\fBi8k_left_fan_status\fR\*(T>\fR
 If running the i8k kernel driver for Inspiron laptops, displays the left fan status as listed in /proc/i8k (translated to human-readable). Beware, some laptops i8k reports these fans in reverse order.
 
-.TP 
-\fB\*(T<\fBi8k_right_fan_rpm\fR\*(T>\fR 
+.TP
+\fB\*(T<\fBi8k_right_fan_rpm\fR\*(T>\fR
 If running the i8k kernel driver for Inspiron laptops, displays the right fan's rate of rotation, in revolutions per minute as listed in /proc/i8k. Beware, some laptops i8k reports these fans in reverse order.
 
-.TP 
-\fB\*(T<\fBi8k_right_fan_status\fR\*(T>\fR 
+.TP
+\fB\*(T<\fBi8k_right_fan_status\fR\*(T>\fR
 If running the i8k kernel driver for Inspiron laptops, displays the right fan status as listed in /proc/i8k (translated to human-readable). Beware, some laptops i8k reports these fans in reverse order.
 
-.TP 
-\fB\*(T<\fBi8k_serial\fR\*(T>\fR 
+.TP
+\fB\*(T<\fBi8k_serial\fR\*(T>\fR
 If running the i8k kernel driver for Inspiron laptops, displays your laptop serial number as listed in /proc/i8k.
 
-.TP 
-\fB\*(T<\fBi8k_version\fR\*(T>\fR 
+.TP
+\fB\*(T<\fBi8k_version\fR\*(T>\fR
 If running the i8k kernel driver for Inspiron laptops, displays the version formatting of /proc/i8k.
 
-.TP 
-\fB\*(T<\fBibm_fan\fR\*(T>\fR 
+.TP
+\fB\*(T<\fBibm_fan\fR\*(T>\fR
 If running the IBM ACPI, displays the fan speed.
 
-.TP 
-\fB\*(T<\fBibm_temps\fR\*(T>\fR \*(T<\fBN\fR\*(T> 
+.TP
+\fB\*(T<\fBibm_temps\fR\*(T>\fR \*(T<\fBN\fR\*(T>
 If running the IBM ACPI, displays the temperatures
 from the IBM temperature sensors (N=0..7) Sensor 0 is
 on the CPU, 3 is on the GPU.
 
-.TP 
-\fB\*(T<\fBibm_volume\fR\*(T>\fR 
+.TP
+\fB\*(T<\fBibm_volume\fR\*(T>\fR
 If running the IBM ACPI, displays the "master" volume,
 controlled by the volume keys (0-14).
 
-.TP 
-\fB\*(T<\fBibm_brightness\fR\*(T>\fR 
+.TP
+\fB\*(T<\fBibm_brightness\fR\*(T>\fR
 If running the IBM ACPI, displays the brigtness of the
 laptops's LCD (0-7).
 
-.TP 
-\fB\*(T<\fBif_empty\fR\*(T>\fR \*(T<\fB(var)\fR\*(T> 
+.TP
+\fB\*(T<\fBif_empty\fR\*(T>\fR \*(T<\fB(var)\fR\*(T>
 if conky variable VAR is empty, display everything between $if_empty and the matching $endif
 
-.TP 
-\fB\*(T<\fBif_running\fR\*(T>\fR \*(T<\fB(process)\fR\*(T> 
+.TP
+\fB\*(T<\fBif_running\fR\*(T>\fR \*(T<\fB(process)\fR\*(T>
 if PROCESS is running, display everything $if_running and the matching $endif
 
-.TP 
-\fB\*(T<\fBif_existing\fR\*(T>\fR \*(T<\fBfile (string)\fR\*(T> 
+.TP
+\fB\*(T<\fBif_existing\fR\*(T>\fR \*(T<\fBfile (string)\fR\*(T>
 if FILE exists, display everything between if_existing and the matching $endif. The optional second paramater checks for FILE containing the specified string and prints everything between $if_existing and the matching $endif.
 
-.TP 
-\fB\*(T<\fBif_mounted\fR\*(T>\fR \*(T<\fB(mountpoint)\fR\*(T> 
+.TP
+\fB\*(T<\fBif_mounted\fR\*(T>\fR \*(T<\fB(mountpoint)\fR\*(T>
 if MOUNTPOINT is mounted, display everything between $if_mounted and the matching $endif
 
-.TP 
-\fB\*(T<\fBimap_messages\fR\*(T>\fR \*(T<\fB(args)\fR\*(T> 
+.TP
+\fB\*(T<\fBimap_messages\fR\*(T>\fR \*(T<\fB(args)\fR\*(T>
 Displays the number of messages in your global IMAP inbox by default. You can define individual IMAP inboxes seperately by passing arguments to this object. Arguments are: "host user pass [-i interval] [-p port] [-e command]". Default port is 143, default interval is 5 minutes. If the password is supplied as '*', you will be prompted to enter the password when Conky starts.
 
-.TP 
-\fB\*(T<\fBimap_unseen\fR\*(T>\fR \*(T<\fB(args)\fR\*(T> 
+.TP
+\fB\*(T<\fBimap_unseen\fR\*(T>\fR \*(T<\fB(args)\fR\*(T>
 Displays the number of unseen messages in your global IMAP inbox by default. You can define individual IMAP inboxes seperately by passing arguments to this object. Arguments are: "host user pass [-i interval] [-p port] [-e command]". Default port is 143, default interval is 5 minutes. If the password is supplied as '*', you will be prompted to enter the password when Conky starts.
 
-.TP 
-\fB\*(T<\fBkernel\fR\*(T>\fR 
+.TP
+\fB\*(T<\fBkernel\fR\*(T>\fR
 Kernel version
 
-.TP 
-\fB\*(T<\fBloadavg\fR\*(T>\fR 
+.TP
+\fB\*(T<\fBloadavg\fR\*(T>\fR
 (1,2,3)> System load average, 1 is for past 1 minute, 2 for past 5 minutes and 3 for past 15 minutes.
 
-.TP 
-\fB\*(T<\fBmachine\fR\*(T>\fR 
+.TP
+\fB\*(T<\fBmachine\fR\*(T>\fR
 Machine, i686 for example
 
-.TP 
-\fB\*(T<\fBmails\fR\*(T>\fR \*(T<\fB(mailbox)\fR\*(T> \*(T<\fB(interval)\fR\*(T> 
+.TP
+\fB\*(T<\fBmails\fR\*(T>\fR \*(T<\fB(mailbox)\fR\*(T> \*(T<\fB(interval)\fR\*(T>
 Mail count in the specified mailbox or your mail spool if not.
 Both mbox and maildir type mailboxes are supported. You can
 use a program like fetchmail to get mails from some server
 using your favourite protocol. See also new_mails.
 
-.TP 
-\fB\*(T<\fBmboxscan\fR\*(T>\fR \*(T<\fB(\-n number of messages to print) (\-fw from width) (\-sw subject width) mbox\fR\*(T> 
+.TP
+\fB\*(T<\fBmboxscan\fR\*(T>\fR \*(T<\fB(\-n number of messages to print) (\-fw from width) (\-sw subject width) mbox\fR\*(T>
 Print a summary of recent messages in an mbox format mailbox. mbox parameter is the filename of the mailbox (can be encapsulated using '"', ie. ${mboxscan -n 10 "/home/brenden/some box"}
 
-.TP 
-\fB\*(T<\fBmem\fR\*(T>\fR 
+.TP
+\fB\*(T<\fBmem\fR\*(T>\fR
 Amount of memory in use
 
-.TP 
-\fB\*(T<\fBmembar\fR\*(T>\fR \*(T<\fB(height),(width)\fR\*(T> 
+.TP
+\fB\*(T<\fBmembar\fR\*(T>\fR \*(T<\fB(height),(width)\fR\*(T>
 Bar that shows amount of memory in use
 
-.TP 
-\fB\*(T<\fBmemmax\fR\*(T>\fR 
+.TP
+\fB\*(T<\fBmemmax\fR\*(T>\fR
 Total amount of memory
 
-.TP 
-\fB\*(T<\fBmemperc\fR\*(T>\fR 
+.TP
+\fB\*(T<\fBmemperc\fR\*(T>\fR
 Percentage of memory in use
 
-.TP 
-\fB\*(T<\fBmpd_artist\fR\*(T>\fR 
+.TP
+\fB\*(T<\fBmpd_artist\fR\*(T>\fR
 Artist in current MPD song must be enabled at compile
 
-.TP 
-\fB\*(T<\fBmpd_album\fR\*(T>\fR 
+.TP
+\fB\*(T<\fBmpd_album\fR\*(T>\fR
 Album in current MPD song
 
-.TP 
-\fB\*(T<\fBmpd_bar\fR\*(T>\fR \*(T<\fB(height),(width)\fR\*(T> 
+.TP
+\fB\*(T<\fBmpd_bar\fR\*(T>\fR \*(T<\fB(height),(width)\fR\*(T>
 Bar of mpd's progress
 
-.TP 
-\fB\*(T<\fBmpd_bitrate\fR\*(T>\fR 
+.TP
+\fB\*(T<\fBmpd_bitrate\fR\*(T>\fR
 Bitrate of current song
 
-.TP 
-\fB\*(T<\fBmpd_status\fR\*(T>\fR 
+.TP
+\fB\*(T<\fBmpd_status\fR\*(T>\fR
 Playing, stopped, et cetera.
 
-.TP 
-\fB\*(T<\fBmpd_title\fR\*(T>\fR \*(T<\fB(max length)\fR\*(T> 
+.TP
+\fB\*(T<\fBmpd_title\fR\*(T>\fR \*(T<\fB(max length)\fR\*(T>
 Title of current MPD song
 
-.TP 
-\fB\*(T<\fBmpd_vol\fR\*(T>\fR 
+.TP
+\fB\*(T<\fBmpd_vol\fR\*(T>\fR
 MPD's volume
 
-.TP 
-\fB\*(T<\fBmpd_elapsed\fR\*(T>\fR 
+.TP
+\fB\*(T<\fBmpd_elapsed\fR\*(T>\fR
 Song's elapsed time
 
-.TP 
-\fB\*(T<\fBmpd_length\fR\*(T>\fR 
+.TP
+\fB\*(T<\fBmpd_length\fR\*(T>\fR
 Song's length
 
-.TP 
-\fB\*(T<\fBmpd_percent\fR\*(T>\fR 
+.TP
+\fB\*(T<\fBmpd_percent\fR\*(T>\fR
 Percent of song's progress
 
-.TP 
-\fB\*(T<\fBmpd_random\fR\*(T>\fR 
+.TP
+\fB\*(T<\fBmpd_random\fR\*(T>\fR
 Random status (On/Off)
 
-.TP 
-\fB\*(T<\fBmpd_repeat\fR\*(T>\fR 
+.TP
+\fB\*(T<\fBmpd_repeat\fR\*(T>\fR
 Repeat status (On/Off)
 
-.TP 
-\fB\*(T<\fBmpd_track\fR\*(T>\fR 
+.TP
+\fB\*(T<\fBmpd_track\fR\*(T>\fR
 Prints the MPD track field
 
-.TP 
-\fB\*(T<\fBmpd_name\fR\*(T>\fR 
+.TP
+\fB\*(T<\fBmpd_name\fR\*(T>\fR
 Prints the MPD name field
 
-.TP 
-\fB\*(T<\fBmpd_file\fR\*(T>\fR 
+.TP
+\fB\*(T<\fBmpd_file\fR\*(T>\fR
 Prints the file name of the current MPD song
 
-.TP 
-\fB\*(T<\fBmpd_smart\fR\*(T>\fR 
+.TP
+\fB\*(T<\fBmpd_smart\fR\*(T>\fR
 Prints the song name in either the form "artist - title" or file name, depending on whats available
 
-.TP 
-\fB\*(T<\fBnew_mails\fR\*(T>\fR \*(T<\fB(mailbox)\fR\*(T> \*(T<\fB(interval)\fR\*(T> 
+.TP
+\fB\*(T<\fBnew_mails\fR\*(T>\fR \*(T<\fB(mailbox)\fR\*(T> \*(T<\fB(interval)\fR\*(T>
 Unread mail count in the specified mailbox or mail spool if
 not. Both mbox and maildir type mailboxes are supported.
 
-.TP 
-\fB\*(T<\fBnodename\fR\*(T>\fR 
+.TP
+\fB\*(T<\fBnodename\fR\*(T>\fR
 Hostname
 
-.TP 
-\fB\*(T<\fBoutlinecolor\fR\*(T>\fR \*(T<\fB(color)\fR\*(T> 
+.TP
+\fB\*(T<\fBoutlinecolor\fR\*(T>\fR \*(T<\fB(color)\fR\*(T>
 Change outline color
 
-.TP 
-\fB\*(T<\fBpb_battery\fR\*(T>\fR \*(T<\fBitem\fR\*(T> 
+.TP
+\fB\*(T<\fBpb_battery\fR\*(T>\fR \*(T<\fBitem\fR\*(T>
 If running on Apple powerbook/ibook, display
 information on battery status. The item parameter
 specifies, what information to display. Exactly one item
@@ -984,67 +984,67 @@ rate. Nothing is displayed, if battery is
 absent or if it's present but fully charged
 and not discharging.
 
-.TP 
-\fB\*(T<\fBplatform\fR\*(T>\fR \*(T<\fB(dev) type n\fR\*(T> 
+.TP
+\fB\*(T<\fBplatform\fR\*(T>\fR \*(T<\fB(dev) type n\fR\*(T>
 Platform sensor from sysfs (Linux 2.6). Parameter dev may be omitted if you have only one platform device. Platform type is either 'in' or 'vol' meaning voltage; 'fan' meaning fan; 'temp' (Celsius) or 'tempf' (Fahrenheit) meaning temperature. Parameter n is number of the sensor. See /sys/bus/platform/devices/ on your local computer.
 
-.TP 
-\fB\*(T<\fBpop3_unseen\fR\*(T>\fR \*(T<\fB(args)\fR\*(T> 
+.TP
+\fB\*(T<\fBpop3_unseen\fR\*(T>\fR \*(T<\fB(args)\fR\*(T>
 Displays the number of unseen messages in your global POP3 inbox by default. You can define individual POP3 inboxes seperately by passing arguments to this object. Arguments are: "host user pass [-i interval] [-p port] [-e command]". Default port is 110, default interval is 5 minutes. If the password is supplied as '*', you will be prompted to enter the password when Conky starts.
 
-.TP 
-\fB\*(T<\fBpop3_used\fR\*(T>\fR \*(T<\fB(args)\fR\*(T> 
+.TP
+\fB\*(T<\fBpop3_used\fR\*(T>\fR \*(T<\fB(args)\fR\*(T>
 Displays the amount of space (in MiB, 2^20) used in your global POP3 inbox by default. You can define individual POP3 inboxes seperately by passing arguments to this object. Arguments are: "host user pass [-i interval] [-p port] [-e command]". Default port is 110, default interval is 5 minutes. If the password is supplied as '*', you will be prompted to enter the password when Conky starts.
 
-.TP 
-\fB\*(T<\fBpre_exec\fR\*(T>\fR \*(T<\fBshell command\fR\*(T> 
+.TP
+\fB\*(T<\fBpre_exec\fR\*(T>\fR \*(T<\fBshell command\fR\*(T>
 Executes a shell command one time before conky displays anything and puts output as text.
 
-.TP 
-\fB\*(T<\fBprocesses\fR\*(T>\fR 
+.TP
+\fB\*(T<\fBprocesses\fR\*(T>\fR
 Total processes (sleeping and running)
 
-.TP 
-\fB\*(T<\fBrunning_processes\fR\*(T>\fR 
+.TP
+\fB\*(T<\fBrunning_processes\fR\*(T>\fR
 Running processes (not sleeping), requires Linux 2.6
 
-.TP 
-\fB\*(T<\fBshadecolor\fR\*(T>\fR \*(T<\fB(color)\fR\*(T> 
+.TP
+\fB\*(T<\fBshadecolor\fR\*(T>\fR \*(T<\fB(color)\fR\*(T>
 Change shading color
 
-.TP 
-\fB\*(T<\fBstippled_hr\fR\*(T>\fR \*(T<\fB(space)\fR\*(T> 
+.TP
+\fB\*(T<\fBstippled_hr\fR\*(T>\fR \*(T<\fB(space)\fR\*(T>
 Stippled (dashed) horizontal line
 
-.TP 
-\fB\*(T<\fBswapbar\fR\*(T>\fR \*(T<\fB(height),(width)\fR\*(T> 
+.TP
+\fB\*(T<\fBswapbar\fR\*(T>\fR \*(T<\fB(height),(width)\fR\*(T>
 Bar that shows amount of swap in use
 
-.TP 
-\fB\*(T<\fBswap\fR\*(T>\fR 
+.TP
+\fB\*(T<\fBswap\fR\*(T>\fR
 Amount of swap in use
 
-.TP 
-\fB\*(T<\fBswapmax\fR\*(T>\fR 
+.TP
+\fB\*(T<\fBswapmax\fR\*(T>\fR
 Total amount of swap
 
-.TP 
-\fB\*(T<\fBswapperc\fR\*(T>\fR 
+.TP
+\fB\*(T<\fBswapperc\fR\*(T>\fR
 Percentage of swap in use
 
-.TP 
-\fB\*(T<\fBsysname\fR\*(T>\fR 
+.TP
+\fB\*(T<\fBsysname\fR\*(T>\fR
 System name, Linux for example
 
-.TP 
-\fB\*(T<\fBtcp_portmon\fR\*(T>\fR \*(T<\fBport_begin port_end item (index)\fR\*(T> \fI(ip4 only at present)\fR 
+.TP
+\fB\*(T<\fBtcp_portmon\fR\*(T>\fR \*(T<\fBport_begin port_end item (index)\fR\*(T> \fI(ip4 only at present)\fR
 TCP port monitor for specified local ports. Port numbers must be in the range 1 to 65535. Valid items are:
 
 \fBcount\fR - total number of connections in the range
 .br
 \fBrip\fR - remote ip address
 .br
-\fBrhost\fR - remote host name 
+\fBrhost\fR - remote host name
 .br
 \fBrport\fR - remote port number
 .br
@@ -1080,215 +1080,215 @@ displays the remote host port of the fifth connection on a privileged port
 \fB${tcp_portmon 1 65535 lservice 14}\fR -
 displays the local service name of the fifteenth connection in the range of all ports
 
-Note that port monitor variables which share the same port range actually refer to the same monitor, so many references to a single port range for different items and different indexes all use the same monitor internally. In other words, the program avoids creating redundant monitors. 
-.TP 
-\fB\*(T<\fBtexeci\fR\*(T>\fR \*(T<\fBinterval command\fR\*(T> 
+Note that port monitor variables which share the same port range actually refer to the same monitor, so many references to a single port range for different items and different indexes all use the same monitor internally. In other words, the program avoids creating redundant monitors.
+.TP
+\fB\*(T<\fBtexeci\fR\*(T>\fR \*(T<\fBinterval command\fR\*(T>
 Runs a command at an interval inside a thread and displays the output. Same as $execi, except the command is run inside a thread. Use this if you have a slow script to keep Conky updating. You should make the interval slightly longer then the time it takes your script to execute. For example, if you have a script that take 5 seconds to execute, you should make the interval at least 6 seconds. See also $execi.
 
-.TP 
-\fB\*(T<\fBoffset\fR\*(T>\fR \*(T<\fB(pixels)\fR\*(T> 
+.TP
+\fB\*(T<\fBoffset\fR\*(T>\fR \*(T<\fB(pixels)\fR\*(T>
 Move text over by N pixels. See also $voffset.
 
-.TP 
-\fB\*(T<\fBrss\fR\*(T>\fR \*(T<\fBurl delay_in_minutes action item_num\fR\*(T> 
+.TP
+\fB\*(T<\fBrss\fR\*(T>\fR \*(T<\fBurl delay_in_minutes action item_num\fR\*(T>
 Download and parse RSS feeds. Action may be one of the following: feed_title, item_title (with num par), item_desc (with num par) and item_titles.
 
-.TP 
-\fB\*(T<\fBtab\fR\*(T>\fR \*(T<\fB(width, (start))\fR\*(T> 
+.TP
+\fB\*(T<\fBtab\fR\*(T>\fR \*(T<\fB(width, (start))\fR\*(T>
 Puts a tab of the specified width, starting from column 'start'.
 
-.TP 
-\fB\*(T<\fBtail\fR\*(T>\fR \*(T<\fBlogfile lines (interval)\fR\*(T> 
+.TP
+\fB\*(T<\fBtail\fR\*(T>\fR \*(T<\fBlogfile lines (interval)\fR\*(T>
 Displays last N lines of supplied text text file. If interval is not supplied, Conky assumes 2x Conky's interval. Max of 30 lines can be displayed, or until the text buffer is filled.
 
-.TP 
-\fB\*(T<\fBtime\fR\*(T>\fR \*(T<\fB(format)\fR\*(T> 
+.TP
+\fB\*(T<\fBtime\fR\*(T>\fR \*(T<\fB(format)\fR\*(T>
 Local time, see man strftime to get more information about format
 
-.TP 
-\fB\*(T<\fButime\fR\*(T>\fR \*(T<\fB(format)\fR\*(T> 
+.TP
+\fB\*(T<\fButime\fR\*(T>\fR \*(T<\fB(format)\fR\*(T>
 Display time in UTC (universal coordinate time).
 
-.TP 
-\fB\*(T<\fBtztime\fR\*(T>\fR \*(T<\fB(timezone) (format)\fR\*(T> 
+.TP
+\fB\*(T<\fBtztime\fR\*(T>\fR \*(T<\fB(timezone) (format)\fR\*(T>
 Local time for specified timezone, see man strftime to get more information about format. The timezone argument is specified in similar fashion as TZ environment variable. For hints, look in /usr/share/zoneinfo. e.g. US/Pacific, Europe/Zurich, etc.
 
-.TP 
-\fB\*(T<\fBtotaldown\fR\*(T>\fR \*(T<\fBnet\fR\*(T> 
+.TP
+\fB\*(T<\fBtotaldown\fR\*(T>\fR \*(T<\fBnet\fR\*(T>
 Total download, overflows at 4 GB on Linux with 32-bit arch and there doesn't seem to be a way to know how many times it has already done that before conky has started.
 
-.TP 
-\fB\*(T<\fBtop\fR\*(T>\fR \*(T<\fBtype, num\fR\*(T> 
+.TP
+\fB\*(T<\fBtop\fR\*(T>\fR \*(T<\fBtype, num\fR\*(T>
 This takes arguments in the form:top (name) (number) Basically, processes are ranked from highest to lowest in terms of cpu usage, which is what (num) represents. The types are: "name", "pid", "cpu", "mem", and "time". There can be a max of 10 processes listed.
 
-.TP 
-\fB\*(T<\fBtop_mem\fR\*(T>\fR \*(T<\fBtype, num\fR\*(T> 
+.TP
+\fB\*(T<\fBtop_mem\fR\*(T>\fR \*(T<\fBtype, num\fR\*(T>
 Same as top, except sorted by mem usage instead of cpu
 
-.TP 
-\fB\*(T<\fBtotalup\fR\*(T>\fR \*(T<\fBnet\fR\*(T> 
+.TP
+\fB\*(T<\fBtotalup\fR\*(T>\fR \*(T<\fBnet\fR\*(T>
 Total upload, this one too, may overflow
 
-.TP 
-\fB\*(T<\fBupdates\fR\*(T>\fR \*(T<\fBNumber of updates\fR\*(T> 
+.TP
+\fB\*(T<\fBupdates\fR\*(T>\fR \*(T<\fBNumber of updates\fR\*(T>
 for debugging
 
-.TP 
-\fB\*(T<\fBupspeed\fR\*(T>\fR \*(T<\fBnet\fR\*(T> 
+.TP
+\fB\*(T<\fBupspeed\fR\*(T>\fR \*(T<\fBnet\fR\*(T>
 Upload speed in kilobytes
 
-.TP 
-\fB\*(T<\fBupspeedf\fR\*(T>\fR \*(T<\fBnet\fR\*(T> 
+.TP
+\fB\*(T<\fBupspeedf\fR\*(T>\fR \*(T<\fBnet\fR\*(T>
 Upload speed in kilobytes with one decimal
 
-.TP 
-\fB\*(T<\fBupspeedgraph\fR\*(T>\fR \*(T<\fBnet (height),(width) (gradient colour 1) (gradient colour 2) (scale)\fR\*(T> 
+.TP
+\fB\*(T<\fBupspeedgraph\fR\*(T>\fR \*(T<\fBnet (height),(width) (gradient colour 1) (gradient colour 2) (scale)\fR\*(T>
 Upload speed graph, colours defined in hex, minus the #. If scale is non-zero, it becomes the scale for the graph.
 
-.TP 
-\fB\*(T<\fBuptime\fR\*(T>\fR 
+.TP
+\fB\*(T<\fBuptime\fR\*(T>\fR
 Uptime
 
-.TP 
-\fB\*(T<\fBuptime_short\fR\*(T>\fR 
+.TP
+\fB\*(T<\fBuptime_short\fR\*(T>\fR
 Uptime in a shorter format
 
-.TP 
-\fB\*(T<\fBvoffset\fR\*(T>\fR \*(T<\fB(pixels)\fR\*(T> 
+.TP
+\fB\*(T<\fBvoffset\fR\*(T>\fR \*(T<\fB(pixels)\fR\*(T>
 Change vertical offset by N pixels. Negative values will cause text to overlap. See also $offset.
 
-.TP 
-\fB\*(T<\fBvoltage_mv\fR\*(T>\fR \*(T<\fB(n)\fR\*(T> 
+.TP
+\fB\*(T<\fBvoltage_mv\fR\*(T>\fR \*(T<\fB(n)\fR\*(T>
 Returns CPU #n's voltage in mV. CPUs are
 counted from 1. If omitted, the parameter
-defaults to 1. 
+defaults to 1.
 
-.TP 
-\fB\*(T<\fBvoltage_v\fR\*(T>\fR \*(T<\fB(n)\fR\*(T> 
+.TP
+\fB\*(T<\fBvoltage_v\fR\*(T>\fR \*(T<\fB(n)\fR\*(T>
 Returns CPU #n's voltage in V. CPUs are
 counted from 1. If omitted, the parameter
 defaults to 1.
 
-.TP 
-\fB\*(T<\fBwireless_essid\fR\*(T>\fR \*(T<\fBnet\fR\*(T> 
+.TP
+\fB\*(T<\fBwireless_essid\fR\*(T>\fR \*(T<\fBnet\fR\*(T>
 Wireless access point ESSID (Linux only)
 
-.TP 
-\fB\*(T<\fBwireless_mode\fR\*(T>\fR \*(T<\fBnet\fR\*(T> 
+.TP
+\fB\*(T<\fBwireless_mode\fR\*(T>\fR \*(T<\fBnet\fR\*(T>
 Wireless mode (Managed/Ad-Hoc/Master) (Linux only)
 
-.TP 
-\fB\*(T<\fBwireless_bitrate\fR\*(T>\fR \*(T<\fBnet\fR\*(T> 
+.TP
+\fB\*(T<\fBwireless_bitrate\fR\*(T>\fR \*(T<\fBnet\fR\*(T>
 Wireless bitrate (ie 11 Mb/s) (Linux only)
 
-.TP 
-\fB\*(T<\fBwireless_ap\fR\*(T>\fR \*(T<\fBnet\fR\*(T> 
+.TP
+\fB\*(T<\fBwireless_ap\fR\*(T>\fR \*(T<\fBnet\fR\*(T>
 Wireless access point MAC address (Linux only)
 
-.TP 
-\fB\*(T<\fBwireless_link_qual\fR\*(T>\fR \*(T<\fBnet\fR\*(T> 
+.TP
+\fB\*(T<\fBwireless_link_qual\fR\*(T>\fR \*(T<\fBnet\fR\*(T>
 Wireless link quality (Linux only)
 
-.TP 
-\fB\*(T<\fBwireless_link_qual_max\fR\*(T>\fR \*(T<\fBnet\fR\*(T> 
+.TP
+\fB\*(T<\fBwireless_link_qual_max\fR\*(T>\fR \*(T<\fBnet\fR\*(T>
 Wireless link quality maximum value (Linux only)
 
-.TP 
-\fB\*(T<\fBwireless_link_qual_perc\fR\*(T>\fR \*(T<\fBnet\fR\*(T> 
+.TP
+\fB\*(T<\fBwireless_link_qual_perc\fR\*(T>\fR \*(T<\fBnet\fR\*(T>
 Wireless link quality in percents (Linux only)
 
-.TP 
-\fB\*(T<\fBwireless_link_bar\fR\*(T>\fR \*(T<\fB(height), (width) net\fR\*(T> 
+.TP
+\fB\*(T<\fBwireless_link_bar\fR\*(T>\fR \*(T<\fB(height), (width) net\fR\*(T>
 Wireless link quality bar (Linux only)
 
-.TP 
-\fB\*(T<\fBxmms2_artist\fR\*(T>\fR 
+.TP
+\fB\*(T<\fBxmms2_artist\fR\*(T>\fR
 Artist in current XMMS2 song
 
-.TP 
-\fB\*(T<\fBxmms2_album\fR\*(T>\fR 
+.TP
+\fB\*(T<\fBxmms2_album\fR\*(T>\fR
 Album in current XMMS2 song
 
-.TP 
-\fB\*(T<\fBxmms2_title\fR\*(T>\fR 
+.TP
+\fB\*(T<\fBxmms2_title\fR\*(T>\fR
 Title in current XMMS2 song
 
-.TP 
-\fB\*(T<\fBxmms2_genre\fR\*(T>\fR 
+.TP
+\fB\*(T<\fBxmms2_genre\fR\*(T>\fR
 Genre in current XMMS2 song
 
-.TP 
-\fB\*(T<\fBxmms2_comment\fR\*(T>\fR 
+.TP
+\fB\*(T<\fBxmms2_comment\fR\*(T>\fR
 Comment in current XMMS2 song
 
-.TP 
-\fB\*(T<\fBxmms2_decoder\fR\*(T>\fR 
+.TP
+\fB\*(T<\fBxmms2_decoder\fR\*(T>\fR
 Decoder plugin used
 
-.TP 
-\fB\*(T<\fBxmms2_transport\fR\*(T>\fR 
+.TP
+\fB\*(T<\fBxmms2_transport\fR\*(T>\fR
 Transport plugin used
 
-.TP 
-\fB\*(T<\fBxmms2_url\fR\*(T>\fR 
+.TP
+\fB\*(T<\fBxmms2_url\fR\*(T>\fR
 Full path to current song
 
-.TP 
-\fB\*(T<\fBxmms2_tracknr\fR\*(T>\fR 
+.TP
+\fB\*(T<\fBxmms2_tracknr\fR\*(T>\fR
 Track number in current XMMS2 song
 
-.TP 
-\fB\*(T<\fBxmms2_bitrate\fR\*(T>\fR 
+.TP
+\fB\*(T<\fBxmms2_bitrate\fR\*(T>\fR
 Bitrate of current song
 
-.TP 
-\fB\*(T<\fBxmms2_id\fR\*(T>\fR 
+.TP
+\fB\*(T<\fBxmms2_id\fR\*(T>\fR
 XMMS2 id of current song
 
-.TP 
-\fB\*(T<\fBxmms2_duration\fR\*(T>\fR 
+.TP
+\fB\*(T<\fBxmms2_duration\fR\*(T>\fR
 Duration of current song
 
-.TP 
-\fB\*(T<\fBxmms2_elapsed\fR\*(T>\fR 
+.TP
+\fB\*(T<\fBxmms2_elapsed\fR\*(T>\fR
 Song's elapsed time
 
-.TP 
-\fB\*(T<\fBxmms2_size\fR\*(T>\fR 
+.TP
+\fB\*(T<\fBxmms2_size\fR\*(T>\fR
 Size of current song
 
-.TP 
-\fB\*(T<\fBxmms2_percent\fR\*(T>\fR 
+.TP
+\fB\*(T<\fBxmms2_percent\fR\*(T>\fR
 Percent of song's progress
 
-.TP 
-\fB\*(T<\fBxmms2_status\fR\*(T>\fR 
+.TP
+\fB\*(T<\fBxmms2_status\fR\*(T>\fR
 XMMS2 status (Playing, Paused, Stopped, or Disconnected)
 
-.TP 
-\fB\*(T<\fBxmms2_bar\fR\*(T>\fR \*(T<\fB(height),(width)\fR\*(T> 
+.TP
+\fB\*(T<\fBxmms2_bar\fR\*(T>\fR \*(T<\fB(height),(width)\fR\*(T>
 Bar of XMMS2's progress
 
-.TP 
-\fB\*(T<\fBxmms2_smart\fR\*(T>\fR 
+.TP
+\fB\*(T<\fBxmms2_smart\fR\*(T>\fR
 Prints the song name in either the form "artist - title" or file name, depending on whats available
 
 .SH EXAMPLES
-.TP 
+.TP
 \*(T<conky \*(T>\*(T<\fB\-t '${time %D %H:%M}' \-o \-u 30\fR\*(T>
 Start Conky in its own window with date and clock as text and 30 sec update interval.
-.TP 
+.TP
 \*(T<conky \*(T>\*(T<\fB\-a top_left \-x 5 \-y 500 \-d\fR\*(T>
 Start Conky to background at coordinates (5, 500).
 .SH FILES
 \*(T<\fI~/.conkyrc\fR\*(T> default configuration file
 .SH BUGS
-Drawing to root or some other desktop window directly doesn't work with 
-all window managers. Especially doesn't work well with Gnome and it has 
-been reported that it doesn't work with KDE either. Nautilus can be 
-disabled from drawing to desktop with program gconf-editor. Uncheck 
-show_desktop in /apps/nautilus/preferences/. There is -w switch in Conky 
-to set some specific window id. You might find xwininfo -tree useful to 
+Drawing to root or some other desktop window directly doesn't work with
+all window managers. Especially doesn't work well with Gnome and it has
+been reported that it doesn't work with KDE either. Nautilus can be
+disabled from drawing to desktop with program gconf-editor. Uncheck
+show_desktop in /apps/nautilus/preferences/. There is -w switch in Conky
+to set some specific window id. You might find xwininfo -tree useful to
 find the window to draw to. You can also use -o argument which makes
 Conky to create its own window.
 .SH "SEE ALSO"
index b9ce0b2..0fd254b 100644 (file)
       <arg><replaceable>options</replaceable></arg>
     </cmdsynopsis>
   </refsynopsisdiv>
-  
+
   <refsect1>
     <title>Description</title>
     <para>
-    Conky is a system monitor for X originally based on the torsmo code. 
-    Since it's original conception, Conky has changed a fair bit from it's predecessor.  
-    Conky can display just about anything, either on your root desktop or in it's own window.  
-    Conky has many built-in objects, as well as the ability to execute programs and scripts, 
+    Conky is a system monitor for X originally based on the torsmo code.
+    Since it's original conception, Conky has changed a fair bit from it's predecessor.
+    Conky can display just about anything, either on your root desktop or in it's own window.
+    Conky has many built-in objects, as well as the ability to execute programs and scripts,
     then display the output from stdout.
                </para>
                <para>
-               We are always looking for help, and anyone interested in becoming a developer is welcome.  
+               We are always looking for help, and anyone interested in becoming a developer is welcome.
                Please use the facilities at SourceForge to make bug reports, feature requests, and submit patches.
                </para>
                <para>
                Thanks for your interest in Conky.
-               </para>    
+               </para>
   </refsect1>
 
        <refsect1>
                <title>Compiling</title>
                <para>
-               For users compiling from source, make sure you have the X development libraries installed. 
-               This should be a package along the lines of "libx11-dev or xorg-x11-dev". 
+               For users compiling from source, make sure you have the X development libraries installed.
+               This should be a package along the lines of "libx11-dev or xorg-x11-dev".
                </para>
                <para>
                Gentoo users -- Conky is in Gentoo's Portage... simply use "emerge app-admin/conky" for installation.
                There is also usually an up-to-date ebuild within Conky's package or in Svn.
                </para>
                <para>
-               Debian,etc. users -- Conky will be in Debian's repositories soon (by mid-September, hopefully), and then 
-               Ubuntu shortly thereafter. Until then, "dpkg -i" the .deb package to install. 
+               Debian,etc. users -- Conky will be in Debian's repositories soon (by mid-September, hopefully), and then
+               Ubuntu shortly thereafter. Until then, "dpkg -i" the .deb package to install.
                </para>
                <para>
                Example to compile and run Conky with all optional components (note that some configure options may differ for your system):
                        </varlistentry>
                        <varlistentry>
                                <term>
-                                       <command><option>src/conky</option></command>   
+                                       <command><option>src/conky</option></command>
                                </term>
                        </varlistentry>
                </variablelist>
                <para>
-                       Conky probably doesn't compile with compilers other than gcc and icc. 
+                       Conky probably doesn't compile with compilers other than gcc and icc.
                        It doesn't compile with C89 compiler and not even with pure C99.
-                       It uses a few   things that might not exist: strdup(), strcasecmp(), strncasecmp(), 
+                       It uses a few   things that might not exist: strdup(), strcasecmp(), strncasecmp(),
                        optarg variable with getopt() and long long (not in C89). Crashes in file system
                        statistics stuff when compiled with icc, I don't know exactly why.
                </para>
                <para>
-                       You can disable 'drawing to own window' feature in case you don't need it       by passing 
+                       You can disable 'drawing to own window' feature in case you don't need it       by passing
                        --disable-own-window to configure -script.
                </para>
                <para>
-                       
+
                </para>
        </refsect1>
 
 
-  
+
   <refsect1>
     <title>You Should Know</title>
     <para>
                $top, $font, and $graph objects are quite costly in comparison to the rest of Conky.
                </para>
                <para>
-               If you do use them, please do not complain about memory or CPU usage, 
+               If you do use them, please do not complain about memory or CPU usage,
                unless you think something's seriously wrong (mem leak, etc.).
                </para>
                <para>
                Saves you the trouble of having to kill and then restart.
                </para>
                <para>
-               IMPORTANT: For previous Conky users, Conky 1.3 no longer supports the metar stuff. 
+               IMPORTANT: For previous Conky users, Conky 1.3 no longer supports the metar stuff.
                mdsplib was causing way too many problems. Hopefully there'll be a better solution in Conky 2.x...
                </para>
-  </refsect1>  
-  
+  </refsect1>
+
   <refsect1>
     <title>Options</title>
-       
+
     <para>Command line options override configurations defined in configuration file.</para>
-     
+
                &command_options;
 
   </refsect1>
 
        <refsect1>
                <title>Configuration Settings</title>
-               
+
                <para>
                Default configuration file is $HOME/.conkyrc (can be changed from
-               conky.c among other things). See conkyrc.sample. If installing from Debian package, 
+               conky.c among other things). See conkyrc.sample. If installing from Debian package,
                this should be in /usr/share/doc/conky/examples ("gunzip conkyrc.sample.gz" to get conkyrc.sample).
                </para>
                <para>
                You might want to copy it to $HOME/.conkyrc and then start modifying it.
                Other configs can be found at http://conky.sf.net
                </para>
-               
+
                &config_settings;
        </refsect1>
 
        <refsect1>
                <title>Variables</title>
-               
+
                <para>
                Colors are parsed using XParsecolor(), there might be a list of them:
                /usr/X11R6/lib/X11/rgb.txt. Also, <ulink url="http://sedition.com/perl/rgb.html">
                                                                                                                                                         http://sedition.com/perl/rgb.html</ulink>.
                Color can be also in #rrggbb format (hex).
-               
+
                Note that when displaying bytes, power is 1024 and not 1000 so 1M really
                means 1024*1024 bytes and not 1000*1000.
                </para>
-               
+
                &variables;
        </refsect1>
 
        <refsect1>
                <title>Examples</title>
                <variablelist>
-               
+
                        <varlistentry>
                                <term><varname>conky </varname><option>-t &apos;${time %D %H:%M}&apos; -o -u 30</option></term>
                                <listitem>Start Conky in its own window with date and clock as text and 30 sec update interval.</listitem>
                        </varlistentry>
-                       
+
                        <varlistentry>
                                <term><varname>conky </varname><option>-a top_left -x 5 -y 500 -d</option></term>
                                <listitem>Start Conky to background at coordinates (5, 500).</listitem>
                        </varlistentry>
-                       
+
                </variablelist>
        </refsect1>
 
 
        <refsect1>
                <title>Bugs</title>
-               <para>  
-               Drawing to root or some other desktop window directly doesn't work with 
-               all window managers. Especially doesn't work well with Gnome and it has 
-               been reported that it doesn't work with KDE either. Nautilus can be 
-               disabled from drawing to desktop with program gconf-editor. Uncheck 
-               show_desktop in /apps/nautilus/preferences/. There is -w switch in Conky 
-               to set some specific window id. You might find xwininfo -tree useful to 
+               <para>
+               Drawing to root or some other desktop window directly doesn't work with
+               all window managers. Especially doesn't work well with Gnome and it has
+               been reported that it doesn't work with KDE either. Nautilus can be
+               disabled from drawing to desktop with program gconf-editor. Uncheck
+               show_desktop in /apps/nautilus/preferences/. There is -w switch in Conky
+               to set some specific window id. You might find xwininfo -tree useful to
                find the window to draw to. You can also use -o argument which makes
                Conky to create its own window.
                </para>
        </refsect1>
 
   <refsect1>
-    <title>See Also</title>    
+    <title>See Also</title>
     <para><ulink url="http://conky.sourceforge.net">
     http://conky.sourceforge.net</ulink></para>
     <para><ulink url="http://www.sourceforge.net/projects/conky">
                        #conky on irc.freenode.net
                </para>
   </refsect1>
-  
+
        <refsect1>
                <title>Authors</title>
                <para>
                        The Conky dev team. What's up now!
                </para>
-       </refsect1>  
-         
+       </refsect1>
+
 </refentry>
index e35561a..aa11301 100644 (file)
        <para></para></listitem>
 </varlistentry>
 
-<varlistentry>  
-        <term>          
+<varlistentry>
+        <term>
                 <command><option>bmpx_artist</option></command>
         </term>
         <listitem>
         <para></para></listitem>
 </varlistentry>
 
-<varlistentry>  
+<varlistentry>
         <term>
                 <command><option>bmpx_album</option></command>
-        </term>         
+        </term>
         <listitem>
                 Album in current BMPx track
        <para></para></listitem>
                defaults to 1.
                <para></para></listitem>
 </varlistentry>
-       
+
 <varlistentry>
        <term>
                <command><option>freq_dyn</option></command>
                Returns CPU frequency in GHz, but is calculated by counting to clock cycles to complete an instruction.  Only available for x86/amd64.
        <para></para></listitem>
 </varlistentry>
-       
+
 <varlistentry>
        <term>
                <command><option>fs_bar</option></command>
                                </member>
                        <member><command>rip</command> - remote ip address
                                </member>
-                       <member><command>rhost</command> - remote host name 
+                       <member><command>rhost</command> - remote host name
                                </member>
                        <member><command>rport</command> - remote port number
                                </member>
                                displays the remote host port of the fifth connection on a privileged port</member>
                        <member><command>${tcp_portmon 1 65535 lservice 14}</command> -
                                displays the local service name of the fifteenth connection in the range of all ports</member>
-               </simplelist>Note that port monitor variables which share the same port range actually refer to the same monitor, so many references to a single port range for different items and different indexes all use the same monitor internally.  In other words, the program avoids creating redundant monitors. 
+               </simplelist>Note that port monitor variables which share the same port range actually refer to the same monitor, so many references to a single port range for different items and different indexes all use the same monitor internally.  In other words, the program avoids creating redundant monitors.
        </listitem>
 </varlistentry>
 
        <listitem>
                Returns CPU #n's voltage in mV. CPUs are
                counted from 1. If omitted, the parameter
-               defaults to 1. 
+               defaults to 1.
                <para></para></listitem>
 </varlistentry>
 
index 0ad1a79..7e0e9df 100644 (file)
@@ -1,10 +1,10 @@
 <?xml version="1.0" encoding="utf-8"?>
 <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
   version="1.0">
-  
-  <!--jtan325 created this-->  
+
+  <!--jtan325 created this-->
   <xsl:output method="html"/>
-  
+
   <xsl:template match="/">
     <html>
       <head>
@@ -24,9 +24,9 @@
         <th>Arguments () = optional</th>
         <th>Explanation</th>
       </tr>
-       
+
       <xsl:for-each select="varlistentry">
-                               <xsl:variable name="row_bg">
+                               <xsl:variable name="row_bg">
                                        <xsl:choose>
                                                <xsl:when test="position() mod 2 = 1">#fffafa</xsl:when>
                                                <xsl:otherwise>#b4cdcd</xsl:otherwise>
@@ -36,7 +36,7 @@
             <td align="center">
                 <xsl:value-of select="term/command/option" />
             </td>
-            <td align="center"> 
+            <td align="center">
               <xsl:value-of select="term/option" />
                  </td>
                  <td>
@@ -46,5 +46,5 @@
       </xsl:for-each>
     </table>
   </xsl:template>
-  
-</xsl:stylesheet>
\ No newline at end of file
+
+</xsl:stylesheet>
index 5ab4859..aa20fde 100644 (file)
@@ -1,2 +1,2 @@
-Append the contents of conky.nanorc to your $HOME/.nanorc for nano 
+Append the contents of conky.nanorc to your $HOME/.nanorc for nano
 syntax coloring of your $HOME/.conkyrc file.
index 4cda509..7423418 100644 (file)
@@ -64,7 +64,7 @@ syn keyword ConkyrcSetting
         \ xftalpha
         \ xftfont
 
-syn keyword ConkyrcConstant 
+syn keyword ConkyrcConstant
         \ above
         \ below
         \ bottom_left
@@ -95,17 +95,17 @@ syn region ConkyrcVar start=/\$\w\@=/ end=/\W\@=\|$/ contained contains=ConkyrcV
 syn match ConkyrcVarStuff /{\@<=/ms=s contained nextgroup=ConkyrcVarName
 
 syn keyword ConkyrcVarName contained nextgroup=ConkyrcNumber,ConkyrcColour skipwhite
-        \ acpiacadapter 
-        \ acpifan 
-        \ acpitemp 
-        \ acpitempf 
-        \ addr 
+        \ acpiacadapter
+        \ acpifan
+        \ acpitemp
+        \ acpitempf
+        \ addr
         \ adt746xcpu
-        \ adt746xfan 
-        \ alignc 
-        \ alignr 
-        \ apm_adapter 
-        \ apm_battery_life 
+        \ adt746xfan
+        \ alignc
+        \ alignr
+        \ apm_adapter
+        \ apm_battery_life
         \ apm_battery_time
         \ audacious_bar
         \ audacious_bitrate
@@ -120,119 +120,119 @@ syn keyword ConkyrcVarName contained nextgroup=ConkyrcNumber,ConkyrcColour skipw
         \ audacious_position_seconds
         \ audacious_status
         \ audacious_title
-        \ battery 
+        \ battery
         \ battery_time
-        \ bmpx_album 
-        \ bmpx_artist 
+        \ bmpx_album
+        \ bmpx_artist
         \ bmpx_bitrate
-        \ bmpx_title 
-        \ bmpx_track 
-        \ bmpx_uri 
-        \ buffers 
-        \ cached 
-        \ color 
-        \ colour 
-        \ cpu 
-        \ cpubar 
+        \ bmpx_title
+        \ bmpx_track
+        \ bmpx_uri
+        \ buffers
+        \ cached
+        \ color
+        \ colour
+        \ cpu
+        \ cpubar
         \ cpugraph
-        \ diskio 
+        \ diskio
         \ diskiograph
-        \ downspeed 
+        \ downspeed
         \ downspeedf
         \ downspeedgraph
-        \ else 
+        \ else
         \ entropy_avail
         \ entropy_bar
         \ entropy_poolsize
-        \ exec 
-        \ execbar 
-        \ execgraph 
-        \ execi 
-        \ execibar 
-        \ execigraph 
-        \ font 
+        \ exec
+        \ execbar
+        \ execgraph
+        \ execi
+        \ execibar
+        \ execigraph
+        \ font
         \ freq
-        \ freq_dyn 
-        \ freq_dyn_g 
-        \ freq_g 
-        \ fs_bar 
-        \ fs_free 
-        \ fs_free_perc 
-        \ fs_size 
-        \ fs_used 
+        \ freq_dyn
+        \ freq_dyn_g
+        \ freq_g
+        \ fs_bar
+        \ fs_free
+        \ fs_free_perc
+        \ fs_size
+        \ fs_used
         \ goto
         \ hddtemp
         \ head
-        \ hr 
+        \ hr
         \ hwmon
-        \ i2c 
-        \ i8k_ac_status 
-        \ i8k_bios 
-        \ i8k_buttons_status 
-        \ i8k_cpu_temp 
+        \ i2c
+        \ i8k_ac_status
+        \ i8k_bios
+        \ i8k_buttons_status
+        \ i8k_cpu_temp
         \ i8k_cpu_tempf
-        \ i8k_left_fan_rpm 
-        \ i8k_left_fan_status 
-        \ i8k_right_fan_rpm 
+        \ i8k_left_fan_rpm
+        \ i8k_left_fan_status
+        \ i8k_right_fan_rpm
         \ i8k_right_fan_status
-        \ i8k_serial 
-        \ i8k_version 
-        \ if_existing 
-        \ if_mounted 
-        \ if_running 
-        \ kernel 
-        \ linkstatus 
+        \ i8k_serial
+        \ i8k_version
+        \ if_existing
+        \ if_mounted
+        \ if_running
+        \ kernel
+        \ linkstatus
         \ loadavg
-        \ machine 
-        \ mails 
-        \ mem 
-        \ membar 
-        \ memmax 
-        \ memperc 
-        \ mpd_album 
-        \ mpd_artist 
-        \ mpd_bar 
-        \ mpd_bitrate 
+        \ machine
+        \ mails
+        \ mem
+        \ membar
+        \ memmax
+        \ memperc
+        \ mpd_album
+        \ mpd_artist
+        \ mpd_bar
+        \ mpd_bitrate
         \ mpd_elapsed
         \ mpd_file
-        \ mpd_length 
+        \ mpd_length
         \ mpd_name
-        \ mpd_percent 
+        \ mpd_percent
         \ mpd_smart
-        \ mpd_status 
+        \ mpd_status
         \ mpd_title
-        \ mpd_vol 
-        \ new_mails 
-        \ nodename 
-        \ offset 
-        \ outlinecolor 
+        \ mpd_vol
+        \ new_mails
+        \ nodename
+        \ offset
+        \ outlinecolor
         \ platform
-        \ pre_exec 
+        \ pre_exec
         \ processes
-        \ running_processes 
-        \ shadecolor 
-        \ stippled_hr 
-        \ swap 
-        \ swapbar 
-        \ swapmax 
-        \ swapperc 
+        \ running_processes
+        \ shadecolor
+        \ stippled_hr
+        \ swap
+        \ swapbar
+        \ swapmax
+        \ swapperc
         \ sysname
         \ tab
-        \ tail 
-        \ tcp_portmon 
-        \ texeci 
-        \ time 
-        \ top 
-        \ top_mem 
-        \ totaldown 
-        \ totalup 
+        \ tail
+        \ tcp_portmon
+        \ texeci
+        \ time
+        \ top
+        \ top_mem
+        \ totaldown
+        \ totalup
         \ tztime
-        \ updates 
-        \ upspeed 
+        \ updates
+        \ upspeed
         \ upspeedf
-        \ upspeedgraph 
-        \ uptime 
-        \ uptime_short 
+        \ upspeedgraph
+        \ uptime
+        \ uptime_short
         \ voffset
         \ voltage_mv
         \ voltage_v
index c29b6c0..1444797 100644 (file)
--- a/m4/pkg.m4
+++ b/m4/pkg.m4
@@ -1,5 +1,5 @@
 # pkg.m4 - Macros to locate and utilise pkg-config.            -*- Autoconf -*-
-# 
+#
 # Copyright Â© 2004 Scott James Remnant <scott@netsplit.com>.
 #
 # This program is free software; you can redistribute it and/or modify
@@ -39,7 +39,7 @@ if test -n "$PKG_CONFIG"; then
                AC_MSG_RESULT([no])
                PKG_CONFIG=""
        fi
-               
+
 fi[]dnl
 ])# PKG_PROG_PKG_CONFIG
 
@@ -120,7 +120,7 @@ if test $pkg_failed = yes; then
         _PKG_SHORT_ERRORS_SUPPORTED
         if test $_pkg_short_errors_supported = yes; then
                $1[]_PKG_ERRORS=`$PKG_CONFIG --short-errors --errors-to-stdout --print-errors "$2"`
-        else 
+        else
                $1[]_PKG_ERRORS=`$PKG_CONFIG --errors-to-stdout --print-errors "$2"`
         fi
        # Put the nasty error message in config.log where it belongs
index cc4152b..2597978 100644 (file)
@@ -107,7 +107,7 @@ conky_SOURCES =             \
        mboxscan.c              \
        mboxscan.h              \
        $(x11)                  \
-       $(xmms2) 
+       $(xmms2)
 
 AM_LDFLAGS = $(PTHREAD_LIBS) -lm
 
index 53d7f21..ed7e644 100644 (file)
@@ -1,10 +1,9 @@
 /* $Id$ */
 
-/*
- * audacious.c:  conky support for audacious music player
+/* audacious.c:  conky support for audacious music player
  *
  * Copyright (C) 2005-2007 Philip Kovacs pkovacs@users.sourceforge.net
- * 
+ *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
  * License as published by the Free Software Foundation; either
@@ -18,9 +17,7 @@
  * You should have received a copy of the GNU Lesser General Public
  * License along with this library; if not, write to the Free Software
  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301
- * USA.
- *
- */
+ * USA. */
 
 #ifdef HAVE_CONFIG_H
 #include <config.h>
 #include <audacious/dbus.h>
 #else
 #include <audacious/beepctrl.h>
-#define audacious_remote_is_running(x)            xmms_remote_is_running(x) 
-#define audacious_remote_is_paused(x)             xmms_remote_is_paused(x)
-#define audacious_remote_is_playing(x)            xmms_remote_is_playing(x)
-#define audacious_remote_get_playlist_pos(x)      xmms_remote_get_playlist_pos(x)
-#define audacious_remote_get_playlist_title(x,y)  xmms_remote_get_playlist_title(x,y)
-#define audacious_remote_get_playlist_time(x,y)   xmms_remote_get_playlist_time(x,y)
-#define audacious_remote_get_output_time(x)       xmms_remote_get_output_time(x)
-#define audacious_remote_get_info(w,x,y,z)        xmms_remote_get_info(w,x,y,z)
-#define audacious_remote_get_playlist_file(x,y)   xmms_remote_get_playlist_file(x,y)
-#define audacious_remote_get_playlist_length(x)   xmms_remote_get_playlist_length(x)
+#define audacious_remote_is_running(x)                         \
+       xmms_remote_is_running(x)
+#define audacious_remote_is_paused(x)                          \
+       xmms_remote_is_paused(x)
+#define audacious_remote_is_playing(x)                         \
+       xmms_remote_is_playing(x)
+#define audacious_remote_get_playlist_pos(x)           \
+       xmms_remote_get_playlist_pos(x)
+#define audacious_remote_get_playlist_title(x, y)      \
+       xmms_remote_get_playlist_title(x, y)
+#define audacious_remote_get_playlist_time(x, y)       \
+       xmms_remote_get_playlist_time(x, y)
+#define audacious_remote_get_output_time(x)                    \
+       xmms_remote_get_output_time(x)
+#define audacious_remote_get_info(w, x, y, z)          \
+       xmms_remote_get_info(w, x, y, z)
+#define audacious_remote_get_playlist_file(x, y)       \
+       xmms_remote_get_playlist_file(x, y)
+#define audacious_remote_get_playlist_length(x)                \
+       xmms_remote_get_playlist_length(x)
 #endif
 
 #include "config.h"
@@ -61,176 +68,186 @@ static audacious_t audacious_items;
  * ----------------------------------------- */
 void update_audacious(void)
 {
-  /* 
-    The worker thread is updating audacious_items array asynchronously to the main 
-    conky thread.  We merely copy the audacious_items array into the main thread's 
-    info structure when the main thread's update cycle fires. 
-  */
-  if (!info.audacious.p_timed_thread)
-    return;
-
-  timed_thread_lock (info.audacious.p_timed_thread);
-  memcpy(&info.audacious.items,audacious_items,sizeof(audacious_items));
-  timed_thread_unlock (info.audacious.p_timed_thread);
+       /* The worker thread is updating audacious_items array asynchronously
+        * to the main conky thread.
+        * We merely copy the audacious_items array into the main thread's info
+        * structure when the main thread's update cycle fires. */
+       if (!info.audacious.p_timed_thread) {
+               return;
+       }
+
+       timed_thread_lock(info.audacious.p_timed_thread);
+       memcpy(&info.audacious.items, audacious_items, sizeof(audacious_items));
+       timed_thread_unlock(info.audacious.p_timed_thread);
 }
 
-
-/* ------------------------------------------------------------
+/* ---------------------------------------------------------
  * Create a worker thread for audacious media player status.
  *
- * Returns 0 on success, -1 on error. 
- * ------------------------------------------------------------*/
+ * Returns 0 on success, -1 on error.
+ * --------------------------------------------------------- */
 int create_audacious_thread(void)
 {
-  if (!info.audacious.p_timed_thread)
-    info.audacious.p_timed_thread = 
-      timed_thread_create (audacious_thread_func, NULL, info.music_player_interval * 1000000);
-
-  if (!info.audacious.p_timed_thread || timed_thread_run (info.audacious.p_timed_thread))
-    return (-1);
-
-  return 0;
+       if (!info.audacious.p_timed_thread) {
+               info.audacious.p_timed_thread =
+                       timed_thread_create(audacious_thread_func, NULL,
+                       info.music_player_interval * 1000000);
+       }
+
+       if (!info.audacious.p_timed_thread
+                       || timed_thread_run(info.audacious.p_timed_thread)) {
+               return -1;
+       }
+
+       return 0;
 }
 
-/* ------------------------------------------------
- * Destroy audacious player status thread. 
+/* ---------------------------------------
+ * Destroy audacious player status thread.
  *
  * Returns 0 on success, -1 on error.
- * ------------------------------------------------ */
+ * --------------------------------------- */
 int destroy_audacious_thread(void)
 {
-  /* Is a worker is thread running? If not, no error. */
-  if (!info.audacious.p_timed_thread)
-    return(0);
+       /* Is a worker is thread running? If not, no error. */
+       if (!info.audacious.p_timed_thread) {
+               return 0;
+       }
 
-  timed_thread_destroy (info.audacious.p_timed_thread, &info.audacious.p_timed_thread);
+       timed_thread_destroy(info.audacious.p_timed_thread,
+               &info.audacious.p_timed_thread);
 
-  return 0;
+       return 0;
 }
 
 /* ---------------------------------------------------
  * Worker thread function for audacious data sampling.
- * --------------------------------------------------- */ 
+ * --------------------------------------------------- */
 void *audacious_thread_func(void *pvoid)
 {
-  static audacious_t items;
-  gint playpos,frames,length;
-  gint rate,freq,chans;
-  gchar *psong,*pfilename;
+       static audacious_t items;
+       gint playpos, frames, length;
+       gint rate, freq, chans;
+       gchar *psong, *pfilename;
 
 #ifndef AUDACIOUS_LEGACY
-  DBusGProxy *session = NULL;
-  DBusGConnection *connection = NULL;
+       DBusGProxy *session = NULL;
+       DBusGConnection *connection = NULL;
 #else
-  gint session;
+       gint session;
 #endif
 
-
-  pvoid=(void *)pvoid;  /* avoid warning */
-  session=0;
-  psong=NULL;
-  pfilename=NULL;
+       pvoid = (void *) pvoid; /* avoid warning */
+       session = 0;
+       psong = NULL;
+       pfilename = NULL;
 
 #ifndef AUDACIOUS_LEGACY
-  g_type_init ();
-  connection = dbus_g_bus_get (DBUS_BUS_SESSION, NULL);
-  if (!connection) {
-    CRIT_ERR ("unable to establish dbus connection");
-  }
-  session = dbus_g_proxy_new_for_name (connection, 
-                                       AUDACIOUS_DBUS_SERVICE,
-                                       AUDACIOUS_DBUS_PATH,
-                                       AUDACIOUS_DBUS_INTERFACE);
-  if (!session) {
-    CRIT_ERR ("unable to create dbus proxy");
-  }
+       g_type_init();
+       connection = dbus_g_bus_get(DBUS_BUS_SESSION, NULL);
+       if (!connection) {
+               CRIT_ERR("unable to establish dbus connection");
+       }
+       session = dbus_g_proxy_new_for_name(connection, AUDACIOUS_DBUS_SERVICE,
+               AUDACIOUS_DBUS_PATH, AUDACIOUS_DBUS_INTERFACE);
+       if (!session) {
+               CRIT_ERR("unable to create dbus proxy");
+       }
 #endif /* AUDACIOUS_LEGACY */
 
-  /* Loop until the main thread resets the runnable signal. */
-  while (1) {
-
-    if (!audacious_remote_is_running (session)) 
-    {
-      memset(&items,0,sizeof(items));
-      strcpy(items[AUDACIOUS_STATUS],"Not running");
-        goto bottom;
-    }
-
-    /* Player status */
-    if (audacious_remote_is_paused (session))
-      strcpy(items[AUDACIOUS_STATUS],"Paused");
-    else if (audacious_remote_is_playing (session))
-      strcpy(items[AUDACIOUS_STATUS],"Playing");
-    else
-      strcpy(items[AUDACIOUS_STATUS],"Stopped");
-
-    /* Current song title */
-    playpos = audacious_remote_get_playlist_pos (session);
-    psong = audacious_remote_get_playlist_title (session, playpos);
-    if (psong) 
-    {
-      strncpy(items[AUDACIOUS_TITLE],psong,sizeof(items[AUDACIOUS_TITLE])-1);
-      g_free (psong);
-      psong=NULL;
-    }
-
-    /* Current song length as MM:SS */
-    frames = audacious_remote_get_playlist_time (session,playpos);
-    length = frames / 1000;
-    snprintf(items[AUDACIOUS_LENGTH],sizeof(items[AUDACIOUS_LENGTH])-1, "%d:%.2d", length / 60, length % 60);
-
-    /* Current song length in seconds */
-    snprintf(items[AUDACIOUS_LENGTH_SECONDS],sizeof(items[AUDACIOUS_LENGTH_SECONDS])-1, "%d", length);
-
-    /* Current song position as MM:SS */
-    frames = audacious_remote_get_output_time (session);
-    length = frames / 1000;
-    snprintf(items[AUDACIOUS_POSITION],sizeof(items[AUDACIOUS_POSITION])-1,
-             "%d:%.2d", length / 60, length % 60);
-
-    /* Current song position in seconds */
-    snprintf(items[AUDACIOUS_POSITION_SECONDS],sizeof(items[AUDACIOUS_POSITION_SECONDS])-1, "%d", length);
-
-    /* Current song bitrate */
-    audacious_remote_get_info (session, &rate, &freq, &chans);
-    snprintf(items[AUDACIOUS_BITRATE],sizeof(items[AUDACIOUS_BITRATE])-1, "%d", rate);
-
-    /* Current song frequency */
-    snprintf(items[AUDACIOUS_FREQUENCY],sizeof(items[AUDACIOUS_FREQUENCY])-1, "%d", freq);
-
-    /* Current song channels */
-    snprintf(items[AUDACIOUS_CHANNELS],sizeof(items[AUDACIOUS_CHANNELS])-1, "%d", chans);
-
-    /* Current song filename */
-    pfilename = audacious_remote_get_playlist_file (session,playpos);
-    if (pfilename) 
-    {
-      strncpy(items[AUDACIOUS_FILENAME],pfilename,sizeof(items[AUDACIOUS_FILENAME])-1);
-      g_free (pfilename);
-      pfilename=NULL;
-    }
-
-    /* Length of the Playlist (number of songs) */
-    length = audacious_remote_get_playlist_length (session);
-    snprintf(items[AUDACIOUS_PLAYLIST_LENGTH],sizeof(items[AUDACIOUS_PLAYLIST_LENGTH])-1, "%d", length);
-
-    /* Playlist position (index of song) */
-    snprintf(items[AUDACIOUS_PLAYLIST_POSITION],sizeof(items[AUDACIOUS_PLAYLIST_POSITION])-1, 
-           "%d", playpos+1);
+       /* Loop until the main thread resets the runnable signal. */
+       while (1) {
+
+               if (!audacious_remote_is_running(session)) {
+                       memset(&items, 0, sizeof(items));
+                       strcpy(items[AUDACIOUS_STATUS], "Not running");
+                       goto bottom;
+               }
+
+               /* Player status */
+               if (audacious_remote_is_paused(session)) {
+                       strcpy(items[AUDACIOUS_STATUS], "Paused");
+               } else if (audacious_remote_is_playing(session)) {
+                       strcpy(items[AUDACIOUS_STATUS], "Playing");
+               } else {
+                       strcpy(items[AUDACIOUS_STATUS], "Stopped");
+               }
+
+               /* Current song title */
+               playpos = audacious_remote_get_playlist_pos(session);
+               psong = audacious_remote_get_playlist_title(session, playpos);
+               if (psong) {
+                       strncpy(items[AUDACIOUS_TITLE], psong,
+                               sizeof(items[AUDACIOUS_TITLE]) - 1);
+                       g_free(psong);
+                       psong = NULL;
+               }
+
+               /* Current song length as MM:SS */
+               frames = audacious_remote_get_playlist_time(session, playpos);
+               length = frames / 1000;
+               snprintf(items[AUDACIOUS_LENGTH], sizeof(items[AUDACIOUS_LENGTH]) - 1,
+                       "%d:%.2d", length / 60, length % 60);
+
+               /* Current song length in seconds */
+               snprintf(items[AUDACIOUS_LENGTH_SECONDS],
+                       sizeof(items[AUDACIOUS_LENGTH_SECONDS]) - 1, "%d", length);
+
+               /* Current song position as MM:SS */
+               frames = audacious_remote_get_output_time(session);
+               length = frames / 1000;
+               snprintf(items[AUDACIOUS_POSITION],
+                       sizeof(items[AUDACIOUS_POSITION]) - 1, "%d:%.2d", length / 60,
+                       length % 60);
+
+               /* Current song position in seconds */
+               snprintf(items[AUDACIOUS_POSITION_SECONDS],
+                       sizeof(items[AUDACIOUS_POSITION_SECONDS]) - 1, "%d", length);
+
+               /* Current song bitrate */
+               audacious_remote_get_info(session, &rate, &freq, &chans);
+               snprintf(items[AUDACIOUS_BITRATE], sizeof(items[AUDACIOUS_BITRATE]) - 1,
+                       "%d", rate);
+
+               /* Current song frequency */
+               snprintf(items[AUDACIOUS_FREQUENCY],
+                       sizeof(items[AUDACIOUS_FREQUENCY]) - 1, "%d", freq);
+
+               /* Current song channels */
+               snprintf(items[AUDACIOUS_CHANNELS],
+                       sizeof(items[AUDACIOUS_CHANNELS]) - 1, "%d", chans);
+
+               /* Current song filename */
+               pfilename = audacious_remote_get_playlist_file(session, playpos);
+               if (pfilename) {
+                       strncpy(items[AUDACIOUS_FILENAME], pfilename,
+                               sizeof(items[AUDACIOUS_FILENAME]) - 1);
+                       g_free(pfilename);
+                       pfilename = NULL;
+               }
+
+               /* Length of the Playlist (number of songs) */
+               length = audacious_remote_get_playlist_length(session);
+               snprintf(items[AUDACIOUS_PLAYLIST_LENGTH],
+                       sizeof(items[AUDACIOUS_PLAYLIST_LENGTH]) - 1, "%d", length);
+
+               /* Playlist position (index of song) */
+               snprintf(items[AUDACIOUS_PLAYLIST_POSITION],
+                       sizeof(items[AUDACIOUS_PLAYLIST_POSITION]) - 1, "%d", playpos + 1);
 
 bottom:
 
-    /* Deliver the refreshed items array to audacious_items. */
-    timed_thread_lock (info.audacious.p_timed_thread);
-    memcpy(&audacious_items,items,sizeof(items));
-    timed_thread_unlock (info.audacious.p_timed_thread);
+               /* Deliver the refreshed items array to audacious_items. */
+               timed_thread_lock(info.audacious.p_timed_thread);
+               memcpy(&audacious_items, items, sizeof(items));
+               timed_thread_unlock(info.audacious.p_timed_thread);
 
-    if (timed_thread_test (info.audacious.p_timed_thread)) {
+               if (timed_thread_test(info.audacious.p_timed_thread)) {
 #ifndef AUDACIOUS_LEGACY
-      /* release reference to dbus proxy */
-      g_object_unref (session);
+                       /* release reference to dbus proxy */
+                       g_object_unref(session);
 #endif
-      timed_thread_exit (info.audacious.p_timed_thread);
-    }
-  }
+                       timed_thread_exit(info.audacious.p_timed_thread);
+               }
+       }
 }
index 5b44672..db03b40 100644 (file)
@@ -1,8 +1,7 @@
 /* $Id$ */
 
-/* 
- * audacious.h:  conky support for audacious music player
- * 
+/* audacious.h:  conky support for audacious music player
+ *
  * Copyright (C) 2005-2007 Philip Kovacs pkovacs@users.sourceforge.net
  *
  * This library is free software; you can redistribute it and/or
  * You should have received a copy of the GNU Lesser General Public
  * License along with this library; if not, write to the Free Software
  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301
- * USA.
- *
- */
+ * USA. */
 
 #ifndef AUDACIOUS_H
 #define AUDACIOUS_H
 
 enum _audacious_items {
-       AUDACIOUS_STATUS=0,
+       AUDACIOUS_STATUS = 0,
        AUDACIOUS_TITLE,
        AUDACIOUS_LENGTH,
        AUDACIOUS_LENGTH_SECONDS,
index 34f9177..9e12492 100644 (file)
@@ -1,5 +1,4 @@
-/*
- * Conky, a system monitor, based on torsmo
+/* Conky, a system monitor, based on torsmo
  *
  * Any original torsmo code is licensed under the BSD license
  *
@@ -7,7 +6,8 @@
  *
  * Please see COPYING for details
  *
- * Copyright (c) 2005-2007 Brenden Matthews, Philip Kovacs, et. al. (see AUTHORS)
+ * Copyright (c) 2005-2007 Brenden Matthews, Philip Kovacs, et. al.
+ *     (see AUTHORS)
  * All rights reserved.
  *
  * This program is free software: you can redistribute it and/or modify
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  * GNU General Public License for more details.
  * You should have received a copy of the GNU General Public License
- * along with this program.  If not, see <http://www.gnu.org/licenses/>. 
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
  *
- *  $Id$
- */
+ * $Id$ */
 
 #include <bmp/dbus.hh>
 #include <dbus/dbus-glib.h>
@@ -33,7 +32,8 @@
 
 #include "conky.h"
 
-#define DBUS_TYPE_G_STRING_VALUE_HASHTABLE (dbus_g_type_get_map ("GHashTable", G_TYPE_STRING, G_TYPE_VALUE))
+#define DBUS_TYPE_G_STRING_VALUE_HASHTABLE \
+       (dbus_g_type_get_map("GHashTable", G_TYPE_STRING, G_TYPE_VALUE))
 
 static DBusGConnection *bus;
 static DBusGProxy *remote_object;
@@ -46,44 +46,38 @@ void update_bmpx()
        struct information *current_info = &info;
        gint current_track;
        GHashTable *metadata;
-       
+
        if (connected == 0) {
                g_type_init();
                dbus_g_type_specialized_init();
-               
+
                bus = dbus_g_bus_get(DBUS_BUS_SESSION, &error);
                if (bus == NULL) {
                        ERR("BMPx error 1: %s\n", error->message);
                        goto fail;
                }
-               
-               remote_object = dbus_g_proxy_new_for_name(bus,
-                       BMP_DBUS_SERVICE,
-                       BMP_DBUS_PATH,
-                       BMP_DBUS_INTERFACE);
+
+               remote_object = dbus_g_proxy_new_for_name(bus, BMP_DBUS_SERVICE,
+                       BMP_DBUS_PATH, BMP_DBUS_INTERFACE);
                if (!remote_object) {
                        ERR("BMPx error 2: %s\n", error->message);
                        goto fail;
-               } 
+               }
 
                connected = 1;
-       } 
-       
+       }
+
        if (connected == 1) {
                if (dbus_g_proxy_call(remote_object, "GetCurrentTrack", &error,
-                                       G_TYPE_INVALID,
-                                       G_TYPE_INT, &current_track, G_TYPE_INVALID)) {
+                               G_TYPE_INVALID, G_TYPE_INT, &current_track, G_TYPE_INVALID)) {
                } else {
                        ERR("BMPx error 3: %s\n", error->message);
                        goto fail;
                }
-       
+
                if (dbus_g_proxy_call(remote_object, "GetMetadataForListItem", &error,
-                               G_TYPE_INT,
-                               current_track,
-                               G_TYPE_INVALID,
-                               DBUS_TYPE_G_STRING_VALUE_HASHTABLE,
-                               &metadata,
+                               G_TYPE_INT, current_track, G_TYPE_INVALID,
+                               DBUS_TYPE_G_STRING_VALUE_HASHTABLE, &metadata,
                                G_TYPE_INVALID)) {
                        if (current_info->bmpx.title) {
                                free(current_info->bmpx.title);
@@ -97,22 +91,29 @@ void update_bmpx()
                                free(current_info->bmpx.album);
                                current_info->bmpx.album = 0;
                        }
-                       current_info->bmpx.title = g_value_dup_string(g_hash_table_lookup(metadata, "title"));
-                       current_info->bmpx.artist = g_value_dup_string(g_hash_table_lookup(metadata, "artist"));
-                       current_info->bmpx.album = g_value_dup_string(g_hash_table_lookup(metadata, "album"));
-                       current_info->bmpx.bitrate = g_value_get_int(g_hash_table_lookup(metadata, "bitrate"));
-                       current_info->bmpx.track = g_value_get_int(g_hash_table_lookup(metadata, "track-number"));
-                       current_info->bmpx.uri = g_value_get_string(g_hash_table_lookup(metadata, "location"));
+                       current_info->bmpx.title =
+                               g_value_dup_string(g_hash_table_lookup(metadata, "title"));
+                       current_info->bmpx.artist =
+                               g_value_dup_string(g_hash_table_lookup(metadata, "artist"));
+                       current_info->bmpx.album =
+                               g_value_dup_string(g_hash_table_lookup(metadata, "album"));
+                       current_info->bmpx.bitrate =
+                               g_value_get_int(g_hash_table_lookup(metadata, "bitrate"));
+                       current_info->bmpx.track =
+                               g_value_get_int(g_hash_table_lookup(metadata, "track-number"));
+                       current_info->bmpx.uri =
+                               g_value_get_string(g_hash_table_lookup(metadata, "location"));
                } else {
                        ERR("BMPx error 4: %s\n", error->message);
                        goto fail;
                }
-               
+
                g_hash_table_destroy(metadata);
        } else {
-fail: 
-               if (error)
+fail:
+               if (error) {
                        g_error_free(error);
+               }
                if (current_info->bmpx.title) {
                        g_free(current_info->bmpx.title);
                        current_info->bmpx.title = 0;
index 9001178..9bda9c6 100644 (file)
@@ -1,5 +1,4 @@
-/*
- * Conky, a system monitor, based on torsmo
+/* Conky, a system monitor, based on torsmo
  *
  * Any original torsmo code is licensed under the BSD license
  *
@@ -8,7 +7,8 @@
  * Please see COPYING for details
  *
  * Copyright (c) 2004, Hannu Saransaari and Lauri Hakkarainen
- * Copyright (c) 2005-2007 Brenden Matthews, Philip Kovacs, et. al. (see AUTHORS)
+ * Copyright (c) 2005-2007 Brenden Matthews, Philip Kovacs, et. al.
+ *     (see AUTHORS)
  * All rights reserved.
  *
  * This program is free software: you can redistribute it and/or modify
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  * GNU General Public License for more details.
  * You should have received a copy of the GNU General Public License
- * along with this program.  If not, see <http://www.gnu.org/licenses/>. 
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
  *
- *  $Id$
- */
+ * $Id$ */
 
 #include "conky.h"
 #include <stdio.h>
@@ -45,6 +44,7 @@ void update_uname()
 double get_time()
 {
        struct timeval tv;
+
        gettimeofday(&tv, 0);
        return tv.tv_sec + (tv.tv_usec / 1000000.0);
 }
@@ -52,11 +52,13 @@ double get_time()
 FILE *open_file(const char *file, int *reported)
 {
        FILE *fp = fopen(file, "r");
+
        if (!fp) {
                if (!reported || *reported == 0) {
                        ERR("can't open %s: %s", file, strerror(errno));
-                       if (reported)
+                       if (reported) {
                                *reported = 1;
+                       }
                }
                return 0;
        }
@@ -78,13 +80,14 @@ void variable_substitute(const char *s, char *dest, unsigned int n)
                                if (*s == '{') {
                                        s++;
                                        a = s;
-                                       while (*s && *s != '}')
+                                       while (*s && *s != '}') {
                                                s++;
+                                       }
                                } else {
                                        a = s;
-                                       while (*s && (isalnum((int) *s)
-                                                     || *s == '_'))
+                                       while (*s && (isalnum((int) *s) || *s == '_')) {
                                                s++;
+                                       }
                                }
 
                                /* copy variable to buffer and look it up */
@@ -92,16 +95,18 @@ void variable_substitute(const char *s, char *dest, unsigned int n)
                                strncpy(buf, a, len);
                                buf[len] = '\0';
 
-                               if (*s == '}')
+                               if (*s == '}') {
                                        s++;
+                               }
 
                                var = getenv(buf);
 
                                if (var) {
                                        /* add var to dest */
                                        len = strlen(var);
-                                       if (len >= n)
+                                       if (len >= n) {
                                                len = n - 1;
+                                       }
                                        strncpy(dest, var, len);
                                        dest += len;
                                        n -= len;
@@ -125,13 +130,15 @@ struct net_stat *get_net_stat(const char *dev)
 {
        unsigned int i;
 
-       if (!dev)
+       if (!dev) {
                return 0;
+       }
 
        /* find interface stat */
        for (i = 0; i < 16; i++) {
-               if (netstats[i].dev && strcmp(netstats[i].dev, dev) == 0)
+               if (netstats[i].dev && strcmp(netstats[i].dev, dev) == 0) {
                        return &netstats[i];
+               }
        }
 
        /* wasn't found? add it */
@@ -148,51 +155,53 @@ struct net_stat *get_net_stat(const char *dev)
        return 0;
 }
 
-void clear_net_stats (void)
+void clear_net_stats(void)
 {
-  memset (netstats, 0, sizeof(netstats));
+       memset(netstats, 0, sizeof(netstats));
 }
 
 void format_seconds(char *buf, unsigned int n, long t)
 {
-       if (t >= 24 * 60 * 60)  /* hours necessary when there are days? */
-               snprintf(buf, n, "%ldd %ldh %ldm", t / 60 / 60 / 24,
-                        (t / 60 / 60) % 24, (t / 60) % 60);
-       else if (t >= 60 * 60)
-               snprintf(buf, n, "%ldh %ldm", (t / 60 / 60) % 24,
-                        (t / 60) % 60);
-       else
+       if (t >= 24 * 60 * 60) {        /* hours necessary when there are days? */
+               snprintf(buf, n, "%ldd %ldh %ldm", t / 60 / 60 / 24, (t / 60 / 60) % 24,
+                       (t / 60) % 60);
+       } else if (t >= 60 * 60) {
+               snprintf(buf, n, "%ldh %ldm", (t / 60 / 60) % 24, (t / 60) % 60);
+       } else {
                snprintf(buf, n, "%ldm %lds", t / 60, t % 60);
+       }
 }
 
 void format_seconds_short(char *buf, unsigned int n, long t)
 {
-       if (t >= 24 * 60 * 60)
-               snprintf(buf, n, "%ldd %ldh", t / 60 / 60 / 24,
-                        (t / 60 / 60) % 24);
-       else if (t >= 60 * 60)
-               snprintf(buf, n, "%ldh %ldm", (t / 60 / 60) % 24,
-                        (t / 60) % 60);
-       else
+       if (t >= 24 * 60 * 60) {
+               snprintf(buf, n, "%ldd %ldh", t / 60 / 60 / 24, (t / 60 / 60) % 24);
+       } else if (t >= 60 * 60) {
+               snprintf(buf, n, "%ldh %ldm", (t / 60 / 60) % 24, (t / 60) % 60);
+       } else {
                snprintf(buf, n, "%ldm", t / 60);
+       }
 }
 
 static double last_meminfo_update;
 static double last_fs_update;
 
 unsigned long long need_mask;
+
 #define NEED(a) ((need_mask & (1 << a)) && ((info.mask & (1 << a)) == 0))
 
 void update_stuff()
 {
        unsigned int i;
+
        info.mask = 0;
 
-       if (no_buffers)
+       if (no_buffers) {
                need_mask |= 1 << INFO_BUFFERS;
+       }
 
        /* clear speeds and up status in case device was removed and doesn't get
-          updated */
+        * updated */
 
        for (i = 0; i < 16; i++) {
                if (netstats[i].dev) {
@@ -204,66 +213,77 @@ void update_stuff()
 
        prepare_update();
 
-       if (NEED(INFO_UPTIME))
+       if (NEED(INFO_UPTIME)) {
                update_uptime();
+       }
 
-       if (NEED(INFO_PROCS))
+       if (NEED(INFO_PROCS)) {
                update_total_processes();
+       }
 
-       if (NEED(INFO_RUN_PROCS))
+       if (NEED(INFO_RUN_PROCS)) {
                update_running_processes();
+       }
 
-       if (NEED(INFO_CPU))
+       if (NEED(INFO_CPU)) {
                update_cpu_usage();
+       }
 
-       if (NEED(INFO_NET))
+       if (NEED(INFO_NET)) {
                update_net_stats();
+       }
 
-       if (NEED(INFO_DISKIO))
+       if (NEED(INFO_DISKIO)) {
                update_diskio();
+       }
 
 #if defined(__linux__)
-       if (NEED(INFO_I8K))
+       if (NEED(INFO_I8K)) {
                update_i8k();
+       }
 #endif /* __linux__ */
-       
+
 #ifdef MPD
        if (NEED(INFO_MPD)) {
                if (!mpd_timed_thread) {
                        init_mpd_stats(&info);
-                       mpd_timed_thread = 
-        timed_thread_create((void*)update_mpd, (void*) NULL, info.music_player_interval * 1000000);
+                       mpd_timed_thread = timed_thread_create((void *) update_mpd,
+                               (void *) NULL, info.music_player_interval * 1000000);
                        if (!mpd_timed_thread) {
                                ERR("Failed to create MPD timed thread");
                        }
                        timed_thread_register(mpd_timed_thread, &mpd_timed_thread);
-      if (timed_thread_run (mpd_timed_thread))
-        ERR("Failed to run MPD timed thread");
+                       if (timed_thread_run(mpd_timed_thread)) {
+                               ERR("Failed to run MPD timed thread");
+                       }
                }
        }
 #endif
 
 #ifdef XMMS2
-       if (NEED(INFO_XMMS2))
+       if (NEED(INFO_XMMS2)) {
                update_xmms2();
+       }
 #endif
 
 #ifdef AUDACIOUS
-       if (NEED(INFO_AUDACIOUS))
+       if (NEED(INFO_AUDACIOUS)) {
                update_audacious();
+       }
 #endif
 
 #ifdef BMPX
-       if (NEED(INFO_BMPX))
-                update_bmpx();
+       if (NEED(INFO_BMPX)) {
+               update_bmpx();
+       }
 #endif
 
-       if (NEED(INFO_LOADAVG))
+       if (NEED(INFO_LOADAVG)) {
                update_load_average();
+       }
 
-
-       if ((NEED(INFO_MEM) || NEED(INFO_BUFFERS) || NEED(INFO_TOP)) &&
-           current_update_time - last_meminfo_update > 6.9) {
+       if ((NEED(INFO_MEM) || NEED(INFO_BUFFERS) || NEED(INFO_TOP))
+                       && current_update_time - last_meminfo_update > 6.9) {
                update_meminfo();
                if (no_buffers) {
                        info.mem -= info.bufmem;
@@ -271,8 +291,9 @@ void update_stuff()
                last_meminfo_update = current_update_time;
        }
 
-       if (NEED(INFO_TOP))
+       if (NEED(INFO_TOP)) {
                update_top();
+       }
 
        /* update_fs_stat() won't do anything if there aren't fs -things */
        if (NEED(INFO_FS) && current_update_time - last_fs_update > 12.9) {
@@ -280,11 +301,13 @@ void update_stuff()
                last_fs_update = current_update_time;
        }
 #ifdef TCP_PORT_MONITOR
-       if (NEED(INFO_TCP_PORT_MONITOR))
-               update_tcp_port_monitor_collection( info.p_tcp_port_monitor_collection );
+       if (NEED(INFO_TCP_PORT_MONITOR)) {
+               update_tcp_port_monitor_collection(info.p_tcp_port_monitor_collection);
+       }
 #endif
-       if (NEED(INFO_ENTROPY))
+       if (NEED(INFO_ENTROPY)) {
                update_entropy();
+       }
 }
 
 int round_to_int(float f)
index c54ef25..5ceac4a 100644 (file)
@@ -1,5 +1,4 @@
-/*
- * Conky, a system monitor, based on torsmo
+/* Conky, a system monitor, based on torsmo
  *
  * Any original torsmo code is licensed under the BSD license
  *
@@ -8,7 +7,8 @@
  * Please see COPYING for details
  *
  * Copyright (c) 2004, Hannu Saransaari and Lauri Hakkarainen
- * Copyright (c) 2005-2007 Brenden Matthews, Philip Kovacs, et. al. (see AUTHORS)
+ * Copyright (c) 2005-2007 Brenden Matthews, Philip Kovacs, et. al.
+ *     (see AUTHORS)
  * All rights reserved.
  *
  * This program is free software: you can redistribute it and/or modify
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  * GNU General Public License for more details.
  * You should have received a copy of the GNU General Public License
- * along with this program.  If not, see <http://www.gnu.org/licenses/>. 
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
  *
- *  $Id$
- */
+ * $Id$ */
 
 #include "conky.h"
 #include <stdio.h>
 
 static void print_version()
 {
-       printf("Conky %s compiled %s for %s\n",
-                       VERSION, BUILD_DATE, BUILD_ARCH);
+       printf("Conky %s compiled %s for %s\n", VERSION, BUILD_DATE, BUILD_ARCH);
 
-       printf(
-       "\nCompiled in features:\n\n"
-  "system config file: %s\n\n"
+       printf("\nCompiled in features:\n\n"
+                  "system config file: %s\n\n"
 #ifdef X11
-       " X11:\n"
+                  " X11:\n"
 # ifdef HAVE_XDAMAGE
-       "  * Xdamage extension\n"
+                  "  * Xdamage extension\n"
 # endif /* HAVE_XDAMAGE */
 # ifdef HAVE_XDBE
-       "  * Xdbe extension (double buffer)\n"
+                  "  * Xdbe extension (double buffer)\n"
 # endif /* HAVE_XDBE */
 # ifdef XFT
-       "  * xft\n"
+                  "  * xft\n"
 # endif /* XFT */
-
 #endif /* X11 */
-       "\n Music detection:\n"
+                  "\n Music detection:\n"
 #ifdef AUDACIOUS
-       "  * audacious\n"
+                  "  * audacious\n"
 #endif /* AUDACIOUS */
 #ifdef BMPX
-       "  * bmpx\n"
+                  "  * bmpx\n"
 #endif /* BMPX */
 #ifdef MPD
-       "  * mpd\n"
+                  "  * mpd\n"
 #endif /* MPD */
 #ifdef XMMS2
-       "  * xmms2\n"
+                  "  * xmms2\n"
 #endif /* XMMS2 */
-       "\n General features:\n"
+                  "\n General features:\n"
 #ifdef HDDTEMP
-       "  * hddtemp\n"
+                  "  * hddtemp\n"
 #endif /* HDDTEMP */
 #ifdef TCP_PORT_MONITOR
-       "  * portmon\n"
+                  "  * portmon\n"
 #endif /* TCP_PORT_MONITOR */
 #ifdef RSS
-       "  * rss\n"
+                  "  * rss\n"
 #endif /* RSS */
 #ifdef HAVE_IWLIB
-       "  * wireless\n"
+                  "  * wireless\n"
 #endif
-  "",SYSTEM_CONFIG_FILE
-  );   
+                  "", SYSTEM_CONFIG_FILE
+       );
 
        exit(0);
 }
 
 #ifdef X11
 
-/*
- * text size
- */
+/* text size */
 
 static int text_start_x, text_start_y; /* text start position in window */
 static int text_width, text_height;
@@ -146,7 +140,6 @@ enum alignment {
        NONE
 };
 
-
 /* for fonts */
 struct font_list {
 
@@ -157,9 +150,9 @@ struct font_list {
 #ifdef XFT
        XftFont *xftfont;
        int font_alpha;
-#endif 
-
+#endif
 };
+
 static int selected_font = 0;
 static int font_count = -1;
 struct font_list *fonts = NULL;
@@ -168,14 +161,19 @@ static char *suffixes[] = { "B", "kiB", "MiB", "GiB", "TiB", "PiB", "" };
 
 #ifdef XFT
 
-#define font_height() (use_xft ? (fonts[selected_font].xftfont->ascent + fonts[selected_font].xftfont->descent) : \
-(fonts[selected_font].font->max_bounds.ascent + fonts[selected_font].font->max_bounds.descent))
-#define font_ascent() (use_xft ? fonts[selected_font].xftfont->ascent : fonts[selected_font].font->max_bounds.ascent)
-#define font_descent() (use_xft ? fonts[selected_font].xftfont->descent : fonts[selected_font].font->max_bounds.descent)
+#define font_height() (use_xft ? (fonts[selected_font].xftfont->ascent + \
+       fonts[selected_font].xftfont->descent) \
+       : (fonts[selected_font].font->max_bounds.ascent + \
+       fonts[selected_font].font->max_bounds.descent))
+#define font_ascent() (use_xft ? fonts[selected_font].xftfont->ascent \
+       : fonts[selected_font].font->max_bounds.ascent)
+#define font_descent() (use_xft ? fonts[selected_font].xftfont->descent \
+       : fonts[selected_font].font->max_bounds.descent)
 
 #else
 
-#define font_height() (fonts[selected_font].font->max_bounds.ascent + fonts[selected_font].font->max_bounds.descent)
+#define font_height() (fonts[selected_font].font->max_bounds.ascent + \
+       fonts[selected_font].font->max_bounds.descent)
 #define font_ascent() fonts[selected_font].font->max_bounds.ascent
 #define font_descent() fonts[selected_font].font->max_bounds.descent
 
@@ -183,7 +181,6 @@ static char *suffixes[] = { "B", "kiB", "MiB", "GiB", "TiB", "PiB", "" };
 
 #define MAX_FONTS 64 // hmm, no particular reason, just makes sense.
 
-
 static void set_font();
 
 int addfont(const char *data_in)
@@ -196,15 +193,17 @@ int addfont(const char *data_in)
                if (fonts != NULL) {
                        free(fonts);
                }
-               if ((fonts = (struct font_list*)malloc(sizeof(struct font_list))) == NULL) {
+               if ((fonts = (struct font_list *) malloc(sizeof(struct font_list)))
+                               == NULL) {
                        CRIT_ERR("malloc");
                }
        }
-       fonts = realloc(fonts, (sizeof(struct font_list) * (font_count+1)));
+       fonts = realloc(fonts, (sizeof(struct font_list) * (font_count + 1)));
        if (fonts == NULL) {
                CRIT_ERR("realloc in addfont");
        }
-       if (strlen(data_in) < TEXT_BUFFER_SIZE) { // must account for null terminator
+       // must account for null terminator
+       if (strlen(data_in) < TEXT_BUFFER_SIZE) {
                strncpy(fonts[font_count].name, data_in, TEXT_BUFFER_SIZE);
 #ifdef XFT
                fonts[font_count].font_alpha = 0xffff;
@@ -218,13 +217,14 @@ int addfont(const char *data_in)
 void set_first_font(const char *data_in)
 {
        if (font_count < 0) {
-               if ((fonts = (struct font_list*)malloc(sizeof(struct font_list))) == NULL) {
+               if ((fonts = (struct font_list *) malloc(sizeof(struct font_list)))
+                               == NULL) {
                        CRIT_ERR("malloc");
                }
                font_count++;
        }
        if (strlen(data_in) > 1) {
-               strncpy(fonts[0].name, data_in, TEXT_BUFFER_SIZE-1);
+               strncpy(fonts[0].name, data_in, TEXT_BUFFER_SIZE - 1);
 #ifdef XFT
                fonts[0].font_alpha = 0xffff;
 #endif
@@ -234,6 +234,7 @@ void set_first_font(const char *data_in)
 void free_fonts()
 {
        int i;
+
        for (i = 0; i <= font_count; i++) {
 #ifdef XFT
                if (use_xft) {
@@ -250,49 +251,51 @@ void free_fonts()
        selected_font = 0;
 }
 
-
 static void load_fonts()
 {
        int i;
-       for (i=0; i <= font_count; i++) {
+
+       for (i = 0; i <= font_count; i++) {
 #ifdef XFT
-       /* load Xft font */
-       if (use_xft) {
-       /*if (fonts[i].xftfont != NULL && selected_font == 0) {
-                       XftFontClose(display, fonts[i].xftfont);
-       }*/
-               if ((fonts[i].xftfont =
-                       XftFontOpenName(display, screen, fonts[i].name)) != NULL)
-                       continue;
-               
-               ERR("can't load Xft font '%s'", fonts[i].name);
-               if ((fonts[i].xftfont =
-                       XftFontOpenName(display, screen,
-                                       "courier-12")) != NULL)
+               /* load Xft font */
+               if (use_xft) {
+                       /* if (fonts[i].xftfont != NULL && selected_font == 0) {
+                               XftFontClose(display, fonts[i].xftfont);
+                       } */
+                       if ((fonts[i].xftfont = XftFontOpenName(display, screen,
+                                       fonts[i].name)) != NULL) {
+                               continue;
+                       }
+
+                       ERR("can't load Xft font '%s'", fonts[i].name);
+                       if ((fonts[i].xftfont = XftFontOpenName(display, screen,
+                                       "courier-12")) != NULL) {
+                               continue;
+                       }
+
+                       ERR("can't load Xft font '%s'", "courier-12");
+
+                       if ((fonts[i].font = XLoadQueryFont(display, "fixed")) == NULL) {
+                               CRIT_ERR("can't load font '%s'", "fixed");
+                       }
+                       use_xft = 0;
+
                        continue;
-               
-               ERR("can't load Xft font '%s'", "courier-12");
-               
-               if ((fonts[i].font = XLoadQueryFont(display, "fixed")) == NULL) {
-                       CRIT_ERR("can't load font '%s'", "fixed");
                }
-               use_xft = 0;
-               
-               continue;
-       }
 #endif
-       /* load normal font */
-/*     if (fonts[i].font != NULL)
-               XFreeFont(display, fonts[i].font);*/
-       
-       if ((fonts[i].font = XLoadQueryFont(display, fonts[i].name)) == NULL) {
-               ERR("can't load font '%s'", fonts[i].name);
-               if ((fonts[i].font = XLoadQueryFont(display, "fixed")) == NULL) {
-                       CRIT_ERR("can't load font '%s'", "fixed");
-                       printf("loaded fixed?\n");
+               /* load normal font */
+               /* if (fonts[i].font != NULL) {
+                       XFreeFont(display, fonts[i].font);
+               } */
+
+               if ((fonts[i].font = XLoadQueryFont(display, fonts[i].name)) == NULL) {
+                       ERR("can't load font '%s'", fonts[i].name);
+                       if ((fonts[i].font = XLoadQueryFont(display, "fixed")) == NULL) {
+                               CRIT_ERR("can't load font '%s'", "fixed");
+                               printf("loaded fixed?\n");
+                       }
                }
        }
-       }
 }
 
 #endif /* X11 */
@@ -331,10 +334,10 @@ static long default_fg_color, default_bg_color, default_out_color;
 /* create own window or draw stuff to root? */
 static int set_transparent = 0;
 
-
 #ifdef OWN_WINDOW
 static int own_window = 0;
 static int background_colour = 0;
+
 /* fixed size/pos is set if wm/user changes them */
 static int fixed_size = 0, fixed_pos = 0;
 #endif
@@ -348,7 +351,8 @@ static int maximum_width;
 static int sensor_device;
 #endif
 
-static long color0, color1, color2, color3, color4, color5, color6, color7, color8, color9;
+static long color0, color1, color2, color3, color4, color5, color6, color7,
+       color8, color9;
 
 /* maximum number of special things, e.g. fonts, offsets, aligns, etc. */
 static unsigned int max_specials = MAX_SPECIALS_DEFAULT;
@@ -389,6 +393,7 @@ void free_iconv(void)
 {
        if (iconv_cd) {
                long i;
+
                for (i = 0; i < iconv_count; i++) {
                        if (iconv_cd[i]) {
                                iconv_close(*iconv_cd[i]);
@@ -398,7 +403,6 @@ void free_iconv(void)
                free(iconv_cd);
        }
        iconv_cd = 0;
-               
 }
 
 #endif
@@ -413,7 +417,7 @@ int no_buffers;
 static int pad_percents = 0;
 
 #ifdef TCP_PORT_MONITOR
-tcp_port_monitor_args_t        tcp_port_monitor_args;
+tcp_port_monitor_args_t tcp_port_monitor_args;
 #endif
 
 static char *text = 0;
@@ -430,8 +434,10 @@ int check_contains(char *f, char *s)
 {
        int ret = 0;
        FILE *where = fopen(f, "r");
+
        if (where) {
                char buf1[256], buf2[256];
+
                while (fgets(buf1, 256, where)) {
                        sscanf(buf1, "%255s", buf2);
                        if (strstr(buf2, s)) {
@@ -446,17 +452,19 @@ int check_contains(char *f, char *s)
        return ret;
 }
 
-
 #ifdef X11
 static inline int calc_text_width(const char *s, int l)
 {
 #ifdef XFT
        if (use_xft) {
                XGlyphInfo gi;
+
                if (utf8_mode) {
-                       XftTextExtentsUtf8(display, fonts[selected_font].xftfont, (FcChar8 *)s, l, &gi);
+                       XftTextExtentsUtf8(display, fonts[selected_font].xftfont,
+                               (FcChar8 *) s, l, &gi);
                } else {
-                       XftTextExtents8(display, fonts[selected_font].xftfont, (FcChar8 *)s, l, &gi);
+                       XftTextExtents8(display, fonts[selected_font].xftfont,
+                               (FcChar8 *) s, l, &gi);
                }
                return gi.xOff;
        } else
@@ -502,25 +510,30 @@ struct special_t {
        double graph_scale;
        int graph_width;
        int scaled;
-       unsigned long first_colour; // for graph gradient
+       unsigned long first_colour;     // for graph gradient
        unsigned long last_colour;
        short font_added;
 };
 
-/* create specials array on heap instead of stack with introduction of max_specials */
+/* create specials array on heap instead of stack with introduction of
+ * max_specials */
 static struct special_t *specials = NULL;
 
 static unsigned int special_count;
+
 #ifdef X11
 static unsigned int special_index;     /* used when drawing */
 #endif /* X11 */
 
-#define MAX_GRAPH_DEPTH 256    /* why 256? cause an array of more then 256 doubles seems excessive, and who needs that kind of precision anyway? */
+/* why 256? cause an array of more then 256 doubles seems excessive,
+ * and who needs that kind of precision anyway? */
+#define MAX_GRAPH_DEPTH 256
 
 static struct special_t *new_special(char *buf, enum special_types t)
 {
-       if (special_count >= max_specials)
+       if (special_count >= max_specials) {
                CRIT_ERR("too many special things in text");
+       }
 
        buf[0] = SPECIAL_CHAR;
        buf[1] = '\0';
@@ -528,7 +541,8 @@ static struct special_t *new_special(char *buf, enum special_types t)
        return &specials[special_count++];
 }
 
-long fwd_fcharfind(FILE* fp, char val, unsigned int step) {
+long fwd_fcharfind(FILE *fp, char val, unsigned int step)
+{
 #define BUFSZ 0x1000
        long ret = -1;
        unsigned int count = 0;
@@ -536,24 +550,26 @@ long fwd_fcharfind(FILE* fp, char val, unsigned int step) {
        long orig_pos = ftell(fp);
        long buf_pos = -1;
        long buf_size = BUFSZ;
-       char* cur_found = NULL;
-       while(count < step) {
-               if(cur_found == NULL) {
+       char *cur_found = NULL;
+
+       while (count < step) {
+               if (cur_found == NULL) {
                        buf_size = fread(buf, 1, buf_size, fp);
                        buf_pos = 0;
                }
-               cur_found = memchr(buf+buf_pos, val, buf_size-buf_pos);
-               if(cur_found != NULL) {
-                       buf_pos = cur_found-buf+1;
+               cur_found = memchr(buf + buf_pos, val, buf_size - buf_pos);
+               if (cur_found != NULL) {
+                       buf_pos = cur_found - buf + 1;
                        count++;
-               }
-               else {
-                       if(feof(fp))
+               } else {
+                       if (feof(fp)) {
                                break;
+                       }
                }
        }
-       if(count == step)
+       if (count == step) {
                ret = ftell(fp) - buf_size + buf_pos - 1;
+       }
        fseek(fp, orig_pos, SEEK_SET);
        return ret;
 #undef BUFSZ
@@ -564,13 +580,17 @@ void *memrchr(const void *buffer, char c, size_t n)
 {
        const unsigned char *p = buffer;
 
-       for (p += n; n ; n--)
-               if (*--p == c)
-                       return (void *)p;
+       for (p += n; n; n--) {
+               if (*--p == c) {
+                       return (void *) p;
+               }
+       }
        return NULL;
 }
 #endif
-long rev_fcharfind(FILE* fp, char val, unsigned int step) {
+
+long rev_fcharfind(FILE *fp, char val, unsigned int step)
+{
 #define BUFSZ 0x1000
        long ret = -1;
        unsigned int count = 0;
@@ -579,13 +599,13 @@ long rev_fcharfind(FILE* fp, char val, unsigned int step) {
        long buf_pos = -1;
        long file_pos = orig_pos;
        long buf_size = BUFSZ;
-       char* cur_found;
-       while(count < step) {
-               if(buf_pos <= 0) {
-                       if(file_pos > BUFSZ) {
-                               fseek(fp, file_pos-BUFSZ, SEEK_SET);
-                       }
-                       else {
+       char *cur_found;
+
+       while (count < step) {
+               if (buf_pos <= 0) {
+                       if (file_pos > BUFSZ) {
+                               fseek(fp, file_pos - BUFSZ, SEEK_SET);
+                       } else {
                                buf_size = file_pos;
                                fseek(fp, 0, SEEK_SET);
                        }
@@ -593,19 +613,20 @@ long rev_fcharfind(FILE* fp, char val, unsigned int step) {
                        buf_pos = fread(buf, 1, buf_size, fp);
                }
                cur_found = memrchr(buf, val, (size_t) buf_pos);
-               if(cur_found != NULL) {
-                       buf_pos = cur_found-buf;
+               if (cur_found != NULL) {
+                       buf_pos = cur_found - buf;
                        count++;
                } else {
                        buf_pos = -1;
-                       if(file_pos == 0) {
+                       if (file_pos == 0) {
                                break;
                        }
                }
        }
        fseek(fp, orig_pos, SEEK_SET);
-       if(count == step)
+       if (count == step) {
                ret = file_pos + buf_pos;
+       }
        return ret;
 #undef BUFSZ
 }
@@ -613,6 +634,7 @@ long rev_fcharfind(FILE* fp, char val, unsigned int step) {
 static void new_bar(char *buf, int w, int h, int usage)
 {
        struct special_t *s = new_special(buf, BAR);
+
        s->arg = (usage > 255) ? 255 : ((usage < 0) ? 0 : usage);
        s->width = w;
        s->height = h;
@@ -620,13 +642,16 @@ static void new_bar(char *buf, int w, int h, int usage)
 
 static const char *scan_bar(const char *args, int *w, int *h)
 {
-       *w = 0;                 /* zero width means all space that is available */
+       /* zero width means all space that is available */
+       *w = 0;
        *h = 6;
        /* bar's argument is either height or height,width */
        if (args) {
                int n = 0;
-               if (sscanf(args, "%d,%d %n", h, w, &n) <= 1)
+
+               if (sscanf(args, "%d,%d %n", h, w, &n) <= 1) {
                        sscanf(args, "%d %n", h, &n);
+               }
                args += n;
        }
 
@@ -635,18 +660,22 @@ static const char *scan_bar(const char *args, int *w, int *h)
 
 static char *scan_font(const char *args)
 {
-  if (args && *args)
+       if (args && *args) {
                return strdup(args);
-  
+       }
+
        return NULL;
 }
 
 #ifdef X11
-static void new_font(char *buf, char * args) {
+static void new_font(char *buf, char *args)
+{
        if (args) {
                struct special_t *s = new_special(buf, FONT);
+
                if (!s->font_added || strcmp(args, fonts[s->font_added].name)) {
                        int tmp = selected_font;
+
                        selected_font = s->font_added = addfont(args);
                        load_fonts();
                        selected_font = tmp;
@@ -654,6 +683,7 @@ static void new_font(char *buf, char * args) {
        } else {
                struct special_t *s = new_special(buf, FONT);
                int tmp = selected_font;
+
                selected_font = s->font_added = 0;
                selected_font = tmp;
        }
@@ -666,14 +696,17 @@ inline void graph_append(struct special_t *graph, double f)
                f = graph->graph_scale;
        }
        int i;
+
        if (graph->scaled) {
                graph->graph_scale = 1;
        }
-       graph->graph[0] = f; /* add new data */
-       for (i = graph->graph_width - 1; i > 0; i--) { /* shift all the data by 1 */
+       graph->graph[0] = f;    /* add new data */
+       /* shift all the data by 1 */
+       for (i = graph->graph_width - 1; i > 0; i--) {
                graph->graph[i] = graph->graph[i - 1];
                if (graph->scaled && graph->graph[i] > graph->graph_scale) {
-                       graph->graph_scale = graph->graph[i]; /* check if we need to update the scale */
+                       /* check if we need to update the scale */
+                       graph->graph_scale = graph->graph[i];
                }
        }
 }
@@ -685,10 +718,11 @@ void set_up_gradient();
 #define CONST_8_TO_5_BITS 0.12156862745098
 #define CONST_8_TO_6_BITS 0.247058823529412
 
-/* adjust color values depending on color depth*/
+/* adjust color values depending on color depth */
 static unsigned int adjust_colors(unsigned int color)
 {
        double r, g, b;
+
        if (colour_depth == 0) {
                set_up_gradient();
        }
@@ -696,20 +730,23 @@ static unsigned int adjust_colors(unsigned int color)
                r = (color & 0xff0000) >> 16;
                g = (color & 0xff00) >> 8;
                b =  color & 0xff;
-               color  = (int)(r * CONST_8_TO_5_BITS) << 11;
-               color |= (int)(g * CONST_8_TO_6_BITS) << 5;
-               color |= (int)(b * CONST_8_TO_5_BITS);
+               color  = (int) (r * CONST_8_TO_5_BITS) << 11;
+               color |= (int) (g * CONST_8_TO_6_BITS) << 5;
+               color |= (int) (b * CONST_8_TO_5_BITS);
        }
        return color;
 }
 
-static void new_graph(char *buf, int w, int h, unsigned int first_colour, unsigned int second_colour, double i, int scale, int append)
+static void new_graph(char *buf, int w, int h, unsigned int first_colour,
+               unsigned int second_colour, double i, int scale, int append)
 {
        struct special_t *s = new_special(buf, GRAPH);
+
        s->width = w;
        if (s->graph == NULL) {
                if (s->width > 0 && s->width < MAX_GRAPH_DEPTH) {
-                       s->graph_width = s->width/* - 2*/;      // subtract 2 for the box
+                       // subtract 2 for the box
+                       s->graph_width = s->width /* - 2 */;
                } else {
                        s->graph_width = MAX_GRAPH_DEPTH - 2;
                }
@@ -725,9 +762,9 @@ static void new_graph(char *buf, int w, int h, unsigned int first_colour, unsign
        } else {
                s->scaled = 1;
        }
-       /*if (s->width) {
+       /* if (s->width) {
                s->graph_width = s->width - 2;  // subtract 2 for rectangle around
-       }*/
+       } */
        if (s->scaled) {
                s->graph_scale = 1;
        } else {
@@ -813,7 +850,6 @@ static char *scan_graph(const char *args, int *w, int *h,
        }
 }
 
-
 static inline void new_hr(char *buf, int a)
 {
        new_special(buf, HORIZONTAL_LINE)->height = a;
@@ -822,6 +858,7 @@ static inline void new_hr(char *buf, int a)
 static inline void new_stippled_hr(char *buf, int a, int b)
 {
        struct special_t *s = new_special(buf, STIPPLED_HR);
+
        s->height = b;
        s->arg = a;
 }
@@ -866,15 +903,17 @@ static inline void new_goto(char *buf, long c)
        new_special(buf, GOTO)->arg = c;
 }
 
-static inline void new_tab(char *buf, int a, int b) {
+static inline void new_tab(char *buf, int a, int b)
+{
        struct special_t *s = new_special(buf, TAB);
+
        s->width = a;
        s->arg = b;
 }
 
 /* quite boring functions */
 
-static inline void for_each_line(char *b, void (*f) (char *))
+static inline void for_each_line(char *b, void f(char *))
 {
        char *ps, *pe;
 
@@ -887,8 +926,9 @@ static inline void for_each_line(char *b, void (*f) (char *))
                }
        }
 
-       if (ps < pe)
+       if (ps < pe) {
                f(ps);
+       }
 }
 
 static void convert_escapes(char *buf)
@@ -898,13 +938,15 @@ static void convert_escapes(char *buf)
        while (*s) {
                if (*s == '\\') {
                        s++;
-                       if (*s == 'n')
+                       if (*s == 'n') {
                                *p++ = '\n';
-                       else if (*s == '\\')
+                       } else if (*s == '\\') {
                                *p++ = '\\';
+                       }
                        s++;
-               } else
+               } else {
                        *p++ = *s++;
+               }
        }
        *p = '\0';
 }
@@ -946,7 +988,7 @@ static int spaced_print(char *buf, int size, char *format, int width,
 /* converts from bytes to human readable format (k, M, G, T) */
 static void human_readable(long long num, char *buf, int size, char *func_name)
 {
-       char ** suffix = suffixes;
+       char **suffix = suffixes;
        float fnum;
        int precision, len;
        static const int WIDTH = 10, SHORT_WIDTH = 8;
@@ -1068,13 +1110,13 @@ enum text_object_type {
        OBJ_i8k_right_fan_status,
        OBJ_i8k_left_fan_rpm,
        OBJ_i8k_right_fan_rpm,
-       OBJ_i8k_ac_status,      
+       OBJ_i8k_ac_status,
        OBJ_i8k_buttons_status,
        OBJ_ibm_fan,
        OBJ_ibm_temps,
        OBJ_ibm_volume,
        OBJ_ibm_brightness,
-        OBJ_pb_battery,
+       OBJ_pb_battery,
        OBJ_voltage_mv,
        OBJ_voltage_v,
        OBJ_wireless_essid,
@@ -1123,7 +1165,7 @@ enum text_object_type {
        OBJ_swapmax,
        OBJ_swapperc,
        OBJ_sysname,
-       OBJ_temp1,              /* i2c is used instead in these */
+       OBJ_temp1,      /* i2c is used instead in these */
        OBJ_temp2,
        OBJ_text,
        OBJ_time,
@@ -1143,7 +1185,8 @@ enum text_object_type {
        OBJ_pop3,
        OBJ_pop3_unseen,
        OBJ_pop3_used,
-#if (defined(__FreeBSD__) || defined(__FreeBSD_kernel__) || defined(__OpenBSD__)) && (defined(i386) || defined(__i386__))
+#if (defined(__FreeBSD__) || defined(__FreeBSD_kernel__) \
+               || defined(__OpenBSD__)) && (defined(i386) || defined(__i386__))
        OBJ_apm_adapter,
        OBJ_apm_battery_time,
        OBJ_apm_battery_life,
@@ -1176,23 +1219,23 @@ enum text_object_type {
        OBJ_mpd_percent,
        OBJ_mpd_smart,
 #endif
-  OBJ_music_player_interval,
+       OBJ_music_player_interval,
 #ifdef XMMS2
-    OBJ_xmms2_artist,
-    OBJ_xmms2_album,
-    OBJ_xmms2_title,
-    OBJ_xmms2_genre,
-    OBJ_xmms2_comment,
-    OBJ_xmms2_decoder,
-    OBJ_xmms2_transport,
-    OBJ_xmms2_url,
-    OBJ_xmms2_date,
-    OBJ_xmms2_tracknr,
-    OBJ_xmms2_bitrate,
-    OBJ_xmms2_id,
-    OBJ_xmms2_duration,
-    OBJ_xmms2_elapsed,
-    OBJ_xmms2_size,
+       OBJ_xmms2_artist,
+       OBJ_xmms2_album,
+       OBJ_xmms2_title,
+       OBJ_xmms2_genre,
+       OBJ_xmms2_comment,
+       OBJ_xmms2_decoder,
+       OBJ_xmms2_transport,
+       OBJ_xmms2_url,
+       OBJ_xmms2_date,
+       OBJ_xmms2_tracknr,
+       OBJ_xmms2_bitrate,
+       OBJ_xmms2_id,
+       OBJ_xmms2_duration,
+       OBJ_xmms2_elapsed,
+       OBJ_xmms2_size,
        OBJ_xmms2_percent,
        OBJ_xmms2_status,
        OBJ_xmms2_bar,
@@ -1241,11 +1284,11 @@ enum text_object_type {
 
 struct text_object {
        union {
-               char *s;        /* some string */
-               int i;          /* some integer */
-               long l;         /* some other integer */
+               char *s;                /* some string */
+               int i;                  /* some integer */
+               long l;                 /* some other integer */
                unsigned int sensor;
-        struct net_stat *net;
+               struct net_stat *net;
                struct fs_stat *fs;
                struct diskio_stat *diskio;
                unsigned char loadavg[3];
@@ -1258,19 +1301,19 @@ struct text_object {
                } mboxscan;
 
                struct {
-                       char *tz;    /* timezone variable */
-                       char *fmt;   /* time display formatting */
+                       char *tz;       /* timezone variable */
+                       char *fmt;      /* time display formatting */
                } tztime;
 
                struct {
                        struct fs_stat *fs;
                        int w, h;
-               } fsbar;        /* 3 */
+               } fsbar;                /* 3 */
 
                struct {
                        int l;
                        int w, h;
-               } mixerbar;     /* 3 */
+               } mixerbar;             /* 3 */
 
                struct {
                        int fd;
@@ -1308,7 +1351,7 @@ struct text_object {
                        char *cmd;
                        char *buffer;
                        double data;
-               } execi;        /* 5 */
+               } execi;                /* 5 */
 
                struct {
                        float interval;
@@ -1320,13 +1363,17 @@ struct text_object {
 
                struct {
                        int a, b;
-               } pair;         /* 2 */
+               } pair;                 /* 2 */
 #ifdef TCP_PORT_MONITOR
                struct {
-                       in_port_t  port_range_begin;  /* starting port to monitor */
-                       in_port_t  port_range_end;    /* ending port to monitor */
-                       int        item;              /* enum from libtcp-portmon.h, e.g. COUNT, etc. */
-                       int        connection_index;  /* 0 to n-1 connections. */
+                       /* starting port to monitor */
+                       in_port_t port_range_begin;
+                       /* ending port to monitor */
+                       in_port_t port_range_end;
+                       /* enum from libtcp-portmon.h, e.g. COUNT, etc. */
+                       int item;
+                       /* 0 to n-1 connections. */
+                       int connection_index;
                } tcp_port_monitor;
 #endif
 #ifdef HDDTEMP
@@ -1334,7 +1381,7 @@ struct text_object {
                        char *addr;
                        int port;
                        char *dev;
-               } hddtemp; /* 2 */
+               } hddtemp;              /* 2 */
 #endif
 #ifdef RSS
                struct {
@@ -1361,21 +1408,26 @@ struct text_object_list {
 
 static unsigned int text_object_count;
 static struct text_object *text_objects;
-static void generate_text_internal(char *p, int p_max_size, struct text_object *objs, unsigned int object_count, struct information *cur);
+static void generate_text_internal(char *p, int p_max_size,
+       struct text_object *objs, unsigned int object_count,
+       struct information *cur);
 
 #define MAXDATASIZE 1000
 #define POP3 1
 #define IMAP 2
 
-struct mail_s* parse_mail_args(char type, const char *arg) {
+struct mail_s *parse_mail_args(char type, const char *arg)
+{
        struct mail_s *mail;
        mail = malloc(sizeof(struct mail_s));
        memset(mail, 0, sizeof(struct mail_s));
        char *tmp;
-       if (sscanf(arg, "%128s %128s %128s", mail->host, mail->user, mail->pass) != 3) {
+
+       if (sscanf(arg, "%128s %128s %128s", mail->host, mail->user, mail->pass)
+                       != 3) {
                if (type == POP3) {
                        ERR("Scanning IMAP args failed");
-               } else  if (type == IMAP) {
+               } else if (type == IMAP) {
                        ERR("Scanning POP3 args failed");
                }
        }
@@ -1383,6 +1435,7 @@ struct mail_s* parse_mail_args(char type, const char *arg) {
        if (mail->pass[0] == '*' && mail->pass[1] == '\0') {
                int fp = fileno(stdin);
                struct termios term;
+
                tcgetattr(fp, &term);
                term.c_lflag &= ~ECHO;
                tcsetattr(fp, TCSANOW, &term);
@@ -1424,13 +1477,14 @@ struct mail_s* parse_mail_args(char type, const char *arg) {
        if (tmp) {
                tmp += 3;
                int len = 1024;
+
                if (tmp[0] == '\'') {
-                       len = strstr(tmp+1, "'") - tmp - 1;
+                       len = strstr(tmp + 1, "'") - tmp - 1;
                        if (len > 1024) {
                                len = 1024;
                        }
                }
-               strncpy(mail->command, tmp+1, len);
+               strncpy(mail->command, tmp + 1, len);
        } else {
                mail->command[0] = '\0';
        }
@@ -1438,7 +1492,7 @@ struct mail_s* parse_mail_args(char type, const char *arg) {
        return mail;
 }
 
-void *imap_thread(struct mail_s* mail)
+void *imap_thread(struct mail_s *mail)
 {
        int sockfd, numbytes;
        char recvbuf[MAXDATASIZE];
@@ -1450,13 +1504,15 @@ void *imap_thread(struct mail_s* mail)
        struct stat stat_buf;
        struct hostent *he;
        struct sockaddr_in their_addr;  // connector's address information
-       if ((he = gethostbyname(mail->host)) == NULL) { // get the host info 
+
+       if ((he = gethostbyname(mail->host)) == NULL) { // get the host info
                herror("gethostbyname");
                exit(1);
        }
        while (fail < 5) {
                if (fail > 0) {
-                   ERR("Trying IMAP connection again for %s@%s (try %i/5)", mail->user, mail->host, fail + 1);
+                       ERR("Trying IMAP connection again for %s@%s (try %i/5)",
+                               mail->user, mail->host, fail + 1);
                }
                if ((sockfd = socket(PF_INET, SOCK_STREAM, 0)) == -1) {
                        perror("socket");
@@ -1464,14 +1520,16 @@ void *imap_thread(struct mail_s* mail)
                        goto next_iteration;
                }
 
-               their_addr.sin_family = AF_INET;        // host byte order 
-               their_addr.sin_port = htons(mail->port);        // short, network byte order 
+               // host byte order
+               their_addr.sin_family = AF_INET;
+               // short, network byte order
+               their_addr.sin_port = htons(mail->port);
                their_addr.sin_addr = *((struct in_addr *) he->h_addr);
-               memset(&(their_addr.sin_zero), '\0', 8);        // zero the rest of the struct 
+               // zero the rest of the struct
+               memset(&(their_addr.sin_zero), '\0', 8);
 
-               if (connect
-                   (sockfd, (struct sockaddr *) &their_addr,
-                    sizeof(struct sockaddr)) == -1) {
+               if (connect(sockfd, (struct sockaddr *) &their_addr,
+                               sizeof(struct sockaddr)) == -1) {
                        perror("connect");
                        fail++;
                        goto next_iteration;
@@ -1479,15 +1537,14 @@ void *imap_thread(struct mail_s* mail)
                struct timeval timeout;
                int res;
                fd_set fdset;
+
                timeout.tv_sec = 60;    // 60 second timeout i guess
                timeout.tv_usec = 0;
                FD_ZERO(&fdset);
                FD_SET(sockfd, &fdset);
                res = select(sockfd + 1, &fdset, NULL, NULL, &timeout);
                if (res > 0) {
-                       if ((numbytes =
-                            recv(sockfd, recvbuf, MAXDATASIZE - 1,
-                                 0)) == -1) {
+                       if ((numbytes = recv(sockfd, recvbuf, MAXDATASIZE - 1, 0)) == -1) {
                                perror("recv");
                                fail++;
                                goto next_iteration;
@@ -1504,11 +1561,9 @@ void *imap_thread(struct mail_s* mail)
                        goto next_iteration;
                }
                strncpy(sendbuf, "a1 login ", MAXDATASIZE);
-               strncat(sendbuf, mail->user,
-                       MAXDATASIZE - strlen(sendbuf) - 1);
+               strncat(sendbuf, mail->user, MAXDATASIZE - strlen(sendbuf) - 1);
                strncat(sendbuf, " ", MAXDATASIZE - strlen(sendbuf) - 1);
-               strncat(sendbuf, mail->pass,
-                       MAXDATASIZE - strlen(sendbuf) - 1);
+               strncat(sendbuf, mail->pass, MAXDATASIZE - strlen(sendbuf) - 1);
                strncat(sendbuf, "\n", MAXDATASIZE - strlen(sendbuf) - 1);
                if (send(sockfd, sendbuf, strlen(sendbuf), 0) == -1) {
                        perror("send a1");
@@ -1521,9 +1576,7 @@ void *imap_thread(struct mail_s* mail)
                FD_SET(sockfd, &fdset);
                res = select(sockfd + 1, &fdset, NULL, NULL, &timeout);
                if (res > 0) {
-                       if ((numbytes =
-                            recv(sockfd, recvbuf, MAXDATASIZE - 1,
-                                 0)) == -1) {
+                       if ((numbytes = recv(sockfd, recvbuf, MAXDATASIZE - 1, 0)) == -1) {
                                perror("recv a1");
                                fail++;
                                goto next_iteration;
@@ -1536,8 +1589,7 @@ void *imap_thread(struct mail_s* mail)
                        goto next_iteration;
                }
                strncpy(sendbuf, "a2 STATUS ", MAXDATASIZE);
-               strncat(sendbuf, mail->folder,
-                       MAXDATASIZE - strlen(sendbuf) - 1);
+               strncat(sendbuf, mail->folder, MAXDATASIZE - strlen(sendbuf) - 1);
                strncat(sendbuf, " (MESSAGES UNSEEN)\n",
                        MAXDATASIZE - strlen(sendbuf) - 1);
                if (send(sockfd, sendbuf, strlen(sendbuf), 0) == -1) {
@@ -1551,9 +1603,7 @@ void *imap_thread(struct mail_s* mail)
                FD_SET(sockfd, &fdset);
                res = select(sockfd + 1, &fdset, NULL, NULL, &timeout);
                if (res > 0) {
-                       if ((numbytes =
-                            recv(sockfd, recvbuf, MAXDATASIZE - 1,
-                                 0)) == -1) {
+                       if ((numbytes = recv(sockfd, recvbuf, MAXDATASIZE - 1, 0)) == -1) {
                                perror("recv a2");
                                fail++;
                                goto next_iteration;
@@ -1574,11 +1624,10 @@ void *imap_thread(struct mail_s* mail)
                        fail++;
                        goto next_iteration;
                } else {
-                       timed_thread_lock (mail->p_timed_thread);
-                       sscanf(reply, "MESSAGES %lu UNSEEN %lu",
-                              &mail->messages,
-                              &mail->unseen);
-                       timed_thread_unlock (mail->p_timed_thread);
+                       timed_thread_lock(mail->p_timed_thread);
+                       sscanf(reply, "MESSAGES %lu UNSEEN %lu", &mail->messages,
+                               &mail->unseen);
+                       timed_thread_unlock(mail->p_timed_thread);
                }
                strncpy(sendbuf, "a3 logout\n", MAXDATASIZE);
                if (send(sockfd, sendbuf, strlen(sendbuf), 0) == -1) {
@@ -1592,9 +1641,7 @@ void *imap_thread(struct mail_s* mail)
                FD_SET(sockfd, &fdset);
                res = select(sockfd + 1, &fdset, NULL, NULL, &timeout);
                if (res > 0) {
-                       if ((numbytes =
-                            recv(sockfd, recvbuf, MAXDATASIZE - 1,
-                                 0)) == -1) {
+                       if ((numbytes = recv(sockfd, recvbuf, MAXDATASIZE - 1, 0)) == -1) {
                                perror("recv a3");
                                fail++;
                                goto next_iteration;
@@ -1606,7 +1653,9 @@ void *imap_thread(struct mail_s* mail)
                        fail++;
                        goto next_iteration;
                }
-               if (strlen(mail->command) > 1 && (mail->unseen > old_unseen || (mail->messages > old_messages && mail->unseen > 0))) {  // new mail goodie
+               if (strlen(mail->command) > 1 && (mail->unseen > old_unseen
+                               || (mail->messages > old_messages && mail->unseen > 0))) {
+                       // new mail goodie
                        if (system(mail->command) == -1) {
                                perror("system()");
                        }
@@ -1615,11 +1664,13 @@ void *imap_thread(struct mail_s* mail)
                old_unseen = mail->unseen;
                old_messages = mail->messages;
 next_iteration:
-               if ((fstat(sockfd, &stat_buf)==0) && S_ISSOCK(stat_buf.st_mode))
-                   /* if a valid socket, close it */
-                   close(sockfd);
-               if (timed_thread_test (mail->p_timed_thread))
-                   timed_thread_exit (mail->p_timed_thread);
+               if ((fstat(sockfd, &stat_buf) == 0) && S_ISSOCK(stat_buf.st_mode)) {
+                       /* if a valid socket, close it */
+                       close(sockfd);
+               }
+               if (timed_thread_test(mail->p_timed_thread)) {
+                       timed_thread_exit(mail->p_timed_thread);
+               }
        }
        mail->unseen = 0;
        mail->messages = 0;
@@ -1637,13 +1688,15 @@ void *pop3_thread(struct mail_s *mail)
        struct stat stat_buf;
        struct hostent *he;
        struct sockaddr_in their_addr;  // connector's address information
-       if ((he = gethostbyname(mail->host)) == NULL) { // get the host info 
+
+       if ((he = gethostbyname(mail->host)) == NULL) { // get the host info
                herror("gethostbyname");
                exit(1);
        }
        while (fail < 5) {
                if (fail > 0) {
-                   ERR("Trying POP3 connection again for %s@%s (try %i/5)", mail->user, mail->host, fail + 1);
+                       ERR("Trying POP3 connection again for %s@%s (try %i/5)",
+                               mail->user, mail->host, fail + 1);
                }
                if ((sockfd = socket(PF_INET, SOCK_STREAM, 0)) == -1) {
                        perror("socket");
@@ -1651,14 +1704,16 @@ void *pop3_thread(struct mail_s *mail)
                        goto next_iteration;
                }
 
-               their_addr.sin_family = AF_INET;        // host byte order 
-               their_addr.sin_port = htons(mail->port);        // short, network byte order 
+               // host byte order
+               their_addr.sin_family = AF_INET;
+               // short, network byte order
+               their_addr.sin_port = htons(mail->port);
                their_addr.sin_addr = *((struct in_addr *) he->h_addr);
-               memset(&(their_addr.sin_zero), '\0', 8);        // zero the rest of the struct 
+               // zero the rest of the struct
+               memset(&(their_addr.sin_zero), '\0', 8);
 
-               if (connect
-                   (sockfd, (struct sockaddr *) &their_addr,
-                    sizeof(struct sockaddr)) == -1) {
+               if (connect(sockfd, (struct sockaddr *) &their_addr,
+                               sizeof(struct sockaddr)) == -1) {
                        perror("connect");
                        fail++;
                        goto next_iteration;
@@ -1666,15 +1721,14 @@ void *pop3_thread(struct mail_s *mail)
                struct timeval timeout;
                int res;
                fd_set fdset;
+
                timeout.tv_sec = 60;    // 60 second timeout i guess
                timeout.tv_usec = 0;
                FD_ZERO(&fdset);
                FD_SET(sockfd, &fdset);
                res = select(sockfd + 1, &fdset, NULL, NULL, &timeout);
                if (res > 0) {
-                       if ((numbytes =
-                            recv(sockfd, recvbuf, MAXDATASIZE - 1,
-                                 0)) == -1) {
+                       if ((numbytes = recv(sockfd, recvbuf, MAXDATASIZE - 1, 0)) == -1) {
                                perror("recv");
                                fail++;
                                goto next_iteration;
@@ -1691,8 +1745,7 @@ void *pop3_thread(struct mail_s *mail)
                        goto next_iteration;
                }
                strncpy(sendbuf, "USER ", MAXDATASIZE);
-               strncat(sendbuf, mail->user,
-                       MAXDATASIZE - strlen(sendbuf) - 1);
+               strncat(sendbuf, mail->user, MAXDATASIZE - strlen(sendbuf) - 1);
                strncat(sendbuf, "\n", MAXDATASIZE - strlen(sendbuf) - 1);
                if (send(sockfd, sendbuf, strlen(sendbuf), 0) == -1) {
                        perror("send USER");
@@ -1705,9 +1758,7 @@ void *pop3_thread(struct mail_s *mail)
                FD_SET(sockfd, &fdset);
                res = select(sockfd + 1, &fdset, NULL, NULL, &timeout);
                if (res > 0) {
-                       if ((numbytes =
-                            recv(sockfd, recvbuf, MAXDATASIZE - 1,
-                                 0)) == -1) {
+                       if ((numbytes = recv(sockfd, recvbuf, MAXDATASIZE - 1, 0)) == -1) {
                                perror("recv USER");
                                fail++;
                                goto next_iteration;
@@ -1720,8 +1771,7 @@ void *pop3_thread(struct mail_s *mail)
                        goto next_iteration;
                }
                strncpy(sendbuf, "PASS ", MAXDATASIZE);
-               strncat(sendbuf, mail->pass,
-                       MAXDATASIZE - strlen(sendbuf) - 1);
+               strncat(sendbuf, mail->pass, MAXDATASIZE - strlen(sendbuf) - 1);
                strncat(sendbuf, "\n", MAXDATASIZE - strlen(sendbuf) - 1);
                if (send(sockfd, sendbuf, strlen(sendbuf), 0) == -1) {
                        perror("send PASS");
@@ -1734,9 +1784,7 @@ void *pop3_thread(struct mail_s *mail)
                FD_SET(sockfd, &fdset);
                res = select(sockfd + 1, &fdset, NULL, NULL, &timeout);
                if (res > 0) {
-                       if ((numbytes =
-                            recv(sockfd, recvbuf, MAXDATASIZE - 1,
-                                 0)) == -1) {
+                       if ((numbytes = recv(sockfd, recvbuf, MAXDATASIZE - 1, 0)) == -1) {
                                perror("recv PASS");
                                fail++;
                                goto next_iteration;
@@ -1760,9 +1808,7 @@ void *pop3_thread(struct mail_s *mail)
                FD_SET(sockfd, &fdset);
                res = select(sockfd + 1, &fdset, NULL, NULL, &timeout);
                if (res > 0) {
-                       if ((numbytes =
-                            recv(sockfd, recvbuf, MAXDATASIZE - 1,
-                                 0)) == -1) {
+                       if ((numbytes = recv(sockfd, recvbuf, MAXDATASIZE - 1, 0)) == -1) {
                                perror("recv STAT");
                                fail++;
                                goto next_iteration;
@@ -1781,10 +1827,9 @@ void *pop3_thread(struct mail_s *mail)
                        fail++;
                        goto next_iteration;
                } else {
-                       timed_thread_lock (mail->p_timed_thread);
-                       sscanf(reply, "%lu %lu", &mail->unseen,
-                              &mail->used);
-                       timed_thread_unlock (mail->p_timed_thread);
+                       timed_thread_lock(mail->p_timed_thread);
+                       sscanf(reply, "%lu %lu", &mail->unseen, &mail->used);
+                       timed_thread_unlock(mail->p_timed_thread);
                }
                strncpy(sendbuf, "QUIT\n", MAXDATASIZE);
                if (send(sockfd, sendbuf, strlen(sendbuf), 0) == -1) {
@@ -1798,9 +1843,7 @@ void *pop3_thread(struct mail_s *mail)
                FD_SET(sockfd, &fdset);
                res = select(sockfd + 1, &fdset, NULL, NULL, &timeout);
                if (res > 0) {
-                       if ((numbytes =
-                            recv(sockfd, recvbuf, MAXDATASIZE - 1,
-                                 0)) == -1) {
+                       if ((numbytes = recv(sockfd, recvbuf, MAXDATASIZE - 1, 0)) == -1) {
                                perror("recv QUIT");
                                fail++;
                                goto next_iteration;
@@ -1812,7 +1855,8 @@ void *pop3_thread(struct mail_s *mail)
                        fail++;
                        goto next_iteration;
                }
-               if (strlen(mail->command) > 1 && mail->unseen > old_unseen) {   // new mail goodie
+               if (strlen(mail->command) > 1 && mail->unseen > old_unseen) {
+                       // new mail goodie
                        if (system(mail->command) == -1) {
                                perror("system()");
                        }
@@ -1820,25 +1864,29 @@ void *pop3_thread(struct mail_s *mail)
                fail = 0;
                old_unseen = mail->unseen;
 next_iteration:
-               if ((fstat(sockfd, &stat_buf)==0) && S_ISSOCK(stat_buf.st_mode))  
-                   /* if a valid socket, close it */
-                   close(sockfd);
-               if (timed_thread_test (mail->p_timed_thread))
-                   timed_thread_exit (mail->p_timed_thread);
+               if ((fstat(sockfd, &stat_buf) == 0) && S_ISSOCK(stat_buf.st_mode)) {
+                       /* if a valid socket, close it */
+                       close(sockfd);
+               }
+               if (timed_thread_test(mail->p_timed_thread)) {
+                       timed_thread_exit(mail->p_timed_thread);
+               }
        }
        mail->unseen = 0;
        mail->used = 0;
        return 0;
 }
 
-
-void *threaded_exec(struct text_object *obj) { 
+void *threaded_exec(struct text_object *obj)
+{
        while (1) {
                char *p2 = obj->data.texeci.buffer;
-               FILE *fp = popen(obj->data.texeci.cmd,"r");
-               timed_thread_lock (obj->data.texeci.p_timed_thread);
+               FILE *fp = popen(obj->data.texeci.cmd, "r");
+
+               timed_thread_lock(obj->data.texeci.p_timed_thread);
                int n2 = fread(p2, 1, text_buffer_size, fp);
-               (void) pclose(fp);
+
+               pclose(fp);
                p2[n2] = '\0';
                if (n2 && p2[n2 - 1] == '\n') {
                        p2[n2 - 1] = '\0';
@@ -1849,9 +1897,10 @@ void *threaded_exec(struct text_object *obj) {
                        }
                        p2++;
                }
-               timed_thread_unlock (obj->data.texeci.p_timed_thread);
-               if (timed_thread_test (obj->data.texeci.p_timed_thread))
-                   timed_thread_exit (obj->data.texeci.p_timed_thread);
+               timed_thread_unlock(obj->data.texeci.p_timed_thread);
+               if (timed_thread_test(obj->data.texeci.p_timed_thread)) {
+                       timed_thread_exit(obj->data.texeci.p_timed_thread);
+               }
        }
        return 0;
 }
@@ -1866,6 +1915,7 @@ static struct text_object *new_text_object_internal()
 static void free_text_objects(unsigned int count, struct text_object *objs)
 {
        unsigned int i;
+
        for (i = 0; i < count; i++) {
                switch (objs[i].type) {
 #ifndef __OpenBSD__
@@ -1878,12 +1928,12 @@ static void free_text_objects(unsigned int count, struct text_object *objs)
                        case OBJ_i2c:
                                close(objs[i].data.sysfs.fd);
                                break;
-      case OBJ_platform:
-        close(objs[i].data.sysfs.fd);
-        break;
-      case OBJ_hwmon:
-        close(objs[i].data.sysfs.fd);
-        break;
+                       case OBJ_platform:
+                               close(objs[i].data.sysfs.fd);
+                               break;
+                       case OBJ_hwmon:
+                               close(objs[i].data.sysfs.fd);
+                               break;
 #endif /* !__OpenBSD__ */
                        case OBJ_time:
                                free(objs[i].data.s);
@@ -1956,12 +2006,12 @@ static void free_text_objects(unsigned int count, struct text_object *objs)
                        case OBJ_execgraph:
                                free(objs[i].data.s);
                                break;
-                               /*              case OBJ_execibar:
-                                               free(objs[i].data.s);
-                                               break;
-                                               case OBJ_execigraph:
-                                               free(objs[i].data.s);
-                                               break;*/
+                       /* case OBJ_execibar:
+                               free(objs[i].data.s);
+                               break;
+                       case OBJ_execigraph:
+                               free(objs[i].data.s);
+                               break; */
 #ifdef HAVE_ICONV
                        case OBJ_iconv_start:
                                free_iconv();
@@ -2102,47 +2152,45 @@ static void free_text_objects(unsigned int count, struct text_object *objs)
        }
        free(objs);
 #ifdef MPD
-       {
-               if (info.mpd.title) {
-                       free(info.mpd.title);
-                       info.mpd.title = 0;
-               }
-               if (info.mpd.artist) {
-                       free(info.mpd.artist);
-                       info.mpd.artist = 0;
-               }
-               if (info.mpd.album) {
-                       free(info.mpd.album);
-                       info.mpd.album = 0;
-               }
-               if (info.mpd.random) {
-                       free(info.mpd.random);
-                       info.mpd.random = 0;
-               }
-               if (info.mpd.repeat) {
-                       free(info.mpd.repeat);
-                       info.mpd.repeat = 0;
-               }
-               if (info.mpd.track) {
-                       free(info.mpd.track);
-                       info.mpd.track = 0;
-               }
-               if (info.mpd.name) {
-                       free(info.mpd.name);
-                       info.mpd.name = 0;
-               }
-               if (info.mpd.file) {
-                       free(info.mpd.file);
-                       info.mpd.file = 0;
-               }
-               if (info.mpd.status) {
-                       free(info.mpd.status);
-                       info.mpd.status = 0;
-               }
+       if (info.mpd.title) {
+               free(info.mpd.title);
+               info.mpd.title = NULL;
+       }
+       if (info.mpd.artist) {
+               free(info.mpd.artist);
+               info.mpd.artist = NULL;
+       }
+       if (info.mpd.album) {
+               free(info.mpd.album);
+               info.mpd.album = NULL;
+       }
+       if (info.mpd.random) {
+               free(info.mpd.random);
+               info.mpd.random = NULL;
+       }
+       if (info.mpd.repeat) {
+               free(info.mpd.repeat);
+               info.mpd.repeat = NULL;
+       }
+       if (info.mpd.track) {
+               free(info.mpd.track);
+               info.mpd.track = NULL;
+       }
+       if (info.mpd.name) {
+               free(info.mpd.name);
+               info.mpd.name = NULL;
+       }
+       if (info.mpd.file) {
+               free(info.mpd.file);
+               info.mpd.file = NULL;
+       }
+       if (info.mpd.status) {
+               free(info.mpd.status);
+               info.mpd.status = NULL;
        }
 #endif
-       //text_objects = NULL;
-       //text_object_count = 0;
+       /* text_objects = NULL;
+       text_object_count = 0; */
 }
 
 void scan_mixer_bar(const char *arg, int *a, int *w, int *h)
@@ -2152,265 +2200,270 @@ void scan_mixer_bar(const char *arg, int *a, int *w, int *h)
 
        if (arg && sscanf(arg, "%63s %n", buf1, &n) >= 1) {
                *a = mixer_init(buf1);
-               (void) scan_bar(arg + n, w, h);
+               scan_bar(arg + n, w, h);
        } else {
-               *a = mixer_init(0);
-               (void) scan_bar(arg, w, h);
+               *a = mixer_init(NULL);
+               scan_bar(arg, w, h);
        }
 }
 
-
 /* construct_text_object() creates a new text_object */
-static struct text_object *construct_text_object(const char *s, const char *arg, unsigned int object_count, struct text_object *text_objects, long line)
+static struct text_object *construct_text_object(const char *s,
+               const char *arg, unsigned int object_count,
+               struct text_object *text_objects, long line)
 {
-       //struct text_object *obj = new_text_object();
+       // struct text_object *obj = new_text_object();
        struct text_object *obj = new_text_object_internal();
+
        obj->line = line;
 
-#define OBJ(a, n) if (strcmp(s, #a) == 0) { obj->type = OBJ_##a; need_mask |= (1 << n); {
-#define END ; } } else
+#define OBJ(a, n) if (strcmp(s, #a) == 0) { \
+       obj->type = OBJ_##a; need_mask |= (1 << n); {
+#define END } } else
 
-#ifdef X11     
+#ifdef X11
        if (s[0] == '#') {
                obj->type = OBJ_color;
                obj->data.l = get_x11_color(s);
        } else
 #endif /* X11 */
-#ifndef __OpenBSD__
-               OBJ(acpitemp, 0) obj->data.i = open_acpi_temperature(arg);
-       END OBJ(acpitempf, 0) obj->data.i = open_acpi_temperature(arg);
-       END OBJ(acpiacadapter, 0)
-#endif /* !__OpenBSD__ */
 #ifdef __OpenBSD__
        OBJ(freq, INFO_FREQ)
 #else
+       OBJ(acpitemp, 0)
+               obj->data.i = open_acpi_temperature(arg);
+       END OBJ(acpitempf, 0)
+               obj->data.i = open_acpi_temperature(arg);
+       END OBJ(acpiacadapter, 0)
        END OBJ(freq, INFO_FREQ)
-#endif
-           get_cpu_count();
-       if (!arg
-           || !isdigit(arg[0])
-           || strlen(arg) >=2
-           || atoi(&arg[0])==0
-           || (unsigned int)atoi(&arg[0])>info.cpu_count)
-       {
-           obj->data.cpu_index=1;
-//         ERR("freq: Invalid CPU number or you don't have that many CPUs! Displaying the clock for CPU 1.");
-       }
-       else 
-       {
-           obj->data.cpu_index=atoi(&arg[0]);
-       }
-       obj->a = 1;
+#endif /* !__OpenBSD__ */
+               get_cpu_count();
+               if (!arg || !isdigit(arg[0]) || strlen(arg) >= 2 || atoi(&arg[0]) == 0
+                               || (unsigned int) atoi(&arg[0]) > info.cpu_count) {
+                       obj->data.cpu_index = 1;
+                       /* ERR("freq: Invalid CPU number or you don't have that many CPUs! "
+                               "Displaying the clock for CPU 1."); */
+               } else {
+                       obj->data.cpu_index = atoi(&arg[0]);
+               }
+               obj->a = 1;
        END OBJ(freq_g, INFO_FREQ)
-           get_cpu_count();
-       if (!arg
-           || !isdigit(arg[0])
-           || strlen(arg) >=2
-           || atoi(&arg[0])==0
-           || (unsigned int)atoi(&arg[0])>info.cpu_count)
-       {
-           obj->data.cpu_index=1;
-//         ERR("freq_g: Invalid CPU number or you don't have that many CPUs! Displaying the clock for CPU 1.");
-       }
-       else 
-       {
-           obj->data.cpu_index=atoi(&arg[0]);
-       }
-       obj->a = 1;
+               get_cpu_count();
+               if (!arg || !isdigit(arg[0]) || strlen(arg) >= 2 || atoi(&arg[0]) == 0
+                               || (unsigned int) atoi(&arg[0]) > info.cpu_count) {
+                       obj->data.cpu_index = 1;
+                       /* ERR("freq_g: Invalid CPU number or you don't have that many "
+                               "CPUs! Displaying the clock for CPU 1."); */
+               } else {
+                       obj->data.cpu_index = atoi(&arg[0]);
+               }
+               obj->a = 1;
 #if defined(__linux__)
        END OBJ(voltage_mv, 0)
-           get_cpu_count();
-       if (!arg
-           || !isdigit(arg[0])
-           || strlen(arg) >=2
-           || atoi(&arg[0])==0
-           || (unsigned int)atoi(&arg[0])>info.cpu_count)
-       {
-           obj->data.cpu_index=1;
-//         ERR("voltage_mv: Invalid CPU number or you don't have that many CPUs! Displaying voltage for CPU 1.");
-       }
-       else 
-       {
-           obj->data.cpu_index=atoi(&arg[0]);
-       }
-       obj->a = 1;
+               get_cpu_count();
+               if (!arg || !isdigit(arg[0]) || strlen(arg) >= 2 || atoi(&arg[0]) == 0
+                               || (unsigned int) atoi(&arg[0]) > info.cpu_count) {
+                       obj->data.cpu_index = 1;
+                       /* ERR("voltage_mv: Invalid CPU number or you don't have that many "
+                               "CPUs! Displaying voltage for CPU 1."); */
+               } else {
+                       obj->data.cpu_index = atoi(&arg[0]);
+               }
+               obj->a = 1;
        END OBJ(voltage_v, 0)
-           get_cpu_count();
-       if (!arg
-           || !isdigit(arg[0])
-           || strlen(arg) >=2
-           || atoi(&arg[0])==0
-           || (unsigned int)atoi(&arg[0])>info.cpu_count)
-       {
-           obj->data.cpu_index=1;
-//         ERR("voltage_v: Invalid CPU number or you don't have that many CPUs! Displaying voltage for CPU 1.");
-       }
-       else 
-       {
-           obj->data.cpu_index=atoi(&arg[0]);
-       }
-       obj->a = 1;
+               get_cpu_count();
+               if (!arg || !isdigit(arg[0]) || strlen(arg) >= 2 || atoi(&arg[0]) == 0
+                               || (unsigned int) atoi(&arg[0]) > info.cpu_count) {
+                       obj->data.cpu_index = 1;
+                       /* ERR("voltage_v: Invalid CPU number or you don't have that many "
+                               "CPUs! Displaying voltage for CPU 1."); */
+               } else {
+                       obj->data.cpu_index = atoi(&arg[0]);
+               }
+               obj->a = 1;
 
 #ifdef HAVE_IWLIB
        END OBJ(wireless_essid, INFO_NET)
-       if(arg)
-               obj->data.net = get_net_stat(arg);
-       else
-               CRIT_ERR("wireless_essid: needs an argument");
+               if (arg) {
+                       obj->data.net = get_net_stat(arg);
+               } else {
+                       CRIT_ERR("wireless_essid: needs an argument");
+               }
        END OBJ(wireless_mode, INFO_NET)
-       if(arg)
-               obj->data.net = get_net_stat(arg);
-       else
-               CRIT_ERR("wireless_mode: needs an argument");
+               if (arg) {
+                       obj->data.net = get_net_stat(arg);
+               } else {
+                       CRIT_ERR("wireless_mode: needs an argument");
+               }
        END OBJ(wireless_bitrate, INFO_NET)
-       if(arg)
-               obj->data.net = get_net_stat(arg);
-       else
-               CRIT_ERR("wireless_bitrate: needs an argument");
+               if (arg) {
+                       obj->data.net = get_net_stat(arg);
+               } else {
+                       CRIT_ERR("wireless_bitrate: needs an argument");
+               }
        END OBJ(wireless_ap, INFO_NET)
-       if(arg)
-               obj->data.net = get_net_stat(arg);
-       else
-               CRIT_ERR("wireless_ap: needs an argument");
+               if (arg) {
+                       obj->data.net = get_net_stat(arg);
+               } else {
+                       CRIT_ERR("wireless_ap: needs an argument");
+               }
        END OBJ(wireless_link_qual, INFO_NET)
-       if(arg)
-               obj->data.net = get_net_stat(arg);
-       else
-               CRIT_ERR("wireless_link_qual: needs an argument");
+               if (arg) {
+                       obj->data.net = get_net_stat(arg);
+               } else {
+                       CRIT_ERR("wireless_link_qual: needs an argument");
+               }
        END OBJ(wireless_link_qual_max, INFO_NET)
-       if(arg)
-               obj->data.net = get_net_stat(arg);
-       else
-               CRIT_ERR("wireless_link_qual_max: needs an argument");
+               if (arg) {
+                       obj->data.net = get_net_stat(arg);
+               } else {
+                       CRIT_ERR("wireless_link_qual_max: needs an argument");
+               }
        END OBJ(wireless_link_qual_perc, INFO_NET)
-       if(arg)
-               obj->data.net = get_net_stat(arg);
-       else
-               CRIT_ERR("wireless_link_qual_perc: needs an argument");
+               if (arg) {
+                       obj->data.net = get_net_stat(arg);
+               } else {
+                       CRIT_ERR("wireless_link_qual_perc: needs an argument");
+               }
        END OBJ(wireless_link_bar, INFO_NET)
-       if(arg) {
-               arg = scan_bar(arg, &obj->a, &obj->b);
-               obj->data.net = get_net_stat(arg);
-       } else
-               CRIT_ERR("wireless_link_bar: needs an argument");
+               if (arg) {
+                       arg = scan_bar(arg, &obj->a, &obj->b);
+                       obj->data.net = get_net_stat(arg);
+               } else {
+                       CRIT_ERR("wireless_link_bar: needs an argument");
+               }
 #endif /* HAVE_IWLIB */
 
 #endif /* __linux__ */
        END OBJ(freq_dyn, 0)
        END OBJ(freq_dyn_g, 0)
+
 #ifndef __OpenBSD__
        END OBJ(acpifan, 0)
        END OBJ(battery, 0)
-       char bat[64];
-       if (arg)
-               sscanf(arg, "%63s", bat);
-       else
-               strcpy(bat, "BAT0");
-       obj->data.s = strdup(bat);
+               char bat[64];
+
+               if (arg) {
+                       sscanf(arg, "%63s", bat);
+               } else {
+                       strcpy(bat, "BAT0");
+               }
+               obj->data.s = strdup(bat);
        END OBJ(battery_time, 0)
-       char bat[64];
-       if (arg)
-               sscanf(arg, "%63s", bat);
-       else
-               strcpy(bat, "BAT0");
-       obj->data.s = strdup(bat);
+               char bat[64];
+
+               if (arg) {
+                       sscanf(arg, "%63s", bat);
+               } else {
+                       strcpy(bat, "BAT0");
+               }
+               obj->data.s = strdup(bat);
        END OBJ(battery_percent, 0)
-       char bat[64];
-       if (arg)
-               sscanf(arg, "%63s", bat);
-       else
-               strcpy(bat, "BAT0");
-       obj->data.s = strdup(bat);
+               char bat[64];
+
+               if (arg) {
+                       sscanf(arg, "%63s", bat);
+               } else {
+                       strcpy(bat, "BAT0");
+               }
+               obj->data.s = strdup(bat);
        END OBJ(battery_bar, 0)
-       char bat[64];
-       if (arg) {
-               arg = scan_bar(arg, &obj->a, &obj->b);
-               sscanf(arg, "%63s", bat);
-       } else {
-               strcpy(bat, "BAT0");
-       }
-       obj->data.s = strdup(bat);
+               char bat[64];
+
+               if (arg) {
+                       arg = scan_bar(arg, &obj->a, &obj->b);
+                       sscanf(arg, "%63s", bat);
+               } else {
+                       strcpy(bat, "BAT0");
+               }
+               obj->data.s = strdup(bat);
 #endif /* !__OpenBSD__ */
+
 #if defined(__linux__)
        END OBJ(i8k_version, INFO_I8K)
-               END OBJ(i8k_bios, INFO_I8K)
-               END OBJ(i8k_serial, INFO_I8K)
-               END OBJ(i8k_cpu_temp, INFO_I8K)
-               END OBJ(i8k_cpu_tempf, INFO_I8K)
-               END OBJ(i8k_left_fan_status, INFO_I8K)  
-               END OBJ(i8k_right_fan_status, INFO_I8K)
-               END OBJ(i8k_left_fan_rpm, INFO_I8K)
-               END OBJ(i8k_right_fan_rpm, INFO_I8K)
-               END OBJ(i8k_ac_status, INFO_I8K)
-               END OBJ(i8k_buttons_status, INFO_I8K)
+       END OBJ(i8k_bios, INFO_I8K)
+       END OBJ(i8k_serial, INFO_I8K)
+       END OBJ(i8k_cpu_temp, INFO_I8K)
+       END OBJ(i8k_cpu_tempf, INFO_I8K)
+       END OBJ(i8k_left_fan_status, INFO_I8K)
+       END OBJ(i8k_right_fan_status, INFO_I8K)
+       END OBJ(i8k_left_fan_rpm, INFO_I8K)
+       END OBJ(i8k_right_fan_rpm, INFO_I8K)
+       END OBJ(i8k_ac_status, INFO_I8K)
+       END OBJ(i8k_buttons_status, INFO_I8K)
        END OBJ(ibm_fan, 0)
        END OBJ(ibm_temps, 0)
-           if (!arg) {
-               CRIT_ERR("ibm_temps: needs an argument");
-           }
-           if (!isdigit(arg[0])
-                        || strlen(arg) >=2
-                        || atoi(&arg[0]) >=8)
-           {
-               obj->data.sensor=0;
-               ERR("Invalid temperature sensor! Sensor number must be 0 to 7. Using 0 (CPU temp sensor).");
-           }
+               if (!arg) {
+                       CRIT_ERR("ibm_temps: needs an argument");
+               }
+               if (!isdigit(arg[0]) || strlen(arg) >= 2 || atoi(&arg[0]) >= 8) {
+                       obj->data.sensor = 0;
+                       ERR("Invalid temperature sensor! Sensor number must be 0 to 7. "
+                               "Using 0 (CPU temp sensor).");
+               }
                obj->data.sensor = atoi(&arg[0]);
        END OBJ(ibm_volume, 0)
        END OBJ(ibm_brightness, 0)
        END OBJ(pb_battery, 0)
-                if (arg && strcmp(arg, "status") == 0) {
-                        obj->data.i = PB_BATT_STATUS;
-                } else if (arg && strcmp(arg, "percent") == 0) {
-                        obj->data.i = PB_BATT_PERCENT;
-                } else if (arg && strcmp(arg, "time") == 0) {
-                        obj->data.i = PB_BATT_TIME;
-                } else {
-                        ERR("pb_battery: needs one argument: status, percent or time");
-                        free(obj);
-                        return NULL;
-                }
+               if (arg && strcmp(arg, "status") == 0) {
+                       obj->data.i = PB_BATT_STATUS;
+               } else if (arg && strcmp(arg, "percent") == 0) {
+                       obj->data.i = PB_BATT_PERCENT;
+               } else if (arg && strcmp(arg, "time") == 0) {
+                       obj->data.i = PB_BATT_TIME;
+               } else {
+                       ERR("pb_battery: needs one argument: status, percent or time");
+                       free(obj);
+                       return NULL;
+               }
 
 #endif /* __linux__ */
 #if defined(__OpenBSD__)
        END OBJ(obsd_sensors_temp, 0)
-               if(!arg) {
+               if (!arg) {
                        CRIT_ERR("obsd_sensors_temp: needs an argument");
                }
-               if(!isdigit(arg[0]) || atoi(&arg[0]) < 0 || atoi(&arg[0]) > OBSD_MAX_SENSORS-1) {
-                       obj->data.sensor=0;
+               if (!isdigit(arg[0]) || atoi(&arg[0]) < 0
+                               || atoi(&arg[0]) > OBSD_MAX_SENSORS - 1) {
+                       obj->data.sensor = 0;
                        ERR("Invalid temperature sensor number!");
                }
-                       obj->data.sensor = atoi(&arg[0]);
+               obj->data.sensor = atoi(&arg[0]);
        END OBJ(obsd_sensors_fan, 0)
-               if(!arg) {
-                       CRIT_ERR("obsd_sensors_fan: needs 2 arguments (device and sensor number)");
+               if (!arg) {
+                       CRIT_ERR("obsd_sensors_fan: needs 2 arguments (device and sensor "
+                               "number)");
                }
-               if(!isdigit(arg[0]) || atoi(&arg[0]) < 0 || atoi(&arg[0]) > OBSD_MAX_SENSORS-1) {
-                       obj->data.sensor=0;
+               if (!isdigit(arg[0]) || atoi(&arg[0]) < 0
+                               || atoi(&arg[0]) > OBSD_MAX_SENSORS - 1) {
+                       obj->data.sensor = 0;
                        ERR("Invalid fan sensor number!");
                }
-                       obj->data.sensor = atoi(&arg[0]);
+               obj->data.sensor = atoi(&arg[0]);
        END OBJ(obsd_sensors_volt, 0)
-               if(!arg) {
-                       CRIT_ERR("obsd_sensors_volt: needs 2 arguments (device and sensor number)");
+               if (!arg) {
+                       CRIT_ERR("obsd_sensors_volt: needs 2 arguments (device and sensor "
+                               "number)");
                }
-               if(!isdigit(arg[0]) || atoi(&arg[0]) < 0 || atoi(&arg[0]) > OBSD_MAX_SENSORS-1) {
-                       obj->data.sensor=0;
+               if (!isdigit(arg[0]) || atoi(&arg[0]) < 0
+                               || atoi(&arg[0]) > OBSD_MAX_SENSORS - 1) {
+                       obj->data.sensor = 0;
                        ERR("Invalid voltage sensor number!");
                }
-                       obj->data.sensor = atoi(&arg[0]);
+               obj->data.sensor = atoi(&arg[0]);
        END OBJ(obsd_vendor, 0)
        END OBJ(obsd_product, 0)
 #endif /* __OpenBSD__ */
-               END OBJ(buffers, INFO_BUFFERS)
-               END OBJ(cached, INFO_BUFFERS)
-               END OBJ(cpu, INFO_CPU)
+       END OBJ(buffers, INFO_BUFFERS)
+       END OBJ(cached, INFO_BUFFERS)
+       END OBJ(cpu, INFO_CPU)
                if (arg) {
                        if (strncmp(arg, "cpu", 3) == 0 && isdigit(arg[3])) {
                                obj->data.cpu_index = atoi(&arg[3]);
                                arg += 4;
-                       } else {obj->data.cpu_index = 0; }
+                       } else {
+                               obj->data.cpu_index = 0;
+                       }
                } else {
                        obj->data.cpu_index = 0;
                }
@@ -2419,11 +2472,12 @@ static struct text_object *construct_text_object(const char *s, const char *arg,
                        if (strncmp(arg, "cpu", 3) == 0 && isdigit(arg[3])) {
                                obj->data.cpu_index = atoi(&arg[3]);
                                arg += 4;
+                       } else {
+                               obj->data.cpu_index = 0;
                        }
-                       else {obj->data.cpu_index = 0;}
-                       (void) scan_bar(arg, &obj->a, &obj->b);
+                       scan_bar(arg, &obj->a, &obj->b);
                } else {
-                       (void) scan_bar(arg, &obj->a, &obj->b);
+                       scan_bar(arg, &obj->a, &obj->b);
                        obj->data.cpu_index = 0;
                }
        END OBJ(cpugraph, INFO_CPU)
@@ -2486,7 +2540,7 @@ static struct text_object *construct_text_object(const char *s, const char *arg,
                } else {
                        obj->data.diskio = NULL;
                }
-       END OBJ(color, 0) 
+       END OBJ(color, 0)
 #ifdef X11
                obj->data.l = arg ? get_x11_color(arg) : default_fg_color;
 #endif /* X11 */
@@ -2512,18 +2566,16 @@ static struct text_object *construct_text_object(const char *s, const char *arg,
                obj->data.l = color9;
        END OBJ(font, 0)
                obj->data.s = scan_font(arg);
-       END OBJ(downspeed, INFO_NET) 
-               if(arg) {
+       END OBJ(downspeed, INFO_NET)
+               if (arg) {
                        obj->data.net = get_net_stat(arg);
-               }
-               else {
+               } else {
                        CRIT_ERR("downspeed needs argument");
                }
        END OBJ(downspeedf, INFO_NET)
-               if(arg) {
+               if (arg) {
                        obj->data.net = get_net_stat(arg);
-               }
-               else {
+               } else {
                        CRIT_ERR("downspeedf needs argument");
                }
        END OBJ(downspeedgraph, INFO_NET)
@@ -2536,7 +2588,8 @@ static struct text_object *construct_text_object(const char *s, const char *arg,
                }
        END OBJ(else, 0)
                if (blockdepth) {
-                       (text_objects[blockstart[blockdepth - 1]]).data.ifblock.pos = object_count;
+                       (text_objects[blockstart[blockdepth - 1]]).data.ifblock.pos =
+                               object_count;
                        blockstart[blockdepth - 1] = object_count;
                        obj->data.ifblock.pos = object_count + 2;
                } else {
@@ -2545,550 +2598,606 @@ static struct text_object *construct_text_object(const char *s, const char *arg,
        END OBJ(endif, 0)
                if (blockdepth) {
                        blockdepth--;
-                       text_objects[blockstart[blockdepth]].data.ifblock.pos = object_count;
+                       text_objects[blockstart[blockdepth]].data.ifblock.pos =
+                               object_count;
                } else {
                        ERR("$endif: no matching $if_*");
                }
-       END
-       OBJ(image, 0) obj->data.s = strdup(arg ? arg : "");
-       END
+       END OBJ(image, 0)
+               obj->data.s = strdup(arg ? arg : "");
 #ifdef HAVE_POPEN
-       OBJ(exec, 0) obj->data.s = strdup(arg ? arg : "");
-       END OBJ(execbar, 0) obj->data.s = strdup(arg ? arg : "");
-       END OBJ(execgraph, 0) obj->data.s = strdup(arg ? arg : "");
-       END OBJ(execibar, 0) unsigned int n;
-       if (!arg || sscanf(arg, "%f %n", &obj->data.execi.interval, &n) <= 0) {
-               char buf[256];
-               ERR("${execibar <interval> command}");
-               obj->type = OBJ_text;
-               snprintf(buf, 256, "${%s}", s);
-               obj->data.s = strdup(buf);
-       } else {
-               obj->data.execi.cmd = strdup(arg + n);
-       }
-       END OBJ(execigraph, 0) unsigned int n;
-       if (!arg || sscanf(arg, "%f %n", &obj->data.execi.interval, &n) <= 0) {
-               char buf[256];
-               ERR("${execigraph <interval> command}");
-               obj->type = OBJ_text;
-               snprintf(buf, 256, "${%s}", s);
-               obj->data.s = strdup(buf);
-       } else {
-               obj->data.execi.cmd = strdup(arg + n);
-       }
-       END OBJ(execi, 0) unsigned int n;
-       if (!arg || sscanf(arg, "%f %n", &obj->data.execi.interval, &n) <= 0) {
-               char buf[256];
-               ERR("${execi <interval> command}");
-               obj->type = OBJ_text;
-               snprintf(buf, 256, "${%s}", s);
-               obj->data.s = strdup(buf);
-       } else {
-               obj->data.execi.cmd = strdup(arg + n);
-               obj->data.execi.buffer =
-                       (char *) calloc(1, text_buffer_size);
-       }
-       END OBJ(texeci, 0) unsigned int n;
-       if (!arg || sscanf(arg, "%f %n", &obj->data.texeci.interval, &n) <= 0) {
-               char buf[256];
-               ERR("${texeci <interval> command}");
-               obj->type = OBJ_text;
-               snprintf(buf, 256, "${%s}", s);
-               obj->data.s = strdup(buf);
-       } else {
-               obj->data.texeci.cmd = strdup(arg + n);
-               obj->data.texeci.buffer =
-                       (char *) calloc(1, text_buffer_size);
-       }
-       obj->data.texeci.p_timed_thread = NULL;
-       END OBJ(pre_exec, 0) obj->type = OBJ_text;
-       if (arg) {
-               FILE *fp = popen(arg, "r");
+       END OBJ(exec, 0)
+               obj->data.s = strdup(arg ? arg : "");
+       END OBJ(execbar, 0)
+               obj->data.s = strdup(arg ? arg : "");
+       END OBJ(execgraph, 0)
+               obj->data.s = strdup(arg ? arg : "");
+       END OBJ(execibar, 0)
                unsigned int n;
-               char buf[2048];
 
-               n = fread(buf, 1, 2048, fp);
-               buf[n] = '\0';
+               if (!arg || sscanf(arg, "%f %n", &obj->data.execi.interval, &n) <= 0) {
+                       char buf[256];
 
-               if (n && buf[n - 1] == '\n')
-                       buf[n - 1] = '\0';
+                       ERR("${execibar <interval> command}");
+                       obj->type = OBJ_text;
+                       snprintf(buf, 256, "${%s}", s);
+                       obj->data.s = strdup(buf);
+               } else {
+                       obj->data.execi.cmd = strdup(arg + n);
+               }
+       END OBJ(execigraph, 0)
+               unsigned int n;
 
-               (void) pclose(fp);
+               if (!arg || sscanf(arg, "%f %n", &obj->data.execi.interval, &n) <= 0) {
+                       char buf[256];
 
-               obj->data.s = strdup(buf);
-       } else
-               obj->data.s = strdup("");
-       END
+                       ERR("${execigraph <interval> command}");
+                       obj->type = OBJ_text;
+                       snprintf(buf, 256, "${%s}", s);
+                       obj->data.s = strdup(buf);
+               } else {
+                       obj->data.execi.cmd = strdup(arg + n);
+               }
+       END OBJ(execi, 0)
+               unsigned int n;
+
+               if (!arg || sscanf(arg, "%f %n", &obj->data.execi.interval, &n) <= 0) {
+                       char buf[256];
+
+                       ERR("${execi <interval> command}");
+                       obj->type = OBJ_text;
+                       snprintf(buf, 256, "${%s}", s);
+                       obj->data.s = strdup(buf);
+               } else {
+                       obj->data.execi.cmd = strdup(arg + n);
+                       obj->data.execi.buffer = (char *) calloc(1, text_buffer_size);
+               }
+       END OBJ(texeci, 0)
+               unsigned int n;
+
+               if (!arg || sscanf(arg, "%f %n", &obj->data.texeci.interval, &n) <= 0) {
+                       char buf[256];
+
+                       ERR("${texeci <interval> command}");
+                       obj->type = OBJ_text;
+                       snprintf(buf, 256, "${%s}", s);
+                       obj->data.s = strdup(buf);
+               } else {
+                       obj->data.texeci.cmd = strdup(arg + n);
+                       obj->data.texeci.buffer = (char *) calloc(1, text_buffer_size);
+               }
+               obj->data.texeci.p_timed_thread = NULL;
+       END OBJ(pre_exec, 0)
+               obj->type = OBJ_text;
+               if (arg) {
+                       FILE *fp = popen(arg, "r");
+                       unsigned int n;
+                       char buf[2048];
+
+                       n = fread(buf, 1, 2048, fp);
+                       buf[n] = '\0';
+
+                       if (n && buf[n - 1] == '\n') {
+                               buf[n - 1] = '\0';
+                       }
+
+                       pclose(fp);
+
+                       obj->data.s = strdup(buf);
+               } else {
+                       obj->data.s = strdup("");
+               }
 #endif
-               OBJ(fs_bar, INFO_FS) obj->data.fsbar.h = 4;
-       arg = scan_bar(arg, &obj->data.fsbar.w, &obj->data.fsbar.h);
-       if (arg) {
-               while (isspace(*arg))
-                       arg++;
-               if (*arg == '\0')
+       END OBJ(fs_bar, INFO_FS)
+               obj->data.fsbar.h = 4;
+               arg = scan_bar(arg, &obj->data.fsbar.w, &obj->data.fsbar.h);
+               if (arg) {
+                       while (isspace(*arg)) {
+                               arg++;
+                       }
+                       if (*arg == '\0') {
+                               arg = "/";
+                       }
+               } else {
                        arg = "/";
-       } else
-               arg = "/";
-       obj->data.fsbar.fs = prepare_fs_stat(arg);
-       END OBJ(fs_bar_free, INFO_FS) obj->data.fsbar.h = 4;
-       if (arg) {
-               unsigned int n;
-               if (sscanf(arg, "%d %n", &obj->data.fsbar.h, &n) >= 1)
-                       arg += n;
-       } else
-               arg = "/";
-       obj->data.fsbar.fs = prepare_fs_stat(arg);
-       END OBJ(fs_free, INFO_FS) if (!arg)
-               arg = "/";
-       obj->data.fs = prepare_fs_stat(arg);
-       END OBJ(fs_used_perc, INFO_FS) if (!arg)
-               arg = "/";
-       obj->data.fs = prepare_fs_stat(arg);
-       END OBJ(fs_free_perc, INFO_FS) if (!arg)
-               arg = "/";
-       obj->data.fs = prepare_fs_stat(arg);
-       END OBJ(fs_size, INFO_FS) if (!arg)
-               arg = "/";
-       obj->data.fs = prepare_fs_stat(arg);
-       END OBJ(fs_used, INFO_FS) if (!arg)
-               arg = "/";
-       obj->data.fs = prepare_fs_stat(arg);
-       END OBJ(hr, 0) obj->data.i = arg ? atoi(arg) : 1;
-       END OBJ(offset, 0) obj->data.i = arg ? atoi(arg) : 1;
-       END OBJ(voffset, 0) obj->data.i = arg ? atoi(arg) : 1;
+               }
+               obj->data.fsbar.fs = prepare_fs_stat(arg);
+       END OBJ(fs_bar_free, INFO_FS)
+               obj->data.fsbar.h = 4;
+               if (arg) {
+                       unsigned int n;
+
+                       if (sscanf(arg, "%d %n", &obj->data.fsbar.h, &n) >= 1) {
+                               arg += n;
+                       }
+               } else {
+                       arg = "/";
+               }
+               obj->data.fsbar.fs = prepare_fs_stat(arg);
+       END OBJ(fs_free, INFO_FS)
+               if (!arg) {
+                       arg = "/";
+               }
+               obj->data.fs = prepare_fs_stat(arg);
+       END OBJ(fs_used_perc, INFO_FS)
+               if (!arg) {
+                       arg = "/";
+               }
+               obj->data.fs = prepare_fs_stat(arg);
+       END OBJ(fs_free_perc, INFO_FS)
+               if (!arg) {
+                       arg = "/";
+               }
+               obj->data.fs = prepare_fs_stat(arg);
+       END OBJ(fs_size, INFO_FS)
+               if (!arg) {
+                       arg = "/";
+               }
+               obj->data.fs = prepare_fs_stat(arg);
+       END OBJ(fs_used, INFO_FS)
+               if (!arg) {
+                       arg = "/";
+               }
+               obj->data.fs = prepare_fs_stat(arg);
+       END OBJ(hr, 0)
+               obj->data.i = arg ? atoi(arg) : 1;
+       END OBJ(offset, 0)
+               obj->data.i = arg ? atoi(arg) : 1;
+       END OBJ(voffset, 0)
+               obj->data.i = arg ? atoi(arg) : 1;
        END OBJ(goto, 0)
 
-       if (!arg) {
-               ERR("goto needs arguments");
-               obj->type = OBJ_text;
-               obj->data.s = strdup("${goto}");
-               return NULL;
-       }
-       
-       obj->data.i = atoi(arg);
-       
+               if (!arg) {
+                       ERR("goto needs arguments");
+                       obj->type = OBJ_text;
+                       obj->data.s = strdup("${goto}");
+                       return NULL;
+               }
+
+               obj->data.i = atoi(arg);
+
        END OBJ(tab, 0)
-       int a = 10, b = 0;
-       if (arg) {
-               if (sscanf(arg, "%d %d", &a, &b) != 2)
-                       sscanf(arg, "%d", &b);
-       }
-       if (a <= 0) 
-               a = 1;
-       obj->data.pair.a = a;
-       obj->data.pair.b = b;
+               int a = 10, b = 0;
+
+               if (arg) {
+                       if (sscanf(arg, "%d %d", &a, &b) != 2) {
+                               sscanf(arg, "%d", &b);
+                       }
+               }
+               if (a <= 0) {
+                       a = 1;
+               }
+               obj->data.pair.a = a;
+               obj->data.pair.b = b;
 
 #ifndef __OpenBSD__
        END OBJ(i2c, INFO_SYSFS)
-  char buf1[64], buf2[64];
-       int n;
+               char buf1[64], buf2[64];
+               int n;
 
-       if (!arg) {
-               ERR("i2c needs arguments");
-               obj->type = OBJ_text;
-               //obj->data.s = strdup("${i2c}");
-               return NULL;
-       }
+               if (!arg) {
+                       ERR("i2c needs arguments");
+                       obj->type = OBJ_text;
+                       // obj->data.s = strdup("${i2c}");
+                       return NULL;
+               }
 
-       if (sscanf(arg, "%63s %63s %d", buf1, buf2, &n) != 3) {
-               /* if scanf couldn't read three values, read type and num and use default device */
-               sscanf(arg, "%63s %d", buf2, &n);
-               obj->data.sysfs.fd =
-                       open_i2c_sensor(0, buf2, n, &obj->data.sysfs.arg, obj->data.sysfs.devtype);
-               strncpy(obj->data.sysfs.type, buf2, 63);
-       } else {
-               obj->data.sysfs.fd =
-                       open_i2c_sensor(buf1, buf2, n, &obj->data.sysfs.arg, obj->data.sysfs.devtype);
-               strncpy(obj->data.sysfs.type, buf2, 63);
-       }
-
-  END OBJ(platform, INFO_SYSFS)
-  char buf1[64], buf2[64];
-  int n;
-
-  if (!arg) {
-    ERR("platform needs arguments");
-    obj->type = OBJ_text;
-    return NULL;
-  }
-
-  if (sscanf(arg, "%63s %63s %d", buf1, buf2, &n) != 3) {
-    /* if scanf couldn't read three values, read type and num and use default device */
-    sscanf(arg, "%63s %d", buf2, &n);
-    obj->data.sysfs.fd =
-      open_platform_sensor(0, buf2, n, &obj->data.sysfs.arg, obj->data.sysfs.devtype);
-    strncpy(obj->data.sysfs.type, buf2, 63);
-  } else {
-    obj->data.sysfs.fd =
-      open_platform_sensor(buf1, buf2, n, &obj->data.sysfs.arg, obj->data.sysfs.devtype);
-    strncpy(obj->data.sysfs.type, buf2, 63);
-  }
-
-  END OBJ(hwmon, INFO_SYSFS)
-  char buf1[64], buf2[64];
-  int n;
-
-  if (!arg) {
-    ERR("hwmon needs argumanets");
-    obj->type = OBJ_text;
-    return NULL;
-  }
-
-  if (sscanf(arg, "%63s %63s %d", buf1, buf2, &n) != 3) {
-    /* if scanf couldn't read three values, read type and num and use default device */
-    sscanf(arg, "%63s %d", buf2, &n);
-    obj->data.sysfs.fd =
-      open_hwmon_sensor(0, buf2, n, &obj->data.sysfs.arg, obj->data.sysfs.devtype);
-    strncpy(obj->data.sysfs.type, buf2, 63);
-  } else {
-    obj->data.sysfs.fd =
-      open_hwmon_sensor(buf1, buf2, n, &obj->data.sysfs.arg, obj->data.sysfs.devtype);
-    strncpy(obj->data.sysfs.type, buf2, 63);
-  }
+               if (sscanf(arg, "%63s %63s %d", buf1, buf2, &n) != 3) {
+                       /* if scanf couldn't read three values, read type and num and use
+                        * default device */
+                       sscanf(arg, "%63s %d", buf2, &n);
+                       obj->data.sysfs.fd = open_i2c_sensor(0, buf2, n,
+                               &obj->data.sysfs.arg, obj->data.sysfs.devtype);
+                       strncpy(obj->data.sysfs.type, buf2, 63);
+               } else {
+                       obj->data.sysfs.fd = open_i2c_sensor(buf1, buf2, n,
+                               &obj->data.sysfs.arg, obj->data.sysfs.devtype);
+                       strncpy(obj->data.sysfs.type, buf2, 63);
+               }
+
+       END OBJ(platform, INFO_SYSFS)
+               char buf1[64], buf2[64];
+               int n;
+
+               if (!arg) {
+                       ERR("platform needs arguments");
+                       obj->type = OBJ_text;
+                       return NULL;
+               }
+
+               if (sscanf(arg, "%63s %63s %d", buf1, buf2, &n) != 3) {
+                       /* if scanf couldn't read three values, read type and num and use
+                        * default device */
+                       sscanf(arg, "%63s %d", buf2, &n);
+                       obj->data.sysfs.fd = open_platform_sensor(0, buf2, n,
+                               &obj->data.sysfs.arg, obj->data.sysfs.devtype);
+                       strncpy(obj->data.sysfs.type, buf2, 63);
+               } else {
+                       obj->data.sysfs.fd = open_platform_sensor(buf1, buf2, n,
+                               &obj->data.sysfs.arg, obj->data.sysfs.devtype);
+                       strncpy(obj->data.sysfs.type, buf2, 63);
+               }
+
+       END OBJ(hwmon, INFO_SYSFS)
+               char buf1[64], buf2[64];
+               int n;
+
+               if (!arg) {
+                       ERR("hwmon needs argumanets");
+                       obj->type = OBJ_text;
+                       return NULL;
+               }
+
+               if (sscanf(arg, "%63s %63s %d", buf1, buf2, &n) != 3) {
+                       /* if scanf couldn't read three values, read type and num and use
+                        * default device */
+                       sscanf(arg, "%63s %d", buf2, &n);
+                       obj->data.sysfs.fd = open_hwmon_sensor(0, buf2, n,
+                               &obj->data.sysfs.arg, obj->data.sysfs.devtype);
+                       strncpy(obj->data.sysfs.type, buf2, 63);
+               } else {
+                       obj->data.sysfs.fd = open_hwmon_sensor(buf1, buf2, n,
+                               &obj->data.sysfs.arg, obj->data.sysfs.devtype);
+                       strncpy(obj->data.sysfs.type, buf2, 63);
+               }
 #endif /* !__OpenBSD__ */
 
        END OBJ(top, INFO_TOP)
                char buf[64];
-       int n;
-       if (!arg) {
-               ERR("top needs arguments");
-               obj->type = OBJ_text;
-               //obj->data.s = strdup("${top}");
-               return NULL;
-       }
-       if (sscanf(arg, "%63s %i", buf, &n) == 2) {
-               if (strcmp(buf, "name") == 0) {
-                       obj->data.top.type = TOP_NAME;
-               } else if (strcmp(buf, "cpu") == 0) {
-                       obj->data.top.type = TOP_CPU;
-               } else if (strcmp(buf, "pid") == 0) {
-                       obj->data.top.type = TOP_PID;
-               } else if (strcmp(buf, "mem") == 0) {
-                       obj->data.top.type = TOP_MEM;
-               } else if (strcmp(buf, "time") == 0) {
-                       obj->data.top.type = TOP_TIME;
-               } else {
-                       ERR("invalid arg for top");
+               int n;
+
+               if (!arg) {
+                       ERR("top needs arguments");
+                       obj->type = OBJ_text;
+                       // obj->data.s = strdup("${top}");
                        return NULL;
                }
-               if (n < 1 || n > 10) {
-                       CRIT_ERR("invalid arg for top");
-                       return NULL;
+               if (sscanf(arg, "%63s %i", buf, &n) == 2) {
+                       if (strcmp(buf, "name") == 0) {
+                               obj->data.top.type = TOP_NAME;
+                       } else if (strcmp(buf, "cpu") == 0) {
+                               obj->data.top.type = TOP_CPU;
+                       } else if (strcmp(buf, "pid") == 0) {
+                               obj->data.top.type = TOP_PID;
+                       } else if (strcmp(buf, "mem") == 0) {
+                               obj->data.top.type = TOP_MEM;
+                       } else if (strcmp(buf, "time") == 0) {
+                               obj->data.top.type = TOP_TIME;
+                       } else {
+                               ERR("invalid arg for top");
+                               return NULL;
+                       }
+                       if (n < 1 || n > 10) {
+                               CRIT_ERR("invalid arg for top");
+                               return NULL;
+                       } else {
+                               obj->data.top.num = n - 1;
+                               top_cpu = 1;
+                       }
                } else {
-                       obj->data.top.num = n - 1;
-                       top_cpu = 1;
+                       ERR("invalid args given for top");
+                       return NULL;
                }
-       } else {
-               ERR("invalid args given for top");
-               return NULL;
-       }
        END OBJ(top_mem, INFO_TOP)
                char buf[64];
-       int n;
-       if (!arg) {
-               ERR("top_mem needs arguments");
-               obj->type = OBJ_text;
-               obj->data.s = strdup("${top_mem}");
-               return NULL;
-       }
-       if (sscanf(arg, "%63s %i", buf, &n) == 2) {
-               if (strcmp(buf, "name") == 0) {
-                       obj->data.top.type = TOP_NAME;
-               } else if (strcmp(buf, "cpu") == 0) {
-                       obj->data.top.type = TOP_CPU;
-               } else if (strcmp(buf, "pid") == 0) {
-                       obj->data.top.type = TOP_PID;
-               } else if (strcmp(buf, "mem") == 0) {
-                       obj->data.top.type = TOP_MEM;
-               } else if (strcmp(buf, "time") == 0) {
-                       obj->data.top.type = TOP_TIME;
-               } else {
-                       ERR("invalid arg for top");
+               int n;
+
+               if (!arg) {
+                       ERR("top_mem needs arguments");
+                       obj->type = OBJ_text;
+                       obj->data.s = strdup("${top_mem}");
                        return NULL;
                }
-               if (n < 1 || n > 10) {
-                       CRIT_ERR("invalid arg for top");
-                       return NULL;
+               if (sscanf(arg, "%63s %i", buf, &n) == 2) {
+                       if (strcmp(buf, "name") == 0) {
+                               obj->data.top.type = TOP_NAME;
+                       } else if (strcmp(buf, "cpu") == 0) {
+                               obj->data.top.type = TOP_CPU;
+                       } else if (strcmp(buf, "pid") == 0) {
+                               obj->data.top.type = TOP_PID;
+                       } else if (strcmp(buf, "mem") == 0) {
+                               obj->data.top.type = TOP_MEM;
+                       } else if (strcmp(buf, "time") == 0) {
+                               obj->data.top.type = TOP_TIME;
+                       } else {
+                               ERR("invalid arg for top");
+                               return NULL;
+                       }
+                       if (n < 1 || n > 10) {
+                               CRIT_ERR("invalid arg for top");
+                               return NULL;
+                       } else {
+                               obj->data.top.num = n - 1;
+                               top_mem = 1;
+                       }
                } else {
-                       obj->data.top.num = n - 1;
-                       top_mem = 1;
+                       ERR("invalid args given for top");
+                       return NULL;
                }
-       } else {
-               ERR("invalid args given for top");
-               return NULL;
-       }
        END OBJ(addr, INFO_NET)
-               if(arg) {
+               if (arg) {
                        obj->data.net = get_net_stat(arg);
-               }
-               else {
+               } else {
                        CRIT_ERR("addr needs argument");
                }
        END OBJ(tail, 0)
                char buf[64];
-       int n1, n2;
-       struct stat st;
-       if (!arg) {
-               ERR("tail needs arguments");
-               obj->type = OBJ_text;
-               obj->data.s = strdup("${tail}");
-               return NULL;
-       }
-       if (sscanf(arg, "%63s %i %i", buf, &n1, &n2) == 2) {
-               if (n1 < 1 || n1 > 30) {
-                       CRIT_ERR("invalid arg for tail, number of lines must be between 1 and 30");
-                       return NULL;
-               } else {
-                       FILE *fp = NULL;
-                       int fd;
+               int n1, n2;
+               struct stat st;
 
-                       obj->data.tail.fd = -1;
+               if (!arg) {
+                       ERR("tail needs arguments");
+                       obj->type = OBJ_text;
+                       obj->data.s = strdup("${tail}");
+                       return NULL;
+               }
+               if (sscanf(arg, "%63s %i %i", buf, &n1, &n2) == 2) {
+                       if (n1 < 1 || n1 > 30) {
+                               CRIT_ERR("invalid arg for tail, number of lines must be "
+                                       "between 1 and 30");
+                               return NULL;
+                       } else {
+                               FILE *fp = NULL;
+                               int fd;
 
-                       if (stat(buf, &st) == 0) {
-                               if (S_ISFIFO(st.st_mode)) {
-                                       fd = open(buf, O_RDONLY|O_NONBLOCK);
+                               obj->data.tail.fd = -1;
 
-                                       if (fd == -1)
-                                               CRIT_ERR("tail logfile does not exist, or you do not have correct permissions");
+                               if (stat(buf, &st) == 0) {
+                                       if (S_ISFIFO(st.st_mode)) {
+                                               fd = open(buf, O_RDONLY | O_NONBLOCK);
 
-                                       obj->data.tail.fd = fd;
+                                               if (fd == -1) {
+                                                       CRIT_ERR("tail logfile does not exist, or you do "
+                                                               "not have correct permissions");
+                                               }
 
+                                               obj->data.tail.fd = fd;
+                                       } else {
+                                               fp = fopen(buf, "r");
+                                       }
                                }
-                               else
-                                       fp = fopen(buf, "r");
-                       }
 
-                       if (fp || obj->data.tail.fd != -1) {
-                               obj->data.tail.logfile =
-                                       malloc(text_buffer_size);
-                               strcpy(obj->data.tail.logfile, buf);
-                               obj->data.tail.wantedlines = n1;
-                               obj->data.tail.interval =
-                                       update_interval * 2;
+                               if (fp || obj->data.tail.fd != -1) {
+                                       obj->data.tail.logfile = malloc(text_buffer_size);
+                                       strcpy(obj->data.tail.logfile, buf);
+                                       obj->data.tail.wantedlines = n1;
+                                       obj->data.tail.interval = update_interval * 2;
 
-                               if (obj->data.tail.fd == -1)
-                                       fclose(fp);
+                                       if (obj->data.tail.fd == -1) {
+                                               fclose(fp);
+                                       }
+                               } else {
+                                       // fclose(fp);
+                                       CRIT_ERR("tail logfile does not exist, or you do not have "
+                                               "correct permissions");
+                               }
+                       }
+               } else if (sscanf(arg, "%63s %i %i", buf, &n1, &n2) == 3) {
+                       if (n1 < 1 || n1 > 30) {
+                               CRIT_ERR("invalid arg for tail, number of lines must be "
+                                       "between 1 and 30");
+                               return NULL;
+                       } else if (n2 < 1 || n2 < update_interval) {
+                               CRIT_ERR("invalid arg for tail, interval must be greater than "
+                                       "0 and Conky's interval");
+                               return NULL;
                        } else {
-                               //fclose (fp);
-                               CRIT_ERR("tail logfile does not exist, or you do not have correct permissions");
-                       }
-               }
-       } else if (sscanf(arg, "%63s %i %i", buf, &n1, &n2) == 3) {
-               if (n1 < 1 || n1 > 30) {
-                       CRIT_ERR
-                               ("invalid arg for tail, number of lines must be between 1 and 30");
-                       return NULL;
-               } else if (n2 < 1 || n2 < update_interval) {
-                       CRIT_ERR
-                               ("invalid arg for tail, interval must be greater than 0 and Conky's interval");
-                       return NULL;
-               } else {
-                       FILE *fp=0;
-                       int fd;
+                               FILE *fp = 0;
+                               int fd;
 
-                       obj->data.tail.fd = -1;
+                               obj->data.tail.fd = -1;
 
-                       if (stat(buf, &st) == 0) {
-                               if (S_ISFIFO(st.st_mode)) {
-                                       fd = open(buf, O_RDONLY|O_NONBLOCK);
+                               if (stat(buf, &st) == 0) {
+                                       if (S_ISFIFO(st.st_mode)) {
+                                               fd = open(buf, O_RDONLY | O_NONBLOCK);
 
-                                       if (fd == -1)
-                                               CRIT_ERR("tail logfile does not exist, or you do not have correct permissions");
+                                               if (fd == -1) {
+                                                       CRIT_ERR("tail logfile does not exist, or you do "
+                                                               "not have correct permissions");
+                                               }
 
-                                       obj->data.tail.fd = fd;
+                                               obj->data.tail.fd = fd;
+                                       } else {
+                                               fp = fopen(buf, "r");
+                                       }
                                }
-                               else
-                                       fp = fopen(buf, "r");
-                       }
 
-                       if (fp || obj->data.tail.fd != -1) {
-                               obj->data.tail.logfile =
-                                       malloc(text_buffer_size);
-                               strcpy(obj->data.tail.logfile, buf);
-                               obj->data.tail.wantedlines = n1;
-                               obj->data.tail.interval = n2;
+                               if (fp || obj->data.tail.fd != -1) {
+                                       obj->data.tail.logfile = malloc(text_buffer_size);
+                                       strcpy(obj->data.tail.logfile, buf);
+                                       obj->data.tail.wantedlines = n1;
+                                       obj->data.tail.interval = n2;
 
-                               if (obj->data.tail.fd == -1)
-                                       fclose(fp);
-                       } else {
-                               //fclose (fp);
-                               CRIT_ERR("tail logfile does not exist, or you do not have correct permissions");
+                                       if (obj->data.tail.fd == -1) {
+                                               fclose(fp);
+                                       }
+                               } else {
+                                       // fclose(fp);
+                                       CRIT_ERR("tail logfile does not exist, or you do not have "
+                                               "correct permissions");
+                               }
                        }
+               } else {
+                       ERR("invalid args given for tail");
+                       return NULL;
                }
-       }
-
-       else {
-               ERR("invalid args given for tail");
-               return NULL;
-       }
-       obj->data.tail.buffer = malloc(text_buffer_size * 20); /* asumming all else worked */
+               /* asumming all else worked */
+               obj->data.tail.buffer = malloc(text_buffer_size * 20);
        END OBJ(head, 0)
                char buf[64];
-       int n1, n2;
-       if (!arg) {
-               ERR("head needs arguments");
-               obj->type = OBJ_text;
-               obj->data.s = strdup("${head}");
-               return NULL;
-       }
-       if (sscanf(arg, "%63s %i %i", buf, &n1, &n2) == 2) {
-               if (n1 < 1 || n1 > 30) {
-                       CRIT_ERR("invalid arg for head, number of lines must be between 1 and 30");
+               int n1, n2;
+
+               if (!arg) {
+                       ERR("head needs arguments");
+                       obj->type = OBJ_text;
+                       obj->data.s = strdup("${head}");
                        return NULL;
-               } else {
-                       FILE *fp;
-                       fp = fopen(buf, "r");
-                       if (fp != NULL) {
-                               obj->data.tail.logfile =
-                                       malloc(text_buffer_size);
-                               strcpy(obj->data.tail.logfile, buf);
-                               obj->data.tail.wantedlines = n1;
-                               obj->data.tail.interval =
-                                       update_interval * 2;
-                               fclose(fp);
-                       } else {
-                               //fclose (fp);
-                               CRIT_ERR("head logfile does not exist, or you do not have correct permissions");
-                       }
                }
-       } else if (sscanf(arg, "%63s %i %i", buf, &n1, &n2) == 3) {
-               if (n1 < 1 || n1 > 30) {
-                       CRIT_ERR
-                               ("invalid arg for head, number of lines must be between 1 and 30");
-                       return NULL;
-               } else if (n2 < 1 || n2 < update_interval) {
-                       CRIT_ERR
-                               ("invalid arg for head, interval must be greater than 0 and Conky's interval");
-                       return NULL;
-               } else {
-                       FILE *fp;
-                       fp = fopen(buf, "r");
-                       if (fp != NULL) {
-                               obj->data.tail.logfile =
-                                       malloc(text_buffer_size);
-                               strcpy(obj->data.tail.logfile, buf);
-                               obj->data.tail.wantedlines = n1;
-                               obj->data.tail.interval = n2;
-                               fclose(fp);
+               if (sscanf(arg, "%63s %i %i", buf, &n1, &n2) == 2) {
+                       if (n1 < 1 || n1 > 30) {
+                               CRIT_ERR("invalid arg for head, number of lines must be "
+                                       "between 1 and 30");
+                               return NULL;
                        } else {
-                               //fclose (fp);
-                               CRIT_ERR("head logfile does not exist, or you do not have correct permissions");
+                               FILE *fp;
+
+                               fp = fopen(buf, "r");
+                               if (fp != NULL) {
+                                       obj->data.tail.logfile = malloc(text_buffer_size);
+                                       strcpy(obj->data.tail.logfile, buf);
+                                       obj->data.tail.wantedlines = n1;
+                                       obj->data.tail.interval = update_interval * 2;
+                                       fclose(fp);
+                               } else {
+                                       // fclose(fp);
+                                       CRIT_ERR("head logfile does not exist, or you do not have "
+                                               "correct permissions");
+                               }
+                       }
+               } else if (sscanf(arg, "%63s %i %i", buf, &n1, &n2) == 3) {
+                       if (n1 < 1 || n1 > 30) {
+                               CRIT_ERR("invalid arg for head, number of lines must be "
+                                       "between 1 and 30");
+                               return NULL;
+                       } else if (n2 < 1 || n2 < update_interval) {
+                               CRIT_ERR("invalid arg for head, interval must be greater than "
+                                       "0 and Conky's interval");
+                               return NULL;
+                       } else {
+                               FILE *fp;
+
+                               fp = fopen(buf, "r");
+                               if (fp != NULL) {
+                                       obj->data.tail.logfile = malloc(text_buffer_size);
+                                       strcpy(obj->data.tail.logfile, buf);
+                                       obj->data.tail.wantedlines = n1;
+                                       obj->data.tail.interval = n2;
+                                       fclose(fp);
+                               } else {
+                                       // fclose(fp);
+                                       CRIT_ERR("head logfile does not exist, or you do not have "
+                                               "correct permissions");
+                               }
                        }
+               } else {
+                       ERR("invalid args given for head");
+                       return NULL;
                }
-       }
+               /* asumming all else worked */
+               obj->data.tail.buffer = malloc(text_buffer_size * 20);
+       END OBJ(loadavg, INFO_LOADAVG)
+               int a = 1, b = 2, c = 3, r = 3;
 
-       else {
-               ERR("invalid args given for head");
-               return NULL;
-       }
-       obj->data.tail.buffer = malloc(text_buffer_size * 20); /* asumming all else worked */
-       END OBJ(loadavg, INFO_LOADAVG) int a = 1, b = 2, c = 3, r = 3;
-       if (arg) {
-               r = sscanf(arg, "%d %d %d", &a, &b, &c);
-               if (r >= 3 && (c < 1 || c > 3))
-                       r--;
-               if (r >= 2 && (b < 1 || b > 3))
-                       r--, b = c;
-               if (r >= 1 && (a < 1 || a > 3))
-                       r--, a = b, b = c;
-       }
-       obj->data.loadavg[0] = (r >= 1) ? (unsigned char) a : 0;
-       obj->data.loadavg[1] = (r >= 2) ? (unsigned char) b : 0;
-       obj->data.loadavg[2] = (r >= 3) ? (unsigned char) c : 0;
+               if (arg) {
+                       r = sscanf(arg, "%d %d %d", &a, &b, &c);
+                       if (r >= 3 && (c < 1 || c > 3)) {
+                               r--;
+                       }
+                       if (r >= 2 && (b < 1 || b > 3)) {
+                               r--, b = c;
+                       }
+                       if (r >= 1 && (a < 1 || a > 3)) {
+                               r--, a = b, b = c;
+                       }
+               }
+               obj->data.loadavg[0] = (r >= 1) ? (unsigned char) a : 0;
+               obj->data.loadavg[1] = (r >= 2) ? (unsigned char) b : 0;
+               obj->data.loadavg[2] = (r >= 3) ? (unsigned char) c : 0;
        END OBJ(if_empty, 0)
                if (blockdepth >= MAX_IF_BLOCK_DEPTH) {
                        CRIT_ERR("MAX_IF_BLOCK_DEPTH exceeded");
                }
-       if (!arg) {
-               ERR("if_empty needs an argument");
-               obj->data.ifblock.s = 0;
-       } else
-               obj->data.ifblock.s = strdup(arg);
-       blockstart[blockdepth] = object_count;
-       obj->data.ifblock.pos = object_count + 2;
-       blockdepth++;
+               if (!arg) {
+                       ERR("if_empty needs an argument");
+                       obj->data.ifblock.s = 0;
+               } else {
+                       obj->data.ifblock.s = strdup(arg);
+               }
+               blockstart[blockdepth] = object_count;
+               obj->data.ifblock.pos = object_count + 2;
+               blockdepth++;
        END OBJ(if_existing, 0)
                if (blockdepth >= MAX_IF_BLOCK_DEPTH) {
                        CRIT_ERR("MAX_IF_BLOCK_DEPTH exceeded");
                }
-       if (!arg) {
-               ERR("if_existing needs an argument or two");
-               obj->data.ifblock.s = NULL;
-               obj->data.ifblock.str = NULL;       
-       } else {
-               char buf1[256], buf2[256];
-               int r = sscanf(arg, "%255s %255[^\n]", buf1, buf2);
-               if (r == 1) {
-                       obj->data.ifblock.s = strdup(buf1);             
-                       obj->data.ifblock.str = NULL;       
+               if (!arg) {
+                       ERR("if_existing needs an argument or two");
+                       obj->data.ifblock.s = NULL;
+                       obj->data.ifblock.str = NULL;
                } else {
-                       obj->data.ifblock.s = strdup(buf1);
-                       obj->data.ifblock.str = strdup(buf2);
+                       char buf1[256], buf2[256];
+                       int r = sscanf(arg, "%255s %255[^\n]", buf1, buf2);
+
+                       if (r == 1) {
+                               obj->data.ifblock.s = strdup(buf1);
+                               obj->data.ifblock.str = NULL;
+                       } else {
+                               obj->data.ifblock.s = strdup(buf1);
+                               obj->data.ifblock.str = strdup(buf2);
+                       }
                }
-       }               
-       blockstart[blockdepth] = object_count;
-       obj->data.ifblock.pos = object_count + 2;
-       blockdepth++;
+               blockstart[blockdepth] = object_count;
+               obj->data.ifblock.pos = object_count + 2;
+               blockdepth++;
        END OBJ(if_mounted, 0)
                if (blockdepth >= MAX_IF_BLOCK_DEPTH) {
                        CRIT_ERR("MAX_IF_BLOCK_DEPTH exceeded");
                }
-       if (!arg) {
-               ERR("if_mounted needs an argument");
-               obj->data.ifblock.s = 0;
-       } else
-               obj->data.ifblock.s = strdup(arg);
-       blockstart[blockdepth] = object_count;
-       obj->data.ifblock.pos = object_count + 2;
-       blockdepth++;
+               if (!arg) {
+                       ERR("if_mounted needs an argument");
+                       obj->data.ifblock.s = 0;
+               } else {
+                       obj->data.ifblock.s = strdup(arg);
+               }
+               blockstart[blockdepth] = object_count;
+               obj->data.ifblock.pos = object_count + 2;
+               blockdepth++;
        END OBJ(if_running, 0)
                if (blockdepth >= MAX_IF_BLOCK_DEPTH) {
                        CRIT_ERR("MAX_IF_BLOCK_DEPTH exceeded");
                }
-       if (arg) {
-               char buf[256];
-               snprintf(buf, 256, "pidof %s >/dev/null", arg);
-               obj->data.ifblock.s = strdup(buf);
-       } else {
-               ERR("if_running needs an argument");
-               obj->data.ifblock.s = 0;
-       }
-       blockstart[blockdepth] = object_count;
-       obj->data.ifblock.pos = object_count + 2;
-       blockdepth++;
-       END OBJ(kernel, 0)
-               END OBJ(machine, 0)
-               END OBJ(mails, 0) {
-                       float n1;
-                       char box[256], dst[256];
+               if (arg) {
+                       char buf[256];
 
-                       if (!arg) {
+                       snprintf(buf, 256, "pidof %s >/dev/null", arg);
+                       obj->data.ifblock.s = strdup(buf);
+               } else {
+                       ERR("if_running needs an argument");
+                       obj->data.ifblock.s = 0;
+               }
+               blockstart[blockdepth] = object_count;
+               obj->data.ifblock.pos = object_count + 2;
+               blockdepth++;
+       END OBJ(kernel, 0)
+       END OBJ(machine, 0)
+       END OBJ(mails, 0)
+               float n1;
+               char box[256], dst[256];
+
+               if (!arg) {
+                       n1 = 9.5;
+                       strncpy(box, MAIL_FILE, sizeof(box));
+               } else {
+                       if (sscanf(arg, "%s %f", box, &n1) != 2) {
                                n1 = 9.5;
-                               strncpy(box, MAIL_FILE, sizeof(box));
-                       }
-                       else {
-                               if (sscanf(arg, "%s %f", box, &n1) != 2) {
-                                       n1 = 9.5;
-                                       strncpy(box, arg, sizeof(box));
-                               }
+                               strncpy(box, arg, sizeof(box));
                        }
-
-                       variable_substitute(box, dst, sizeof(dst));
-                       obj->data.local_mail.box = strdup(dst);
-                       obj->data.local_mail.interval = n1;
                }
 
-               END OBJ(mboxscan, 0)
-               obj->data.mboxscan.args = (char*)malloc(TEXT_BUFFER_SIZE);
-               obj->data.mboxscan.output = (char*)malloc(text_buffer_size);
+               variable_substitute(box, dst, sizeof(dst));
+               obj->data.local_mail.box = strdup(dst);
+               obj->data.local_mail.interval = n1;
+       END OBJ(mboxscan, 0)
+               obj->data.mboxscan.args = (char *) malloc(TEXT_BUFFER_SIZE);
+               obj->data.mboxscan.output = (char *) malloc(text_buffer_size);
                /* if '1' (in mboxscan.c) then there was SIGUSR1, hmm */
                obj->data.mboxscan.output[0] = 1;
                strncpy(obj->data.mboxscan.args, arg, TEXT_BUFFER_SIZE);
-               END OBJ(mem, INFO_MEM)
-               END OBJ(memmax, INFO_MEM)
-               END OBJ(memperc, INFO_MEM)
-               END OBJ(membar, INFO_MEM)
-               (void) scan_bar(arg, &obj->data.pair.a, &obj->data.pair.b);
+       END OBJ(mem, INFO_MEM)
+       END OBJ(memmax, INFO_MEM)
+       END OBJ(memperc, INFO_MEM)
+       END OBJ(membar, INFO_MEM)
+               scan_bar(arg, &obj->data.pair.a, &obj->data.pair.b);
        END OBJ(memgraph, INFO_MEM)
                char *buf = scan_graph(arg, &obj->a, &obj->b, &obj->c, &obj->d,
                        &obj->e);
@@ -3096,43 +3205,42 @@ static struct text_object *construct_text_object(const char *s, const char *arg,
                if (buf) {
                        free(buf);
                }
-       END OBJ(mixer, INFO_MIXER) obj->data.l = mixer_init(arg);
-       END OBJ(mixerl, INFO_MIXER) obj->data.l = mixer_init(arg);
-       END OBJ(mixerr, INFO_MIXER) obj->data.l = mixer_init(arg);
+       END OBJ(mixer, INFO_MIXER)
+               obj->data.l = mixer_init(arg);
+       END OBJ(mixerl, INFO_MIXER)
+               obj->data.l = mixer_init(arg);
+       END OBJ(mixerr, INFO_MIXER)
+               obj->data.l = mixer_init(arg);
        END OBJ(mixerbar, INFO_MIXER)
-               scan_mixer_bar(arg, &obj->data.mixerbar.l,
-                               &obj->data.mixerbar.w, &obj->data.mixerbar.h);
+               scan_mixer_bar(arg, &obj->data.mixerbar.l, &obj->data.mixerbar.w,
+                       &obj->data.mixerbar.h);
        END OBJ(mixerlbar, INFO_MIXER)
-               scan_mixer_bar(arg, &obj->data.mixerbar.l,
-                               &obj->data.mixerbar.w, &obj->data.mixerbar.h);
+               scan_mixer_bar(arg, &obj->data.mixerbar.l, &obj->data.mixerbar.w,
+                       &obj->data.mixerbar.h);
        END OBJ(mixerrbar, INFO_MIXER)
-               scan_mixer_bar(arg, &obj->data.mixerbar.l,
-                               &obj->data.mixerbar.w, &obj->data.mixerbar.h);
-       END
-               OBJ(new_mails, 0) {
-                       float n1;
-                       char box[256], dst[256];
-
-                       if (!arg) {
+               scan_mixer_bar(arg, &obj->data.mixerbar.l, &obj->data.mixerbar.w,
+                       &obj->data.mixerbar.h);
+       END OBJ(new_mails, 0)
+               float n1;
+               char box[256], dst[256];
+
+               if (!arg) {
+                       n1 = 9.5;
+                       strncpy(box, MAIL_FILE, sizeof(box));
+               } else {
+                       if (sscanf(arg, "%s %f", box, &n1) != 2) {
                                n1 = 9.5;
-                               strncpy(box, MAIL_FILE, sizeof(box));
-                       }
-                       else {
-                               if (sscanf(arg, "%s %f", box, &n1) != 2) {
-                                       n1 = 9.5;
-                                       strncpy(box, arg, sizeof(box));
-                               }
+                               strncpy(box, arg, sizeof(box));
                        }
-
-                       variable_substitute(box, dst, sizeof(dst));
-                       obj->data.local_mail.box = strdup(dst);
-                       obj->data.local_mail.interval = n1;
                }
 
-               END OBJ(nodename, 0)
-               END OBJ(processes, INFO_PROCS)
-               END OBJ(running_processes, INFO_RUN_PROCS)
-               END OBJ(shadecolor, 0)
+               variable_substitute(box, dst, sizeof(dst));
+               obj->data.local_mail.box = strdup(dst);
+               obj->data.local_mail.interval = n1;
+       END OBJ(nodename, 0)
+       END OBJ(processes, INFO_PROCS)
+       END OBJ(running_processes, INFO_RUN_PROCS)
+       END OBJ(shadecolor, 0)
 #ifdef X11
                obj->data.l = arg ? get_x11_color(arg) : default_bg_color;
 #endif /* X11 */
@@ -3143,38 +3251,45 @@ static struct text_object *construct_text_object(const char *s, const char *arg,
        END OBJ(stippled_hr, 0)
 #ifdef X11
                int a = stippled_borders, b = 1;
-       if (arg) {
-               if (sscanf(arg, "%d %d", &a, &b) != 2)
-                       sscanf(arg, "%d", &b);
-       }
-       if (a <= 0)
-               a = 1;
-       obj->data.pair.a = a;
-       obj->data.pair.b = b;
+
+               if (arg) {
+                       if (sscanf(arg, "%d %d", &a, &b) != 2) {
+                               sscanf(arg, "%d", &b);
+                       }
+               }
+               if (a <= 0) {
+                       a = 1;
+               }
+               obj->data.pair.a = a;
+               obj->data.pair.b = b;
 #endif /* X11 */
        END OBJ(swap, INFO_MEM)
-               END OBJ(swapmax, INFO_MEM)
-               END OBJ(swapperc, INFO_MEM)
-               END OBJ(swapbar, INFO_MEM)
-               (void) scan_bar(arg, &obj->data.pair.a, &obj->data.pair.b);
+       END OBJ(swapmax, INFO_MEM)
+       END OBJ(swapperc, INFO_MEM)
+       END OBJ(swapbar, INFO_MEM)
+               scan_bar(arg, &obj->data.pair.a, &obj->data.pair.b);
        END OBJ(sysname, 0)
 #ifndef __OpenBSD__
-       END OBJ(temp1, INFO_SYSFS) obj->type = OBJ_i2c;
-       obj->data.sysfs.fd =
-               open_i2c_sensor(0, "temp", 1, &obj->data.sysfs.arg,
-                               obj->data.sysfs.devtype);
-       END OBJ(temp2, INFO_SYSFS) obj->type = OBJ_i2c;
-       obj->data.sysfs.fd =
-               open_i2c_sensor(0, "temp", 2, &obj->data.sysfs.arg,
-                               obj->data.sysfs.devtype);
+       END OBJ(temp1, INFO_SYSFS)
+               obj->type = OBJ_i2c;
+               obj->data.sysfs.fd = open_i2c_sensor(0, "temp", 1,
+                       &obj->data.sysfs.arg, obj->data.sysfs.devtype);
+       END OBJ(temp2, INFO_SYSFS)
+               obj->type = OBJ_i2c;
+               obj->data.sysfs.fd = open_i2c_sensor(0, "temp", 2,
+                       &obj->data.sysfs.arg, obj->data.sysfs.devtype);
 #endif
-       END OBJ(time, 0) obj->data.s = strdup(arg ? arg : "%F %T");
-       END OBJ(utime, 0) obj->data.s = strdup(arg ? arg : "%F %T");
+       END OBJ(time, 0)
+               obj->data.s = strdup(arg ? arg : "%F %T");
+       END OBJ(utime, 0)
+               obj->data.s = strdup(arg ? arg : "%F %T");
        END OBJ(tztime, 0)
                char buf1[256], buf2[256], *fmt, *tz;
+
                fmt = tz = NULL;
                if (arg) {
                        int nArgs = sscanf(arg, "%255s %255[^\n]", buf1, buf2);
+
                        switch (nArgs) {
                                case 2:
                                        tz = buf1;
@@ -3188,17 +3303,20 @@ static struct text_object *construct_text_object(const char *s, const char *arg,
 #ifdef HAVE_ICONV
        END OBJ(iconv_start, 0)
                if (iconv_converting) {
-                       CRIT_ERR("You must stop your last iconv conversion before starting another");
+                       CRIT_ERR("You must stop your last iconv conversion before "
+                               "starting another");
                }
                if (arg) {
                        char iconv_from[CODEPAGE_LENGTH];
                        char iconv_to[CODEPAGE_LENGTH];
+
                        if (sscanf(arg, "%s %s", iconv_from, iconv_to) != 2) {
                                CRIT_ERR("Invalid arguments for iconv_start");
                        } else {
                                iconv_t new_iconv;
+
                                new_iconv = iconv_open(iconv_to, iconv_from);
-                               if (new_iconv == (iconv_t)(-1)) {
+                               if (new_iconv == (iconv_t) (-1)) {
                                        ERR("Can't convert from %s to %s.", iconv_from, iconv_to);
                                } else {
                                        obj->a = register_iconv(&new_iconv);
@@ -3210,37 +3328,36 @@ static struct text_object *construct_text_object(const char *s, const char *arg,
                }
        END OBJ(iconv_stop, 0)
                iconv_converting = 0;
-       
+
 #endif
        END OBJ(totaldown, INFO_NET)
-               if(arg) {
+               if (arg) {
                        obj->data.net = get_net_stat(arg);
-               }
-               else {
+               } else {
                        CRIT_ERR("totaldown needs argument");
                }
-       END OBJ(totalup, INFO_NET) obj->data.net = get_net_stat(arg);
-       if(arg) {
+       END OBJ(totalup, INFO_NET)
                obj->data.net = get_net_stat(arg);
-       }
-       else {
-               CRIT_ERR("totalup needs argument");
-       }
+               if (arg) {
+                       obj->data.net = get_net_stat(arg);
+               } else {
+                       CRIT_ERR("totalup needs argument");
+               }
        END OBJ(updates, 0)
-               END OBJ(alignr, 0) obj->data.i = arg ? atoi(arg) : 0;
-       END OBJ(alignc, 0) obj->data.i = arg ? atoi(arg) : 0;
+       END OBJ(alignr, 0)
+               obj->data.i = arg ? atoi(arg) : 0;
+       END OBJ(alignc, 0)
+               obj->data.i = arg ? atoi(arg) : 0;
        END OBJ(upspeed, INFO_NET)
-               if(arg) {
+               if (arg) {
                        obj->data.net = get_net_stat(arg);
-               }
-               else {
+               } else {
                        CRIT_ERR("upspeed needs argument");
                }
-       END OBJ(upspeedf, INFO_NET) 
-               if(arg) {
+       END OBJ(upspeedf, INFO_NET)
+               if (arg) {
                        obj->data.net = get_net_stat(arg);
-               }
-               else {
+               } else {
                        CRIT_ERR("upspeedf needs argument");
                }
 
@@ -3252,16 +3369,19 @@ static struct text_object *construct_text_object(const char *s, const char *arg,
                        obj->data.net = get_net_stat(buf);
                        free(buf);
                }
-       END OBJ(uptime_short, INFO_UPTIME) END OBJ(uptime, INFO_UPTIME) END
+       END OBJ(uptime_short, INFO_UPTIME)
+       END OBJ(uptime, INFO_UPTIME)
 #ifndef __OpenBSD__
-               OBJ(adt746xcpu, 0) END OBJ(adt746xfan, 0) END
+       END OBJ(adt746xcpu, 0)
+       END OBJ(adt746xfan, 0)
 #endif /* !__OpenBSD__ */
-#if (defined(__FreeBSD__) || defined(__FreeBSD_kernel__) || defined(__OpenBSD__)) && (defined(i386) || defined(__i386__))
-               OBJ(apm_adapter, 0) END
-               OBJ(apm_battery_life, 0) END
-               OBJ(apm_battery_time, 0) END
+#if (defined(__FreeBSD__) || defined(__FreeBSD_kernel__) \
+               || defined(__OpenBSD__)) && (defined(i386) || defined(__i386__))
+       END OBJ(apm_adapter, 0)
+       END OBJ(apm_battery_life, 0)
+       END OBJ(apm_battery_time, 0)
 #endif /* __FreeBSD__ */
-               OBJ(imap_unseen, 0)
+       END OBJ(imap_unseen, 0)
                if (arg) {
                        // proccss
                        obj->data.mail = parse_mail_args(IMAP, arg);
@@ -3269,8 +3389,7 @@ static struct text_object *construct_text_object(const char *s, const char *arg,
                } else {
                        obj->global_mode = 1;
                }
-               END
-               OBJ(imap_messages, 0)
+       END OBJ(imap_messages, 0)
                if (arg) {
                        // proccss
                        obj->data.mail = parse_mail_args(IMAP, arg);
@@ -3278,8 +3397,7 @@ static struct text_object *construct_text_object(const char *s, const char *arg,
                } else {
                        obj->global_mode = 1;
                }
-               END
-               OBJ(pop3_unseen, 0)
+       END OBJ(pop3_unseen, 0)
                if (arg) {
                        // proccss
                        obj->data.mail = parse_mail_args(POP3, arg);
@@ -3287,8 +3405,7 @@ static struct text_object *construct_text_object(const char *s, const char *arg,
                } else {
                        obj->global_mode = 1;
                }
-               END
-               OBJ(pop3_used, 0)
+       END OBJ(pop3_used, 0)
                if (arg) {
                        // proccss
                        obj->data.mail = parse_mail_args(POP3, arg);
@@ -3296,235 +3413,218 @@ static struct text_object *construct_text_object(const char *s, const char *arg,
                } else {
                        obj->global_mode = 1;
                }
-               END
 #ifdef MPD
-               OBJ(mpd_artist, INFO_MPD) END
-               OBJ(mpd_title, INFO_MPD)
-               {
-                       if (arg) {
-                               sscanf (arg, "%d", &info.mpd.max_title_len);
-                               if (info.mpd.max_title_len > 0) {
-                                       info.mpd.max_title_len++;
-                               } else {
-                                       CRIT_ERR ("mpd_title: invalid length argument");
-                               }
+       END OBJ(mpd_artist, INFO_MPD)
+       END OBJ(mpd_title, INFO_MPD)
+               if (arg) {
+                       sscanf(arg, "%d", &info.mpd.max_title_len);
+                       if (info.mpd.max_title_len > 0) {
+                               info.mpd.max_title_len++;
                        } else {
-                               info.mpd.max_title_len = 0;
-                       }
-               }
-               END OBJ(mpd_random, INFO_MPD)
-               END OBJ(mpd_repeat, INFO_MPD)
-               END OBJ(mpd_elapsed, INFO_MPD)
-               END OBJ(mpd_length, INFO_MPD)
-               END OBJ(mpd_track, INFO_MPD)
-               END OBJ(mpd_name, INFO_MPD)
-               END OBJ(mpd_file, INFO_MPD)
-               END OBJ(mpd_percent, INFO_MPD)
-               END OBJ(mpd_album, INFO_MPD)
-               END OBJ(mpd_vol, INFO_MPD)
-               END OBJ(mpd_bitrate, INFO_MPD)
-               END OBJ(mpd_status, INFO_MPD)
-               END OBJ(mpd_bar, INFO_MPD)
-               (void) scan_bar(arg, &obj->data.pair.a, &obj->data.pair.b);
-               END OBJ(mpd_smart, INFO_MPD) END
+                               CRIT_ERR("mpd_title: invalid length argument");
+                       }
+               } else {
+                       info.mpd.max_title_len = 0;
+               }
+       END OBJ(mpd_random, INFO_MPD)
+       END OBJ(mpd_repeat, INFO_MPD)
+       END OBJ(mpd_elapsed, INFO_MPD)
+       END OBJ(mpd_length, INFO_MPD)
+       END OBJ(mpd_track, INFO_MPD)
+       END OBJ(mpd_name, INFO_MPD)
+       END OBJ(mpd_file, INFO_MPD)
+       END OBJ(mpd_percent, INFO_MPD)
+       END OBJ(mpd_album, INFO_MPD)
+       END OBJ(mpd_vol, INFO_MPD)
+       END OBJ(mpd_bitrate, INFO_MPD)
+       END OBJ(mpd_status, INFO_MPD)
+       END OBJ(mpd_bar, INFO_MPD)
+               scan_bar(arg, &obj->data.pair.a, &obj->data.pair.b);
+       END OBJ(mpd_smart, INFO_MPD)
 #endif
 #ifdef XMMS2
-               OBJ(xmms2_artist, INFO_XMMS2)
-               END OBJ(xmms2_album, INFO_XMMS2)
-               END OBJ(xmms2_title, INFO_XMMS2)
-               END OBJ(xmms2_genre, INFO_XMMS2)
-               END OBJ(xmms2_comment, INFO_XMMS2)
-               END OBJ(xmms2_decoder, INFO_XMMS2)
-               END OBJ(xmms2_transport, INFO_XMMS2)
-               END OBJ(xmms2_url, INFO_XMMS2)
-               END OBJ(xmms2_tracknr, INFO_XMMS2)
-               END OBJ(xmms2_bitrate, INFO_XMMS2)
-               END OBJ(xmms2_date, INFO_XMMS2)
-               END OBJ(xmms2_id, INFO_XMMS2)
-               END OBJ(xmms2_duration, INFO_XMMS2)
-               END OBJ(xmms2_elapsed, INFO_XMMS2)
-               END OBJ(xmms2_size, INFO_XMMS2)
-               END OBJ(xmms2_status, INFO_XMMS2)
-               END OBJ(xmms2_percent, INFO_XMMS2)
-               END OBJ(xmms2_bar, INFO_XMMS2)
-               (void) scan_bar(arg, &obj->data.pair.a, &obj->data.pair.b);
-               END OBJ(xmms2_smart, INFO_XMMS2)
-               END
+       END OBJ(xmms2_artist, INFO_XMMS2)
+       END OBJ(xmms2_album, INFO_XMMS2)
+       END OBJ(xmms2_title, INFO_XMMS2)
+       END OBJ(xmms2_genre, INFO_XMMS2)
+       END OBJ(xmms2_comment, INFO_XMMS2)
+       END OBJ(xmms2_decoder, INFO_XMMS2)
+       END OBJ(xmms2_transport, INFO_XMMS2)
+       END OBJ(xmms2_url, INFO_XMMS2)
+       END OBJ(xmms2_tracknr, INFO_XMMS2)
+       END OBJ(xmms2_bitrate, INFO_XMMS2)
+       END OBJ(xmms2_date, INFO_XMMS2)
+       END OBJ(xmms2_id, INFO_XMMS2)
+       END OBJ(xmms2_duration, INFO_XMMS2)
+       END OBJ(xmms2_elapsed, INFO_XMMS2)
+       END OBJ(xmms2_size, INFO_XMMS2)
+       END OBJ(xmms2_status, INFO_XMMS2)
+       END OBJ(xmms2_percent, INFO_XMMS2)
+       END OBJ(xmms2_bar, INFO_XMMS2)
+               scan_bar(arg, &obj->data.pair.a, &obj->data.pair.b);
+       END OBJ(xmms2_smart, INFO_XMMS2)
 #endif
 #ifdef AUDACIOUS
-               OBJ(audacious_status, INFO_AUDACIOUS) END
-               OBJ(audacious_title, INFO_AUDACIOUS) 
-               {
-                       if (arg) {
-                               sscanf (arg, "%d", &info.audacious.max_title_len);
-                               if (info.audacious.max_title_len > 0) {
-                                       info.audacious.max_title_len++;
-                               }                   else {
-                                       CRIT_ERR ("audacious_title: invalid length argument");
-                               }
-                       }
-               }
-               END
-               OBJ(audacious_length, INFO_AUDACIOUS) END
-               OBJ(audacious_length_seconds, INFO_AUDACIOUS) END
-               OBJ(audacious_position, INFO_AUDACIOUS) END
-               OBJ(audacious_position_seconds, INFO_AUDACIOUS) END
-               OBJ(audacious_bitrate, INFO_AUDACIOUS) END
-               OBJ(audacious_frequency, INFO_AUDACIOUS) END
-               OBJ(audacious_channels, INFO_AUDACIOUS) END
-               OBJ(audacious_filename, INFO_AUDACIOUS) END
-               OBJ(audacious_playlist_length, INFO_AUDACIOUS) END
-               OBJ(audacious_playlist_position, INFO_AUDACIOUS) END
-               OBJ(audacious_bar, INFO_AUDACIOUS)
-               (void) scan_bar(arg, &obj->a, &obj->b);
-       END
+       END OBJ(audacious_status, INFO_AUDACIOUS)
+       END OBJ(audacious_title, INFO_AUDACIOUS)
+               if (arg) {
+                       sscanf(arg, "%d", &info.audacious.max_title_len);
+                       if (info.audacious.max_title_len > 0) {
+                               info.audacious.max_title_len++;
+                       } else {
+                               CRIT_ERR("audacious_title: invalid length argument");
+                       }
+               }
+       END OBJ(audacious_length, INFO_AUDACIOUS)
+       END OBJ(audacious_length_seconds, INFO_AUDACIOUS)
+       END OBJ(audacious_position, INFO_AUDACIOUS)
+       END OBJ(audacious_position_seconds, INFO_AUDACIOUS)
+       END OBJ(audacious_bitrate, INFO_AUDACIOUS)
+       END OBJ(audacious_frequency, INFO_AUDACIOUS)
+       END OBJ(audacious_channels, INFO_AUDACIOUS)
+       END OBJ(audacious_filename, INFO_AUDACIOUS)
+       END OBJ(audacious_playlist_length, INFO_AUDACIOUS)
+       END OBJ(audacious_playlist_position, INFO_AUDACIOUS)
+       END OBJ(audacious_bar, INFO_AUDACIOUS)
+               scan_bar(arg, &obj->a, &obj->b);
 #endif
 #ifdef BMPX
-               OBJ(bmpx_title, INFO_BMPX)
+       END OBJ(bmpx_title, INFO_BMPX)
                memset(&(info.bmpx), 0, sizeof(struct bmpx_s));
-       END
-               OBJ(bmpx_artist, INFO_BMPX)
+       END OBJ(bmpx_artist, INFO_BMPX)
                memset(&(info.bmpx), 0, sizeof(struct bmpx_s));
-       END
-               OBJ(bmpx_album, INFO_BMPX)
+       END OBJ(bmpx_album, INFO_BMPX)
                memset(&(info.bmpx), 0, sizeof(struct bmpx_s));
-       END
-               OBJ(bmpx_track, INFO_BMPX)
+       END OBJ(bmpx_track, INFO_BMPX)
                memset(&(info.bmpx), 0, sizeof(struct bmpx_s));
-       END
-               OBJ(bmpx_uri, INFO_BMPX)
+       END OBJ(bmpx_uri, INFO_BMPX)
                memset(&(info.bmpx), 0, sizeof(struct bmpx_s));
-       END
-               OBJ(bmpx_bitrate, INFO_BMPX)
+       END OBJ(bmpx_bitrate, INFO_BMPX)
                memset(&(info.bmpx), 0, sizeof(struct bmpx_s));
-       END
 #endif
 #ifdef RSS
-       OBJ(rss, 0) 
+       END OBJ(rss, 0)
                if (arg) {
                        int argc, delay, act_par;
-                       char *uri = (char *)malloc(128 * sizeof(char));
-                       char *action = (char *)malloc(64 * sizeof(char));
+                       char *uri = (char *) malloc(128 * sizeof(char));
+                       char *action = (char *) malloc(64 * sizeof(char));
 
-                       argc = sscanf(arg, "%127s %d %63s %d", uri, &delay, action, &act_par);
+                       argc = sscanf(arg, "%127s %d %63s %d", uri, &delay, action,
+                               &act_par);
                        obj->data.rss.uri = uri;
                        obj->data.rss.delay = delay;
                        obj->data.rss.action = action;
                        obj->data.rss.act_par = act_par;
 
                        init_rss_info();
-               } else
-                       CRIT_ERR("rss needs arguments: <uri> <delay in minutes> <action> [act_par]");
-
-       END
+               } else {
+                       CRIT_ERR("rss needs arguments: <uri> <delay in minutes> <action> "
+                               "[act_par]");
+               }
 #endif
 #ifdef HDDTEMP
-       OBJ(hddtemp, 0)
-               if (!arg || scan_hddtemp(arg, &obj->data.hddtemp.dev, 
-                       &obj->data.hddtemp.addr, &obj->data.hddtemp.port)) {
+       END OBJ(hddtemp, 0)
+               if (!arg || scan_hddtemp(arg, &obj->data.hddtemp.dev,
+                               &obj->data.hddtemp.addr, &obj->data.hddtemp.port)) {
                        ERR("hddtemp needs arguments");
                        obj->type = OBJ_text;
                        obj->data.s = strdup("${hddtemp}");
                        return NULL;
                }
-       END
 #endif
 #ifdef TCP_PORT_MONITOR
-               OBJ(tcp_portmon, INFO_TCP_PORT_MONITOR) 
+       END OBJ(tcp_portmon, INFO_TCP_PORT_MONITOR)
                int argc, port_begin, port_end, item, connection_index;
-       char itembuf[32];
-       memset(itembuf,0,sizeof(itembuf));
-       connection_index=0;
-       /* massive argument checking */
-       if (!arg) {
-               CRIT_ERR("tcp_portmon: needs arguments");
-       }
-       argc=sscanf(arg, "%d %d %31s %d", &port_begin, &port_end, itembuf, &connection_index);
-       if ( (argc != 3) && (argc != 4) ) 
-       {
-               CRIT_ERR("tcp_portmon: requires 3 or 4 arguments");
-       }
-       if ( (port_begin<1) || (port_begin>65535) || (port_end<1) || (port_end>65535) )
-       {
-               CRIT_ERR("tcp_portmon: port values must be from 1 to 65535");
-       }
-       if ( port_begin > port_end )
-       {
-               CRIT_ERR("tcp_portmon: starting port must be <= ending port");
-       }
-       if ( strncmp(itembuf,"count",31) == 0 )
-               item=COUNT;
-       else if ( strncmp(itembuf,"rip",31) == 0 )
-               item=REMOTEIP;
-       else if ( strncmp(itembuf,"rhost",31) == 0 )
-               item=REMOTEHOST;
-       else if ( strncmp(itembuf,"rport",31) == 0 )
-               item=REMOTEPORT;
-       else if ( strncmp(itembuf,"rservice",31) == 0 )
-               item=REMOTESERVICE;
-       else if ( strncmp(itembuf,"lip",31) == 0 )
-               item=LOCALIP;
-       else if ( strncmp(itembuf,"lhost",31) == 0 )
-               item=LOCALHOST;
-       else if ( strncmp(itembuf,"lport",31) == 0 )
-               item=LOCALPORT;
-       else if ( strncmp(itembuf,"lservice",31) == 0 )
-               item=LOCALSERVICE;
-       else
-       {
-               CRIT_ERR("tcp_portmon: invalid item specified"); 
-       }
-       if ( (argc==3) && (item!=COUNT) )
-       {
-               CRIT_ERR("tcp_portmon: 3 argument form valid only for \"count\" item");
-       }
-       if ( (argc==4) && (connection_index<0) )
-       {
-               CRIT_ERR("tcp_portmon: connection index must be non-negative");
-       }
-       /* ok, args looks good. save the text object data */
-       obj->data.tcp_port_monitor.port_range_begin = (in_port_t)port_begin;
-       obj->data.tcp_port_monitor.port_range_end = (in_port_t)port_end;
-       obj->data.tcp_port_monitor.item = item;
-       obj->data.tcp_port_monitor.connection_index = connection_index;
-
-       /* if the port monitor collection hasn't been created, we must create it */
-       if ( !info.p_tcp_port_monitor_collection )
-       {
-               info.p_tcp_port_monitor_collection = 
-                       create_tcp_port_monitor_collection ();
-               if ( !info.p_tcp_port_monitor_collection )
-               {
-                       CRIT_ERR("tcp_portmon: unable to create port monitor collection");
+               char itembuf[32];
+
+               memset(itembuf, 0, sizeof(itembuf));
+               connection_index = 0;
+               /* massive argument checking */
+               if (!arg) {
+                       CRIT_ERR("tcp_portmon: needs arguments");
+               }
+               argc = sscanf(arg, "%d %d %31s %d", &port_begin, &port_end, itembuf,
+                       &connection_index);
+               if ((argc != 3) && (argc != 4)) {
+                       CRIT_ERR("tcp_portmon: requires 3 or 4 arguments");
+               }
+               if ((port_begin < 1) || (port_begin > 65535) || (port_end < 1)
+                               || (port_end > 65535)) {
+                       CRIT_ERR("tcp_portmon: port values must be from 1 to 65535");
+               }
+               if (port_begin > port_end) {
+                       CRIT_ERR("tcp_portmon: starting port must be <= ending port");
+               }
+               if (strncmp(itembuf, "count", 31) == 0) {
+                       item = COUNT;
+               } else if (strncmp(itembuf, "rip", 31) == 0) {
+                       item = REMOTEIP;
+               } else if (strncmp(itembuf, "rhost", 31) == 0) {
+                       item = REMOTEHOST;
+               } else if (strncmp(itembuf, "rport", 31) == 0) {
+                       item = REMOTEPORT;
+               } else if (strncmp(itembuf, "rservice", 31) == 0) {
+                       item = REMOTESERVICE;
+               } else if (strncmp(itembuf, "lip", 31) == 0) {
+                       item = LOCALIP;
+               } else if (strncmp(itembuf, "lhost", 31) == 0) {
+                       item = LOCALHOST;
+               } else if (strncmp(itembuf, "lport", 31) == 0) {
+                       item = LOCALPORT;
+               } else if (strncmp(itembuf, "lservice", 31) == 0) {
+                       item = LOCALSERVICE;
+               } else {
+                       CRIT_ERR("tcp_portmon: invalid item specified");
                }
-       }
+               if ((argc == 3) && (item != COUNT)) {
+                       CRIT_ERR("tcp_portmon: 3 argument form valid only for \"count\" "
+                               "item");
+               }
+               if ((argc == 4) && (connection_index < 0)) {
+                       CRIT_ERR("tcp_portmon: connection index must be non-negative");
+               }
+               /* ok, args looks good. save the text object data */
+               obj->data.tcp_port_monitor.port_range_begin = (in_port_t) port_begin;
+               obj->data.tcp_port_monitor.port_range_end = (in_port_t) port_end;
+               obj->data.tcp_port_monitor.item = item;
+               obj->data.tcp_port_monitor.connection_index = connection_index;
 
-       /* if a port monitor for this port does not exist, create one and add it to the collection */
-       if ( find_tcp_port_monitor( info.p_tcp_port_monitor_collection, port_begin, port_end ) == NULL )
-       {
-               tcp_port_monitor_t * p_monitor = 
-                       create_tcp_port_monitor( port_begin, port_end, &tcp_port_monitor_args );
-               if ( !p_monitor )
-               {
-                       CRIT_ERR("tcp_portmon: unable to create port monitor");
+               /* if the port monitor collection hasn't been created,
+                * we must create it */
+               if (!info.p_tcp_port_monitor_collection) {
+                       info.p_tcp_port_monitor_collection =
+                               create_tcp_port_monitor_collection();
+                       if (!info.p_tcp_port_monitor_collection) {
+                               CRIT_ERR("tcp_portmon: unable to create port monitor "
+                                       "collection");
+                       }
                }
-               /* add the newly created monitor to the collection */
-               if ( insert_tcp_port_monitor_into_collection( info.p_tcp_port_monitor_collection,
-                                       p_monitor ) != 0 )
-               {
-                       CRIT_ERR("tcp_portmon: unable to add port monitor to collection");
+
+               /* if a port monitor for this port does not exist,
+                * create one and add it to the collection */
+               if (find_tcp_port_monitor(info.p_tcp_port_monitor_collection,
+                               port_begin, port_end) == NULL) {
+                       tcp_port_monitor_t *p_monitor = create_tcp_port_monitor(port_begin,
+                               port_end, &tcp_port_monitor_args);
+
+                       if (!p_monitor) {
+                               CRIT_ERR("tcp_portmon: unable to create port monitor");
+                       }
+                       /* add the newly created monitor to the collection */
+                       if (insert_tcp_port_monitor_into_collection(
+                                       info.p_tcp_port_monitor_collection, p_monitor) != 0) {
+                               CRIT_ERR("tcp_portmon: unable to add port monitor to "
+                                       "collection");
+                       }
                }
-       }
-       END
 #endif
-       OBJ(entropy_avail, INFO_ENTROPY) END
-       OBJ(entropy_poolsize, INFO_ENTROPY) END
-       OBJ(entropy_bar, INFO_ENTROPY)
-               (void) scan_bar(arg, &obj->a, &obj->b);
-       END
-
-       {
+       END OBJ(entropy_avail, INFO_ENTROPY)
+       END OBJ(entropy_poolsize, INFO_ENTROPY)
+       END OBJ(entropy_bar, INFO_ENTROPY)
+               scan_bar(arg, &obj->a, &obj->b);
+       END {
                char buf[256];
+
                ERR("unknown variable %s", s);
                obj->type = OBJ_text;
                snprintf(buf, 256, "${%s}", s);
@@ -3569,13 +3669,14 @@ static struct text_object_list *extract_variable_text_internal(const char *p)
                if (*p == '$') {
                        *(char *) p = '\0';
                        obj = create_plain_text(s);
-                       if(obj != NULL) {
+                       if (obj != NULL) {
                                // allocate memory for the object
-                               retval->text_objects = realloc(retval->text_objects, 
-                                               sizeof(struct text_object) * (retval->text_object_count+1));
+                               retval->text_objects = realloc(retval->text_objects,
+                                       sizeof(struct text_object) *
+                                       (retval->text_object_count + 1));
                                // assign the new object to the end of the list.
-                               memcpy(&retval->text_objects[retval->text_object_count++],
-                                               obj, sizeof(struct text_object));
+                               memcpy(&retval->text_objects[retval->text_object_count++], obj,
+                                       sizeof(struct text_object));
                                free(obj);
                        }
                        *(char *) p = '$';
@@ -3590,21 +3691,27 @@ static struct text_object_list *extract_variable_text_internal(const char *p)
                                /* variable is either $foo or ${foo} */
                                if (*p == '{') {
                                        unsigned int brl = 1, brr = 0;
+
                                        p++;
                                        s = p;
                                        while (*p && brl != brr) {
-                                               if (*p == '{') brl++;
-                                               if (*p == '}') brr++;
+                                               if (*p == '{') {
+                                                       brl++;
+                                               }
+                                               if (*p == '}') {
+                                                       brr++;
+                                               }
                                                p++;
                                        }
                                        p--;
                                } else {
                                        s = p;
-                                       if (*p == '#')
+                                       if (*p == '#') {
                                                p++;
-                                       while (*p && (isalnum((int) *p)
-                                                               || *p == '_'))
+                                       }
+                                       while (*p && (isalnum((int) *p) || *p == '_')) {
                                                p++;
+                                       }
                                }
 
                                /* copy variable to buffer */
@@ -3612,13 +3719,14 @@ static struct text_object_list *extract_variable_text_internal(const char *p)
                                strncpy(buf, s, len);
                                buf[len] = '\0';
 
-                               if (*p == '}')
+                               if (*p == '}') {
                                        p++;
+                               }
                                s = p;
 
                                var = getenv(buf);
 
-                               /* if variable wasn't found from environment, use some special */
+                               /* if variable wasn't found in environment, use some special */
                                if (!var) {
                                        char *p;
                                        char *arg = 0;
@@ -3628,10 +3736,12 @@ static struct text_object_list *extract_variable_text_internal(const char *p)
                                                arg = strchr(buf, ' ');
                                                *arg = '\0';
                                                arg++;
-                                               while (isspace((int) *arg))
+                                               while (isspace((int) *arg)) {
                                                        arg++;
-                                               if (!*arg)
+                                               }
+                                               if (!*arg) {
                                                        arg = 0;
+                                               }
                                        }
 
                                        /* lowercase variable name */
@@ -3642,27 +3752,31 @@ static struct text_object_list *extract_variable_text_internal(const char *p)
                                        }
 
                                        // create new object
-                                       obj = construct_text_object(buf, arg, retval->text_object_count, retval->text_objects, line);
-                                       if(obj != NULL) {
+                                       obj = construct_text_object(buf, arg,
+                                               retval->text_object_count, retval->text_objects, line);
+                                       if (obj != NULL) {
                                                // allocate memory for the object
-                                               retval->text_objects = realloc(retval->text_objects, 
-                                                               sizeof(struct text_object) * (retval->text_object_count+1));
+                                               retval->text_objects = realloc(retval->text_objects,
+                                                       sizeof(struct text_object) *
+                                                       (retval->text_object_count + 1));
                                                // assign the new object to the end of the list.
-                                               memcpy(&retval->text_objects[retval->text_object_count++],
-                                                               obj, sizeof(struct text_object));
+                                               memcpy(
+                                                       &retval->text_objects[retval->text_object_count++],
+                                                       obj, sizeof(struct text_object));
                                                free(obj);
                                        }
                                }
                                continue;
                        } else {
                                obj = create_plain_text("$");
-                               if(obj != NULL) {
+                               if (obj != NULL) {
                                        // allocate memory for the object
-                                       retval->text_objects = realloc(retval->text_objects, 
-                                                       sizeof(struct text_object) * (retval->text_object_count+1));
+                                       retval->text_objects = realloc(retval->text_objects,
+                                               sizeof(struct text_object) *
+                                               (retval->text_object_count + 1));
                                        // assign the new object to the end of the list.
                                        memcpy(&retval->text_objects[retval->text_object_count++],
-                                                       obj, sizeof(struct text_object));
+                                               obj, sizeof(struct text_object));
                                        free(obj);
                                }
                        }
@@ -3670,13 +3784,13 @@ static struct text_object_list *extract_variable_text_internal(const char *p)
                p++;
        }
        obj = create_plain_text(s);
-       if(obj != NULL) {
+       if (obj != NULL) {
                // allocate memory for the object
                retval->text_objects = realloc(retval->text_objects,
-                               sizeof(struct text_object) * (retval->text_object_count+1));
+                       sizeof(struct text_object) * (retval->text_object_count + 1));
                // assign the new object to the end of the list.
-               memcpy(&retval->text_objects[retval->text_object_count++],
-                               obj, sizeof(struct text_object));
+               memcpy(&retval->text_objects[retval->text_object_count++], obj,
+                       sizeof(struct text_object));
                free(obj);
        }
 
@@ -3695,111 +3809,112 @@ static void extract_variable_text(const char *p)
        text_object_count = 0;
        text_objects = NULL;
 
-
        list = extract_variable_text_internal(p);
        text_objects = list->text_objects;
        text_object_count = list->text_object_count;
 
        free(list);
-
-       return;
 }
 
-void parse_conky_vars(char * text, char * p, struct information *cur) { 
-       struct text_object_list *object_list = extract_variable_text_internal(text);
-       generate_text_internal(p, P_MAX_SIZE, object_list->text_objects, object_list->text_object_count, cur);
+void parse_conky_vars(char *text, char *p, struct information *cur)
+{
+       struct text_object_list *object_list =
+               extract_variable_text_internal(text);
+
+       generate_text_internal(p, P_MAX_SIZE, object_list->text_objects,
+               object_list->text_object_count, cur);
        free(object_list);
 }
 
-/*
- * Allows reading from a FIFO (i.e., /dev/xconsole). The file descriptor is
- * set to non-blocking which makes this possible.
+/* Allows reading from a FIFO (i.e., /dev/xconsole).
+ * The file descriptor is set to non-blocking which makes this possible.
  *
- * FIXME
- * Since lseek cannot seek a file descriptor long lines will break.
- */
+ * FIXME: Since lseek cannot seek a file descriptor long lines will break. */
 static void tail_pipe(struct text_object *obj, char *dst, size_t dst_size)
 {
 #define TAIL_PIPE_BUFSIZE      4096
-    int lines = 0;
-    int line_len = 0;
-    int last_line = 0;
-    int fd = obj->data.tail.fd;
-
-    while (1) {
-       char buf[TAIL_PIPE_BUFSIZE];
-       ssize_t len = read(fd, buf, sizeof(buf));
-       int i;
+       int lines = 0;
+       int line_len = 0;
+       int last_line = 0;
+       int fd = obj->data.tail.fd;
 
-       if (len == -1) {
-           if (errno != EAGAIN) {
-               strcpy(obj->data.tail.buffer, "Logfile Read Error");
-               snprintf(dst, dst_size, "Logfile Read Error");
-           }
+       while (1) {
+               char buf[TAIL_PIPE_BUFSIZE];
+               ssize_t len = read(fd, buf, sizeof(buf));
+               int i;
 
-           break;
-       }
-       else if (len == 0) {
-           strcpy(obj->data.tail.buffer, "Logfile Empty");
-           snprintf(dst, dst_size, "Logfile Empty");
-           break;
-       }
+               if (len == -1) {
+                       if (errno != EAGAIN) {
+                               strcpy(obj->data.tail.buffer, "Logfile Read Error");
+                               snprintf(dst, dst_size, "Logfile Read Error");
+                       }
 
-       for (line_len = 0, i = 0; i < len; i++) {
-           int pos = 0;
-           char *p;
+                       break;
+               } else if (len == 0) {
+                       strcpy(obj->data.tail.buffer, "Logfile Empty");
+                       snprintf(dst, dst_size, "Logfile Empty");
+                       break;
+               }
 
-           if (buf[i] == '\n') {
-               lines++;
+               for (line_len = 0, i = 0; i < len; i++) {
+                       int pos = 0;
+                       char *p;
 
-               if (obj->data.tail.readlines > 0) {
-                   int n;
-                   int olines = 0;
-                   int first_line = 0;
+                       if (buf[i] == '\n') {
+                               lines++;
 
-                   for (n = 0; obj->data.tail.buffer[n]; n++) {
-                       if (obj->data.tail.buffer[n] == '\n') {
-                           if (!first_line)
-                               first_line = n+1;
+                               if (obj->data.tail.readlines > 0) {
+                                       int n;
+                                       int olines = 0;
+                                       int first_line = 0;
 
-                           if (++olines < obj->data.tail.wantedlines) {
-                               pos = n+1;
-                               continue;
-                           }
+                                       for (n = 0; obj->data.tail.buffer[n]; n++) {
+                                               if (obj->data.tail.buffer[n] == '\n') {
+                                                       if (!first_line) {
+                                                               first_line = n + 1;
+                                                       }
 
-                           n++;
-                           p = obj->data.tail.buffer + first_line;
-                           pos = n - first_line;
-                           memmove(obj->data.tail.buffer, obj->data.tail.buffer + first_line, strlen(p));
-                           obj->data.tail.buffer[pos] = 0;
-                           break;
-                       }
-                   }
-               }
+                                                       if (++olines < obj->data.tail.wantedlines) {
+                                                               pos = n + 1;
+                                                               continue;
+                                                       }
 
-               p = buf + last_line;
-               line_len++;
-               memcpy(&(obj->data.tail.buffer[pos]), p, line_len);
-               obj->data.tail.buffer[pos + line_len] = 0;
-               last_line = i+1;
-               line_len = 0;
-               obj->data.tail.readlines = lines;
-               continue;
-           }
+                                                       n++;
+                                                       p = obj->data.tail.buffer + first_line;
+                                                       pos = n - first_line;
+                                                       memmove(obj->data.tail.buffer,
+                                                               obj->data.tail.buffer + first_line, strlen(p));
+                                                       obj->data.tail.buffer[pos] = 0;
+                                                       break;
+                                               }
+                                       }
+                               }
 
-           line_len++;
+                               p = buf + last_line;
+                               line_len++;
+                               memcpy(&(obj->data.tail.buffer[pos]), p, line_len);
+                               obj->data.tail.buffer[pos + line_len] = 0;
+                               last_line = i + 1;
+                               line_len = 0;
+                               obj->data.tail.readlines = lines;
+                               continue;
+                       }
+
+                       line_len++;
+               }
        }
-    }
 
-    snprintf(dst, dst_size, "%s", obj->data.tail.buffer);
+       snprintf(dst, dst_size, "%s", obj->data.tail.buffer);
 }
 
-static void generate_text_internal(char *p, int p_max_size, struct text_object *objs, unsigned int object_count, struct information *cur)
+static void generate_text_internal(char *p, int p_max_size,
+               struct text_object *objs, unsigned int object_count,
+               struct information *cur)
 {
        unsigned int i;
 
 #ifdef HAVE_ICONV
-       char buff_in[P_MAX_SIZE] = {0};
+       char buff_in[P_MAX_SIZE] = { 0 };
        iconv_converting = 0;
 #endif
 
@@ -3810,746 +3925,818 @@ static void generate_text_internal(char *p, int p_max_size, struct text_object *
 
                switch (obj->type) {
                        default:
-                               {
-                                       ERR("not implemented obj type %d",
-                                                       obj->type);
-                               }
+                               ERR("not implemented obj type %d", obj->type);
 #ifndef __OpenBSD__
-                               OBJ(acpitemp) {
-                                       /* does anyone have decimals in acpi temperature? */
-                                       spaced_print(p, p_max_size, "%d", 5, "acpitemp",
-                                               round_to_int(get_acpi_temperature(obj->data.i)));
-                               }
-                               OBJ(acpitempf) {
-                                       /* does anyone have decimals in acpi temperature? */
-                                       spaced_print(p, p_max_size, "%d", 5, "acpitemp",
-                                               round_to_int((get_acpi_temperature(obj->data.i) + 40) *
-                                               9.0 / 5 - 40));
-                               }
+                       OBJ(acpitemp) {
+                               /* does anyone have decimals in acpi temperature? */
+                               spaced_print(p, p_max_size, "%d", 5, "acpitemp",
+                                       round_to_int(get_acpi_temperature(obj->data.i)));
+                       }
+                       OBJ(acpitempf) {
+                               /* does anyone have decimals in acpi temperature? */
+                               spaced_print(p, p_max_size, "%d", 5, "acpitemp",
+                                       round_to_int((get_acpi_temperature(obj->data.i) + 40) *
+                                       9.0 / 5 - 40));
+                       }
 #endif /* !__OpenBSD__ */
-                               OBJ(freq) {
-                                       if (obj->a) {
-                                               obj->a = get_freq(p, p_max_size, "%.0f", 1, obj->data.cpu_index); 
-                                       }
+                       OBJ(freq) {
+                               if (obj->a) {
+                                       obj->a = get_freq(p, p_max_size, "%.0f", 1,
+                                               obj->data.cpu_index);
                                }
-                               OBJ(freq_g) {
-                                       if (obj->a) {
+                       }
+                       OBJ(freq_g) {
+                               if (obj->a) {
 #ifndef __OpenBSD__
-                                               obj->a = get_freq(p, p_max_size, "%'.2f", 1000, obj->data.cpu_index); 
+                                       obj->a = get_freq(p, p_max_size, "%'.2f", 1000,
+                                               obj->data.cpu_index);
 #else
-                                               /* OpenBSD has no such flag (SUSv2) */
-                                               obj->a = get_freq(p, p_max_size, "%.2f", 1000, obj->data.cpu_index); 
+                                       /* OpenBSD has no such flag (SUSv2) */
+                                       obj->a = get_freq(p, p_max_size, "%.2f", 1000,
+                                               obj->data.cpu_index);
 #endif
-
-                                       }
                                }
+                       }
 #if defined(__linux__)
-                               OBJ(voltage_mv) {
-                                       if (obj->a) {
-                                               obj->a = get_voltage(p, p_max_size, "%.0f", 1, obj->data.cpu_index);
-                                       }
+                       OBJ(voltage_mv) {
+                               if (obj->a) {
+                                       obj->a = get_voltage(p, p_max_size, "%.0f", 1,
+                                               obj->data.cpu_index);
                                }
-                               OBJ(voltage_v) {
-                                       if (obj->a) {
-                                               obj->a = get_voltage(p, p_max_size, "%'.3f", 1000, obj->data.cpu_index);
-                                       }
+                       }
+                       OBJ(voltage_v) {
+                               if (obj->a) {
+                                       obj->a = get_voltage(p, p_max_size, "%'.3f", 1000,
+                                               obj->data.cpu_index);
                                }
+                       }
+
 #ifdef HAVE_IWLIB
-                               OBJ(wireless_essid) {
-                                       snprintf(p, p_max_size, "%s", obj->data.net->essid);
-                               }
-                               OBJ(wireless_mode) {
-                                       snprintf(p, p_max_size, "%s", obj->data.net->mode);
-                               }
-                               OBJ(wireless_bitrate) {
-                                       snprintf(p, p_max_size, "%s", obj->data.net->bitrate);
-                               }
-                               OBJ(wireless_ap) {
-                                       snprintf(p, p_max_size, "%s", obj->data.net->ap);
-                               }
-                               OBJ(wireless_link_qual) {
-                                       spaced_print(p, p_max_size, "%d", 4, "wireless_link_qual",
-                                               obj->data.net->link_qual);
-                               }
-                               OBJ(wireless_link_qual_max) {
-                                       spaced_print(p, p_max_size, "%d", 4,
-                                               "wireless_link_qual_max", obj->data.net->link_qual_max);
-                               }
-                               OBJ(wireless_link_qual_perc) {
-                                       if(obj->data.net->link_qual_max > 0) {
-                                               spaced_print(p, p_max_size, "%.0f%%", 5,
-                                                       "wireless_link_qual_perc",
-                                                       (double) obj->data.net->link_qual /
-                                                       obj->data.net->link_qual_max * 100);
-                                       } else {
-                                               spaced_print(p, p_max_size, "unk", 5,
-                                                       "wireless_link_qual_perc");
-                                       }
-                               }
-                               OBJ(wireless_link_bar) {
-                                       new_bar(p, obj->a, obj->b, ((double)obj->data.net->link_qual/obj->data.net->link_qual_max)*255.0);
+                       OBJ(wireless_essid) {
+                               snprintf(p, p_max_size, "%s", obj->data.net->essid);
+                       }
+                       OBJ(wireless_mode) {
+                               snprintf(p, p_max_size, "%s", obj->data.net->mode);
+                       }
+                       OBJ(wireless_bitrate) {
+                               snprintf(p, p_max_size, "%s", obj->data.net->bitrate);
+                       }
+                       OBJ(wireless_ap) {
+                               snprintf(p, p_max_size, "%s", obj->data.net->ap);
+                       }
+                       OBJ(wireless_link_qual) {
+                               spaced_print(p, p_max_size, "%d", 4, "wireless_link_qual",
+                                       obj->data.net->link_qual);
+                       }
+                       OBJ(wireless_link_qual_max) {
+                               spaced_print(p, p_max_size, "%d", 4,
+                                       "wireless_link_qual_max", obj->data.net->link_qual_max);
+                       }
+                       OBJ(wireless_link_qual_perc) {
+                               if (obj->data.net->link_qual_max > 0) {
+                                       spaced_print(p, p_max_size, "%.0f%%", 5,
+                                               "wireless_link_qual_perc",
+                                               (double) obj->data.net->link_qual /
+                                               obj->data.net->link_qual_max * 100);
+                               } else {
+                                       spaced_print(p, p_max_size, "unk", 5,
+                                               "wireless_link_qual_perc");
                                }
+                       }
+                       OBJ(wireless_link_bar) {
+                               new_bar(p, obj->a, obj->b, ((double) obj->data.net->link_qual /
+                                       obj->data.net->link_qual_max) * 255.0);
+                       }
 #endif /* HAVE_IWLIB */
 
 #endif /* __linux__ */
 
-                               OBJ(freq_dyn) {
-                                       get_freq_dynamic(p, p_max_size, "%.0f", 1);
-                                       spaced_print(p, p_max_size, "%s", 6, "freq_dyn", p);
-                               }
-                               OBJ(freq_dyn_g) {
+                       OBJ(freq_dyn) {
+                               get_freq_dynamic(p, p_max_size, "%.0f", 1);
+                               spaced_print(p, p_max_size, "%s", 6, "freq_dyn", p);
+                       }
+                       OBJ(freq_dyn_g) {
 #ifndef __OpenBSD__
-                                       get_freq_dynamic(p, p_max_size, "%'.2f", 1000);
+                               get_freq_dynamic(p, p_max_size, "%'.2f", 1000);
 #else
-                                       get_freq_dynamic(p, p_max_size, "%.2f", 1000);
+                               get_freq_dynamic(p, p_max_size, "%.2f", 1000);
 #endif
-                                       spaced_print(p, p_max_size, "%s", 6, "freq_dyn", p);
-                               }
+                               spaced_print(p, p_max_size, "%s", 6, "freq_dyn", p);
+                       }
+
 #ifndef __OpenBSD__
-                               OBJ(adt746xcpu) {
-                                       get_adt746x_cpu(p, p_max_size); 
-                               }
-                               OBJ(adt746xfan) {
-                                       get_adt746x_fan(p, p_max_size); 
-                               }
-                               OBJ(acpifan) {
-                                       get_acpi_fan(p, p_max_size);  
-                               }
-                               OBJ(acpiacadapter) {
-                                       get_acpi_ac_adapter(p, p_max_size); 
-                               }
-                               OBJ(battery) {
-                                       get_battery_stuff(p, p_max_size, obj->data.s, BATTERY_STATUS);
-                               }
-                               OBJ(battery_time) {
-                                       get_battery_stuff(p, p_max_size, obj->data.s, BATTERY_TIME);
-                               }
-                               OBJ(battery_percent) {
-                                       snprintf(p, p_max_size, "%d", 
-                                               get_battery_perct(obj->data.s));
-                               }
-                               OBJ(battery_bar) {
-                                       new_bar(p, obj->a, obj->b, get_battery_perct_bar(obj->data.s));
-                               }
+                       OBJ(adt746xcpu) {
+                               get_adt746x_cpu(p, p_max_size);
+                       }
+                       OBJ(adt746xfan) {
+                               get_adt746x_fan(p, p_max_size);
+                       }
+                       OBJ(acpifan) {
+                               get_acpi_fan(p, p_max_size);
+                       }
+                       OBJ(acpiacadapter) {
+                               get_acpi_ac_adapter(p, p_max_size);
+                       }
+                       OBJ(battery) {
+                               get_battery_stuff(p, p_max_size, obj->data.s, BATTERY_STATUS);
+                       }
+                       OBJ(battery_time) {
+                               get_battery_stuff(p, p_max_size, obj->data.s, BATTERY_TIME);
+                       }
+                       OBJ(battery_percent) {
+                               snprintf(p, p_max_size, "%d", get_battery_perct(obj->data.s));
+                       }
+                       OBJ(battery_bar) {
+                               new_bar(p, obj->a, obj->b, get_battery_perct_bar(obj->data.s));
+                       }
 #endif /* __OpenBSD__ */
-                               OBJ(buffers) {
-                                       human_readable(cur->buffers * 1024, p, 255, "buffers");
-                               }
-                               OBJ(cached) {
-                                       human_readable(cur->cached * 1024, p, 255, "buffers");
-                               }
-                               OBJ(cpu) {
-                                       if (obj->data.cpu_index > info.cpu_count) {
-                                               printf("obj->data.cpu_index %i info.cpu_count %i",
-                                                       obj->data.cpu_index, info.cpu_count);
-                                               CRIT_ERR("attempting to use more CPUs then you have!");
-                                       }
-                                       spaced_print(p, p_max_size, "%*d", 4, "cpu", pad_percents,
-                                               round_to_int(cur->cpu_usage[obj->data.cpu_index] *
-                                               100.0));
-                               }
-                               OBJ(cpubar) {
-                                       new_bar(p, obj->a,
-                                                       obj->b,
-                                                       round_to_int(cur->cpu_usage[obj->data.cpu_index] * 255.0));
-                               }
-                               OBJ(cpugraph) {
-                                       new_graph(p, obj->a,
-                                                       obj->b, obj->c, obj->d,
-                                                       (unsigned int) round_to_int(cur->cpu_usage[obj->data.cpu_index] *
-                                                                                   100), 100, 1);
-                               }
-                               OBJ(color) {
-                                       new_fg(p, obj->data.l);
-                               }
-                               OBJ(color0) {
-                                       new_fg(p, color0);
-                               }
-                               OBJ(color1) {
-                                       new_fg(p, color1);
-                               }
-                               OBJ(color2) {
-                                       new_fg(p, color2);
-                               }
-                               OBJ(color3) {
-                                       new_fg(p, color3);
-                               }
-                               OBJ(color4) {
-                                       new_fg(p, color4);
-                               }
-                               OBJ(color5) {
-                                       new_fg(p, color5);
-                               }
-                               OBJ(color6) {
-                                       new_fg(p, color6);
-                               }
-                               OBJ(color7) {
-                                       new_fg(p, color7);
-                               }
-                               OBJ(color8) {
-                                       new_fg(p, color8);
-                               }
-                               OBJ(color9) {
-                                       new_fg(p, color9);
+
+                       OBJ(buffers) {
+                               human_readable(cur->buffers * 1024, p, 255, "buffers");
+                       }
+                       OBJ(cached) {
+                               human_readable(cur->cached * 1024, p, 255, "buffers");
+                       }
+                       OBJ(cpu) {
+                               if (obj->data.cpu_index > info.cpu_count) {
+                                       printf("obj->data.cpu_index %i info.cpu_count %i",
+                                               obj->data.cpu_index, info.cpu_count);
+                                       CRIT_ERR("attempting to use more CPUs then you have!");
                                }
+                               spaced_print(p, p_max_size, "%*d", 4, "cpu", pad_percents,
+                                       round_to_int(cur->cpu_usage[obj->data.cpu_index] * 100.0));
+                       }
+                       OBJ(cpubar) {
+                               new_bar(p, obj->a, obj->b,
+                                       round_to_int(cur->cpu_usage[obj->data.cpu_index] * 255.0));
+                       }
+                       OBJ(cpugraph) {
+                               new_graph(p, obj->a, obj->b, obj->c, obj->d, (unsigned int)
+                                       round_to_int(cur->cpu_usage[obj->data.cpu_index] * 100),
+                                       100, 1);
+                       }
+                       OBJ(color) {
+                               new_fg(p, obj->data.l);
+                       }
+                       OBJ(color0) {
+                               new_fg(p, color0);
+                       }
+                       OBJ(color1) {
+                               new_fg(p, color1);
+                       }
+                       OBJ(color2) {
+                               new_fg(p, color2);
+                       }
+                       OBJ(color3) {
+                               new_fg(p, color3);
+                       }
+                       OBJ(color4) {
+                               new_fg(p, color4);
+                       }
+                       OBJ(color5) {
+                               new_fg(p, color5);
+                       }
+                       OBJ(color6) {
+                               new_fg(p, color6);
+                       }
+                       OBJ(color7) {
+                               new_fg(p, color7);
+                       }
+                       OBJ(color8) {
+                               new_fg(p, color8);
+                       }
+                       OBJ(color9) {
+                               new_fg(p, color9);
+                       }
 #if defined(__linux__)
-                               OBJ(i8k_version) {
-                                       snprintf(p, p_max_size, "%s", i8k.version);
-                               }
-                               OBJ(i8k_bios) {
-                                       snprintf(p, p_max_size, "%s", i8k.bios);
-                               }
-                               OBJ(i8k_serial) { 
-                                       snprintf(p, p_max_size, "%s", i8k.serial);
-                               }
-                               OBJ(i8k_cpu_temp) { 
-                                       snprintf(p, p_max_size, "%s", i8k.cpu_temp);
-                               }
-                               OBJ(i8k_cpu_tempf) { 
-                                       int cpu_temp;
-                                       sscanf(i8k.cpu_temp, "%d", &cpu_temp);
-                                       snprintf(p, p_max_size, "%.1f", cpu_temp*(9.0/5.0)+32.0);
-                               }
-                               OBJ(i8k_left_fan_status) { 
-                                       int left_fan_status;
-                                       sscanf(i8k.left_fan_status, "%d", &left_fan_status);
-                                       if(left_fan_status == 0) {
-                                               snprintf(p, p_max_size,"off");
-                                       } if(left_fan_status == 1) {
-                                               snprintf(p, p_max_size, "low");
-                                       }       if(left_fan_status == 2) {
-                                               snprintf(p, p_max_size, "high");
-                                       }
+                       OBJ(i8k_version) {
+                               snprintf(p, p_max_size, "%s", i8k.version);
+                       }
+                       OBJ(i8k_bios) {
+                               snprintf(p, p_max_size, "%s", i8k.bios);
+                       }
+                       OBJ(i8k_serial) {
+                               snprintf(p, p_max_size, "%s", i8k.serial);
+                       }
+                       OBJ(i8k_cpu_temp) {
+                               snprintf(p, p_max_size, "%s", i8k.cpu_temp);
+                       }
+                       OBJ(i8k_cpu_tempf) {
+                               int cpu_temp;
+
+                               sscanf(i8k.cpu_temp, "%d", &cpu_temp);
+                               snprintf(p, p_max_size, "%.1f", cpu_temp * (9.0 / 5.0) + 32.0);
+                       }
+                       OBJ(i8k_left_fan_status) {
+                               int left_fan_status;
 
+                               sscanf(i8k.left_fan_status, "%d", &left_fan_status);
+                               if (left_fan_status == 0) {
+                                       snprintf(p, p_max_size, "off");
                                }
-                               OBJ(i8k_right_fan_status) { 
-                                       int right_fan_status;
-                                       sscanf(i8k.right_fan_status, "%d", &right_fan_status);
-                                       if(right_fan_status == 0) {
-                                               snprintf(p, p_max_size,"off");
-                                       } if(right_fan_status == 1) {
-                                               snprintf(p, p_max_size, "low");
-                                       }       if(right_fan_status == 2) {
-                                               snprintf(p, p_max_size, "high");
-                                       }
+                               if (left_fan_status == 1) {
+                                       snprintf(p, p_max_size, "low");
                                }
-                               OBJ(i8k_left_fan_rpm) { 
-                                       snprintf(p, p_max_size, "%s", i8k.left_fan_rpm);
-                               }
-                               OBJ(i8k_right_fan_rpm) { 
-                                       snprintf(p, p_max_size, "%s", i8k.right_fan_rpm);
-                               }
-                               OBJ(i8k_ac_status) { 
-                                       int ac_status;
-                                       sscanf(i8k.ac_status, "%d", &ac_status);
-                                       if(ac_status == -1) {
-                                               snprintf(p, p_max_size,"disabled (read i8k docs)");
-                                       } if(ac_status == 0) {
-                                               snprintf(p, p_max_size, "off");
-                                       }       if(ac_status == 1) {
-                                               snprintf(p, p_max_size, "on");
-                                       }
+                               if (left_fan_status == 2) {
+                                       snprintf(p, p_max_size, "high");
                                }
-                               OBJ(i8k_buttons_status) {
-                                       snprintf(p, p_max_size, "%s", i8k.buttons_status); 
-
-                               }
-                                OBJ(ibm_fan) {
-                                    get_ibm_acpi_fan(p, p_max_size);
-                                }
-                               OBJ(ibm_temps) {
-                                    get_ibm_acpi_temps();
-                                    snprintf(p, p_max_size, "%d",
-                                             ibm_acpi.temps[obj->data.sensor]);
-                                }
-                                OBJ(ibm_volume) {
-                                    get_ibm_acpi_volume(p, p_max_size);
-                                }
-                                OBJ(ibm_brightness) {
-                                    get_ibm_acpi_brightness(p, p_max_size);
-                                }
-                                OBJ(pb_battery) {
-                                    get_powerbook_batt_info(p, p_max_size, obj->data.i);
-                                }
-#endif /* __linux__ */
+                       }
+                       OBJ(i8k_right_fan_status) {
+                               int right_fan_status;
 
-#ifdef __OpenBSD__
-                               OBJ(obsd_sensors_temp) {
-                                       obsd_sensors.device = sensor_device;
-                                       update_obsd_sensors();
-                                       snprintf(p, p_max_size, "%.1f",
-                                               obsd_sensors.temp[obsd_sensors.device][obj->data.sensor]);
+                               sscanf(i8k.right_fan_status, "%d", &right_fan_status);
+                               if (right_fan_status == 0) {
+                                       snprintf(p, p_max_size, "off");
                                }
-
-                               OBJ(obsd_sensors_fan) {
-                                       obsd_sensors.device = sensor_device;
-                                       update_obsd_sensors();
-                                       snprintf(p, p_max_size, "%d",
-                                               obsd_sensors.fan[obsd_sensors.device][obj->data.sensor]);
+                               if (right_fan_status == 1) {
+                                       snprintf(p, p_max_size, "low");
                                }
-
-                               OBJ(obsd_sensors_volt) {
-                                       obsd_sensors.device = sensor_device;
-                                       update_obsd_sensors();
-                                       snprintf(p, p_max_size, "%.2f",
-                                               obsd_sensors.volt[obsd_sensors.device][obj->data.sensor]);
+                               if (right_fan_status == 2) {
+                                       snprintf(p, p_max_size, "high");
                                }
+                       }
+                       OBJ(i8k_left_fan_rpm) {
+                               snprintf(p, p_max_size, "%s", i8k.left_fan_rpm);
+                       }
+                       OBJ(i8k_right_fan_rpm) {
+                               snprintf(p, p_max_size, "%s", i8k.right_fan_rpm);
+                       }
+                       OBJ(i8k_ac_status) {
+                               int ac_status;
 
-                               OBJ(obsd_vendor) {
-                                       get_obsd_vendor(p, p_max_size);
+                               sscanf(i8k.ac_status, "%d", &ac_status);
+                               if (ac_status == -1) {
+                                       snprintf(p, p_max_size, "disabled (read i8k docs)");
                                }
-
-                               OBJ(obsd_product) {
-                                       get_obsd_product(p, p_max_size);
+                               if (ac_status == 0) {
+                                       snprintf(p, p_max_size, "off");
                                }
+                               if (ac_status == 1) {
+                                       snprintf(p, p_max_size, "on");
+                               }
+                       }
+                       OBJ(i8k_buttons_status) {
+                               snprintf(p, p_max_size, "%s", i8k.buttons_status);
+                       }
+                       OBJ(ibm_fan) {
+                               get_ibm_acpi_fan(p, p_max_size);
+                       }
+                       OBJ(ibm_temps) {
+                               get_ibm_acpi_temps();
+                               snprintf(p, p_max_size, "%d", ibm_acpi.temps[obj->data.sensor]);
+                       }
+                       OBJ(ibm_volume) {
+                               get_ibm_acpi_volume(p, p_max_size);
+                       }
+                       OBJ(ibm_brightness) {
+                               get_ibm_acpi_brightness(p, p_max_size);
+                       }
+                       OBJ(pb_battery) {
+                               get_powerbook_batt_info(p, p_max_size, obj->data.i);
+                       }
+#endif /* __linux__ */
+
+#ifdef __OpenBSD__
+                       OBJ(obsd_sensors_temp) {
+                               obsd_sensors.device = sensor_device;
+                               update_obsd_sensors();
+                               snprintf(p, p_max_size, "%.1f",
+                                       obsd_sensors.temp[obsd_sensors.device][obj->data.sensor]);
+                       }
+                       OBJ(obsd_sensors_fan) {
+                               obsd_sensors.device = sensor_device;
+                               update_obsd_sensors();
+                               snprintf(p, p_max_size, "%d",
+                                       obsd_sensors.fan[obsd_sensors.device][obj->data.sensor]);
+                       }
+                       OBJ(obsd_sensors_volt) {
+                               obsd_sensors.device = sensor_device;
+                               update_obsd_sensors();
+                               snprintf(p, p_max_size, "%.2f",
+                                       obsd_sensors.volt[obsd_sensors.device][obj->data.sensor]);
+                       }
+                       OBJ(obsd_vendor) {
+                               get_obsd_vendor(p, p_max_size);
+                       }
+                       OBJ(obsd_product) {
+                               get_obsd_product(p, p_max_size);
+                       }
 #endif /* __OpenBSD__ */
 
 #ifdef X11
-                               OBJ(font) {
-                                       new_font(p, obj->data.s);
-                               }
+                       OBJ(font) {
+                               new_font(p, obj->data.s);
+                       }
 #endif
-                               /* TODO: move this correction from kB to kB/s elsewhere
-                                * (or get rid of it??) */
-                               OBJ(diskio) {
-                                       if (obj->data.diskio) {
-                                               human_readable((obj->data.diskio->current / update_interval) * 1024LL, p, p_max_size, "diskio");
-                                       } else {
-                                               human_readable(diskio_value * 1024LL, p, p_max_size, "diskio");
-                                       }
-                               }
-                               OBJ(diskio_write) {
-                                       if (obj->data.diskio) {
-                                               human_readable((obj->data.diskio->current_write / update_interval) * 1024LL, p, p_max_size,
-                                                               "diskio_write");
-                                       } else {
-                                               human_readable(diskio_write_value * 1024LL, p, p_max_size,
-                                                               "diskio_write");
-                                       }
-                               }
-                               OBJ(diskio_read) {
-                                       if (obj->data.diskio) {
-                                               human_readable((obj->data.diskio->current_read / update_interval) * 1024LL, p, p_max_size,
-                                                               "diskio_read");
-                                       } else {
-                                               human_readable(diskio_read_value * 1024LL, p, p_max_size,
-                                                               "diskio_read");
-                                       }
-                               }
-                               OBJ(diskiograph) {
-                                       if (obj->data.diskio) {
-                                               new_graph(p, obj->a, obj->b, obj->c, obj->d,
-                                                       obj->data.diskio->current, obj->e, 1);
-                                       } else {
-                                               new_graph(p, obj->a, obj->b, obj->c, obj->d,
-                                                       diskio_value, obj->e, 1);
-                                       }
-                               }
-                               OBJ(diskiograph_read) {
-                                       if (obj->data.diskio) {
-                                               new_graph(p, obj->a, obj->b, obj->c, obj->d,
-                                                       obj->data.diskio->current_read, obj->e, 1);
-                                       } else {
-                                               new_graph(p, obj->a, obj->b, obj->c, obj->d,
-                                                       diskio_read_value, obj->e, 1);
-                                       }
+                       /* TODO: move this correction from kB to kB/s elsewhere
+                        * (or get rid of it??) */
+                       OBJ(diskio) {
+                               if (obj->data.diskio) {
+                                       human_readable(
+                                               (obj->data.diskio->current / update_interval) * 1024LL,
+                                               p, p_max_size, "diskio");
+                               } else {
+                                       human_readable(diskio_value * 1024LL, p, p_max_size,
+                                               "diskio");
                                }
-                               OBJ(diskiograph_write) {
-                                       if (obj->data.diskio) {
-                                               new_graph(p, obj->a, obj->b, obj->c, obj->d,
-                                                       obj->data.diskio->current_write, obj->e, 1);
-                                       } else {
-                                               new_graph(p, obj->a, obj->b, obj->c, obj->d,
-                                                       diskio_write_value, obj->e, 1);
-                                       }
+                       }
+                       OBJ(diskio_write) {
+                               if (obj->data.diskio) {
+                                       human_readable((obj->data.diskio->current_write / update_interval) * 1024LL, p, p_max_size,
+                                               "diskio_write");
+                               } else {
+                                       human_readable(diskio_write_value * 1024LL, p, p_max_size,
+                                               "diskio_write");
                                }
-                               OBJ(downspeed) {
-                                       spaced_print(p, p_max_size, "%d", 6, "downspeed",
-                                               round_to_int(obj->data.net->recv_speed / 1024));
+                       }
+                       OBJ(diskio_read) {
+                               if (obj->data.diskio) {
+                                       human_readable((obj->data.diskio->current_read / update_interval) * 1024LL, p, p_max_size,
+                                               "diskio_read");
+                               } else {
+                                       human_readable(diskio_read_value * 1024LL, p, p_max_size,
+                                               "diskio_read");
                                }
-                               OBJ(downspeedf) {
-                                       spaced_print(p, p_max_size, "%.1f", 8, "downspeedf",
-                                               obj->data.net->recv_speed / 1024.0);
+                       }
+                       OBJ(diskiograph) {
+                               if (obj->data.diskio) {
+                                       new_graph(p, obj->a, obj->b, obj->c, obj->d,
+                                               obj->data.diskio->current, obj->e, 1);
+                               } else {
+                                       new_graph(p, obj->a, obj->b, obj->c, obj->d, diskio_value,
+                                               obj->e, 1);
                                }
-                               OBJ(downspeedgraph) {
+                       }
+                       OBJ(diskiograph_read) {
+                               if (obj->data.diskio) {
+                                       new_graph(p, obj->a, obj->b, obj->c, obj->d,
+                                               obj->data.diskio->current_read, obj->e, 1);
+                               } else {
                                        new_graph(p, obj->a, obj->b, obj->c, obj->d,
-                                               (obj->data.net->recv_speed / 1024.0), obj->e, 1);
+                                               diskio_read_value, obj->e, 1);
                                }
-                               OBJ(else) {
-                                       if (!if_jumped) {
-                                               i = obj->data.ifblock.pos - 1;
-                                       } else {
-                                               if_jumped = 0;
-                                       }
+                       }
+                       OBJ(diskiograph_write) {
+                               if (obj->data.diskio) {
+                                       new_graph(p, obj->a, obj->b, obj->c, obj->d,
+                                               obj->data.diskio->current_write, obj->e, 1);
+                               } else {
+                                       new_graph(p, obj->a, obj->b, obj->c, obj->d,
+                                               diskio_write_value, obj->e, 1);
                                }
-                               OBJ(endif) {
+                       }
+                       OBJ(downspeed) {
+                               spaced_print(p, p_max_size, "%d", 6, "downspeed",
+                                       round_to_int(obj->data.net->recv_speed / 1024));
+                       }
+                       OBJ(downspeedf) {
+                               spaced_print(p, p_max_size, "%.1f", 8, "downspeedf",
+                                       obj->data.net->recv_speed / 1024.0);
+                       }
+                       OBJ(downspeedgraph) {
+                               new_graph(p, obj->a, obj->b, obj->c, obj->d,
+                                       obj->data.net->recv_speed / 1024.0, obj->e, 1);
+                       }
+                       OBJ(else) {
+                               if (!if_jumped) {
+                                       i = obj->data.ifblock.pos - 1;
+                               } else {
                                        if_jumped = 0;
                                }
+                       }
+                       OBJ(endif) {
+                               if_jumped = 0;
+                       }
 #ifdef HAVE_POPEN
-                               OBJ(addr) {
-                                       snprintf(p, p_max_size, "%u.%u.%u.%u",
-                                                       obj->data.net->addr.
-                                                       sa_data[2] & 255,
-                                                       obj->data.net->addr.
-                                                       sa_data[3] & 255,
-                                                       obj->data.net->addr.
-                                                       sa_data[4] & 255,
-                                                       obj->data.net->addr.
-                                                       sa_data[5] & 255);
+                       OBJ(addr) {
+                               snprintf(p, p_max_size, "%u.%u.%u.%u",
+                                       obj->data.net->addr.sa_data[2] & 255,
+                                       obj->data.net->addr.sa_data[3] & 255,
+                                       obj->data.net->addr.sa_data[4] & 255,
+                                       obj->data.net->addr.sa_data[5] & 255);
+                       }
 
-                               }
 #if defined(IMLIB2) && defined(X11)
-                               OBJ(image) {
-                                       if (obj->a < 1) {
-                                               obj->a++;
-                                       } else {
-                                               Imlib_Image image, buffer;
-                                               image = imlib_load_image(obj->data.s);
+                       OBJ(image) {
+                               if (obj->a < 1) {
+                                       obj->a++;
+                               } else {
+                                       Imlib_Image image, buffer;
+
+                                       image = imlib_load_image(obj->data.s);
+                                       imlib_context_set_image(image);
+                                       if (image) {
+                                               int w, h;
+
+                                               w = imlib_image_get_width();
+                                               h = imlib_image_get_height();
+                                               buffer = imlib_create_image(w, h);
+                                               imlib_context_set_display(display);
+                                               imlib_context_set_drawable(window.drawable);
+                                               imlib_context_set_colormap(DefaultColormap(display,
+                                                       screen));
+                                               imlib_context_set_visual(DefaultVisual(display,
+                                                       screen));
+                                               imlib_context_set_image(buffer);
+                                               imlib_blend_image_onto_image(image, 0, 0, 0, w, h,
+                                                       text_start_x, text_start_y, w, h);
+                                               imlib_render_image_on_drawable(text_start_x,
+                                                       text_start_y);
+                                               imlib_free_image();
                                                imlib_context_set_image(image);
-                                               if (image) {
-                                                       int w, h;
-                                                       w = imlib_image_get_width();
-                                                       h = imlib_image_get_height();
-                                                       buffer = imlib_create_image(w, h);
-                                                       imlib_context_set_display(display);
-                                                       imlib_context_set_drawable(window.drawable);
-                                                       imlib_context_set_colormap(DefaultColormap(display, screen));
-                                                       imlib_context_set_visual(DefaultVisual(display, screen));
-                                                       imlib_context_set_image(buffer);
-                                                       imlib_blend_image_onto_image(image, 0, 0, 0, w, h, text_start_x, text_start_y, w, h);
-                                                       imlib_render_image_on_drawable(text_start_x, text_start_y);
-                                                       imlib_free_image();
-                                                       imlib_context_set_image(image);
-                                                       imlib_free_image();
-                                               }
+                                               imlib_free_image();
                                        }
                                }
+                       }
 #endif /* IMLIB2 */
-                               OBJ(exec) {
-                                       FILE *fp = popen(obj->data.s, "r");
-                                       int length = fread(p, 1, p_max_size, fp);
-                                       (void) pclose(fp);
-
-                                       /*output[length] = '\0';
-                                         if (length > 0 && output[length - 1] == '\n') {
-                                         output[length - 1] = '\0';
-                                         }*/
-                                       p[length] = '\0';
-                                       if (length > 0 && p[length - 1] == '\n') {
-                                               p[length - 1] = '\0';
+
+                       OBJ(exec) {
+                               FILE *fp = popen(obj->data.s, "r");
+                               int length = fread(p, 1, p_max_size, fp);
+
+                               pclose(fp);
+                               /* output[length] = '\0';
+                               if (length > 0 && output[length - 1] == '\n') {
+                                       output[length - 1] = '\0';
+                               } */
+                               p[length] = '\0';
+                               if (length > 0 && p[length - 1] == '\n') {
+                                       p[length - 1] = '\0';
+                               }
+                               // parse_conky_vars(output, p, cur);
+                       }
+                       OBJ(execbar) {
+                               char *p2 = p;
+                               FILE *fp = popen(obj->data.s, "r");
+                               int n2 = fread(p, 1, p_max_size, fp);
+
+                               pclose(fp);
+                               p[n2] = '\0';
+                               if (n2 && p[n2 - 1] == '\n') {
+                                       p[n2 - 1] = '\0';
+                               }
+
+                               while (*p2) {
+                                       if (*p2 == '\001') {
+                                               *p2 = ' ';
+                                       }
+                                       p2++;
+                               }
+                               double barnum;
+
+                               if (sscanf(p, "%lf", &barnum) == 0) {
+                                       ERR("reading execbar value failed (perhaps it's not the "
+                                               "correct format?)");
+                               }
+                               if (barnum > 100 || barnum < 0) {
+                                       ERR("your execbar value is not between 0 and 100, "
+                                               "therefore it will be ignored");
+                               } else {
+                                       barnum = barnum / 100.0;
+                                       new_bar(p, 0, 4, (int) (barnum * 255.0));
+                               }
+                       }
+                       OBJ(execgraph) {
+                               char *p2 = p;
+                               FILE *fp = popen(obj->data.s, "r");
+                               int n2 = fread(p, 1, p_max_size, fp);
+
+                               pclose(fp);
+                               p[n2] = '\0';
+                               if (n2 && p[n2 - 1] == '\n') {
+                                       p[n2 - 1] = '\0';
+                               }
+                               while (*p2) {
+                                       if (*p2 == '\001') {
+                                               *p2 = ' ';
                                        }
+                                       p2++;
+                               }
+                               double barnum;
 
-                                       //parse_conky_vars(output, p, cur);
+                               if (sscanf(p, "%lf", &barnum) == 0) {
+                                       ERR("reading execgraph value failed (perhaps it's not the "
+                                               "correct format?)");
+                               }
+                               if (barnum > 100 || barnum < 0) {
+                                       ERR("your execgraph value is not between 0 and 100, "
+                                               "therefore it will be ignored");
+                               } else {
+                                       new_graph(p, 0, 25, obj->c, obj->d, (int) (barnum),
+                                               obj->e, 1);
                                }
-                               OBJ(execbar) {
+                       }
+                       OBJ(execibar) {
+                               if (current_update_time - obj->data.execi.last_update
+                                               < obj->data.execi.interval) {
+                                       new_bar(p, 0, 4, (int) obj->f);
+                               } else {
                                        char *p2 = p;
-                                       FILE *fp = popen(obj->data.s, "r");
+                                       FILE *fp = popen(obj->data.execi.cmd, "r");
                                        int n2 = fread(p, 1, p_max_size, fp);
-                                       (void) pclose(fp);
 
+                                       pclose(fp);
                                        p[n2] = '\0';
-                                       if (n2 && p[n2 - 1] == '\n')
+                                       if (n2 && p[n2 - 1] == '\n') {
                                                p[n2 - 1] = '\0';
+                                       }
 
                                        while (*p2) {
-                                               if (*p2 == '\001')
+                                               if (*p2 == '\001') {
                                                        *p2 = ' ';
+                                               }
                                                p2++;
                                        }
-                                       double barnum;
-                                       if (sscanf(p, "%lf", &barnum) == 0) {
-                                               ERR("reading execbar value failed (perhaps it's not the correct format?)");
+                                       float barnum;
+
+                                       if (sscanf(p, "%f", &barnum) == 0) {
+                                               ERR("reading execibar value failed (perhaps it's not "
+                                                       "the correct format?)");
                                        }
                                        if (barnum > 100 || barnum < 0) {
-                                               ERR("your execbar value is not between 0 and 100, therefore it will be ignored");
+                                               ERR("your execibar value is not between 0 and 100, "
+                                                       "therefore it will be ignored");
                                        } else {
-                                               barnum = barnum / 100.0;
-                                               new_bar(p, 0, 4, (int) (barnum * 255.0));
+                                               obj->f = 255 * barnum / 100.0;
+                                               new_bar(p, 0, 4, (int) obj->f);
                                        }
-
+                                       obj->data.execi.last_update = current_update_time;
                                }
-                               OBJ(execgraph) {
+                       }
+                       OBJ(execigraph) {
+                               if (current_update_time - obj->data.execi.last_update
+                                               < obj->data.execi.interval) {
+                                       new_graph(p, 0, 25, obj->c, obj->d, (int) (obj->f), 100, 0);
+                               } else {
                                        char *p2 = p;
-                                       FILE *fp = popen(obj->data.s, "r");
+                                       FILE *fp = popen(obj->data.execi.cmd, "r");
                                        int n2 = fread(p, 1, p_max_size, fp);
-                                       (void) pclose(fp);
 
+                                       pclose(fp);
                                        p[n2] = '\0';
-                                       if (n2 && p[n2 - 1] == '\n')
+                                       if (n2 && p[n2 - 1] == '\n') {
                                                p[n2 - 1] = '\0';
+                                       }
 
                                        while (*p2) {
-                                               if (*p2 == '\001')
+                                               if (*p2 == '\001') {
                                                        *p2 = ' ';
+                                               }
                                                p2++;
                                        }
-                                       double barnum;
-                                       if (sscanf(p, "%lf", &barnum) == 0) {
-                                               ERR("reading execgraph value failed (perhaps it's not the correct format?)");
+                                       float barnum;
+
+                                       if (sscanf(p, "%f", &barnum) == 0) {
+                                               ERR("reading execigraph value failed (perhaps it's not "
+                                                       "the correct format?)");
                                        }
                                        if (barnum > 100 || barnum < 0) {
-                                               ERR("your execgraph value is not between 0 and 100, therefore it will be ignored");
+                                               ERR("your execigraph value is not between 0 and 100, "
+                                                       "therefore it will be ignored");
                                        } else {
-                                               new_graph(p, 0, 25, obj->c, obj->d, (int) (barnum), obj->e, 1);
+                                               obj->f = barnum;
+                                               new_graph(p, 0, 25, obj->c, obj->d, (int) (obj->f),
+                                                       100, 1);
                                        }
+                                       obj->data.execi.last_update = current_update_time;
+                               }
+                       }
+                       OBJ(execi) {
+                               if (current_update_time - obj->data.execi.last_update
+                                               < obj->data.execi.interval
+                                               || obj->data.execi.interval == 0) {
+                                       snprintf(p, p_max_size, "%s", obj->data.execi.buffer);
+                               } else {
+                                       char *output = obj->data.execi.buffer;
+                                       FILE *fp = popen(obj->data.execi.cmd, "r");
 
+                                       // int length = fread(output, 1, text_buffer_size, fp);
+                                       int length = fread(output, 1, text_buffer_size, fp);
+
+                                       pclose(fp);
+                                       output[length] = '\0';
+                                       if (length > 0 && output[length - 1] == '\n') {
+                                               output[length - 1] = '\0';
+                                       }
+                                       obj->data.execi.last_update = current_update_time;
+                                       snprintf(p, p_max_size, "%s", output);
+                               }
+                               // parse_conky_vars(output, p, cur);
+                       }
+                       OBJ(texeci) {
+                               if (!obj->data.texeci.p_timed_thread) {
+                                       obj->data.texeci.p_timed_thread =
+                                               timed_thread_create((void *) threaded_exec,
+                                               (void *) obj, obj->data.texeci.interval * 1000000);
+                                       if (!obj->data.texeci.p_timed_thread) {
+                                               ERR("Error creating texeci timed thread");
+                                       }
+                                       timed_thread_register(obj->data.texeci.p_timed_thread,
+                                               &obj->data.texeci.p_timed_thread);
+                                       if (timed_thread_run(obj->data.texeci.p_timed_thread)) {
+                                               ERR("Error running texeci timed thread");
+                                       }
                                }
-                               OBJ(execibar) {
-                                       if (current_update_time - obj->data.execi.last_update < obj->data.execi.interval) {
-                                               new_bar(p, 0, 4, (int) obj->f);
-                                       } else {
-                                               char *p2 = p;
-                                               FILE *fp = popen(obj->data.execi.cmd, "r");
-                                               int n2 = fread(p, 1, p_max_size, fp);
-                                               (void) pclose(fp);
-                                               p[n2] = '\0';
-                                               if (n2 && p[n2 - 1] == '\n')
-                                                       p[n2 - 1] = '\0';
-
-                                               while (*p2) {
-                                                       if (*p2 == '\001')
-                                                               *p2 = ' ';
-                                                       p2++;
-                                               }
-                                               float barnum;
-                                               if (sscanf(p, "%f", &barnum) == 0) {
-                                                       ERR("reading execibar value failed (perhaps it's not the correct format?)");
+                               timed_thread_lock(obj->data.texeci.p_timed_thread);
+                               snprintf(p, p_max_size, "%s", obj->data.texeci.buffer);
+                               timed_thread_unlock(obj->data.texeci.p_timed_thread);
+                       }
+#endif /* HAVE_POPEN */
+                       OBJ(imap_unseen) {
+                               if (obj->global_mode && info.mail) {
+                                       // this means we use info
+                                       if (!info.mail->p_timed_thread) {
+                                               info.mail->p_timed_thread =
+                                                       timed_thread_create((void *) imap_thread,
+                                                       (void *) info.mail, info.mail->interval * 1000000);
+                                               if (!info.mail->p_timed_thread) {
+                                                       ERR("Error creating imap timed thread");
                                                }
-                                               if (barnum > 100 || barnum < 0) {
-                                                       ERR("your execibar value is not between 0 and 100, therefore it will be ignored");
-                                               } else {
-                                                       obj->f = 255 * barnum / 100.0;
-                                                       new_bar(p, 0, 4, (int) obj->f);
+                                               timed_thread_register(info.mail->p_timed_thread,
+                                                       &info.mail->p_timed_thread);
+                                               if (timed_thread_run(info.mail->p_timed_thread)) {
+                                                       ERR("Error running imap timed thread");
                                                }
-                                               obj->data.execi.last_update =
-                                                       current_update_time;
                                        }
-                               }
-                               OBJ(execigraph) {
-                                       if (current_update_time - obj->data.execi.last_update < obj->data.execi.interval) {
-                                               new_graph(p, 0, 25, obj->c, obj->d, (int) (obj->f), 100, 0);
-                                       } else {
-                                               char *p2 = p;
-                                               FILE *fp = popen(obj->data.execi.cmd, "r");
-                                               int n2 = fread(p, 1, p_max_size, fp);
-                                               (void) pclose(fp);
-                                               p[n2] = '\0';
-                                               if (n2 && p[n2 - 1] == '\n')
-                                                       p[n2 - 1] = '\0';
-
-                                               while (*p2) {
-                                                       if (*p2 == '\001')
-                                                               *p2 = ' ';
-                                                       p2++;
+                                       timed_thread_lock(info.mail->p_timed_thread);
+                                       snprintf(p, p_max_size, "%lu", info.mail->unseen);
+                                       timed_thread_unlock(info.mail->p_timed_thread);
+                               } else if (obj->data.mail) {
+                                       // this means we use obj
+                                       if (!obj->data.mail->p_timed_thread) {
+                                               obj->data.mail->p_timed_thread =
+                                                       timed_thread_create((void *) imap_thread,
+                                                       (void *) obj->data.mail,
+                                                       obj->data.mail->interval * 1000000);
+                                               if (!obj->data.mail->p_timed_thread) {
+                                                       ERR("Error creating imap timed thread");
                                                }
-                                               float barnum;
-                                               if (sscanf(p, "%f", &barnum) == 0) {
-                                                       ERR("reading execigraph value failed (perhaps it's not the correct format?)");
-                                               }
-                                               if (barnum > 100 || barnum < 0) {
-                                                       ERR("your execigraph value is not between 0 and 100, therefore it will be ignored");
-                                               } else {
-                                                       obj->f = barnum;
-                                                       new_graph(p, 0, 25, obj->c, obj->d, (int) (obj->f), 100, 1);
+                                               timed_thread_register(obj->data.mail->p_timed_thread,
+                                                       &obj->data.mail->p_timed_thread);
+                                               if (timed_thread_run(obj->data.mail->p_timed_thread)) {
+                                                       ERR("Error running imap timed thread");
                                                }
-                                               obj->data.execi.last_update = current_update_time;
-
                                        }
-
-                               }
-                               OBJ(execi) {
-                                       if (current_update_time - obj->data.execi.last_update < obj->data.execi.interval || obj->data.execi.interval == 0) {
-                                               snprintf(p, p_max_size, "%s", obj->data.execi.buffer);
-                                       } else {
-                                               char *output = obj->data.execi.buffer;
-                                               FILE *fp = popen(obj->data.execi.cmd, "r");
-                                               //int length = fread(output, 1, text_buffer_size, fp);
-                                               int length = fread(output, 1, text_buffer_size, fp);
-                                               (void) pclose(fp);
-
-                                               output[length] = '\0';
-                                               if (length > 0 && output[length - 1] == '\n') {
-                                                       output[length - 1] = '\0';
+                                       timed_thread_lock(obj->data.mail->p_timed_thread);
+                                       snprintf(p, p_max_size, "%lu", obj->data.mail->unseen);
+                                       timed_thread_unlock(obj->data.mail->p_timed_thread);
+                               } else if (!obj->a) {
+                                       // something is wrong, warn once then stop
+                                       ERR("Theres a problem with your imap_unseen settings.  "
+                                               "Check that the global IMAP settings are defined "
+                                               "properly (line %li).", obj->line);
+                                       obj->a++;
+                               }
+                       }
+                       OBJ(imap_messages) {
+                               if (obj->global_mode && info.mail) {
+                                       // this means we use info
+                                       if (!info.mail->p_timed_thread) {
+                                               info.mail->p_timed_thread =
+                                                       timed_thread_create((void *) imap_thread,
+                                                       (void *) info.mail, info.mail->interval * 1000000);
+                                               if (!info.mail->p_timed_thread) {
+                                                       ERR("Error creating imap timed thread");
+                                               }
+                                               timed_thread_register(info.mail->p_timed_thread,
+                                                       &info.mail->p_timed_thread);
+                                               if (timed_thread_run(info.mail->p_timed_thread)) {
+                                                       ERR("Error running imap timed thread");
                                                }
-                                               obj->data.execi.last_update = current_update_time;
-                                               snprintf(p, p_max_size, "%s", output);
                                        }
-                                       //parse_conky_vars(output, p, cur);
-                               }
-                               OBJ(texeci) {
-                                       if (!obj->data.texeci.p_timed_thread)
-                                       {
-                                           obj->data.texeci.p_timed_thread=
-                                             timed_thread_create ((void*)threaded_exec, (void*) obj, obj->data.texeci.interval * 1000000);
-                                           if (!obj->data.texeci.p_timed_thread)
-                                                   ERR("Error creating texeci timed thread");
-                                           timed_thread_register (obj->data.texeci.p_timed_thread, &obj->data.texeci.p_timed_thread);
-              if (timed_thread_run (obj->data.texeci.p_timed_thread))
-                ERR("Error running texeci timed thread");
+                                       timed_thread_lock(info.mail->p_timed_thread);
+                                       snprintf(p, p_max_size, "%lu", info.mail->messages);
+                                       timed_thread_unlock(info.mail->p_timed_thread);
+                               } else if (obj->data.mail) {
+                                       // this means we use obj
+                                       if (!obj->data.mail->p_timed_thread) {
+                                               obj->data.mail->p_timed_thread =
+                                                       timed_thread_create((void *) imap_thread,
+                                                       (void *) obj->data.mail,
+                                                       obj->data.mail->interval * 1000000);
+                                               if (!obj->data.mail->p_timed_thread) {
+                                                       ERR("Error creating imap timed thread");
+                                               }
+                                               timed_thread_register(obj->data.mail->p_timed_thread,
+                                                       &obj->data.mail->p_timed_thread);
+                                               if (timed_thread_run(obj->data.mail->p_timed_thread)) {
+                                                       ERR("Error runninging imap timed thread");
+                                               }
                                        }
-                                       timed_thread_lock (obj->data.texeci.p_timed_thread);
-                                       snprintf(p, p_max_size, "%s", obj->data.texeci.buffer);
-                                       timed_thread_unlock (obj->data.texeci.p_timed_thread);
-                               }
-#endif /* HAVE_POPEN */
-                               OBJ(imap_unseen) {
-                                       if (obj->global_mode && info.mail) { // this means we use info
-                                               if (!info.mail->p_timed_thread)
-                                               {
-                                                   info.mail->p_timed_thread = 
-                                                     timed_thread_create ((void*)imap_thread, (void*)info.mail, info.mail->interval * 1000000);
-                                                   if (!info.mail->p_timed_thread)
-                                                           ERR("Error creating imap timed thread");
-                                                   timed_thread_register (info.mail->p_timed_thread, &info.mail->p_timed_thread);
-                if (timed_thread_run (info.mail->p_timed_thread))
-                  ERR("Error running imap timed thread");
+                                       timed_thread_lock(obj->data.mail->p_timed_thread);
+                                       snprintf(p, p_max_size, "%lu", obj->data.mail->messages);
+                                       timed_thread_lock(obj->data.mail->p_timed_thread);
+                               } else if (!obj->a) {
+                                       // something is wrong, warn once then stop
+                                       ERR("Theres a problem with your imap_messages settings.  "
+                                               "Check that the global IMAP settings are defined "
+                                               "properly (line %li).", obj->line);
+                                       obj->a++;
+                               }
+                       }
+                       OBJ(pop3_unseen) {
+                               if (obj->global_mode && info.mail) {
+                                       // this means we use info
+                                       if (!info.mail->p_timed_thread) {
+                                               info.mail->p_timed_thread =
+                                                       timed_thread_create((void *) pop3_thread,
+                                                       (void *) info.mail, info.mail->interval * 1000000);
+                                               if (!info.mail->p_timed_thread) {
+                                                       ERR("Error creating pop3 timed thread");
                                                }
-                                               timed_thread_lock (info.mail->p_timed_thread);
-                                               snprintf(p, p_max_size, "%lu", info.mail->unseen);
-                                               timed_thread_unlock (info.mail->p_timed_thread);
-                                       } else if (obj->data.mail) { // this means we use obj
-                                               if (!obj->data.mail->p_timed_thread)
-                                               {
-                                                   obj->data.mail->p_timed_thread = 
-                                                     timed_thread_create ((void*)imap_thread, (void*)obj->data.mail, 
-                                       obj->data.mail->interval * 1000000);
-                                                   if (!obj->data.mail->p_timed_thread)
-                                                           ERR("Error creating imap timed thread");
-                                                   timed_thread_register (obj->data.mail->p_timed_thread, &obj->data.mail->p_timed_thread);
-                if (timed_thread_run (obj->data.mail->p_timed_thread))
-                  ERR("Error running imap timed thread");
+                                               timed_thread_register(info.mail->p_timed_thread,
+                                                       &info.mail->p_timed_thread);
+                                               if (timed_thread_run(info.mail->p_timed_thread)) {
+                                                       ERR("Error running pop3 timed thread");
                                                }
-                                               timed_thread_lock (obj->data.mail->p_timed_thread);
-                                               snprintf(p, p_max_size, "%lu", obj->data.mail->unseen);
-                                               timed_thread_unlock (obj->data.mail->p_timed_thread);
-                                       } else if (!obj->a) { // something is wrong, warn once then stop
-                                               ERR("Theres a problem with your imap_unseen settings.  Check that the global IMAP settings are defined properly (line %li).", obj->line);
-                                                       obj->a++;
                                        }
-                               }
-                               OBJ(imap_messages) {
-                                       if (obj->global_mode && info.mail) { // this means we use info
-                                               if (!info.mail->p_timed_thread)
-                                               {
-                                                   info.mail->p_timed_thread =
-                  timed_thread_create ((void*)imap_thread, (void*)info.mail, info.mail->interval * 1000000);
-                if (!info.mail->p_timed_thread)
-                  ERR("Error creating imap timed thread");
-                timed_thread_register (info.mail->p_timed_thread, &info.mail->p_timed_thread);
-                if (timed_thread_run (info.mail->p_timed_thread))
-                  ERR("Error running imap timed thread");
+                                       timed_thread_lock(info.mail->p_timed_thread);
+                                       snprintf(p, p_max_size, "%lu", info.mail->unseen);
+                                       timed_thread_unlock(info.mail->p_timed_thread);
+                               } else if (obj->data.mail) {
+                                       // this means we use obj
+                                       if (!obj->data.mail->p_timed_thread) {
+                                               obj->data.mail->p_timed_thread =
+                                                       timed_thread_create((void *) pop3_thread,
+                                                       (void *) obj->data.mail,
+                                                       obj->data.mail->interval * 1000000);
+                                               if (!obj->data.mail->p_timed_thread) {
+                                                       ERR("Error creating pop3 timed thread");
+                                               }
+                                               timed_thread_register(obj->data.mail->p_timed_thread,
+                                                       &obj->data.mail->p_timed_thread);
+                                               if (timed_thread_run(obj->data.mail->p_timed_thread)) {
+                                                       ERR("Error running pop3 timed thread");
                                                }
-                                               timed_thread_lock (info.mail->p_timed_thread);
-                                               snprintf(p, p_max_size, "%lu", info.mail->messages);
-                                               timed_thread_unlock (info.mail->p_timed_thread);
-                                       } else if (obj->data.mail) { // this means we use obj
-                                               if (!obj->data.mail->p_timed_thread)
-            {
-              obj->data.mail->p_timed_thread =
-                timed_thread_create ((void*)imap_thread, (void*)obj->data.mail, 
-                                     obj->data.mail->interval * 1000000);
-              if (!obj->data.mail->p_timed_thread)
-                ERR("Error creating imap timed thread");
-              timed_thread_register (obj->data.mail->p_timed_thread, &obj->data.mail->p_timed_thread);
-              if (timed_thread_run (obj->data.mail->p_timed_thread))
-                ERR("Error runninging imap timed thread");
-            }
-                                               timed_thread_lock (obj->data.mail->p_timed_thread);
-                                               snprintf(p, p_max_size, "%lu", obj->data.mail->messages);
-                                               timed_thread_lock (obj->data.mail->p_timed_thread);
-                                       } else if (!obj->a) { // something is wrong, warn once then stop
-                                               ERR("Theres a problem with your imap_messages settings.  Check that the global IMAP settings are defined properly (line %li).", obj->line);
-                                                       obj->a++;
                                        }
-                               }
-                               OBJ(pop3_unseen) {
-                                       if (obj->global_mode && info.mail) { // this means we use info
-                                               if (!info.mail->p_timed_thread)
-                                               {
-                                                   info.mail->p_timed_thread = 
-                                                   timed_thread_create ((void*)pop3_thread, (void*)info.mail, info.mail->interval * 1000000);
-                                                   if (!info.mail->p_timed_thread)
-                                                           ERR("Error creating pop3 timed thread");
-                                                   timed_thread_register (info.mail->p_timed_thread, &info.mail->p_timed_thread);
-                if (timed_thread_run (info.mail->p_timed_thread))
-                  ERR("Error running pop3 timed thread");
+                                       timed_thread_lock(obj->data.mail->p_timed_thread);
+                                       snprintf(p, p_max_size, "%lu", obj->data.mail->unseen);
+                                       timed_thread_unlock(obj->data.mail->p_timed_thread);
+                               } else if (!obj->a) {
+                                       // something is wrong, warn once then stop
+                                       ERR("Theres a problem with your pop3_unseen settings.  "
+                                               "Check that the global POP3 settings are defined "
+                                               "properly (line %li).", obj->line);
+                                       obj->a++;
+                               }
+                       }
+                       OBJ(pop3_used) {
+                               if (obj->global_mode && info.mail) {
+                                       // this means we use info
+                                       if (!info.mail->p_timed_thread) {
+                                               info.mail->p_timed_thread =
+                                                       timed_thread_create((void *) pop3_thread,
+                                                       (void *) info.mail, info.mail->interval * 1000000);
+                                               if (!info.mail->p_timed_thread) {
+                                                       ERR("Error creating pop3 timed thread");
                                                }
-                                               timed_thread_lock (info.mail->p_timed_thread);
-                                               snprintf(p, p_max_size, "%lu", info.mail->unseen);
-                                               timed_thread_unlock (info.mail->p_timed_thread);
-                                       } else if (obj->data.mail) { // this means we use obj
-                                               if (!obj->data.mail->p_timed_thread)
-                                               {
-                                                   obj->data.mail->p_timed_thread = 
-                                                   timed_thread_create ((void*)pop3_thread, (void*)obj->data.mail,
-                                                                                          obj->data.mail->interval * 1000000);
-                                                   if (!obj->data.mail->p_timed_thread)
-                                                           ERR("Error creating pop3 timed thread");
-                                                   timed_thread_register (obj->data.mail->p_timed_thread, &obj->data.mail->p_timed_thread);
-                if (timed_thread_run (obj->data.mail->p_timed_thread))
-                  ERR("Error running pop3 timed thread");
+                                               timed_thread_register(info.mail->p_timed_thread,
+                                                       &info.mail->p_timed_thread);
+                                               if (timed_thread_run(info.mail->p_timed_thread)) {
+                                                       ERR("Error running pop3 timed thread");
                                                }
-                                               timed_thread_lock (obj->data.mail->p_timed_thread);
-                                               snprintf(p, p_max_size, "%lu", obj->data.mail->unseen);
-                                               timed_thread_unlock (obj->data.mail->p_timed_thread);
-                                       } else if (!obj->a) { // something is wrong, warn once then stop
-                                               ERR("Theres a problem with your pop3_unseen settings.  Check that the global POP3 settings are defined properly (line %li).", obj->line);
-                                                       obj->a++;
                                        }
-                               }
-                               OBJ(pop3_used) {
-                                       if (obj->global_mode && info.mail) { // this means we use info
-                                               if (!info.mail->p_timed_thread)
-                                               {
-                                                   info.mail->p_timed_thread = 
-                                                     timed_thread_create ((void*)pop3_thread, (void*)info.mail, info.mail->interval * 1000000);
-                                                   if (!info.mail->p_timed_thread)
-                                                           ERR("Error creating pop3 timed thread");
-                                                   timed_thread_register (info.mail->p_timed_thread, &info.mail->p_timed_thread);
-                if (timed_thread_run (info.mail->p_timed_thread))
-                  ERR("Error running pop3 timed thread");
+                                       timed_thread_lock(info.mail->p_timed_thread);
+                                       snprintf(p, p_max_size, "%.1f",
+                                               info.mail->used / 1024.0 / 1024.0);
+                                       timed_thread_unlock(info.mail->p_timed_thread);
+                               } else if (obj->data.mail) {
+                                       // this means we use obj
+                                       if (!obj->data.mail->p_timed_thread) {
+                                               obj->data.mail->p_timed_thread =
+                                                       timed_thread_create((void *) pop3_thread,
+                                                       (void *) obj->data.mail,
+                                                       obj->data.mail->interval * 1000000);
+                                               if (!obj->data.mail->p_timed_thread) {
+                                                       ERR("Error creating pop3 timed thread");
                                                }
-                                               timed_thread_lock (info.mail->p_timed_thread);
-                                               snprintf(p, p_max_size, "%.1f", info.mail->used/1024.0/1024.0);
-                                               timed_thread_unlock (info.mail->p_timed_thread);
-                                       } else if (obj->data.mail) { // this means we use obj
-                                               if (!obj->data.mail->p_timed_thread)
-                                               {
-                                                   obj->data.mail->p_timed_thread =
-                                                     timed_thread_create ((void*)pop3_thread, (void*)obj->data.mail,
-                                                                                            obj->data.mail->interval * 1000000);
-                                                   if (!obj->data.mail->p_timed_thread)
-                                                           ERR("Error creating pop3 timed thread");
-                                                   timed_thread_register (obj->data.mail->p_timed_thread, &obj->data.mail->p_timed_thread);
-                if (timed_thread_run (obj->data.mail->p_timed_thread))
-                  ERR("Error running pop3 timed thread");
+                                               timed_thread_register(obj->data.mail->p_timed_thread,
+                                                       &obj->data.mail->p_timed_thread);
+                                               if (timed_thread_run(obj->data.mail->p_timed_thread)) {
+                                                       ERR("Error running pop3 timed thread");
                                                }
-                                               timed_thread_lock (obj->data.mail->p_timed_thread);
-                                               snprintf(p, p_max_size, "%.1f", obj->data.mail->used/1024.0/1024.0);
-                                               timed_thread_unlock (obj->data.mail->p_timed_thread);
-                                       } else if (!obj->a) { // something is wrong, warn once then stop
-                                               ERR("Theres a problem with your pop3_used settings.  Check that the global POP3 settings are defined properly (line %li).", obj->line);
-                                                       obj->a++;
                                        }
+                                       timed_thread_lock(obj->data.mail->p_timed_thread);
+                                       snprintf(p, p_max_size, "%.1f",
+                                               obj->data.mail->used / 1024.0 / 1024.0);
+                                       timed_thread_unlock(obj->data.mail->p_timed_thread);
+                               } else if (!obj->a) {
+                                       // something is wrong, warn once then stop
+                                       ERR("Theres a problem with your pop3_used settings.  "
+                                               "Check that the global POP3 settings are defined "
+                                               "properly (line %li).", obj->line);
+                                       obj->a++;
                                }
+                       }
                        OBJ(fs_bar) {
                                if (obj->data.fs != NULL) {
-                                       if (obj->data.fs->size == 0)
-                                               new_bar(p,
-                                                       obj->data.fsbar.w,
-                                                       obj->data.fsbar.h,
-                                                       255);
-                                       else
-                                               new_bar(p,
-                                                       obj->data.fsbar.w,
-                                                       obj->data.fsbar.h,
-                                                       (int) (255 -
-                                                              obj->data.
-                                                              fsbar.fs->
-                                                              avail *
-                                                              255 /
-                                                              obj->data.
-                                                              fs->size));
+                                       if (obj->data.fs->size == 0) {
+                                               new_bar(p, obj->data.fsbar.w, obj->data.fsbar.h, 255);
+                                       } else {
+                                               new_bar(p, obj->data.fsbar.w, obj->data.fsbar.h,
+                                                       (int) (255 - obj->data.fsbar.fs->avail * 255 /
+                                                       obj->data.fs->size));
+                                       }
                                }
                        }
                        OBJ(fs_free) {
@@ -4559,17 +4746,13 @@ static void generate_text_internal(char *p, int p_max_size, struct text_object *
                        }
                        OBJ(fs_free_perc) {
                                if (obj->data.fs != NULL) {
-                                       if (obj->data.fs->size)
-                                               snprintf(p, p_max_size, "%*d",
-                                                        pad_percents,
-                                                        (int) ((obj->data.
-                                                                fs->
-                                                                avail *
-                                                                100) /
-                                                               obj->data.
-                                                               fs->size));
-                                       else
+                                       if (obj->data.fs->size) {
+                                               snprintf(p, p_max_size, "%*d", pad_percents,
+                                                       (int) ((obj->data.fs->avail * 100) /
+                                                       obj->data.fs->size));
+                                       } else {
                                                snprintf(p, p_max_size, "0");
+                                       }
                                }
                        }
                        OBJ(fs_size) {
@@ -4579,67 +4762,49 @@ static void generate_text_internal(char *p, int p_max_size, struct text_object *
                        }
                        OBJ(fs_used) {
                                if (obj->data.fs != NULL) {
-                                       human_readable(obj->data.fs->size -
-                                               (obj->data.fs->free ? obj->data.fs->free :
-                                               obj->data.fs->avail), p, 255, "fs_used");
+                                       human_readable(obj->data.fs->size - (obj->data.fs->free
+                                               ? obj->data.fs->free : obj->data.fs->avail), p, 255,
+                                               "fs_used");
                                }
                        }
                        OBJ(fs_bar_free) {
                                if (obj->data.fs != NULL) {
-                                       if (obj->data.fs->size == 0)
-                                               new_bar(p,
-                                                       obj->data.fsbar.w,
-                                                       obj->data.fsbar.h,
-                                                       255);
-                                       else
-                                               new_bar(p,
-                                                       obj->data.fsbar.w,
-                                                       obj->data.fsbar.h,
-                                                       (int) (obj->data.
-                                                              fsbar.fs->
-                                                              avail *
-                                                              255 /
-                                                              obj->data.
-                                                              fs->size));
+                                       if (obj->data.fs->size == 0) {
+                                               new_bar(p, obj->data.fsbar.w, obj->data.fsbar.h, 255);
+                                       } else {
+                                               new_bar(p, obj->data.fsbar.w, obj->data.fsbar.h,
+                                                       (int) (obj->data.fsbar.fs->avail * 255 /
+                                                       obj->data.fs->size));
+                                       }
                                }
                        }
                        OBJ(fs_used_perc) {
                                if (obj->data.fs != NULL) {
-                                       if (obj->data.fs->size)
+                                       if (obj->data.fs->size) {
                                                snprintf(p, 4, "%d",
-                                                        100 - ((int)
-                                                               ((obj->
-                                                                 data.fs->
-                                                                 avail *
-                                                                 100) /
-                                                                obj->data.
-                                                                fs->
-                                                                size)));
-                                       else
+                                                       100 - ((int) ((obj->data.fs->avail * 100) /
+                                                       obj->data.fs->size)));
+                                       } else {
                                                snprintf(p, p_max_size, "0");
+                                       }
                                }
                        }
                        OBJ(loadavg) {
                                float *v = info.loadavg;
 
-                               if (obj->data.loadavg[2])
+                               if (obj->data.loadavg[2]) {
                                        snprintf(p, p_max_size, "%.2f %.2f %.2f",
-                                                v[obj->data.loadavg[0] -
-                                                  1],
-                                                v[obj->data.loadavg[1] -
-                                                  1],
-                                                v[obj->data.loadavg[2] -
-                                                  1]);
-                               else if (obj->data.loadavg[1])
+                                               v[obj->data.loadavg[0] - 1],
+                                               v[obj->data.loadavg[1] - 1],
+                                               v[obj->data.loadavg[2] - 1]);
+                               } else if (obj->data.loadavg[1]) {
                                        snprintf(p, p_max_size, "%.2f %.2f",
-                                                v[obj->data.loadavg[0] -
-                                                  1],
-                                                v[obj->data.loadavg[1] -
-                                                  1]);
-                               else if (obj->data.loadavg[0])
+                                               v[obj->data.loadavg[0] - 1],
+                                               v[obj->data.loadavg[1] - 1]);
+                               } else if (obj->data.loadavg[0]) {
                                        snprintf(p, p_max_size, "%.2f",
-                                                v[obj->data.loadavg[0] -
-                                                  1]);
+                                               v[obj->data.loadavg[0] - 1]);
+                               }
                        }
                        OBJ(goto) {
                                new_goto(p, obj->data.i);
@@ -4652,46 +4817,65 @@ static void generate_text_internal(char *p, int p_max_size, struct text_object *
                        }
 #ifdef RSS
                        OBJ(rss) {
-                               PRSS* data = get_rss_info(obj->data.rss.uri, obj->data.rss.delay);
+                               PRSS *data = get_rss_info(obj->data.rss.uri,
+                                       obj->data.rss.delay);
                                char *str;
-                               if(data == NULL)
+
+                               if (data == NULL) {
                                        snprintf(p, p_max_size, "prss: Error reading RSS data\n");
-                               else {
-                                       if(!strcmp(obj->data.rss.action, "feed_title")) {
-                                                       str = data->title;
-                                                       if(str[strlen(str)-1] == '\n')
-                                                               str[strlen(str)-1] = 0; // remove trailing new line if one exists
-                                                       snprintf(p, p_max_size, "%s", str);
-                                       } else if(!strcmp(obj->data.rss.action, "item_title")) {
-                                               if(obj->data.rss.act_par < data->item_count) {
+                               } else {
+                                       if (!strcmp(obj->data.rss.action, "feed_title")) {
+                                               str = data->title;
+                                               // 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(obj->data.rss.action, "item_title")) {
+                                               if (obj->data.rss.act_par < data->item_count) {
                                                        str = data->items[obj->data.rss.act_par].title;
-                                                       if(str[strlen(str)-1] == '\n')
-                                                               str[strlen(str)-1] = 0; // remove trailing new line if one exists
+                                                       // 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(obj->data.rss.action, "item_desc")) {
-                                               if(obj->data.rss.act_par < data->item_count) {
-                                                       str = data->items[obj->data.rss.act_par].description;
-                                                       if(str[strlen(str)-1] == '\n')
-                                                               str[strlen(str)-1] = 0; // remove trailing new line if one exists
+                                       } else if (!strcmp(obj->data.rss.action, "item_desc")) {
+                                               if (obj->data.rss.act_par < data->item_count) {
+                                                       str =
+                                                               data->items[obj->data.rss.act_par].description;
+                                                       // 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(obj->data.rss.action, "item_titles")) {
-                                               if(data->item_count > 0) {
+                                       } else if (!strcmp(obj->data.rss.action, "item_titles")) {
+                                               if (data->item_count > 0) {
                                                        int itmp;
+
                                                        p[0] = 0;
                                                        int show;
-                                                       if(obj->data.rss.act_par > data->item_count)
+
+                                                       if (obj->data.rss.act_par > data->item_count) {
                                                                show = data->item_count;
-                                                       else    show = obj->data.rss.act_par;
-                                                       for(itmp = 0; itmp < show; itmp++) {
+                                                       } else {
+                                                               show = obj->data.rss.act_par;
+                                                       }
+                                                       for (itmp = 0; itmp < show; itmp++) {
                                                                PRSS_Item *item = &data->items[itmp];
+
                                                                str = item->title;
-                                                               if(str) {
-                                                                       if(itmp>0) // don't add new line before first item
+                                                               if (str) {
+                                                                       // don't add new line before first item
+                                                                       if (itmp > 0) {
                                                                                strncat(p, "\n", p_max_size);
-                                                                       if(str[strlen(str)-1] == '\n')
-                                                                               str[strlen(str)-1] = 0; // remove trailing new line if one exists, we have our own
+                                                                       }
+                                                                       /* remove trailing new line if one exists,
+                                                                        * we have our own */
+                                                                       if (str[strlen(str) - 1] == '\n') {
+                                                                               str[strlen(str) - 1] = 0;
+                                                                       }
                                                                        strncat(p, str, p_max_size);
                                                                }
                                                        }
@@ -4704,15 +4888,15 @@ static void generate_text_internal(char *p, int p_max_size, struct text_object *
                        OBJ(hddtemp) {
                                char *temp;
                                char unit;
-                               
-                               temp = get_hddtemp_info(obj->data.hddtemp.dev, 
-                                               obj->data.hddtemp.addr, obj->data.hddtemp.port, &unit);
+
+                               temp = get_hddtemp_info(obj->data.hddtemp.dev,
+                                       obj->data.hddtemp.addr, obj->data.hddtemp.port, &unit);
                                if (!temp) {
                                        snprintf(p, p_max_size, "N/A");
                                } else if (unit == '*') {
                                        snprintf(p, p_max_size, "%s", temp);
                                } else {
-                                        snprintf(p, p_max_size, "%s°%c", temp, unit);
+                                       snprintf(p, p_max_size, "%s°%c", temp, unit);
                                }
                        }
 #endif
@@ -4726,42 +4910,39 @@ static void generate_text_internal(char *p, int p_max_size, struct text_object *
                        OBJ(i2c) {
                                double r;
 
-                               r = get_sysfs_info(&obj->data.sysfs.fd,
-                                                            obj->data.sysfs.arg,
-                                                            obj->data.sysfs.devtype,
-                                                            obj->data.sysfs.type);
+                               r = get_sysfs_info(&obj->data.sysfs.fd, obj->data.sysfs.arg,
+                                       obj->data.sysfs.devtype, obj->data.sysfs.type);
+
+                               if (r >= 100.0 || r == 0) {
+                                       snprintf(p, p_max_size, "%d", (int) r);
+                               } else {
+                                       snprintf(p, p_max_size, "%.1f", r);
+                               }
+                       }
+                       OBJ(platform) {
+                               double r;
+
+                               r = get_sysfs_info(&obj->data.sysfs.fd, obj->data.sysfs.arg,
+                                       obj->data.sysfs.devtype, obj->data.sysfs.type);
+
+                               if (r >= 100.0 || r == 0) {
+                                       snprintf(p, p_max_size, "%d", (int) r);
+                               } else {
+                                       snprintf(p, p_max_size, "%.1f", r);
+                               }
+                       }
+                       OBJ(hwmon) {
+                               double r;
+
+                               r = get_sysfs_info(&obj->data.sysfs.fd, obj->data.sysfs.arg,
+                                       obj->data.sysfs.devtype, obj->data.sysfs.type);
 
-                               if (r >= 100.0 || r == 0)
+                               if (r >= 100.0 || r == 0) {
                                        snprintf(p, p_max_size, "%d", (int) r);
-                               else
+                               } else {
                                        snprintf(p, p_max_size, "%.1f", r);
+                               }
                        }
-      OBJ(platform) {
-        double r;
-
-        r = get_sysfs_info(&obj->data.sysfs.fd,
-                         obj->data.sysfs.arg,
-                         obj->data.sysfs.devtype,
-                         obj->data.sysfs.type);
-
-        if (r >= 100.0 || r == 0)
-          snprintf(p, p_max_size, "%d", (int) r);
-        else
-          snprintf(p, p_max_size, "%.1f", r);
-      }
-      OBJ(hwmon) {
-        double r;
-
-        r = get_sysfs_info(&obj->data.sysfs.fd,
-                         obj->data.sysfs.arg,
-                         obj->data.sysfs.devtype,
-                         obj->data.sysfs.type);
-
-        if (r >= 100.0 || r == 0)
-           snprintf(p, p_max_size, "%d", (int) r);
-        else
-          snprintf(p, p_max_size, "%.1f", r);
-      }
 #endif /* !__OpenBSD__ */
                        OBJ(alignr) {
                                new_alignr(p, obj->data.i);
@@ -4771,7 +4952,8 @@ static void generate_text_internal(char *p, int p_max_size, struct text_object *
                        }
                        OBJ(if_empty) {
                                struct information *my_info =
-                                   malloc(sizeof(struct information));
+                                       malloc(sizeof(struct information));
+
                                memcpy(my_info, cur, sizeof(struct information));
                                parse_conky_vars(obj->data.ifblock.s, p, my_info);
                                if (strlen(p) != 0) {
@@ -4785,26 +4967,28 @@ static void generate_text_internal(char *p, int p_max_size, struct text_object *
                        }
                        OBJ(if_existing) {
                                struct stat tmp;
+
                                if ((obj->data.ifblock.s)
-                                   && (stat(obj->data.ifblock.s, &tmp) ==
-                                       -1)) {
+                                               && (stat(obj->data.ifblock.s, &tmp) == -1)) {
                                        i = obj->data.ifblock.pos;
                                        if_jumped = 1;
                                } else {
-                                       if (obj->data.ifblock.str) {
-                                               if (!check_contains(obj->data.ifblock.s, 
-                                                       obj->data.ifblock.str)) {
+                                       if (obj->data.ifblock.str) {
+                                               if (!check_contains(obj->data.ifblock.s,
+                                                               obj->data.ifblock.str)) {
                                                        i = obj->data.ifblock.pos;
                                                        if_jumped = 1;
-                                               } else 
-                                                       if_jumped = 0;
-                                       } else 
-                                               if_jumped = 0;
+                                               } else {
+                                                       if_jumped = 0;
+                                               }
+                                       } else {
+                                               if_jumped = 0;
+                                       }
                                }
                        }
                        OBJ(if_mounted) {
                                if ((obj->data.ifblock.s)
-                                   && (!check_mount(obj->data.ifblock.s))) {
+                                               && (!check_mount(obj->data.ifblock.s))) {
                                        i = obj->data.ifblock.pos;
                                        if_jumped = 1;
                                } else {
@@ -4812,8 +4996,7 @@ static void generate_text_internal(char *p, int p_max_size, struct text_object *
                                }
                        }
                        OBJ(if_running) {
-                               if ((obj->data.ifblock.s)
-                                   && system(obj->data.ifblock.s)) {
+                               if ((obj->data.ifblock.s) && system(obj->data.ifblock.s)) {
                                        i = obj->data.ifblock.pos;
                                        if_jumped = 1;
                                } else {
@@ -4841,48 +5024,36 @@ static void generate_text_internal(char *p, int p_max_size, struct text_object *
                                }
                        }
                        OBJ(membar) {
-                               new_bar(p, obj->data.pair.a,
-                                       obj->data.pair.b,
-                                       cur->memmax ? (cur->mem * 255) /
-                                       (cur->memmax) : 0);
+                               new_bar(p, obj->data.pair.a, obj->data.pair.b,
+                                       cur->memmax ? (cur->mem * 255) / (cur->memmax) : 0);
                        }
-
                        OBJ(memgraph) {
-                               new_graph(p, obj->a,
-                               obj->b, obj->c, obj->d,
-                               cur->memmax ? (cur->mem * 100.0) /
-                                               (cur->memmax) : 0.0, 100, 1);
+                               new_graph(p, obj->a, obj->b, obj->c, obj->d,
+                                       cur->memmax ? (cur->mem * 100.0) / (cur->memmax) : 0.0,
+                                       100, 1);
                        }
+
                        /* mixer stuff */
                        OBJ(mixer) {
-                               snprintf(p, p_max_size, "%d",
-                                        mixer_get_avg(obj->data.l));
+                               snprintf(p, p_max_size, "%d", mixer_get_avg(obj->data.l));
                        }
                        OBJ(mixerl) {
-                               snprintf(p, p_max_size, "%d",
-                                        mixer_get_left(obj->data.l));
+                               snprintf(p, p_max_size, "%d", mixer_get_left(obj->data.l));
                        }
                        OBJ(mixerr) {
-                               snprintf(p, p_max_size, "%d",
-                                        mixer_get_right(obj->data.l));
+                               snprintf(p, p_max_size, "%d", mixer_get_right(obj->data.l));
                        }
                        OBJ(mixerbar) {
-                               new_bar(p, obj->data.mixerbar.w,
-                                       obj->data.mixerbar.h,
-                                       mixer_get_avg(obj->data.mixerbar.
-                                                     l) * 255 / 100);
+                               new_bar(p, obj->data.mixerbar.w, obj->data.mixerbar.h,
+                                       mixer_get_avg(obj->data.mixerbar.l) * 255 / 100);
                        }
                        OBJ(mixerlbar) {
-                               new_bar(p, obj->data.mixerbar.w,
-                                       obj->data.mixerbar.h,
-                                       mixer_get_left(obj->data.mixerbar.
-                                                      l) * 255 / 100);
+                               new_bar(p, obj->data.mixerbar.w, obj->data.mixerbar.h,
+                                       mixer_get_left(obj->data.mixerbar.l) * 255 / 100);
                        }
                        OBJ(mixerrbar) {
-                               new_bar(p, obj->data.mixerbar.w,
-                                       obj->data.mixerbar.h,
-                                       mixer_get_right(obj->data.mixerbar.
-                                                       l) * 255 / 100);
+                               new_bar(p, obj->data.mixerbar.w, obj->data.mixerbar.h,
+                                       mixer_get_right(obj->data.mixerbar.l) * 255 / 100);
                        }
 
                        /* mail stuff */
@@ -4891,17 +5062,17 @@ static void generate_text_internal(char *p, int p_max_size, struct text_object *
                                snprintf(p, p_max_size, "%d", obj->data.local_mail.mail_count);
                        }
                        OBJ(mboxscan) {
-                mbox_scan(obj->data.mboxscan.args, obj->data.mboxscan.output, TEXT_BUFFER_SIZE);
+                               mbox_scan(obj->data.mboxscan.args, obj->data.mboxscan.output,
+                                       TEXT_BUFFER_SIZE);
                                snprintf(p, p_max_size, "%s", obj->data.mboxscan.output);
                        }
                        OBJ(new_mails) {
                                update_mail_count(&obj->data.local_mail);
-                               snprintf(p, p_max_size, "%d", obj->data.local_mail.new_mail_count);
+                               snprintf(p, p_max_size, "%d",
+                                       obj->data.local_mail.new_mail_count);
                        }
-
                        OBJ(nodename) {
-                               snprintf(p, p_max_size, "%s",
-                                        cur->uname_s.nodename);
+                               snprintf(p, p_max_size, "%s", cur->uname_s.nodename);
                        }
                        OBJ(outlinecolor) {
                                new_outline(p, obj->data.l);
@@ -4910,8 +5081,7 @@ static void generate_text_internal(char *p, int p_max_size, struct text_object *
                                spaced_print(p, p_max_size, "%hu", 5, "processes", cur->procs);
                        }
                        OBJ(running_processes) {
-                               spaced_print(p, p_max_size, "%hu", 3, "running_processes",
-                                       cur->run_procs);
+                               spaced_print(p, p_max_size, "%hu", 3, "running_processes", cur->run_procs);
                        }
                        OBJ(text) {
                                snprintf(p, p_max_size, "%s", obj->data.s);
@@ -4920,8 +5090,7 @@ static void generate_text_internal(char *p, int p_max_size, struct text_object *
                                new_bg(p, obj->data.l);
                        }
                        OBJ(stippled_hr) {
-                               new_stippled_hr(p, obj->data.pair.a,
-                                               obj->data.pair.b);
+                               new_stippled_hr(p, obj->data.pair.a, obj->data.pair.b);
                        }
                        OBJ(swap) {
                                human_readable(cur->swap * 1024, p, 255, "swap");
@@ -4938,10 +5107,8 @@ static void generate_text_internal(char *p, int p_max_size, struct text_object *
                                }
                        }
                        OBJ(swapbar) {
-                               new_bar(p, obj->data.pair.a,
-                                       obj->data.pair.b,
-                                       cur->swapmax ? (cur->swap * 255) /
-                                       (cur->swapmax) : 0);
+                               new_bar(p, obj->data.pair.a, obj->data.pair.b,
+                                       cur->swapmax ? (cur->swap * 255) / (cur->swapmax) : 0);
                        }
                        OBJ(sysname) {
                                snprintf(p, p_max_size, "%s", cur->uname_s.sysname);
@@ -4949,16 +5116,19 @@ static void generate_text_internal(char *p, int p_max_size, struct text_object *
                        OBJ(time) {
                                time_t t = time(NULL);
                                struct tm *tm = localtime(&t);
+
                                setlocale(LC_TIME, "");
                                strftime(p, p_max_size, obj->data.s, tm);
                        }
                        OBJ(utime) {
                                time_t t = time(NULL);
                                struct tm *tm = gmtime(&t);
+
                                strftime(p, p_max_size, obj->data.s, tm);
                        }
                        OBJ(tztime) {
-                               char* oldTZ = NULL;
+                               char *oldTZ = NULL;
+
                                if (obj->data.tztime.tz) {
                                        oldTZ = getenv("TZ");
                                        setenv("TZ", obj->data.tztime.tz, 1);
@@ -4966,6 +5136,7 @@ static void generate_text_internal(char *p, int p_max_size, struct text_object *
                                }
                                time_t t = time(NULL);
                                struct tm *tm = localtime(&t);
+
                                setlocale(LC_TIME, "");
                                strftime(p, p_max_size, obj->data.tztime.fmt, tm);
                                if (oldTZ) {
@@ -4974,7 +5145,7 @@ static void generate_text_internal(char *p, int p_max_size, struct text_object *
                                } else {
                                        unsetenv("TZ");
                                }
-                               // Needless to free oldTZ since getenv gives ptr to static data 
+                               // Needless to free oldTZ since getenv gives ptr to static data
                        }
                        OBJ(totaldown) {
                                human_readable(obj->data.net->recv, p, 255, "totaldown");
@@ -4995,31 +5166,34 @@ static void generate_text_internal(char *p, int p_max_size, struct text_object *
                        }
                        OBJ(upspeedgraph) {
                                new_graph(p, obj->a, obj->b, obj->c, obj->d,
-                                       (obj->data.net->trans_speed / 1024.0), obj->e, 1);
+                                       obj->data.net->trans_speed / 1024.0, obj->e, 1);
                        }
                        OBJ(uptime_short) {
-                               format_seconds_short(p, p_max_size,
-                                                    (int) cur->uptime);
+                               format_seconds_short(p, p_max_size, (int) cur->uptime);
                        }
                        OBJ(uptime) {
                                format_seconds(p, p_max_size, (int) cur->uptime);
                        }
 
-#if (defined(__FreeBSD__) || defined(__FreeBSD_kernel__) || defined(__OpenBSD__)) && (defined(i386) || defined(__i386__))
+#if (defined(__FreeBSD__) || defined(__FreeBSD_kernel__) \
+               || defined(__OpenBSD__)) && (defined(i386) || defined(__i386__))
                        OBJ(apm_adapter) {
-                               char    *msg;
+                               char *msg;
+
                                msg = get_apm_adapter();
                                snprintf(p, p_max_size, "%s", msg);
                                free(msg);
                        }
                        OBJ(apm_battery_life) {
-                               char    *msg;
+                               char *msg;
+
                                msg = get_apm_battery_life();
                                snprintf(p, p_max_size, "%s", msg);
                                free(msg);
                        }
                        OBJ(apm_battery_time) {
-                               char    *msg;
+                               char *msg;
+
                                msg = get_apm_battery_time();
                                snprintf(p, p_max_size, "%s", msg);
                                free(msg);
@@ -5028,9 +5202,9 @@ static void generate_text_internal(char *p, int p_max_size, struct text_object *
 
 #ifdef MPD
                        OBJ(mpd_title) {
-                           snprintf(p, cur->mpd.max_title_len > 0 ?
-                                       cur->mpd.max_title_len : p_max_size, "%s", 
-                                    cur->mpd.title);
+                               snprintf(p, cur->mpd.max_title_len > 0
+                                       ? cur->mpd.max_title_len : p_max_size, "%s",
+                                       cur->mpd.title);
                        }
                        OBJ(mpd_artist) {
                                snprintf(p, p_max_size, "%s", cur->mpd.artist);
@@ -5063,9 +5237,9 @@ static void generate_text_internal(char *p, int p_max_size, struct text_object *
                                snprintf(p, p_max_size, "%s", cur->mpd.status);
                        }
                        OBJ(mpd_elapsed) {
-                               int days = 0, hours = 0, minutes =
-                                   0, seconds = 0;
+                               int days = 0, hours = 0, minutes = 0, seconds = 0;
                                int tmp = cur->mpd.elapsed;
+
                                while (tmp >= 86400) {
                                        tmp -= 86400;
                                        days++;
@@ -5079,21 +5253,20 @@ static void generate_text_internal(char *p, int p_max_size, struct text_object *
                                        minutes++;
                                }
                                seconds = tmp;
-                               if (days > 0)
-                                       snprintf(p, p_max_size, "%i days %i:%02i:%02i",
-                                                days, hours, minutes,
-                                                seconds);
-                               else if (hours > 0)
-                                       snprintf(p, p_max_size, "%i:%02i:%02i", hours,
-                                                minutes, seconds);
-                               else
-                                       snprintf(p, p_max_size, "%i:%02i", minutes,
-                                                seconds);
+                               if (days > 0) {
+                                       snprintf(p, p_max_size, "%i days %i:%02i:%02i", days,
+                                               hours, minutes, seconds);
+                               } else if (hours > 0) {
+                                       snprintf(p, p_max_size, "%i:%02i:%02i", hours, minutes,
+                                               seconds);
+                               } else {
+                                       snprintf(p, p_max_size, "%i:%02i", minutes, seconds);
+                               }
                        }
                        OBJ(mpd_length) {
-                               int days = 0, hours = 0, minutes =
-                                   0, seconds = 0;
+                               int days = 0, hours = 0, minutes = 0, seconds = 0;
                                int tmp = cur->mpd.length;
+
                                while (tmp >= 86400) {
                                        tmp -= 86400;
                                        days++;
@@ -5107,47 +5280,41 @@ static void generate_text_internal(char *p, int p_max_size, struct text_object *
                                        minutes++;
                                }
                                seconds = tmp;
-                               if (days > 0)
-                                       snprintf(p, p_max_size,
-                                                "%i days %i:%02i:%02i",
-                                                days, hours, minutes,
-                                                seconds);
-                               else if (hours > 0)
-                                       snprintf(p, p_max_size, "%i:%02i:%02i", hours,
-                                                minutes, seconds);
-                               else
-                                       snprintf(p, p_max_size, "%i:%02i", minutes,
-                                                seconds);
+                               if (days > 0) {
+                                       snprintf(p, p_max_size, "%i days %i:%02i:%02i", days,
+                                               hours, minutes, seconds);
+                               } else if (hours > 0) {
+                                       snprintf(p, p_max_size, "%i:%02i:%02i", hours, minutes,
+                                               seconds);
+                               } else {
+                                       snprintf(p, p_max_size, "%i:%02i", minutes, seconds);
+                               }
                        }
                        OBJ(mpd_percent) {
-                               snprintf(p, p_max_size, "%2.0f",
-                                        cur->mpd.progress * 100);
+                               snprintf(p, p_max_size, "%2.0f", cur->mpd.progress * 100);
                        }
                        OBJ(mpd_bar) {
-                               new_bar(p, obj->data.pair.a,
-                                       obj->data.pair.b,
-                                       (int) (cur->mpd.progress *
-                                              255.0f));
+                               new_bar(p, obj->data.pair.a, obj->data.pair.b,
+                                       (int) (cur->mpd.progress * 255.0f));
                        }
                        OBJ(mpd_smart) {
-        memset (p, 0, p_max_size);
-        if (cur->mpd.artist && *cur->mpd.artist && cur->mpd.title && *cur->mpd.title) {
-          snprintf(p, p_max_size, "%s - %s", cur->mpd.artist, cur->mpd.title);
-        }
-        else if (cur->mpd.title && *cur->mpd.title) {
-          snprintf(p, p_max_size, "%s", cur->mpd.title);
-        }
-        else if (cur->mpd.artist && *cur->mpd.artist) {
-          snprintf(p, p_max_size, "%s", cur->mpd.artist);
-        }
-        else if (cur->mpd.file && *cur->mpd.file) {
-          snprintf(p, p_max_size, "%s", cur->mpd.file);
-        }
-        else {
-          *p=0;
-        }
+                               memset(p, 0, p_max_size);
+                               if (cur->mpd.artist && *cur->mpd.artist && cur->mpd.title
+                                               && *cur->mpd.title) {
+                                       snprintf(p, p_max_size, "%s - %s", cur->mpd.artist,
+                                               cur->mpd.title);
+                               } else if (cur->mpd.title && *cur->mpd.title) {
+                                       snprintf(p, p_max_size, "%s", cur->mpd.title);
+                               } else if (cur->mpd.artist && *cur->mpd.artist) {
+                                       snprintf(p, p_max_size, "%s", cur->mpd.artist);
+                               } else if (cur->mpd.file && *cur->mpd.file) {
+                                       snprintf(p, p_max_size, "%s", cur->mpd.file);
+                               } else {
+                                       *p = 0;
+                               }
                        }
 #endif
+
 #ifdef XMMS2
                        OBJ(xmms2_artist) {
                                snprintf(p, p_max_size, "%s", cur->xmms2.artist);
@@ -5176,96 +5343,109 @@ static void generate_text_internal(char *p, int p_max_size, struct text_object *
                        OBJ(xmms2_status) {
                                snprintf(p, p_max_size, "%s", cur->xmms2.status);
                        }
-            OBJ(xmms2_date) {
-                    snprintf(p, p_max_size, "%s", cur->xmms2.date);
+                       OBJ(xmms2_date) {
+                               snprintf(p, p_max_size, "%s", cur->xmms2.date);
                        }
                        OBJ(xmms2_tracknr) {
-                           if (cur->xmms2.tracknr != -1)
-                    snprintf(p, p_max_size, "%i", cur->xmms2.tracknr);
+                               if (cur->xmms2.tracknr != -1) {
+                                       snprintf(p, p_max_size, "%i", cur->xmms2.tracknr);
+                               }
                        }
                        OBJ(xmms2_bitrate) {
                                snprintf(p, p_max_size, "%i", cur->xmms2.bitrate);
                        }
-            OBJ(xmms2_id) {
+                       OBJ(xmms2_id) {
                                snprintf(p, p_max_size, "%u", cur->xmms2.id);
                        }
-            OBJ(xmms2_size) {
+                       OBJ(xmms2_size) {
                                snprintf(p, p_max_size, "%2.1f", cur->xmms2.size);
                        }
                        OBJ(xmms2_elapsed) {
-                               int tmp = cur->xmms2.elapsed;
-                               snprintf(p, p_max_size, "%02d:%02d",
-                                   tmp / 60000, (tmp / 1000) % 60);
+                               snprintf(p, p_max_size, "%02d:%02d", cur->xmms2.elapsed / 60000,
+                                       (cur->xmms2.elapsed / 1000) % 60);
                        }
                        OBJ(xmms2_duration) {
-                               int tmp = cur->xmms2.duration;
                                snprintf(p, p_max_size, "%02d:%02d",
-                                   tmp / 60000, (tmp / 1000) % 60);
+                                       cur->xmms2.duration / 60000,
+                                       (cur->xmms2.duration / 1000) % 60);
                        }
                        OBJ(xmms2_percent) {
-                               snprintf(p, p_max_size, "%2.0f",
-                                        cur->xmms2.progress * 100);
+                               snprintf(p, p_max_size, "%2.0f", cur->xmms2.progress * 100);
                        }
                        OBJ(xmms2_bar) {
-                               new_bar(p, obj->data.pair.a,
-                                       obj->data.pair.b,
-                                       (int) (cur->xmms2.progress *
-                                              255.0f));
+                               new_bar(p, obj->data.pair.a, obj->data.pair.b,
+                                       (int) (cur->xmms2.progress * 255.0f));
                        }
                        OBJ(xmms2_smart) {
-                               if (strlen(cur->xmms2.title) < 2 && strlen(cur->xmms2.title) < 2) {
+                               if (strlen(cur->xmms2.title) < 2
+                                               && strlen(cur->xmms2.title) < 2) {
                                        snprintf(p, p_max_size, "%s", cur->xmms2.url);
                                } else {
-                                       snprintf(p, p_max_size, "%s - %s", cur->xmms2.artist, cur->xmms2.title);
+                                       snprintf(p, p_max_size, "%s - %s", cur->xmms2.artist,
+                                               cur->xmms2.title);
                                }
                        }
 #endif
 #ifdef AUDACIOUS
                        OBJ(audacious_status) {
-                           snprintf(p, p_max_size, "%s", cur->audacious.items[AUDACIOUS_STATUS]);
+                               snprintf(p, p_max_size, "%s",
+                                       cur->audacious.items[AUDACIOUS_STATUS]);
                        }
-                       OBJ(audacious_title) {
-                           snprintf(p, cur->audacious.max_title_len > 0 ?
-                                       cur->audacious.max_title_len : p_max_size, "%s", 
-                                    cur->audacious.items[AUDACIOUS_TITLE]);
+                       OBJ(audacious_title) {
+                               snprintf(p, cur->audacious.max_title_len > 0
+                                       ? cur->audacious.max_title_len : p_max_size, "%s",
+                                       cur->audacious.items[AUDACIOUS_TITLE]);
                        }
-                       OBJ(audacious_length) {
-                           snprintf(p, p_max_size, "%s", cur->audacious.items[AUDACIOUS_LENGTH]);
+                       OBJ(audacious_length) {
+                               snprintf(p, p_max_size, "%s",
+                                       cur->audacious.items[AUDACIOUS_LENGTH]);
                        }
-                       OBJ(audacious_length_seconds) {
-                           snprintf(p, p_max_size, "%s", cur->audacious.items[AUDACIOUS_LENGTH_SECONDS]);
+                       OBJ(audacious_length_seconds) {
+                               snprintf(p, p_max_size, "%s",
+                                       cur->audacious.items[AUDACIOUS_LENGTH_SECONDS]);
                        }
-                       OBJ(audacious_position) {
-                           snprintf(p, p_max_size, "%s", cur->audacious.items[AUDACIOUS_POSITION]);
+                       OBJ(audacious_position) {
+                               snprintf(p, p_max_size, "%s",
+                                       cur->audacious.items[AUDACIOUS_POSITION]);
                        }
-                       OBJ(audacious_position_seconds) {
-                           snprintf(p, p_max_size, "%s", cur->audacious.items[AUDACIOUS_POSITION_SECONDS]);
+                       OBJ(audacious_position_seconds) {
+                               snprintf(p, p_max_size, "%s",
+                                       cur->audacious.items[AUDACIOUS_POSITION_SECONDS]);
                        }
-                       OBJ(audacious_bitrate) {
-                           snprintf(p, p_max_size, "%s", cur->audacious.items[AUDACIOUS_BITRATE]);
+                       OBJ(audacious_bitrate) {
+                               snprintf(p, p_max_size, "%s",
+                                       cur->audacious.items[AUDACIOUS_BITRATE]);
                        }
-                       OBJ(audacious_frequency) {
-                           snprintf(p, p_max_size, "%s", cur->audacious.items[AUDACIOUS_FREQUENCY]);
+                       OBJ(audacious_frequency) {
+                               snprintf(p, p_max_size, "%s",
+                                       cur->audacious.items[AUDACIOUS_FREQUENCY]);
                        }
-                       OBJ(audacious_channels) {
-                           snprintf(p, p_max_size, "%s", cur->audacious.items[AUDACIOUS_CHANNELS]);
+                       OBJ(audacious_channels) {
+                               snprintf(p, p_max_size, "%s",
+                                       cur->audacious.items[AUDACIOUS_CHANNELS]);
                        }
-                       OBJ(audacious_filename) {
-                           snprintf(p, p_max_size, "%s", cur->audacious.items[AUDACIOUS_FILENAME]);
+                       OBJ(audacious_filename) {
+                               snprintf(p, p_max_size, "%s",
+                                       cur->audacious.items[AUDACIOUS_FILENAME]);
                        }
-                       OBJ(audacious_playlist_length) {
-                           snprintf(p, p_max_size, "%s", cur->audacious.items[AUDACIOUS_PLAYLIST_LENGTH]);
+                       OBJ(audacious_playlist_length) {
+                               snprintf(p, p_max_size, "%s",
+                                       cur->audacious.items[AUDACIOUS_PLAYLIST_LENGTH]);
                        }
-                       OBJ(audacious_playlist_position) {
-                           snprintf(p, p_max_size, "%s", cur->audacious.items[AUDACIOUS_PLAYLIST_POSITION]);
+                       OBJ(audacious_playlist_position) {
+                               snprintf(p, p_max_size, "%s",
+                                       cur->audacious.items[AUDACIOUS_PLAYLIST_POSITION]);
                        }
-                       OBJ(audacious_bar) {
-                            double progress;
-                            progress= atof(cur->audacious.items[AUDACIOUS_POSITION_SECONDS]) /
-                                      atof(cur->audacious.items[AUDACIOUS_LENGTH_SECONDS]);
-                            new_bar(p,obj->a,obj->b,(int)(progress*255.0f));
+                       OBJ(audacious_bar) {
+                               double progress;
+
+                               progress =
+                                       atof(cur->audacious.items[AUDACIOUS_POSITION_SECONDS]) /
+                                       atof(cur->audacious.items[AUDACIOUS_LENGTH_SECONDS]);
+                               new_bar(p, obj->a, obj->b, (int) (progress * 255.0f));
                        }
 #endif
+
 #ifdef BMPX
                        OBJ(bmpx_title) {
                                snprintf(p, p_max_size, "%s", cur->bmpx.title);
@@ -5280,44 +5460,49 @@ static void generate_text_internal(char *p, int p_max_size, struct text_object *
                                snprintf(p, p_max_size, "%s", cur->bmpx.uri);
                        }
                        OBJ(bmpx_track) {
-                                snprintf(p, p_max_size, "%i", cur->bmpx.track);
+                               snprintf(p, p_max_size, "%i", cur->bmpx.track);
                        }
                        OBJ(bmpx_bitrate) {
                                snprintf(p, p_max_size, "%i", cur->bmpx.bitrate);
                        }
 #endif
 
-                       char *format_time(unsigned long time, const int width) {
+                       char *format_time(unsigned long time, const int width)
+                       {
                                char buf[10];
-                               unsigned long nt; // narrow time, for speed on
-
-                               // 32-bit
-                               unsigned cc; // centiseconds
-                               unsigned nn; // multi-purpose whatever
+                               unsigned long nt;       // narrow time, for speed on 32-bit
+                               unsigned cc;            // centiseconds
+                               unsigned nn;            // multi-purpose whatever
 
                                nt = time;
-                               cc = nt % 100; // centiseconds past second
-                               nt /= 100; // total seconds
-                               nn = nt % 60; // seconds past the minute
-                               nt /= 60; // total minutes
-                               if (width >= snprintf(buf, sizeof buf, "%lu:%02u.%02u", nt,
-                                               nn, cc))
+                               cc = nt % 100;          // centiseconds past second
+                               nt /= 100;                      // total seconds
+                               nn = nt % 60;           // seconds past the minute
+                               nt /= 60;                       // total minutes
+                               if (width >= snprintf(buf, sizeof buf, "%lu:%02u.%02u",
+                                               nt, nn, cc)) {
                                        return strdup(buf);
-                               if (width >= snprintf(buf, sizeof buf, "%lu:%02u", nt, nn))
+                               }
+                               if (width >= snprintf(buf, sizeof buf, "%lu:%02u", nt, nn)) {
                                        return strdup(buf);
-                               nn = nt % 60; // minutes past the hour
-                               nt /= 60; // total hours
-                               if (width >= snprintf(buf, sizeof buf, "%lu,%02u", nt, nn))
+                               }
+                               nn = nt % 60;           // minutes past the hour
+                               nt /= 60;                       // total hours
+                               if (width >= snprintf(buf, sizeof buf, "%lu,%02u", nt, nn)) {
                                        return strdup(buf);
-                               nn = nt; // now also hours
-                               if (width >= snprintf(buf, sizeof buf, "%uh", nn))
+                               }
+                               nn = nt;                        // now also hours
+                               if (width >= snprintf(buf, sizeof buf, "%uh", nn)) {
                                        return strdup(buf);
-                               nn /= 24; // now days
-                               if (width >= snprintf(buf, sizeof buf, "%ud", nn))
+                               }
+                               nn /= 24;                       // now days
+                               if (width >= snprintf(buf, sizeof buf, "%ud", nn)) {
                                        return strdup(buf);
-                               nn /= 7; // now weeks
-                               if (width >= snprintf(buf, sizeof buf, "%uw", nn))
+                               }
+                               nn /= 7;                        // now weeks
+                               if (width >= snprintf(buf, sizeof buf, "%uw", nn)) {
                                        return strdup(buf);
+                               }
                                // well shoot, this outta' fit...
                                return strdup("<inf>");
                        }
@@ -5345,13 +5530,13 @@ static void generate_text_internal(char *p, int p_max_size, struct text_object *
                                                        break;
                                                case TOP_TIME:
                                                        time = format_time(
-                                                               cur->cpu[obj->data.top.num]->total_cpu_time,
-                                                               9);
+                                                               cur->cpu[obj->data.top.num]->total_cpu_time, 9);
                                                        snprintf(p, 10, "%9s", time);
                                                        free(time);
                                                        break;
                                                default:
-                                                       ERR("Unhandled top data type: %d\n", obj->data.top.type);
+                                                       ERR("Unhandled top data type: %d\n",
+                                                               obj->data.top.type);
                                        }
                                } else {
                                        ERR("Top index < 0 or > 10: %d\n", obj->data.top.num);
@@ -5364,7 +5549,7 @@ static void generate_text_internal(char *p, int p_max_size, struct text_object *
                                        switch (obj->data.top.type) {
                                                case TOP_NAME:
                                                        snprintf(p, 16, "%-15s",
-                                               cur->memu[obj->data.top.num]->name);
+                                                               cur->memu[obj->data.top.num]->name);
                                                        break;
                                                case TOP_CPU:
                                                        snprintf(p, 7, "%6.2f",
@@ -5376,109 +5561,114 @@ static void generate_text_internal(char *p, int p_max_size, struct text_object *
                                                        break;
                                                case TOP_MEM:
                                                        snprintf(p, 7, "%6.2f",
-                                               cur->memu[obj->data.top.num]->totalmem);
+                                                               cur->memu[obj->data.top.num]->totalmem);
                                                        break;
                                                case TOP_TIME:
                                                        time = format_time(
                                                                cur->memu[obj->data.top.num]->total_cpu_time,
                                                                9);
-                                       snprintf(p, 10, "%9s", time);
-                                       free(time);
+                                                       snprintf(p, 10, "%9s", time);
+                                                       free(time);
                                                        break;
                                                default:
-                                                       ERR("Unhandled top data type: %d\n", obj->data.top.type);
+                                                       ERR("Unhandled top data type: %d\n",
+                                                               obj->data.top.type);
                                        }
                                } else {
                                        ERR("Top index < 0 or > 10: %d\n", obj->data.top.num);
                                }
                        }
-
-
                        OBJ(tail) {
-                               if (current_update_time -obj->data.tail.last_update < obj->data.tail.interval) {
-                                                       snprintf(p, p_max_size, "%s", obj->data.tail.buffer);
+                               if (current_update_time - obj->data.tail.last_update
+                                               < obj->data.tail.interval) {
+                                       snprintf(p, p_max_size, "%s", obj->data.tail.buffer);
                                } else {
                                        obj->data.tail.last_update = current_update_time;
                                        FILE *fp;
-                                       long nl=0, bsize;
+                                       long nl = 0, bsize;
                                        int iter;
 
                                        if (obj->data.tail.fd != -1) {
-                                           tail_pipe(obj, p, p_max_size);
-                                           goto head;
+                                               tail_pipe(obj, p, p_max_size);
+                                               goto head;
                                        }
 
                                        fp = fopen(obj->data.tail.logfile, "rt");
 
                                        if (fp == NULL) {
-                                               /* Send one message, but do not consistently spam on
-                                                * missing logfiles. */
-                                               if(obj->data.tail.readlines != 0) {
+                                               /* Send one message, but do not consistently spam
+                                                * on missing logfiles. */
+                                               if (obj->data.tail.readlines != 0) {
                                                        ERR("tail logfile failed to open");
                                                        strcpy(obj->data.tail.buffer, "Logfile Missing");
                                                }
                                                obj->data.tail.readlines = 0;
                                                snprintf(p, p_max_size, "Logfile Missing");
-                                       }
-                                       else {
+                                       } else {
                                                obj->data.tail.readlines = 0;
-                                               /* -1 instead of 0 to avoid counting a trailing newline */
-                                               fseek(fp, -1, SEEK_END); 
+                                               /* -1 instead of 0 to avoid counting a trailing
+                                                * newline */
+                                               fseek(fp, -1, SEEK_END);
                                                bsize = ftell(fp) + 1;
-                                               for(iter = obj->data.tail.wantedlines; iter > 0; iter--) {
+                                               for (iter = obj->data.tail.wantedlines; iter > 0;
+                                                               iter--) {
                                                        nl = rev_fcharfind(fp, '\n', iter);
-                                                       if(nl >= 0)
+                                                       if (nl >= 0) {
                                                                break;
+                                                       }
                                                }
                                                obj->data.tail.readlines = iter;
-                                               if(obj->data.tail.readlines < obj->data.tail.wantedlines) {
+                                               if (obj->data.tail.readlines
+                                                               < obj->data.tail.wantedlines) {
                                                        fseek(fp, 0, SEEK_SET);
-                                               }
-                                               else {
-                                                       fseek(fp, nl+1, SEEK_SET);
+                                               } else {
+                                                       fseek(fp, nl + 1, SEEK_SET);
                                                        bsize -= ftell(fp);
                                                }
-                                               /* Make sure bsize is at least 1 byte smaller than
-                                                * the buffer max size. */
-                                               if(bsize > (long)((text_buffer_size*20) - 1)) {
-                                                       fseek(fp, bsize - text_buffer_size*20 - 1, SEEK_CUR);
-                                                       bsize = text_buffer_size*20 - 1;
+                                               /* Make sure bsize is at least 1 byte smaller than the
+                                                * buffer max size. */
+                                               if (bsize > (long) ((text_buffer_size * 20) - 1)) {
+                                                       fseek(fp, bsize - text_buffer_size * 20 - 1,
+                                                               SEEK_CUR);
+                                                       bsize = text_buffer_size * 20 - 1;
                                                }
                                                bsize = fread(obj->data.tail.buffer, 1, bsize, fp);
                                                fclose(fp);
-                                               if(bsize > 0) {
-                                                       /* Clean up trailing newline, make sure the buffer
-                                                        * is null terminated. */
-                                                       if(obj->data.tail.buffer[bsize-1] == '\n')
-                                                               obj->data.tail.buffer[bsize-1] = '\0';
-                                                       else
+                                               if (bsize > 0) {
+                                                       /* Clean up trailing newline, make sure the
+                                                        * buffer is null terminated. */
+                                                       if (obj->data.tail.buffer[bsize - 1] == '\n') {
+                                                               obj->data.tail.buffer[bsize - 1] = '\0';
+                                                       } else {
                                                                obj->data.tail.buffer[bsize] = '\0';
-                                                       snprintf(p, p_max_size, "%s", obj->data.tail.buffer);
-                                               }
-                                               else {
+                                                       }
+                                                       snprintf(p, p_max_size, "%s",
+                                                               obj->data.tail.buffer);
+                                               } else {
                                                        strcpy(obj->data.tail.buffer, "Logfile Empty");
                                                        snprintf(p, p_max_size, "Logfile Empty");
-                                               } /* bsize > 0 */
-                                       } /*  fp == NULL  */
-                               } /* if cur_upd_time >= */
-
-                               //parse_conky_vars(obj->data.tail.buffer, p, cur);
-
+                                               }       /* bsize > 0 */
+                                       }               /* fp == NULL */
+                               }                       /* if cur_upd_time >= */
+                               // parse_conky_vars(obj->data.tail.buffer, p, cur);
                        }
+
 head:
                        OBJ(head) {
-                               if (current_update_time -obj->data.tail.last_update < obj->data.tail.interval) {
+                               if (current_update_time - obj->data.tail.last_update
+                                               < obj->data.tail.interval) {
                                        snprintf(p, p_max_size, "%s", obj->data.tail.buffer);
                                } else {
                                        obj->data.tail.last_update = current_update_time;
                                        FILE *fp;
-                                       long nl=0;
+                                       long nl = 0;
                                        int iter;
+
                                        fp = fopen(obj->data.tail.logfile, "rt");
                                        if (fp == NULL) {
-                                               /* Send one message, but do not consistently spam on
-                                                * missing logfiles. */
-                                               if(obj->data.tail.readlines != 0) {
+                                               /* Send one message, but do not consistently spam
+                                                * on missing logfiles. */
+                                               if (obj->data.tail.readlines != 0) {
                                                        ERR("head logfile failed to open");
                                                        strcpy(obj->data.tail.buffer, "Logfile Missing");
                                                }
@@ -5486,59 +5676,58 @@ head:
                                                snprintf(p, p_max_size, "Logfile Missing");
                                        } else {
                                                obj->data.tail.readlines = 0;
-                                               for(iter = obj->data.tail.wantedlines; iter > 0; iter--) {
+                                               for (iter = obj->data.tail.wantedlines; iter > 0;
+                                                               iter--) {
                                                        nl = fwd_fcharfind(fp, '\n', iter);
-                                                       if(nl >= 0)
+                                                       if (nl >= 0) {
                                                                break;
+                                                       }
                                                }
                                                obj->data.tail.readlines = iter;
-                                               /* Make sure nl is at least 1 byte smaller than
-                                                * the buffer max size. */
-                                               if(nl > (long)((text_buffer_size*20) - 1)) {
-                                                       nl = text_buffer_size*20 - 1;
+                                               /* Make sure nl is at least 1 byte smaller than the
+                                                * buffer max size. */
+                                               if (nl > (long) ((text_buffer_size * 20) - 1)) {
+                                                       nl = text_buffer_size * 20 - 1;
                                                }
                                                nl = fread(obj->data.tail.buffer, 1, nl, fp);
                                                fclose(fp);
-                                               if(nl > 0) {
+                                               if (nl > 0) {
                                                        /* Clean up trailing newline, make sure the buffer
                                                         * is null terminated. */
-                                                       if (obj->data.tail.buffer[nl-1] == '\n') {
-                                                               obj->data.tail.buffer[nl-1] = '\0';
-                                                       }
-                                                       else {
+                                                       if (obj->data.tail.buffer[nl - 1] == '\n') {
+                                                               obj->data.tail.buffer[nl - 1] = '\0';
+                                                       } else {
                                                                obj->data.tail.buffer[nl] = '\0';
                                                        }
-                                                       snprintf(p, p_max_size, "%s", obj->data.tail.buffer);
-                                               } 
-                                               else {
+                                                       snprintf(p, p_max_size, "%s",
+                                                               obj->data.tail.buffer);
+                                               } else {
                                                        strcpy(obj->data.tail.buffer, "Logfile Empty");
                                                        snprintf(p, p_max_size, "Logfile Empty");
-                                               } /* nl > 0 */
-                                       } /* if fp == null */
-                               } /* cur_upd_time >= */
-
-                               //parse_conky_vars(obj->data.tail.buffer, p, cur);
-
+                                               }       /* nl > 0 */
+                                       }               /* if fp == null */
+                               }                       /* cur_upd_time >= */
+                               // parse_conky_vars(obj->data.tail.buffer, p, cur);
                        }
+
 #ifdef TCP_PORT_MONITOR
-                       OBJ(tcp_portmon)
-                       {
+                       OBJ(tcp_portmon) {
                                /* grab a pointer to this port monitor */
-                               tcp_port_monitor_t * p_monitor = 
-                                       find_tcp_port_monitor( info.p_tcp_port_monitor_collection,
-                                                               obj->data.tcp_port_monitor.port_range_begin,
-                                                               obj->data.tcp_port_monitor.port_range_end );
-                               if ( !p_monitor ) {
+                               tcp_port_monitor_t *p_monitor =
+                                       find_tcp_port_monitor(info.p_tcp_port_monitor_collection,
+                                       obj->data.tcp_port_monitor.port_range_begin,
+                                       obj->data.tcp_port_monitor.port_range_end);
+
+                               if (!p_monitor) {
                                        snprintf(p, p_max_size, "monitor not found");
                                        break;
                                }
 
                                /* now grab the text of interest */
-                               if ( peek_tcp_port_monitor( p_monitor, 
-                                                           obj->data.tcp_port_monitor.item, 
-                                                           obj->data.tcp_port_monitor.connection_index,
-                                                           p, p_max_size ) != 0 )
-                               {
+                               if (peek_tcp_port_monitor(p_monitor,
+                                               obj->data.tcp_port_monitor.item,
+                                               obj->data.tcp_port_monitor.connection_index, p,
+                                               p_max_size) != 0) {
                                        snprintf(p, p_max_size, "monitor peek error");
                                        break;
                                }
@@ -5546,34 +5735,29 @@ head:
 #endif
 
 #ifdef HAVE_ICONV
-                       OBJ(iconv_start)
-                       {
+                       OBJ(iconv_start) {
                                iconv_converting = 1;
                                iconv_selected = obj->a;
-                               
                        }
-                       OBJ(iconv_stop)
-                       {
+                       OBJ(iconv_stop) {
                                iconv_converting = 0;
                                iconv_selected = 0;
                        }
 #endif
-                       OBJ(entropy_avail) 
-                       {
-                               snprintf(p, p_max_size, "%d", cur->entropy.entropy_avail);
+
+                       OBJ(entropy_avail) {
+                               snprintf(p, p_max_size, "%d", cur->entropy.entropy_avail);
                        }
-                       OBJ(entropy_poolsize)
-                       {
+                       OBJ(entropy_poolsize) {
                                snprintf(p, p_max_size, "%d", cur->entropy.poolsize);
                        }
-                       OBJ(entropy_bar)
-                       {
+                       OBJ(entropy_bar) {
                                double entropy_perc;
-                               entropy_perc = (double)cur->entropy.entropy_avail / 
-                                              (double)cur->entropy.poolsize;
-                               new_bar(p,obj->a,obj->b,(int)(entropy_perc * 255.0f));
-                       }
 
+                               entropy_perc = (double) cur->entropy.entropy_avail /
+                                       (double) cur->entropy.poolsize;
+                               new_bar(p, obj->a, obj->b, (int) (entropy_perc * 255.0f));
+                       }
 
                        break;
                }
@@ -5582,26 +5766,29 @@ head:
                        unsigned int a = strlen(p);
 
 #ifdef HAVE_ICONV
-                       if (a > 0 && iconv_converting && iconv_selected > 0 && (iconv_cd[iconv_selected - 1] != (iconv_t)(-1))) {
+                       if (a > 0 && iconv_converting && iconv_selected > 0
+                                       && (iconv_cd[iconv_selected - 1] != (iconv_t) (-1))) {
                                int bytes;
                                size_t dummy1, dummy2;
                                char *ptr = buff_in;
                                char *outptr = p;
 
                                dummy1 = dummy2 = a;
-                               
+
                                strncpy(buff_in, p, P_MAX_SIZE);
 
                                iconv(*iconv_cd[iconv_selected - 1], NULL, NULL, NULL, NULL);
                                while (dummy1 > 0) {
-                                       bytes = iconv(*iconv_cd[iconv_selected - 1], &ptr, &dummy1, &outptr, &dummy2);
+                                       bytes = iconv(*iconv_cd[iconv_selected - 1], &ptr, &dummy1,
+                                               &outptr, &dummy2);
                                        if (bytes == -1) {
                                                ERR("Iconv codeset conversion failed");
                                                break;
                                        }
                                }
 
-                               /* It is nessecary when we are converting from multibyte to singlebyte codepage */
+                               /* It is nessecary when we are converting from multibyte to
+                                * singlebyte codepage */
                                a = outptr - p;
                        }
 #endif
@@ -5611,7 +5798,6 @@ head:
        }
 }
 
-
 double current_update_time, last_update_time;
 
 static void generate_text()
@@ -5619,7 +5805,6 @@ static void generate_text()
        struct information *cur = &info;
        char *p;
 
-
        special_count = 0;
 
        /* update info */
@@ -5631,7 +5816,6 @@ static void generate_text()
        diskio_read_value = diskio_read_value / update_interval;
        diskio_write_value = diskio_write_value / update_interval;
        diskio_value = diskio_value / update_interval;
-       
 
        /* add things to the buffer */
 
@@ -5651,31 +5835,26 @@ static void generate_text()
                }
        }
 
-
        last_update_time = current_update_time;
        total_updates++;
-       //free(p);
+       // free(p);
 }
 
-
 #ifdef X11
 static void set_font()
 {
 #ifdef XFT
        if (use_xft) {
-                       if (window.xftdraw != NULL) {
-                               XftDrawDestroy(window.xftdraw);
-                       }
-                       window.xftdraw = XftDrawCreate(display, window.drawable,
-                                       DefaultVisual(display,
-                                                       screen),
-                                       DefaultColormap(display,
-                                                       screen));
-               } else
+               if (window.xftdraw != NULL) {
+                       XftDrawDestroy(window.xftdraw);
+               }
+               window.xftdraw = XftDrawCreate(display, window.drawable,
+                       DefaultVisual(display, screen), DefaultColormap(display, screen));
+       } else
 #endif
-{
-       XSetFont(display, window.gc, fonts[selected_font].font->fid);
-}
+       {
+               XSetFont(display, window.gc, fonts[selected_font].font->fid);
+       }
 }
 
 #endif /* X11 */
@@ -5696,19 +5875,23 @@ static inline int get_string_width_special(char *s)
        }
 #ifdef X11
        char *p, *final;
+
        p = strdup(s);
        final = p;
        int index = 1;
        int width = 0;
        unsigned int i;
+
        while (*p) {
                if (*p == SPECIAL_CHAR) {
-                       /* shift everything over by 1 so that the special char doesn't mess up the size calculation */
+                       /* shift everything over by 1 so that the special char
+                        * doesn't mess up the size calculation */
                        for (i = 0; i < strlen(p); i++) {
                                *(p + i) = *(p + i + 1);
                        }
-                       if (specials[special_index+index].type == GRAPH || specials[special_index+index].type == BAR) {
-                               width += specials[special_index+index].width;
+                       if (specials[special_index + index].type == GRAPH
+                                       || specials[special_index + index].type == BAR) {
+                               width += specials[special_index + index].width;
                        }
                        index++;
                } else {
@@ -5744,43 +5927,45 @@ static void update_text_area()
                last_font_height = font_height();
                for_each_line(text_buffer, text_size_updater);
                text_width += 1;
-               if (text_height < minimum_height)
+               if (text_height < minimum_height) {
                        text_height = minimum_height;
-               if (text_width > maximum_width && maximum_width > 0)
+               }
+               if (text_width > maximum_width && maximum_width > 0) {
                        text_width = maximum_width;
+               }
        }
 
        /* get text position on workarea */
        switch (text_alignment) {
-       case TOP_LEFT:
-               x = gap_x;
-               y = gap_y;
-               break;
-
-       case TOP_RIGHT:
-               x = workarea[2] - text_width - gap_x;
-               y = gap_y;
-               break;
-
-       default:
-       case BOTTOM_LEFT:
-               x = gap_x;
-               y = workarea[3] - text_height - gap_y;
-               break;
-
-       case BOTTOM_RIGHT:
-               x = workarea[2] - text_width - gap_x;
-               y = workarea[3] - text_height - gap_y;
-               break;
-       
+               case TOP_LEFT:
+                       x = gap_x;
+                       y = gap_y;
+                       break;
+
+               case TOP_RIGHT:
+                       x = workarea[2] - text_width - gap_x;
+                       y = gap_y;
+                       break;
+
+               default:
+               case BOTTOM_LEFT:
+                       x = gap_x;
+                       y = workarea[3] - text_height - gap_y;
+                       break;
+
+               case BOTTOM_RIGHT:
+                       x = workarea[2] - text_width - gap_x;
+                       y = workarea[3] - text_height - gap_y;
+                       break;
+
 #ifdef OWN_WINDOW
-       case NONE: // Let the WM manage the window
-               x = window.x;
-               y = window.y;
+               case NONE:      // Let the WM manage the window
+                       x = window.x;
+                       y = window.y;
 
-               fixed_pos  = 1;
-               fixed_size = 1;
-               break;
+                       fixed_pos = 1;
+                       fixed_size = 1;
+                       break;
 #endif
        }
 #ifdef OWN_WINDOW
@@ -5795,11 +5980,10 @@ static void update_text_area()
        } else
 #endif
        {
-               /* If window size doesn't match to workarea's size, then window
-                * probably includes panels (gnome).
+               /* If window size doesn't match to workarea's size,
+                * then window probably includes panels (gnome).
                 * Blah, doesn't work on KDE. */
-               if (workarea[2] != window.width
-                   || workarea[3] != window.height) {
+               if (workarea[2] != window.width || workarea[3] != window.height) {
                        y += workarea[1];
                        x += workarea[0];
                }
@@ -5809,9 +5993,7 @@ static void update_text_area()
        }
 }
 
-/*
- * drawing stuff
- */
+/* drawing stuff */
 
 static int cur_x, cur_y;       /* current x and y for drawing */
 static int draw_mode;          /* FG, BG or OUTLINE */
@@ -5822,6 +6004,7 @@ static void text_size_updater(char *s)
 {
        int w = 0;
        char *p;
+
        /* get string widths and skip specials */
        p = s;
        while (*p) {
@@ -5831,7 +6014,7 @@ static void text_size_updater(char *s)
                        *p = SPECIAL_CHAR;
 
                        if (specials[special_index].type == BAR
-                           || specials[special_index].type == GRAPH) {
+                                       || specials[special_index].type == GRAPH) {
                                w += specials[special_index].width;
                                if (specials[special_index].height > last_font_height) {
                                        last_font_height = specials[special_index].height;
@@ -5845,13 +6028,15 @@ static void text_size_updater(char *s)
                                last_font_height += specials[special_index].arg;
                        } else if (specials[special_index].type == GOTO) {
                                if (specials[special_index].arg > cur_x) {
-                                       w = (int)specials[special_index].arg;
+                                       w = (int) specials[special_index].arg;
                                }
-                       } else if (specials[special_index].type == TAB) { 
-                               int start = specials[special_index].arg;
+                       } else if (specials[special_index].type == TAB) {
+                               int start = specials[special_index].arg;
                                int step = specials[special_index].width;
-                               if (!step || step < 0)
+
+                               if (!step || step < 0) {
                                        step = 10;
+                               }
                                w += step - (cur_x - text_start_x - start) % step;
                        } else if (specials[special_index].type == FONT) {
                                selected_font = specials[special_index].font_added;
@@ -5859,7 +6044,7 @@ static void text_size_updater(char *s)
                                        last_font_height = font_height();
                                }
                        }
-                       
+
                        special_index++;
                        s = p + 1;
                }
@@ -5887,63 +6072,62 @@ static inline void set_foreground_color(long c)
 
 static void draw_string(const char *s)
 {
-       if (s[0] == '\0')
+       if (s[0] == '\0') {
                return;
+       }
        int i, i2, pos, width_of_s;
-       int max=0;
+       int max = 0;
        int added;
+
        width_of_s = get_string_width(s);
        if (out_to_console) {
                printf("%s\n", s);
-               fflush(stdout);   /* output immediately, don't buffer */
+               fflush(stdout); /* output immediately, don't buffer */
        }
-       memset(tmpstring1,0,TEXT_BUFFER_SIZE);
-       memset(tmpstring2,0,TEXT_BUFFER_SIZE);
-       strncpy(tmpstring1, s, TEXT_BUFFER_SIZE-1);
+       memset(tmpstring1, 0, TEXT_BUFFER_SIZE);
+       memset(tmpstring2, 0, TEXT_BUFFER_SIZE);
+       strncpy(tmpstring1, s, TEXT_BUFFER_SIZE - 1);
        pos = 0;
        added = 0;
        char space[2];
+
        snprintf(space, 2, " ");
 #ifdef X11
        max = ((text_width - width_of_s) / get_string_width(space));
 #endif /* X11 */
-       /*
-        * This code looks for tabs in the text and coverts them to spaces.
-        * The trick is getting the correct number of spaces,
-        * and not going over the window's size without forcing
-        * the window larger.
-        */
+       /* This code looks for tabs in the text and coverts them to spaces.
+        * The trick is getting the correct number of spaces, and not going
+        * over the window's size without forcing the window larger. */
        for (i = 0; i < TEXT_BUFFER_SIZE; i++) {
-               if (tmpstring1[i] == '\t')      // 9 is ascii tab
-               {
+               if (tmpstring1[i] == '\t') {    // 9 is ascii tab
                        i2 = 0;
-                       for (i2 = 0;
-                            i2 < (8 - (1 + pos) % 8) && added <= max;
-                            i2++) {
-                               /*
-                               if ( pos + i2 > TEXT_BUFFER_SIZE-1 )
-                                       fprintf(stderr,"buffer overrun detected\n");
-                               */
-                               tmpstring2[ MIN(pos + i2, TEXT_BUFFER_SIZE-1) ] = ' '; /* guard against overrun */
+                       for (i2 = 0; i2 < (8 - (1 + pos) % 8) && added <= max; i2++) {
+                               /* if (pos + i2 > TEXT_BUFFER_SIZE - 1) {
+                                       fprintf(stderr, "buffer overrun detected\n");
+                               } */
+                               /* guard against overrun */
+                               tmpstring2[MIN(pos + i2, TEXT_BUFFER_SIZE - 1)] = ' ';
                                added++;
                        }
                        pos += i2;
                } else {
                        if (tmpstring1[i] != 9) {
-                               /*
-                               if ( pos > TEXT_BUFFER_SIZE-1 )
-                                        fprintf(stderr,"buffer overrun detected\n");
-                               */
-                               tmpstring2[ MIN(pos, TEXT_BUFFER_SIZE-1) ] = tmpstring1[i]; /* guard against overrun */
+                               /* if (pos > TEXT_BUFFER_SIZE - 1) {
+                                       fprintf(stderr, "buffer overrun detected\n");
+                               } */
+                               /* guard against overrun */
+                               tmpstring2[MIN(pos, TEXT_BUFFER_SIZE - 1)] = tmpstring1[i];
                                pos++;
                        }
                }
        }
 #ifdef X11
        if (text_width == maximum_width) {
-               /* this means the text is probably pushing the limit, so we'll chop it */
-               while (cur_x + get_string_width(tmpstring2) - text_start_x > maximum_width && strlen(tmpstring2) > 0) {
-                       tmpstring2[strlen(tmpstring2)-1] = '\0';
+               /* this means the text is probably pushing the limit,
+                * so we'll chop it */
+               while (cur_x + get_string_width(tmpstring2) - text_start_x
+                               > maximum_width && strlen(tmpstring2) > 0) {
+                       tmpstring2[strlen(tmpstring2) - 1] = '\0';
                }
        }
 #endif /* X11 */
@@ -5953,6 +6137,7 @@ static void draw_string(const char *s)
        if (use_xft) {
                XColor c;
                XftColor c2;
+
                c.pixel = current_color;
                XQueryColor(display, DefaultColormap(display, screen), &c);
 
@@ -5963,18 +6148,16 @@ static void draw_string(const char *s)
                c2.color.alpha = fonts[selected_font].font_alpha;
                if (utf8_mode) {
                        XftDrawStringUtf8(window.xftdraw, &c2, fonts[selected_font].xftfont,
-                                         cur_x, cur_y, (XftChar8 *) s,
-                                         strlen(s));
+                               cur_x, cur_y, (XftChar8 *) s, strlen(s));
                } else {
                        XftDrawString8(window.xftdraw, &c2, fonts[selected_font].xftfont,
-                                      cur_x, cur_y, (XftChar8 *) s,
-                                      strlen(s));
+                               cur_x, cur_y, (XftChar8 *) s, strlen(s));
                }
        } else
 #endif
        {
-               XDrawString(display, window.drawable, window.gc,
-                           cur_x, cur_y, s, strlen(s));
+               XDrawString(display, window.drawable, window.gc, cur_x, cur_y, s,
+                       strlen(s));
        }
        cur_x += width_of_s;
 #endif /* X11 */
@@ -5991,31 +6174,37 @@ void set_up_gradient()
        colour_depth = 16;
 #endif /* X11 */
        if (colour_depth != 24 && colour_depth != 16) {
-               ERR("using non-standard colour depth, gradients may look like a lolly-pop");
+               ERR("using non-standard colour depth, gradients may look like a "
+                       "lolly-pop");
        }
        int i;
+
        redmask = 0;
        greenmask = 0;
        bluemask = 0;
-       for(i = (colour_depth / 3)-1; i>=0; i--) {
+       for (i = (colour_depth / 3) - 1; i >= 0; i--) {
                redmask |= 1 << i;
                greenmask |= 1 << i;
                bluemask |= 1 << i;
        }
-       if (colour_depth%3 == 1) {
+       if (colour_depth % 3 == 1) {
                greenmask |= 1 << (colour_depth / 3);
        }
-       redmask = redmask << (2*colour_depth / 3 + colour_depth%3);
+       redmask = redmask << (2 * colour_depth / 3 + colour_depth % 3);
        greenmask = greenmask << (colour_depth / 3);
 }
 
-inline unsigned long do_gradient(unsigned long first_colour, unsigned long last_colour) { /* this function returns the next colour between two colours for a gradient */
+/* this function returns the next colour between two colours for a gradient */
+inline unsigned long do_gradient(unsigned long first_colour,
+               unsigned long last_colour)
+{
        int tmp_color = 0;
-       int red1, green1, blue1; // first colour
-       int red2, green2, blue2; // second colour
-       int red3 = 0, green3 = 0, blue3 = 0; // difference
-       short redshift = (2*colour_depth / 3 + colour_depth%3);
+       int red1, green1, blue1;                                // first colour
+       int red2, green2, blue2;                                // second colour
+       int red3 = 0, green3 = 0, blue3 = 0;    // difference
+       short redshift = (2 * colour_depth / 3 + colour_depth % 3);
        short greenshift = (colour_depth / 3);
+
        red1 = (first_colour & redmask) >> redshift;
        green1 = (first_colour & greenmask) >> greenshift;
        blue1 = first_colour & bluemask;
@@ -6065,15 +6254,19 @@ inline unsigned long do_gradient(unsigned long first_colour, unsigned long last_
        return tmp_color;
 }
 
-inline unsigned long gradient_max(unsigned long first_colour, unsigned long last_colour) { /* this function returns the max diff for a gradient */
+/* this function returns the max diff for a gradient */
+inline unsigned long gradient_max(unsigned long first_colour,
+               unsigned long last_colour)
+{
        if (colour_depth == 0) {
                set_up_gradient();
        }
-       int red1, green1, blue1; // first colour
-       int red2, green2, blue2; // second colour
-       long redshift = (2*colour_depth / 3 + colour_depth%3);
+       int red1, green1, blue1;                                // first colour
+       int red2, green2, blue2;                                // second colour
+       long redshift = (2 * colour_depth / 3 + colour_depth % 3);
        long greenshift = (colour_depth / 3);
-       int red3 = 0, green3 = 0, blue3 = 0; // difference
+       int red3 = 0, green3 = 0, blue3 = 0;    // difference
+
        red1 = (first_colour & redmask) >> redshift;
        green1 = (first_colour & greenmask) >> greenshift;
        blue1 = first_colour & bluemask;
@@ -6084,10 +6277,13 @@ inline unsigned long gradient_max(unsigned long first_colour, unsigned long last
        green3 = abs(green1 - green2);
        blue3 = abs(blue1 - blue2);
        int max = red3;
-       if (green3 > max)
+
+       if (green3 > max) {
                max = green3;
-       if (blue3 > max)
+       }
+       if (blue3 > max) {
                max = blue3;
+       }
        return max;
 }
 
@@ -6095,6 +6291,7 @@ static void draw_line(char *s)
 {
 #ifdef X11
        char *p;
+
        cur_x = text_start_x;
        cur_y += font_ascent();
        int cur_y_add = 0;
@@ -6114,174 +6311,155 @@ static void draw_line(char *s)
 
                        /* draw special */
                        switch (specials[special_index].type) {
-                       case HORIZONTAL_LINE:
+                               case HORIZONTAL_LINE:
                                {
-                                       int h =
-                                           specials[special_index].height;
+                                       int h = specials[special_index].height;
                                        int mid = font_ascent() / 2;
-                                       w = text_start_x + text_width -
-                                           cur_x;
-
-                                       XSetLineAttributes(display,
-                                                          window.gc, h,
-                                                          LineSolid,
-                                                          CapButt,
-                                                          JoinMiter);
-                                       XDrawLine(display, window.drawable,
-                                                 window.gc, cur_x,
-                                                 cur_y - mid / 2,
-                                                 cur_x + w,
-                                                 cur_y - mid / 2);
+
+                                       w = text_start_x + text_width - cur_x;
+
+                                       XSetLineAttributes(display, window.gc, h, LineSolid,
+                                               CapButt, JoinMiter);
+                                       XDrawLine(display, window.drawable, window.gc, cur_x,
+                                               cur_y - mid / 2, cur_x + w, cur_y - mid / 2);
+                                       break;
                                }
-                               break;
 
-                       case STIPPLED_HR:
+                               case STIPPLED_HR:
                                {
-                                       int h =
-                                           specials[special_index].height;
-                                       int s =
-                                           specials[special_index].arg;
+                                       int h = specials[special_index].height;
+                                       int s = specials[special_index].arg;
                                        int mid = font_ascent() / 2;
                                        char ss[2] = { s, s };
-                                       w = text_start_x + text_width -
-                                           cur_x - 1;
-
-                                       XSetLineAttributes(display,
-                                                          window.gc, h,
-                                                          LineOnOffDash,
-                                                          CapButt,
-                                                          JoinMiter);
-                                       XSetDashes(display, window.gc, 0,
-                                                  ss, 2);
-                                       XDrawLine(display, window.drawable,
-                                                 window.gc, cur_x,
-                                                 cur_y - mid / 2,
-                                                 cur_x + w,
-                                                 cur_y - mid / 2);
+
+                                       w = text_start_x + text_width - cur_x - 1;
+                                       XSetLineAttributes(display, window.gc, h, LineOnOffDash,
+                                               CapButt, JoinMiter);
+                                       XSetDashes(display, window.gc, 0, ss, 2);
+                                       XDrawLine(display, window.drawable, window.gc, cur_x,
+                                               cur_y - mid / 2, cur_x + w, cur_y - mid / 2);
+                                       break;
                                }
-                               break;
 
-                       case BAR:
+                               case BAR:
                                {
-                                       if (cur_x - text_start_x > maximum_width && maximum_width > 0) {
+                                       if (cur_x - text_start_x > maximum_width
+                                                       && maximum_width > 0) {
                                                break;
                                        }
-                                       int h =
-                                           specials[special_index].height;
-                                       int bar_usage =
-                                           specials[special_index].arg;
+                                       int h = specials[special_index].height;
+                                       int bar_usage = specials[special_index].arg;
                                        int by = cur_y - (font_ascent() / 2) - 1;
+
                                        if (h < font_height()) {
                                                by -= h / 2 - 1;
                                        }
                                        w = specials[special_index].width;
-                                       if (w == 0)
-                                               w = text_start_x +
-                                                   text_width - cur_x - 1;
-                                       if (w < 0)
+                                       if (w == 0) {
+                                               w = text_start_x + text_width - cur_x - 1;
+                                       }
+                                       if (w < 0) {
                                                w = 0;
+                                       }
 
-                                       XSetLineAttributes(display,
-                                                          window.gc, 1,
-                                                          LineSolid,
-                                                          CapButt,
-                                                          JoinMiter);
-
-                                       XDrawRectangle(display,
-                                                      window.drawable,
-                                                      window.gc, cur_x,
-                                                      by, w, h);
-                                       XFillRectangle(display,
-                                                      window.drawable,
-                                                      window.gc, cur_x,
-                                                      by,
-                                                      w * bar_usage / 255,
-                                                      h);
-                                       if (specials[special_index].
-                                           height > cur_y_add
-                                           && specials[special_index].
-                                           height > font_h) {
-                                               cur_y_add =
-                                                   specials
-                                                   [special_index].height;
+                                       XSetLineAttributes(display, window.gc, 1, LineSolid,
+                                               CapButt, JoinMiter);
+
+                                       XDrawRectangle(display, window.drawable, window.gc, cur_x,
+                                               by, w, h);
+                                       XFillRectangle(display, window.drawable, window.gc, cur_x,
+                                               by, w * bar_usage / 255, h);
+                                       if (specials[special_index].height > cur_y_add
+                                                       && specials[special_index].height > font_h) {
+                                               cur_y_add = specials[special_index].height;
                                        }
+                                       break;
                                }
-                               break;
 
-                       case GRAPH:
-                       {
-                                       if (cur_x - text_start_x > maximum_width && maximum_width > 0) {
+                               case GRAPH:
+                               {
+                                       if (cur_x - text_start_x > maximum_width
+                                                       && maximum_width > 0) {
                                                break;
                                        }
-                                       int h =
-                                           specials[special_index].height;
+                                       int h = specials[special_index].height;
                                        unsigned long last_colour = current_color;
-                                       int by = cur_y - (font_ascent()/2) - 1;
+                                       int by = cur_y - (font_ascent() / 2) - 1;
+
                                        if (h < font_height()) {
                                                by -= h / 2 - 1;
                                        }
                                        w = specials[special_index].width;
-                                       if (w == 0)
+                                       if (w == 0) {
                                                w = text_start_x + text_width - cur_x - 1;
-                                       if (w < 0)
+                                       }
+                                       if (w < 0) {
                                                w = 0;
+                                       }
                                        if (draw_graph_borders) {
-                                               XSetLineAttributes(display, window.gc, 1, LineSolid, CapButt, JoinMiter);
-                                               XDrawRectangle(display,window.drawable, window.gc, cur_x, by, w, h);
+                                               XSetLineAttributes(display, window.gc, 1, LineSolid,
+                                                       CapButt, JoinMiter);
+                                               XDrawRectangle(display, window.drawable, window.gc,
+                                                       cur_x, by, w, h);
                                        }
-                                       XSetLineAttributes(display,
-                                                          window.gc, 1,
-                                                          LineSolid,
-                                                          CapButt,
-                                                          JoinMiter);
-       int i;
-       int j = 0;
-       int gradient_size = 0;
-       float gradient_factor = 0;
-       float gradient_update = 0;
-       unsigned long tmpcolour = current_color;
-       if (specials[special_index].last_colour != 0 || specials[special_index].first_colour != 0) {
-               tmpcolour = specials[special_index].last_colour;
-               gradient_size = gradient_max(specials[special_index].last_colour, specials[special_index].first_colour);
-               gradient_factor = (float)gradient_size / (w - 2);
-       }
-       for (i = w - 2; i > -1; i--) {
-               if (specials[special_index].last_colour != 0 || specials[special_index].first_colour != 0) {
-                       XSetForeground(display, window.gc, tmpcolour);
-                       gradient_update += gradient_factor;
-                       while (gradient_update > 0) {
-                               tmpcolour = do_gradient(tmpcolour, specials[special_index].first_colour);
-                               gradient_update--;
-                       }
-               }
-               if ((w - i) / ((float) (w - 2) / (specials[special_index].graph_width)) > j && j < MAX_GRAPH_DEPTH - 3) {
-                       j++;
-               }
-                                               XDrawLine(display,  window.drawable, window.gc, cur_x + i + 1, by + h, cur_x + i + 1, by + h - specials[special_index].graph[j] * (h - 1) / specials[special_index].graph_scale);       /* this is mugfugly, but it works */
+                                       XSetLineAttributes(display, window.gc, 1, LineSolid,
+                                               CapButt, JoinMiter);
+                                       int i;
+                                       int j = 0;
+                                       int gradient_size = 0;
+                                       float gradient_factor = 0;
+                                       float gradient_update = 0;
+                                       unsigned long tmpcolour = current_color;
+
+                                       if (specials[special_index].last_colour != 0
+                                                       || specials[special_index].first_colour != 0) {
+                                               tmpcolour = specials[special_index].last_colour;
+                                               gradient_size =
+                                                       gradient_max(specials[special_index].last_colour,
+                                                       specials[special_index].first_colour);
+                                               gradient_factor = (float) gradient_size / (w - 2);
+                                       }
+                                       for (i = w - 2; i > -1; i--) {
+                                               if (specials[special_index].last_colour != 0
+                                                               || specials[special_index].first_colour != 0) {
+                                                       XSetForeground(display, window.gc, tmpcolour);
+                                                       gradient_update += gradient_factor;
+                                                       while (gradient_update > 0) {
+                                                               tmpcolour = do_gradient(tmpcolour,
+                                                                       specials[special_index].first_colour);
+                                                               gradient_update--;
+                                                       }
+                                               }
+                                               if ((w - i) / ((float) (w - 2) /
+                                                               (specials[special_index].graph_width)) > j
+                                                               && j < MAX_GRAPH_DEPTH - 3) {
+                                                       j++;
+                                               }
+                                               /* this is mugfugly, but it works */
+                                               XDrawLine(display, window.drawable, window.gc,
+                                                       cur_x + i + 1, by + h, cur_x + i + 1,
+                                                       by + h - specials[special_index].graph[j] *
+                                                       (h - 1) / specials[special_index].graph_scale);
                                        }
-                                       if (specials[special_index].
-                                           height > cur_y_add
-                                           && specials[special_index].
-                                           height > font_h) {
-                                               cur_y_add =
-                                                   specials
-                                                   [special_index].height;
+                                       if (specials[special_index].height > cur_y_add
+                                                       && specials[special_index].height > font_h) {
+                                               cur_y_add = specials[special_index].height;
                                        }
-/*                             if (draw_mode == BG) {
-                                       set_foreground_color(default_bg_color);
+                                       /* if (draw_mode == BG) {
+                                               set_foreground_color(default_bg_color);
+                                       } else if (draw_mode == OUTLINE) {
+                                               set_foreground_color(default_out_color);
+                                       } else {
+                                               set_foreground_color(default_fg_color);
+                                       } */
+                                       set_foreground_color(last_colour);
+                                       break;
                                }
-                               else if (draw_mode == OUTLINE) {
-                                       set_foreground_color(default_out_color);
-                               } else {
-                                       set_foreground_color(default_fg_color);
-                               }*/
-                               set_foreground_color(last_colour);
-                       }
-                               break;
-                       
+
                                case FONT:
                                {
                                        int old = font_ascent();
+
                                        cur_y -= font_ascent();
                                        selected_font = specials[special_index].font_added;
                                        if (cur_y + font_ascent() < cur_y + old) {
@@ -6290,75 +6468,89 @@ static void draw_line(char *s)
                                                cur_y += font_ascent();
                                        }
                                        set_font();
+                                       break;
                                }
-                               break;
-                       case FG:
-                               if (draw_mode == FG)
-                                       set_foreground_color(specials
-                                                            [special_index].
-                                                            arg);
-                               break;
+                               case FG:
+                                       if (draw_mode == FG) {
+                                               set_foreground_color(specials[special_index].arg);
+                                       }
+                                       break;
 
-                       case BG:
-                               if (draw_mode == BG)
-                                       set_foreground_color(specials
-                                                            [special_index].
-                                                            arg);
-                               break;
+                               case BG:
+                                       if (draw_mode == BG) {
+                                               set_foreground_color(specials[special_index].arg);
+                                       }
+                                       break;
 
-                       case OUTLINE:
-                               if (draw_mode == OUTLINE)
-                                       set_foreground_color(specials
-                                                            [special_index].
-                                                            arg);
-                               break;
+                               case OUTLINE:
+                                       if (draw_mode == OUTLINE) {
+                                               set_foreground_color(specials[special_index].arg);
+                                       }
+                                       break;
 
-                       case OFFSET:
-                               w += specials[special_index].arg;
-                               break;
-               
-                       case VOFFSET:
-                               cur_y += specials[special_index].arg;
-                               break;
+                               case OFFSET:
+                                       w += specials[special_index].arg;
+                                       break;
 
-                       case GOTO:
-                               if (specials[special_index].arg >= 0)
-                                       cur_x = (int)specials[special_index].arg;
-                               break;
+                               case VOFFSET:
+                                       cur_y += specials[special_index].arg;
+                                       break;
+
+                               case GOTO:
+                                       if (specials[special_index].arg >= 0) {
+                                               cur_x = (int) specials[special_index].arg;
+                                       }
+                                       break;
 
-                       case TAB:
+                               case TAB:
                                {
                                        int start = specials[special_index].arg;
                                        int step = specials[special_index].width;
-                                       if (!step || step < 0)
+
+                                       if (!step || step < 0) {
                                                step = 10;
+                                       }
                                        w = step - (cur_x - text_start_x - start) % step;
+                                       break;
                                }
-                               break;
 
-                       case ALIGNR:
+                               case ALIGNR:
                                {
-                                       int pos_x = text_start_x + text_width - get_string_width_special(s) /*+ border_margin*/;
-                                       /*printf("pos_x %i text_start_x %i text_width %i cur_x %i get_string_width(p) %i gap_x %i specials[special_index].arg %i border_margin %i border_width %i\n", pos_x, text_start_x, text_width, cur_x, get_string_width_special(s), gap_x, specials[special_index].arg, border_margin, border_width);*/
+                                       /* TODO: add back in "+ border_margin" to the end of
+                                        * this line? */
+                                       int pos_x = text_start_x + text_width -
+                                               get_string_width_special(s);
+
+                                       /* printf("pos_x %i text_start_x %i text_width %i cur_x %i "
+                                               "get_string_width(p) %i gap_x %i "
+                                               "specials[special_index].arg %i border_margin %i "
+                                               "border_width %i\n", pos_x, text_start_x, text_width,
+                                               cur_x, get_string_width_special(s), gap_x,
+                                               specials[special_index].arg, border_margin,
+                                               border_width); */
                                        if (pos_x > specials[special_index].arg && pos_x > cur_x) {
                                                cur_x = pos_x - specials[special_index].arg;
+                                       }
+                                       break;
                                }
-                               }
-                               break;
 
-                       case ALIGNC:
+                               case ALIGNC:
                                {
-                                       int pos_x = (text_width)/2 - get_string_width_special(s)/2 - (cur_x - text_start_x);
-                                       /*int pos_x = text_start_x + text_width/2 - get_string_width_special(s)/2;*/
-                                       /*printf("pos_x %i text_start_x %i text_width %i cur_x %i get_string_width(p) %i gap_x %i specials[special_index].arg %i\n", pos_x, text_start_x, text_width, cur_x, get_string_width(s), gap_x, specials[special_index].arg);*/
-                                       if (pos_x >
-                                           specials[special_index].arg)
-                                               w = pos_x -
-                                                   specials
-                                                   [special_index].arg;
+                                       int pos_x = (text_width) / 2 - get_string_width_special(s) /
+                                               2 - (cur_x - text_start_x);
+                                       /* int pos_x = text_start_x + text_width / 2 -
+                                               get_string_width_special(s) / 2; */
+
+                                       /* printf("pos_x %i text_start_x %i text_width %i cur_x %i "
+                                               "get_string_width(p) %i gap_x %i "
+                                               "specials[special_index].arg %i\n", pos_x, text_start_x,
+                                               text_width, cur_x, get_string_width(s), gap_x,
+                                               specials[special_index].arg); */
+                                       if (pos_x > specials[special_index].arg) {
+                                               w = pos_x - specials[special_index].arg;
+                                       }
+                                       break;
                                }
-                               break;
-
                        }
 
                        cur_x += w;
@@ -6393,24 +6585,19 @@ static void draw_text()
                unsigned int b = (border_width + 1) / 2;
 
                if (stippled_borders) {
-                       char ss[2] =
-                           { stippled_borders, stippled_borders };
-                       XSetLineAttributes(display, window.gc,
-                                          border_width, LineOnOffDash,
-                                          CapButt, JoinMiter);
+                       char ss[2] = { stippled_borders, stippled_borders };
+                       XSetLineAttributes(display, window.gc, border_width, LineOnOffDash,
+                               CapButt, JoinMiter);
                        XSetDashes(display, window.gc, 0, ss, 2);
                } else {
-                       XSetLineAttributes(display, window.gc,
-                                          border_width, LineSolid,
-                                          CapButt, JoinMiter);
+                       XSetLineAttributes(display, window.gc, border_width, LineSolid,
+                               CapButt, JoinMiter);
                }
 
                XDrawRectangle(display, window.drawable, window.gc,
-                              text_start_x - border_margin + b,
-                              text_start_y - border_margin + b,
-                              text_width + border_margin * 2 - 1 - b * 2,
-                              text_height + border_margin * 2 - 1 -
-                              b * 2);
+                       text_start_x - border_margin + b, text_start_y - border_margin + b,
+                       text_width + border_margin * 2 - 1 - b * 2,
+                       text_height + border_margin * 2 - 1 - b * 2);
        }
 
        /* draw text */
@@ -6436,10 +6623,12 @@ static void draw_stuff()
        if (draw_outline) {
                selected_font = 0;
                int i, j;
-               for (i = -1; i < 2; i++)
+
+               for (i = -1; i < 2; i++) {
                        for (j = -1; j < 2; j++) {
-                               if (i == 0 && j == 0)
+                               if (i == 0 && j == 0) {
                                        continue;
+                               }
                                text_start_x += i;
                                text_start_y += j;
                                set_foreground_color(default_out_color);
@@ -6448,6 +6637,7 @@ static void draw_stuff()
                                text_start_x -= i;
                                text_start_y -= j;
                        }
+               }
        }
 
        set_foreground_color(default_fg_color);
@@ -6458,6 +6648,7 @@ static void draw_stuff()
 #ifdef HAVE_XDBE
        if (use_xdbe) {
                XdbeSwapInfo swap;
+
                swap.swap_window = window.window;
                swap.swap_action = XdbeBackground;
                XdbeSwapBuffers(display, &swap, 1);
@@ -6465,22 +6656,22 @@ static void draw_stuff()
 #endif
 #endif /* X11 */
 }
+
 #ifdef X11
 static void clear_text(int exposures)
 {
 #ifdef HAVE_XDBE
        if (use_xdbe) {
-               return;         /* The swap action is XdbeBackground, which clears */
+               /* The swap action is XdbeBackground, which clears */
+               return;
        } else
 #endif
        {
-       /* there is some extra space for borders and outlines */
-       XClearArea(display, window.window,
-                  text_start_x - border_margin - 1,
-                  text_start_y - border_margin - 1,
-                  text_width + border_margin * 2 + 2,
-                  text_height + border_margin * 2 + 2,
-                  exposures ? True : 0);
+               /* there is some extra space for borders and outlines */
+               XClearArea(display, window.window, text_start_x - border_margin - 1,
+                       text_start_y - border_margin - 1,
+                       text_width + border_margin * 2 + 2,
+                       text_height + border_margin * 2 + 2, exposures ? True : 0);
        }
 }
 #endif /* X11 */
@@ -6500,24 +6691,29 @@ static void update_text()
 static void main_loop()
 {
 #ifdef SIGNAL_BLOCKING
-       sigset_t  newmask, oldmask;
+       sigset_t newmask, oldmask;
 
        sigemptyset(&newmask);
-       sigaddset(&newmask,SIGINT);
-       sigaddset(&newmask,SIGTERM);
-       sigaddset(&newmask,SIGUSR1);
+       sigaddset(&newmask, SIGINT);
+       sigaddset(&newmask, SIGTERM);
+       sigaddset(&newmask, SIGUSR1);
 #endif
 
 #ifdef X11
        Region region = XCreateRegion();
+
 #ifdef HAVE_XDAMAGE
        int event_base, error_base;
-       if (!XDamageQueryExtension (display, &event_base, &error_base)) {
+
+       if (!XDamageQueryExtension(display, &event_base, &error_base)) {
                ERR("Xdamage extension unavailable");
        }
-       Damage damage = XDamageCreate(display, window.window, XDamageReportNonEmpty);
-       XserverRegion region2 = XFixesCreateRegionFromWindow(display, window.window, 0);
-       XserverRegion part = XFixesCreateRegionFromWindow(display, window.window, 0);
+       Damage damage = XDamageCreate(display, window.window,
+               XDamageReportNonEmpty);
+       XserverRegion region2 = XFixesCreateRegionFromWindow(display,
+               window.window, 0);
+       XserverRegion part = XFixesCreateRegionFromWindow(display,
+               window.window, 0);
 #endif /* HAVE_XDAMAGE */
 #endif /* X11 */
 
@@ -6527,8 +6723,9 @@ static void main_loop()
 
 #ifdef SIGNAL_BLOCKING
                /* block signals.  we will inspect for pending signals later */
-               if (sigprocmask(SIG_BLOCK, &newmask, &oldmask) < 0)
+               if (sigprocmask(SIG_BLOCK, &newmask, &oldmask) < 0) {
                        CRIT_ERR("unable to sigprocmask()");
+               }
 #endif
 
 #ifdef X11
@@ -6540,38 +6737,35 @@ static void main_loop()
                        fd_set fdsr;
                        struct timeval tv;
                        int s;
-                       double t =
-                           update_interval - (get_time() -
-                                              last_update_time);
+                       double t = update_interval - (get_time() - last_update_time);
 
-                       if (t < 0)
+                       if (t < 0) {
                                t = 0;
+                       }
 
                        tv.tv_sec = (long) t;
                        tv.tv_usec = (long) (t * 1000000) % 1000000;
                        FD_ZERO(&fdsr);
                        FD_SET(ConnectionNumber(display), &fdsr);
 
-
-                       s = select(ConnectionNumber(display) + 1, &fdsr, 0,
-                                  0, &tv);
-#else
-                       usleep(update_interval*1000000); /* FIXME just sleep for the interval time if no X11 */
-#endif /* X11 */
-#ifdef X11
+                       s = select(ConnectionNumber(display) + 1, &fdsr, 0, 0, &tv);
                        if (s == -1) {
-                               if (errno != EINTR)
-                                       ERR("can't select(): %s",
-                                           strerror(errno));
+                               if (errno != EINTR) {
+                                       ERR("can't select(): %s", strerror(errno));
+                               }
                        } else {
                                /* timeout */
-                               if (s == 0)
+                               if (s == 0) {
+#else
+               /* FIXME just sleep for the interval time if no X11 */
+               usleep(update_interval * 1000000);
 #endif /* X11 */
                                        update_text();
 #ifdef X11
+                               }
                        }
                }
-               
+
                if (need_to_update) {
 #ifdef OWN_WINDOW
                        int wx = window.x, wy = window.y;
@@ -6583,32 +6777,21 @@ static void main_loop()
 #ifdef OWN_WINDOW
                        if (own_window) {
                                /* resize window if it isn't right size */
-                               if (!fixed_size &&
-                                   (text_width + border_margin * 2 + 1 !=
-                                    window.width
-                                    || text_height + border_margin * 2 + 1 !=
-                                    window.height)) {
-                                       window.width =
-                                           text_width +
-                                           border_margin * 2 + 1;
-                                       window.height =
-                                           text_height +
-                                           border_margin * 2 + 1;
-                                       XResizeWindow(display,
-                                                     window.window,
-                                                     window.width,
-                                                     window.height);
-                       if (own_window) {
-                               set_transparent_background(window.window);
-                       }
-                                    }
+                               if (!fixed_size
+                                               && (text_width + border_margin * 2 + 1 != window.width
+                                               || text_height + border_margin * 2 + 1 != window.height)) {
+                                       window.width = text_width + border_margin * 2 + 1;
+                                       window.height = text_height + border_margin * 2 + 1;
+                                       XResizeWindow(display, window.window, window.width,
+                                               window.height);
+                                       if (own_window) {
+                                               set_transparent_background(window.window);
+                                       }
+                               }
 
                                /* move window if it isn't in right position */
-                               if (!fixed_pos
-                                   && (window.x != wx
-                                       || window.y != wy)) {
-                                       XMoveWindow(display, window.window,
-                                                   window.x, window.y);
+                               if (!fixed_pos && (window.x != wx || window.y != wy)) {
+                                       XMoveWindow(display, window.window, window.x, window.y);
                                }
                        }
 #endif
@@ -6618,6 +6801,7 @@ static void main_loop()
 #ifdef HAVE_XDBE
                        if (use_xdbe) {
                                XRectangle r;
+
                                r.x = text_start_x - border_margin;
                                r.y = text_start_y - border_margin;
                                r.width = text_width + border_margin * 2;
@@ -6628,139 +6812,129 @@ static void main_loop()
                }
 
                /* handle X events */
-
                while (XPending(display)) {
                        XEvent ev;
+
                        XNextEvent(display, &ev);
                        switch (ev.type) {
-                       case Expose:
+                               case Expose:
                                {
                                        XRectangle r;
+
                                        r.x = ev.xexpose.x;
                                        r.y = ev.xexpose.y;
                                        r.width = ev.xexpose.width;
                                        r.height = ev.xexpose.height;
-                                       XUnionRectWithRegion(&r, region,
-                                                            region);
+                                       XUnionRectWithRegion(&r, region, region);
+                                       break;
                                }
-                               break;
 
 #ifdef OWN_WINDOW
-                       case ReparentNotify:
-                               /* set background to ParentRelative for all parents */
-                               if (own_window) {
-                                       set_transparent_background(window.
-                                       window);
-                               }
-                               break;
+                               case ReparentNotify:
+                                       /* set background to ParentRelative for all parents */
+                                       if (own_window) {
+                                               set_transparent_background(window.window);
+                                       }
+                                       break;
+
+                               case ConfigureNotify:
+                                       if (own_window) {
+                                               /* if window size isn't what expected, set fixed size */
+                                               if (ev.xconfigure.width != window.width
+                                                               || ev.xconfigure.height != window.height) {
+                                                       if (window.width != 0 && window.height != 0) {
+                                                               fixed_size = 1;
+                                                       }
+
+                                                       /* clear old stuff before screwing up
+                                                        * size and pos */
+                                                       clear_text(1);
+
+                                                       {
+                                                               XWindowAttributes attrs;
+
+                                                               if (XGetWindowAttributes(display,
+                                                                               window.window, &attrs)) {
+                                                                       window.width = attrs.width;
+                                                                       window.height = attrs.height;
+                                                               }
+                                                       }
 
-                       case ConfigureNotify:
-                               if (own_window) {
-                                       /* if window size isn't what expected, set fixed size */
-                                       if (ev.xconfigure.width !=
-                                           window.width
-                                           || ev.xconfigure.height !=
-                                           window.height) {
-                                               if (window.width != 0
-                                                   && window.height != 0)
-                                                       fixed_size = 1;
-
-                                               /* clear old stuff before screwing up size and pos */
-                                               clear_text(1);
-
-                                               {
-                                                       XWindowAttributes
-                                                           attrs;
-                                                       if (XGetWindowAttributes(display, window.window, &attrs)) {
-                                                               window.
-                                                                   width =
-                                                                   attrs.
-                                                                   width;
-                                                               window.
-                                                                   height
-                                                                   =
-                                                                   attrs.
-                                                                   height;
+                                                       text_width = window.width - border_margin * 2 - 1;
+                                                       text_height = window.height - border_margin * 2 - 1;
+                                                       if (text_width > maximum_width
+                                                                       && maximum_width > 0) {
+                                                               text_width = maximum_width;
                                                        }
                                                }
 
-                                               text_width =
-                                                   window.width -
-                                                   border_margin * 2 - 1;
-                                               text_height =
-                                                   window.height -
-                                                   border_margin * 2 - 1;
-                                               if (text_width > maximum_width && maximum_width > 0)
-                                                       text_width = maximum_width;
+                                               /* if position isn't what expected, set fixed pos
+                                                * total_updates avoids setting fixed_pos when window
+                                                * is set to weird locations when started */
+                                               /* // this is broken
+                                               if (total_updates >= 2 && !fixed_pos
+                                                               && (window.x != ev.xconfigure.x
+                                                               || window.y != ev.xconfigure.y)
+                                                               && (ev.xconfigure.x != 0
+                                                               || ev.xconfigure.y != 0)) {
+                                                       fixed_pos = 1;
+                                               } */
+                                               set_font();
                                        }
+                                       break;
 
-                                       /* if position isn't what expected, set fixed pos, total_updates
-                                        * avoids setting fixed_pos when window is set to weird locations
-                                        * when started */
-                                       /*if (total_updates >= 2 this is broken
-                                           && !fixed_pos
-                                           && (window.x != ev.xconfigure.x
-                                               || window.y !=
-                                               ev.xconfigure.y)
-                                           && (ev.xconfigure.x != 0
-                                               || ev.xconfigure.y != 0)) {
-                                               fixed_pos = 1;
-                               }*/
-                                       set_font();
-                               }
-                               break;
-
-                       case ButtonPress:
-                               if (own_window)
-        {
-          /* if an ordinary window with decorations */
-          if ((window.type==TYPE_NORMAL) && (!TEST_HINT(window.hints,HINT_UNDECORATED)))
-          {
-            /* allow conky to hold input focus.*/
-            break;
-          }
-          else
-                                 {
-                                   /* forward the click to the desktop window */
-                                   XUngrabPointer(display, ev.xbutton.time);
-                                   ev.xbutton.window = window.desktop;
-                                   XSendEvent(display, ev.xbutton.window, False, ButtonPressMask, &ev);
-            XSetInputFocus(display, ev.xbutton.window,RevertToParent,ev.xbutton.time);
-                                 }
-        }
-                               break;
+                               case ButtonPress:
+                                       if (own_window) {
+                                               /* if an ordinary window with decorations */
+                                               if ((window.type == TYPE_NORMAL)
+                                                               && (!TEST_HINT(window.hints,
+                                                               HINT_UNDECORATED))) {
+                                                       /* allow conky to hold input focus. */
+                                                       break;
+                                               } else {
+                                                       /* forward the click to the desktop window */
+                                                       XUngrabPointer(display, ev.xbutton.time);
+                                                       ev.xbutton.window = window.desktop;
+                                                       XSendEvent(display, ev.xbutton.window, False,
+                                                               ButtonPressMask, &ev);
+                                                       XSetInputFocus(display, ev.xbutton.window,
+                                                               RevertToParent, ev.xbutton.time);
+                                               }
+                                       }
+                                       break;
 
-                       case ButtonRelease:
-        if (own_window)
-        {
-          /* if an ordinary window with decorations */
-          if ((window.type==TYPE_NORMAL) && (!TEST_HINT(window.hints,HINT_UNDECORATED)))
-          {
-            /* allow conky to hold input focus.*/
-            break;
-          }
-          else
-          {
-            /* forward the release to the desktop window */
-            ev.xbutton.window = window.desktop;
-            XSendEvent(display, ev.xbutton.window, False, ButtonReleaseMask, &ev);
-          }
-        }
-        break;
+                               case ButtonRelease:
+                                       if (own_window) {
+                                               /* if an ordinary window with decorations */
+                                               if ((window.type == TYPE_NORMAL)
+                                                               && (!TEST_HINT(window.hints,
+                                                               HINT_UNDECORATED))) {
+                                                       /* allow conky to hold input focus. */
+                                                       break;
+                                               } else {
+                                                       /* forward the release to the desktop window */
+                                                       ev.xbutton.window = window.desktop;
+                                                       XSendEvent(display, ev.xbutton.window, False,
+                                                               ButtonReleaseMask, &ev);
+                                               }
+                                       }
+                                       break;
 
 #endif
 
-                       default:
+                               default:
 #ifdef HAVE_XDAMAGE
-                               if (ev.type == event_base + XDamageNotify) {
-                                       XDamageNotifyEvent  *dev = (XDamageNotifyEvent *) &ev;
-                                       XFixesSetRegion(display, part, &dev->area, 1);
-                                       XFixesUnionRegion(display, region2, region2, part);
-                               }
+                                       if (ev.type == event_base + XDamageNotify) {
+                                               XDamageNotifyEvent *dev = (XDamageNotifyEvent *) &ev;
+
+                                               XFixesSetRegion(display, part, &dev->area, 1);
+                                               XFixesUnionRegion(display, region2, region2, part);
+                                       }
 #endif /* HAVE_XDAMAGE */
-                               break;
+                                       break;
                        }
-       }
+               }
+
 #ifdef HAVE_XDAMAGE
                XDamageSubtract(display, damage, region2, None);
                XFixesSetRegion(display, region2, 0, 0);
@@ -6771,19 +6945,19 @@ static void main_loop()
                 * to XdbeSwapBuffers. That means that if we're using XDBE, we need to
                 * redraw the text even if it wasn't part of the exposed area. OTOH,
                 * if we're not going to call draw_stuff at all, then no swap happens
-                * and we can safely do nothing.
-                */
+                * and we can safely do nothing. */
 
                if (!XEmptyRegion(region)) {
 #ifdef HAVE_XDBE
                        if (use_xdbe) {
                                XRectangle r;
+
                                r.x = text_start_x - border_margin;
                                r.y = text_start_y - border_margin;
                                r.width = text_width + border_margin * 2;
                                r.height = text_height + border_margin * 2;
                                XUnionRectWithRegion(&r, region, region);
-               }
+                       }
 #endif
                        XSetRegion(display, window.gc, region);
 #ifdef XFT
@@ -6801,42 +6975,40 @@ static void main_loop()
 
 #ifdef SIGNAL_BLOCKING
                /* unblock signals of interest and let handler fly */
-               if (sigprocmask(SIG_SETMASK, &oldmask, NULL) < 0)
+               if (sigprocmask(SIG_SETMASK, &oldmask, NULL) < 0) {
                        CRIT_ERR("unable to sigprocmask()");
+               }
 #endif
 
-               switch(g_signal_pending) {
-               case SIGUSR1:
-                       {
-                       ERR("received SIGUSR1. reloading the config file.");
-                       reload_config();
-                       break;
-                       }
-               case SIGINT:
-               case SIGTERM:
-                       {
-                       ERR("received SIGINT or SIGTERM to terminate. bye!");
-                       clean_up();
+               switch (g_signal_pending) {
+                       case SIGUSR1:
+                               ERR("received SIGUSR1. reloading the config file.");
+                               reload_config();
+                               break;
+                       case SIGINT:
+                       case SIGTERM:
+                               ERR("received SIGINT or SIGTERM to terminate. bye!");
+                               clean_up();
 #ifdef X11
-                       XDestroyRegion(region);
-                       region = NULL;
+                               XDestroyRegion(region);
+                               region = NULL;
 #endif /* X11 */
-                       return;  /* return from main_loop */
-                       /*break;*/
-                       }
-               default:
-                       {
-                       /* Reaching here means someone set a signal( SIGXXXX, signal_handler )
-                        * but didn't write any code to deal with it.   if you don't want to
-                        * handle a signal, don't set a handler on it in the first place. */
-                       if (g_signal_pending)
-                               ERR("ignoring signal (%d)", g_signal_pending);
-                       break;
-                       }
+                               return; /* return from main_loop */
+                               /* break; */
+                       default:
+                               /* Reaching here means someone set a signal
+                                * (SIGXXXX, signal_handler), but didn't write any code
+                                * to deal with it.
+                                * If you don't want to handle a signal, don't set a handler on
+                                * it in the first place. */
+                               if (g_signal_pending) {
+                                       ERR("ignoring signal (%d)", g_signal_pending);
+                               }
+                               break;
                }
-               g_signal_pending=0;
-       
+               g_signal_pending = 0;
        }
+
 #if defined(X11) && defined(HAVE_XDAMAGE)
        XDamageDestroy(display, damage);
        XFixesDestroyRegion(display, region2);
@@ -6851,63 +7023,62 @@ static void load_config_file(const char *);
 /* reload the config file */
 void reload_config(void)
 {
-       timed_thread_destroy_registered_threads ();
+       timed_thread_destroy_registered_threads();
 
        if (info.cpu_usage) {
                free(info.cpu_usage);
                info.cpu_usage = NULL;
        }
-       
+
        if (info.mail) {
                free(info.mail);
        }
 
 #ifdef MPD
-       {
-               if (info.mpd.title) {
-                       free(info.mpd.title);
-                       info.mpd.title = 0;
-               }
-               if (info.mpd.artist) {
-                       free(info.mpd.artist);
-                       info.mpd.artist = 0;
-               }
-               if (info.mpd.album) {
-                       free(info.mpd.album);
-                       info.mpd.album = 0;
-               }
-               if (info.mpd.random) {
-                       free(info.mpd.random);
-                       info.mpd.random = 0;
-               }
-               if (info.mpd.repeat) {
-                       free(info.mpd.repeat);
-                       info.mpd.repeat = 0;
-               }
-               if (info.mpd.track) {
-                       free(info.mpd.track);
-                       info.mpd.track = 0;
-               }
-               if (info.mpd.name) {
-                       free(info.mpd.name);
-                       info.mpd.name = 0;
-               }
-               if (info.mpd.file) {
-                       free(info.mpd.file);
-                       info.mpd.file = 0;
-               }
-               if (info.mpd.status) {
-                       free(info.mpd.status);
-                       info.mpd.status = 0;
-               }
+       if (info.mpd.title) {
+               free(info.mpd.title);
+               info.mpd.title = NULL;
+       }
+       if (info.mpd.artist) {
+               free(info.mpd.artist);
+               info.mpd.artist = NULL;
+       }
+       if (info.mpd.album) {
+               free(info.mpd.album);
+               info.mpd.album = NULL;
+       }
+       if (info.mpd.random) {
+               free(info.mpd.random);
+               info.mpd.random = NULL;
+       }
+       if (info.mpd.repeat) {
+               free(info.mpd.repeat);
+               info.mpd.repeat = NULL;
+       }
+       if (info.mpd.track) {
+               free(info.mpd.track);
+               info.mpd.track = NULL;
+       }
+       if (info.mpd.name) {
+               free(info.mpd.name);
+               info.mpd.name = NULL;
+       }
+       if (info.mpd.file) {
+               free(info.mpd.file);
+               info.mpd.file = NULL;
+       }
+       if (info.mpd.status) {
+               free(info.mpd.status);
+               info.mpd.status = NULL;
        }
 #endif
+
 #ifdef X11
        free_fonts();
 #endif /* X11 */
 
 #ifdef TCP_PORT_MONITOR
-       destroy_tcp_port_monitor_collection( info.p_tcp_port_monitor_collection );
+       destroy_tcp_port_monitor_collection(info.p_tcp_port_monitor_collection);
 #endif
 
        if (current_config) {
@@ -6915,22 +7086,28 @@ void reload_config(void)
                load_config_file(current_config);
 
                /* re-init specials array */
-               if ((specials = realloc ((void *)specials, sizeof(struct special_t)*max_specials)) == 0)
-                   ERR("failed to realloc specials array");
+               if ((specials = realloc((void *) specials,
+                               sizeof(struct special_t) * max_specials)) == 0) {
+                       ERR("failed to realloc specials array");
+               }
 
 #ifdef X11
                load_fonts();
                set_font();
-               XClearWindow(display, RootWindow(display, screen)); // clear the window first
+
+               // clear the window first
+               XClearWindow(display, RootWindow(display, screen));
 
 #endif /* X11 */
 #ifdef TCP_PORT_MONITOR
-               info.p_tcp_port_monitor_collection = NULL; 
+               info.p_tcp_port_monitor_collection = NULL;
 #endif
 #ifdef AUDACIOUS
-                if (create_audacious_thread() !=0)
-                    CRIT_ERR("unable to create audacious thread!");
-               timed_thread_register (info.audacious.p_timed_thread, &info.audacious.p_timed_thread);
+               if (create_audacious_thread() != 0) {
+                       CRIT_ERR("unable to create audacious thread!");
+               }
+               timed_thread_register(info.audacious.p_timed_thread,
+                       &info.audacious.p_timed_thread);
 #endif
                extract_variable_text(text);
                free(text);
@@ -6941,7 +7118,7 @@ void reload_config(void)
 
 void clean_up(void)
 {
-       timed_thread_destroy_registered_threads ();
+       timed_thread_destroy_registered_threads();
 
        if (info.cpu_usage) {
                free(info.cpu_usage);
@@ -6954,13 +7131,11 @@ void clean_up(void)
        }
 #endif
 #ifdef OWN_WINDOW
-       if (own_window) 
-       {
+       if (own_window) {
                XDestroyWindow(display, window.window);
                XClearWindow(display, RootWindow(display, screen));
                XFlush(display);
-       }
-       else
+       } else
 #endif
        {
                XClearWindow(display, RootWindow(display, screen));
@@ -6976,13 +7151,14 @@ void clean_up(void)
        text_object_count = 0;
        text_objects = NULL;
 
-       if (!text)
+       if (!text) {
                free(text);
+       }
 
        free(current_config);
 
 #ifdef TCP_PORT_MONITOR
-       destroy_tcp_port_monitor_collection( info.p_tcp_port_monitor_collection );
+       destroy_tcp_port_monitor_collection(info.p_tcp_port_monitor_collection);
        info.p_tcp_port_monitor_collection = NULL;
 #endif
 #ifdef RSS
@@ -6991,11 +7167,14 @@ void clean_up(void)
 
        if (specials) {
                unsigned int i;
-               for(i=0;i<special_count;i++)
-                       if(specials[i].type == GRAPH)
+
+               for (i = 0; i < special_count; i++) {
+                       if (specials[i].type == GRAPH) {
                                free(specials[i].graph);
-               free (specials);
-               specials=NULL;
+                       }
+               }
+               free(specials);
+               specials = NULL;
        }
 
        clear_diskio_stats();
@@ -7003,42 +7182,44 @@ void clean_up(void)
 
 static int string_to_bool(const char *s)
 {
-       if (!s)
-               return 1;
-       if (strcasecmp(s, "yes") == 0)
-               return 1;
-       if (strcasecmp(s, "true") == 0)
-               return 1;
-       if (strcasecmp(s, "1") == 0)
-               return 1;
-       return 0;
+       if (!s) {
+               return TRUE;
+       } else if (strcasecmp(s, "yes") == 0) {
+               return TRUE;
+       } else if (strcasecmp(s, "true") == 0) {
+               return TRUE;
+       } else if (strcasecmp(s, "1") == 0) {
+               return TRUE;
+       }
+       return FALSE;
 }
+
 #ifdef X11
 static enum alignment string_to_alignment(const char *s)
 {
-       if (strcasecmp(s, "top_left") == 0)
+       if (strcasecmp(s, "top_left") == 0) {
                return TOP_LEFT;
-       else if (strcasecmp(s, "top_right") == 0)
+       } else if (strcasecmp(s, "top_right") == 0) {
                return TOP_RIGHT;
-       else if (strcasecmp(s, "bottom_left") == 0)
+       } else if (strcasecmp(s, "bottom_left") == 0) {
                return BOTTOM_LEFT;
-       else if (strcasecmp(s, "bottom_right") == 0)
+       } else if (strcasecmp(s, "bottom_right") == 0) {
                return BOTTOM_RIGHT;
-       else if (strcasecmp(s, "tl") == 0)
+       } else if (strcasecmp(s, "tl") == 0) {
                return TOP_LEFT;
-       else if (strcasecmp(s, "tr") == 0)
+       } else if (strcasecmp(s, "tr") == 0) {
                return TOP_RIGHT;
-       else if (strcasecmp(s, "bl") == 0)
+       } else if (strcasecmp(s, "bl") == 0) {
                return BOTTOM_LEFT;
-       else if (strcasecmp(s, "br") == 0)
+       } else if (strcasecmp(s, "br") == 0) {
                return BOTTOM_RIGHT;
-       else if (strcasecmp(s, "none") == 0)
+       } else if (strcasecmp(s, "none") == 0) {
                return NONE;
+       }
        return TOP_LEFT;
 }
 #endif /* X11 */
 
-
 static void set_default_configurations(void)
 {
        fork_to_background = 0;
@@ -7063,15 +7244,15 @@ static void set_default_configurations(void)
        info.mpd.file = NULL;
 #endif
 #ifdef XMMS2
-    info.xmms2.artist = NULL;
-    info.xmms2.album = NULL;
-    info.xmms2.title = NULL;
-    info.xmms2.genre = NULL;
-    info.xmms2.comment = NULL;
-    info.xmms2.decoder = NULL;
-    info.xmms2.transport = NULL;
-    info.xmms2.url = NULL;
-    info.xmms2.status = NULL;
+       info.xmms2.artist = NULL;
+       info.xmms2.album = NULL;
+       info.xmms2.title = NULL;
+       info.xmms2.genre = NULL;
+       info.xmms2.comment = NULL;
+       info.xmms2.decoder = NULL;
+       info.xmms2.transport = NULL;
+       info.xmms2.url = NULL;
+       info.xmms2.status = NULL;
 #endif
        use_spacer = NO_SPACER;
 #ifdef X11
@@ -7105,11 +7286,11 @@ static void set_default_configurations(void)
        maximum_width = 0;
 #ifdef OWN_WINDOW
        own_window = 0;
-       window.type=TYPE_NORMAL;
-       window.hints=0;
-       strcpy(window.class_name, "Conky");     
+       window.type = TYPE_NORMAL;
+       window.hints = 0;
+       strcpy(window.class_name, "Conky");
        update_uname();
-       sprintf(window.title,"Conky (%s)",info.uname_s.nodename);
+       sprintf(window.title, "Conky (%s)", info.uname_s.nodename);
 #endif
        stippled_borders = 0;
        border_margin = 3;
@@ -7120,18 +7301,21 @@ static void set_default_configurations(void)
        free(current_mail_spool);
        {
                char buf[256];
+
                variable_substitute(MAIL_FILE, buf, 256);
-               if (buf[0] != '\0')
+               if (buf[0] != '\0') {
                        current_mail_spool = strdup(buf);
+               }
        }
 
        no_buffers = 1;
        update_interval = 3.0;
-  info.music_player_interval = 1.0;
+       info.music_player_interval = 1.0;
        stuff_in_upper_case = 0;
 
 #ifdef TCP_PORT_MONITOR
-       tcp_port_monitor_args.max_port_monitor_connections = MAX_PORT_MONITOR_CONNECTIONS_DEFAULT;
+       tcp_port_monitor_args.max_port_monitor_connections =
+               MAX_PORT_MONITOR_CONNECTIONS_DEFAULT;
 #endif
 }
 
@@ -7143,34 +7327,41 @@ static void load_config_file(const char *f)
 
        set_default_configurations();
        fp = fopen(f, "r");
-       if (!fp)
+       if (!fp) {
                return;
+       }
 
        while (!feof(fp)) {
                char buf[256], *p, *p2, *name, *value;
+
                line++;
-               if (fgets(buf, 256, fp) == NULL)
+               if (fgets(buf, 256, fp) == NULL) {
                        break;
+               }
 
                p = buf;
 
                /* break at comment */
                p2 = strchr(p, '#');
-               if (p2)
+               if (p2) {
                        *p2 = '\0';
+               }
 
                /* skip spaces */
-               while (*p && isspace((int) *p))
+               while (*p && isspace((int) *p)) {
                        p++;
-               if (*p == '\0')
+               }
+               if (*p == '\0') {
                        continue;       /* empty line */
+               }
 
                name = p;
 
                /* skip name */
                p2 = p;
-               while (*p2 && !isspace((int) *p2))
+               while (*p2 && !isspace((int) *p2)) {
                        p2++;
+               }
                if (*p2 != '\0') {
                        *p2 = '\0';     /* break at name's end */
                        p2++;
@@ -7179,39 +7370,42 @@ static void load_config_file(const char *f)
                /* get value */
                if (*p2) {
                        p = p2;
-                       while (*p && isspace((int) *p))
+                       while (*p && isspace((int) *p)) {
                                p++;
+                       }
 
                        value = p;
 
                        p2 = value + strlen(value);
-                       while (isspace((int) *(p2 - 1)))
+                       while (isspace((int) *(p2 - 1))) {
                                *--p2 = '\0';
+                       }
                } else {
                        value = 0;
                }
 
 #define CONF2(a) if (strcasecmp(name, a) == 0)
 #define CONF(a) else CONF2(a)
-#define CONF3(a,b) \
-else if (strcasecmp(name, a) == 0 || strcasecmp(name, b) == 0)
-
+#define CONF3(a, b) else if (strcasecmp(name, a) == 0 \
+               || strcasecmp(name, b) == 0)
 
 #ifdef X11
                CONF2("alignment") {
-               if (value) {
-                       int a = string_to_alignment(value);
-                       if (a <= 0)
+                       if (value) {
+                               int a = string_to_alignment(value);
+
+                               if (a <= 0) {
+                                       CONF_ERR;
+                               } else {
+                                       text_alignment = a;
+                               }
+                       } else {
                                CONF_ERR;
-                       else
-                               text_alignment = a;
-               } else
-                       CONF_ERR;
+                       }
                }
                CONF("background") {
                        fork_to_background = string_to_bool(value);
                }
-
 #else
                CONF2("background") {
                        fork_to_background = string_to_bool(value);
@@ -7219,94 +7413,109 @@ else if (strcasecmp(name, a) == 0 || strcasecmp(name, b) == 0)
 #endif /* X11 */
 #ifdef X11
                CONF("border_margin") {
-                       if (value)
+                       if (value) {
                                border_margin = strtol(value, 0, 0);
-                       else
+                       } else {
                                CONF_ERR;
+                       }
                }
                CONF("border_width") {
-                       if (value)
+                       if (value) {
                                border_width = strtol(value, 0, 0);
-                       else
+                       } else {
                                CONF_ERR;
+                       }
                }
                CONF("color0") {
-                       if (value)
+                       if (value) {
                                color0 = get_x11_color(value);
-                       else
+                       } else {
                                CONF_ERR;
+                       }
                }
                CONF("color1") {
-                       if (value)
+                       if (value) {
                                color1 = get_x11_color(value);
-                       else
+                       } else {
                                CONF_ERR;
+                       }
                }
                CONF("color2") {
-                       if (value)
+                       if (value) {
                                color2 = get_x11_color(value);
-                       else
+                       } else {
                                CONF_ERR;
+                       }
                }
                CONF("color3") {
-                       if (value)
+                       if (value) {
                                color3 = get_x11_color(value);
-                       else
+                       } else {
                                CONF_ERR;
+                       }
                }
                CONF("color4") {
-                       if (value)
+                       if (value) {
                                color4 = get_x11_color(value);
-                       else
+                       } else {
                                CONF_ERR;
+                       }
                }
                CONF("color5") {
-                       if (value)
+                       if (value) {
                                color5 = get_x11_color(value);
-                       else
+                       } else {
                                CONF_ERR;
+                       }
                }
                CONF("color6") {
-                       if (value)
+                       if (value) {
                                color6 = get_x11_color(value);
-                       else
+                       } else {
                                CONF_ERR;
+                       }
                }
                CONF("color7") {
-                       if (value)
+                       if (value) {
                                color7 = get_x11_color(value);
-                       else
+                       } else {
                                CONF_ERR;
+                       }
                }
                CONF("color8") {
-                       if (value)
+                       if (value) {
                                color8 = get_x11_color(value);
-                       else
+                       } else {
                                CONF_ERR;
+                       }
                }
                CONF("color9") {
-                       if (value)
+                       if (value) {
                                color9 = get_x11_color(value);
-                       else
+                       } else {
                                CONF_ERR;
+                       }
                }
                CONF("default_color") {
-                       if (value)
+                       if (value) {
                                default_fg_color = get_x11_color(value);
-                       else
+                       } else {
                                CONF_ERR;
+                       }
                }
                CONF3("default_shade_color", "default_shadecolor") {
-                       if (value)
+                       if (value) {
                                default_bg_color = get_x11_color(value);
-                       else
+                       } else {
                                CONF_ERR;
+                       }
                }
                CONF3("default_outline_color", "default_outlinecolor") {
-                       if (value)
+                       if (value) {
                                default_out_color = get_x11_color(value);
-                       else
+                       } else {
                                CONF_ERR;
+                       }
                }
 #endif /* X11 */
                CONF("imap") {
@@ -7325,82 +7534,78 @@ else if (strcasecmp(name, a) == 0 || strcasecmp(name, b) == 0)
                }
 #ifdef MPD
                CONF("mpd_host") {
-                       if (value)
+                       if (value) {
                                strncpy(info.mpd.host, value, 127);
-                       else
+                       } else {
                                CONF_ERR;
+                       }
                }
                CONF("mpd_port") {
                        if (value) {
                                info.mpd.port = strtol(value, 0, 0);
-                               if (info.mpd.port < 1
-                                   || info.mpd.port > 0xffff)
+                               if (info.mpd.port < 1 || info.mpd.port > 0xffff) {
                                        CONF_ERR;
+                               }
                        }
                }
                CONF("mpd_password") {
-                       if (value)
+                       if (value) {
                                strncpy(info.mpd.password, value, 127);
-                       else
+                       } else {
                                CONF_ERR;
+                       }
                }
 #endif
-    CONF("music_player_interval") {
-      if (value)
-        info.music_player_interval = strtod(value, 0);
-      else
-        CONF_ERR;
-      }
+               CONF("music_player_interval") {
+                       if (value) {
+                               info.music_player_interval = strtod(value, 0);
+                       } else {
+                               CONF_ERR;
+                       }
+               }
 #ifdef __OpenBSD__
                CONF("sensor_device") {
-                       if(value)
+                       if (value) {
                                sensor_device = strtol(value, 0, 0);
-                       else
+                       } else {
                                CONF_ERR;
+                       }
                }
 #endif
                CONF("cpu_avg_samples") {
                        if (value) {
                                cpu_avg_samples = strtol(value, 0, 0);
-                               if (cpu_avg_samples < 1
-                                   || cpu_avg_samples > 14)
+                               if (cpu_avg_samples < 1 || cpu_avg_samples > 14) {
                                        CONF_ERR;
-                               else
-                                       info.
-                                           cpu_avg_samples
-                                           = cpu_avg_samples;
-                       } else
+                               } else {
+                                       info.cpu_avg_samples = cpu_avg_samples;
+                               }
+                       } else {
                                CONF_ERR;
+                       }
                }
                CONF("net_avg_samples") {
                        if (value) {
                                net_avg_samples = strtol(value, 0, 0);
-                               if (net_avg_samples < 1
-                                   || net_avg_samples > 14)
+                               if (net_avg_samples < 1 || net_avg_samples > 14) {
                                        CONF_ERR;
-                               else
-                                       info.
-                                           net_avg_samples
-                                           = net_avg_samples;
-                       } else
+                               } else {
+                                       info.net_avg_samples = net_avg_samples;
+                               }
+                       } else {
                                CONF_ERR;
+                       }
                }
 
-
-
-
-
-
 #ifdef HAVE_XDBE
                CONF("double_buffer") {
-               use_xdbe = string_to_bool(value);
+                       use_xdbe = string_to_bool(value);
                }
 #endif
 #ifdef X11
                CONF("override_utf8_locale") {
-       utf8_mode = string_to_bool(value);
+                       utf8_mode = string_to_bool(value);
                }
-
                CONF("draw_borders") {
                        draw_borders = string_to_bool(value);
                }
@@ -7451,22 +7656,24 @@ else if (strcasecmp(name, a) == 0 || strcasecmp(name, b) == 0)
                CONF("font") {
                        if (value) {
                                set_first_font(value);
-                       } else
+                       } else {
                                CONF_ERR;
+                       }
                }
                CONF("xftalpha") {
-                       if (value && font_count >= 0)
-                               fonts[0].font_alpha = atof(value)
-                                   * 65535.0;
-                       else
+                       if (value && font_count >= 0) {
+                               fonts[0].font_alpha = atof(value) * 65535.0;
+                       } else {
                                CONF_ERR;
+                       }
                }
                CONF("xftfont") {
                        if (use_xft) {
 #else
                CONF("use_xft") {
-                       if (string_to_bool(value))
+                       if (string_to_bool(value)) {
                                ERR("Xft not enabled");
+                       }
                }
                CONF("xftfont") {
                        /* xftfont silently ignored when no Xft */
@@ -7478,58 +7685,65 @@ else if (strcasecmp(name, a) == 0 || strcasecmp(name, b) == 0)
 #endif
                                if (value) {
                                        set_first_font(value);
-                               } else
+                               } else {
                                        CONF_ERR;
+                               }
 #ifdef XFT
                        }
 #endif
                }
                CONF("gap_x") {
-                       if (value)
+                       if (value) {
                                gap_x = atoi(value);
-                       else
+                       } else {
                                CONF_ERR;
+                       }
                }
                CONF("gap_y") {
-                       if (value)
+                       if (value) {
                                gap_y = atoi(value);
-                       else
+                       } else {
                                CONF_ERR;
+                       }
                }
 #endif /* X11 */
                CONF("mail_spool") {
                        if (value) {
                                char buf[256];
+
                                variable_substitute(value, buf, 256);
 
-                               if (buf[0]
-                                   != '\0') {
-                                       if (current_mail_spool)
+                               if (buf[0] != '\0') {
+                                       if (current_mail_spool) {
                                                free(current_mail_spool);
+                                       }
                                        current_mail_spool = strdup(buf);
                                }
-                       } else
+                       } else {
                                CONF_ERR;
+                       }
                }
 #ifdef X11
                CONF("minimum_size") {
-       if (value) {
-               if (sscanf
-                                 (value, "%d %d", &minimum_width,
-                                  &minimum_height) != 2)
-                       if (sscanf
-                                                (value, "%d",
-                                                  &minimum_width) != 1)
+                       if (value) {
+                               if (sscanf(value, "%d %d", &minimum_width, &minimum_height)
+                                               != 2) {
+                                       if (sscanf(value, "%d", &minimum_width) != 1) {
+                                               CONF_ERR;
+                                       }
+                               }
+                       } else {
                                CONF_ERR;
-       } else
-               CONF_ERR;
+                       }
                }
                CONF("maximum_width") {
                        if (value) {
-                               if (sscanf(value, "%d", &maximum_width) != 1)
+                               if (sscanf(value, "%d", &maximum_width) != 1) {
                                        CONF_ERR;
-                       } else
+                               }
+                       } else {
                                CONF_ERR;
+                       }
                }
 #endif /* X11 */
                CONF("no_buffers") {
@@ -7542,45 +7756,47 @@ else if (strcasecmp(name, a) == 0 || strcasecmp(name, b) == 0)
                        short_units = string_to_bool(value);
                }
                CONF("pad_percents") {
-       pad_percents = atoi(value);
+                       pad_percents = atoi(value);
                }
 #ifdef X11
 #ifdef OWN_WINDOW
                CONF("own_window") {
-      if (value)
-                         own_window = string_to_bool(value);
-      else
-        CONF_ERR;
+                       if (value) {
+                               own_window = string_to_bool(value);
+                       } else {
+                               CONF_ERR;
+                       }
                }
                CONF("own_window_class") {
-      if (value)
-      {
-                         memset(window.class_name,0,sizeof(window.class_name));
-                         strncpy(window.class_name, value, sizeof(window.class_name)-1);
-      }
-      else 
-        CONF_ERR;
-               }
-    CONF("own_window_title") {
-      if (value)
-      {
-        memset(window.title,0,sizeof(window.title));
-        strncpy(window.title, value, sizeof(window.title)-1);
-      }
-      else
-        CONF_ERR;
-    }
+                       if (value) {
+                               memset(window.class_name, 0, sizeof(window.class_name));
+                               strncpy(window.class_name, value,
+                                       sizeof(window.class_name) - 1);
+                       } else {
+                               CONF_ERR;
+                       }
+               }
+               CONF("own_window_title") {
+                       if (value) {
+                               memset(window.title, 0, sizeof(window.title));
+                               strncpy(window.title, value, sizeof(window.title) - 1);
+                       } else {
+                               CONF_ERR;
+                       }
+               }
                CONF("own_window_transparent") {
-      if (value)
-                         set_transparent = string_to_bool(value);
-      else
-        CONF_ERR;
+                       if (value) {
+                               set_transparent = string_to_bool(value);
+                       } else {
+                               CONF_ERR;
+                       }
                }
                CONF("own_window_colour") {
                        if (value) {
                                background_colour = get_x11_color(value);
                        } else {
-                               ERR("Invalid colour for own_window_colour (try omitting the '#' for hex colours");
+                               ERR("Invalid colour for own_window_colour (try omitting the "
+                                       "'#' for hex colours");
                        }
                }
                CONF("own_window_hints") {
@@ -7589,205 +7805,212 @@ else if (strcasecmp(name, a) == 0 || strcasecmp(name, b) == 0)
                                char delim[] = ", ";
 
                                /* tokenize the value into individual hints */
-                               if ((p_hint=strtok_r(value, delim, &p_save)) != NULL)
-                               do {
-                                        /*fprintf(stderr, "hint [%s] parsed\n", p_hint);*/
-                                        if (strncmp(p_hint,"undecorate",10) == 0)
-                                            SET_HINT(window.hints,HINT_UNDECORATED);
-                                        else if (strncmp(p_hint,"below",5) == 0)
-                                            SET_HINT(window.hints,HINT_BELOW);
-                                        else if (strncmp(p_hint,"above",5) == 0)
-                                            SET_HINT(window.hints,HINT_ABOVE);
-                                        else if (strncmp(p_hint,"sticky",6) == 0)
-                                            SET_HINT(window.hints,HINT_STICKY);
-                                        else if (strncmp(p_hint,"skip_taskbar",12) == 0)
-                                            SET_HINT(window.hints,HINT_SKIP_TASKBAR);
-                                        else if (strncmp(p_hint,"skip_pager",10) == 0)
-                                            SET_HINT(window.hints,HINT_SKIP_PAGER);
-                                        else
-                                            CONF_ERR;
-
-                                        p_hint=strtok_r(NULL, delim, &p_save);
-                               }
-                               while (p_hint!=NULL);
-                       }
-      else
-        CONF_ERR;
+                               if ((p_hint = strtok_r(value, delim, &p_save)) != NULL) {
+                                       do {
+                                               /* fprintf(stderr, "hint [%s] parsed\n", p_hint); */
+                                               if (strncmp(p_hint, "undecorate", 10) == 0) {
+                                                       SET_HINT(window.hints, HINT_UNDECORATED);
+                                               } else if (strncmp(p_hint, "below", 5) == 0) {
+                                                       SET_HINT(window.hints, HINT_BELOW);
+                                               } else if (strncmp(p_hint, "above", 5) == 0) {
+                                                       SET_HINT(window.hints, HINT_ABOVE);
+                                               } else if (strncmp(p_hint, "sticky", 6) == 0) {
+                                                       SET_HINT(window.hints, HINT_STICKY);
+                                               } else if (strncmp(p_hint, "skip_taskbar", 12) == 0) {
+                                                       SET_HINT(window.hints, HINT_SKIP_TASKBAR);
+                                               } else if (strncmp(p_hint, "skip_pager", 10) == 0) {
+                                                       SET_HINT(window.hints, HINT_SKIP_PAGER);
+                                               } else {
+                                                       CONF_ERR;
+                                               }
+
+                                               p_hint = strtok_r(NULL, delim, &p_save);
+                                       } while (p_hint != NULL);
+                               }
+                       } else {
+                               CONF_ERR;
+                       }
                }
                CONF("own_window_type") {
                        if (value) {
-                               if (strncmp(value,"normal",6)==0)
+                               if (strncmp(value, "normal", 6) == 0) {
                                        window.type = TYPE_NORMAL;
-                               else if  (strncmp(value,"desktop",7)==0)
+                               } else if (strncmp(value, "desktop", 7) == 0) {
                                        window.type = TYPE_DESKTOP;
-                               else if (strncmp(value,"override",8)==0)
+                               } else if (strncmp(value, "override", 8) == 0) {
                                        window.type = TYPE_OVERRIDE;
-                               else
-                                 CONF_ERR;
+                               } else {
+                                       CONF_ERR;
+                               }
+                       } else {
+                               CONF_ERR;
                        }
-      else
-        CONF_ERR;
                }
 #endif
                CONF("stippled_borders") {
-                       if (value)
+                       if (value) {
                                stippled_borders = strtol(value, 0, 0);
-                       else
+                       } else {
                                stippled_borders = 4;
+                       }
                }
 #endif /* X11 */
                CONF("temp1") {
-                       ERR("temp1 configuration is obsolete, use ${i2c <i2c device here> temp 1}");
+                       ERR("temp1 configuration is obsolete, use ${i2c <i2c device here> "
+                               "temp 1}");
                }
                CONF("temp2") {
-                       ERR("temp2 configuration is obsolete, use ${i2c <i2c device here> temp 2}");
+                       ERR("temp2 configuration is obsolete, use ${i2c <i2c device here> "
+                               "temp 2}");
                }
                CONF("update_interval") {
-                       if (value)
+                       if (value) {
                                update_interval = strtod(value, 0);
-                       else
+                       } else {
                                CONF_ERR;
+                       }
                        if (info.music_player_interval == 0) {
                                // default to update_interval
                                info.music_player_interval = update_interval;
                        }
                }
                CONF("total_run_times") {
-                       if (value)
+                       if (value) {
                                total_run_times = strtod(value, 0);
-                       else
+                       } else {
                                CONF_ERR;
+                       }
                }
                CONF("uppercase") {
                        stuff_in_upper_case = string_to_bool(value);
                }
                CONF("max_specials") {
-                       if (value)
+                       if (value) {
                                max_specials = atoi(value);
-                       else
+                       } else {
                                CONF_ERR;
+                       }
                }
                CONF("max_user_text") {
-                       if (value)
+                       if (value) {
                                max_user_text = atoi(value);
-                       else
+                       } else {
                                CONF_ERR;
+                       }
                }
                CONF("text_buffer_size") {
-                       if (value)
+                       if (value) {
                                text_buffer_size = atoi(value);
-                       else
+                       } else {
                                CONF_ERR;
+                       }
                }
                CONF("text") {
-                       if (!text)
+                       if (!text) {
                                free(text);
+                       }
 
-                       text = (char *)
-                           malloc(1);
-                       text[0]
-                           = '\0';
+                       text = (char *) malloc(1);
+                       text[0] = '\0';
 
                        while (!feof(fp)) {
-                               unsigned
-                               int l = strlen(text);
-                               if (fgets(buf, 256, fp) == NULL)
+                               unsigned int l = strlen(text);
+
+                               if (fgets(buf, 256, fp) == NULL) {
                                        break;
-                               text = (char *)
-                                   realloc(text, l + strlen(buf)
-                                           + 1);
+                               }
+                               text = (char *) realloc(text, l + strlen(buf) + 1);
                                strcat(text, buf);
 
-                               if (strlen(text) > max_user_text)
+                               if (strlen(text) > max_user_text) {
                                        break;
+                               }
                        }
                        fclose(fp);
                        text_lines = line + 1;
                        return;
                }
 #ifdef TCP_PORT_MONITOR
-               CONF("max_port_monitor_connections") 
-               {
-                       if ( !value || 
-                            (sscanf(value, "%d", &tcp_port_monitor_args.max_port_monitor_connections) != 1) 
-                            || tcp_port_monitor_args.max_port_monitor_connections < 0 )
-                       {
+               CONF("max_port_monitor_connections") {
+                       if (!value || (sscanf(value, "%d",
+                                       &tcp_port_monitor_args.max_port_monitor_connections) != 1)
+                                       || tcp_port_monitor_args.max_port_monitor_connections < 0) {
                                /* an error. use default, warn and continue. */
-                               tcp_port_monitor_args.max_port_monitor_connections = 
+                               tcp_port_monitor_args.max_port_monitor_connections =
                                        MAX_PORT_MONITOR_CONNECTIONS_DEFAULT;
                                CONF_ERR;
-                       }
-                       else if ( tcp_port_monitor_args.max_port_monitor_connections == 0 )
-                       {
+                       } else if (tcp_port_monitor_args.max_port_monitor_connections
+                                       == 0) {
                                /* no error, just use default */
-                               tcp_port_monitor_args.max_port_monitor_connections = 
+                               tcp_port_monitor_args.max_port_monitor_connections =
                                        MAX_PORT_MONITOR_CONNECTIONS_DEFAULT;
                        }
-                       /* else tcp_port_monitor_args.max_port_monitor_connections > 0 as per config */
+                       /* else tcp_port_monitor_args.max_port_monitor_connections > 0
+                        * as per config */
                }
 #endif
-
-               else
-               ERR("%s: %d: no such configuration: '%s'", f, line, name);
+               else {
+                       ERR("%s: %d: no such configuration: '%s'", f, line, name);
+               }
 
 #undef CONF
 #undef CONF2
        }
 
        fclose(fp);
+
 #undef CONF_ERR
 
        if (info.music_player_interval == 0) {
                // default to update_interval
                info.music_player_interval = update_interval;
        }
-
 }
 
 /* : means that character before that takes an argument */
 static const char *getopt_string = "vVdt:u:i:hc:"
 #ifdef X11
-               "x:y:w:a:f:"
+       "x:y:w:a:f:"
 #ifdef OWN_WINDOW
-    "o"
+       "o"
 #endif
 #ifdef HAVE_XDBE
-    "b"
+       "b"
 #endif
 #endif /* X11 */
        ;
 
-static const struct option
-               longopts[] = {
-                       { "help", 0, NULL, 'h' },
-                       { "version", 0, NULL, 'V' },
-                       { "config", 1, NULL, 'c' },
-                       { "daemonize", 0, NULL, 'd' },
+static const struct option longopts[] = {
+       { "help", 0, NULL, 'h' },
+       { "version", 0, NULL, 'V' },
+       { "config", 1, NULL, 'c' },
+       { "daemonize", 0, NULL, 'd' },
 #ifdef X11
-                       { "alignment", 1, NULL, 'a'},
-                       { "font", 1, NULL, 'f'},
+       { "alignment", 1, NULL, 'a' },
+       { "font", 1, NULL, 'f' },
 #ifdef OWN_WINDOW
-                       { "own-window", 0, NULL, 'o'},
+       { "own-window", 0, NULL, 'o' },
 #endif
 #ifdef HAVE_XDBE
-                       { "double-buffer", 0, NULL, 'b'},
+       { "double-buffer", 0, NULL, 'b' },
 #endif
-                       { "window-id", 1, NULL, 'w'},
+       { "window-id", 1, NULL, 'w' },
 #endif /* X11 */
-                       { "text", 1, NULL, 't' },
-                       { "interval", 0, NULL, 'u' },
-                       { 0, 0, 0, 0 }
-               };
+       { "text", 1, NULL, 't' },
+       { "interval", 0, NULL, 'u' },
+       { 0, 0, 0, 0 }
+};
 
 int main(int argc, char **argv)
 {
        struct sigaction act, oact;
 
-       g_signal_pending=0;
+       g_signal_pending = 0;
        memset(&info, 0, sizeof(info));
 
 #ifdef TCP_PORT_MONITOR
-       tcp_port_monitor_args.max_port_monitor_connections = MAX_PORT_MONITOR_CONNECTIONS_DEFAULT;
+       tcp_port_monitor_args.max_port_monitor_connections =
+               MAX_PORT_MONITOR_CONNECTIONS_DEFAULT;
 #endif
 
        /* handle command line parameters that don't change configs */
@@ -7795,9 +8018,9 @@ int main(int argc, char **argv)
        char *s, *temp;
        unsigned int x;
 
-       if (((s = getenv("LC_ALL")) && *s) || ((s = getenv("LC_CTYPE")) && 
-                    *s) || ((s = getenv("LANG")) && *s)) {
-               temp = (char *)malloc((strlen(s) + 1) * sizeof(char));
+       if (((s = getenv("LC_ALL")) && *s) || ((s = getenv("LC_CTYPE")) && *s)
+                       || ((s = getenv("LANG")) && *s)) {
+               temp = (char *) malloc((strlen(s) + 1) * sizeof(char));
                if (temp == NULL) {
                        ERR("malloc failed");
                }
@@ -7808,7 +8031,7 @@ int main(int argc, char **argv)
                if (strstr(temp, "utf-8") || strstr(temp, "utf8")) {
                        utf8_mode = 1;
                }
-               
+
                free(temp);
        }
        if (!setlocale(LC_CTYPE, "")) {
@@ -7818,62 +8041,62 @@ int main(int argc, char **argv)
        while (1) {
                int c = getopt_long(argc, argv, getopt_string, longopts, NULL);
 
-               if (c == -1)
-               {
+               if (c == -1) {
                        break;
                }
 
                switch (c) {
-               case 'v':
-               case 'V':
-                       print_version();
-               case 'c':
-                       if (current_config)
-                               free(current_config);
-                       current_config = strdup(optarg);
-                       break;
+                       case 'v':
+                       case 'V':
+                               print_version();
+                       case 'c':
+                               if (current_config) {
+                                       free(current_config);
+                               }
+                               current_config = strdup(optarg);
+                               break;
 
                        case 'h':
-                               printf(
-                                               "Usage: %s [OPTION]...\n"
-                                               "Conky is a system monitor that renders text on desktop or to own transparent\n"
-                                               "window. Command line options will override configurations defined in config\n"
-                                               "file.\n"
-                                               "   -V, --version             version\n"
-                                               "   -c, --config=FILE         config file to load\n"
-                                               "   -d, --daemonize           daemonize, fork to background\n"
-                                               "   -h, --help                help\n"
+                               printf("Usage: %s [OPTION]...\n"
+                                          "Conky is a system monitor that renders text on desktop or to own transparent\n"
+                                          "window. Command line options will override configurations defined in config\n"
+                                          "file.\n"
+                                          "   -V, --version             version\n"
+                                          "   -c, --config=FILE         config file to load\n"
+                                          "   -d, --daemonize           daemonize, fork to background\n"
+                                          "   -h, --help                help\n"
 #ifdef X11
-                                               "   -a, --alignment=ALIGNMENT text alignment on screen, {top,bottom}_{left,right}\n"
-                                               "   -f, --font=FONT           font to use\n"
+                                          "   -a, --alignment=ALIGNMENT text alignment on screen, {top,bottom}_{left,right}\n"
+                                          "   -f, --font=FONT           font to use\n"
 #ifdef OWN_WINDOW
-                                               "   -o, --own-window          create own window to draw\n"
+                                          "   -o, --own-window          create own window to draw\n"
 #endif
 #ifdef HAVE_XDBE
-                                               "   -b, --double-buffer       double buffer (prevents flickering)\n"
+                                          "   -b, --double-buffer       double buffer (prevents flickering)\n"
 #endif
-                                               "   -w, --window-id=WIN_ID    window id to draw\n"
-                                               "   -x X                      x position\n"
-                                               "   -y Y                      y position\n"
+                                          "   -w, --window-id=WIN_ID    window id to draw\n"
+                                          "   -x X                      x position\n"
+                                          "   -y Y                      y position\n"
 #endif /* X11 */
-                                               "   -t, --text=TEXT           text to render, remember single quotes, like -t '$uptime'\n"
-                                               "   -u, --interval=SECS       update interval\n"
-                                               "   -i NUM                    number of times to update Conky\n",
-                                               argv[0]
+                                          "   -t, --text=TEXT           text to render, remember single quotes, like -t '$uptime'\n"
+                                          "   -u, --interval=SECS       update interval\n"
+                                          "   -i NUM                    number of times to update Conky\n",
+                                          argv[0]
                                );
                                return 0;
 #ifdef X11
-               case 'w':
-                       window.window = strtol(optarg, 0, 0);
-                       break;
+                       case 'w':
+                               window.window = strtol(optarg, 0, 0);
+                               break;
 #endif /* X11 */
 
-               case '?':
-                       exit(EXIT_FAILURE);
+                       case '?':
+                               exit(EXIT_FAILURE);
                }
        }
 #ifdef X11
-       /* initalize X BEFORE we load config. (we need to so that 'screen' is set) */
+       /* initalize X BEFORE we load config.
+        * (we need to so that 'screen' is set) */
        init_X11();
 #endif /* X11 */
 
@@ -7882,39 +8105,43 @@ int main(int argc, char **argv)
        if (!current_config) {
                /* load default config file */
                char buf[256];
-    FILE *fp;
+               FILE *fp;
 
-    /* Try to use personal config file first */
+               /* Try to use personal config file first */
                variable_substitute(CONFIG_FILE, buf, sizeof(buf));
-    if (buf[0] && (fp=fopen(buf,"r"))) {
-      current_config = strdup(buf);
-      fclose(fp);
-    }
+               if (buf[0] && (fp = fopen(buf, "r"))) {
+                       current_config = strdup(buf);
+                       fclose(fp);
+               }
 
-    /* Try to use system config file if personal config not readable */
-    if (!current_config && (fp=fopen(SYSTEM_CONFIG_FILE,"r"))) {
-      current_config = strdup(SYSTEM_CONFIG_FILE);
-      fclose(fp);
-    }
+               /* Try to use system config file if personal config not readable */
+               if (!current_config && (fp = fopen(SYSTEM_CONFIG_FILE, "r"))) {
+                       current_config = strdup(SYSTEM_CONFIG_FILE);
+                       fclose(fp);
+               }
 
-    /* No readable config found */
-    if (!current_config)
-      CRIT_ERR("no readable personal or system-wide config file found");
+               /* No readable config found */
+               if (!current_config) {
+                       CRIT_ERR("no readable personal or system-wide config file found");
+               }
        }
 
        load_config_file(current_config);
 
        /* init specials array */
-       if ((specials = calloc (sizeof(struct special_t), max_specials)) == 0)
-           ERR("failed to create specials array");
+       if ((specials = calloc(sizeof(struct special_t), max_specials)) == 0) {
+               ERR("failed to create specials array");
+       }
 
 #ifdef MAIL_FILE
        if (current_mail_spool == NULL) {
                char buf[256];
+
                variable_substitute(MAIL_FILE, buf, 256);
 
-               if (buf[0] != '\0')
+               if (buf[0] != '\0') {
                        current_mail_spool = strdup(buf);
+               }
        }
 #endif
 
@@ -7928,73 +8155,74 @@ int main(int argc, char **argv)
 #endif
 
 #if defined(__FreeBSD__) || defined(__FreeBSD_kernel__)
-       if ((kd = kvm_open("/dev/null", "/dev/null", "/dev/null",
-                       O_RDONLY, "kvm_open")) == NULL)
-               CRIT_ERR( "cannot read kvm");
+       if ((kd = kvm_open("/dev/null", "/dev/null", "/dev/null", O_RDONLY,
+                       "kvm_open")) == NULL) {
+               CRIT_ERR("cannot read kvm");
+       }
 #endif
-       
+
        while (1) {
                int c = getopt_long(argc, argv, getopt_string, longopts, NULL);
 
-               if (c == -1)
-               {
+               if (c == -1) {
                        break;
                }
 
                switch (c) {
-               case 'd':
-                       fork_to_background = 1;
-                       break;
+                       case 'd':
+                               fork_to_background = 1;
+                               break;
 
 #ifdef X11
                        case 'f':
-                       set_first_font(optarg);
-                       break;
+                               set_first_font(optarg);
+                               break;
                        case 'a':
                                text_alignment = string_to_alignment(optarg);
                                break;
 
 #ifdef OWN_WINDOW
-               case 'o':
-                       own_window = 1;
-                       break;
+                       case 'o':
+                               own_window = 1;
+                               break;
 #endif
 #ifdef HAVE_XDBE
-               case 'b':
+                       case 'b':
                                use_xdbe = 1;
-                       break;
+                               break;
 #endif
 #endif /* X11 */
-               case 't':
-                       if (!text)
-                               free(text);
-                       text = strdup(optarg);
-                       convert_escapes(text);
-                       break;
+                       case 't':
+                               if (!text) {
+                                       free(text);
+                               }
+                               text = strdup(optarg);
+                               convert_escapes(text);
+                               break;
 
-               case 'u':
-                       update_interval = strtod(optarg, 0);
-                       if (info.music_player_interval == 0) {
-                               // default to update_interval
-                               info.music_player_interval = update_interval;
-                       }
-                       break;
+                       case 'u':
+                               update_interval = strtod(optarg, 0);
+                               if (info.music_player_interval == 0) {
+                                       // default to update_interval
+                                       info.music_player_interval = update_interval;
+                               }
+                               break;
 
-               case 'i':
-                       total_run_times = strtod(optarg, 0);
-                       break;
+                       case 'i':
+                               total_run_times = strtod(optarg, 0);
+                               break;
 #ifdef X11
-               case 'x':
-                       gap_x = atoi(optarg);
-                       break;
+                       case 'x':
+                               gap_x = atoi(optarg);
+                               break;
 
-               case 'y':
-                       gap_y = atoi(optarg);
-                       break;
+                       case 'y':
+                               gap_y = atoi(optarg);
+                               break;
 #endif /* X11 */
 
-               case '?':
-                       exit(EXIT_FAILURE);
+                       case '?':
+                               exit(EXIT_FAILURE);
                }
        }
 
@@ -8012,21 +8240,26 @@ int main(int argc, char **argv)
        /* fork */
        if (fork_to_background) {
                int pid = fork();
+
                switch (pid) {
-               case -1:
-                       ERR("Conky: couldn't fork() to background: %s", strerror(errno));
-                       break;
+                       case -1:
+                               ERR("Conky: couldn't fork() to background: %s",
+                                       strerror(errno));
+                               break;
 
-               case 0:
-                       /* child process */
-                       usleep(25000);
-                       fprintf(stderr,"\n"); fflush(stderr);
-                       break;
+                       case 0:
+                               /* child process */
+                               usleep(25000);
+                               fprintf(stderr, "\n");
+                               fflush(stderr);
+                               break;
 
-               default:
-                       /* parent process */
-                       fprintf(stderr,"Conky: forked to background, pid is %d\n", pid); fflush(stderr);
-                       return 0;
+                       default:
+                               /* parent process */
+                               fprintf(stderr, "Conky: forked to background, pid is %d\n",
+                                       pid);
+                               fflush(stderr);
+                               return 0;
                }
        }
 
@@ -8034,12 +8267,10 @@ int main(int argc, char **argv)
        selected_font = 0;
        update_text_area();     /* to get initial size of the window */
 
-       init_window
-               (own_window,
-                text_width + border_margin * 2 + 1,
-                text_height + border_margin * 2 + 1,
-                set_transparent, background_colour, argv, argc);
-       
+       init_window(own_window, text_width + border_margin * 2 + 1,
+               text_height + border_margin * 2 + 1, set_transparent, background_colour,
+               argv, argc);
+
        selected_font = 0;
        update_text_area();     /* to position text/window on screen */
 #endif /* X11 */
@@ -8060,7 +8291,6 @@ int main(int argc, char **argv)
        draw_stuff();
 #endif /* X11 */
 
-
        /* Set signal handlers */
        act.sa_handler = signal_handler;
        sigemptyset(&act.sa_mask);
@@ -8069,38 +8299,36 @@ int main(int argc, char **argv)
        act.sa_flags |= SA_RESTART;
 #endif
 
-       if ( sigaction(SIGINT,&act,&oact) < 0 ||
-            sigaction(SIGUSR1,&act,&oact) < 0 ||
-            sigaction(SIGTERM,&act,&oact) < 0 )
-       {
-               ERR("error setting signal handler: %s", strerror(errno) );
+       if (sigaction(SIGINT, &act, &oact) < 0
+                       || sigaction(SIGUSR1, &act, &oact) < 0
+                       || sigaction(SIGTERM, &act, &oact) < 0) {
+               ERR("error setting signal handler: %s", strerror(errno));
        }
 
 #ifdef AUDACIOUS
-       if (create_audacious_thread() !=0) 
-           CRIT_ERR("unable to create audacious thread!");
-       timed_thread_register (info.audacious.p_timed_thread, &info.audacious.p_timed_thread);
+       if (create_audacious_thread() != 0) {
+               CRIT_ERR("unable to create audacious thread!");
+       }
+       timed_thread_register(info.audacious.p_timed_thread,
+               &info.audacious.p_timed_thread);
 #endif
 
-  /*
-   * ***************
-   * MAIN CONKY LOOP
-   * ***************
-   *
-   */
-  main_loop();
+       /* *************** *
+        * MAIN CONKY LOOP *
+        * *************** */
+       main_loop();
 
 #if defined(__FreeBSD__) || defined(__FreeBSD_kernel__)
        kvm_close(kd);
 #endif
-       
+
        return 0;
 }
 
 void signal_handler(int sig)
 {
-       /* signal handler is light as a feather, as it should be. 
+       /* signal handler is light as a feather, as it should be.
         * we will poll g_signal_pending with each loop of conky
         * and do any signal processing there, NOT here. */
-       g_signal_pending=sig;
+       g_signal_pending = sig;
 }
index 96db823..c87ffab 100644 (file)
@@ -1,5 +1,4 @@
-/*
- * Conky, a system monitor, based on torsmo
+/* Conky, a system monitor, based on torsmo
  *
  * Any original torsmo code is licensed under the BSD license
  *
@@ -8,7 +7,8 @@
  * Please see COPYING for details
  *
  * Copyright (c) 2004, Hannu Saransaari and Lauri Hakkarainen
- * Copyright (c) 2005-2007 Brenden Matthews, Philip Kovacs, et. al. (see AUTHORS)
+ * Copyright (c) 2005-2007 Brenden Matthews, Philip Kovacs, et. al.
+ *     (see AUTHORS)
  * All rights reserved.
  *
  * This program is free software: you can redistribute it and/or modify
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  * GNU General Public License for more details.
  * You should have received a copy of the GNU General Public License
- * along with this program.  If not, see <http://www.gnu.org/licenses/>. 
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
  *
- *  $Id$
- */
+ * $Id$ */
 
 #ifndef _conky_h_
 #define _conky_h_
@@ -32,6 +31,7 @@
 #if defined(HAS_MCHECK_H)
 #include <mcheck.h>
 #endif /* HAS_MCHECK_H */
+
 #include "config.h"
 #include <sys/utsname.h>
 #include <stdio.h>
 #include <langinfo.h>
 #include <wchar.h>
 #include <sys/param.h>
+
 #if defined(__FreeBSD__) || defined(__FreeBSD_kernel__)
 #include <sys/mount.h>
 #include <sys/ucred.h>
 #include <fcntl.h>
 #include <kvm.h>
-#endif /* __FreeBSD__ */
-
-#if (defined(__FreeBSD__) || defined(__FreeBSD_kernel__)) && (defined(i386) || defined(__i386__))
+#if (defined(i386) || defined(__i386__))
 #include <machine/apm_bios.h>
+#endif /* i386 || __i386__ */
 #endif /* __FreeBSD__ */
 
 #if defined(__OpenBSD__)
@@ -80,7 +80,7 @@
 #define TOP_TIME 5
 
 #define TEXT_BUFFER_SIZE 1280
-#define P_MAX_SIZE ((TEXT_BUFFER_SIZE * 4) - 2) 
+#define P_MAX_SIZE ((TEXT_BUFFER_SIZE * 4) - 2)
 extern unsigned int text_buffer_size;
 
 /* maximum number of special things, e.g. fonts, offsets, aligns, etc. */
@@ -91,12 +91,11 @@ extern unsigned int text_buffer_size;
 
 #include <sys/socket.h>
 
-#define ERR(s, varargs...) \
-fprintf(stderr, "Conky: " s "\n", ##varargs)
+#define ERR(s, varargs...) fprintf(stderr, "Conky: " s "\n", ##varargs)
 
 /* critical error */
 #define CRIT_ERR(s, varargs...) \
-{ fprintf(stderr, "Conky: " s "\n", ##varargs);  exit(EXIT_FAILURE); }
+       { fprintf(stderr, "Conky: " s "\n", ##varargs); exit(EXIT_FAILURE); }
 
 struct i8k_struct {
        char *version;
@@ -160,10 +159,10 @@ struct mail_s {                   // for imap and pop3
        char secure;
 } mail;
 
-/*struct cpu_stat {
+/* struct cpu_stat {
        unsigned int user, nice, system, idle, iowait, irq, softirq;
        int cpu_avg_samples;
-};*/
+}; */
 
 #ifdef MPD
 struct mpd_s {
@@ -191,31 +190,31 @@ struct mpd_s {
 
 #ifdef XMMS2
 struct xmms2_s {
-    char* artist;
-    char* album;
-    char* title;
-    char* genre;
-    char* comment;
-    char* decoder;
-    char* transport;
-    char* url;
-    char* date;
-    int tracknr;
-    int bitrate;
-    unsigned int id;
-    int duration;
-    int elapsed;
-    float size;
-
-    float progress;
-    char* status;
+       char *artist;
+       char *album;
+       char *title;
+       char *genre;
+       char *comment;
+       char *decoder;
+       char *transport;
+       char *url;
+       char *date;
+       int tracknr;
+       int bitrate;
+       unsigned int id;
+       int duration;
+       int elapsed;
+       float size;
+
+       float progress;
+       char *status;
 };
 #endif
 
 #ifdef AUDACIOUS
 struct audacious_s {
-       audacious_t items;              /* e.g. items[AUDACIOUS_STATUS] */
-       int max_title_len;              /* e.g. ${audacious_title 50} */
+       audacious_t items;      /* e.g. items[AUDACIOUS_STATUS] */
+       int max_title_len;      /* e.g. ${audacious_title 50} */
        timed_thread *p_timed_thread;
 };
 #endif
@@ -266,7 +265,7 @@ enum {
        INFO_DISKIO = 17,
        INFO_I8K = 18,
 #ifdef TCP_PORT_MONITOR
-  INFO_TCP_PORT_MONITOR = 19,
+       INFO_TCP_PORT_MONITOR = 19,
 #endif
 #ifdef AUDACIOUS
        INFO_AUDACIOUS = 20,
@@ -283,7 +282,6 @@ enum {
 #endif
 };
 
-
 /* get_battery_stuff() item selector */
 enum {
        BATTERY_STATUS,
@@ -316,7 +314,7 @@ struct information {
        unsigned short run_procs;
 
        float *cpu_usage;
-       /*      struct cpu_stat cpu_summed; what the hell is this? */
+       /* struct cpu_stat cpu_summed; what the hell is this? */
        unsigned int cpu_count;
        unsigned int cpu_avg_samples;
 
@@ -324,7 +322,7 @@ struct information {
 
        float loadavg[3];
 
-       struct mail_s* mail;
+       struct mail_s *mail;
        int mail_running;
 #ifdef MPD
        struct mpd_s mpd;
@@ -333,7 +331,7 @@ struct information {
 #ifdef XMMS2
        struct xmms2_s xmms2;
        int xmms2_conn_state;
-       xmms_socket_t xmms2_fd; 
+       xmms_socket_t xmms2_fd;
        fd_set xmms2_fdset;
        xmmsc_connection_t *xmms2_conn;
 #endif
@@ -348,26 +346,29 @@ struct information {
        struct process *first_process;
        unsigned long looped;
 #ifdef TCP_PORT_MONITOR
-  tcp_port_monitor_collection_t * p_tcp_port_monitor_collection;
+       tcp_port_monitor_collection_t *p_tcp_port_monitor_collection;
 #endif
        struct entropy_s entropy;
-  double music_player_interval;
+       double music_player_interval;
 
-       short kflags;  /* kernel settings, see enum KFLAG */
+       short kflags;   /* kernel settings, see enum KFLAG */
 };
 
 enum {
-       KFLAG_IS_LONGSTAT = 0x01,         /* set to true if kernel uses "long" format for /proc/stats */
-       KFLAG_PROC_IS_THREADS=0x02       /* set to true if kernel shows # of threads for the proc value in sysinfo() call */
-/*     KFLAG_NEXT_ONE=0x04                 bits 0x04, 0x08, 0x10, 0x20, 0x40, 0x80 available for future use */
-     };        
+       /* set to true if kernel uses "long" format for /proc/stats */
+       KFLAG_IS_LONGSTAT = 0x01,
+       /* set to true if kernel shows # of threads for the proc value
+        * in sysinfo() call */
+       KFLAG_PROC_IS_THREADS = 0x02
+       /* bits 0x04, 0x08, 0x10, 0x20, 0x40, 0x80 available for future use */
+       /* KFLAG_NEXT_ONE = 0x04 */
+};
 
-#define KFLAG_SETON(a) info.kflags |= a 
+#define KFLAG_SETON(a) info.kflags |= a
 #define KFLAG_SETOFF(a) info.kflags &= (~a)
 #define KFLAG_FLIP(a) info.kflags ^= a
 #define KFLAG_ISSET(a) info.kflags & a
 
-
 int out_to_console;
 
 int top_cpu;
@@ -399,8 +400,8 @@ char tmpstring2[TEXT_BUFFER_SIZE];
 
 #ifdef OWN_WINDOW
 enum _window_type {
-        TYPE_NORMAL = 0,
-        TYPE_DESKTOP,
+       TYPE_NORMAL = 0,
+       TYPE_DESKTOP,
        TYPE_OVERRIDE
 };
 
@@ -412,11 +413,13 @@ enum _window_hints {
        HINT_SKIP_TASKBAR,
        HINT_SKIP_PAGER
 };
-#define SET_HINT(mask,hint)    (mask |= (1<<hint))
-#define TEST_HINT(mask,hint)   (mask & (1<<hint))
+
+#define SET_HINT(mask, hint)   (mask |= (1 << hint))
+#define TEST_HINT(mask, hint)  (mask & (1 << hint))
 #endif
+
 struct conky_window {
-       Window root,window,desktop;
+       Window root, window, desktop;
        Drawable drawable;
        GC gc;
 #ifdef HAVE_XDBE
@@ -430,7 +433,7 @@ struct conky_window {
        int height;
 #ifdef OWN_WINDOW
        char class_name[256];
-  char title[256];
+       char title[256];
        int x;
        int y;
        unsigned int type;
@@ -442,7 +445,6 @@ struct conky_window {
 extern int use_xdbe;
 #endif
 
-
 #ifdef XFT
 extern int use_xft;
 #endif
@@ -457,8 +459,8 @@ extern int workarea[4];
 extern struct conky_window window;
 
 void init_X11();
-void init_window(int use_own_window, int width, int height, int set_trans, int back_colour, 
-                 char **argv, int argc);
+void init_window(int use_own_window, int width, int height, int set_trans,
+       int back_colour, char **argv, int argc);
 void create_gc();
 void set_transparent_background(Window win);
 long get_x11_color(const char *);
@@ -508,31 +510,31 @@ void update_cpu_usage(void);
 void update_total_processes(void);
 void update_running_processes(void);
 void update_i8k(void);
-char get_freq( char *, size_t, char *, int, unsigned int ); 
-void get_freq_dynamic( char *, size_t, char *, int ); 
-char get_voltage(char *, size_t, char *, int, unsigned int ); /* ptarjan */
+char get_freq(char *, size_t, char *, int, unsigned int);
+void get_freq_dynamic(char *, size_t, char *, int);
+char get_voltage(char *, size_t, char *, int, unsigned int);   /* ptarjan */
 void update_load_average();
 
-int open_sysfs_sensor(const char *dir, const char *dev, const char *type, int n, int *div, char *devtype);
-#define open_i2c_sensor(dev,type,n,div,devtype) \
-    open_sysfs_sensor("/sys/bus/i2c/devices/",dev,type,n,div,devtype)
-
-#define open_platform_sensor(dev,type,n,div,devtype) \
-    open_sysfs_sensor("/sys/bus/platform/devices/",dev,type,n,div,devtype)
+int open_sysfs_sensor(const char *dir, const char *dev, const char *type, int n,
+       int *div, char *devtype);
 
-#define open_hwmon_sensor(dev,type,n,div,devtype) \
-   open_sysfs_sensor("/sys/class/hwmon/",dev,type,n,div,devtype); \
+#define open_i2c_sensor(dev, type, n, div, devtype) \
+       open_sysfs_sensor("/sys/bus/i2c/devices/", dev, type, n, div, devtype)
+#define open_platform_sensor(dev, type, n, div, devtype) \
+       open_sysfs_sensor("/sys/bus/platform/devices/", dev, type, n, div, devtype)
+#define open_hwmon_sensor(dev, type, n, div, devtype) \
+       open_sysfs_sensor("/sys/class/hwmon/", dev, type, n, div, devtype)
 
 double get_sysfs_info(int *fd, int arg, char *devtype, char *type);
 
-void get_adt746x_cpu( char *, size_t ); 
-void get_adt746x_fan( char *, size_t ); 
+void get_adt746x_cpu(char *, size_t);
+void get_adt746x_fan(char *, size_t);
 unsigned int get_diskio(void);
 
 int open_acpi_temperature(const char *name);
 double get_acpi_temperature(int fd);
-void get_acpi_ac_adapter( char *, size_t ); 
-void get_acpi_fan( char *, size_t ); 
+void get_acpi_ac_adapter(char *, size_t);
+void get_acpi_fan(char *, size_t);
 void get_battery_stuff(char *buf, unsigned int n, const char *bat, int item);
 int get_battery_perct(const char *bat);
 int get_battery_perct_bar(const char *bat);
@@ -543,7 +545,7 @@ void get_ibm_acpi_brightness(char *buf, size_t client_buffer_size);
 void get_cpu_count();
 
 struct ibm_acpi_struct {
-    unsigned int temps[8];
+       unsigned int temps[8];
 };
 
 struct ibm_acpi_struct ibm_acpi;
@@ -563,9 +565,8 @@ struct obsd_sensors_struct {
 struct obsd_sensors_struct obsd_sensors;
 #endif /* __OpenBSD__ */
 
-
-enum { PB_BATT_STATUS, PB_BATT_PERCENT, PB_BATT_TIME};
-void get_powerbook_batt_info(char*, size_t, int);
+enum { PB_BATT_STATUS, PB_BATT_PERCENT, PB_BATT_TIME };
+void get_powerbook_batt_info(char *, size_t, int);
 
 struct process {
        struct process *next;
@@ -625,7 +626,8 @@ void update_mail_count();
 kvm_t *kd;
 #endif
 
-#if (defined(__FreeBSD__) || defined(__FreeBSD_kernel__) || defined(__OpenBSD__)) && (defined(i386) || defined(__i386__))
+#if (defined(__FreeBSD__) || defined(__FreeBSD_kernel__) \
+               || defined(__OpenBSD__)) && (defined(i386) || defined(__i386__))
 #ifdef __OpenBSD__
 typedef struct apm_power_info *apm_info_t;
 #endif
@@ -655,7 +657,7 @@ char *get_hddtemp_info(char *dev, char *addr, int port, char *unit);
 
 /* in rss.c */
 #ifdef RSS
-PRSS* get_rss_info(char *uri, int delay);
+PRSS *get_rss_info(char *uri, int delay);
 void init_rss_info();
 void free_rss_info();
 #endif /* RSS */
@@ -663,5 +665,3 @@ void free_rss_info();
 /* in linux.c */
 
 #endif
-
-
index 8b754a6..920fb89 100644 (file)
@@ -1,5 +1,4 @@
-/*
- * Conky, a system monitor, based on torsmo
+/* Conky, a system monitor, based on torsmo
  *
  * Any original torsmo code is licensed under the BSD license
  *
@@ -7,7 +6,8 @@
  *
  * Please see COPYING for details
  *
- * Copyright (c) 2005-2007 Brenden Matthews, Philip Kovacs, et. al. (see AUTHORS)
+ * Copyright (c) 2005-2007 Brenden Matthews, Philip Kovacs, et. al.
+ *     (see AUTHORS)
  * All rights reserved.
  *
  * This program is free software: you can redistribute it and/or modify
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  * GNU General Public License for more details.
  * You should have received a copy of the GNU General Public License
- * along with this program.  If not, see <http://www.gnu.org/licenses/>. 
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
  *
- *  $Id$
- */
+ * $Id$ */
 
 #include <sys/dkstat.h>
 #include <sys/param.h>
@@ -55,9 +54,9 @@
 
 #include "conky.h"
 
-#define        GETSYSCTL(name, var)    getsysctl(name, &(var), sizeof (var))
-#define        KELVTOC(x)              ((x - 2732) / 10.0)
-#define        MAXSHOWDEVS             16
+#define        GETSYSCTL(name, var)    getsysctl(name, &(var), sizeof(var))
+#define        KELVTOC(x)                              ((x - 2732) / 10.0)
+#define        MAXSHOWDEVS                             16
 
 #if 0
 #define        FREEBSD_DEBUG
@@ -72,15 +71,16 @@ static short diskio_setup = 0;
 static int getsysctl(char *name, void *ptr, size_t len)
 {
        size_t nlen = len;
+
        if (sysctlbyname(name, ptr, &nlen, NULL, 0) == -1) {
-               return (-1);
+               return -1;
        }
 
        if (nlen != len) {
-               return (-1);
+               return -1;
        }
 
-       return (0);
+       return 0;
 }
 
 struct ifmibdata *data = NULL;
@@ -95,11 +95,12 @@ static int swapmode(int *retavail, int *retfree)
        *retavail = 0;
        *retfree = 0;
 
-#define        CONVERT(v)      ((quad_t)(v) * pagesize / 1024)
+#define        CONVERT(v)      ((quad_t) (v) * pagesize / 1024)
 
        n = kvm_getswapinfo(kd, swapary, 1, 0);
-       if (n < 0 || swapary[0].ksw_total == 0)
-               return (0);
+       if (n < 0 || swapary[0].ksw_total == 0) {
+               return 0;
+       }
 
        *retavail = CONVERT(swapary[0].ksw_total);
        *retfree = CONVERT(swapary[0].ksw_total - swapary[0].ksw_used);
@@ -107,24 +108,22 @@ static int swapmode(int *retavail, int *retfree)
        n = (int) ((double) swapary[0].ksw_used * 100.0 /
                (double) swapary[0].ksw_total);
 
-       return (n);
+       return n;
 }
 
-void
-prepare_update()
+void prepare_update()
 {
 }
 
-void
-update_uptime()
+void update_uptime()
 {
        int mib[2] = { CTL_KERN, KERN_BOOTTIME };
        struct timeval boottime;
        time_t now;
-       size_t size = sizeof (boottime);
+       size_t size = sizeof(boottime);
 
-       if ((sysctl(mib, 2, &boottime, &size, NULL, 0) != -1) &&
-                       (boottime.tv_sec != 0)) {
+       if ((sysctl(mib, 2, &boottime, &size, NULL, 0) != -1)
+                       && (boottime.tv_sec != 0)) {
                time(&now);
                info.uptime = now - boottime.tv_sec;
        } else {
@@ -139,37 +138,36 @@ int check_mount(char *s)
        int i, mntsize;
 
        mntsize = getmntinfo(&mntbuf, MNT_NOWAIT);
-       for (i = mntsize - 1; i >= 0; i--)
-               if (strcmp(mntbuf[i].f_mntonname, s) == 0)
+       for (i = mntsize - 1; i >= 0; i--) {
+               if (strcmp(mntbuf[i].f_mntonname, s) == 0) {
                        return 1;
+               }
+       }
 
        return 0;
 }
 
-void
-update_meminfo()
+void update_meminfo()
 {
        int total_pages, inactive_pages, free_pages;
        int swap_avail, swap_free;
 
        int pagesize = getpagesize();
 
-       if (GETSYSCTL("vm.stats.vm.v_page_count", total_pages))
-               fprintf(stderr,
-                       "Cannot read sysctl \"vm.stats.vm.v_page_count\"");
+       if (GETSYSCTL("vm.stats.vm.v_page_count", total_pages)) {
+               fprintf(stderr, "Cannot read sysctl \"vm.stats.vm.v_page_count\"");
+       }
 
-       if (GETSYSCTL("vm.stats.vm.v_free_count", free_pages))
-               fprintf(stderr,
-                       "Cannot read sysctl \"vm.stats.vm.v_free_count\"");
+       if (GETSYSCTL("vm.stats.vm.v_free_count", free_pages)) {
+               fprintf(stderr, "Cannot read sysctl \"vm.stats.vm.v_free_count\"");
+       }
 
-       if (GETSYSCTL("vm.stats.vm.v_inactive_count", inactive_pages))
-               fprintf(stderr,
-                       "Cannot read sysctl \"vm.stats.vm.v_inactive_count\"");
+       if (GETSYSCTL("vm.stats.vm.v_inactive_count", inactive_pages)) {
+               fprintf(stderr, "Cannot read sysctl \"vm.stats.vm.v_inactive_count\"");
+       }
 
        info.memmax = (total_pages * pagesize) >> 10;
-       info.mem =
-           ((total_pages - free_pages - inactive_pages) * pagesize) >> 10;
-
+       info.mem = ((total_pages - free_pages - inactive_pages) * pagesize) >> 10;
 
        if ((swapmode(&swap_avail, &swap_free)) >= 0) {
                info.swapmax = swap_avail;
@@ -180,8 +178,7 @@ update_meminfo()
        }
 }
 
-void
-update_net_stats()
+void update_net_stats()
 {
        struct net_stat *ns;
        double delta;
@@ -189,14 +186,15 @@ update_net_stats()
        struct ifaddrs *ifap, *ifa;
        struct if_data *ifd;
 
-
        /* get delta */
        delta = current_update_time - last_update_time;
-       if (delta <= 0.0001)
+       if (delta <= 0.0001) {
                return;
+       }
 
-       if (getifaddrs(&ifap) < 0)
+       if (getifaddrs(&ifap) < 0) {
                return;
+       }
 
        for (ifa = ifap; ifa; ifa = ifa->ifa_next) {
                ns = get_net_stat((const char *) ifa->ifa_name);
@@ -208,35 +206,37 @@ update_net_stats()
                        last_recv = ns->recv;
                        last_trans = ns->trans;
 
-                       if (ifa->ifa_addr->sa_family != AF_LINK)
+                       if (ifa->ifa_addr->sa_family != AF_LINK) {
                                continue;
+                       }
 
-                       for (iftmp = ifa->ifa_next; iftmp != NULL &&
-                               strcmp(ifa->ifa_name, iftmp->ifa_name) == 0;
-                               iftmp = iftmp->ifa_next)
-                               if (iftmp->ifa_addr->sa_family == AF_INET)
+                       for (iftmp = ifa->ifa_next;
+                                       iftmp != NULL && strcmp(ifa->ifa_name, iftmp->ifa_name) == 0;
+                                       iftmp = iftmp->ifa_next) {
+                               if (iftmp->ifa_addr->sa_family == AF_INET) {
                                        memcpy(&(ns->addr), iftmp->ifa_addr,
                                                iftmp->ifa_addr->sa_len);
+                               }
+                       }
 
                        ifd = (struct if_data *) ifa->ifa_data;
                        r = ifd->ifi_ibytes;
                        t = ifd->ifi_obytes;
 
-                       if (r < ns->last_read_recv)
-                               ns->recv +=
-                                   ((long long) 4294967295U -
-                                       ns->last_read_recv) + r;
-                       else
+                       if (r < ns->last_read_recv) {
+                               ns->recv += ((long long) 4294967295U - ns->last_read_recv) + r;
+                       } else {
                                ns->recv += (r - ns->last_read_recv);
+                       }
 
                        ns->last_read_recv = r;
 
-                       if (t < ns->last_read_trans)
-                               ns->trans +=
-                                   ((long long) 4294967295U -
+                       if (t < ns->last_read_trans) {
+                               ns->trans += ((long long) 4294967295U -
                                        ns->last_read_trans) + t;
-                       else
+                       } else {
                                ns->trans += (t - ns->last_read_trans);
+                       }
 
                        ns->last_read_trans = t;
 
@@ -251,8 +251,7 @@ update_net_stats()
        freeifaddrs(ifap);
 }
 
-void
-update_total_processes()
+void update_total_processes()
 {
        int n_processes;
 
@@ -261,8 +260,7 @@ update_total_processes()
        info.procs = n_processes;
 }
 
-void
-update_running_processes()
+void update_running_processes()
 {
        struct kinfo_proc *p;
        int n_processes;
@@ -271,11 +269,12 @@ update_running_processes()
        p = kvm_getprocs(kd, KERN_PROC_ALL, 0, &n_processes);
        for (i = 0; i < n_processes; i++) {
 #if (__FreeBSD__ < 5) && (__FreeBSD_kernel__ < 5)
-               if (p[i].kp_proc.p_stat == SRUN)
+               if (p[i].kp_proc.p_stat == SRUN) {
 #else
-               if (p[i].ki_stat == SRUN)
+               if (p[i].ki_stat == SRUN) {
 #endif
                        cnt++;
+               }
        }
 
        info.run_procs = cnt;
@@ -288,37 +287,33 @@ struct cpu_load_struct {
 struct cpu_load_struct fresh = { {0, 0, 0, 0, 0} };
 long cpu_used, oldtotal, oldused;
 
-void
-get_cpu_count()
+void get_cpu_count()
 {
        /* int cpu_count = 0; */
 
-       /*
-        * XXX
-        * FreeBSD doesn't allow to get per CPU load stats
-        * on SMP machines. It's possible to get a CPU count,
-        * but as we fulfil only info.cpu_usage[0], it's better
-        * to report there's only one CPU. It should fix some bugs
-        * (e.g. cpugraph)
-        */
+       /* XXX: FreeBSD doesn't allow to get per CPU load stats on SMP machines.
+        * It's possible to get a CPU count, but as we fulfill only
+        * info.cpu_usage[0], it's better to report there's only one CPU.
+        * It should fix some bugs (e.g. cpugraph) */
 #if 0
-       if (GETSYSCTL("hw.ncpu", cpu_count) == 0)
+       if (GETSYSCTL("hw.ncpu", cpu_count) == 0) {
                info.cpu_count = cpu_count;
+       }
 #endif
        info.cpu_count = 1;
 
-       info.cpu_usage = malloc(info.cpu_count * sizeof (float));
-       if (info.cpu_usage == NULL)
+       info.cpu_usage = malloc(info.cpu_count * sizeof(float));
+       if (info.cpu_usage == NULL) {
                CRIT_ERR("malloc");
+       }
 }
 
 /* XXX: SMP support */
-void
-update_cpu_usage()
+void update_cpu_usage()
 {
        long used, total;
        long cp_time[CPUSTATES];
-       size_t len = sizeof (cp_time);
+       size_t len = sizeof(cp_time);
 
        /* add check for !info.cpu_usage since that mem is freed on a SIGUSR1 */
        if ((cpu_setup == 0) || (!info.cpu_usage)) {
@@ -327,7 +322,7 @@ update_cpu_usage()
        }
 
        if (sysctlbyname("kern.cp_time", &cp_time, &len, NULL, 0) < 0) {
-               (void) fprintf(stderr, "Cannot get kern.cp_time");
+               fprintf(stderr, "Cannot get kern.cp_time");
        }
 
        fresh.load[0] = cp_time[CP_USER];
@@ -337,8 +332,7 @@ update_cpu_usage()
        fresh.load[4] = cp_time[CP_IDLE];
 
        used = fresh.load[0] + fresh.load[1] + fresh.load[2];
-       total =
-           fresh.load[0] + fresh.load[1] + fresh.load[2] + fresh.load[3];
+       total = fresh.load[0] + fresh.load[1] + fresh.load[2] + fresh.load[3];
 
        if ((total - oldtotal) != 0) {
                info.cpu_usage[0] = ((double) (used - oldused)) /
@@ -351,16 +345,15 @@ update_cpu_usage()
        oldtotal = total;
 }
 
-double
-get_sysfs_info(int *fd, int arg, char *devtype, char *type)
+double get_sysfs_info(int *fd, int arg, char *devtype, char *type)
 {
        return 0.0;
 }
 
-void
-update_load_average()
+void update_load_average()
 {
        double v[3];
+
        getloadavg(v, 3);
 
        info.loadavg[0] = (double) v[0];
@@ -368,187 +361,164 @@ update_load_average()
        info.loadavg[2] = (double) v[2];
 }
 
-double
-get_acpi_temperature(int fd)
+double get_acpi_temperature(int fd)
 {
        int temp;
 
        if (GETSYSCTL("hw.acpi.thermal.tz0.temperature", temp)) {
                fprintf(stderr,
-               "Cannot read sysctl \"hw.acpi.thermal.tz0.temperature\"\n");
-               return (0.0);
+                       "Cannot read sysctl \"hw.acpi.thermal.tz0.temperature\"\n");
+               return 0.0;
        }
 
-       return (KELVTOC(temp));
+       return KELVTOC(temp);
 }
 
-void
-get_battery_stuff(char *buf, unsigned int n, const char *bat, int item)
+void get_battery_stuff(char *buf, unsigned int n, const char *bat, int item)
 {
        int battime, batcapacity, batstate, ac;
        char battery_status[64];
        char battery_time[64];
 
-       if (GETSYSCTL("hw.acpi.battery.time", battime))
-               (void) fprintf(stderr,
-                       "Cannot read sysctl \"hw.acpi.battery.time\"\n");
-       if (GETSYSCTL("hw.acpi.battery.life", batcapacity))
-               (void) fprintf(stderr,
-                                          "Cannot read sysctl \"hw.acpi.battery.life\"\n");
+       if (GETSYSCTL("hw.acpi.battery.time", battime)) {
+               fprintf(stderr, "Cannot read sysctl \"hw.acpi.battery.time\"\n");
+       }
+       if (GETSYSCTL("hw.acpi.battery.life", batcapacity)) {
+               fprintf(stderr, "Cannot read sysctl \"hw.acpi.battery.life\"\n");
+       }
 
-       if (GETSYSCTL("hw.acpi.battery.state", batstate))
-               (void) fprintf(stderr,
-                                          "Cannot read sysctl \"hw.acpi.battery.state\"\n");
+       if (GETSYSCTL("hw.acpi.battery.state", batstate)) {
+               fprintf(stderr, "Cannot read sysctl \"hw.acpi.battery.state\"\n");
+       }
 
-       if (GETSYSCTL("hw.acpi.acline", ac))
-               (void) fprintf(stderr,
-                                          "Cannot read sysctl \"hw.acpi.acline\"\n");
+       if (GETSYSCTL("hw.acpi.acline", ac)) {
+               fprintf(stderr, "Cannot read sysctl \"hw.acpi.acline\"\n");
+       }
 
        if (batstate == 1) {
                if (battime != -1) {
-                       snprintf (battery_status, sizeof(battery_status)-1,
-                                 "remaining %d%%", batcapacity);
-                       snprintf (battery_time, sizeof(battery_time)-1,
-                                 "%d:%2.2d", battime / 60, battime % 60);
-                       /*
-                       snprintf(buf, n, "remaining %d%% (%d:%2.2d)",
-                                       batcapacity, battime / 60, battime % 60);
-                       */
-               }
-               else
+                       snprintf(battery_status, sizeof(battery_status) - 1,
+                               "remaining %d%%", batcapacity);
+                       snprintf(battery_time, sizeof(battery_time) - 1, "%d:%2.2d",
+                               battime / 60, battime % 60);
+                       /* snprintf(buf, n, "remaining %d%% (%d:%2.2d)", batcapacity,
+                               battime / 60, battime % 60); */
+               } else {
                        /* no time estimate available yet */
-                       snprintf(battery_status, sizeof(battery_status)-1,
-                                "remaining %d%%", batcapacity);
-                       /*
-                       snprintf(buf, n, "remaining %d%%",
-                                       batcapacity);
-                       */
-               if (ac == 1)
-                       (void) fprintf(stderr, "Discharging while on AC!\n");
+                       snprintf(battery_status, sizeof(battery_status) - 1,
+                               "remaining %d%%", batcapacity);
+               }
+               /* snprintf(buf, n, "remaining %d%%", batcapacity); */
+               if (ac == 1) {
+                       fprintf(stderr, "Discharging while on AC!\n");
+               }
        } else {
-               snprintf (battery_status, sizeof(battery_status)-1,
-                         batstate == 2 ? "charging (%d%%)" : "charged (%d%%)", batcapacity);
-               /*
-               snprintf(buf, n, batstate == 2 ? "charging (%d%%)" : "charged (%d%%)", batcapacity);
-               */
-               if (batstate != 2 && batstate != 0)
-                       (void) fprintf(stderr, "Unknown battery state %d!\n", batstate);
-               if (ac == 0)
-                       (void) fprintf(stderr, "Charging while not on AC!\n");
+               snprintf(battery_status, sizeof(battery_status) - 1,
+                       batstate == 2 ? "charging (%d%%)" : "charged (%d%%)", batcapacity);
+               /* snprintf(buf, n,
+                       batstate == 2 ? "charging (%d%%)" : "charged (%d%%)",
+                       batcapacity); */
+               if (batstate != 2 && batstate != 0) {
+                       fprintf(stderr, "Unknown battery state %d!\n", batstate);
+               }
+               if (ac == 0) {
+                       fprintf(stderr, "Charging while not on AC!\n");
+               }
        }
 
        switch (item) {
-        case BATTERY_STATUS:
-                {
-                        snprintf(buf, n, "%s", battery_status);
-                        break;
-                }
-        case BATTERY_TIME:
-                {
-                        snprintf(buf, n, "%s", battery_time);
-                        break;
-                }
-        default:
-                        break;
-        }
-        return;
-}
-
-int
-get_battery_perct(const char *bat)
+               case BATTERY_STATUS:
+                       snprintf(buf, n, "%s", battery_status);
+                       break;
+               case BATTERY_TIME:
+                       snprintf(buf, n, "%s", battery_time);
+                       break;
+               default:
+                       break;
+       }
+}
+
+int get_battery_perct(const char *bat)
 {
        /* not implemented */
-       return (0);
+       return 0;
 }
 
-int
-get_battery_perct_bar(const char *bar)
+int get_battery_perct_bar(const char *bar)
 {
        /* not implemented */
-       return (0);
+       return 0;
 }
 
-int
-open_sysfs_sensor(const char *dir, const char *dev, const char *type, int n, int *div, char *devtype)
+int open_sysfs_sensor(const char *dir, const char *dev, const char *type,
+               int n, int *div, char *devtype)
 {
-       return (0);
+       return 0;
 }
 
-int
-open_acpi_temperature(const char *name)
+int open_acpi_temperature(const char *name)
 {
-       return (0);
+       return 0;
 }
 
-void
-get_acpi_ac_adapter(char *p_client_buffer, size_t client_buffer_size)
+void get_acpi_ac_adapter(char *p_client_buffer, size_t client_buffer_size)
 {
        int state;
 
-       if (!p_client_buffer || client_buffer_size <= 0)
+       if (!p_client_buffer || client_buffer_size <= 0) {
                return;
+       }
 
        if (GETSYSCTL("hw.acpi.acline", state)) {
-               fprintf(stderr,
-                       "Cannot read sysctl \"hw.acpi.acline\"\n");
+               fprintf(stderr, "Cannot read sysctl \"hw.acpi.acline\"\n");
                return;
        }
 
-
-       if (state)
-               strncpy(p_client_buffer, "Running on AC Power",
-                               client_buffer_size);
-       else
-               strncpy(p_client_buffer, "Running on battery",
-                               client_buffer_size);
-
+       if (state) {
+               strncpy(p_client_buffer, "Running on AC Power", client_buffer_size);
+       } else {
+               strncpy(p_client_buffer, "Running on battery", client_buffer_size);
+       }
 }
 
-void
-get_acpi_fan(char *p_client_buffer, size_t client_buffer_size)
+void get_acpi_fan(char *p_client_buffer, size_t client_buffer_size)
 {
-       if (!p_client_buffer || client_buffer_size <= 0)
-               return;
-
        /* not implemented */
-       memset(p_client_buffer, 0, client_buffer_size);
+       if (p_client_buffer && client_buffer_size > 0) {
+               memset(p_client_buffer, 0, client_buffer_size);
+       }
 }
 
-void
-get_adt746x_cpu(char *p_client_buffer, size_t client_buffer_size)
+void get_adt746x_cpu(char *p_client_buffer, size_t client_buffer_size)
 {
-       if (!p_client_buffer || client_buffer_size <= 0)
-               return;
-
        /* not implemented */
-       memset(p_client_buffer, 0, client_buffer_size);
+       if (p_client_buffer && client_buffer_size > 0) {
+               memset(p_client_buffer, 0, client_buffer_size);
+       }
 }
 
-void
-get_adt746x_fan(char *p_client_buffer, size_t client_buffer_size)
+void get_adt746x_fan(char *p_client_buffer, size_t client_buffer_size)
 {
-       if (!p_client_buffer || client_buffer_size <= 0)
-               return;
-
        /* not implemented */
-       memset(p_client_buffer, 0, client_buffer_size);
+       if (p_client_buffer && client_buffer_size > 0) {
+               memset(p_client_buffer, 0, client_buffer_size);
+       }
 }
 
 /* rdtsc() and get_freq_dynamic() copied from linux.c */
 
 #if  defined(__i386) || defined(__x86_64)
-__inline__ unsigned long long int
-rdtsc()
+__inline__ unsigned long long int rdtsc()
 {
        unsigned long long int x;
+
        __asm__ volatile(".byte 0x0f, 0x31":"=A" (x));
-       return (x);
+       return x;
 }
 #endif
 
 /* return system frequency in MHz (use divisor=1) or GHz (use divisor=1000) */
-void
-get_freq_dynamic(char *p_client_buffer, size_t client_buffer_size,
+void get_freq_dynamic(char *p_client_buffer, size_t client_buffer_size,
                char *p_format, int divisor)
 {
 #if  defined(__i386) || defined(__x86_64)
@@ -557,7 +527,7 @@ get_freq_dynamic(char *p_client_buffer, size_t client_buffer_size,
        unsigned long long cycles[2];   /* gotta be 64 bit */
        unsigned int microseconds;      /* total time taken */
 
-       memset(&tz, 0, sizeof (tz));
+       memset(&tz, 0, sizeof(tz));
 
        /* get this function in cached memory */
        gettimeofday(&tvstart, &tz);
@@ -572,62 +542,61 @@ get_freq_dynamic(char *p_client_buffer, size_t client_buffer_size,
                (tvstop.tv_usec - tvstart.tv_usec);
 
        snprintf(p_client_buffer, client_buffer_size, p_format,
-               (float)((cycles[1] - cycles[0]) / microseconds) / divisor);
+               (float) ((cycles[1] - cycles[0]) / microseconds) / divisor);
 #else
        get_freq(p_client_buffer, client_buffer_size, p_format, divisor, 1);
 #endif
 }
 
-/*void*/
-char
-get_freq(char *p_client_buffer, size_t client_buffer_size,
-               char *p_format, int divisor, unsigned int cpu)
+/* void */
+char get_freq(char *p_client_buffer, size_t client_buffer_size, char *p_format,
+               int divisor, unsigned int cpu)
 {
        int freq;
        char *freq_sysctl;
 
-       freq_sysctl = (char *)calloc(16, sizeof(char));
-       if (freq_sysctl == NULL)
+       freq_sysctl = (char *) calloc(16, sizeof(char));
+       if (freq_sysctl == NULL) {
                exit(-1);
+       }
 
        snprintf(freq_sysctl, 16, "dev.cpu.%d.freq", (cpu - 1));
-       
-       if (!p_client_buffer || client_buffer_size <= 0 ||
-                       !p_format || divisor <= 0)
+
+       if (!p_client_buffer || client_buffer_size <= 0 || !p_format
+                       || divisor <= 0) {
                return 0;
+       }
 
-       if (GETSYSCTL(freq_sysctl, freq) == 0)
-               snprintf(p_client_buffer, client_buffer_size,
-                               p_format, (float)freq/divisor);
-       else
+       if (GETSYSCTL(freq_sysctl, freq) == 0) {
+               snprintf(p_client_buffer, client_buffer_size, p_format,
+                       (float) freq / divisor);
+       } else {
                snprintf(p_client_buffer, client_buffer_size, p_format, 0.0f);
+       }
 
        free(freq_sysctl);
        return 1;
 }
 
-void
-update_top()
+void update_top()
 {
        proc_find_top(info.cpu, info.memu);
 }
 
 #if 0
-void
-update_wifi_stats()
+void update_wifi_stats()
 {
        struct ifreq ifr;               /* interface stats */
        struct wi_req wireq;
-       struct net_stat * ns;
+       struct net_stat *ns;
        struct ifaddrs *ifap, *ifa;
        struct ifmediareq ifmr;
        int s;
 
-       /*
-        * Get iface table
-        */
-       if (getifaddrs(&ifap) < 0)
+       /* Get iface table */
+       if (getifaddrs(&ifap) < 0) {
                return;
+       }
 
        for (ifa = ifap; ifa; ifa = ifa->ifa_next) {
                ns = get_net_stat((const char *) ifa->ifa_name);
@@ -637,32 +606,29 @@ update_wifi_stats()
                /* Get media type */
                bzero(&ifmr, sizeof(ifmr));
                strlcpy(ifmr.ifm_name, ifa->ifa_name, IFNAMSIZ);
-               if (ioctl(s, SIOCGIFMEDIA, (caddr_t) &ifmr) < 0)
+               if (ioctl(s, SIOCGIFMEDIA, (caddr_t) &ifmr) < 0) {
                        goto cleanup;
-               
-               /*
-                * We can monitor only wireless interfaces
-                * which not in hostap mode
-                */
-               if ((ifmr.ifm_active & IFM_IEEE80211) &&
-                               !(ifmr.ifm_active & IFM_IEEE80211_HOSTAP)) {
+               }
+
+               /* We can monitor only wireless interfaces
+                * which are not in hostap mode */
+               if ((ifmr.ifm_active & IFM_IEEE80211)
+                               && !(ifmr.ifm_active & IFM_IEEE80211_HOSTAP)) {
                        /* Get wi status */
                        bzero(&ifr, sizeof(ifr));
                        strlcpy(ifr.ifr_name, ifa->ifa_name, IFNAMSIZ);
-                       wireq.wi_type   = WI_RID_COMMS_QUALITY;
-                       wireq.wi_len    = WI_MAX_DATALEN;
-                       ifr.ifr_data    = (void *) &wireq;
+                       wireq.wi_type = WI_RID_COMMS_QUALITY;
+                       wireq.wi_len = WI_MAX_DATALEN;
+                       ifr.ifr_data = (void *) &wireq;
 
                        if (ioctl(s, SIOCGWAVELAN, (caddr_t) &ifr) < 0) {
                                perror("ioctl (getting wi status)");
                                exit(1);
                        }
 
-                       /*
-                        * wi_val[0] = quality
+                       /* wi_val[0] = quality
                         * wi_val[1] = signal
-                        * wi_val[2] = noise
-                        */
+                        * wi_val[2] = noise */
                        ns->linkstatus = (int) wireq.wi_val[1];
                }
 cleanup:
@@ -671,50 +637,49 @@ cleanup:
 }
 #endif
 
-void
-update_diskio()
+void update_diskio()
 {
        int devs_count, num_selected, num_selections, i;
        struct device_selection *dev_select = NULL;
        long select_generation;
        int dn;
-       static struct statinfo  statinfo_cur;
+       static struct statinfo statinfo_cur;
        u_int64_t diskio_current = 0;
 
-       bzero(&statinfo_cur, sizeof (statinfo_cur));
-       statinfo_cur.dinfo = (struct devinfo *)malloc(sizeof (struct devinfo));
-       bzero(statinfo_cur.dinfo, sizeof (struct devinfo));
+       bzero(&statinfo_cur, sizeof(statinfo_cur));
+       statinfo_cur.dinfo = (struct devinfo *) malloc(sizeof(struct devinfo));
+       bzero(statinfo_cur.dinfo, sizeof(struct devinfo));
 
-       if (devstat_getdevs(NULL, &statinfo_cur) < 0)
+       if (devstat_getdevs(NULL, &statinfo_cur) < 0) {
                return;
+       }
 
        devs_count = statinfo_cur.dinfo->numdevs;
        if (devstat_selectdevs(&dev_select, &num_selected, &num_selections,
                        &select_generation, statinfo_cur.dinfo->generation,
-                       statinfo_cur.dinfo->devices, devs_count, NULL, 0,
-                       NULL, 0, DS_SELECT_ONLY, MAXSHOWDEVS, 1) >= 0) {
+                       statinfo_cur.dinfo->devices, devs_count, NULL, 0, NULL, 0,
+                       DS_SELECT_ONLY, MAXSHOWDEVS, 1) >= 0) {
                for (dn = 0; dn < devs_count; ++dn) {
                        int di;
-                       struct devstat  *dev;
+                       struct devstat *dev;
 
                        di = dev_select[dn].position;
                        dev = &statinfo_cur.dinfo->devices[di];
 
-                       diskio_current += dev->bytes[DEVSTAT_READ] +
+                       diskio_current += dev->bytes[DEVSTAT_READ] +0
                                dev->bytes[DEVSTAT_WRITE];
 
                        for (i = 0; i < MAX_DISKIO_STATS; i++) {
                                if (diskio_stats[i].dev && strcmp(dev_select[dn].device_name,
                                                diskio_stats[i].dev) == 0) {
-                                       diskio_stats[i].current =
-                                               (dev->bytes[DEVSTAT_READ] + dev->bytes[DEVSTAT_WRITE] -
-                                               diskio_stats[i].last) / 1024;
+                                       diskio_stats[i].current = (dev->bytes[DEVSTAT_READ] +
+                                               dev->bytes[DEVSTAT_WRITE] - diskio_stats[i].last) / 1024;
                                        diskio_stats[i].current_read = (dev->bytes[DEVSTAT_READ] -
                                                diskio_stats[i].last_read) / 1024;
                                        diskio_stats[i].current_write = (dev->bytes[DEVSTAT_WRITE] -
                                                diskio_stats[i].last_write) / 1024;
-                                       if (dev->bytes[DEVSTAT_READ] +
-                                                       dev->bytes[DEVSTAT_WRITE] < diskio_stats[i].last) {
+                                       if (dev->bytes[DEVSTAT_READ] + dev->bytes[DEVSTAT_WRITE]
+                                                       < diskio_stats[i].last) {
                                                diskio_stats[i].current = 0;
                                        }
                                        if (dev->bytes[DEVSTAT_READ] < diskio_stats[i].last_read) {
@@ -726,7 +691,7 @@ update_diskio()
                                                diskio_stats[i].current = diskio_stats[i].current_read;
                                        }
                                        diskio_stats[i].last = dev->bytes[DEVSTAT_READ] +
-                                               dev->bytes[DEVSTAT_WRITE];
+                                               de v->bytes[DEVSTAT_WRITE];
                                        diskio_stats[i].last_read = dev->bytes[DEVSTAT_READ];
                                        diskio_stats[i].last_write = dev->bytes[DEVSTAT_WRITE];
                                }
@@ -736,53 +701,46 @@ update_diskio()
                free(dev_select);
        }
 
-       /*
-        * Since we return (diskio_total_current - diskio_total_old), first
-        * frame will be way too high (it will be equal to
-        * diskio_total_current, i.e. all disk I/O since boot). That's why
-        * it is better to return 0 first time;
-        */
+       /* Since we return (diskio_total_current - diskio_total_old),
+        * the first frame will be way too high
+        * (it will be equal to diskio_total_current, i.e. all disk I/O since boot).
+        *  That's why it is better to return 0 first time; */
        if (diskio_setup == 0) {
                diskio_setup = 1;
                diskio_value = 0;
-       } else
-               diskio_value = (unsigned int)((diskio_current - diskio_prev)/
-                               1024);
+       } else {
+               diskio_value = (unsigned int) ((diskio_current - diskio_prev) / 1024);
+       }
        diskio_prev = diskio_current;
 
        free(statinfo_cur.dinfo);
 }
 
-/*
- * While topless is obviously better, top is also not bad.
- */
+/* While topless is obviously better, top is also not bad. */
 
-int
-comparecpu(const void *a, const void *b)
+int comparecpu(const void *a, const void *b)
 {
-       if (((struct process *)a)->amount > ((struct process *)b)->amount)
-               return (-1);
-
-       if (((struct process *)a)->amount < ((struct process *)b)->amount)
-               return (1);
-
-       return (0);
+       if (a->amount > b->amount) {
+               return -1;
+       } else if (a->amount < b->amount) {
+               return 1;
+       } else {
+               return 0;
+       }
 }
 
-int
-comparemem(const void *a, const void *b)
+int comparemem(const void *a, const void *b)
 {
-       if (((struct process *)a)->totalmem > ((struct process *)b)->totalmem)
-               return (-1);
-
-       if (((struct process *)a)->totalmem < ((struct process *)b)->totalmem)
-               return (1);
-
-       return (0);
+       if (a->totalmem > b->totalmem) {
+               return -1;
+       } else if (a->totalmem < b->totalmem) {
+               return 1;
+       } else {
+               return 0;
+       }
 }
 
-inline void
-proc_find_top(struct process **cpu, struct process **mem)
+inline void proc_find_top(struct process **cpu, struct process **mem)
 {
        struct kinfo_proc *p;
        int n_processes;
@@ -792,31 +750,29 @@ proc_find_top(struct process **cpu, struct process **mem)
        int total_pages;
 
        /* we get total pages count again to be sure it is up to date */
-       if (GETSYSCTL("vm.stats.vm.v_page_count", total_pages) != 0)
-               CRIT_ERR("Cannot read sysctl"
-                       "\"vm.stats.vm.v_page_count\"");
+       if (GETSYSCTL("vm.stats.vm.v_page_count", total_pages) != 0) {
+               CRIT_ERR("Cannot read sysctl \"vm.stats.vm.v_page_count\"");
+       }
 
        p = kvm_getprocs(kd, KERN_PROC_PROC, 0, &n_processes);
-       processes = malloc(n_processes * sizeof (struct process));
+       processes = malloc(n_processes * sizeof(struct process));
 
        for (i = 0; i < n_processes; i++) {
-               if (!((p[i].ki_flag & P_SYSTEM)) &&
-                               p[i].ki_comm != NULL) {
+               if (!((p[i].ki_flag & P_SYSTEM)) && p[i].ki_comm != NULL) {
                        processes[j].pid = p[i].ki_pid;
-                       processes[j].name =  strdup(p[i].ki_comm);
-                       processes[j].amount = 100.0 *
-                               p[i].ki_pctcpu / FSCALE;
-                       processes[j].totalmem = (float)(p[i].ki_rssize /
-                                       (float)total_pages) * 100.0;
+                       processes[j].name = strdup(p[i].ki_comm);
+                       processes[j].amount = 100.0 * p[i].ki_pctcpu / FSCALE;
+                       processes[j].totalmem = (float) (p[i].ki_rssize /
+                               (float) total_pages) * 100.0;
                        j++;
                }
        }
 
-       qsort(processes, j - 1, sizeof (struct process), comparemem);
+       qsort(processes, j - 1, sizeof(struct process), comparemem);
        for (i = 0; i < 10 && i < n_processes; i++) {
                struct process *tmp, *ttmp;
 
-               tmp = malloc(sizeof (struct process));
+               tmp = malloc(sizeof(struct process));
                tmp->pid = processes[i].pid;
                tmp->amount = processes[i].amount;
                tmp->totalmem = processes[i].totalmem;
@@ -830,11 +786,11 @@ proc_find_top(struct process **cpu, struct process **mem)
                }
        }
 
-       qsort(processes, j - 1, sizeof (struct process), comparecpu);
+       qsort(processes, j - 1, sizeof(struct process), comparecpu);
        for (i = 0; i < 10 && i < n_processes; i++) {
                struct process *tmp, *ttmp;
 
-               tmp = malloc(sizeof (struct process));
+               tmp = malloc(sizeof(struct process));
                tmp->pid = processes[i].pid;
                tmp->amount = processes[i].amount;
                tmp->totalmem = processes[i].totalmem;
@@ -851,12 +807,14 @@ proc_find_top(struct process **cpu, struct process **mem)
 #if defined(FREEBSD_DEBUG)
        printf("=====\nmem\n");
        for (i = 0; i < 10; i++) {
-               printf("%d: %s(%d) %.2f\n", i, mem[i]->name,
-                               mem[i]->pid, mem[i]->totalmem);
+               printf("%d: %s(%d) %.2f\n", i, mem[i]->name, mem[i]->pid,
+                       mem[i]->totalmem);
        }
 #endif
 
-       for (i = 0; i < j; free(processes[i++].name));
+       for (i = 0; i < j; i++) {
+               free(processes[i].name);
+       }
        free(processes);
 }
 
@@ -864,95 +822,93 @@ proc_find_top(struct process **cpu, struct process **mem)
 #define        APMDEV          "/dev/apm"
 #define        APM_UNKNOWN     255
 
-int
-apm_getinfo(int fd, apm_info_t aip)
+int apm_getinfo(int fd, apm_info_t aip)
 {
-       if (ioctl(fd, APMIO_GETINFO, aip) == -1)
-               return (-1);
+       if (ioctl(fd, APMIO_GETINFO, aip) == -1) {
+               return -1;
+       }
 
-       return (0);
+       return 0;
 }
 
-char
-*get_apm_adapter()
+char *get_apm_adapter()
 {
        int fd;
        struct apm_info info;
        char *out;
 
-       out = (char *)calloc(16, sizeof (char));
+       out = (char *) calloc(16, sizeof(char));
 
        fd = open(APMDEV, O_RDONLY);
        if (fd < 0) {
                strncpy(out, "ERR", 16);
-               return (out);
+               return out;
        }
 
        if (apm_getinfo(fd, &info) != 0) {
                close(fd);
                strncpy(out, "ERR", 16);
-               return (out);
+               return out;
        }
        close(fd);
 
        switch (info.ai_acline) {
                case 0:
                        strncpy(out, "off-line", 16);
-                       return (out);
+                       return out;
                        break;
                case 1:
                        if (info.ai_batt_stat == 3) {
                                strncpy(out, "charging", 16);
-                               return (out);
+                               return out;
                        } else {
                                strncpy(out, "on-line", 16);
-                               return (out);
+                               return out;
                        }
                        break;
                default:
                        strncpy(out, "unknown", 16);
-                       return (out);
+                       return out;
                        break;
        }
 }
 
-char
-*get_apm_battery_life()
+char *get_apm_battery_life()
 {
        int fd;
        u_int batt_life;
        struct apm_info info;
        char *out;
 
-       out = (char *)calloc(16, sizeof (char));
+       out = (char *) calloc(16, sizeof(char));
 
        fd = open(APMDEV, O_RDONLY);
        if (fd < 0) {
                strncpy(out, "ERR", 16);
-               return (out);
+               return out;
        }
 
        if (apm_getinfo(fd, &info) != 0) {
                close(fd);
                strncpy(out, "ERR", 16);
-               return (out);
+               return out;
        }
        close(fd);
 
        batt_life = info.ai_batt_life;
-       if (batt_life == APM_UNKNOWN)
+       if (batt_life == APM_UNKNOWN) {
                strncpy(out, "unknown", 16);
-       else if (batt_life <= 100) {
+       } else if (batt_life <= 100) {
                snprintf(out, 16, "%d%%", batt_life);
-               return (out);
-       } else
+               return out;
+       } else {
                strncpy(out, "ERR", 16);
+       }
 
-       return (out);
+       return out;
 }
 
-char
-*get_apm_battery_time()
+char *get_apm_battery_time()
 {
        int fd;
        int batt_time;
@@ -960,26 +916,26 @@ char
        struct apm_info info;
        char *out;
 
-       out = (char *)calloc(16, sizeof (char));
+       out = (char *) calloc(16, sizeof(char));
 
        fd = open(APMDEV, O_RDONLY);
        if (fd < 0) {
                strncpy(out, "ERR", 16);
-               return (out);
+               return out;
        }
 
        if (apm_getinfo(fd, &info) != 0) {
                close(fd);
                strncpy(out, "ERR", 16);
-               return (out);
+               return out;
        }
        close(fd);
 
        batt_time = info.ai_batt_time;
 
-       if (batt_time == -1)
+       if (batt_time == -1) {
                strncpy(out, "unknown", 16);
-       else {
+       } else {
                h = batt_time;
                s = h % 60;
                h /= 60;
@@ -988,18 +944,17 @@ char
                snprintf(out, 16, "%2d:%02d:%02d", h, m, s);
        }
 
-       return (out);
+       return out;
 }
 
 #endif
 
-void update_entropy (void)
+void update_entropy(void)
 {
-     /* mirrorbox: can you do anything equivalent in freebsd? -drphibes. */
+       /* mirrorbox: can you do anything equivalent in freebsd? -drphibes. */
 }
 
 /* empty stub so conky links */
-void
-free_all_processes(void)
+void free_all_processes(void)
 {
 }
index 0636929..7851e65 100644 (file)
--- a/src/fs.c
+++ b/src/fs.c
@@ -1,5 +1,4 @@
-/*
- * Conky, a system monitor, based on torsmo
+/* Conky, a system monitor, based on torsmo
  *
  * Any original torsmo code is licensed under the BSD license
  *
@@ -8,7 +7,8 @@
  * Please see COPYING for details
  *
  * Copyright (c) 2004, Hannu Saransaari and Lauri Hakkarainen
- * Copyright (c) 2005-2007 Brenden Matthews, Philip Kovacs, et. al. (see AUTHORS)
+ * Copyright (c) 2005-2007 Brenden Matthews, Philip Kovacs, et. al.
+ *     (see AUTHORS)
  * All rights reserved.
  *
  * This program is free software: you can redistribute it and/or modify
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  * GNU General Public License for more details.
  * You should have received a copy of the GNU General Public License
- * along with this program.  If not, see <http://www.gnu.org/licenses/>. 
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
  *
- *  $Id$
- */
+ * $Id$ */
 
 #include "conky.h"
 #include <unistd.h>
 static struct fs_stat fs_stats_[MAX_FS_STATS];
 struct fs_stat *fs_stats = fs_stats_;
 
-static void update_fs_stat(struct fs_stat* fs);
+static void update_fs_stat(struct fs_stat *fs);
 
 void update_fs_stats()
 {
        unsigned i;
-       for(i=0; i<MAX_FS_STATS; ++i)
-               if(fs_stats[i].path)
+
+       for (i = 0; i < MAX_FS_STATS; ++i) {
+               if (fs_stats[i].path) {
                        update_fs_stat(&fs_stats[i]);
+               }
+       }
 }
 
 void clear_fs_stats()
 {
        unsigned i;
-       for(i=0; i<MAX_FS_STATS; ++i)
-               if(fs_stats[i].path) {
+
+       for (i = 0; i < MAX_FS_STATS; ++i) {
+               if (fs_stats[i].path) {
                        free(fs_stats[i].path);
-                       fs_stats[i].path = 0;
+                       fs_stats[i].path = NULL;
                }
+       }
 }
 
 struct fs_stat *prepare_fs_stat(const char *s)
 {
-       struct fs_stat* new = 0;
+       struct fs_stat *new = 0;
        unsigned i;
+
        /* lookup existing or get new */
-       for(i=0; i<MAX_FS_STATS; ++i) {
-               if(fs_stats[i].path) {
-                       if(strcmp(fs_stats[i].path, s) == 0)
+       for (i = 0; i < MAX_FS_STATS; ++i) {
+               if (fs_stats[i].path) {
+                       if (strcmp(fs_stats[i].path, s) == 0) {
                                return &fs_stats[i];
-               } else
+                       }
+               } else {
                        new = &fs_stats[i];
+               }
        }
        /* new path */
-       if(!new) {
+       if (!new) {
                ERR("too many fs stats");
                return 0;
        }
@@ -94,14 +101,14 @@ struct fs_stat *prepare_fs_stat(const char *s)
        return new;
 }
 
-static
-void update_fs_stat(struct fs_stat* fs)
+static void update_fs_stat(struct fs_stat *fs)
 {
        struct statfs s;
-       if(statfs(fs->path, &s) == 0) {
+
+       if (statfs(fs->path, &s) == 0) {
                fs->size = (long long) s.f_blocks * s.f_bsize;
                /* bfree (root) or bavail (non-roots) ? */
-               fs->avail = (long long) s.f_bavail* s.f_bsize;
+               fs->avail = (long long) s.f_bavail * s.f_bsize;
                fs->free = (long long) s.f_bfree * s.f_bsize;
        } else {
                fs->size = 0;
index cffa213..ec0d701 100644 (file)
@@ -1,5 +1,4 @@
-/*
- * Conky, a system monitor, based on torsmo
+/* Conky, a system monitor, based on torsmo
  *
  * Any original torsmo code is licensed under the BSD license
  *
@@ -8,7 +7,8 @@
  * Please see COPYING for details
  *
  * Copyright (c) 2004, Hannu Saransaari and Lauri Hakkarainen
- * Copyright (c) 2005-2007 Brenden Matthews, Philip Kovacs, et. al. (see AUTHORS)
+ * Copyright (c) 2005-2007 Brenden Matthews, Philip Kovacs, et. al.
+ *     (see AUTHORS)
  * All rights reserved.
  *
  * This program is free software: you can redistribute it and/or modify
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  * GNU General Public License for more details.
  * You should have received a copy of the GNU General Public License
- * along with this program.  If not, see <http://www.gnu.org/licenses/>. 
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
  *
- *  $Id$
- */
+ * $Id$ */
 
 #include "conky.h"
 #include <errno.h>
@@ -47,22 +46,25 @@ int scan_hddtemp(const char *arg, char **dev, char **addr, int *port)
 {
        char buf1[32], buf2[64];
        int n, ret;
-       
+
        ret = sscanf(arg, "%31s %63s %d", buf1, buf2, &n);
-       
-       if (ret < 1)
+
+       if (ret < 1) {
                return -1;
+       }
 
        *dev = strdup(buf1);
-       if (ret >= 2)
+       if (ret >= 2) {
                *addr = strdup(buf2);
-       else
+       } else {
                *addr = strdup("127.0.0.1");
+       }
 
-       if (ret == 3) 
+       if (ret == 3) {
                *port = n;
-       else
+       } else {
                *port = PORT;
+       }
 
        return 0;
 }
@@ -77,7 +79,7 @@ char *get_hddtemp_info(char *dev, char *hostaddr, int port, char *unit)
        int len, i, devlen = strlen(dev);
        char sep;
        char *p, *out, *r = NULL;
-       
+
        if ((sockfd = socket(AF_INET, SOCK_STREAM, 0)) == -1) {
                perror("socket");
                return NULL;
@@ -91,10 +93,11 @@ char *get_hddtemp_info(char *dev, char *hostaddr, int port, char *unit)
 
        addr.sin_family = AF_INET;
        addr.sin_port = htons(port);
-       addr.sin_addr = *((struct in_addr *)he->h_addr);
+       addr.sin_addr = *((struct in_addr *) he->h_addr);
        memset(&(addr.sin_zero), 0, 8);
 
-       if (connect(sockfd, (struct sockaddr *)&addr, sizeof(struct sockaddr)) == -1) {
+       if (connect(sockfd, (struct sockaddr *) &addr,
+                       sizeof(struct sockaddr)) == -1) {
                perror("connect");
                goto out;
        }
@@ -102,29 +105,30 @@ char *get_hddtemp_info(char *dev, char *hostaddr, int port, char *unit)
        FD_ZERO(&rfds);
        FD_SET(sockfd, &rfds);
 
-       /* We're going to wait up to a quarter a second to see whether
-        * there's any data available. Polling with timeout set to 0
-        * doesn't seem to work with hddtemp. */
+       /* We're going to wait up to a quarter a second to see whether there's
+        * any data available. Polling with timeout set to 0 doesn't seem to work
+        * with hddtemp. */
        tv.tv_sec = 0;
        tv.tv_usec = 250000;
-       
-       i = select(sockfd+1, &rfds, NULL, NULL, &tv);
-       if (i == -1)
-       {
-               if (errno == EINTR)     /* silently ignore interrupted system call */
-                   goto out;
-               else
-                   perror("select");
+
+       i = select(sockfd + 1, &rfds, NULL, NULL, &tv);
+       if (i == -1) {
+               if (errno == EINTR) {   /* silently ignore interrupted system call */
+                       goto out;
+               } else {
+                       perror("select");
+               }
        }
 
        /* No data available */
-       if (i <= 0)
+       if (i <= 0) {
                goto out;
-       
+       }
+
        p = buf;
        len = 0;
        do {
-               i = recv(sockfd, p, BUFLEN - (p-buf), 0);
+               i = recv(sockfd, p, BUFLEN - (p - buf), 0);
                if (i < 0) {
                        perror("recv");
                        goto out;
@@ -132,48 +136,51 @@ char *get_hddtemp_info(char *dev, char *hostaddr, int port, char *unit)
                len += i;
                p += i;
        } while (i > 0 && p < buf + BUFLEN - 1);
-       
+
        if (len < 2) {
                goto out;
        }
-       
+
        buf[len] = 0;
-               
+
        /* The first character read is the separator. */
        sep = buf[0];
-       p = buf+1;
-       
+       p = buf + 1;
+
        while (*p) {
                if (!strncmp(p, dev, devlen)) {
-                       p += devlen + 1; 
+                       p += devlen + 1;
                        p = strchr(p, sep);
-                       if (!p) 
+                       if (!p) {
                                goto out;
+                       }
                        p++;
-                       out = p;        
+                       out = p;
                        p = strchr(p, sep);
-                       if (!p) 
+                       if (!p) {
                                goto out;
+                       }
                        *p = '\0';
                        p++;
-                       *unit = *p;     
+                       *unit = *p;
                        if (!strncmp(out, "NA", 2)) {
                                strcpy(buf, "N/A");
                                r = buf;
-                       } else {                                        
+                       } else {
                                r = out;
                        }
                        goto out;
                } else {
                        for (i = 0; i < 5; i++) {
                                p = strchr(p, sep);
-                               if (!p)
+                               if (!p) {
                                        goto out;
+                               }
                                p++;
                        }
                }
        }
-out:   close(sockfd);
+out:
+       close(sockfd);
        return r;
 }
-
index ab30468..47b5021 100644 (file)
@@ -1,34 +1,33 @@
 /* libmpdclient
-   (c)2003-2006 by Warren Dukes (warren.dukes@gmail.com)
-   This project's homepage is: http://www.musicpd.org
-
-   Redistribution and use in source and binary forms, with or without
-   modification, are permitted provided that the following conditions
-   are met:
-
-   - Redistributions of source code must retain the above copyright
-   notice, this list of conditions and the following disclaimer.
-
-   - Redistributions in binary form must reproduce the above copyright
-   notice, this list of conditions and the following disclaimer in the
-   documentation and/or other materials provided with the distribution.
-
-   - Neither the name of the Music Player Daemon nor the names of its
-   contributors may be used to endorse or promote products derived from
-   this software without specific prior written permission.
-
-   THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-   ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-   LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-   A PARTICULAR PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR
-   CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
-   EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
-   PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
-   PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
-   LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
-   NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
-   SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-*/
+ * (c)2003-2006 by Warren Dukes (warren.dukes@gmail.com)
+ * This project's homepage is: http://www.musicpd.org
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * - Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * - Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * - Neither the name of the Music Player Daemon nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */
 
 #include "libmpdclient.h"
 
 #  include <netdb.h>
 #endif
 
-/* (bits+1)/3 (plus the sign character) */
-#define INTLEN      ((sizeof(int)       * CHAR_BIT + 1) / 3 + 1)
-#define LONGLONGLEN ((sizeof(long long) * CHAR_BIT + 1) / 3 + 1)
+/* (bits + 1) / 3 (plus the sign character) */
+#define INTLEN         ((sizeof(int)           * CHAR_BIT + 1) / 3 + 1)
+#define LONGLONGLEN    ((sizeof(long long)     * CHAR_BIT + 1) / 3 + 1)
 
-#define COMMAND_LIST    1
-#define COMMAND_LIST_OK 2
+#define COMMAND_LIST   1
+#define COMMAND_LIST_OK        2
 
 #ifndef MPD_NO_GAI
 #  ifdef AI_ADDRCONFIG
 #endif
 
 #ifdef WIN32
-#  define SELECT_ERRNO_IGNORE   (errno == WSAEINTR || errno == WSAEINPROGRESS)
-#  define SENDRECV_ERRNO_IGNORE SELECT_ERRNO_IGNORE
+#  define SELECT_ERRNO_IGNORE  (errno == WSAEINTR || errno == WSAEINPROGRESS)
+#  define SENDRECV_ERRNO_IGNORE        SELECT_ERRNO_IGNORE
 #else
-#  define SELECT_ERRNO_IGNORE   (errno == EINTR)
-#  define SENDRECV_ERRNO_IGNORE (errno == EINTR || errno == EAGAIN)
-#  define winsock_dll_error(c)  0
-#  define closesocket(s)        close(s)
-#  define WSACleanup()          do { /* nothing */ } while (0)
+#  define SELECT_ERRNO_IGNORE  (errno == EINTR)
+#  define SENDRECV_ERRNO_IGNORE        (errno == EINTR || errno == EAGAIN)
+#  define winsock_dll_error(c) 0
+#  define closesocket(s)               close(s)
+#  define WSACleanup()                 do { /* nothing */ } while (0)
 #endif
 
 #ifdef WIN32
 static int winsock_dll_error(mpd_Connection *connection)
 {
        WSADATA wsaData;
-       if ((WSAStartup(MAKEWORD(2, 2), &wsaData)) != 0 ||
-                       LOBYTE(wsaData.wVersion) != 2 ||
-                       HIBYTE(wsaData.wVersion) != 2 ) {
-               strcpy(connection->errorStr,
-                      "Could not find usable WinSock DLL.");
+
+       if ((WSAStartup(MAKEWORD(2, 2), &wsaData)) != 0
+                       || LOBYTE(wsaData.wVersion) != 2
+                       || HIBYTE(wsaData.wVersion) != 2) {
+               strcpy(connection->errorStr, "Could not find usable WinSock DLL.");
                connection->error = MPD_ERROR_SYSTEM;
                return 1;
        }
@@ -97,45 +96,45 @@ static int winsock_dll_error(mpd_Connection *connection)
 }
 
 static int do_connect_fail(mpd_Connection *connection,
-                           const struct sockaddr *serv_addr, int addrlen)
+               const struct sockaddr *serv_addr, int addrlen)
 {
-       int iMode = 1; /* 0 = blocking, else non-blocking */
-       ioctlsocket(connection->sock, FIONBIO, (u_long FAR*) &iMode);
-       return (connect(connection->sock,serv_addr,addrlen) == SOCKET_ERROR
-                       && WSAGetLastError() != WSAEWOULDBLOCK);
+       int iMode = 1;  /* 0 = blocking, else non-blocking */
+
+       ioctlsocket(connection->sock, FIONBIO, (u_long FAR *) &iMode);
+       return (connect(connection->sock, serv_addr, addrlen) == SOCKET_ERROR
+               && WSAGetLastError() != WSAEWOULDBLOCK);
 }
 #else /* !WIN32 (sane operating systems) */
 static int do_connect_fail(mpd_Connection *connection,
-                           const struct sockaddr *serv_addr, int addrlen)
+               const struct sockaddr *serv_addr, int addrlen)
 {
        int flags = fcntl(connection->sock, F_GETFL, 0);
+
        fcntl(connection->sock, F_SETFL, flags | O_NONBLOCK);
-       return (connect(connection->sock,serv_addr,addrlen)<0 &&
-                               errno!=EINPROGRESS);
+       return (connect(connection->sock, serv_addr, addrlen) < 0
+               && errno != EINPROGRESS);
 }
 #endif /* !WIN32 */
 
 #ifdef MPD_HAVE_GAI
-static int mpd_connect(mpd_Connection * connection, const char * host, int port,
-                       float timeout)
+static int mpd_connect(mpd_Connection *connection, const char *host, int port,
+               float timeout)
 {
        int error;
-       char service[INTLEN+1];
+       char service[INTLEN + 1];
        struct addrinfo hints;
        struct addrinfo *res = NULL;
        struct addrinfo *addrinfo = NULL;
 
-       /**
-        * Setup hints
-        */
-       hints.ai_flags     = AI_ADDRCONFIG;
-       hints.ai_family    = PF_UNSPEC;
-       hints.ai_socktype  = SOCK_STREAM;
-       hints.ai_protocol  = IPPROTO_TCP;
-       hints.ai_addrlen   = 0;
-       hints.ai_addr      = NULL;
-       hints.ai_canonname = NULL;
-       hints.ai_next      = NULL;
+       /* Setup hints */
+       hints.ai_flags          = AI_ADDRCONFIG;
+       hints.ai_family         = PF_UNSPEC;
+       hints.ai_socktype       = SOCK_STREAM;
+       hints.ai_protocol       = IPPROTO_TCP;
+       hints.ai_addrlen        = 0;
+       hints.ai_addr           = NULL;
+       hints.ai_canonname      = NULL;
+       hints.ai_next           = NULL;
 
        snprintf(service, sizeof(service), "%i", port);
 
@@ -143,8 +142,7 @@ static int mpd_connect(mpd_Connection * connection, const char * host, int port,
 
        if (error) {
                snprintf(connection->errorStr, MPD_ERRORSTR_MAX_LENGTH,
-                        "host \"%s\" not found: %s",
-                        host, gai_strerror(error));
+                       "host \"%s\" not found: %s", host, gai_strerror(error));
                connection->error = MPD_ERROR_UNKHOST;
                return -1;
        }
@@ -152,11 +150,10 @@ static int mpd_connect(mpd_Connection * connection, const char * host, int port,
        for (res = addrinfo; res; res = res->ai_next) {
                /* create socket */
                connection->sock = socket(res->ai_family, SOCK_STREAM,
-                                         res->ai_protocol);
+                       res->ai_protocol);
                if (connection->sock < 0) {
                        snprintf(connection->errorStr, MPD_ERRORSTR_MAX_LENGTH,
-                                "problems creating socket: %s",
-                                strerror(errno));
+                               "problems creating socket: %s", strerror(errno));
                        connection->error = MPD_ERROR_SYSTEM;
                        freeaddrinfo(addrinfo);
                        return -1;
@@ -165,12 +162,11 @@ static int mpd_connect(mpd_Connection * connection, const char * host, int port,
                mpd_setConnectionTimeout(connection, timeout);
 
                /* connect stuff */
-               if (do_connect_fail(connection,
-                                   res->ai_addr, res->ai_addrlen)) {
-                       /* try the next address family */
-                       closesocket(connection->sock);
-                       connection->sock = -1;
-                       continue;
+               if (do_connect_fail(connection, res->ai_addr, res->ai_addrlen)) {
+                       /* try the next address family */
+                       closesocket(connection->sock);
+                       connection->sock = -1;
+                       continue;
                }
        }
 
@@ -178,8 +174,8 @@ static int mpd_connect(mpd_Connection * connection, const char * host, int port,
 
        if (connection->sock < 0) {
                snprintf(connection->errorStr, MPD_ERRORSTR_MAX_LENGTH,
-                        "problems connecting to \"%s\" on port %i: %s",
-                        host, port, strerror(errno));
+                       "problems connecting to \"%s\" on port %i: %s", host, port,
+                       strerror(errno));
                connection->error = MPD_ERROR_CONNPORT;
 
                return -1;
@@ -188,53 +184,52 @@ static int mpd_connect(mpd_Connection * connection, const char * host, int port,
        return 0;
 }
 #else /* !MPD_HAVE_GAI */
-static int mpd_connect(mpd_Connection * connection, const char * host, int port,
-                       float timeout)
+static int mpd_connect(mpd_Connection *connection, const char *host, int port,
+               float timeout)
 {
-       struct hostent * he;
-       struct sockaddr * dest;
+       struct hostent *he;
+       struct sockaddr *dest;
        int destlen;
        struct sockaddr_in sin;
 
-       if(!(he=gethostbyname(host))) {
-               snprintf(connection->errorStr,MPD_ERRORSTR_MAX_LENGTH,
-                               "host \"%s\" not found",host);
+       if (!(he = gethostbyname(host))) {
+               snprintf(connection->errorStr, MPD_ERRORSTR_MAX_LENGTH,
+                       "host \"%s\" not found", host);
                connection->error = MPD_ERROR_UNKHOST;
                return -1;
        }
 
-       memset(&sin,0,sizeof(struct sockaddr_in));
-       /*dest.sin_family = he->h_addrtype;*/
+       memset(&sin, 0, sizeof(struct sockaddr_in));
+       /* dest.sin_family = he->h_addrtype; */
        sin.sin_family = AF_INET;
        sin.sin_port = htons(port);
 
-       switch(he->h_addrtype) {
-       case AF_INET:
-               memcpy((char *)&sin.sin_addr.s_addr,(char *)he->h_addr,
+       switch (he->h_addrtype) {
+               case AF_INET:
+                       memcpy((char *) &sin.sin_addr.s_addr, (char *) he->h_addr,
                                he->h_length);
-               dest = (struct sockaddr *)&sin;
-               destlen = sizeof(struct sockaddr_in);
-               break;
-       default:
-               strcpy(connection->errorStr,"address type is not IPv4");
-               connection->error = MPD_ERROR_SYSTEM;
-               return -1;
-               break;
+                       dest = (struct sockaddr *) &sin;
+                       destlen = sizeof(struct sockaddr_in);
+                       break;
+               default:
+                       strcpy(connection->errorStr, "address type is not IPv4");
+                       connection->error = MPD_ERROR_SYSTEM;
+                       return -1;
+                       break;
        }
 
-       if((connection->sock = socket(dest->sa_family,SOCK_STREAM,0))<0) {
-               strcpy(connection->errorStr,"problems creating socket");
+       if ((connection->sock = socket(dest->sa_family, SOCK_STREAM, 0)) < 0) {
+               strcpy(connection->errorStr, "problems creating socket");
                connection->error = MPD_ERROR_SYSTEM;
                return -1;
        }
 
-       mpd_setConnectionTimeout(connection,timeout);
+       mpd_setConnectionTimeout(connection, timeout);
 
        /* connect stuff */
        if (do_connect_fail(connection, dest, destlen)) {
-               snprintf(connection->errorStr,MPD_ERRORSTR_MAX_LENGTH,
-                               "problems connecting to \"%s\" on port"
-                               " %i",host,port);
+               snprintf(connection->errorStr, MPD_ERRORSTR_MAX_LENGTH,
+                       "problems connecting to \"%s\" on port %i", host, port);
                connection->error = MPD_ERROR_CONNPORT;
                return -1;
        }
@@ -243,8 +238,7 @@ static int mpd_connect(mpd_Connection * connection, const char * host, int port,
 }
 #endif /* !MPD_HAVE_GAI */
 
-char * mpdTagItemKeys[MPD_TAG_NUM_OF_ITEM_TYPES] =
-{
+char *mpdTagItemKeys[MPD_TAG_NUM_OF_ITEM_TYPES] = {
        "Artist",
        "Album",
        "Title",
@@ -260,31 +254,33 @@ char * mpdTagItemKeys[MPD_TAG_NUM_OF_ITEM_TYPES] =
        "Any"
 };
 
-static char * mpd_sanitizeArg(const char * arg) {
+static char *mpd_sanitizeArg(const char *arg)
+{
        size_t i;
-       char * ret;
+       char *ret;
        register const char *c;
        register char *rc;
 
-       /* instead of counting in that loop above, just
-        * use a bit more memory and half running time
-        */
+       /* instead of counting in that loop above,
+        * just use a bit more memory and halve running time */
        ret = malloc(strlen(arg) * 2 + 1);
 
        c = arg;
        rc = ret;
-       for(i = strlen(arg)+1; i != 0; --i) {
-               if(*c=='"' || *c=='\\')
+       for (i = strlen(arg) + 1; i != 0; --i) {
+               if (*c == '"' || *c == '\\') {
                        *rc++ = '\\';
+               }
                *(rc++) = *(c++);
        }
 
        return ret;
 }
 
-static mpd_ReturnElement * mpd_newReturnElement(const char * name, const char * value)
+static mpd_ReturnElement *mpd_newReturnElement(const char *name,
+               const char *value)
 {
-       mpd_ReturnElement * ret = malloc(sizeof(mpd_ReturnElement));
+       mpd_ReturnElement *ret = malloc(sizeof(mpd_ReturnElement));
 
        ret->name = strdup(name);
        ret->value = strdup(value);
@@ -292,44 +288,45 @@ static mpd_ReturnElement * mpd_newReturnElement(const char * name, const char *
        return ret;
 }
 
-static void mpd_freeReturnElement(mpd_ReturnElement * re) {
+static void mpd_freeReturnElement(mpd_ReturnElement *re)
+{
        free(re->name);
        free(re->value);
        free(re);
 }
 
-void mpd_setConnectionTimeout(mpd_Connection * connection, float timeout) {
-       connection->timeout.tv_sec = (int)timeout;
-       connection->timeout.tv_usec = (int)(timeout*1e6 -
-                                           connection->timeout.tv_sec*1000000 +
-                                           0.5);
+void mpd_setConnectionTimeout(mpd_Connection *connection, float timeout)
+{
+       connection->timeout.tv_sec = (int) timeout;
+       connection->timeout.tv_usec =
+               (int) ((timeout - connection->timeout.tv_sec) * 1e6 + 0.5);
 }
 
-static int mpd_parseWelcome(mpd_Connection * connection, const char * host, int port,
-                            /*char * rt,*/ char * output) {
-       char * tmp;
-       char * test;
+static int mpd_parseWelcome(mpd_Connection *connection, const char *host,
+               int port, /* char *rt, */ char *output)
+{
+       char *tmp;
+       char *test;
        int i;
 
-       if(strncmp(output,MPD_WELCOME_MESSAGE,strlen(MPD_WELCOME_MESSAGE))) {
-               snprintf(connection->errorStr,MPD_ERRORSTR_MAX_LENGTH,
-                               "mpd not running on port %i on host \"%s\"",
-                               port,host);
+       if (strncmp(output, MPD_WELCOME_MESSAGE, strlen(MPD_WELCOME_MESSAGE))) {
+               snprintf(connection->errorStr, MPD_ERRORSTR_MAX_LENGTH,
+                       "mpd not running on port %i on host \"%s\"", port, host);
                connection->error = MPD_ERROR_NOTMPD;
                return 1;
        }
 
        tmp = &output[strlen(MPD_WELCOME_MESSAGE)];
 
-       for(i=0;i<3;i++) {
-               if(tmp) connection->version[i] = strtol(tmp,&test,10);
+       for (i = 0; i < 3; i++) {
+               if (tmp) {
+                       connection->version[i] = strtol(tmp, &test, 10);
+               }
 
                if (!tmp || (test[0] != '.' && test[0] != '\0')) {
-                       snprintf(connection->errorStr,
-                                MPD_ERRORSTR_MAX_LENGTH,
-                                "error parsing version number at "
-                                "\"%s\"",
-                                &output[strlen(MPD_WELCOME_MESSAGE)]);
+                       snprintf(connection->errorStr, MPD_ERRORSTR_MAX_LENGTH,
+                               "error parsing version number at \"%s\"",
+                               &output[strlen(MPD_WELCOME_MESSAGE)]);
                        connection->error = MPD_ERROR_NOTMPD;
                        return 1;
                }
@@ -339,17 +336,19 @@ static int mpd_parseWelcome(mpd_Connection * connection, const char * host, int
        return 0;
 }
 
-mpd_Connection * mpd_newConnection(const char * host, int port, float timeout) {
+mpd_Connection *mpd_newConnection(const char *host, int port, float timeout)
+{
        int err;
-       char * rt;
-       char * output =  NULL;
-       mpd_Connection * connection = malloc(sizeof(mpd_Connection));
+       char *rt;
+       char *output = NULL;
+       mpd_Connection *connection = malloc(sizeof(mpd_Connection));
        struct timeval tv;
        fd_set fds;
-       strcpy(connection->buffer,"");
+
+       strcpy(connection->buffer, "");
        connection->buflen = 0;
        connection->bufstart = 0;
-       strcpy(connection->errorStr,"");
+       strcpy(connection->errorStr, "");
        connection->error = 0;
        connection->doneProcessing = 0;
        connection->commandList = 0;
@@ -358,47 +357,46 @@ mpd_Connection * mpd_newConnection(const char * host, int port, float timeout) {
        connection->returnElement = NULL;
        connection->request = NULL;
 
-       if (winsock_dll_error(connection))
+       if (winsock_dll_error(connection)) {
                return connection;
+       }
 
-       if (mpd_connect(connection, host, port, timeout) < 0)
+       if (mpd_connect(connection, host, port, timeout) < 0) {
                return connection;
+       }
 
-       while(!(rt = strstr(connection->buffer,"\n"))) {
+       while (!(rt = strstr(connection->buffer, "\n"))) {
                tv.tv_sec = connection->timeout.tv_sec;
                tv.tv_usec = connection->timeout.tv_usec;
                FD_ZERO(&fds);
-               FD_SET(connection->sock,&fds);
-               if((err = select(connection->sock+1,&fds,NULL,NULL,&tv)) == 1) {
+               FD_SET(connection->sock, &fds);
+               if ((err = select(connection->sock + 1, &fds, NULL, NULL, &tv)) == 1) {
                        int readed;
+
                        readed = recv(connection->sock,
-                                       &(connection->buffer[connection->buflen]),
-                                       MPD_BUFFER_MAX_LENGTH-connection->buflen,0);
-                       if(readed<=0) {
-                               snprintf(connection->errorStr,MPD_ERRORSTR_MAX_LENGTH,
-                                               "problems getting a response from"
-                                               " \"%s\" on port %i : %s",host,
-                                               port, strerror(errno));
+                               &(connection->buffer[connection->buflen]),
+                               MPD_BUFFER_MAX_LENGTH - connection->buflen, 0);
+                       if (readed <= 0) {
+                               snprintf(connection->errorStr, MPD_ERRORSTR_MAX_LENGTH,
+                                       "problems getting a response from \"%s\" on port %i : %s",
+                                       host, port, strerror(errno));
                                connection->error = MPD_ERROR_NORESPONSE;
                                return connection;
                        }
-                       connection->buflen+=readed;
+                       connection->buflen += readed;
                        connection->buffer[connection->buflen] = '\0';
-               }
-               else if(err<0) {
-                       if (SELECT_ERRNO_IGNORE)
+               } else if (err < 0) {
+                       if (SELECT_ERRNO_IGNORE) {
                                continue;
-                       snprintf(connection->errorStr,
-                                       MPD_ERRORSTR_MAX_LENGTH,
-                                       "problems connecting to \"%s\" on port"
-                                       " %i",host,port);
+                       }
+                       snprintf(connection->errorStr, MPD_ERRORSTR_MAX_LENGTH,
+                               "problems connecting to \"%s\" on port %i", host, port);
                        connection->error = MPD_ERROR_CONNPORT;
                        return connection;
-               }
-               else {
-                       snprintf(connection->errorStr,MPD_ERRORSTR_MAX_LENGTH,
-                                       "timeout in attempting to get a response from"
-                                       " \"%s\" on port %i",host,port);
+               } else {
+                       snprintf(connection->errorStr, MPD_ERRORSTR_MAX_LENGTH,
+                               "timeout in attempting to get a response from \"%s\" on "
+                               "port %i", host, port);
                        connection->error = MPD_ERROR_NORESPONSE;
                        return connection;
                }
@@ -406,38 +404,47 @@ mpd_Connection * mpd_newConnection(const char * host, int port, float timeout) {
 
        *rt = '\0';
        output = strdup(connection->buffer);
-       strcpy(connection->buffer,rt+1);
+       strcpy(connection->buffer, rt + 1);
        connection->buflen = strlen(connection->buffer);
 
-       if(mpd_parseWelcome(connection,host,port,/*rt,*/output) == 0) connection->doneProcessing = 1;
+       if (mpd_parseWelcome(connection, host, port, /* rt, */ output) == 0) {
+               connection->doneProcessing = 1;
+       }
 
        free(output);
 
        return connection;
 }
 
-void mpd_clearError(mpd_Connection * connection) {
+void mpd_clearError(mpd_Connection *connection)
+{
        connection->error = 0;
        connection->errorStr[0] = '\0';
 }
 
-void mpd_closeConnection(mpd_Connection * connection) {
+void mpd_closeConnection(mpd_Connection *connection)
+{
        closesocket(connection->sock);
-       if(connection->returnElement) free(connection->returnElement);
-       if(connection->request) free(connection->request);
+       if (connection->returnElement) {
+               free(connection->returnElement);
+       }
+       if (connection->request) {
+               free(connection->request);
+       }
        free(connection);
        WSACleanup();
 }
 
-static void mpd_executeCommand(mpd_Connection * connection, char * command) {
+static void mpd_executeCommand(mpd_Connection *connection, char *command)
+{
        int ret;
        struct timeval tv;
        fd_set fds;
-       char * commandPtr = command;
+       char *commandPtr = command;
        int commandLen = strlen(command);
 
-       if(!connection->doneProcessing && !connection->commandList) {
-               strcpy(connection->errorStr,"not done processing current command");
+       if (!connection->doneProcessing && !connection->commandList) {
+               strcpy(connection->errorStr, "not done processing current command");
                connection->error = 1;
                return;
        }
@@ -445,113 +452,115 @@ static void mpd_executeCommand(mpd_Connection * connection, char * command) {
        mpd_clearError(connection);
 
        FD_ZERO(&fds);
-       FD_SET(connection->sock,&fds);
+       FD_SET(connection->sock, &fds);
        tv.tv_sec = connection->timeout.tv_sec;
        tv.tv_usec = connection->timeout.tv_usec;
 
-       while((ret = select(connection->sock+1,NULL,&fds,NULL,&tv)==1) ||
-                       (ret==-1 && SELECT_ERRNO_IGNORE)) {
-               ret = send(connection->sock,commandPtr,commandLen,MSG_DONTWAIT);
-               if(ret<=0)
-               {
-                       if (SENDRECV_ERRNO_IGNORE) continue;
-                       snprintf(connection->errorStr,MPD_ERRORSTR_MAX_LENGTH,
-                                "problems giving command \"%s\"",command);
+       while ((ret = select(connection->sock + 1, NULL, &fds, NULL, &tv) == 1)
+                       || (ret == -1 && SELECT_ERRNO_IGNORE)) {
+               ret = send(connection->sock, commandPtr, commandLen, MSG_DONTWAIT);
+               if (ret <= 0) {
+                       if (SENDRECV_ERRNO_IGNORE) {
+                               continue;
+                       }
+                       snprintf(connection->errorStr, MPD_ERRORSTR_MAX_LENGTH,
+                               "problems giving command \"%s\"", command);
                        connection->error = MPD_ERROR_SENDING;
                        return;
-               }
-               else {
-                       commandPtr+=ret;
-                       commandLen-=ret;
+               } else {
+                       commandPtr += ret;
+                       commandLen -= ret;
                }
 
-               if(commandLen<=0) break;
+               if (commandLen <= 0) {
+                       break;
+               }
        }
 
-       if(commandLen>0) {
+       if (commandLen > 0) {
                perror("");
-               snprintf(connection->errorStr,MPD_ERRORSTR_MAX_LENGTH,
-                        "timeout sending command \"%s\"",command);
+               snprintf(connection->errorStr, MPD_ERRORSTR_MAX_LENGTH,
+                       "timeout sending command \"%s\"", command);
                connection->error = MPD_ERROR_TIMEOUT;
                return;
        }
 
-       if(!connection->commandList) connection->doneProcessing = 0;
-       else if(connection->commandList == COMMAND_LIST_OK) {
+       if (!connection->commandList) {
+               connection->doneProcessing = 0;
+       } else if (connection->commandList == COMMAND_LIST_OK) {
                connection->listOks++;
        }
 }
 
-static void mpd_getNextReturnElement(mpd_Connection * connection) {
-       char * output = NULL;
-       char * rt = NULL;
-       char * name = NULL;
-       char * value = NULL;
+static void mpd_getNextReturnElement(mpd_Connection *connection)
+{
+       char *output = NULL;
+       char *rt = NULL;
+       char *name = NULL;
+       char *value = NULL;
        fd_set fds;
        struct timeval tv;
-       char * tok = NULL;
+       char *tok = NULL;
        int readed;
-       char * bufferCheck = NULL;
+       char *bufferCheck = NULL;
        int err;
        int pos;
 
-       if(connection->returnElement) mpd_freeReturnElement(connection->returnElement);
+       if (connection->returnElement) {
+               mpd_freeReturnElement(connection->returnElement);
+       }
        connection->returnElement = NULL;
 
-       if(connection->doneProcessing || (connection->listOks &&
-          connection->doneListOk))
-       {
-               strcpy(connection->errorStr,"already done processing current command");
+       if (connection->doneProcessing
+                       || (connection->listOks && connection->doneListOk)) {
+               strcpy(connection->errorStr,
+                       "already done processing current command");
                connection->error = 1;
                return;
        }
 
-       bufferCheck = connection->buffer+connection->bufstart;
-       while(connection->bufstart>=connection->buflen ||
-                       !(rt = strchr(bufferCheck,'\n'))) {
-               if(connection->buflen>=MPD_BUFFER_MAX_LENGTH) {
+       bufferCheck = connection->buffer + connection->bufstart;
+       while (connection->bufstart >= connection->buflen
+                       || !(rt = strchr(bufferCheck, '\n'))) {
+               if (connection->buflen >= MPD_BUFFER_MAX_LENGTH) {
                        memmove(connection->buffer,
-                                       connection->buffer+
-                                       connection->bufstart,
-                                       connection->buflen-
-                                       connection->bufstart+1);
-                       connection->buflen-=connection->bufstart;
+                               connection->buffer + connection->bufstart,
+                               connection->buflen - connection->bufstart + 1);
+                       connection->buflen -= connection->bufstart;
                        connection->bufstart = 0;
                }
-               if(connection->buflen>=MPD_BUFFER_MAX_LENGTH) {
-                       strcpy(connection->errorStr,"buffer overrun");
+               if (connection->buflen >= MPD_BUFFER_MAX_LENGTH) {
+                       strcpy(connection->errorStr, "buffer overrun");
                        connection->error = MPD_ERROR_BUFFEROVERRUN;
                        connection->doneProcessing = 1;
                        connection->doneListOk = 0;
                        return;
                }
-               bufferCheck = connection->buffer+connection->buflen;
+               bufferCheck = connection->buffer + connection->buflen;
                tv.tv_sec = connection->timeout.tv_sec;
                tv.tv_usec = connection->timeout.tv_usec;
                FD_ZERO(&fds);
-               FD_SET(connection->sock,&fds);
-               if((err = select(connection->sock+1,&fds,NULL,NULL,&tv) == 1)) {
+               FD_SET(connection->sock, &fds);
+               if ((err = select(connection->sock + 1, &fds, NULL, NULL, &tv) == 1)) {
                        readed = recv(connection->sock,
-                                       connection->buffer+connection->buflen,
-                                       MPD_BUFFER_MAX_LENGTH-connection->buflen,
-                                       MSG_DONTWAIT);
-                       if(readed<0 && SENDRECV_ERRNO_IGNORE) {
+                               connection->buffer + connection->buflen,
+                               MPD_BUFFER_MAX_LENGTH - connection->buflen, MSG_DONTWAIT);
+                       if (readed < 0 && SENDRECV_ERRNO_IGNORE) {
                                continue;
                        }
-                       if(readed<=0) {
-                               strcpy(connection->errorStr,"connection"
-                                      " closed");
+                       if (readed <= 0) {
+                               strcpy(connection->errorStr, "connection closed");
                                connection->error = MPD_ERROR_CONNCLOSED;
                                connection->doneProcessing = 1;
                                connection->doneListOk = 0;
                                return;
                        }
-                       connection->buflen+=readed;
+                       connection->buflen += readed;
                        connection->buffer[connection->buflen] = '\0';
-               }
-               else if(err<0 && SELECT_ERRNO_IGNORE) continue;
-               else {
-                       strcpy(connection->errorStr,"connection timeout");
+               } else if (err < 0 && SELECT_ERRNO_IGNORE) {
+                       continue;
+               } else {
+                       strcpy(connection->errorStr, "connection timeout");
                        connection->error = MPD_ERROR_TIMEOUT;
                        connection->doneProcessing = 1;
                        connection->doneListOk = 0;
@@ -560,11 +569,11 @@ static void mpd_getNextReturnElement(mpd_Connection * connection) {
        }
 
        *rt = '\0';
-       output = connection->buffer+connection->bufstart;
+       output = connection->buffer + connection->bufstart;
        connection->bufstart = rt - connection->buffer + 1;
 
-       if(strcmp(output,"OK")==0) {
-               if(connection->listOks > 0) {
+       if (strcmp(output, "OK") == 0) {
+               if (connection->listOks > 0) {
                        strcpy(connection->errorStr, "expected more list_OK's");
                        connection->error = 1;
                }
@@ -574,22 +583,20 @@ static void mpd_getNextReturnElement(mpd_Connection * connection) {
                return;
        }
 
-       if(strcmp(output, "list_OK") == 0) {
-               if(!connection->listOks) {
-                       strcpy(connection->errorStr,
-                                       "got an unexpected list_OK");
+       if (strcmp(output, "list_OK") == 0) {
+               if (!connection->listOks) {
+                       strcpy(connection->errorStr, "got an unexpected list_OK");
                        connection->error = 1;
-               }
-               else {
+               } else {
                        connection->doneListOk = 1;
                        connection->listOks--;
                }
                return;
        }
 
-       if(strncmp(output,"ACK",strlen("ACK"))==0) {
-               char * test;
-               char * needle;
+       if (strncmp(output, "ACK", strlen("ACK")) == 0) {
+               char *test;
+               char *needle;
                int val;
 
                strcpy(connection->errorStr, output);
@@ -600,73 +607,92 @@ static void mpd_getNextReturnElement(mpd_Connection * connection) {
                connection->doneListOk = 0;
 
                needle = strchr(output, '[');
-               if(!needle) return;
-               val = strtol(needle+1, &test, 10);
-               if(*test != '@') return;
+               if (!needle) {
+                       return;
+               }
+               val = strtol(needle + 1, &test, 10);
+               if (*test != '@') {
+                       return;
+               }
                connection->errorCode = val;
-               val = strtol(test+1, &test, 10);
-               if(*test != ']') return;
+               val = strtol(test + 1, &test, 10);
+               if (*test != ']') {
+                       return;
+               }
                connection->errorAt = val;
                return;
        }
 
        tok = strchr(output, ':');
-       if (!tok) return;
+       if (!tok) {
+               return;
+       }
        pos = tok - output;
        value = ++tok;
        name = output;
        name[pos] = '\0';
 
-       if(value[0]==' ') {
-               connection->returnElement = mpd_newReturnElement(name,&(value[1]));
-       }
-       else {
-               snprintf(connection->errorStr,MPD_ERRORSTR_MAX_LENGTH,
-                                       "error parsing: %s:%s",name,value);
+       if (value[0] == ' ') {
+               connection->returnElement = mpd_newReturnElement(name, &(value[1]));
+       } else {
+               snprintf(connection->errorStr, MPD_ERRORSTR_MAX_LENGTH,
+                       "error parsing: %s:%s", name, value);
                connection->error = 1;
        }
 }
 
-void mpd_finishCommand(mpd_Connection * connection) {
-       while(!connection->doneProcessing) {
-               if(connection->doneListOk) connection->doneListOk = 0;
+void mpd_finishCommand(mpd_Connection *connection)
+{
+       while (!connection->doneProcessing) {
+               if (connection->doneListOk) {
+                       connection->doneListOk = 0;
+               }
                mpd_getNextReturnElement(connection);
        }
 }
 
-static void mpd_finishListOkCommand(mpd_Connection * connection) {
-       while(!connection->doneProcessing && connection->listOks &&
-                       !connection->doneListOk)
-       {
+static void mpd_finishListOkCommand(mpd_Connection *connection)
+{
+       while (!connection->doneProcessing && connection->listOks
+                       && !connection->doneListOk) {
                mpd_getNextReturnElement(connection);
        }
 }
 
-int mpd_nextListOkCommand(mpd_Connection * connection) {
+int mpd_nextListOkCommand(mpd_Connection *connection)
+{
        mpd_finishListOkCommand(connection);
-       if(!connection->doneProcessing) connection->doneListOk = 0;
-       if(connection->listOks == 0 || connection->doneProcessing) return -1;
+       if (!connection->doneProcessing) {
+               connection->doneListOk = 0;
+       }
+       if (connection->listOks == 0 || connection->doneProcessing) {
+               return -1;
+       }
        return 0;
 }
 
-void mpd_sendStatusCommand(mpd_Connection * connection) {
-       mpd_executeCommand(connection,"status\n");
+void mpd_sendStatusCommand(mpd_Connection *connection)
+{
+       mpd_executeCommand(connection, "status\n");
 }
 
-mpd_Status * mpd_getStatus(mpd_Connection * connection) {
-       mpd_Status * status;
-
-       /*mpd_executeCommand(connection,"status\n");
+mpd_Status *mpd_getStatus(mpd_Connection *connection)
+{
+       mpd_Status *status;
 
-       if(connection->error) return NULL;*/
+       /* mpd_executeCommand(connection, "status\n");
+       if (connection->error) {
+               return NULL;
+       } */
 
-       if(connection->doneProcessing || (connection->listOks &&
-          connection->doneListOk))
-       {
+       if (connection->doneProcessing
+                       || (connection->listOks && connection->doneListOk)) {
                return NULL;
        }
 
-       if(!connection->returnElement) mpd_getNextReturnElement(connection);
+       if (!connection->returnElement) {
+               mpd_getNextReturnElement(connection);
+       }
 
        status = malloc(sizeof(mpd_Status));
        status->volume = -1;
@@ -687,92 +713,79 @@ mpd_Status * mpd_getStatus(mpd_Connection * connection) {
        status->error = NULL;
        status->updatingDb = 0;
 
-       if(connection->error) {
+       if (connection->error) {
                free(status);
                return NULL;
        }
-       while(connection->returnElement) {
-               mpd_ReturnElement * re = connection->returnElement;
-               if(strcmp(re->name,"volume")==0) {
+       while (connection->returnElement) {
+               mpd_ReturnElement *re = connection->returnElement;
+
+               if (strcmp(re->name, "volume") == 0) {
                        status->volume = atoi(re->value);
-               }
-               else if(strcmp(re->name,"repeat")==0) {
+               } else if (strcmp(re->name, "repeat") == 0) {
                        status->repeat = atoi(re->value);
-               }
-               else if(strcmp(re->name,"random")==0) {
+               } else if (strcmp(re->name, "random") == 0) {
                        status->random = atoi(re->value);
-               }
-               else if(strcmp(re->name,"playlist")==0) {
-                       status->playlist = strtol(re->value,NULL,10);
-               }
-               else if(strcmp(re->name,"playlistlength")==0) {
+               } else if (strcmp(re->name, "playlist") == 0) {
+                       status->playlist = strtol(re->value, NULL, 10);
+               } else if (strcmp(re->name, "playlistlength") == 0) {
                        status->playlistLength = atoi(re->value);
-               }
-               else if(strcmp(re->name,"bitrate")==0) {
+               } else if (strcmp(re->name, "bitrate") == 0) {
                        status->bitRate = atoi(re->value);
-               }
-               else if(strcmp(re->name,"state")==0) {
-                       if(strcmp(re->value,"play")==0) {
+               } else if (strcmp(re->name, "state") == 0) {
+                       if (strcmp(re->value, "play") == 0) {
                                status->state = MPD_STATUS_STATE_PLAY;
-                       }
-                       else if(strcmp(re->value,"stop")==0) {
+                       } else if (strcmp(re->value, "stop") == 0) {
                                status->state = MPD_STATUS_STATE_STOP;
-                       }
-                       else if(strcmp(re->value,"pause")==0) {
+                       } else if (strcmp(re->value, "pause") == 0) {
                                status->state = MPD_STATUS_STATE_PAUSE;
-                       }
-                       else {
+                       } else {
                                status->state = MPD_STATUS_STATE_UNKNOWN;
                        }
-               }
-               else if(strcmp(re->name,"song")==0) {
+               } else if (strcmp(re->name, "song") == 0) {
                        status->song = atoi(re->value);
-               }
-               else if(strcmp(re->name,"songid")==0) {
+               } else if (strcmp(re->name, "songid") == 0) {
                        status->songid = atoi(re->value);
-               }
-               else if(strcmp(re->name,"time")==0) {
-                       char * tok = strchr(re->value,':');
+               } else if (strcmp(re->name, "time") == 0) {
+                       char *tok = strchr(re->value, ':');
+
                        /* the second strchr below is a safety check */
-                       if (tok && (strchr(tok,0) > (tok+1))) {
+                       if (tok && (strchr(tok, 0) > (tok + 1))) {
                                /* atoi stops at the first non-[0-9] char: */
                                status->elapsedTime = atoi(re->value);
-                               status->totalTime = atoi(tok+1);
+                               status->totalTime = atoi(tok + 1);
                        }
-               }
-               else if(strcmp(re->name,"error")==0) {
+               } else if (strcmp(re->name, "error") == 0) {
                        status->error = strdup(re->value);
-               }
-               else if(strcmp(re->name,"xfade")==0) {
+               } else if (strcmp(re->name, "xfade") == 0) {
                        status->crossfade = atoi(re->value);
-               }
-               else if(strcmp(re->name,"updating_db")==0) {
+               } else if (strcmp(re->name, "updating_db") == 0) {
                        status->updatingDb = atoi(re->value);
-               }
-               else if(strcmp(re->name,"audio")==0) {
-                       char * tok = strchr(re->value,':');
-                       if (tok && (strchr(tok,0) > (tok+1))) {
+               } else if (strcmp(re->name, "audio") == 0) {
+                       char *tok = strchr(re->value, ':');
+
+                       if (tok && (strchr(tok, 0) > (tok + 1))) {
                                status->sampleRate = atoi(re->value);
                                status->bits = atoi(++tok);
-                               tok = strchr(tok,':');
-                               if (tok && (strchr(tok,0) > (tok+1)))
-                                       status->channels = atoi(tok+1);
+                               tok = strchr(tok, ':');
+                               if (tok && (strchr(tok, 0) > (tok + 1))) {
+                                       status->channels = atoi(tok + 1);
+                               }
                        }
                }
 
                mpd_getNextReturnElement(connection);
-               if(connection->error) {
+               if (connection->error) {
                        free(status);
                        return NULL;
                }
        }
 
-       if(connection->error) {
+       if (connection->error) {
                free(status);
                return NULL;
-       }
-       else if(status->state<0) {
-               strcpy(connection->errorStr,"state not found");
+       } else if (status->state < 0) {
+               strcpy(connection->errorStr, "state not found");
                connection->error = 1;
                free(status);
                return NULL;
@@ -781,29 +794,36 @@ mpd_Status * mpd_getStatus(mpd_Connection * connection) {
        return status;
 }
 
-void mpd_freeStatus(mpd_Status * status) {
-       if(status->error) free(status->error);
+void mpd_freeStatus(mpd_Status *status)
+{
+       if (status->error) {
+               free(status->error);
+       }
        free(status);
 }
 
-void mpd_sendStatsCommand(mpd_Connection * connection) {
-       mpd_executeCommand(connection,"stats\n");
+void mpd_sendStatsCommand(mpd_Connection *connection)
+{
+       mpd_executeCommand(connection, "stats\n");
 }
 
-mpd_Stats * mpd_getStats(mpd_Connection * connection) {
-       mpd_Stats * stats;
-
-       /*mpd_executeCommand(connection,"stats\n");
+mpd_Stats *mpd_getStats(mpd_Connection *connection)
+{
+       mpd_Stats *stats;
 
-       if(connection->error) return NULL;*/
+       /* mpd_executeCommand(connection, "stats\n");
+       if (connection->error) {
+               return NULL;
+       } */
 
-       if(connection->doneProcessing || (connection->listOks &&
-          connection->doneListOk))
-       {
+       if (connection->doneProcessing
+                       || (connection->listOks && connection->doneListOk)) {
                return NULL;
        }
 
-       if(!connection->returnElement) mpd_getNextReturnElement(connection);
+       if (!connection->returnElement) {
+               mpd_getNextReturnElement(connection);
+       }
 
        stats = malloc(sizeof(mpd_Stats));
        stats->numberOfArtists = 0;
@@ -814,42 +834,37 @@ mpd_Stats * mpd_getStats(mpd_Connection * connection) {
        stats->playTime = 0;
        stats->dbPlayTime = 0;
 
-       if(connection->error) {
+       if (connection->error) {
                free(stats);
                return NULL;
        }
-       while(connection->returnElement) {
-               mpd_ReturnElement * re = connection->returnElement;
-               if(strcmp(re->name,"artists")==0) {
+       while (connection->returnElement) {
+               mpd_ReturnElement *re = connection->returnElement;
+
+               if (strcmp(re->name, "artists") == 0) {
                        stats->numberOfArtists = atoi(re->value);
-               }
-               else if(strcmp(re->name,"albums")==0) {
+               } else if (strcmp(re->name, "albums") == 0) {
                        stats->numberOfAlbums = atoi(re->value);
-               }
-               else if(strcmp(re->name,"songs")==0) {
+               } else if (strcmp(re->name, "songs") == 0) {
                        stats->numberOfSongs = atoi(re->value);
-               }
-               else if(strcmp(re->name,"uptime")==0) {
-                       stats->uptime = strtol(re->value,NULL,10);
-               }
-               else if(strcmp(re->name,"db_update")==0) {
-                       stats->dbUpdateTime = strtol(re->value,NULL,10);
-               }
-               else if(strcmp(re->name,"playtime")==0) {
-                       stats->playTime = strtol(re->value,NULL,10);
-               }
-               else if(strcmp(re->name,"db_playtime")==0) {
-                       stats->dbPlayTime = strtol(re->value,NULL,10);
+               } else if (strcmp(re->name, "uptime") == 0) {
+                       stats->uptime = strtol(re->value, NULL, 10);
+               } else if (strcmp(re->name, "db_update") == 0) {
+                       stats->dbUpdateTime = strtol(re->value, NULL, 10);
+               } else if (strcmp(re->name, "playtime") == 0) {
+                       stats->playTime = strtol(re->value, NULL, 10);
+               } else if (strcmp(re->name, "db_playtime") == 0) {
+                       stats->dbPlayTime = strtol(re->value, NULL, 10);
                }
 
                mpd_getNextReturnElement(connection);
-               if(connection->error) {
+               if (connection->error) {
                        free(stats);
                        return NULL;
                }
        }
 
-       if(connection->error) {
+       if (connection->error) {
                free(stats);
                return NULL;
        }
@@ -857,24 +872,28 @@ mpd_Stats * mpd_getStats(mpd_Connection * connection) {
        return stats;
 }
 
-void mpd_freeStats(mpd_Stats * stats) {
+void mpd_freeStats(mpd_Stats *stats)
+{
        free(stats);
 }
 
-mpd_SearchStats * mpd_getSearchStats(mpd_Connection * connection)
+mpd_SearchStats *mpd_getSearchStats(mpd_Connection *connection)
 {
-       mpd_SearchStats * stats;
-       mpd_ReturnElement * re;
+       mpd_SearchStats *stats;
+       mpd_ReturnElement *re;
 
-       if (connection->doneProcessing ||
-           (connection->listOks && connection->doneListOk)) {
+       if (connection->doneProcessing
+                       || (connection->listOks && connection->doneListOk)) {
                return NULL;
        }
 
-       if (!connection->returnElement) mpd_getNextReturnElement(connection);
+       if (!connection->returnElement) {
+               mpd_getNextReturnElement(connection);
+       }
 
-       if (connection->error)
+       if (connection->error) {
                return NULL;
+       }
 
        stats = malloc(sizeof(mpd_SearchStats));
        stats->numberOfSongs = 0;
@@ -904,12 +923,13 @@ mpd_SearchStats * mpd_getSearchStats(mpd_Connection * connection)
        return stats;
 }
 
-void mpd_freeSearchStats(mpd_SearchStats * stats)
+void mpd_freeSearchStats(mpd_SearchStats *stats)
 {
        free(stats);
 }
 
-static void mpd_initSong(mpd_Song * song) {
+static void mpd_initSong(mpd_Song *song)
+{
        song->file = NULL;
        song->artist = NULL;
        song->album = NULL;
@@ -929,47 +949,95 @@ static void mpd_initSong(mpd_Song * song) {
        song->id = MPD_SONG_NO_ID;
 }
 
-static void mpd_finishSong(mpd_Song * song) {
-       if(song->file) free(song->file);
-       if(song->artist) free(song->artist);
-       if(song->album) free(song->album);
-       if(song->title) free(song->title);
-       if(song->track) free(song->track);
-       if(song->name) free(song->name);
-       if(song->date) free(song->date);
-       if(song->genre) free(song->genre);
-       if(song->composer) free(song->composer);
-       if(song->disc) free(song->disc);
-       if(song->comment) free(song->comment);
+static void mpd_finishSong(mpd_Song *song)
+{
+       if (song->file) {
+               free(song->file);
+       }
+       if (song->artist) {
+               free(song->artist);
+       }
+       if (song->album) {
+               free(song->album);
+       }
+       if (song->title) {
+               free(song->title);
+       }
+       if (song->track) {
+               free(song->track);
+       }
+       if (song->name) {
+               free(song->name);
+       }
+       if (song->date) {
+               free(song->date);
+       }
+       if (song->genre) {
+               free(song->genre);
+       }
+       if (song->composer) {
+               free(song->composer);
+       }
+       if (song->disc) {
+               free(song->disc);
+       }
+       if (song->comment) {
+               free(song->comment);
+       }
 }
 
-mpd_Song * mpd_newSong(void) {
-       mpd_Song * ret = malloc(sizeof(mpd_Song));
+mpd_Song *mpd_newSong(void)
+{
+       mpd_Song *ret = malloc(sizeof(mpd_Song));
 
        mpd_initSong(ret);
 
        return ret;
 }
 
-void mpd_freeSong(mpd_Song * song) {
+void mpd_freeSong(mpd_Song *song)
+{
        mpd_finishSong(song);
        free(song);
 }
 
-mpd_Song * mpd_songDup(mpd_Song * song) {
-       mpd_Song * ret = mpd_newSong();
-
-       if(song->file) ret->file = strdup(song->file);
-       if(song->artist) ret->artist = strdup(song->artist);
-       if(song->album) ret->album = strdup(song->album);
-       if(song->title) ret->title = strdup(song->title);
-       if(song->track) ret->track = strdup(song->track);
-       if(song->name) ret->name = strdup(song->name);
-       if(song->date) ret->date = strdup(song->date);
-       if(song->genre) ret->genre= strdup(song->genre);
-       if(song->composer) ret->composer= strdup(song->composer);
-       if(song->disc) ret->disc = strdup(song->disc);
-       if(song->comment) ret->comment = strdup(song->comment);
+mpd_Song *mpd_songDup(mpd_Song *song)
+{
+       mpd_Song *ret = mpd_newSong();
+
+       if (song->file) {
+               ret->file = strdup(song->file);
+       }
+       if (song->artist) {
+               ret->artist = strdup(song->artist);
+       }
+       if (song->album) {
+               ret->album = strdup(song->album);
+       }
+       if (song->title) {
+               ret->title = strdup(song->title);
+       }
+       if (song->track) {
+               ret->track = strdup(song->track);
+       }
+       if (song->name) {
+               ret->name = strdup(song->name);
+       }
+       if (song->date) {
+               ret->date = strdup(song->date);
+       }
+       if (song->genre) {
+               ret->genre = strdup(song->genre);
+       }
+       if (song->composer) {
+               ret->composer = strdup(song->composer);
+       }
+       if (song->disc) {
+               ret->disc = strdup(song->disc);
+       }
+       if (song->comment) {
+               ret->comment = strdup(song->comment);
+       }
        ret->time = song->time;
        ret->pos = song->pos;
        ret->id = song->id;
@@ -977,219 +1045,226 @@ mpd_Song * mpd_songDup(mpd_Song * song) {
        return ret;
 }
 
-static void mpd_initDirectory(mpd_Directory * directory) {
+static void mpd_initDirectory(mpd_Directory *directory)
+{
        directory->path = NULL;
 }
 
-static void mpd_finishDirectory(mpd_Directory * directory) {
-       if(directory->path) free(directory->path);
+static void mpd_finishDirectory(mpd_Directory *directory)
+{
+       if (directory->path) {
+               free(directory->path);
+       }
 }
 
-mpd_Directory * mpd_newDirectory(void) {
-       mpd_Directory * directory = malloc(sizeof(mpd_Directory));
+mpd_Directory *mpd_newDirectory(void)
+{
+       mpd_Directory *directory = malloc(sizeof(mpd_Directory));
 
        mpd_initDirectory(directory);
 
        return directory;
 }
 
-void mpd_freeDirectory(mpd_Directory * directory) {
+void mpd_freeDirectory(mpd_Directory *directory)
+{
        mpd_finishDirectory(directory);
 
        free(directory);
 }
 
-mpd_Directory * mpd_directoryDup(mpd_Directory * directory) {
-       mpd_Directory * ret = mpd_newDirectory();
+mpd_Directory *mpd_directoryDup(mpd_Directory *directory)
+{
+       mpd_Directory *ret = mpd_newDirectory();
 
-       if(directory->path) ret->path = strdup(directory->path);
+       if (directory->path) {
+               ret->path = strdup(directory->path);
+       }
 
        return ret;
 }
 
-static void mpd_initPlaylistFile(mpd_PlaylistFile * playlist) {
+static void mpd_initPlaylistFile(mpd_PlaylistFile *playlist)
+{
        playlist->path = NULL;
 }
 
-static void mpd_finishPlaylistFile(mpd_PlaylistFile * playlist) {
-       if(playlist->path) free(playlist->path);
+static void mpd_finishPlaylistFile(mpd_PlaylistFile *playlist)
+{
+       if (playlist->path) {
+               free(playlist->path);
+       }
 }
 
-mpd_PlaylistFile * mpd_newPlaylistFile(void) {
-       mpd_PlaylistFile * playlist = malloc(sizeof(mpd_PlaylistFile));
+mpd_PlaylistFile *mpd_newPlaylistFile(void)
+{
+       mpd_PlaylistFile *playlist = malloc(sizeof(mpd_PlaylistFile));
 
        mpd_initPlaylistFile(playlist);
 
        return playlist;
 }
 
-void mpd_freePlaylistFile(mpd_PlaylistFile * playlist) {
+void mpd_freePlaylistFile(mpd_PlaylistFile *playlist)
+{
        mpd_finishPlaylistFile(playlist);
        free(playlist);
 }
 
-mpd_PlaylistFile * mpd_playlistFileDup(mpd_PlaylistFile * playlist) {
-       mpd_PlaylistFile * ret = mpd_newPlaylistFile();
+mpd_PlaylistFile *mpd_playlistFileDup(mpd_PlaylistFile *playlist)
+{
+       mpd_PlaylistFile *ret = mpd_newPlaylistFile();
 
-       if(playlist->path) ret->path = strdup(playlist->path);
+       if (playlist->path) {
+               ret->path = strdup(playlist->path);
+       }
 
        return ret;
 }
 
-static void mpd_initInfoEntity(mpd_InfoEntity * entity) {
+static void mpd_initInfoEntity(mpd_InfoEntity *entity)
+{
        entity->info.directory = NULL;
 }
 
-static void mpd_finishInfoEntity(mpd_InfoEntity * entity) {
-       if(entity->info.directory) {
-               if(entity->type == MPD_INFO_ENTITY_TYPE_DIRECTORY) {
+static void mpd_finishInfoEntity(mpd_InfoEntity *entity)
+{
+       if (entity->info.directory) {
+               if (entity->type == MPD_INFO_ENTITY_TYPE_DIRECTORY) {
                        mpd_freeDirectory(entity->info.directory);
-               }
-               else if(entity->type == MPD_INFO_ENTITY_TYPE_SONG) {
+               } else if (entity->type == MPD_INFO_ENTITY_TYPE_SONG) {
                        mpd_freeSong(entity->info.song);
-               }
-               else if(entity->type == MPD_INFO_ENTITY_TYPE_PLAYLISTFILE) {
+               } else if (entity->type == MPD_INFO_ENTITY_TYPE_PLAYLISTFILE) {
                        mpd_freePlaylistFile(entity->info.playlistFile);
                }
        }
 }
 
-mpd_InfoEntity * mpd_newInfoEntity(void) {
-       mpd_InfoEntity * entity = malloc(sizeof(mpd_InfoEntity));
+mpd_InfoEntity *mpd_newInfoEntity(void)
+{
+       mpd_InfoEntity *entity = malloc(sizeof(mpd_InfoEntity));
 
        mpd_initInfoEntity(entity);
 
        return entity;
 }
 
-void mpd_freeInfoEntity(mpd_InfoEntity * entity) {
+void mpd_freeInfoEntity(mpd_InfoEntity *entity)
+{
        mpd_finishInfoEntity(entity);
        free(entity);
 }
 
-static void mpd_sendInfoCommand(mpd_Connection * connection, char * command) {
-       mpd_executeCommand(connection,command);
+static void mpd_sendInfoCommand(mpd_Connection *connection, char *command)
+{
+       mpd_executeCommand(connection, command);
 }
 
-mpd_InfoEntity * mpd_getNextInfoEntity(mpd_Connection * connection) {
-       mpd_InfoEntity * entity = NULL;
+mpd_InfoEntity *mpd_getNextInfoEntity(mpd_Connection *connection)
+{
+       mpd_InfoEntity *entity = NULL;
 
-       if(connection->doneProcessing || (connection->listOks &&
-          connection->doneListOk))
-       {
+       if (connection->doneProcessing
+                       || (connection->listOks && connection->doneListOk)) {
                return NULL;
        }
 
-       if(!connection->returnElement) mpd_getNextReturnElement(connection);
+       if (!connection->returnElement) {
+               mpd_getNextReturnElement(connection);
+       }
 
-       if(connection->returnElement) {
-               if(strcmp(connection->returnElement->name,"file")==0) {
+       if (connection->returnElement) {
+               if (strcmp(connection->returnElement->name, "file") == 0) {
                        entity = mpd_newInfoEntity();
                        entity->type = MPD_INFO_ENTITY_TYPE_SONG;
                        entity->info.song = mpd_newSong();
-                       entity->info.song->file =
-                               strdup(connection->returnElement->value);
-               }
-               else if(strcmp(connection->returnElement->name,
-                                       "directory")==0) {
+                       entity->info.song->file = strdup(connection->returnElement->value);
+               } else if (strcmp(connection->returnElement->name, "directory") == 0) {
                        entity = mpd_newInfoEntity();
                        entity->type = MPD_INFO_ENTITY_TYPE_DIRECTORY;
                        entity->info.directory = mpd_newDirectory();
                        entity->info.directory->path =
                                strdup(connection->returnElement->value);
-               }
-               else if(strcmp(connection->returnElement->name,"playlist")==0) {
+               } else if (strcmp(connection->returnElement->name, "playlist") == 0) {
                        entity = mpd_newInfoEntity();
                        entity->type = MPD_INFO_ENTITY_TYPE_PLAYLISTFILE;
                        entity->info.playlistFile = mpd_newPlaylistFile();
                        entity->info.playlistFile->path =
                                strdup(connection->returnElement->value);
-               }
-               else if(strcmp(connection->returnElement->name, "cpos") == 0){
+               } else if (strcmp(connection->returnElement->name, "cpos") == 0) {
                        entity = mpd_newInfoEntity();
                        entity->type = MPD_INFO_ENTITY_TYPE_SONG;
                        entity->info.song = mpd_newSong();
                        entity->info.song->pos = atoi(connection->returnElement->value);
-               }
-               else {
+               } else {
                        connection->error = 1;
-                       strcpy(connection->errorStr,"problem parsing song info");
+                       strcpy(connection->errorStr, "problem parsing song info");
                        return NULL;
                }
+       } else {
+               return NULL;
        }
-       else return NULL;
 
        mpd_getNextReturnElement(connection);
-       while(connection->returnElement) {
-               mpd_ReturnElement * re = connection->returnElement;
-
-               if(strcmp(re->name,"file")==0) return entity;
-               else if(strcmp(re->name,"directory")==0) return entity;
-               else if(strcmp(re->name,"playlist")==0) return entity;
-               else if(strcmp(re->name,"cpos")==0) return entity;
-
-               if(entity->type == MPD_INFO_ENTITY_TYPE_SONG &&
-                               strlen(re->value)) {
-                       if(!entity->info.song->artist &&
-                                       strcmp(re->name,"Artist")==0) {
+       while (connection->returnElement) {
+               mpd_ReturnElement *re = connection->returnElement;
+
+               if (strcmp(re->name, "file") == 0) {
+                       return entity;
+               } else if (strcmp(re->name, "directory") == 0) {
+                       return entity;
+               } else if (strcmp(re->name, "playlist") == 0) {
+                       return entity;
+               } else if (strcmp(re->name, "cpos") == 0) {
+                       return entity;
+               }
+
+               if (entity->type == MPD_INFO_ENTITY_TYPE_SONG && strlen(re->value)) {
+                       if (!entity->info.song->artist
+                                       && strcmp(re->name, "Artist") == 0) {
                                entity->info.song->artist = strdup(re->value);
-                       }
-                       else if(!entity->info.song->album &&
-                                       strcmp(re->name,"Album")==0) {
+                       } else if (!entity->info.song->album
+                                       && strcmp(re->name, "Album") == 0) {
                                entity->info.song->album = strdup(re->value);
-                       }
-                       else if(!entity->info.song->title &&
-                                       strcmp(re->name,"Title")==0) {
+                       } else if (!entity->info.song->title
+                                       && strcmp(re->name, "Title") == 0) {
                                entity->info.song->title = strdup(re->value);
-                       }
-                       else if(!entity->info.song->track &&
-                                       strcmp(re->name,"Track")==0) {
+                       } else if (!entity->info.song->track
+                                       && strcmp(re->name, "Track") == 0) {
                                entity->info.song->track = strdup(re->value);
-                       }
-                       else if(!entity->info.song->name &&
-                                       strcmp(re->name,"Name")==0) {
+                       } else if (!entity->info.song->name
+                                       && strcmp(re->name, "Name") == 0) {
                                entity->info.song->name = strdup(re->value);
-                       }
-                       else if(entity->info.song->time==MPD_SONG_NO_TIME &&
-                                       strcmp(re->name,"Time")==0) {
+                       } else if (entity->info.song->time == MPD_SONG_NO_TIME
+                                       && strcmp(re->name, "Time") == 0) {
                                entity->info.song->time = atoi(re->value);
-                       }
-                       else if(entity->info.song->pos==MPD_SONG_NO_NUM &&
-                                       strcmp(re->name,"Pos")==0) {
+                       } else if (entity->info.song->pos == MPD_SONG_NO_NUM
+                                       && strcmp(re->name, "Pos") == 0) {
                                entity->info.song->pos = atoi(re->value);
-                       }
-                       else if(entity->info.song->id==MPD_SONG_NO_ID &&
-                                       strcmp(re->name,"Id")==0) {
+                       } else if (entity->info.song->id == MPD_SONG_NO_ID
+                                       && strcmp(re->name, "Id") == 0) {
                                entity->info.song->id = atoi(re->value);
-                       }
-                       else if(!entity->info.song->date &&
-                                       strcmp(re->name, "Date") == 0) {
+                       } else if (!entity->info.song->date
+                                       && strcmp(re->name, "Date") == 0) {
                                entity->info.song->date = strdup(re->value);
-                       }
-                       else if(!entity->info.song->genre &&
-                                       strcmp(re->name, "Genre") == 0) {
+                       } else if (!entity->info.song->genre
+                                       && strcmp(re->name, "Genre") == 0) {
                                entity->info.song->genre = strdup(re->value);
-                       }
-                       else if(!entity->info.song->composer &&
-                                       strcmp(re->name, "Composer") == 0) {
+                       } else if (!entity->info.song->composer
+                                       && strcmp(re->name, "Composer") == 0) {
                                entity->info.song->composer = strdup(re->value);
-                       }
-                       else if(!entity->info.song->performer &&
-                                       strcmp(re->name, "Performer") == 0) {
+                       } else if (!entity->info.song->performer
+                                       && strcmp(re->name, "Performer") == 0) {
                                entity->info.song->performer = strdup(re->value);
-                       }
-                       else if(!entity->info.song->disc &&
-                                       strcmp(re->name, "Disc") == 0) {
+                       } else if (!entity->info.song->disc
+                                       && strcmp(re->name, "Disc") == 0) {
                                entity->info.song->disc = strdup(re->value);
-                       }
-                       else if(!entity->info.song->comment &&
-                                       strcmp(re->name, "Comment") == 0) {
+                       } else if (!entity->info.song->comment
+                                       && strcmp(re->name, "Comment") == 0) {
                                entity->info.song->comment = strdup(re->value);
                        }
-               }
-               else if(entity->type == MPD_INFO_ENTITY_TYPE_DIRECTORY) {
-               }
-               else if(entity->type == MPD_INFO_ENTITY_TYPE_PLAYLISTFILE) {
+               } else if (entity->type == MPD_INFO_ENTITY_TYPE_DIRECTORY) {
+               } else if (entity->type == MPD_INFO_ENTITY_TYPE_PLAYLISTFILE) {
                }
 
                mpd_getNextReturnElement(connection);
@@ -1198,20 +1273,21 @@ mpd_InfoEntity * mpd_getNextInfoEntity(mpd_Connection * connection) {
        return entity;
 }
 
-static char * mpd_getNextReturnElementNamed(mpd_Connection * connection,
-               const char * name)
+static char *mpd_getNextReturnElementNamed(mpd_Connection *connection,
+               const char *name)
 {
-       if(connection->doneProcessing || (connection->listOks &&
-                               connection->doneListOk))
-       {
+       if (connection->doneProcessing
+                       || (connection->listOks && connection->doneListOk)) {
                return NULL;
        }
 
        mpd_getNextReturnElement(connection);
-       while(connection->returnElement) {
-               mpd_ReturnElement * re = connection->returnElement;
+       while (connection->returnElement) {
+               mpd_ReturnElement *re = connection->returnElement;
 
-               if(strcmp(re->name,name)==0) return strdup(re->value);
+               if (strcmp(re->name, name) == 0) {
+                       return strdup(re->value);
+               }
                mpd_getNextReturnElement(connection);
        }
 
@@ -1220,139 +1296,164 @@ static char * mpd_getNextReturnElementNamed(mpd_Connection * connection,
 
 char *mpd_getNextTag(mpd_Connection *connection, int type)
 {
-       if (type < 0 || type >= MPD_TAG_NUM_OF_ITEM_TYPES ||
-           type == MPD_TAG_ITEM_ANY)
+       if (type < 0 || type >= MPD_TAG_NUM_OF_ITEM_TYPES
+                       || type == MPD_TAG_ITEM_ANY) {
                return NULL;
-       if (type == MPD_TAG_ITEM_FILENAME)
+       }
+       if (type == MPD_TAG_ITEM_FILENAME) {
                return mpd_getNextReturnElementNamed(connection, "file");
+       }
        return mpd_getNextReturnElementNamed(connection, mpdTagItemKeys[type]);
 }
 
-char * mpd_getNextArtist(mpd_Connection * connection) {
-       return mpd_getNextReturnElementNamed(connection,"Artist");
+char *mpd_getNextArtist(mpd_Connection *connection)
+{
+       return mpd_getNextReturnElementNamed(connection, "Artist");
 }
 
-char * mpd_getNextAlbum(mpd_Connection * connection) {
-       return mpd_getNextReturnElementNamed(connection,"Album");
+char *mpd_getNextAlbum(mpd_Connection *connection)
+{
+       return mpd_getNextReturnElementNamed(connection, "Album");
 }
 
-void mpd_sendPlaylistInfoCommand(mpd_Connection * connection, int songPos) {
-       int len = strlen("playlistinfo")+2+INTLEN+3;
+void mpd_sendPlaylistInfoCommand(mpd_Connection *connection, int songPos)
+{
+       int len = strlen("playlistinfo") + 2 + INTLEN + 3;
        char *string = malloc(len);
+
        snprintf(string, len, "playlistinfo \"%i\"\n", songPos);
-       mpd_sendInfoCommand(connection,string);
+       mpd_sendInfoCommand(connection, string);
        free(string);
 }
 
-void mpd_sendPlaylistIdCommand(mpd_Connection * connection, int id) {
-       int len = strlen("playlistid")+2+INTLEN+3;
+void mpd_sendPlaylistIdCommand(mpd_Connection *connection, int id)
+{
+       int len = strlen("playlistid") + 2 + INTLEN + 3;
        char *string = malloc(len);
+
        snprintf(string, len, "playlistid \"%i\"\n", id);
        mpd_sendInfoCommand(connection, string);
        free(string);
 }
 
-void mpd_sendPlChangesCommand(mpd_Connection * connection, long long playlist) {
-       int len = strlen("plchanges")+2+LONGLONGLEN+3;
+void mpd_sendPlChangesCommand(mpd_Connection *connection, long long playlist)
+{
+       int len = strlen("plchanges") + 2 + LONGLONGLEN + 3;
        char *string = malloc(len);
+
        snprintf(string, len, "plchanges \"%lld\"\n", playlist);
-       mpd_sendInfoCommand(connection,string);
+       mpd_sendInfoCommand(connection, string);
        free(string);
 }
 
-void mpd_sendPlChangesPosIdCommand(mpd_Connection * connection, long long playlist) {
-       int len = strlen("plchangesposid")+2+LONGLONGLEN+3;
+void mpd_sendPlChangesPosIdCommand(mpd_Connection *connection,
+               long long playlist)
+{
+       int len = strlen("plchangesposid") + 2 + LONGLONGLEN + 3;
        char *string = malloc(len);
+
        snprintf(string, len, "plchangesposid \"%lld\"\n", playlist);
-       mpd_sendInfoCommand(connection,string);
+       mpd_sendInfoCommand(connection, string);
        free(string);
 }
 
-void mpd_sendListallCommand(mpd_Connection * connection, const char * dir) {
-       char * sDir = mpd_sanitizeArg(dir);
-       int len = strlen("listall")+2+strlen(sDir)+3;
+void mpd_sendListallCommand(mpd_Connection *connection, const char *dir)
+{
+       char *sDir = mpd_sanitizeArg(dir);
+       int len = strlen("listall") + 2 + strlen(sDir) + 3;
        char *string = malloc(len);
+
        snprintf(string, len, "listall \"%s\"\n", sDir);
-       mpd_sendInfoCommand(connection,string);
+       mpd_sendInfoCommand(connection, string);
        free(string);
        free(sDir);
 }
 
-void mpd_sendListallInfoCommand(mpd_Connection * connection, const char * dir) {
-       char * sDir = mpd_sanitizeArg(dir);
-       int len = strlen("listallinfo")+2+strlen(sDir)+3;
+void mpd_sendListallInfoCommand(mpd_Connection *connection, const char *dir)
+{
+       char *sDir = mpd_sanitizeArg(dir);
+       int len = strlen("listallinfo") + 2 + strlen(sDir) + 3;
        char *string = malloc(len);
+
        snprintf(string, len, "listallinfo \"%s\"\n", sDir);
-       mpd_sendInfoCommand(connection,string);
+       mpd_sendInfoCommand(connection, string);
        free(string);
        free(sDir);
 }
 
-void mpd_sendLsInfoCommand(mpd_Connection * connection, const char * dir) {
-       char * sDir = mpd_sanitizeArg(dir);
-       int len = strlen("lsinfo")+2+strlen(sDir)+3;
+void mpd_sendLsInfoCommand(mpd_Connection *connection, const char *dir)
+{
+       char *sDir = mpd_sanitizeArg(dir);
+       int len = strlen("lsinfo") + 2 + strlen(sDir) + 3;
        char *string = malloc(len);
+
        snprintf(string, len, "lsinfo \"%s\"\n", sDir);
-       mpd_sendInfoCommand(connection,string);
+       mpd_sendInfoCommand(connection, string);
        free(string);
        free(sDir);
 }
 
-void mpd_sendCurrentSongCommand(mpd_Connection * connection) {
-       mpd_executeCommand(connection,"currentsong\n");
+void mpd_sendCurrentSongCommand(mpd_Connection *connection)
+{
+       mpd_executeCommand(connection, "currentsong\n");
 }
 
-void mpd_sendSearchCommand(mpd_Connection * connection, int table,
-               const char * str)
+void mpd_sendSearchCommand(mpd_Connection *connection, int table,
+               const char *str)
 {
        mpd_startSearch(connection, 0);
        mpd_addConstraintSearch(connection, table, str);
        mpd_commitSearch(connection);
 }
 
-void mpd_sendFindCommand(mpd_Connection * connection, int table,
-               const char * str)
+void mpd_sendFindCommand(mpd_Connection *connection, int table,
+               const char *str)
 {
        mpd_startSearch(connection, 1);
        mpd_addConstraintSearch(connection, table, str);
        mpd_commitSearch(connection);
 }
 
-void mpd_sendListCommand(mpd_Connection * connection, int table,
-               const char * arg1)
+void mpd_sendListCommand(mpd_Connection *connection, int table,
+               const char *arg1)
 {
        char st[10];
        int len;
        char *string;
-       if(table == MPD_TABLE_ARTIST) strcpy(st,"artist");
-       else if(table == MPD_TABLE_ALBUM) strcpy(st,"album");
-       else {
+
+       if (table == MPD_TABLE_ARTIST) {
+               strcpy(st, "artist");
+       } else if (table == MPD_TABLE_ALBUM) {
+               strcpy(st, "album");
+       } else {
                connection->error = 1;
-               strcpy(connection->errorStr,"unknown table for list");
+               strcpy(connection->errorStr, "unknown table for list");
                return;
        }
-       if(arg1) {
-               char * sanitArg1 = mpd_sanitizeArg(arg1);
-               len = strlen("list")+1+strlen(sanitArg1)+2+strlen(st)+3;
+       if (arg1) {
+               char *sanitArg1 = mpd_sanitizeArg(arg1);
+
+               len = strlen("list") + 1 + strlen(sanitArg1) + 2 + strlen(st) + 3;
                string = malloc(len);
                snprintf(string, len, "list %s \"%s\"\n", st, sanitArg1);
                free(sanitArg1);
-       }
-       else {
-               len = strlen("list")+1+strlen(st)+2;
+       } else {
+               len = strlen("list") + 1 + strlen(st) + 2;
                string = malloc(len);
                snprintf(string, len, "list %s\n", st);
        }
-       mpd_sendInfoCommand(connection,string);
+       mpd_sendInfoCommand(connection, string);
        free(string);
 }
 
-void mpd_sendAddCommand(mpd_Connection * connection, const char * file) {
-       char * sFile = mpd_sanitizeArg(file);
-       int len = strlen("add")+2+strlen(sFile)+3;
+void mpd_sendAddCommand(mpd_Connection *connection, const char *file)
+{
+       char *sFile = mpd_sanitizeArg(file);
+       int len = strlen("add") + 2 + strlen(sFile) + 3;
        char *string = malloc(len);
+
        snprintf(string, len, "add \"%s\"\n", sFile);
-       mpd_executeCommand(connection,string);
+       mpd_executeCommand(connection, string);
        free(string);
        free(sFile);
 }
@@ -1361,7 +1462,7 @@ int mpd_sendAddIdCommand(mpd_Connection *connection, const char *file)
 {
        int retval = -1;
        char *sFile = mpd_sanitizeArg(file);
-       int len = strlen("addid")+2+strlen(sFile)+3;
+       int len = strlen("addid") + 2 + strlen(sFile) + 3;
        char *string = malloc(len);
 
        snprintf(string, len, "addid \"%s\"\n", sFile);
@@ -1374,63 +1475,74 @@ int mpd_sendAddIdCommand(mpd_Connection *connection, const char *file)
                retval = atoi(string);
                free(string);
        }
-       
+
        return retval;
 }
 
-void mpd_sendDeleteCommand(mpd_Connection * connection, int songPos) {
-       int len = strlen("delete")+2+INTLEN+3;
+void mpd_sendDeleteCommand(mpd_Connection *connection, int songPos)
+{
+       int len = strlen("delete") + 2 + INTLEN + 3;
        char *string = malloc(len);
+
        snprintf(string, len, "delete \"%i\"\n", songPos);
-       mpd_sendInfoCommand(connection,string);
+       mpd_sendInfoCommand(connection, string);
        free(string);
 }
 
-void mpd_sendDeleteIdCommand(mpd_Connection * connection, int id) {
-       int len = strlen("deleteid")+2+INTLEN+3;
+void mpd_sendDeleteIdCommand(mpd_Connection *connection, int id)
+{
+       int len = strlen("deleteid") + 2 + INTLEN + 3;
        char *string = malloc(len);
+
        snprintf(string, len, "deleteid \"%i\"\n", id);
-       mpd_sendInfoCommand(connection,string);
+       mpd_sendInfoCommand(connection, string);
        free(string);
 }
 
-void mpd_sendSaveCommand(mpd_Connection * connection, const char * name) {
-       char * sName = mpd_sanitizeArg(name);
-       int len = strlen("save")+2+strlen(sName)+3;
+void mpd_sendSaveCommand(mpd_Connection *connection, const char *name)
+{
+       char *sName = mpd_sanitizeArg(name);
+       int len = strlen("save") + 2 + strlen(sName) + 3;
        char *string = malloc(len);
+
        snprintf(string, len, "save \"%s\"\n", sName);
-       mpd_executeCommand(connection,string);
+       mpd_executeCommand(connection, string);
        free(string);
        free(sName);
 }
 
-void mpd_sendLoadCommand(mpd_Connection * connection, const char * name) {
-       char * sName = mpd_sanitizeArg(name);
-       int len = strlen("load")+2+strlen(sName)+3;
+void mpd_sendLoadCommand(mpd_Connection *connection, const char *name)
+{
+       char *sName = mpd_sanitizeArg(name);
+       int len = strlen("load") + 2 + strlen(sName) + 3;
        char *string = malloc(len);
+
        snprintf(string, len, "load \"%s\"\n", sName);
-       mpd_executeCommand(connection,string);
+       mpd_executeCommand(connection, string);
        free(string);
        free(sName);
 }
 
-void mpd_sendRmCommand(mpd_Connection * connection, const char * name) {
-       char * sName = mpd_sanitizeArg(name);
-       int len = strlen("rm")+2+strlen(sName)+3;
+void mpd_sendRmCommand(mpd_Connection *connection, const char *name)
+{
+       char *sName = mpd_sanitizeArg(name);
+       int len = strlen("rm") + 2 + strlen(sName) + 3;
        char *string = malloc(len);
+
        snprintf(string, len, "rm \"%s\"\n", sName);
-       mpd_executeCommand(connection,string);
+       mpd_executeCommand(connection, string);
        free(string);
        free(sName);
 }
 
 void mpd_sendRenameCommand(mpd_Connection *connection, const char *from,
-                           const char *to)
+               const char *to)
 {
        char *sFrom = mpd_sanitizeArg(from);
        char *sTo = mpd_sanitizeArg(to);
-       int len = strlen("rename")+2+strlen(sFrom)+3+strlen(sTo)+3;
+       int len = strlen("rename") + 2 + strlen(sFrom) + 3 + strlen(sTo) + 3;
        char *string = malloc(len);
+
        snprintf(string, len, "rename \"%s\" \"%s\"\n", sFrom, sTo);
        mpd_executeCommand(connection, string);
        free(string);
@@ -1438,110 +1550,135 @@ void mpd_sendRenameCommand(mpd_Connection *connection, const char *from,
        free(sTo);
 }
 
-void mpd_sendShuffleCommand(mpd_Connection * connection) {
-       mpd_executeCommand(connection,"shuffle\n");
+void mpd_sendShuffleCommand(mpd_Connection *connection)
+{
+       mpd_executeCommand(connection, "shuffle\n");
 }
 
-void mpd_sendClearCommand(mpd_Connection * connection) {
-       mpd_executeCommand(connection,"clear\n");
+void mpd_sendClearCommand(mpd_Connection *connection)
+{
+       mpd_executeCommand(connection, "clear\n");
 }
 
-void mpd_sendPlayCommand(mpd_Connection * connection, int songPos) {
-       int len = strlen("play")+2+INTLEN+3;
+void mpd_sendPlayCommand(mpd_Connection *connection, int songPos)
+{
+       int len = strlen("play") + 2 + INTLEN + 3;
        char *string = malloc(len);
+
        snprintf(string, len, "play \"%i\"\n", songPos);
-       mpd_sendInfoCommand(connection,string);
+       mpd_sendInfoCommand(connection, string);
        free(string);
 }
 
-void mpd_sendPlayIdCommand(mpd_Connection * connection, int id) {
-       int len = strlen("playid")+2+INTLEN+3;
+void mpd_sendPlayIdCommand(mpd_Connection *connection, int id)
+{
+       int len = strlen("playid") + 2 + INTLEN + 3;
        char *string = malloc(len);
+
        snprintf(string, len, "playid \"%i\"\n", id);
-       mpd_sendInfoCommand(connection,string);
+       mpd_sendInfoCommand(connection, string);
        free(string);
 }
 
-void mpd_sendStopCommand(mpd_Connection * connection) {
-       mpd_executeCommand(connection,"stop\n");
+void mpd_sendStopCommand(mpd_Connection *connection)
+{
+       mpd_executeCommand(connection, "stop\n");
 }
 
-void mpd_sendPauseCommand(mpd_Connection * connection, int pauseMode) {
-       int len = strlen("pause")+2+INTLEN+3;
+void mpd_sendPauseCommand(mpd_Connection *connection, int pauseMode)
+{
+       int len = strlen("pause") + 2 + INTLEN + 3;
        char *string = malloc(len);
+
        snprintf(string, len, "pause \"%i\"\n", pauseMode);
-       mpd_executeCommand(connection,string);
+       mpd_executeCommand(connection, string);
        free(string);
 }
 
-void mpd_sendNextCommand(mpd_Connection * connection) {
-       mpd_executeCommand(connection,"next\n");
+void mpd_sendNextCommand(mpd_Connection *connection)
+{
+       mpd_executeCommand(connection, "next\n");
 }
 
-void mpd_sendMoveCommand(mpd_Connection * connection, int from, int to) {
-       int len = strlen("move")+2+INTLEN+3+INTLEN+3;
+void mpd_sendMoveCommand(mpd_Connection *connection, int from, int to)
+{
+       int len = strlen("move") + 2 + INTLEN + 3 + INTLEN + 3;
        char *string = malloc(len);
+
        snprintf(string, len, "move \"%i\" \"%i\"\n", from, to);
-       mpd_sendInfoCommand(connection,string);
+       mpd_sendInfoCommand(connection, string);
        free(string);
 }
 
-void mpd_sendMoveIdCommand(mpd_Connection * connection, int id, int to) {
-       int len = strlen("moveid")+2+INTLEN+3+INTLEN+3;
+void mpd_sendMoveIdCommand(mpd_Connection *connection, int id, int to)
+{
+       int len = strlen("moveid") + 2 + INTLEN + 3 + INTLEN + 3;
        char *string = malloc(len);
+
        snprintf(string, len, "moveid \"%i\" \"%i\"\n", id, to);
-       mpd_sendInfoCommand(connection,string);
+       mpd_sendInfoCommand(connection, string);
        free(string);
 }
 
-void mpd_sendSwapCommand(mpd_Connection * connection, int song1, int song2) {
-       int len = strlen("swap")+2+INTLEN+3+INTLEN+3;
+void mpd_sendSwapCommand(mpd_Connection *connection, int song1, int song2)
+{
+       int len = strlen("swap") + 2 + INTLEN + 3 + INTLEN + 3;
        char *string = malloc(len);
+
        snprintf(string, len, "swap \"%i\" \"%i\"\n", song1, song2);
-       mpd_sendInfoCommand(connection,string);
+       mpd_sendInfoCommand(connection, string);
        free(string);
 }
 
-void mpd_sendSwapIdCommand(mpd_Connection * connection, int id1, int id2) {
-       int len = strlen("swapid")+2+INTLEN+3+INTLEN+3;
+void mpd_sendSwapIdCommand(mpd_Connection *connection, int id1, int id2)
+{
+       int len = strlen("swapid") + 2 + INTLEN + 3 + INTLEN + 3;
        char *string = malloc(len);
+
        snprintf(string, len, "swapid \"%i\" \"%i\"\n", id1, id2);
-       mpd_sendInfoCommand(connection,string);
+       mpd_sendInfoCommand(connection, string);
        free(string);
 }
 
-void mpd_sendSeekCommand(mpd_Connection * connection, int song, int time) {
-       int len = strlen("seek")+2+INTLEN+3+INTLEN+3;
+void mpd_sendSeekCommand(mpd_Connection *connection, int song, int time)
+{
+       int len = strlen("seek") + 2 + INTLEN + 3 + INTLEN + 3;
        char *string = malloc(len);
+
        snprintf(string, len, "seek \"%i\" \"%i\"\n", song, time);
-       mpd_sendInfoCommand(connection,string);
+       mpd_sendInfoCommand(connection, string);
        free(string);
 }
 
-void mpd_sendSeekIdCommand(mpd_Connection * connection, int id, int time) {
-       int len = strlen("seekid")+2+INTLEN+3+INTLEN+3;
+void mpd_sendSeekIdCommand(mpd_Connection *connection, int id, int time)
+{
+       int len = strlen("seekid") + 2 + INTLEN + 3 + INTLEN + 3;
        char *string = malloc(len);
+
        snprintf(string, len, "seekid \"%i\" \"%i\"\n", id, time);
-       mpd_sendInfoCommand(connection,string);
+       mpd_sendInfoCommand(connection, string);
        free(string);
 }
 
-void mpd_sendUpdateCommand(mpd_Connection * connection, char * path) {
-       char * sPath = mpd_sanitizeArg(path);
-       int len = strlen("update")+2+strlen(sPath)+3;
+void mpd_sendUpdateCommand(mpd_Connection *connection, char *path)
+{
+       char *sPath = mpd_sanitizeArg(path);
+       int len = strlen("update") + 2 + strlen(sPath) + 3;
        char *string = malloc(len);
+
        snprintf(string, len, "update \"%s\"\n", sPath);
-       mpd_sendInfoCommand(connection,string);
+       mpd_sendInfoCommand(connection, string);
        free(string);
        free(sPath);
 }
 
-int mpd_getUpdateId(mpd_Connection * connection) {
-       char * jobid;
+int mpd_getUpdateId(mpd_Connection *connection)
+{
+       char *jobid;
        int ret = 0;
 
-       jobid = mpd_getNextReturnElementNamed(connection,"updating_db");
-       if(jobid) {
+       jobid = mpd_getNextReturnElementNamed(connection, "updating_db");
+       if (jobid) {
                ret = atoi(jobid);
                free(jobid);
        }
@@ -1549,201 +1686,218 @@ int mpd_getUpdateId(mpd_Connection * connection) {
        return ret;
 }
 
-void mpd_sendPrevCommand(mpd_Connection * connection) {
-       mpd_executeCommand(connection,"previous\n");
+void mpd_sendPrevCommand(mpd_Connection *connection)
+{
+       mpd_executeCommand(connection, "previous\n");
 }
 
-void mpd_sendRepeatCommand(mpd_Connection * connection, int repeatMode) {
-       int len = strlen("repeat")+2+INTLEN+3;
+void mpd_sendRepeatCommand(mpd_Connection *connection, int repeatMode)
+{
+       int len = strlen("repeat") + 2 + INTLEN + 3;
        char *string = malloc(len);
+
        snprintf(string, len, "repeat \"%i\"\n", repeatMode);
-       mpd_executeCommand(connection,string);
+       mpd_executeCommand(connection, string);
        free(string);
 }
 
-void mpd_sendRandomCommand(mpd_Connection * connection, int randomMode) {
-       int len = strlen("random")+2+INTLEN+3;
+void mpd_sendRandomCommand(mpd_Connection *connection, int randomMode)
+{
+       int len = strlen("random") + 2 + INTLEN + 3;
        char *string = malloc(len);
+
        snprintf(string, len, "random \"%i\"\n", randomMode);
-       mpd_executeCommand(connection,string);
+       mpd_executeCommand(connection, string);
        free(string);
 }
 
-void mpd_sendSetvolCommand(mpd_Connection * connection, int volumeChange) {
-       int len = strlen("setvol")+2+INTLEN+3;
+void mpd_sendSetvolCommand(mpd_Connection *connection, int volumeChange)
+{
+       int len = strlen("setvol") + 2 + INTLEN + 3;
        char *string = malloc(len);
+
        snprintf(string, len, "setvol \"%i\"\n", volumeChange);
-       mpd_executeCommand(connection,string);
+       mpd_executeCommand(connection, string);
        free(string);
 }
 
-void mpd_sendVolumeCommand(mpd_Connection * connection, int volumeChange) {
-       int len = strlen("volume")+2+INTLEN+3;
+void mpd_sendVolumeCommand(mpd_Connection *connection, int volumeChange)
+{
+       int len = strlen("volume") + 2 + INTLEN + 3;
        char *string = malloc(len);
+
        snprintf(string, len, "volume \"%i\"\n", volumeChange);
-       mpd_executeCommand(connection,string);
+       mpd_executeCommand(connection, string);
        free(string);
 }
 
-void mpd_sendCrossfadeCommand(mpd_Connection * connection, int seconds) {
-       int len = strlen("crossfade")+2+INTLEN+3;
+void mpd_sendCrossfadeCommand(mpd_Connection *connection, int seconds)
+{
+       int len = strlen("crossfade") + 2 + INTLEN + 3;
        char *string = malloc(len);
+
        snprintf(string, len, "crossfade \"%i\"\n", seconds);
-       mpd_executeCommand(connection,string);
+       mpd_executeCommand(connection, string);
        free(string);
 }
 
-void mpd_sendPasswordCommand(mpd_Connection * connection, const char * pass) {
-       char * sPass = mpd_sanitizeArg(pass);
-       int len = strlen("password")+2+strlen(sPass)+3;
+void mpd_sendPasswordCommand(mpd_Connection *connection, const char *pass)
+{
+       char *sPass = mpd_sanitizeArg(pass);
+       int len = strlen("password") + 2 + strlen(sPass) + 3;
        char *string = malloc(len);
+
        snprintf(string, len, "password \"%s\"\n", sPass);
-       mpd_executeCommand(connection,string);
+       mpd_executeCommand(connection, string);
        free(string);
        free(sPass);
 }
 
-void mpd_sendCommandListBegin(mpd_Connection * connection) {
-       if(connection->commandList) {
-               strcpy(connection->errorStr,"already in command list mode");
+void mpd_sendCommandListBegin(mpd_Connection *connection)
+{
+       if (connection->commandList) {
+               strcpy(connection->errorStr, "already in command list mode");
                connection->error = 1;
                return;
        }
        connection->commandList = COMMAND_LIST;
-       mpd_executeCommand(connection,"command_list_begin\n");
+       mpd_executeCommand(connection, "command_list_begin\n");
 }
 
-void mpd_sendCommandListOkBegin(mpd_Connection * connection) {
-       if(connection->commandList) {
-               strcpy(connection->errorStr,"already in command list mode");
+void mpd_sendCommandListOkBegin(mpd_Connection *connection)
+{
+       if (connection->commandList) {
+               strcpy(connection->errorStr, "already in command list mode");
                connection->error = 1;
                return;
        }
        connection->commandList = COMMAND_LIST_OK;
-       mpd_executeCommand(connection,"command_list_ok_begin\n");
+       mpd_executeCommand(connection, "command_list_ok_begin\n");
        connection->listOks = 0;
 }
 
-void mpd_sendCommandListEnd(mpd_Connection * connection) {
-       if(!connection->commandList) {
-               strcpy(connection->errorStr,"not in command list mode");
+void mpd_sendCommandListEnd(mpd_Connection *connection)
+{
+       if (!connection->commandList) {
+               strcpy(connection->errorStr, "not in command list mode");
                connection->error = 1;
                return;
        }
        connection->commandList = 0;
-       mpd_executeCommand(connection,"command_list_end\n");
+       mpd_executeCommand(connection, "command_list_end\n");
 }
 
-void mpd_sendOutputsCommand(mpd_Connection * connection) {
-       mpd_executeCommand(connection,"outputs\n");
+void mpd_sendOutputsCommand(mpd_Connection *connection)
+{
+       mpd_executeCommand(connection, "outputs\n");
 }
 
-mpd_OutputEntity * mpd_getNextOutput(mpd_Connection * connection) {
-       mpd_OutputEntity * output = NULL;
+mpd_OutputEntity *mpd_getNextOutput(mpd_Connection *connection)
+{
+       mpd_OutputEntity *output = NULL;
 
-       if(connection->doneProcessing || (connection->listOks &&
-                               connection->doneListOk))
-       {
+       if (connection->doneProcessing
+                       || (connection->listOks && connection->doneListOk)) {
                return NULL;
        }
 
-       if(connection->error) return NULL;
+       if (connection->error) {
+               return NULL;
+       }
 
        output = malloc(sizeof(mpd_OutputEntity));
        output->id = -10;
        output->name = NULL;
        output->enabled = 0;
 
-       if(!connection->returnElement) mpd_getNextReturnElement(connection);
+       if (!connection->returnElement) {
+               mpd_getNextReturnElement(connection);
+       }
+
+       while (connection->returnElement) {
+               mpd_ReturnElement *re = connection->returnElement;
 
-       while(connection->returnElement) {
-               mpd_ReturnElement * re = connection->returnElement;
-               if(strcmp(re->name,"outputid")==0) {
-                       if(output!=NULL && output->id>=0) return output;
+               if (strcmp(re->name, "outputid") == 0) {
+                       if (output != NULL && output->id >= 0) {
+                               return output;
+                       }
                        output->id = atoi(re->value);
-               }
-               else if(strcmp(re->name,"outputname")==0) {
+               } else if (strcmp(re->name, "outputname") == 0) {
                        output->name = strdup(re->value);
-               }
-               else if(strcmp(re->name,"outputenabled")==0) {
+               } else if (strcmp(re->name, "outputenabled") == 0) {
                        output->enabled = atoi(re->value);
                }
 
                mpd_getNextReturnElement(connection);
-               if(connection->error) {
+               if (connection->error) {
                        free(output);
                        return NULL;
                }
-
        }
 
        return output;
 }
 
-void mpd_sendEnableOutputCommand(mpd_Connection * connection, int outputId) {
-       int len = strlen("enableoutput")+2+INTLEN+3;
+void mpd_sendEnableOutputCommand(mpd_Connection *connection, int outputId)
+{
+       int len = strlen("enableoutput") + 2 + INTLEN + 3;
        char *string = malloc(len);
+
        snprintf(string, len, "enableoutput \"%i\"\n", outputId);
-       mpd_executeCommand(connection,string);
+       mpd_executeCommand(connection, string);
        free(string);
 }
 
-void mpd_sendDisableOutputCommand(mpd_Connection * connection, int outputId) {
-       int len = strlen("disableoutput")+2+INTLEN+3;
+void mpd_sendDisableOutputCommand(mpd_Connection *connection, int outputId)
+{
+       int len = strlen("disableoutput") + 2 + INTLEN + 3;
        char *string = malloc(len);
+
        snprintf(string, len, "disableoutput \"%i\"\n", outputId);
-       mpd_executeCommand(connection,string);
+       mpd_executeCommand(connection, string);
        free(string);
 }
 
-void mpd_freeOutputElement(mpd_OutputEntity * output) {
+void mpd_freeOutputElement(mpd_OutputEntity *output)
+{
        free(output->name);
        free(output);
 }
 
-/**
- * mpd_sendNotCommandsCommand
- * odd naming, but it gets the not allowed commands
- */
-
-void mpd_sendNotCommandsCommand(mpd_Connection * connection)
+/** odd naming, but it gets the not allowed commands */
+void mpd_sendNotCommandsCommand(mpd_Connection *connection)
 {
        mpd_executeCommand(connection, "notcommands\n");
 }
 
-/**
- * mpd_sendCommandsCommand
- * odd naming, but it gets the allowed commands
- */
-void mpd_sendCommandsCommand(mpd_Connection * connection)
+/** odd naming, but it gets the allowed commands */
+void mpd_sendCommandsCommand(mpd_Connection *connection)
 {
        mpd_executeCommand(connection, "commands\n");
 }
 
-/**
- * Get the next returned command
- */
-char * mpd_getNextCommand(mpd_Connection * connection)
+/** Get the next returned command */
+char *mpd_getNextCommand(mpd_Connection *connection)
 {
        return mpd_getNextReturnElementNamed(connection, "command");
 }
 
-void mpd_sendUrlHandlersCommand(mpd_Connection * connection)
+void mpd_sendUrlHandlersCommand(mpd_Connection *connection)
 {
        mpd_executeCommand(connection, "urlhandlers\n");
 }
 
-char * mpd_getNextHandler(mpd_Connection * connection)
+char *mpd_getNextHandler(mpd_Connection *connection)
 {
        return mpd_getNextReturnElementNamed(connection, "handler");
 }
 
-void mpd_sendTagTypesCommand(mpd_Connection * connection)
+void mpd_sendTagTypesCommand(mpd_Connection *connection)
 {
        mpd_executeCommand(connection, "tagtypes\n");
 }
 
-char * mpd_getNextTagType(mpd_Connection * connection)
+char *mpd_getNextTagType(mpd_Connection *connection)
 {
        return mpd_getNextReturnElementNamed(connection, "tagtype");
 }
@@ -1756,8 +1910,11 @@ void mpd_startSearch(mpd_Connection *connection, int exact)
                return;
        }
 
-       if (exact) connection->request = strdup("find");
-       else connection->request = strdup("search");
+       if (exact) {
+               connection->request = strdup("find");
+       } else {
+               connection->request = strdup("search");
+       }
 }
 
 void mpd_startStatsSearch(mpd_Connection *connection)
@@ -1779,8 +1936,11 @@ void mpd_startPlaylistSearch(mpd_Connection *connection, int exact)
                return;
        }
 
-       if (exact) connection->request = strdup("playlistfind");
-       else connection->request = strdup("playlistsearch");
+       if (exact) {
+               connection->request = strdup("playlistfind");
+       } else {
+               connection->request = strdup("playlistsearch");
+       }
 }
 
 void mpd_startFieldSearch(mpd_Connection *connection, int type)
@@ -1802,14 +1962,15 @@ void mpd_startFieldSearch(mpd_Connection *connection, int type)
 
        strtype = mpdTagItemKeys[type];
 
-       len = 5+strlen(strtype)+1;
+       len = 5 + strlen(strtype) + 1;
        connection->request = malloc(len);
 
-       snprintf(connection->request, len, "list %c%s",
-                tolower(strtype[0]), strtype+1);
+       snprintf(connection->request, len, "list %c%s", tolower(strtype[0]),
+               strtype + 1);
 }
 
-void mpd_addConstraintSearch(mpd_Connection *connection, int type, const char *name)
+void mpd_addConstraintSearch(mpd_Connection *connection, int type,
+               const char *name)
 {
        char *strtype;
        char *arg;
@@ -1838,10 +1999,10 @@ void mpd_addConstraintSearch(mpd_Connection *connection, int type, const char *n
        strtype = mpdTagItemKeys[type];
        arg = mpd_sanitizeArg(name);
 
-       len = strlen(string)+1+strlen(strtype)+2+strlen(arg)+2;
+       len = strlen(string) + 1 + strlen(strtype) + 2 + strlen(arg) + 2;
        connection->request = realloc(connection->request, len);
-       snprintf(connection->request, len, "%s %c%s \"%s\"",
-                string, tolower(strtype[0]), strtype+1, arg);
+       snprintf(connection->request, len, "%s %c%s \"%s\"", string,
+               tolower(strtype[0]), strtype + 1, arg);
 
        free(string);
        free(arg);
@@ -1857,10 +2018,10 @@ void mpd_commitSearch(mpd_Connection *connection)
                return;
        }
 
-       len = strlen(connection->request)+2;
+       len = strlen(connection->request) + 2;
        connection->request = realloc(connection->request, len);
-       connection->request[len-2] = '\n';
-       connection->request[len-1] = '\0';
+       connection->request[len - 2] = '\n';
+       connection->request[len - 1] = '\0';
        mpd_sendInfoCommand(connection, connection->request);
 
        free(connection->request);
@@ -1868,17 +2029,16 @@ void mpd_commitSearch(mpd_Connection *connection)
 }
 
 /**
- * @param connection a MpdConnection
- * @param path the path to the playlist.
- *
- * List the content, with full metadata, of a stored playlist.
+ * @param connection   a MpdConnection
+ * @param path                 the path to the playlist.
  *
- */
+ * List the content, with full metadata, of a stored playlist. */
 void mpd_sendListPlaylistInfoCommand(mpd_Connection *connection, char *path)
 {
        char *arg = mpd_sanitizeArg(path);
-       int len = strlen("listplaylistinfo")+2+strlen(arg)+3;
+       int len = strlen("listplaylistinfo") + 2 + strlen(arg) + 3;
        char *query = malloc(len);
+
        snprintf(query, len, "listplaylistinfo \"%s\"\n", arg);
        mpd_sendInfoCommand(connection, query);
        free(arg);
@@ -1886,17 +2046,16 @@ void mpd_sendListPlaylistInfoCommand(mpd_Connection *connection, char *path)
 }
 
 /**
- * @param connection a MpdConnection
- * @param path the path to the playlist.
- *
- * List the content of a stored playlist.
+ * @param connection   a MpdConnection
+ * @param path                 the path to the playlist.
  *
- */
+ * List the content of a stored playlist. */
 void mpd_sendListPlaylistCommand(mpd_Connection *connection, char *path)
 {
        char *arg = mpd_sanitizeArg(path);
-       int len = strlen("listplaylist")+2+strlen(arg)+3;
+       int len = strlen("listplaylist") + 2 + strlen(arg) + 3;
        char *query = malloc(len);
+
        snprintf(query, len, "listplaylist \"%s\"\n", arg);
        mpd_sendInfoCommand(connection, query);
        free(arg);
@@ -1906,21 +2065,24 @@ void mpd_sendListPlaylistCommand(mpd_Connection *connection, char *path)
 void mpd_sendPlaylistClearCommand(mpd_Connection *connection, char *path)
 {
        char *sPath = mpd_sanitizeArg(path);
-       int len = strlen("playlistclear")+2+strlen(sPath)+3;
+       int len = strlen("playlistclear") + 2 + strlen(sPath) + 3;
        char *string = malloc(len);
+
        snprintf(string, len, "playlistclear \"%s\"\n", sPath);
        mpd_executeCommand(connection, string);
        free(sPath);
        free(string);
 }
 
-void mpd_sendPlaylistAddCommand(mpd_Connection *connection,
-                                char *playlist, char *path)
+void mpd_sendPlaylistAddCommand(mpd_Connection *connection, char *playlist,
+               char *path)
 {
        char *sPlaylist = mpd_sanitizeArg(playlist);
        char *sPath = mpd_sanitizeArg(path);
-       int len = strlen("playlistadd")+2+strlen(sPlaylist)+3+strlen(sPath)+3;
+       int len = strlen("playlistadd") + 2 + strlen(sPlaylist) + 3 +
+               strlen(sPath) + 3;
        char *string = malloc(len);
+
        snprintf(string, len, "playlistadd \"%s\" \"%s\"\n", sPlaylist, sPath);
        mpd_executeCommand(connection, string);
        free(sPlaylist);
@@ -1928,26 +2090,29 @@ void mpd_sendPlaylistAddCommand(mpd_Connection *connection,
        free(string);
 }
 
-void mpd_sendPlaylistMoveCommand(mpd_Connection *connection,
-                                 char *playlist, int from, int to)
+void mpd_sendPlaylistMoveCommand(mpd_Connection *connection, char *playlist,
+               int from, int to)
 {
        char *sPlaylist = mpd_sanitizeArg(playlist);
-       int len = strlen("playlistmove")+
-                 2+strlen(sPlaylist)+3+INTLEN+3+INTLEN+3;
+       int len = strlen("playlistmove") + 2 + strlen(sPlaylist) + 3 + INTLEN +
+               3 + INTLEN + 3;
        char *string = malloc(len);
-       snprintf(string, len, "playlistmove \"%s\" \"%i\" \"%i\"\n",
-                sPlaylist, from, to);
+
+       snprintf(string, len, "playlistmove \"%s\" \"%i\" \"%i\"\n", sPlaylist,
+               from, to);
        mpd_executeCommand(connection, string);
        free(sPlaylist);
        free(string);
 }
 
-void mpd_sendPlaylistDeleteCommand(mpd_Connection *connection,
-                                   char *playlist, int pos)
+void mpd_sendPlaylistDeleteCommand(mpd_Connection *connection, char *playlist,
+               int pos)
 {
        char *sPlaylist = mpd_sanitizeArg(playlist);
-       int len = strlen("playlistdelete")+2+strlen(sPlaylist)+3+INTLEN+3;
+       int len = strlen("playlistdelete") + 2 + strlen(sPlaylist) + 3 +
+               INTLEN + 3;
        char *string = malloc(len);
+
        snprintf(string, len, "playlistdelete \"%s\" \"%i\"\n", sPlaylist, pos);
        mpd_executeCommand(connection, string);
        free(sPlaylist);
index 111d52a..bdc0447 100644 (file)
@@ -1,34 +1,33 @@
 /* libmpdclient
-   (c)2003-2006 by Warren Dukes (warren.dukes@gmail.com)
-   This project's homepage is: http://www.musicpd.org
-
-   Redistribution and use in source and binary forms, with or without
-   modification, are permitted provided that the following conditions
-   are met:
-
-   - Redistributions of source code must retain the above copyright
-   notice, this list of conditions and the following disclaimer.
-
-   - Redistributions in binary form must reproduce the above copyright
-   notice, this list of conditions and the following disclaimer in the
-   documentation and/or other materials provided with the distribution.
-
-   - Neither the name of the Music Player Daemon nor the names of its
-   contributors may be used to endorse or promote products derived from
-   this software without specific prior written permission.
-
-   THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-   ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-   LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-   A PARTICULAR PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR
-   CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
-   EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
-   PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
-   PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
-   LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
-   NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
-   SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-*/
+ * (c)2003-2006 by Warren Dukes (warren.dukes@gmail.com)
+ * This project's homepage is: http://www.musicpd.org
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * - Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * - Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * - Neither the name of the Music Player Daemon nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */
 
 #ifndef LIBMPDCLIENT_H
 #define LIBMPDCLIENT_H
 #include <stdarg.h>
 #define MPD_BUFFER_MAX_LENGTH  50000
 #define MPD_ERRORSTR_MAX_LENGTH        1000
-#define MPD_WELCOME_MESSAGE    "OK MPD "
-
-#define MPD_ERROR_TIMEOUT      10 /* timeout trying to talk to mpd */
-#define MPD_ERROR_SYSTEM       11 /* system error */
-#define MPD_ERROR_UNKHOST      12 /* unknown host */
-#define MPD_ERROR_CONNPORT     13 /* problems connecting to port on host */
-#define MPD_ERROR_NOTMPD       14 /* mpd not running on port at host */
-#define MPD_ERROR_NORESPONSE   15 /* no response on attempting to connect */
-#define MPD_ERROR_SENDING      16 /* error sending command */
-#define MPD_ERROR_CONNCLOSED   17 /* connection closed by mpd */
-#define MPD_ERROR_ACK          18 /* ACK returned! */
-#define MPD_ERROR_BUFFEROVERRUN        19 /* Buffer was overrun! */
+#define MPD_WELCOME_MESSAGE            "OK MPD "
+
+#define MPD_ERROR_TIMEOUT              10      /* timeout trying to talk to mpd */
+#define MPD_ERROR_SYSTEM               11      /* system error */
+#define MPD_ERROR_UNKHOST              12      /* unknown host */
+#define MPD_ERROR_CONNPORT             13      /* problems connecting to port on host */
+#define MPD_ERROR_NOTMPD               14      /* mpd not running on port at host */
+#define MPD_ERROR_NORESPONSE   15      /* no response on attempting to connect */
+#define MPD_ERROR_SENDING              16      /* error sending command */
+#define MPD_ERROR_CONNCLOSED   17      /* connection closed by mpd */
+#define MPD_ERROR_ACK                  18      /* ACK returned! */
+#define MPD_ERROR_BUFFEROVERRUN        19      /* Buffer was overrun! */
 
 #define MPD_ACK_ERROR_UNK      -1
 #define MPD_ERROR_AT_UNK       -1
 
-#define MPD_ACK_ERROR_NOT_LIST                 1
+#define MPD_ACK_ERROR_NOT_LIST         1
 #define MPD_ACK_ERROR_ARG                      2
-#define MPD_ACK_ERROR_PASSWORD                 3
-#define MPD_ACK_ERROR_PERMISSION               4
-#define MPD_ACK_ERROR_UNKNOWN_CMD              5
+#define MPD_ACK_ERROR_PASSWORD         3
+#define MPD_ACK_ERROR_PERMISSION       4
+#define MPD_ACK_ERROR_UNKNOWN_CMD      5
 
 #define MPD_ACK_ERROR_NO_EXIST                 50
 #define MPD_ACK_ERROR_PLAYLIST_MAX             51
 #define MPD_ACK_ERROR_SYSTEM                   52
 #define MPD_ACK_ERROR_PLAYLIST_LOAD            53
-#define MPD_ACK_ERROR_UPDATE_ALREADY           54
+#define MPD_ACK_ERROR_UPDATE_ALREADY   54
 #define MPD_ACK_ERROR_PLAYER_SYNC              55
-#define MPD_ACK_ERROR_EXIST                    56
-
-#ifdef __cplusplus
-extern "C" {
-#endif
+#define MPD_ACK_ERROR_EXIST                            56
 
-typedef enum mpd_TagItems
-{
+typedef enum mpd_TagItems {
        MPD_TAG_ITEM_ARTIST,
        MPD_TAG_ITEM_ALBUM,
        MPD_TAG_ITEM_TITLE,
@@ -93,60 +87,56 @@ typedef enum mpd_TagItems
        MPD_TAG_NUM_OF_ITEM_TYPES
 } mpd_TagItems;
 
-extern char * mpdTagItemKeys[MPD_TAG_NUM_OF_ITEM_TYPES];
+extern char *mpdTagItemKeys[MPD_TAG_NUM_OF_ITEM_TYPES];
 
 /* internal stuff don't touch this struct */
 typedef struct _mpd_ReturnElement {
-       char * name;
-       char * value;
+       char *name;
+       char *value;
 } mpd_ReturnElement;
 
 /* mpd_Connection
  * holds info about connection to mpd
- * use error, and errorStr to detect errors
- */
+ * use error, and errorStr to detect errors */
 typedef struct _mpd_Connection {
        /* use this to check the version of mpd */
        int version[3];
        /* IMPORTANT, you want to get the error messages from here */
-       char errorStr[MPD_ERRORSTR_MAX_LENGTH+1];
+       char errorStr[MPD_ERRORSTR_MAX_LENGTH + 1];
        int errorCode;
        int errorAt;
        /* this will be set to MPD_ERROR_* if there is an error, 0 if not */
        int error;
        /* DON'T TOUCH any of the rest of this stuff */
        int sock;
-       char buffer[MPD_BUFFER_MAX_LENGTH+1];
+       char buffer[MPD_BUFFER_MAX_LENGTH + 1];
        int buflen;
        int bufstart;
        int doneProcessing;
        int listOks;
        int doneListOk;
        int commandList;
-       mpd_ReturnElement * returnElement;
+       mpd_ReturnElement *returnElement;
        struct timeval timeout;
        char *request;
 } mpd_Connection;
 
 /* mpd_newConnection
  * use this to open a new connection
- * you should use mpd_closeConnection, when your done with the connection,
+ * you should use mpd_closeConnection when you're done with the connection,
  * even if an error has occurred
- * _timeout_ is the connection timeout period in seconds
- */
-mpd_Connection * mpd_newConnection(const char * host, int port, float timeout);
+ * _timeout_ is the connection timeout period in seconds */
+mpd_Connection *mpd_newConnection(const char *host, int port, float timeout);
 
-void mpd_setConnectionTimeout(mpd_Connection * connection, float timeout);
+void mpd_setConnectionTimeout(mpd_Connection *connection, float timeout);
 
 /* mpd_closeConnection
- * use this to close a connection and free'ing subsequent memory
- */
-void mpd_closeConnection(mpd_Connection * connection);
+ * use this to close a connection and free subsequent memory */
+void mpd_closeConnection(mpd_Connection *connection);
 
 /* mpd_clearError
- * clears error
- */
-void mpd_clearError(mpd_Connection * connection);
+ * clears error */
+void mpd_clearError(mpd_Connection *connection);
 
 /* STATUS STUFF */
 
@@ -156,12 +146,11 @@ void mpd_clearError(mpd_Connection * connection);
 #define MPD_STATUS_STATE_PLAY          2
 #define MPD_STATUS_STATE_PAUSE         3
 
-/* us this with status.volume to determine if mpd has volume support */
+/* use this with status.volume to determine if mpd has volume support */
 #define MPD_STATUS_NO_VOLUME           -1
 
 /* mpd_Status
- * holds info return from status command
- */
+ * holds info return from status command */
 typedef struct mpd_Status {
        /* 0-100, or MPD_STATUS_NO_VOLUME when there is no volume support */
        int volume;
@@ -177,16 +166,13 @@ typedef struct mpd_Status {
        int state;
        /* crossfade setting in seconds */
        int crossfade;
-       /* if a song is currently selected (always the case when state is
-        * PLAY or PAUSE), this is the position of the currently
-        * playing song in the playlist, beginning with 0
-        */
+       /* if a song is currently selected (always the case when state is PLAY
+        * or PAUSE), this is the position of the currently playing song in the
+        * playlist, beginning with 0 */
        int song;
        /* Song ID of the currently selected song */
        int songid;
-       /* time in seconds that have elapsed in the currently playing/paused
-        * song
-        */
+       /* time in seconds that have elapsed in the currently playing/paused song */
        int elapsedTime;
        /* length in seconds of the currently playing/paused song */
        int totalTime;
@@ -201,21 +187,19 @@ typedef struct mpd_Status {
        /* 1 if mpd is updating, 0 otherwise */
        int updatingDb;
        /* error */
-       char * error;
+       char *error;
 } mpd_Status;
 
-void mpd_sendStatusCommand(mpd_Connection * connection);
+void mpd_sendStatusCommand(mpd_Connection *connection);
 
 /* mpd_getStatus
  * returns status info, be sure to free it with mpd_freeStatus()
- * call this after mpd_sendStatusCommand()
- */
-mpd_Status * mpd_getStatus(mpd_Connection * connection);
+ * call this after mpd_sendStatusCommand() */
+mpd_Status *mpd_getStatus(mpd_Connection *connection);
 
 /* mpd_freeStatus
- * free's status info malloc'd and returned by mpd_getStatus
- */
-void mpd_freeStatus(mpd_Status * status);
+ * free's status info malloc'd and returned by mpd_getStatus */
+void mpd_freeStatus(mpd_Status *status);
 
 typedef struct _mpd_Stats {
        int numberOfArtists;
@@ -232,15 +216,15 @@ typedef struct _mpd_SearchStats {
        unsigned long playTime;
 } mpd_SearchStats;
 
-void mpd_sendStatsCommand(mpd_Connection * connection);
+void mpd_sendStatsCommand(mpd_Connection *connection);
 
-mpd_Stats * mpd_getStats(mpd_Connection * connection);
+mpd_Stats *mpd_getStats(mpd_Connection *connection);
 
-void mpd_freeStats(mpd_Stats * stats);
+void mpd_freeStats(mpd_Stats *stats);
 
-mpd_SearchStats * mpd_getSearchStats(mpd_Connection * connection);
+mpd_SearchStats *mpd_getSearchStats(mpd_Connection *connection);
 
-void mpd_freeSearchStats(mpd_SearchStats * stats);
+void mpd_freeSearchStats(mpd_SearchStats *stats);
 
 /* SONG STUFF */
 
@@ -249,22 +233,21 @@ void mpd_freeSearchStats(mpd_SearchStats * stats);
 #define MPD_SONG_NO_ID         -1
 
 /* mpd_Song
- * for storing song info returned by mpd
- */
+ * for storing song info returned by mpd */
 typedef struct _mpd_Song {
        /* filename of song */
-       char * file;
+       char *file;
        /* artist, maybe NULL if there is no tag */
-       char * artist;
+       char *artist;
        /* title, maybe NULL if there is no tag */
-       char * title;
+       char *title;
        /* album, maybe NULL if there is no tag */
-       char * album;
+       char *album;
        /* track, maybe NULL if there is no tag */
-       char * track;
-       /* name, maybe NULL if there is no tag; it's the name of the current
-        * song, f.e. the icyName of the stream */
-       char * name;
+       char *track;
+       /* name, maybe NULL if there is no tag; it's the name of the current song,
+        * f.e. the icyName of the stream */
+       char *name;
        /* date */
        char *date;
 
@@ -280,10 +263,10 @@ typedef struct _mpd_Song {
        /* Comment */
        char *comment;
 
-       /* length of song in seconds, check that it is not MPD_SONG_NO_TIME  */
+       /* length of song in seconds, check that it is not MPD_SONG_NO_TIME */
        int time;
-       /* if plchanges/playlistinfo/playlistid used, is the position of the
-        * song in the playlist */
+       /* if plchanges/playlistinfo/playlistid used, is the position of the song
+        * in the playlist */
        int pos;
        /* song id for a song in the playlist */
        int id;
@@ -292,343 +275,322 @@ typedef struct _mpd_Song {
 /* mpd_newSong
  * use to allocate memory for a new mpd_Song
  * file, artist, etc all initialized to NULL
- * if your going to assign values to file, artist, etc
- * be sure to malloc or strdup the memory
+ * if you're going to assign values to file, artist, etc., be sure to
+ * malloc or strdup the memory
  * use mpd_freeSong to free the memory for the mpd_Song, it will also
- * free memory for file, artist, etc, so don't do it yourself
- */
-mpd_Song * mpd_newSong(void);
+ * free memory for file, artist, etc, so don't do it yourself */
+mpd_Song *mpd_newSong(void);
 
 /* mpd_freeSong
  * use to free memory allocated by mpd_newSong
- * also it will free memory pointed to by file, artist, etc, so be careful
- */
-void mpd_freeSong(mpd_Song * song);
+ * also it will free memory pointed to by file, artist, etc, so be careful */
+void mpd_freeSong(mpd_Song *song);
 
 /* mpd_songDup
- * works like strDup, but for a mpd_Song
- */
-mpd_Song * mpd_songDup(mpd_Song * song);
+ * works like strDup, but for a mpd_Song */
+mpd_Song *mpd_songDup(mpd_Song *song);
 
 /* DIRECTORY STUFF */
 
 /* mpd_Directory
- * used to store info fro directory (right now that just the path)
- */
+ * used to store info from directory (right now just the path) */
 typedef struct _mpd_Directory {
-       char * path;
+       char *path;
 } mpd_Directory;
 
 /* mpd_newDirectory
  * allocates memory for a new directory
- * use mpd_freeDirectory to free this memory
- */
-mpd_Directory * mpd_newDirectory(void);
+ * use mpd_freeDirectory to free this memory */
+mpd_Directory *mpd_newDirectory(void);
 
 /* mpd_freeDirectory
  * used to free memory allocated with mpd_newDirectory, and it frees
- * path of mpd_Directory, so be careful
- */
-void mpd_freeDirectory(mpd_Directory * directory);
+ * path of mpd_Directory, so be careful */
+void mpd_freeDirectory(mpd_Directory *directory);
 
 /* mpd_directoryDup
- * works like strdup, but for mpd_Directory
- */
-mpd_Directory * mpd_directoryDup(mpd_Directory * directory);
+ * works like strdup, but for mpd_Directory */
+mpd_Directory *mpd_directoryDup(mpd_Directory *directory);
 
 /* PLAYLISTFILE STUFF */
 
 /* mpd_PlaylistFile
- * stores info about playlist file returned by lsinfo
- */
+ * stores info about playlist file returned by lsinfo */
 typedef struct _mpd_PlaylistFile {
-       char * path;
+       char *path;
 } mpd_PlaylistFile;
 
 /* mpd_newPlaylistFile
  * allocates memory for new mpd_PlaylistFile, path is set to NULL
- * free this memory with mpd_freePlaylistFile
- */
-mpd_PlaylistFile * mpd_newPlaylistFile(void);
+ * free this memory with mpd_freePlaylistFile */
+mpd_PlaylistFile *mpd_newPlaylistFile(void);
 
 /* mpd_freePlaylist
- * free memory allocated for freePlaylistFile, will also free
- * path, so be careful
- */
-void mpd_freePlaylistFile(mpd_PlaylistFile * playlist);
+ * free memory allocated for freePlaylistFile
+ * will also free path, so be careful */
+void mpd_freePlaylistFile(mpd_PlaylistFile *playlist);
 
 /* mpd_playlistFileDup
- * works like strdup, but for mpd_PlaylistFile
- */
-mpd_PlaylistFile * mpd_playlistFileDup(mpd_PlaylistFile * playlist);
+ * works like strdup, but for mpd_PlaylistFile */
+mpd_PlaylistFile *mpd_playlistFileDup(mpd_PlaylistFile *playlist);
 
 /* INFO ENTITY STUFF */
 
 /* the type of entity returned from one of the commands that generates info
- * use in conjunction with mpd_InfoEntity.type
- */
+ * use in conjunction with mpd_InfoEntity.type */
 #define MPD_INFO_ENTITY_TYPE_DIRECTORY         0
 #define MPD_INFO_ENTITY_TYPE_SONG              1
 #define MPD_INFO_ENTITY_TYPE_PLAYLISTFILE      2
 
 /* mpd_InfoEntity
- * stores info on stuff returned info commands
- */
+ * stores info on stuff returned info commands */
 typedef struct mpd_InfoEntity {
        /* the type of entity, use with MPD_INFO_ENTITY_TYPE_* to determine
-        * what this entity is (song, directory, etc...)
-        */
+        * what this entity is (song, directory, etc...) */
        int type;
        /* the actual data you want, mpd_Song, mpd_Directory, etc */
        union {
-               mpd_Directory * directory;
-               mpd_Song * song;
-               mpd_PlaylistFile * playlistFile;
+               mpd_Directory *directory;
+               mpd_Song *song;
+               mpd_PlaylistFile *playlistFile;
        } info;
 } mpd_InfoEntity;
 
-mpd_InfoEntity * mpd_newInfoEntity(void);
+mpd_InfoEntity *mpd_newInfoEntity(void);
 
-void mpd_freeInfoEntity(mpd_InfoEntity * entity);
+void mpd_freeInfoEntity(mpd_InfoEntity *entity);
 
 /* INFO COMMANDS AND STUFF */
 
 /* use this function to loop over after calling Info/Listall functions */
-mpd_InfoEntity * mpd_getNextInfoEntity(mpd_Connection * connection);
+mpd_InfoEntity *mpd_getNextInfoEntity(mpd_Connection *connection);
 
-/* fetches the currently seeletect song (the song referenced by status->song
- * and status->songid*/
-void mpd_sendCurrentSongCommand(mpd_Connection * connection);
+/* fetches the currently selected song (the song referenced by status->song
+ * and status->songid */
+void mpd_sendCurrentSongCommand(mpd_Connection *connection);
 
 /* songNum of -1, means to display the whole list */
-void mpd_sendPlaylistInfoCommand(mpd_Connection * connection, int songNum);
+void mpd_sendPlaylistInfoCommand(mpd_Connection *connection, int songNum);
 
 /* songId of -1, means to display the whole list */
-void mpd_sendPlaylistIdCommand(mpd_Connection * connection, int songId);
+void mpd_sendPlaylistIdCommand(mpd_Connection *connection, int songId);
 
 /* use this to get the changes in the playlist since version _playlist_ */
-void mpd_sendPlChangesCommand(mpd_Connection * connection, long long playlist);
+void mpd_sendPlChangesCommand(mpd_Connection *connection, long long playlist);
 
 /**
  * @param connection: A valid and connected mpd_Connection.
  * @param playlist: The playlist version you want the diff with.
+ *
  * A more bandwidth efficient version of the mpd_sendPlChangesCommand.
- * It only returns the pos+id of the changes song.
- */
-void mpd_sendPlChangesPosIdCommand(mpd_Connection * connection, long long playlist);
+ * It only returns the pos+id of the changes song. */
+void mpd_sendPlChangesPosIdCommand(mpd_Connection *connection,
+       long long playlist);
 
-/* recursivel fetches all songs/dir/playlists in "dir* (no metadata is
- * returned) */
-void mpd_sendListallCommand(mpd_Connection * connection, const char * dir);
+/* recursively fetches all songs/dir/playlists in "dir*
+ * (no metadata is returned) */
+void mpd_sendListallCommand(mpd_Connection *connection, const char *dir);
 
 /* same as sendListallCommand, but also metadata is returned */
-void mpd_sendListallInfoCommand(mpd_Connection * connection, const char * dir);
+void mpd_sendListallInfoCommand(mpd_Connection *connection, const char *dir);
 
 /* non-recursive version of ListallInfo */
-void mpd_sendLsInfoCommand(mpd_Connection * connection, const char * dir);
+void mpd_sendLsInfoCommand(mpd_Connection *connection, const char *dir);
 
 #define MPD_TABLE_ARTIST       MPD_TAG_ITEM_ARTIST
 #define MPD_TABLE_ALBUM                MPD_TAG_ITEM_ALBUM
 #define MPD_TABLE_TITLE                MPD_TAG_ITEM_TITLE
 #define MPD_TABLE_FILENAME     MPD_TAG_ITEM_FILENAME
 
-void mpd_sendSearchCommand(mpd_Connection * connection, int table,
-               const char * str);
+void mpd_sendSearchCommand(mpd_Connection *connection, int table,
+       const char *str);
 
-void mpd_sendFindCommand(mpd_Connection * connection, int table,
-               const char * str);
+void mpd_sendFindCommand(mpd_Connection *connection, int table,
+       const char *str);
 
 /* LIST TAG COMMANDS */
 
-/* use this function fetch next artist entry, be sure to free the returned
- * string.  NULL means there are no more.  Best used with sendListArtists
- */
-char * mpd_getNextArtist(mpd_Connection * connection);
+/* use this function fetch next artist entry, be sure to free the
+ * returned string.
+ * NULL means there are no more.
+ * Best used with sendListArtists */
+char *mpd_getNextArtist(mpd_Connection *connection);
 
-char * mpd_getNextAlbum(mpd_Connection * connection);
+char *mpd_getNextAlbum(mpd_Connection *connection);
 
-char * mpd_getNextTag(mpd_Connection *connection, int type);
+char *mpd_getNextTag(mpd_Connection *connection, int type);
 
-/* list artist or albums by artist, arg1 should be set to the artist if
- * listing albums by a artist, otherwise NULL for listing all artists or albums
- */
-void mpd_sendListCommand(mpd_Connection * connection, int table,
-               const char * arg1);
+/* list artist or albums by artist
+ * arg1 should be set to the artist if listing albums by a artist
+ * otherwise NULL for listing all artists or albums */
+void mpd_sendListCommand(mpd_Connection *connection, int table,
+       const char *arg1);
 
 /* SIMPLE COMMANDS */
 
-void mpd_sendAddCommand(mpd_Connection * connection, const char * file);
+void mpd_sendAddCommand(mpd_Connection *connection, const char *file);
 
 int mpd_sendAddIdCommand(mpd_Connection *connection, const char *file);
 
-void mpd_sendDeleteCommand(mpd_Connection * connection, int songNum);
+void mpd_sendDeleteCommand(mpd_Connection *connection, int songNum);
 
-void mpd_sendDeleteIdCommand(mpd_Connection * connection, int songNum);
+void mpd_sendDeleteIdCommand(mpd_Connection *connection, int songNum);
 
-void mpd_sendSaveCommand(mpd_Connection * connection, const char * name);
+void mpd_sendSaveCommand(mpd_Connection *connection, const char *name);
 
-void mpd_sendLoadCommand(mpd_Connection * connection, const char * name);
+void mpd_sendLoadCommand(mpd_Connection *connection, const char *name);
 
-void mpd_sendRmCommand(mpd_Connection * connection, const char * name);
+void mpd_sendRmCommand(mpd_Connection *connection, const char *name);
 
 void mpd_sendRenameCommand(mpd_Connection *connection, const char *from,
-                           const char *to);
+       const char *to);
 
-void mpd_sendShuffleCommand(mpd_Connection * connection);
+void mpd_sendShuffleCommand(mpd_Connection *connection);
 
-void mpd_sendClearCommand(mpd_Connection * connection);
+void mpd_sendClearCommand(mpd_Connection *connection);
 
 /* use this to start playing at the beginning, useful when in random mode */
 #define MPD_PLAY_AT_BEGINNING  -1
 
-void mpd_sendPlayCommand(mpd_Connection * connection, int songNum);
+void mpd_sendPlayCommand(mpd_Connection *connection, int songNum);
 
-void mpd_sendPlayIdCommand(mpd_Connection * connection, int songNum);
+void mpd_sendPlayIdCommand(mpd_Connection *connection, int songNum);
 
-void mpd_sendStopCommand(mpd_Connection * connection);
+void mpd_sendStopCommand(mpd_Connection *connection);
 
-void mpd_sendPauseCommand(mpd_Connection * connection, int pauseMode);
+void mpd_sendPauseCommand(mpd_Connection *connection, int pauseMode);
 
-void mpd_sendNextCommand(mpd_Connection * connection);
+void mpd_sendNextCommand(mpd_Connection *connection);
 
-void mpd_sendPrevCommand(mpd_Connection * connection);
+void mpd_sendPrevCommand(mpd_Connection *connection);
 
-void mpd_sendMoveCommand(mpd_Connection * connection, int from, int to);
+void mpd_sendMoveCommand(mpd_Connection *connection, int from, int to);
 
-void mpd_sendMoveIdCommand(mpd_Connection * connection, int from, int to);
+void mpd_sendMoveIdCommand(mpd_Connection *connection, int from, int to);
 
-void mpd_sendSwapCommand(mpd_Connection * connection, int song1, int song2);
+void mpd_sendSwapCommand(mpd_Connection *connection, int song1, int song2);
 
-void mpd_sendSwapIdCommand(mpd_Connection * connection, int song1, int song2);
+void mpd_sendSwapIdCommand(mpd_Connection *connection, int song1, int song2);
 
-void mpd_sendSeekCommand(mpd_Connection * connection, int song, int time);
+void mpd_sendSeekCommand(mpd_Connection *connection, int song, int time);
 
-void mpd_sendSeekIdCommand(mpd_Connection * connection, int song, int time);
+void mpd_sendSeekIdCommand(mpd_Connection *connection, int song, int time);
 
-void mpd_sendRepeatCommand(mpd_Connection * connection, int repeatMode);
+void mpd_sendRepeatCommand(mpd_Connection *connection, int repeatMode);
 
-void mpd_sendRandomCommand(mpd_Connection * connection, int randomMode);
+void mpd_sendRandomCommand(mpd_Connection *connection, int randomMode);
 
-void mpd_sendSetvolCommand(mpd_Connection * connection, int volumeChange);
+void mpd_sendSetvolCommand(mpd_Connection *connection, int volumeChange);
 
 /* WARNING: don't use volume command, its depreacted */
-void mpd_sendVolumeCommand(mpd_Connection * connection, int volumeChange);
+void mpd_sendVolumeCommand(mpd_Connection *connection, int volumeChange);
 
-void mpd_sendCrossfadeCommand(mpd_Connection * connection, int seconds);
+void mpd_sendCrossfadeCommand(mpd_Connection *connection, int seconds);
 
-void mpd_sendUpdateCommand(mpd_Connection * connection, char * path);
+void mpd_sendUpdateCommand(mpd_Connection *connection, char *path);
 
-/* returns the update job id, call this after a update command*/
-int mpd_getUpdateId(mpd_Connection * connection);
+/* returns the update job id, call this after a update command */
+int mpd_getUpdateId(mpd_Connection *connection);
 
-void mpd_sendPasswordCommand(mpd_Connection * connection, const char * pass);
+void mpd_sendPasswordCommand(mpd_Connection *connection, const char *pass);
 
-/* after executing a command, when your done with it to get its status
- * (you want to check connection->error for an error)
- */
-void mpd_finishCommand(mpd_Connection * connection);
+/* after executing a command, when you're done with it to get its status
+ * (you want to check connection->error for an error) */
+void mpd_finishCommand(mpd_Connection *connection);
 
 /* command list stuff, use this to do things like add files very quickly */
-void mpd_sendCommandListBegin(mpd_Connection * connection);
+void mpd_sendCommandListBegin(mpd_Connection *connection);
 
-void mpd_sendCommandListOkBegin(mpd_Connection * connection);
+void mpd_sendCommandListOkBegin(mpd_Connection *connection);
 
-void mpd_sendCommandListEnd(mpd_Connection * connection);
+void mpd_sendCommandListEnd(mpd_Connection *connection);
 
 /* advance to the next listOk
  * returns 0 if advanced to the next list_OK,
  * returns -1 if it advanced to an OK or ACK */
-int mpd_nextListOkCommand(mpd_Connection * connection);
+int mpd_nextListOkCommand(mpd_Connection *connection);
 
 typedef struct _mpd_OutputEntity {
        int id;
-       char * name;
+       char *name;
        int enabled;
 } mpd_OutputEntity;
 
-void mpd_sendOutputsCommand(mpd_Connection * connection);
+void mpd_sendOutputsCommand(mpd_Connection *connection);
 
-mpd_OutputEntity * mpd_getNextOutput(mpd_Connection * connection);
+mpd_OutputEntity *mpd_getNextOutput(mpd_Connection *connection);
 
-void mpd_sendEnableOutputCommand(mpd_Connection * connection, int outputId);
+void mpd_sendEnableOutputCommand(mpd_Connection *connection, int outputId);
 
-void mpd_sendDisableOutputCommand(mpd_Connection * connection, int outputId);
+void mpd_sendDisableOutputCommand(mpd_Connection *connection, int outputId);
 
-void mpd_freeOutputElement(mpd_OutputEntity * output);
+void mpd_freeOutputElement(mpd_OutputEntity *output);
 
 /**
  * @param connection a #mpd_Connection
  *
- * Queries mpd for the allowed commands
- */
-void mpd_sendCommandsCommand(mpd_Connection * connection);
+ * Queries mpd for the allowed commands */
+void mpd_sendCommandsCommand(mpd_Connection *connection);
 
 /**
  * @param connection a #mpd_Connection
  *
- * Queries mpd for the not allowed commands
- */
-void mpd_sendNotCommandsCommand(mpd_Connection * connection);
+ * Queries mpd for the not allowed commands */
+void mpd_sendNotCommandsCommand(mpd_Connection *connection);
 
 /**
  * @param connection a #mpd_Connection
  *
  * returns the next supported command.
  *
- * @returns a string, needs to be free'ed
- */
+ * @returns a string, needs to be freed */
 char *mpd_getNextCommand(mpd_Connection *connection);
 
-void mpd_sendUrlHandlersCommand(mpd_Connection * connection);
+void mpd_sendUrlHandlersCommand(mpd_Connection *connection);
 
-char *mpd_getNextHandler(mpd_Connection * connection);
+char *mpd_getNextHandler(mpd_Connection *connection);
 
-void mpd_sendTagTypesCommand(mpd_Connection * connection);
+void mpd_sendTagTypesCommand(mpd_Connection *connection);
 
-char *mpd_getNextTagType(mpd_Connection * connection);
+char *mpd_getNextTagType(mpd_Connection *connection);
 
 /**
- * @param connection a MpdConnection
- * @param path the path to the playlist.
- *
- * List the content, with full metadata, of a stored playlist.
+ * @param connection   a MpdConnection
+ * @param path                 the path to the playlist.
  *
- */
+ * List the content, with full metadata, of a stored playlist. */
 void mpd_sendListPlaylistInfoCommand(mpd_Connection *connection, char *path);
 
 /**
- * @param connection a MpdConnection
- * @param path the path to the playlist.
+ * @param connection   a MpdConnection
+ * @param path                 the path to the playlist.
  *
- * List the content of a stored playlist.
- *
- */
+ * List the content of a stored playlist. */
 void mpd_sendListPlaylistCommand(mpd_Connection *connection, char *path);
 
 /**
- * @param connection a #mpd_Connection
- * @param exact if to match exact
+ * @param connection   a #mpd_Connection
+ * @param exact                        if to match exact
  *
- * starts a search, use mpd_addConstraintSearch to add
- * a constraint to the search, and mpd_commitSearch to do the actual search
- */
+ * starts a search
+ * use mpd_addConstraintSearch to add a constraint to the search
+ * use mpd_commitSearch to do the actual search */
 void mpd_startSearch(mpd_Connection *connection, int exact);
 
 /**
  * @param connection a #mpd_Connection
  * @param type
- * @param name
- */
-void mpd_addConstraintSearch(mpd_Connection *connection, int type, const char *name);
+ * @param name */
+void mpd_addConstraintSearch(mpd_Connection *connection, int type,
+       const char *name);
 
 /**
- * @param connection a #mpd_Connection
- */
+ * @param connection a #mpd_Connection */
 void mpd_commitSearch(mpd_Connection *connection);
 
 /**
- * @param connection a #mpd_Connection
- * @param type The type to search for
+ * @param connection   a #mpd_Connection
+ * @param type                 The type to search for
  *
  * starts a search for fields... f.e. get a list of artists would be:
  * @code
@@ -643,10 +605,10 @@ void mpd_commitSearch(mpd_Connection *connection);
  * mpd_commitSearch(connection);
  * @endcode
  *
- * mpd_startSearch will return  a list of songs (and you need mpd_getNextInfoEntity)
- * this one will return a list of only one field (the one specified with type) and you need
- * mpd_getNextTag to get the results
- */
+ * mpd_startSearch will return a list of songs
+ * (and you need mpd_getNextInfoEntity)
+ * this will return a list of only one field (the one specified with type)
+ * you need mpd_getNextTag to get the results */
 void mpd_startFieldSearch(mpd_Connection *connection, int type);
 
 void mpd_startPlaylistSearch(mpd_Connection *connection, int exact);
@@ -655,16 +617,13 @@ void mpd_startStatsSearch(mpd_Connection *connection);
 
 void mpd_sendPlaylistClearCommand(mpd_Connection *connection, char *path);
 
-void mpd_sendPlaylistAddCommand(mpd_Connection *connection,
-                                char *playlist, char *path);
+void mpd_sendPlaylistAddCommand(mpd_Connection *connection, char *playlist,
+       char *path);
 
-void mpd_sendPlaylistMoveCommand(mpd_Connection *connection,
-                                 char *playlist, int from, int to);
+void mpd_sendPlaylistMoveCommand(mpd_Connection *connection, char *playlist,
+       int from, int to);
 
-void mpd_sendPlaylistDeleteCommand(mpd_Connection *connection,
-                                   char *playlist, int pos);
-#ifdef __cplusplus
-}
-#endif
+void mpd_sendPlaylistDeleteCommand(mpd_Connection *connection, char *playlist,
+       int pos);
 
 #endif
index dc01f83..63095f8 100644 (file)
@@ -1,10 +1,9 @@
 /* $Id$ */
 
-/*
- * libtcp-portmon.c:  tcp port monitoring library.               
+/* libtcp-portmon.c:  tcp port monitoring library.
  *
  * Copyright (C) 2005-2007 Philip Kovacs pkovacs@users.sourceforge.net
- * 
+ *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
  * License as published by the Free Software Foundation; either
@@ -18,9 +17,7 @@
  * You should have received a copy of the GNU Lesser General Public
  * License along with this library; if not, write to the Free Software
  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301
- * USA.
- *
- */
+ * USA. */
 
 #include <glib/gprintf.h>
 #include "libtcp-portmon.h"
  * functions.  Use the "Client interface" functions defined at bottom.
  * ------------------------------------------------------------------- */
 
-/* ----------------------------------
+/* -----------------------------------
  * Copy a tcp_connection_t
  *
  * Returns 0 on success, -1 otherwise.
- * ----------------------------------*/
-int copy_tcp_connection( 
-       tcp_connection_t *                      p_dest_connection,
-       const tcp_connection_t *                p_source_connection
-       )
+ * ----------------------------------- */
+int copy_tcp_connection(tcp_connection_t *p_dest_connection,
+               const tcp_connection_t *p_source_connection)
 {
-   if ( !p_dest_connection || !p_source_connection )
-       return (-1);
+       if (!p_dest_connection || !p_source_connection) {
+               return -1;
+       }
 
-   g_strlcpy (p_dest_connection->key, p_source_connection->key, sizeof(p_dest_connection->key));
-   p_dest_connection->local_addr = p_source_connection->local_addr;
-   p_dest_connection->local_port = p_source_connection->local_port;
-   p_dest_connection->remote_addr = p_source_connection->remote_addr;
-   p_dest_connection->remote_port = p_source_connection->remote_port;
-   p_dest_connection->age = p_source_connection->age;
+       g_strlcpy(p_dest_connection->key, p_source_connection->key,
+               sizeof(p_dest_connection->key));
+       p_dest_connection->local_addr = p_source_connection->local_addr;
+       p_dest_connection->local_port = p_source_connection->local_port;
+       p_dest_connection->remote_addr = p_source_connection->remote_addr;
+       p_dest_connection->remote_port = p_source_connection->remote_port;
+       p_dest_connection->age = p_source_connection->age;
 
-   return 0;
+       return 0;
 }
 
-/* ---------------------------------------------------------------------------
- * Port monitor utility functions implementing tcp_port_monitor_function_ptr_t
- * ---------------------------------------------------------------------------*/
-void destroy_tcp_port_monitor(
-        tcp_port_monitor_t *                    p_monitor,
-       void *                                  p_void 
-        )
+/* -------------------------------------------
+ * Port monitor utility functions implementing
+ * tcp_port_monitor_function_ptr_t
+ * ------------------------------------------- */
+void destroy_tcp_port_monitor(tcp_port_monitor_t *p_monitor, void *p_void)
 {
-   tcp_connection_node_t *p_node, *p_temp;
+       tcp_connection_node_t *p_node, *p_temp;
+
+       if (!p_monitor || p_void) {     /* p_void should be NULL in this context */
+               return;
+       }
 
-   if ( !p_monitor || p_void )         /* p_void should be NULL in this context */
-      return;
+       /* destroy the monitor's peek array */
+       free(p_monitor->p_peek);
 
-   /* destroy the monitor's peek array */
-   free( p_monitor->p_peek );
+       /* destroy the monitor's connection list */
+       for (p_node = p_monitor->connection_list.p_head; p_node != NULL; ) {
+               /* p_temp is for the next iteration */
+               p_temp = p_node->p_next;
 
-   /* destroy the monitor's connection list */
-   for ( p_node=p_monitor->connection_list.p_head; p_node!=NULL; )
-   {
-          /* p_temp is for the next iteration */
-          p_temp = p_node->p_next;
-          
-          free( p_node );
+               free(p_node);
 
-          p_node = p_temp;
-   }
+               p_node = p_temp;
+       }
 
-   /* destroy the monitor's hash */
-   g_hash_table_destroy (p_monitor->hash);
-   p_monitor->hash=NULL;
+       /* destroy the monitor's hash */
+       g_hash_table_destroy(p_monitor->hash);
+       p_monitor->hash = NULL;
 
-   /* destroy the monitor */
-   free( p_monitor );
-   p_monitor=NULL;
+       /* destroy the monitor */
+       free(p_monitor);
+       p_monitor = NULL;
 }
 
-void age_tcp_port_monitor(
-        tcp_port_monitor_t *                    p_monitor,
-       void *                                  p_void
-        )
+void age_tcp_port_monitor(tcp_port_monitor_t *p_monitor, void *p_void)
 {
-   /* Run through the monitor's connections and decrement the age variable. 
-    * If the age goes negative, we remove the connection from the monitor. 
-    * Function takes O(n) time on the number of connections. */
-
-   tcp_connection_node_t *p_node, *p_temp;
-   tcp_connection_t *p_conn;
-
-   if ( !p_monitor || p_void )  /* p_void should be NULL in this context */
-          return;
-
-   if ( !p_monitor->p_peek )
-          return;
-
-   for ( p_node = p_monitor->connection_list.p_head; p_node; )
-   {
-          if ( --p_node->connection.age >= 0 ) {
-                  p_node = p_node->p_next;
-                  continue;
-          }
-       
-          /* connection on p_node is old.  remove connection from the hash. */
-          p_conn = &p_node->connection;
-#ifdef HASH_DEBUG
-          fprintf (stderr, "monitor hash removal of connection [%s]", p_conn->key);
-          if ( !g_hash_table_remove (p_monitor->hash, (gconstpointer)p_conn->key) ) {
-                  fprintf (stderr, " - ERROR NOT FOUND\n");
-                  return;
-          }
-          fprintf (stderr, " - OK\n");
-#else
-          if ( !g_hash_table_remove (p_monitor->hash, (gconstpointer)p_conn->key) ) 
-               return;
-#endif
+       /* Run through the monitor's connections and decrement the age variable.
+        * If the age goes negative, we remove the connection from the monitor.
+        * Function takes O(n) time on the number of connections. */
 
-          /* splice p_node out of the connection_list */
-          if ( p_node->p_prev != NULL )
-                  p_node->p_prev->p_next = p_node->p_next;
-          if ( p_node->p_next != NULL )
-                  p_node->p_next->p_prev = p_node->p_prev;
+       tcp_connection_node_t *p_node, *p_temp;
+       tcp_connection_t *p_conn;
 
-          /* correct the list head and tail if necessary */
-          if ( p_monitor->connection_list.p_head == p_node )
-                  p_monitor->connection_list.p_head = p_node->p_next;
-          if ( p_monitor->connection_list.p_tail == p_node )
-                  p_monitor->connection_list.p_tail = p_node->p_prev;
+       if (!p_monitor || p_void) {     /* p_void should be NULL in this context */
+               return;
+       }
 
-          /* p_temp is for the next iteration */
-          p_temp = p_node->p_next;
+       if (!p_monitor->p_peek) {
+               return;
+       }
 
-          /* destroy the node */
-          free( p_node );
+       for (p_node = p_monitor->connection_list.p_head; p_node; ) {
+               if (--p_node->connection.age >= 0) {
+                       p_node = p_node->p_next;
+                       continue;
+               }
 
-          p_node = p_temp;
-   }
+               /* connection on p_node is old.  remove connection from the hash. */
+               p_conn = &p_node->connection;
+#ifdef HASH_DEBUG
+               fprintf(stderr, "monitor hash removal of connection [%s]", p_conn->key);
+               if (!g_hash_table_remove(p_monitor->hash,
+                               (gconstpointer) p_conn->key)) {
+                       fprintf(stderr, " - ERROR NOT FOUND\n");
+                       return;
+               }
+               fprintf(stderr, " - OK\n");
+#else
+               if (!g_hash_table_remove(p_monitor->hash,
+                               (gconstpointer) p_conn->key)) {
+                       return;
+               }
+#endif
+
+               /* splice p_node out of the connection_list */
+               if (p_node->p_prev != NULL) {
+                       p_node->p_prev->p_next = p_node->p_next;
+               }
+               if (p_node->p_next != NULL) {
+                       p_node->p_next->p_prev = p_node->p_prev;
+               }
+
+               /* correct the list head and tail if necessary */
+               if (p_monitor->connection_list.p_head == p_node) {
+                       p_monitor->connection_list.p_head = p_node->p_next;
+               }
+               if (p_monitor->connection_list.p_tail == p_node) {
+                       p_monitor->connection_list.p_tail = p_node->p_prev;
+               }
+
+               /* p_temp is for the next iteration */
+               p_temp = p_node->p_next;
+
+               /* destroy the node */
+               free(p_node);
+
+               p_node = p_temp;
+       }
 }
 
-void rebuild_tcp_port_monitor_peek_table(
-       tcp_port_monitor_t *                    p_monitor,
-       void *                                  p_void
-       )
+void rebuild_tcp_port_monitor_peek_table(tcp_port_monitor_t *p_monitor,
+               void *p_void)
 {
-   /* Run through the monitor's connections and rebuild the peek table
-    * of connection pointers.  This is done so peeking into the monitor
-    * can be done in O(1) time instead of O(n) time for each peek. */
-
-   tcp_connection_node_t *p_node;
-   int i = 0;
+       /* Run through the monitor's connections and rebuild the peek table of
+        * connection pointers.  This is done so peeking into the monitor can be
+        * done in O(1) time instead of O(n) time for each peek. */
 
-   if ( !p_monitor || p_void )  /* p_void should be NULL in this context */
-       return;
+       tcp_connection_node_t *p_node;
+       int i = 0;
 
-   /* zero out the peek array */
-   memset( p_monitor->p_peek, 0, p_monitor->max_port_monitor_connections * sizeof(tcp_connection_t *) );
+       if (!p_monitor || p_void) {     /* p_void should be NULL in this context */
+               return;
+       }
 
-   for ( p_node=p_monitor->connection_list.p_head; p_node!=NULL; p_node=p_node->p_next, i++ )
-   {
-          p_monitor->p_peek[i] = &p_node->connection;
-   }
+       /* zero out the peek array */
+       memset(p_monitor->p_peek, 0, p_monitor->max_port_monitor_connections *
+               sizeof(tcp_connection_t *));
 
+       for (p_node = p_monitor->connection_list.p_head; p_node != NULL;
+                       p_node = p_node->p_next, i++) {
+               p_monitor->p_peek[i] = &p_node->connection;
+       }
 }
 
-void show_connection_to_tcp_port_monitor(
-        tcp_port_monitor_t *                    p_monitor,
-        void *                                 p_void
-        )
+void show_connection_to_tcp_port_monitor(tcp_port_monitor_t *p_monitor,
+               void *p_void)
 {
-   /* The monitor gets to look at each connection to see if it falls within
-    * the monitor's port range of interest.  Connections of interest are first
-    * looked up in the hash to see if they are already there.  If they are, we
-    * reset the age of the connection so it is not deleted.  If the connection 
-    * is not in the hash, we add it, but only if we haven't exceeded the maximum
-    * connection limit for the monitor. The function takes O(1) time. */
-
-   tcp_connection_node_t *p_node;
-   tcp_connection_t *p_connection, *p_conn_hash;
-
-   if ( !p_monitor || !p_void )
-       return;
-
-   /* This p_connection is on caller's stack and not the heap.  If we are interested,
-    * we will create a copy of the connection (on the heap) and add it to our list. */
-   p_connection = (tcp_connection_t *)p_void;
-   
-   /* inspect the local port number of the connection to see if we're interested. */
-   if ( (p_monitor->port_range_begin <= p_connection->local_port) &&
-        (p_connection->local_port <= p_monitor->port_range_end) )
-   {
-       /* the connection is in the range of the monitor. */
-
-       /* first check the hash to see if the connection is already there. */
-       if ( (p_conn_hash = g_hash_table_lookup (p_monitor->hash, (gconstpointer)p_connection->key)) )
-       {
-           /* it's already in the hash.  reset the age of the connection. */
-           p_conn_hash->age = TCP_CONNECTION_STARTING_AGE;
-
-           return;
-       }
-
-       /* Connection is not yet in the hash.  Add it if max_connections not exceeded. */
-       if (g_hash_table_size (p_monitor->hash) >= p_monitor->max_port_monitor_connections)
-               return;
-
-       /* create a new connection node */
-       if ( (p_node = (tcp_connection_node_t *) calloc(1, sizeof(tcp_connection_node_t))) == NULL )
-               return;
-
-       /* copy the connection data */
-       if ( copy_tcp_connection( &p_node->connection, p_connection ) != 0 )
-       {
-               /* error copying the connection data. deallocate p_node to avoid leaks and return. */
-               free( p_node );
+       /* The monitor gets to look at each connection to see if it falls within
+        * the monitor's port range of interest.  Connections of interest are first
+        * looked up in the hash to see if they are already there.  If they are, we
+        * reset the age of the connection so it is not deleted.  If the connection
+        * is not in the hash, we add it, but only if we haven't exceeded the
+        * maximum connection limit for the monitor.
+        * The function takes O(1) time. */
+
+       tcp_connection_node_t *p_node;
+       tcp_connection_t *p_connection, *p_conn_hash;
+
+       if (!p_monitor || !p_void) {
                return;
-       }
-
-       p_node->connection.age = TCP_CONNECTION_STARTING_AGE;
-       p_node->p_next = NULL;
+       }
 
-       /* insert it into the monitor's hash table */
+       /* This p_connection is on caller's stack and not the heap.
+        * If we are interested, we will create a copy of the connection
+        * (on the heap) and add it to our list. */
+       p_connection = (tcp_connection_t *) p_void;
+
+       /* inspect the local port number of the connection to see if we're
+        * interested. */
+       if ((p_monitor->port_range_begin <= p_connection->local_port)
+                       && (p_connection->local_port <= p_monitor->port_range_end)) {
+               /* the connection is in the range of the monitor. */
+
+               /* first check the hash to see if the connection is already there. */
+               if ((p_conn_hash = g_hash_table_lookup(p_monitor->hash,
+                               (gconstpointer) p_connection->key))) {
+                       /* it's already in the hash.  reset the age of the connection. */
+                       p_conn_hash->age = TCP_CONNECTION_STARTING_AGE;
+
+                       return;
+               }
+
+               /* Connection is not yet in the hash.
+                * Add it if max_connections not exceeded. */
+               if (g_hash_table_size(p_monitor->hash)
+                               >= p_monitor->max_port_monitor_connections) {
+                       return;
+               }
+
+               /* create a new connection node */
+               if ((p_node = (tcp_connection_node_t *)
+                               calloc(1, sizeof(tcp_connection_node_t))) == NULL) {
+                       return;
+               }
+
+               /* copy the connection data */
+               if (copy_tcp_connection(&p_node->connection, p_connection) != 0) {
+                       /* error copying the connection data. deallocate p_node to
+                        * avoid leaks and return. */
+                       free(p_node);
+                       return;
+               }
+
+               p_node->connection.age = TCP_CONNECTION_STARTING_AGE;
+               p_node->p_next = NULL;
+
+               /* insert it into the monitor's hash table */
 #ifdef HASH_DEBUG
-       fprintf (stderr, "monitor hash insert of connection [%s]\n", p_node->connection.key);
+               fprintf(stderr, "monitor hash insert of connection [%s]\n",
+                       p_node->connection.key);
 #endif
-       g_hash_table_insert( p_monitor->hash, 
-                            (gpointer)p_node->connection.key, 
-                            (gpointer)&p_node->connection);
-
-       /* append the node to the monitor's connection list */
-       if ( p_monitor->connection_list.p_tail == NULL )  /* assume p_head is NULL too */
-       {
-               p_monitor->connection_list.p_head = p_node;
-               p_monitor->connection_list.p_tail = p_node;
-               p_node->p_prev = NULL;
-       }
-       else
-       {
-               p_monitor->connection_list.p_tail->p_next = p_node;
-               p_node->p_prev = p_monitor->connection_list.p_tail;
-               p_monitor->connection_list.p_tail = p_node;
+               g_hash_table_insert(p_monitor->hash,
+                       (gpointer) p_node->connection.key, (gpointer) &p_node->connection);
+
+               /* append the node to the monitor's connection list */
+               if (p_monitor->connection_list.p_tail == NULL) {
+                       /* assume p_head is NULL too */
+                       p_monitor->connection_list.p_head = p_node;
+                       p_monitor->connection_list.p_tail = p_node;
+                       p_node->p_prev = NULL;
+               } else {
+                       p_monitor->connection_list.p_tail->p_next = p_node;
+                       p_node->p_prev = p_monitor->connection_list.p_tail;
+                       p_monitor->connection_list.p_tail = p_node;
+               }
        }
-   }
 }
 
-/* ---------------------------------------------------------------------------------------
- * Apply a tcp_port_monitor_function_ptr_t function to each port monitor in the collection. 
- * ---------------------------------------------------------------------------------------*/
+/* ------------------------------------------------------------------------
+ * Apply a tcp_port_monitor_function_ptr_t function to each port monitor in
+ * the collection.
+ * ------------------------------------------------------------------------ */
 void for_each_tcp_port_monitor_in_collection(
-       tcp_port_monitor_collection_t *         p_collection,
-       tcp_port_monitor_function_ptr_t         p_function,
-       void *                                  p_function_args
-       )
+               tcp_port_monitor_collection_t *p_collection,
+               tcp_port_monitor_function_ptr_t p_function, void *p_function_args)
 {
-   tcp_port_monitor_node_t * p_current_node, * p_next_node;
-   
-   if ( !p_collection || !p_function )
-       return;
-
-   /* for each monitor in the collection */
-   for ( p_current_node = p_collection->monitor_list.p_head; p_current_node != NULL; )
-   {
-        p_next_node = p_current_node->p_next;  /* do this first! */
-
-       if ( p_current_node->p_monitor )
-       {
-            /* apply the function with the given arguments */
-           (*p_function)( p_current_node->p_monitor, p_function_args );
+       tcp_port_monitor_node_t *p_current_node, *p_next_node;
+
+       if (!p_collection || !p_function) {
+               return;
        }
 
-        p_current_node = p_next_node;
-   }
-  
+       /* for each monitor in the collection */
+       for (p_current_node = p_collection->monitor_list.p_head;
+                       p_current_node != NULL; p_current_node = p_next_node) {
+               p_next_node = p_current_node->p_next;   /* do this first! */
+
+               if (p_current_node->p_monitor) {
+                       /* apply the function with the given arguments */
+                       p_function(p_current_node->p_monitor, p_function_args);
+               }
+       }
 }
 
 /* ----------------------------------------------------------------------
- * CLIENT INTERFACE 
+ * CLIENT INTERFACE
  *
  * Clients should call only those functions below this line.
  * ---------------------------------------------------------------------- */
@@ -299,162 +298,169 @@ void for_each_tcp_port_monitor_in_collection(
  * ---------------------------------- */
 
 /* Clients should first try to "find_tcp_port_monitor" before creating one
-   so that there are no redundant monitors. */
-tcp_port_monitor_t * create_tcp_port_monitor(
-       in_port_t                               port_range_begin, 
-       in_port_t                               port_range_end,
-       tcp_port_monitor_args_t *               p_creation_args
-       )
+ * so that there are no redundant monitors. */
+tcp_port_monitor_t *create_tcp_port_monitor(in_port_t port_range_begin,
+               in_port_t port_range_end, tcp_port_monitor_args_t *p_creation_args)
 {
-   tcp_port_monitor_t * p_monitor;
-
-   /* create the monitor */
-   p_monitor = (tcp_port_monitor_t *) calloc(1, sizeof(tcp_port_monitor_t) );
-   if ( !p_monitor )
-       return NULL;
-
-   p_monitor->max_port_monitor_connections = p_creation_args->max_port_monitor_connections;
-
-   /* build the monitor key for the collection hash */
-   g_sprintf (p_monitor->key, ":%04X :%04X", port_range_begin, port_range_end);
-
-   /* create the monitor's connection hash */
-   if ( (p_monitor->hash = g_hash_table_new (g_str_hash, g_str_equal)) == NULL)
-   {
-       /* we failed to create the hash, so destroy the monitor completely so we don't leak */
-       destroy_tcp_port_monitor(p_monitor,NULL);
-       return NULL;
-   }
-
-   /* create the monitor's peek array */
-   if ( (p_monitor->p_peek = (tcp_connection_t **) calloc (p_monitor->max_port_monitor_connections,
-                                                          sizeof(tcp_connection_t *))) == NULL )
-   {
-       /* we failed to create the peek array, so destroy the monitor completely, again, so we don't leak */
-       destroy_tcp_port_monitor(p_monitor,NULL);
-       return NULL ;
-   }
-
-   p_monitor->port_range_begin = port_range_begin;
-   p_monitor->port_range_end = port_range_end;
-
-   p_monitor->connection_list.p_head = NULL;
-   p_monitor->connection_list.p_tail = NULL;
-
-   return p_monitor;
-}
+       tcp_port_monitor_t *p_monitor;
 
-/* Clients use this function to get connection data from the indicated port monitor.
-   The requested monitor value is copied into a client-supplied char buffer.
-   Returns 0 on success, -1 otherwise. */
-int peek_tcp_port_monitor(
-        const tcp_port_monitor_t *              p_monitor,
-        int                                     item,
-        int                                     connection_index,
-        char *                                  p_buffer,
-        size_t                                  buffer_size
-        )
-{
-   struct hostent *p_hostent;
-   struct servent *p_servent;
-   struct in_addr net;
-
-   if ( !p_monitor || !p_buffer || connection_index < 0 )
-       return(-1);
-
-   memset(p_buffer, 0, buffer_size);
-   memset(&net, 0, sizeof(net));
-
-   /* if the connection index is out of range, we simply return with no error
-    * having first cleared the client-supplied buffer. */
-   if ( (item!=COUNT) && (connection_index > (int)g_hash_table_size (p_monitor->hash) - 1) )
-          return(0);
-                  
-   switch (item) {
-
-   case COUNT:
-   
-       snprintf( p_buffer, buffer_size, "%d" , g_hash_table_size (p_monitor->hash) );
-       break;
-
-   case REMOTEIP:
-
-       net.s_addr = p_monitor->p_peek[ connection_index ]->remote_addr;
-       snprintf( p_buffer, buffer_size, "%s", inet_ntoa( net ) );
-       break;
-
-   case REMOTEHOST:
-
-       p_hostent = gethostbyaddr( (const void *)&p_monitor->p_peek[ connection_index ]->remote_addr, 
-                                  sizeof(in_addr_t), AF_INET);
-       /* if no host name found, just use ip address. */
-       if ( !p_hostent || !p_hostent->h_name )
-       {
-               net.s_addr = p_monitor->p_peek[ connection_index ]->remote_addr;
-               snprintf( p_buffer, buffer_size, "%s", inet_ntoa( net ) );
-               break;
+       /* create the monitor */
+       p_monitor = (tcp_port_monitor_t *) calloc(1, sizeof(tcp_port_monitor_t));
+       if (!p_monitor) {
+               return NULL;
        }
-       snprintf( p_buffer, buffer_size, "%s", p_hostent->h_name );
-       break;
-
-   case REMOTEPORT:
 
-        snprintf( p_buffer, buffer_size, "%d", p_monitor->p_peek[ connection_index ]->remote_port );                          
-       break;
+       p_monitor->max_port_monitor_connections =
+               p_creation_args->max_port_monitor_connections;
 
-   case REMOTESERVICE:
+       /* build the monitor key for the collection hash */
+       g_sprintf(p_monitor->key, ":%04X :%04X", port_range_begin, port_range_end);
 
-        p_servent = getservbyport( htons(p_monitor->p_peek[ connection_index ]->remote_port ), "tcp" );
-        /* if no service name found for the port, just use the port number. */
-        if ( !p_servent || !p_servent->s_name ) {
-            snprintf( p_buffer, buffer_size, "%d", p_monitor->p_peek[ connection_index ]->remote_port );
-        } else {
-            snprintf( p_buffer, buffer_size, "%s", p_servent->s_name );
-        }
-        break;
+       /* create the monitor's connection hash */
+       if ((p_monitor->hash = g_hash_table_new(g_str_hash, g_str_equal)) == NULL) {
+               /* we failed to create the hash, so destroy the monitor completely
+                * so we don't leak */
+               destroy_tcp_port_monitor(p_monitor, NULL);
+               return NULL;
+       }
 
-   case LOCALIP:
+       /* create the monitor's peek array */
+       if ((p_monitor->p_peek = (tcp_connection_t **)
+                       calloc(p_monitor->max_port_monitor_connections,
+                       sizeof(tcp_connection_t *))) == NULL) {
+               /* we failed to create the peek array,
+                * so destroy the monitor completely, again, so we don't leak */
+               destroy_tcp_port_monitor(p_monitor, NULL);
+               return NULL;
+       }
 
-       net.s_addr = p_monitor->p_peek[ connection_index ]->local_addr;
-       snprintf( p_buffer, buffer_size, "%s", inet_ntoa( net ) );
-        break;
+       p_monitor->port_range_begin = port_range_begin;
+       p_monitor->port_range_end = port_range_end;
 
-   case LOCALHOST:
+       p_monitor->connection_list.p_head = NULL;
+       p_monitor->connection_list.p_tail = NULL;
 
-       p_hostent = gethostbyaddr( (const void *)&p_monitor->p_peek[ connection_index ]->local_addr, 
-                                  sizeof(in_addr_t), AF_INET);
-       /* if no host name found, just use ip address. */
-       if ( !p_hostent || !p_hostent->h_name )
-       {
-               net.s_addr = p_monitor->p_peek[ connection_index ]->local_addr;
-               snprintf( p_buffer, buffer_size, "%s", inet_ntoa( net ) );
-               break;
-       }
-       snprintf( p_buffer, buffer_size, "%s", p_hostent->h_name );
-       break;
+       return p_monitor;
+}
 
-   case LOCALPORT: 
+/* Clients use this function to get connection data from the indicated
+ * port monitor.
+ * The requested monitor value is copied into a client-supplied char buffer.
+ * Returns 0 on success, -1 otherwise. */
+int peek_tcp_port_monitor(const tcp_port_monitor_t *p_monitor, int item,
+               int connection_index, char *p_buffer, size_t buffer_size)
+{
+       struct hostent *p_hostent;
+       struct servent *p_servent;
+       struct in_addr net;
 
-        snprintf( p_buffer, buffer_size, "%d", p_monitor->p_peek[ connection_index ]->local_port );
-        break;        
+       if (!p_monitor || !p_buffer || connection_index < 0) {
+               return -1;
+       }
 
-   case LOCALSERVICE:
+       memset(p_buffer, 0, buffer_size);
+       memset(&net, 0, sizeof(net));
 
-       p_servent = getservbyport( htons(p_monitor->p_peek[ connection_index ]->local_port ), "tcp" );
-       /* if no service name found for the port, just use the port number. */
-       if ( !p_servent || !p_servent->s_name )
-       {
-               snprintf( p_buffer, buffer_size, "%d", p_monitor->p_peek[ connection_index ]->local_port );
-               break;
+       /* if the connection index is out of range, we simply return with no error,
+        * having first cleared the client-supplied buffer. */
+       if ((item != COUNT) && (connection_index
+                       > (int) g_hash_table_size(p_monitor->hash) - 1)) {
+               return 0;
        }
-       snprintf( p_buffer, buffer_size, "%s", p_servent->s_name );
-       break;
 
-   default:
-       return(-1);
-   }
+       switch (item) {
+
+               case COUNT:
+
+                       snprintf(p_buffer, buffer_size, "%d",
+                               g_hash_table_size(p_monitor->hash));
+                       break;
+
+               case REMOTEIP:
+
+                       net.s_addr = p_monitor->p_peek[connection_index]->remote_addr;
+                       snprintf(p_buffer, buffer_size, "%s", inet_ntoa(net));
+                       break;
+
+               case REMOTEHOST:
+
+                       p_hostent = gethostbyaddr((const void *)
+                               &p_monitor->p_peek[connection_index]->remote_addr,
+                               sizeof(in_addr_t), AF_INET);
+                       /* if no host name found, just use ip address. */
+                       if (!p_hostent || !p_hostent->h_name) {
+                               net.s_addr = p_monitor->p_peek[connection_index]->remote_addr;
+                               snprintf(p_buffer, buffer_size, "%s", inet_ntoa(net));
+                               break;
+                       }
+                       snprintf(p_buffer, buffer_size, "%s", p_hostent->h_name);
+                       break;
+
+               case REMOTEPORT:
+
+                       snprintf(p_buffer, buffer_size, "%d",
+                               p_monitor->p_peek[connection_index]->remote_port);
+                       break;
+
+               case REMOTESERVICE:
+
+                       p_servent = getservbyport(
+                               htons(p_monitor->p_peek[connection_index]->remote_port), "tcp");
+                       /* if no service name found for the port,
+                        * just use the port number. */
+                       if (!p_servent || !p_servent->s_name) {
+                               snprintf(p_buffer, buffer_size, "%d",
+                                       p_monitor->p_peek[connection_index]->remote_port);
+                       } else {
+                               snprintf(p_buffer, buffer_size, "%s", p_servent->s_name);
+                       }
+                       break;
+
+               case LOCALIP:
+
+                       net.s_addr = p_monitor->p_peek[connection_index]->local_addr;
+                       snprintf(p_buffer, buffer_size, "%s", inet_ntoa(net));
+                       break;
+
+               case LOCALHOST:
+
+                       p_hostent = gethostbyaddr((const void *)
+                               &p_monitor->p_peek[connection_index]->local_addr,
+                               sizeof(in_addr_t), AF_INET);
+                       /* if no host name found, just use ip address. */
+                       if (!p_hostent || !p_hostent->h_name) {
+                               net.s_addr = p_monitor->p_peek[connection_index]->local_addr;
+                               snprintf(p_buffer, buffer_size, "%s", inet_ntoa(net));
+                               break;
+                       }
+                       snprintf(p_buffer, buffer_size, "%s", p_hostent->h_name);
+                       break;
+
+               case LOCALPORT:
+
+                       snprintf(p_buffer, buffer_size, "%d",
+                               p_monitor->p_peek[connection_index]->local_port);
+                       break;
+
+               case LOCALSERVICE:
+
+                       p_servent = getservbyport(
+                               htons(p_monitor->p_peek[connection_index]->local_port), "tcp");
+                       /* if no service name found for the port,
+                        * just use the port number. */
+                       if (!p_servent || !p_servent->s_name) {
+                               snprintf(p_buffer, buffer_size, "%d",
+                                       p_monitor->p_peek[connection_index]->local_port);
+                               break;
+                       }
+                       snprintf(p_buffer, buffer_size, "%s", p_servent->s_name);
+                       break;
+
+               default:
+                       return -1;
+       }
 
-   return(0);
+       return 0;
 }
 
 /* --------------------------------
@@ -462,187 +468,186 @@ int peek_tcp_port_monitor(
  * -------------------------------- */
 
 /* Create a monitor collection.  Do this one first. */
-tcp_port_monitor_collection_t * create_tcp_port_monitor_collection (void)
+tcp_port_monitor_collection_t *create_tcp_port_monitor_collection(void)
 {
-   tcp_port_monitor_collection_t * p_collection;
+       tcp_port_monitor_collection_t *p_collection;
 
-   p_collection = (tcp_port_monitor_collection_t *) calloc( 1, sizeof( tcp_port_monitor_collection_t ) );
-   if ( !p_collection )
-          return NULL;
+       p_collection = (tcp_port_monitor_collection_t *)
+               calloc(1, sizeof(tcp_port_monitor_collection_t));
+       if (!p_collection) {
+               return NULL;
+       }
 
-   /* create the collection's monitor hash */
-   if ( (p_collection->hash = g_hash_table_new (g_str_hash, g_str_equal)) == NULL)
-   {
-         /* we failed to create the hash, so destroy the monitor completely so we don't leak */
-         destroy_tcp_port_monitor_collection(p_collection);
-         return NULL;
-   }
+       /* create the collection's monitor hash */
+       if ((p_collection->hash = g_hash_table_new(g_str_hash, g_str_equal))
+                       == NULL) {
+               /* we failed to create the hash,
+                * so destroy the monitor completely so we don't leak */
+               destroy_tcp_port_monitor_collection(p_collection);
+               return NULL;
+       }
 
-   p_collection->monitor_list.p_head = NULL;
-   p_collection->monitor_list.p_tail = NULL;
+       p_collection->monitor_list.p_head = NULL;
+       p_collection->monitor_list.p_tail = NULL;
 
-   return p_collection;
+       return p_collection;
 }
 
-/* Destroy the monitor collection (and the monitors inside).  Do this one last. */
-void destroy_tcp_port_monitor_collection( 
-       tcp_port_monitor_collection_t *         p_collection
-       )
+/* Destroy the monitor collection (and the monitors inside).
+ * Do this one last. */
+void destroy_tcp_port_monitor_collection(
+               tcp_port_monitor_collection_t *p_collection)
 {
-   tcp_port_monitor_node_t * p_current_node, * p_next_node;
-
-   if ( !p_collection )
-          return;
-
-   /* destroy the monitors */
-   for_each_tcp_port_monitor_in_collection(
-        p_collection,
-       &destroy_tcp_port_monitor,
-       NULL
-       );
-
-   /* next destroy the empty monitor nodes */
-   for ( p_current_node = p_collection->monitor_list.p_head; p_current_node != NULL; )
-   {
-       p_next_node = p_current_node->p_next;  /* do this first! */
-
-        free( p_current_node );
-       p_current_node = p_next_node;
-   }
-   
-   /* destroy the collection's hash */
-   g_hash_table_destroy (p_collection->hash);
-   p_collection->hash = NULL;
-
-   free( p_collection );
-   p_collection=NULL;
+       tcp_port_monitor_node_t *p_current_node, *p_next_node;
+
+       if (!p_collection) {
+               return;
+       }
+
+       /* destroy the monitors */
+       for_each_tcp_port_monitor_in_collection(p_collection,
+               &destroy_tcp_port_monitor, NULL);
+
+       /* next destroy the empty monitor nodes */
+       for (p_current_node = p_collection->monitor_list.p_head;
+                       p_current_node != NULL; p_current_node = p_next_node) {
+               p_next_node = p_current_node->p_next;   /* do this first! */
+
+               free(p_current_node);
+       }
+
+       /* destroy the collection's hash */
+       g_hash_table_destroy(p_collection->hash);
+       p_collection->hash = NULL;
+
+       free(p_collection);
+       p_collection = NULL;
 }
 
 /* Updates the tcp statistics for all monitors within a collection */
 void update_tcp_port_monitor_collection(
-        tcp_port_monitor_collection_t *         p_collection
-        )
+               tcp_port_monitor_collection_t *p_collection)
 {
        FILE *fp;
-        char buf[256];
-        tcp_connection_t conn;
-        unsigned long inode,uid,state;
+       char buf[256];
+       tcp_connection_t conn;
+       unsigned long inode, uid, state;
 
-       if ( !p_collection )
+       if (!p_collection) {
                return;
+       }
 
        /* age the connections in all port monitors. */
-       for_each_tcp_port_monitor_in_collection(
-               p_collection,
-               &age_tcp_port_monitor,
-               NULL
-               );
+       for_each_tcp_port_monitor_in_collection(p_collection,
+               &age_tcp_port_monitor, NULL);
 
        /* read tcp data from /proc/net/tcp */
-       if ( ( fp = fopen("/proc/net/tcp", "r" ) ) == NULL )
+       if ((fp = fopen("/proc/net/tcp", "r")) == NULL) {
                return;
+       }
 
-        /* ignore field name line */
-        fgets(buf, 255, fp);
-
-        /* read all tcp connections */
-        while (fgets (buf, sizeof (buf), fp) != NULL) {
+       /* ignore field name line */
+       fgets(buf, 255, fp);
 
-                if ( sscanf (buf, "%*d: %x:%hx %x:%hx %lx %*x:%*x %*x:%*x %*x %lu %*d %lu",
-                        (unsigned int *)&conn.local_addr, &conn.local_port,
-                        (unsigned int *)&conn.remote_addr, &conn.remote_port,
-                        (unsigned long *)&state, (unsigned long *)&uid, (unsigned long *)&inode) != 7 )
+       /* read all tcp connections */
+       while (fgets(buf, sizeof(buf), fp) != NULL) {
 
-                        fprintf( stderr, "/proc/net/tcp: bad file format\n" );
+               if (sscanf(buf,
+                               "%*d: %x:%hx %x:%hx %lx %*x:%*x %*x:%*x %*x %lu %*d %lu",
+                               (unsigned int *) &conn.local_addr, &conn.local_port,
+                               (unsigned int *) &conn.remote_addr, &conn.remote_port,
+                               (unsigned long *) &state, (unsigned long *) &uid,
+                               (unsigned long *) &inode) != 7) {
+                       fprintf(stderr, "/proc/net/tcp: bad file format\n");
+               }
 
-                if ((inode == 0) || (state != TCP_ESTABLISHED)) continue;
+               if ((inode == 0) || (state != TCP_ESTABLISHED)) {
+                       continue;
+               }
 
                /* build hash key */
-               g_sprintf (conn.key, "%08X:%04X %08X:%04X", 
-                          conn.local_addr, conn.local_port,
-                          conn.remote_addr, conn.remote_port);
+               g_sprintf(conn.key, "%08X:%04X %08X:%04X", conn.local_addr,
+                       conn.local_port, conn.remote_addr, conn.remote_port);
 
                /* show the connection to each port monitor. */
-               for_each_tcp_port_monitor_in_collection(
-                       p_collection,
-                       &show_connection_to_tcp_port_monitor,
-                       (void *) &conn
-                       );
-        }
+               for_each_tcp_port_monitor_in_collection(p_collection,
+                       &show_connection_to_tcp_port_monitor, (void *) &conn);
+       }
 
        fclose(fp);
 
-       /* rebuild the connection peek tables of all monitors so clients can peek in O(1) time */
-       for_each_tcp_port_monitor_in_collection(
-               p_collection,
-               &rebuild_tcp_port_monitor_peek_table,
-               NULL
-               );
+       /* rebuild the connection peek tables of all monitors
+        * so clients can peek in O(1) time */
+       for_each_tcp_port_monitor_in_collection(p_collection,
+               &rebuild_tcp_port_monitor_peek_table, NULL);
 }
 
 /* After clients create a monitor, use this to add it to the collection.
-   Returns 0 on success, -1 otherwise. */
-int insert_tcp_port_monitor_into_collection( 
-       tcp_port_monitor_collection_t *         p_collection,
-       tcp_port_monitor_t *                    p_monitor
-       )
+ * Returns 0 on success, -1 otherwise. */
+int insert_tcp_port_monitor_into_collection(
+               tcp_port_monitor_collection_t *p_collection,
+               tcp_port_monitor_t *p_monitor)
 {
-   tcp_port_monitor_node_t * p_node;
+       tcp_port_monitor_node_t *p_node;
 
-   if ( !p_collection || !p_monitor )
-       return (-1);
+       if (!p_collection || !p_monitor) {
+               return -1;
+       }
 
-   /* create a container node for this monitor */
-   p_node = (tcp_port_monitor_node_t *) calloc( 1, sizeof(tcp_port_monitor_node_t) );
-   if ( !p_node )
-       return (-1);
+       /* create a container node for this monitor */
+       p_node = (tcp_port_monitor_node_t *)
+               calloc(1, sizeof(tcp_port_monitor_node_t));
+       if (!p_node) {
+               return -1;
+       }
 
-   /* populate the node */
-   p_node->p_monitor = p_monitor;
-   p_node->p_next = NULL;
-          
-   /* add a pointer to this monitor to the collection's hash */
+       /* populate the node */
+       p_node->p_monitor = p_monitor;
+       p_node->p_next = NULL;
+
+       /* add a pointer to this monitor to the collection's hash */
 #ifdef HASH_DEBUG
-   fprintf (stderr, "collection hash insert of monitor [%s]\n", p_monitor->key);
+       fprintf(stderr, "collection hash insert of monitor [%s]\n", p_monitor->key);
 #endif
-   g_hash_table_insert (p_collection->hash, (gpointer)p_monitor->key, (gpointer)p_monitor);
-
-   /* tail of the container gets this node */
-   if ( !p_collection->monitor_list.p_tail )
-       p_collection->monitor_list.p_tail = p_node;
-   else
-   {
-       /* p_next of the tail better be NULL */
-        if ( p_collection->monitor_list.p_tail->p_next != NULL )
-          return (-1);
-
-        /* splice node onto tail */
-       p_collection->monitor_list.p_tail->p_next = p_node;
-       p_collection->monitor_list.p_tail = p_node;
-   }
-
-   /* if this was the first element added */
-   if ( !p_collection->monitor_list.p_head )
-       p_collection->monitor_list.p_head = p_collection->monitor_list.p_tail;
-
-   return 0;
+       g_hash_table_insert(p_collection->hash, (gpointer) p_monitor->key,
+               (gpointer) p_monitor);
+
+       /* tail of the container gets this node */
+       if (!p_collection->monitor_list.p_tail) {
+               p_collection->monitor_list.p_tail = p_node;
+       } else {
+               /* p_next of the tail better be NULL */
+               if (p_collection->monitor_list.p_tail->p_next != NULL) {
+                       return -1;
+               }
+
+               /* splice node onto tail */
+               p_collection->monitor_list.p_tail->p_next = p_node;
+               p_collection->monitor_list.p_tail = p_node;
+       }
+
+       /* if this was the first element added */
+       if (!p_collection->monitor_list.p_head) {
+               p_collection->monitor_list.p_head = p_collection->monitor_list.p_tail;
+       }
+
+       return 0;
 }
 
 /* Clients need a way to find monitors */
-tcp_port_monitor_t * find_tcp_port_monitor( 
-       const tcp_port_monitor_collection_t *   p_collection, 
-       in_port_t                               port_range_begin,
-       in_port_t                               port_range_end
-       )
+tcp_port_monitor_t *find_tcp_port_monitor(
+               const tcp_port_monitor_collection_t *p_collection,
+               in_port_t port_range_begin, in_port_t port_range_end)
 {
-   tcp_port_monitor_t *p_monitor;
-   gchar key[12];
+       tcp_port_monitor_t *p_monitor;
+       gchar key[12];
 
-   if ( !p_collection )
-        return NULL;
+       if (!p_collection) {
+               return NULL;
+       }
 
-   /* is monitor in hash? */
-   g_sprintf (key, ":%04X :%04X", port_range_begin, port_range_end);
-   p_monitor = g_hash_table_lookup( p_collection->hash, (gconstpointer)key);
-   return (p_monitor);
+       /* is monitor in hash? */
+       g_sprintf(key, ":%04X :%04X", port_range_begin, port_range_end);
+       p_monitor = g_hash_table_lookup(p_collection->hash, (gconstpointer) key);
+       return p_monitor;
 }
index 4231148..41ac423 100644 (file)
@@ -1,7 +1,6 @@
 /* $Id$ */
 
-/*
- * libtcp-portmon.h:  tcp port monitoring library.               
+/* libtcp-portmon.h:  tcp port monitoring library.
  *
  * Copyright (C) 2005-2007 Philip Kovacs pkovacs@users.sourceforge.net
  *
@@ -18,9 +17,7 @@
  * You should have received a copy of the GNU Lesser General Public
  * License along with this library; if not, write to the Free Software
  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301
- * USA.
- *
- */
+ * USA. */
 
 #ifndef LIBTCP_PORTMON_H
 #define LIBTCP_PORTMON_H
 
 #include <glib.h>
 
-#define TCP_CONNECTION_STARTING_AGE 1  /* connection deleted if unseen again after this # of refreshes */
+/* connection deleted if unseen again after this # of refreshes */
+#define TCP_CONNECTION_STARTING_AGE 1
 #define TCP_CONNECTION_HASH_KEY_SIZE 28
 #define TCP_PORT_MONITOR_HASH_KEY_SIZE 12
 
 /* -------------------------------------------------------------------
  * IMPLEMENTATION INTERFACE
  *
- * Implementation-specific interface begins here.  Clients should not 
- * manipulate these structures directly, nor call the defined helper 
+ * Implementation-specific interface begins here.  Clients should not
+ * manipulate these structures directly, nor call the defined helper
  * functions.  Use the "Client interface" functions defined at bottom.
  * ------------------------------------------------------------------- */
 
 /* The inventory of peekable items within the port monitor. */
-enum tcp_port_monitor_peekables { 
-       COUNT=0, 
-       REMOTEIP, 
-       REMOTEHOST, 
-       REMOTEPORT, 
-       REMOTESERVICE, 
-       LOCALIP, 
-       LOCALHOST, 
-       LOCALPORT, 
-       LOCALSERVICE 
+enum tcp_port_monitor_peekables {
+       COUNT = 0,
+       REMOTEIP,
+       REMOTEHOST,
+       REMOTEPORT,
+       REMOTESERVICE,
+       LOCALIP,
+       LOCALHOST,
+       LOCALPORT,
+       LOCALSERVICE
 };
 
 /* ------------------------------------------------------------------------
- * A single tcp connection 
+ * A single tcp connection
  *
  * The age variable provides the mechanism for removing connections if they
  * are not seen again in subsequent update cycles.
  * ------------------------------------------------------------------------ */
 typedef struct _tcp_connection_t {
-       gchar key[TCP_CONNECTION_HASH_KEY_SIZE];        /* connection's key in monitor hash */
-        in_addr_t local_addr;
-        in_port_t local_port;
-        in_addr_t remote_addr;
-        in_port_t remote_port;
+       /* connection's key in monitor hash */
+       gchar key[TCP_CONNECTION_HASH_KEY_SIZE];
+       in_addr_t local_addr;
+       in_port_t local_port;
+       in_addr_t remote_addr;
+       in_port_t remote_port;
        int age;
 } tcp_connection_t;
 
@@ -84,163 +83,159 @@ typedef struct _tcp_connection_t {
  * Copy a connection
  *
  * Returns 0 on success, -1 otherwise
- * ----------------------------------*/
-int copy_tcp_connection( 
-       tcp_connection_t *                      /* p_dest_connection */,
-       const tcp_connection_t *                /* p_source_connection */
-       );
+ * ---------------------------------- */
+int copy_tcp_connection(tcp_connection_t *p_dest_connection,
+       const tcp_connection_t *p_source_connection);
 
-/* ------------------------------------------------------------------------
+/* -------------------------------------------------------------------
  * A tcp connection node/list
  *
  * Connections within each monitor are stored in a double-linked list.
- * ------------------------------------------------------------------------ */
+ * ------------------------------------------------------------------- */
 typedef struct _tcp_connection_node_t {
        tcp_connection_t connection;
-       struct _tcp_connection_node_t * p_prev;
-       struct _tcp_connection_node_t * p_next;
+       struct _tcp_connection_node_t *p_prev;
+       struct _tcp_connection_node_t *p_next;
 } tcp_connection_node_t;
 
 typedef struct _tcp_connection_list_t {
-       tcp_connection_node_t * p_head;
-       tcp_connection_node_t * p_tail;
+       tcp_connection_node_t *p_head;
+       tcp_connection_node_t *p_tail;
 } tcp_connection_list_t;
 
 /* --------------
- * A port monitor 
+ * A port monitor
  * -------------- */
 typedef struct _tcp_port_monitor_t {
-       gchar key[TCP_PORT_MONITOR_HASH_KEY_SIZE];      /* monitor's key in collection hash */
-        in_port_t port_range_begin;                    /* start of monitor port range */
-        in_port_t port_range_end;                      /* begin = end to monitor a single port */
-       tcp_connection_list_t connection_list;          /* list of connections for this monitor */
-       GHashTable *hash;                               /* hash table of pointers into connection list */
-       tcp_connection_t **p_peek;                      /* array of connection pointers for O(1) peeking */ 
-       unsigned int max_port_monitor_connections;      /* max number of connections */
+       /* monitor's key in collection hash */
+       gchar key[TCP_PORT_MONITOR_HASH_KEY_SIZE];
+       /* start of monitor port range */
+       in_port_t port_range_begin;
+       /* begin = end to monitor a single port */
+       in_port_t port_range_end;
+       /* list of connections for this monitor */
+       tcp_connection_list_t connection_list;
+       /* hash table of pointers into connection list */
+       GHashTable *hash;
+       /* array of connection pointers for O(1) peeking */
+       tcp_connection_t **p_peek;
+       /* max number of connections */
+       unsigned int max_port_monitor_connections;
 } tcp_port_monitor_t;
 
 /* ------------------------
- * A port monitor node/list 
+ * A port monitor node/list
  * ------------------------ */
 typedef struct _tcp_port_monitor_node_t {
-        tcp_port_monitor_t * p_monitor;
-        struct _tcp_port_monitor_node_t *p_next;
+       tcp_port_monitor_t *p_monitor;
+       struct _tcp_port_monitor_node_t *p_next;
 } tcp_port_monitor_node_t;
 
 typedef struct __tcp_port_monitor_list_t {
-       tcp_port_monitor_node_t * p_head;
-       tcp_port_monitor_node_t * p_tail;
+       tcp_port_monitor_node_t *p_head;
+       tcp_port_monitor_node_t *p_tail;
 } tcp_port_monitor_list_t;
 
 /* ---------------------------------------
  * A port monitor utility function typedef
- * ---------------------------------------*/ 
-typedef void (*tcp_port_monitor_function_ptr_t)( tcp_port_monitor_t * /* p_monitor */, void * /* p_void */ );
-
-/* ---------------------------------------------------------------------------
- * Port monitor utility functions implementing tcp_port_monitor_function_ptr_t
- * ---------------------------------------------------------------------------*/
-void destroy_tcp_port_monitor(
-        tcp_port_monitor_t *                    /* p_monitor */,
-       void *                                  /* p_void (use NULL for this function) */
-       );
-
-void age_tcp_port_monitor(
-       tcp_port_monitor_t *                    /* p_monitor */,
-       void *                                  /* p_void (use NULL for this function) */
-       );
-
-void rebuild_tcp_port_monitor_peek_table(
-       tcp_port_monitor_t *                    /* p_monitor */,
-       void *                                  /* p_void (use NULL for this function) */
-       );
-
-void show_connection_to_tcp_port_monitor(
-       tcp_port_monitor_t *                    /* p_monitor */,
-       void *                                  /* p_connection (client should cast) */
-       );
+ * --------------------------------------- */
+typedef void (*tcp_port_monitor_function_ptr_t)(tcp_port_monitor_t *p_monitor,
+       void *p_void);
+
+/* -------------------------------------------
+ * Port monitor utility functions implementing
+ * tcp_port_monitor_function_ptr_t
+ * ------------------------------------------- */
+void destroy_tcp_port_monitor(tcp_port_monitor_t *p_monitor,
+       void *p_void /* (use NULL for this function) */);
+
+void age_tcp_port_monitor(tcp_port_monitor_t *p_monitor,
+       void *p_void /* (use NULL for this function) */);
+
+void rebuild_tcp_port_monitor_peek_table(tcp_port_monitor_t *p_monitor,
+       void *p_void /* (use NULL for this function) */);
+
+void show_connection_to_tcp_port_monitor(tcp_port_monitor_t *p_monitor,
+       void *p_connection /* (client should cast) */);
 
 /* -----------------------------
  * A tcp port monitor collection
- * -----------------------------*/
+ * ----------------------------- */
 typedef struct _tcp_port_monitor_collection_t {
-       tcp_port_monitor_list_t monitor_list;   /* list of monitors for this collection */
-       GHashTable *hash;                       /* hash table of pointers into collection's monitor list */
+       /* list of monitors for this collection */
+       tcp_port_monitor_list_t monitor_list;
+       /* hash table of pointers into collection's monitor list */
+       GHashTable *hash;
 } tcp_port_monitor_collection_t;
 
-/* ---------------------------------------------------------------------------------------
- * Apply a tcp_port_monitor_function_ptr_t function to each port monitor in the collection. 
- * ---------------------------------------------------------------------------------------*/
+/* --------------------------------------------------------
+ * Apply a tcp_port_monitor_function_ptr_t function to each
+ * port monitor in the collection.
+ * -------------------------------------------------------- */
 void for_each_tcp_port_monitor_in_collection(
-       tcp_port_monitor_collection_t *         /* p_collection */,
-       tcp_port_monitor_function_ptr_t         /* p_function */,
-       void *                                  /* p_function_args (for user arguments) */
-       );
+       tcp_port_monitor_collection_t *p_collection,
+       tcp_port_monitor_function_ptr_t p_function,
+       void *p_function_args /* (for user arguments) */);
 
 /* ----------------------------------------------------------------------
- * CLIENT INTERFACE 
+ * CLIENT INTERFACE
  *
  * Clients should call only those functions below this line.
  * ---------------------------------------------------------------------- */
 
 /* struct to hold monitor creation arguments */
 typedef struct _tcp_port_monitor_args_t {
-       int     max_port_monitor_connections;   /* monitor supports tracking at most this many connections */
+       /* monitor supports tracking at most this many connections */
+       int max_port_monitor_connections;
 } tcp_port_monitor_args_t;
 
-
 /* ----------------------------------
  * Client operations on port monitors
  * ---------------------------------- */
 
-/* Clients should first try to "find_tcp_port_monitor" before creating one
-   so that there are no redundant monitors. */
-tcp_port_monitor_t * create_tcp_port_monitor(
-       in_port_t                       /* port_range_begin */, 
-       in_port_t                       /* port_range_end */,
-       tcp_port_monitor_args_t *       /* p_creation_args */
-       );
-
-/* Clients use this function to get connection data from the indicated port monitor.
-   The requested monitor value is copied into a client-supplied char buffer. 
-   Returns 0 on success, -1 otherwise. */
-int peek_tcp_port_monitor(
-       const tcp_port_monitor_t *      /* p_monitor */,
-       int                             /* item, ( item of interest, from tcp_port_monitor_peekables enum ) */,
-       int                             /* connection_index, ( 0 to number of connections in monitor - 1 )*/,
-       char *                          /* p_buffer, buffer to receive requested value */,
-       size_t                          /* buffer_size, size of p_buffer */
-       );
+/* Clients should first try to "find_tcp_port_monitor" before creating one,
+ * so that there are no redundant monitors. */
+tcp_port_monitor_t *create_tcp_port_monitor(in_port_t port_range_begin,
+       in_port_t port_range_end, tcp_port_monitor_args_t *p_creation_args);
+
+/* Clients use this function to get connection data from
+ * the indicated port monitor.
+ * The requested monitor value is copied into a client-supplied char buffer.
+ * Returns 0 on success, -1 otherwise. */
+int peek_tcp_port_monitor(const tcp_port_monitor_t *p_monitor,
+       /* (item of interest, from tcp_port_monitor_peekables enum) */
+       int item,
+       /* (0 to number of connections in monitor - 1) */
+       int connection_index,
+       /* buffer to receive requested value */
+       char *p_buffer,
+       /* size of p_buffer */
+       size_t buffer_size);
 
 /* --------------------------------
  * Client operations on collections
  * -------------------------------- */
 
 /* Create a monitor collection.  Do this one first. */
-tcp_port_monitor_collection_t * create_tcp_port_monitor_collection (void);
+tcp_port_monitor_collection_t *create_tcp_port_monitor_collection(void);
 
-/* Destroy the monitor collection (and everything it contains).  Do this one last. */
-void destroy_tcp_port_monitor_collection( 
-       tcp_port_monitor_collection_t *         /* p_collection */ 
-       );
+/* Destroy the monitor collection (and everything it contains).
+ * Do this one last. */
+void destroy_tcp_port_monitor_collection(
+       tcp_port_monitor_collection_t *p_collection);
 
 /* Updates the tcp statitics for all monitors within a collection */
 void update_tcp_port_monitor_collection(
-       tcp_port_monitor_collection_t *         /* p_collection */
-       );
+       tcp_port_monitor_collection_t *p_collection);
 
-/* After clients create a monitor, use this to add it to the collection. 
-   Returns 0 on success, -1 otherwise. */
-int insert_tcp_port_monitor_into_collection( 
-       tcp_port_monitor_collection_t *         /* p_collection */, 
-       tcp_port_monitor_t *                    /* p_monitor */ 
-       );
+/* After clients create a monitor, use this to add it to the collection.
+ * Returns 0 on success, -1 otherwise. */
+int insert_tcp_port_monitor_into_collection(
+       tcp_port_monitor_collection_t *p_collection, tcp_port_monitor_t *p_monitor);
 
 /* Clients need a way to find monitors */
-tcp_port_monitor_t * find_tcp_port_monitor( 
-       const tcp_port_monitor_collection_t *   /* p_collection */, 
-       in_port_t                               /* port_range_begin */, 
-       in_port_t                               /* port_range_end */ 
-       );
+tcp_port_monitor_t *find_tcp_port_monitor(
+       const tcp_port_monitor_collection_t *p_collection,
+       in_port_t port_range_begin, in_port_t port_range_end);
 
 #endif
index b5f8926..a49e9bf 100644 (file)
@@ -1,5 +1,4 @@
-/*
- * Conky, a system monitor, based on torsmo
+/* Conky, a system monitor, based on torsmo
  *
  * Any original torsmo code is licensed under the BSD license
  *
@@ -9,7 +8,8 @@
  *
  * Copyright (c) 2004, Hannu Saransaari and Lauri Hakkarainen
  * Copyright (c) 2007 Toni Spets
- * Copyright (c) 2005-2007 Brenden Matthews, Philip Kovacs, et. al. (see AUTHORS)
+ * Copyright (c) 2005-2007 Brenden Matthews, Philip Kovacs, et. al.
+ *     (see AUTHORS)
  * All rights reserved.
  *
  * This program is free software: you can redistribute it and/or modify
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  * GNU General Public License for more details.
  * You should have received a copy of the GNU General Public License
- * along with this program.  If not, see <http://www.gnu.org/licenses/>. 
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
  *
- *  $Id$
- */
+ * $Id$ */
 
 #include "conky.h"
 #include <stdio.h>
 
 static int show_nice_processes;
 
-/* this flags tells the linux routines to use the /proc system
- * where possible, even if other api's are available, e.g. sysinfo()
- * or getloadavg(). the reason for this is to allow for /proc-based
- * distributed monitoring. using a flag in this manner creates less
- * confusing code.
- */
+/* This flag tells the linux routines to use the /proc system where possible,
+ * even if other api's are available, e.g. sysinfo() or getloadavg().
+ * the reason for this is to allow for /proc-based distributed monitoring.
+ * using a flag in this manner creates less confusing code. */
 static int prefer_proc = 0;
 
 void prepare_update()
@@ -78,35 +75,35 @@ void prepare_update()
 void update_uptime()
 {
 #ifdef HAVE_SYSINFO
-  if (!prefer_proc)
-  {
-    struct sysinfo s_info;
-    sysinfo(&s_info);
-    info.uptime = (double) s_info.uptime;
-  }
-  else
+       if (!prefer_proc) {
+               struct sysinfo s_info;
+
+               sysinfo(&s_info);
+               info.uptime = (double) s_info.uptime;
+       } else
 #endif
-  {
-         static int rep = 0;
-         FILE *fp;
-
-    if (!(fp = open_file("/proc/uptime", &rep)))
-    {
-      info.uptime=0.0;
-      return;
-    }
-         fscanf(fp, "%lf", &info.uptime);
-         fclose(fp);
-  }
-  info.mask |= (1 << INFO_UPTIME);
+       {
+               static int rep = 0;
+               FILE *fp;
+
+               if (!(fp = open_file("/proc/uptime", &rep))) {
+                       info.uptime = 0.0;
+                       return;
+               }
+               fscanf(fp, "%lf", &info.uptime);
+               fclose(fp);
+       }
+       info.mask |= (1 << INFO_UPTIME);
 }
 
 int check_mount(char *s)
 {
        int ret = 0;
        FILE *mtab = fopen("/etc/mtab", "r");
+
        if (mtab) {
                char buf1[256], buf2[128];
+
                while (fgets(buf1, 256, mtab)) {
                        sscanf(buf1, "%*s %128s", buf2);
                        if (!strcmp(s, buf2)) {
@@ -121,25 +118,28 @@ int check_mount(char *s)
        return ret;
 }
 
-/* these things are also in sysinfo except Buffers:, that's why I'm reading
-* them from proc */
+/* these things are also in sysinfo except Buffers:
+ * (that's why I'm reading them from proc) */
 
 void update_meminfo()
 {
-  FILE *meminfo_fp;
+       FILE *meminfo_fp;
        static int rep = 0;
-       /*  unsigned int a; */
+
+       /* unsigned int a; */
        char buf[256];
 
        info.mem = info.memmax = info.swap = info.swapmax = info.bufmem =
-           info.buffers = info.cached = 0;
+               info.buffers = info.cached = 0;
 
-  if (!(meminfo_fp = open_file("/proc/meminfo", &rep)))
-      return;
+       if (!(meminfo_fp = open_file("/proc/meminfo", &rep))) {
+               return;
+       }
 
        while (!feof(meminfo_fp)) {
-               if (fgets(buf, 255, meminfo_fp) == NULL)
+               if (fgets(buf, 255, meminfo_fp) == NULL) {
                        break;
+               }
 
                if (strncmp(buf, "MemTotal:", 9) == 0) {
                        sscanf(buf, "%*s %Lu", &info.memmax);
@@ -163,13 +163,14 @@ void update_meminfo()
 
        info.mask |= (1 << INFO_MEM) | (1 << INFO_BUFFERS);
 
-  fclose (meminfo_fp);
+       fclose(meminfo_fp);
 }
 
 inline void update_net_stats()
 {
-  FILE *net_dev_fp;
+       FILE *net_dev_fp;
        static int rep = 0;
+
        // FIXME: arbitrary size chosen to keep code simple.
        int i, i2;
        unsigned int curtmp1, curtmp2;
@@ -187,15 +188,15 @@ inline void update_net_stats()
 
        /* get delta */
        delta = current_update_time - last_update_time;
-       if (delta <= 0.0001)
+       if (delta <= 0.0001) {
                return;
+       }
 
        /* open file and ignore first two lines */
-  if (!(net_dev_fp = open_file("/proc/net/dev", &rep)))
-  {
-    clear_net_stats ();
-    return;
-  }
+       if (!(net_dev_fp = open_file("/proc/net/dev", &rep))) {
+               clear_net_stats();
+               return;
+       }
 
        fgets(buf, 255, net_dev_fp);    /* garbage */
        fgets(buf, 255, net_dev_fp);    /* garbage (field names) */
@@ -210,15 +211,18 @@ inline void update_net_stats()
                        break;
                }
                p = buf;
-               while (isspace((int) *p))
+               while (isspace((int) *p)) {
                        p++;
+               }
 
                s = p;
 
-               while (*p && *p != ':')
+               while (*p && *p != ':') {
                        p++;
-               if (*p == '\0')
+               }
+               if (*p == '\0') {
                        continue;
+               }
                *p = '\0';
                p++;
 
@@ -228,23 +232,23 @@ inline void update_net_stats()
                last_recv = ns->recv;
                last_trans = ns->trans;
 
-               sscanf(p,
-                      /* bytes packets errs drop fifo frame compressed multicast|bytes ... */
-                      "%Ld  %*d     %*d  %*d  %*d  %*d   %*d        %*d       %Ld",
-                      &r, &t);
+               /* bytes packets errs drop fifo frame compressed multicast|bytes ... */
+               sscanf(p, "%Ld  %*d     %*d  %*d  %*d  %*d   %*d        %*d       %Ld",
+                       &r, &t);
 
                /* if recv or trans is less than last time, an overflow happened */
-
-               if (r < ns->last_read_recv)
+               if (r < ns->last_read_recv) {
                        last_recv = 0;
-               else
+               } else {
                        ns->recv += (r - ns->last_read_recv);
+               }
                ns->last_read_recv = r;
 
-               if (t < ns->last_read_trans)
+               if (t < ns->last_read_trans) {
                        last_trans = 0;
-               else
+               } else {
                        ns->trans += (t - ns->last_read_trans);
+               }
                ns->last_read_trans = t;
 
                /*** ip addr patch ***/
@@ -258,21 +262,18 @@ inline void update_net_stats()
 
                for (k = 0; k < conf.ifc_len / sizeof(struct ifreq); k++) {
                        struct net_stat *ns;
-                       ns = get_net_stat(((struct ifreq *) conf.
-                                          ifc_buf)[k].ifr_ifrn.ifrn_name);
-                       ns->addr =
-                           ((struct ifreq *) conf.ifc_buf)[k].ifr_ifru.
-                           ifru_addr;
+
+                       ns = get_net_stat(
+                               ((struct ifreq *) conf.ifc_buf)[k].ifr_ifrn.ifrn_name);
+                       ns->addr = ((struct ifreq *) conf.ifc_buf)[k].ifr_ifru.ifru_addr;
                }
 
                close((long) i);
 
                free(conf.ifc_buf);
 
-
                /*** end ip addr patch ***/
 
-
                /* calculate speeds */
                ns->net_rec[0] = (ns->recv - last_recv) / delta;
                ns->net_trans[0] = (ns->trans - last_trans) / delta;
@@ -283,15 +284,18 @@ inline void update_net_stats()
                        curtmp1 += ns->net_rec[i];
                        curtmp2 += ns->net_trans[i];
                }
-               if (curtmp1 == 0) curtmp1 = 1;
-               if (curtmp2 == 0) curtmp2 = 1;
+               if (curtmp1 == 0) {
+                       curtmp1 = 1;
+               }
+               if (curtmp2 == 0) {
+                       curtmp2 = 1;
+               }
                ns->recv_speed = curtmp1 / (double) info.net_avg_samples;
                ns->trans_speed = curtmp2 / (double) info.net_avg_samples;
                if (info.net_avg_samples > 1) {
                        for (i = info.net_avg_samples; i > 1; i--) {
                                ns->net_rec[i - 1] = ns->net_rec[i - 2];
-                               ns->net_trans[i - 1] =
-                                   ns->net_trans[i - 2];
+                               ns->net_trans[i - 1] = ns->net_trans[i - 2];
                        }
                }
 
@@ -301,44 +305,50 @@ inline void update_net_stats()
                memset(winfo, 0, sizeof(struct wireless_info));
 
                skfd = iw_sockets_open();
-               if(iw_get_basic_config(skfd, s, &(winfo->b)) > -1) {
+               if (iw_get_basic_config(skfd, s, &(winfo->b)) > -1) {
 
                        // set present winfo variables
-                       if(iw_get_stats(skfd, s, &(winfo->stats), &winfo->range, winfo->has_range) >= 0)
+                       if (iw_get_stats(skfd, s, &(winfo->stats),
+                                       &winfo->range, winfo->has_range) >= 0) {
                                winfo->has_stats = 1;
-                       if(iw_get_range_info(skfd, s, &(winfo->range)) >= 0)
+                       }
+                       if (iw_get_range_info(skfd, s, &(winfo->range)) >= 0) {
                                winfo->has_range = 1;
-                       if(iw_get_ext(skfd, s, SIOCGIWAP, &wrq) >= 0) {
+                       }
+                       if (iw_get_ext(skfd, s, SIOCGIWAP, &wrq) >= 0) {
                                winfo->has_ap_addr = 1;
-                               memcpy(&(winfo->ap_addr), &(wrq.u.ap_addr), sizeof (sockaddr));
+                               memcpy(&(winfo->ap_addr), &(wrq.u.ap_addr), sizeof(sockaddr));
                        }
 
                        // get bitrate
-                       if(iw_get_ext(skfd, s, SIOCGIWRATE, &wrq) >= 0) {
+                       if (iw_get_ext(skfd, s, SIOCGIWRATE, &wrq) >= 0) {
                                memcpy(&(winfo->bitrate), &(wrq.u.bitrate), sizeof(iwparam));
                                iw_print_bitrate(ns->bitrate, 16, winfo->bitrate.value);
                                has_bitrate = 1;
                        }
 
                        // get link quality
-                       if(winfo->has_range && winfo->has_stats && ((winfo->stats.qual.level != 0) || (winfo->stats.qual.updated & IW_QUAL_DBM))) {
-                               if(!(winfo->stats.qual.updated & IW_QUAL_QUAL_INVALID)) {
+                       if (winfo->has_range && winfo->has_stats
+                                       && ((winfo->stats.qual.level != 0)
+                                       || (winfo->stats.qual.updated & IW_QUAL_DBM))) {
+                               if (!(winfo->stats.qual.updated & IW_QUAL_QUAL_INVALID)) {
                                        ns->link_qual = winfo->stats.qual.qual;
                                        ns->link_qual_max = winfo->range.max_qual.qual;
                                }
                        }
 
                        // get ap mac
-                       if(winfo->has_ap_addr) {
+                       if (winfo->has_ap_addr) {
                                iw_sawap_ntop(&winfo->ap_addr, ns->ap);
                        }
 
                        // get essid
-                       if(winfo->b.has_essid) {
-                               if(winfo->b.essid_on)
-                               snprintf(ns->essid, 32, "%s", winfo->b.essid);
-                               else
-                               snprintf(ns->essid, 32, "off/any");
+                       if (winfo->b.has_essid) {
+                               if (winfo->b.essid_on) {
+                                       snprintf(ns->essid, 32, "%s", winfo->b.essid);
+                               } else {
+                                       snprintf(ns->essid, 32, "off/any");
+                               }
                        }
 
                        snprintf(ns->mode, 16, "%s", iw_operation_mode[winfo->b.mode]);
@@ -350,7 +360,7 @@ inline void update_net_stats()
 
        fclose(net_dev_fp);
 
-  info.mask |= (1 << INFO_NET);
+       info.mask |= (1 << INFO_NET);
 }
 
 int result;
@@ -358,27 +368,25 @@ int result;
 void update_total_processes()
 {
 #ifdef HAVE_SYSINFO
-  if (!prefer_proc)
-  {
-    struct sysinfo s_info;
-    sysinfo(&s_info);
-    info.procs = s_info.procs;
-  }
-  else
+       if (!prefer_proc) {
+               struct sysinfo s_info;
+
+               sysinfo(&s_info);
+               info.procs = s_info.procs;
+       } else
 #endif
-  {
-    static int rep = 0;
-    FILE *fp;
-
-    if (!(fp = open_file("/proc/loadavg", &rep)))
-    {
-      info.procs=0;
-      return;
-    }
-    fscanf(fp, "%*f %*f %*f %*d/%hd", &info.procs );
-    fclose(fp);
-  }
-  info.mask |= (1 << INFO_PROCS);
+       {
+               static int rep = 0;
+               FILE *fp;
+
+               if (!(fp = open_file("/proc/loadavg", &rep))) {
+                       info.procs = 0;
+                       return;
+               }
+               fscanf(fp, "%*f %*f %*f %*d/%hd", &info.procs);
+               fclose(fp);
+       }
+       info.mask |= (1 << INFO_PROCS);
 }
 
 #define CPU_SAMPLE_COUNT 15
@@ -399,36 +407,43 @@ struct cpu_info {
 };
 static short cpu_setup = 0;
 
-/*
-   determine if this kernel gives us "extended" statistics information in /proc/stat.
-   Kernels around 2.5 and earlier only reported user, system, nice and idle values in proc stat.
-   Kernels around 2.6 and greater report these PLUS iowait, irq, softirq, and steal
-*/
-void determine_longstat(char * buf) {
-       unsigned long long iowait=0;
+/* Determine if this kernel gives us "extended" statistics information in
+ * /proc/stat.
+ * Kernels around 2.5 and earlier only reported user, system, nice, and
+ * idle values in proc stat.
+ * Kernels around 2.6 and greater report these PLUS iowait, irq, softirq,
+ * and steal */
+void determine_longstat(char *buf)
+{
+       unsigned long long iowait = 0;
+
        KFLAG_SETOFF(KFLAG_IS_LONGSTAT);
-       /* scanf will either return -1 or 1 because there is only 1 assignment  */
-       if (sscanf(buf, "%*s %*d %*d %*d %*d %llu",&iowait)>0) KFLAG_SETON(KFLAG_IS_LONGSTAT);
+       /* scanf will either return -1 or 1 because there is only 1 assignment */
+       if (sscanf(buf, "%*s %*d %*d %*d %*d %llu", &iowait) > 0) {
+               KFLAG_SETON(KFLAG_IS_LONGSTAT);
+       }
 }
 
 void get_cpu_count()
 {
-  FILE *stat_fp;
-  static int rep = 0;
+       FILE *stat_fp;
+       static int rep = 0;
 
        if (info.cpu_usage) {
                return;
        }
        char buf[256];
 
-  if (!(stat_fp = open_file("/proc/stat", &rep)))
-    return;
+       if (!(stat_fp = open_file("/proc/stat", &rep))) {
+               return;
+       }
 
        info.cpu_count = 0;
 
        while (!feof(stat_fp)) {
-               if (fgets(buf, 255, stat_fp) == NULL)
+               if (fgets(buf, 255, stat_fp) == NULL) {
                        break;
+               }
 
                if (strncmp(buf, "cpu", 3) == 0 && isdigit(buf[3])) {
                        if (info.cpu_count == 0) {
@@ -439,7 +454,7 @@ void get_cpu_count()
        }
        info.cpu_usage = malloc((info.cpu_count + 1) * sizeof(float));
 
-  fclose (stat_fp);
+       fclose(stat_fp);
 }
 
 #define TMPL_LONGSTAT "%*s %llu %llu %llu %llu %llu %llu %llu %llu"
@@ -447,16 +462,15 @@ void get_cpu_count()
 
 inline static void update_stat()
 {
-  FILE *stat_fp;
-  static int rep = 0;
+       FILE *stat_fp;
+       static int rep = 0;
        static struct cpu_info *cpu = NULL;
        char buf[256];
        unsigned int i;
        unsigned int index;
        double curtmp;
-       char * stat_template=NULL;
-       unsigned int malloc_cpu_size=0;
-
+       char *stat_template = NULL;
+       unsigned int malloc_cpu_size = 0;
 
        /* add check for !info.cpu_usage since that mem is freed on a SIGUSR1 */
        if (!cpu_setup || !info.cpu_usage) {
@@ -465,7 +479,8 @@ inline static void update_stat()
        }
 
        if (!stat_template) {
-               stat_template = KFLAG_ISSET(KFLAG_IS_LONGSTAT) ? TMPL_LONGSTAT : TMPL_SHORTSTAT ;
+               stat_template =
+                       KFLAG_ISSET(KFLAG_IS_LONGSTAT) ? TMPL_LONGSTAT : TMPL_SHORTSTAT;
        }
 
        if (!cpu) {
@@ -474,78 +489,73 @@ inline static void update_stat()
                memset(cpu, 0, malloc_cpu_size);
        }
 
-  if (!(stat_fp = open_file("/proc/stat", &rep)))
-  {
-    info.run_procs=0;
-    if (info.cpu_usage)
-    {
-       memset(info.cpu_usage, 0, info.cpu_count * sizeof (float));
-    }
-    return;
-  }
+       if (!(stat_fp = open_file("/proc/stat", &rep))) {
+               info.run_procs = 0;
+               if (info.cpu_usage) {
+                       memset(info.cpu_usage, 0, info.cpu_count * sizeof(float));
+               }
+               return;
+       }
 
        index = 0;
        while (!feof(stat_fp)) {
-               if (fgets(buf, 255, stat_fp) == NULL)
+               if (fgets(buf, 255, stat_fp) == NULL) {
                        break;
+               }
 
                if (strncmp(buf, "procs_running ", 14) == 0) {
                        sscanf(buf, "%*s %hu", &info.run_procs);
                        info.mask |= (1 << INFO_RUN_PROCS);
                } else if (strncmp(buf, "cpu", 3) == 0) {
-                       index = isdigit(buf[3]) ? ((int)buf[3]) - 0x2F : 0;
-                       sscanf(buf, stat_template
-                               , &(cpu[index].cpu_user)
-                               , &(cpu[index].cpu_nice)
-                               , &(cpu[index].cpu_system)
-                               , &(cpu[index].cpu_idle)
-                               , &(cpu[index].cpu_iowait)
-                               , &(cpu[index].cpu_irq)
-                               , &(cpu[index].cpu_softirq)
-                               , &(cpu[index].cpu_steal)
-                               );
-
-                       cpu[index].cpu_total = cpu[index].cpu_user
-                                        + cpu[index].cpu_nice
-                                        + cpu[index].cpu_system
-                                        + cpu[index].cpu_idle
-                                        + cpu[index].cpu_iowait
-                                        + cpu[index].cpu_irq
-                                        + cpu[index].cpu_softirq
-                                        + cpu[index].cpu_steal
-                                        ;
-
-                       cpu[index].cpu_active_total = cpu[index].cpu_total - (cpu[index].cpu_idle + cpu[index].cpu_iowait);
+                       index = isdigit(buf[3]) ? ((int) buf[3]) - 0x2F : 0;
+                       sscanf(buf, stat_template, &(cpu[index].cpu_user),
+                               &(cpu[index].cpu_nice), &(cpu[index].cpu_system),
+                               &(cpu[index].cpu_idle), &(cpu[index].cpu_iowait),
+                               &(cpu[index].cpu_irq), &(cpu[index].cpu_softirq),
+                               &(cpu[index].cpu_steal));
+
+                       cpu[index].cpu_total = cpu[index].cpu_user + cpu[index].cpu_nice +
+                               cpu[index].cpu_system + cpu[index].cpu_idle +
+                               cpu[index].cpu_iowait + cpu[index].cpu_irq +
+                               cpu[index].cpu_softirq + cpu[index].cpu_steal;
+
+                       cpu[index].cpu_active_total = cpu[index].cpu_total -
+                               (cpu[index].cpu_idle + cpu[index].cpu_iowait);
                        info.mask |= (1 << INFO_CPU);
 
                        double delta = current_update_time - last_update_time;
-                       if (delta <= 0.001) break;
 
-                       cpu[index].cpu_val[0] = (cpu[index].cpu_active_total -  cpu[index].cpu_last_active_total) /
-                                               (float )(cpu[index].cpu_total - cpu[index].cpu_last_total);
+                       if (delta <= 0.001) {
+                               break;
+                       }
+
+                       cpu[index].cpu_val[0] = (cpu[index].cpu_active_total -
+                               cpu[index].cpu_last_active_total) /
+                               (float) (cpu[index].cpu_total - cpu[index].cpu_last_total);
                        curtmp = 0;
-                       for (i=0; i < info.cpu_avg_samples; i++ ) {
+                       for (i = 0; i < info.cpu_avg_samples; i++) {
                                curtmp += cpu[index].cpu_val[i];
                        }
-                       /* TESTING -- I've removed this, because I don't think it is right. You shouldn't divide
-                                     by the cpu count here ... removing for testing */
-                       /* if (index == 0) {
-                               info.cpu_usage[index] = curtmp / info.cpu_avg_samples / info.cpu_count;
-                       } else {
-                               info.cpu_usage[index] = curtmp / info.cpu_avg_samples;
-                       }  */
+                       /* TESTING -- I've removed this, because I don't think it is right.
+                        * You shouldn't divide by the cpu count here ...
+                        * removing for testing */
+                       /* if (index == 0) {
+                               info.cpu_usage[index] = curtmp / info.cpu_avg_samples /
+                                       info.cpu_count;
+                       } else {
+                               info.cpu_usage[index] = curtmp / info.cpu_avg_samples;
+                       } */
                        /* TESTING -- this line replaces the prev. "suspect" if/else */
                        info.cpu_usage[index] = curtmp / info.cpu_avg_samples;
 
                        cpu[index].cpu_last_total = cpu[index].cpu_total;
                        cpu[index].cpu_last_active_total = cpu[index].cpu_active_total;
-                       for (i = info.cpu_avg_samples - 1; i > 0; i--) {
-                               cpu[index].cpu_val[i] = cpu[index].cpu_val[i - 1];
+                       for (i = info.cpu_avg_samples - 1; i > 0; i--) {
+                               cpu[index].cpu_val[i] = cpu[index].cpu_val[i - 1];
                        }
                }
-
        }
-  fclose (stat_fp);
+       fclose(stat_fp);
 }
 
 void update_running_processes()
@@ -561,29 +571,28 @@ void update_cpu_usage()
 void update_load_average()
 {
 #ifdef HAVE_GETLOADAVG
-  if (!prefer_proc)
-  {
-         double v[3];
-         getloadavg(v, 3);
-         info.loadavg[0] = (float) v[0];
-         info.loadavg[1] = (float) v[1];
-         info.loadavg[2] = (float) v[2];
-  }
-  else
+       if (!prefer_proc) {
+               double v[3];
+
+               getloadavg(v, 3);
+               info.loadavg[0] = (float) v[0];
+               info.loadavg[1] = (float) v[1];
+               info.loadavg[2] = (float) v[2];
+       } else
 #endif
-  {
-    static int rep = 0;
-    FILE *fp;
-
-    if (!(fp = open_file("/proc/loadavg", &rep)))
-    {
-      info.loadavg[0] = info.loadavg[1] = info.loadavg[2] = 0.0;
-      return;
-    }
-    fscanf(fp, "%f %f %f", &info.loadavg[0], &info.loadavg[1], &info.loadavg[2]);
-    fclose(fp);
-  }
-  info.mask |= (1 << INFO_LOADAVG);
+       {
+               static int rep = 0;
+               FILE *fp;
+
+               if (!(fp = open_file("/proc/loadavg", &rep))) {
+                       info.loadavg[0] = info.loadavg[1] = info.loadavg[2] = 0.0;
+                       return;
+               }
+               fscanf(fp, "%f %f %f", &info.loadavg[0], &info.loadavg[1],
+                       &info.loadavg[2]);
+               fclose(fp);
+       }
+       info.mask |= (1 << INFO_LOADAVG);
 }
 
 #define PROC_I8K "/proc/i8k"
@@ -592,46 +601,47 @@ static char *i8k_procbuf = NULL;
 void update_i8k()
 {
        FILE *fp;
+
        if (!i8k_procbuf) {
-               i8k_procbuf = (char*)malloc(128*sizeof(char));
+               i8k_procbuf = (char *) malloc(128 * sizeof(char));
        }
-       if ((fp = fopen(PROC_I8K,"r")) == NULL) {
-               CRIT_ERR("/proc/i8k doesn't exist! use insmod to make sure the kernel driver is loaded...");
+       if ((fp = fopen(PROC_I8K, "r")) == NULL) {
+               CRIT_ERR("/proc/i8k doesn't exist! use insmod to make sure the kernel "
+                       "driver is loaded...");
        }
 
-       memset(&i8k_procbuf[0],0,128);
-       if (fread(&i8k_procbuf[0],sizeof(char),128,fp) == 0) {
+       memset(&i8k_procbuf[0], 0, 128);
+       if (fread(&i8k_procbuf[0], sizeof(char), 128, fp) == 0) {
                ERR("something wrong with /proc/i8k...");
        }
 
        fclose(fp);
 
-  i8k.version = strtok(&i8k_procbuf[0],I8K_DELIM);
-       i8k.bios = strtok(NULL,I8K_DELIM);
-       i8k.serial = strtok(NULL,I8K_DELIM);
-       i8k.cpu_temp = strtok(NULL,I8K_DELIM);
-       i8k.left_fan_status = strtok(NULL,I8K_DELIM);
-       i8k.right_fan_status = strtok(NULL,I8K_DELIM);
-       i8k.left_fan_rpm = strtok(NULL,I8K_DELIM);
-       i8k.right_fan_rpm = strtok(NULL,I8K_DELIM);
-       i8k.ac_status = strtok(NULL,I8K_DELIM);
-       i8k.buttons_status = strtok(NULL,I8K_DELIM);
+       i8k.version = strtok(&i8k_procbuf[0], I8K_DELIM);
+       i8k.bios = strtok(NULL, I8K_DELIM);
+       i8k.serial = strtok(NULL, I8K_DELIM);
+       i8k.cpu_temp = strtok(NULL, I8K_DELIM);
+       i8k.left_fan_status = strtok(NULL, I8K_DELIM);
+       i8k.right_fan_status = strtok(NULL, I8K_DELIM);
+       i8k.left_fan_rpm = strtok(NULL, I8K_DELIM);
+       i8k.right_fan_rpm = strtok(NULL, I8K_DELIM);
+       i8k.ac_status = strtok(NULL, I8K_DELIM);
+       i8k.buttons_status = strtok(NULL, I8K_DELIM);
 }
 
-
 /***********************************************************/
 /***********************************************************/
 /***********************************************************/
 
 static int no_dots(const struct dirent *d)
 {
-       if (d->d_name[0] == '.')
+       if (d->d_name[0] == '.') {
                return 0;
+       }
        return 1;
 }
 
-static int
-get_first_file_in_a_directory(const char *dir, char *s, int *rep)
+static int get_first_file_in_a_directory(const char *dir, char *s, int *rep)
 {
        struct dirent **namelist;
        int i, n;
@@ -640,59 +650,65 @@ get_first_file_in_a_directory(const char *dir, char *s, int *rep)
        if (n < 0) {
                if (!rep || !*rep) {
                        ERR("scandir for %s: %s", dir, strerror(errno));
-                       if (rep)
+                       if (rep) {
                                *rep = 1;
+                       }
                }
                return 0;
        } else {
-               if (n == 0)
+               if (n == 0) {
                        return 0;
+               }
 
                strncpy(s, namelist[0]->d_name, 255);
                s[255] = '\0';
 
-               for (i = 0; i < n; i++)
+               for (i = 0; i < n; i++) {
                        free(namelist[i]);
+               }
                free(namelist);
 
                return 1;
        }
 }
 
-int open_sysfs_sensor(const char *dir, const char *dev, const char *type, int n, int *div, char *devtype)
+int open_sysfs_sensor(const char *dir, const char *dev, const char *type, int n,
+               int *div, char *devtype)
 {
        char path[256];
        char buf[256];
        int fd;
        int divfd;
 
-  memset (buf, 0, sizeof(buf));
+       memset(buf, 0, sizeof(buf));
 
        /* if device is NULL or *, get first */
        if (dev == NULL || strcmp(dev, "*") == 0) {
                static int rep = 0;
-               if (!get_first_file_in_a_directory(dir, buf, &rep))
+
+               if (!get_first_file_in_a_directory(dir, buf, &rep)) {
                        return -1;
+               }
                dev = buf;
        }
 
-  if (strcmp (dir, "/sys/class/hwmon/")==0) {
-    if (*buf) {
-      /* buf holds result from get_first_file_in_a_directory() above, 
-       * e.g. "hwmon0" -- append "/device" */
-      strcat (buf,"/device");
-    }
-    else {
-      /* dev holds device number N as a string, 
-       * e.g. "0", -- convert to "hwmon0/device" */
-      sprintf (buf,"hwmon%s/device",dev);
-      dev = buf;
-    }
-  }
+       if (strcmp(dir, "/sys/class/hwmon/") == 0) {
+               if (*buf) {
+                       /* buf holds result from get_first_file_in_a_directory() above,
+                        * e.g. "hwmon0" -- append "/device" */
+                       strcat(buf, "/device");
+               } else {
+                       /* dev holds device number N as a string,
+                        * e.g. "0", -- convert to "hwmon0/device" */
+                       sprintf(buf, "hwmon%s/device", dev);
+                       dev = buf;
+               }
+       }
 
        /* change vol to in */
-       if (strcmp(type, "vol") == 0)
+       if (strcmp(type, "vol") == 0) {
                type = "in";
+       }
 
        if (strcmp(type, "tempf") == 0) {
                snprintf(path, 255, "%s%s/%s%d_input", dir, dev, "temp", n);
@@ -704,23 +720,24 @@ int open_sysfs_sensor(const char *dir, const char *dev, const char *type, int n,
        /* open file */
        fd = open(path, O_RDONLY);
        if (fd < 0) {
-               CRIT_ERR("can't open '%s': %s\nplease check your device or remove this var from Conky", 
-        path, strerror(errno));
+               CRIT_ERR("can't open '%s': %s\nplease check your device or remove this "
+                       "var from Conky", path, strerror(errno));
        }
 
        if (strcmp(type, "in") == 0 || strcmp(type, "temp") == 0
-           || strcmp(type, "tempf") == 0)
+                       || strcmp(type, "tempf") == 0) {
                *div = 1;
-       else
+       } else {
                *div = 0;
+       }
        /* fan does not use *_div as a read divisor */
-       if (strcmp("fan", type) == 0)
+       if (strcmp("fan", type) == 0) {
                return fd;
+       }
 
        /* test if *_div file exist, open it and use it as divisor */
        if (strcmp(type, "tempf") == 0) {
-               snprintf(path, 255, "%s%s/%s%d_div", dir, "one", "two",
-                        n);
+               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);
        }
@@ -730,6 +747,7 @@ int open_sysfs_sensor(const char *dir, const char *dev, const char *type, int n,
                /* read integer */
                char divbuf[64];
                unsigned int divn;
+
                divn = read(divfd, divbuf, 63);
                /* should read until n == 0 but I doubt that kernel will give these
                 * in multiple pieces. :) */
@@ -746,8 +764,9 @@ double get_sysfs_info(int *fd, int div, char *devtype, char *type)
 {
        int val = 0;
 
-       if (*fd <= 0)
+       if (*fd <= 0) {
                return 0;
+       }
 
        lseek(*fd, 0, SEEK_SET);
 
@@ -755,6 +774,7 @@ double get_sysfs_info(int *fd, int div, char *devtype, char *type)
        {
                char buf[64];
                unsigned int n;
+
                n = read(*fd, buf, 63);
                /* should read until n == 0 but I doubt that kernel will give these
                 * in multiple pieces. :) */
@@ -765,123 +785,116 @@ double get_sysfs_info(int *fd, int div, char *devtype, char *type)
        close(*fd);
        /* open file */
        *fd = open(devtype, O_RDONLY);
-       if (*fd < 0)
+       if (*fd < 0) {
                ERR("can't open '%s': %s", devtype, strerror(errno));
+       }
 
        /* My dirty hack for computing CPU value
-        * Filedil, from forums.gentoo.org
-        */
-/*     if (strstr(devtype, "temp1_input") != NULL)
-       return -15.096+1.4893*(val / 1000.0); */
-
+        * Filedil, from forums.gentoo.org */
+       /* if (strstr(devtype, "temp1_input") != NULL) {
+               return -15.096 + 1.4893 * (val / 1000.0);
+       } */
 
        /* divide voltage and temperature by 1000 */
        /* or if any other divisor is given, use that */
        if (strcmp(type, "tempf") == 0) {
-               if (div > 1)
+               if (div > 1) {
                        return ((val / div + 40) * 9.0 / 5) - 40;
-               else if (div)
+               } else if (div) {
                        return ((val / 1000.0 + 40) * 9.0 / 5) - 40;
-               else
+               } else {
                        return ((val + 40) * 9.0 / 5) - 40;
+               }
        } else {
-               if (div > 1)
+               if (div > 1) {
                        return val / div;
-               else if (div)
+               } else if (div) {
                        return val / 1000.0;
-               else
+               } else {
                        return val;
+               }
        }
 }
 
-/* Prior to kernel version 2.6.12, the CPU fan speed was available
- * in ADT746X_FAN_OLD, whereas later kernel versions provide this
- * information in ADT746X_FAN.
- */
+/* Prior to kernel version 2.6.12, the CPU fan speed was available in
+ * ADT746X_FAN_OLD, whereas later kernel versions provide this information in
+ * ADT746X_FAN. */
 #define ADT746X_FAN "/sys/devices/temperatures/sensor1_fan_speed"
 #define ADT746X_FAN_OLD "/sys/devices/temperatures/cpu_fan_speed"
 
-void get_adt746x_fan( char * p_client_buffer, size_t client_buffer_size )
+void get_adt746x_fan(char *p_client_buffer, size_t client_buffer_size)
 {
        static int rep = 0;
        char adt746x_fan_state[64];
        FILE *fp;
 
-       if ( !p_client_buffer || client_buffer_size <= 0 )
+       if (!p_client_buffer || client_buffer_size <= 0) {
                return;
+       }
 
        if ((fp = open_file(ADT746X_FAN, &rep)) == NULL
-                && (fp = open_file(ADT746X_FAN_OLD, &rep)) == NULL)
-
-       {
+                       && (fp = open_file(ADT746X_FAN_OLD, &rep)) == NULL) {
                sprintf(adt746x_fan_state, "adt746x not found");
-       }
-       else
-       {
+       } else {
                fgets(adt746x_fan_state, sizeof(adt746x_fan_state), fp);
                adt746x_fan_state[strlen(adt746x_fan_state) - 1] = 0;
                fclose(fp);
        }
 
-       snprintf( p_client_buffer, client_buffer_size, "%s", adt746x_fan_state );
-       return;
+       snprintf(p_client_buffer, client_buffer_size, "%s", adt746x_fan_state);
 }
 
-/* Prior to kernel version 2.6.12, the CPU temperature was found
- * in ADT746X_CPU_OLD, whereas later kernel versions provide this
- * information in ADT746X_CPU.
- */
+/* Prior to kernel version 2.6.12, the CPU temperature was found in
+ * ADT746X_CPU_OLD, whereas later kernel versions provide this information in
+ * ADT746X_CPU. */
 #define ADT746X_CPU "/sys/devices/temperatures/sensor1_temperature"
 #define ADT746X_CPU_OLD "/sys/devices/temperatures/cpu_temperature"
 
-void get_adt746x_cpu( char * p_client_buffer, size_t client_buffer_size )
+void get_adt746x_cpu(char *p_client_buffer, size_t client_buffer_size)
 {
        static int rep = 0;
        char adt746x_cpu_state[64];
        FILE *fp;
 
-       if ( !p_client_buffer || client_buffer_size <= 0 )
+       if (!p_client_buffer || client_buffer_size <= 0) {
                return;
+       }
 
        if ((fp = open_file(ADT746X_CPU, &rep)) == NULL
-                && (fp = open_file(ADT746X_CPU_OLD, &rep)) == NULL)
-       {
+                       && (fp = open_file(ADT746X_CPU_OLD, &rep)) == NULL) {
                sprintf(adt746x_cpu_state, "adt746x not found");
-       }
-       else
-       {
+       } else {
                fscanf(fp, "%2s", adt746x_cpu_state);
                fclose(fp);
        }
 
-       snprintf( p_client_buffer, client_buffer_size, "%s", adt746x_cpu_state );
-       return;
+       snprintf(p_client_buffer, client_buffer_size, "%s", adt746x_cpu_state);
 }
 
 /* Thanks to "Walt Nelson" <wnelsonjr@comcast.net> */
 
 /***********************************************************************/
-/*
- *  This file is part of x86info.
- *  (C) 2001 Dave Jones.
+/* This file is part of x86info.
+ * (C) 2001 Dave Jones.
  *
- *  Licensed under the terms of the GNU GPL License version 2.
+ * Licensed under the terms of the GNU GPL License version 2.
  *
  * Estimate CPU MHz routine by Andrea Arcangeli <andrea@suse.de>
- * Small changes by David Sterba <sterd9am@ss1000.ms.mff.cuni.cz>
- *
- */
+ * Small changes by David Sterba <sterd9am@ss1000.ms.mff.cuni.cz> */
+
 #if  defined(__i386) || defined(__x86_64)
 __inline__ unsigned long long int rdtsc()
 {
        unsigned long long int x;
-       __asm__ volatile (".byte 0x0f, 0x31":"=A" (x));
+
+       __asm__ volatile(".byte 0x0f, 0x31":"=A" (x));
        return x;
 }
 #endif
 
 /* return system frequency in MHz (use divisor=1) or GHz (use divisor=1000) */
-void get_freq_dynamic( char * p_client_buffer, size_t client_buffer_size, char * p_format, int divisor )
+void get_freq_dynamic(char *p_client_buffer, size_t client_buffer_size,
+               char *p_format, int divisor)
 {
 #if  defined(__i386) || defined(__x86_64)
        struct timezone tz;
@@ -889,8 +902,10 @@ void get_freq_dynamic( char * p_client_buffer, size_t client_buffer_size, char *
        unsigned long long cycles[2];   /* gotta be 64 bit */
        unsigned int microseconds;      /* total time taken */
 
-       if ( !p_client_buffer || client_buffer_size <= 0 || !p_format || divisor <= 0 )
-            return;
+       if (!p_client_buffer || client_buffer_size <= 0 || !p_format
+                       || divisor <= 0) {
+               return;
+       }
 
        memset(&tz, 0, sizeof(tz));
 
@@ -904,103 +919,112 @@ void get_freq_dynamic( char * p_client_buffer, size_t client_buffer_size, char *
        cycles[1] = rdtsc();
        gettimeofday(&tvstop, &tz);
        microseconds = ((tvstop.tv_sec - tvstart.tv_sec) * 1000000) +
-           (tvstop.tv_usec - tvstart.tv_usec);
+               (tvstop.tv_usec - tvstart.tv_usec);
 
-       snprintf( p_client_buffer, client_buffer_size, p_format, (float)((cycles[1] - cycles[0]) / microseconds) / divisor );
+       snprintf(p_client_buffer, client_buffer_size, p_format,
+               (float) ((cycles[1] - cycles[0]) / microseconds) / divisor);
        return;
 #else
-/* FIXME: hardwired: get freq for first cpu!
-   this whole function needs to be rethought and redone for
-   multi-cpu/multi-core/multi-threaded environments and
-   arbitrary combinations thereof
-*/
-       get_freq( p_client_buffer, client_buffer_size, p_format, divisor, 1 );
+       /* FIXME: hardwired: get freq for first cpu!
+        * this whole function needs to be rethought and redone for
+        * multi-cpu/multi-core/multi-threaded environments and
+        * arbitrary combinations thereof */
+       get_freq(p_client_buffer, client_buffer_size, p_format, divisor, 1);
        return;
 #endif
 }
 
-
 #define CPUFREQ_PREFIX "/sys/devices/system/cpu"
 #define CPUFREQ_POSTFIX "cpufreq/scaling_cur_freq"
 
 /* return system frequency in MHz (use divisor=1) or GHz (use divisor=1000) */
-char get_freq( char * p_client_buffer, size_t client_buffer_size, char * p_format, int divisor, unsigned int cpu )
+char get_freq(char *p_client_buffer, size_t client_buffer_size, char *p_format,
+               int divisor, unsigned int cpu)
 {
        FILE *f;
-  static int rep = 0;
+       static int rep = 0;
        char frequency[32];
        char s[256];
        double freq = 0;
 
-       if ( !p_client_buffer || client_buffer_size <= 0 || !p_format || divisor <= 0 )
+       if (!p_client_buffer || client_buffer_size <= 0 || !p_format
+                       || divisor <= 0) {
                return 0;
+       }
 
-  if (!prefer_proc)
-  {
-    char current_freq_file[128];
-    snprintf(current_freq_file, 127, "%s/cpu%d/%s",CPUFREQ_PREFIX, cpu-1, CPUFREQ_POSTFIX);
-         f = fopen(current_freq_file, "r");
-         if (f)
-    {
-                 /* if there's a cpufreq /sys node, read the current frequency from this node;
-                  * divide by 1000 to get Mhz. */
-                 if (fgets(s, sizeof(s), f)) {
-                           s[strlen(s)-1] = '\0';
-                           freq = strtod(s, NULL);
-                 }
-                 fclose(f);
-                 snprintf( p_client_buffer, client_buffer_size, p_format, (freq/1000)/divisor );
-                 return 1;
-    }
-       }
-
-       f = open_file("/proc/cpuinfo", &rep);           //open the CPU information file
+       if (!prefer_proc) {
+               char current_freq_file[128];
+
+               snprintf(current_freq_file, 127, "%s/cpu%d/%s", CPUFREQ_PREFIX, cpu - 1,
+                       CPUFREQ_POSTFIX);
+               f = fopen(current_freq_file, "r");
+               if (f) {
+                       /* if there's a cpufreq /sys node, read the current frequency from
+                        * this node and divide by 1000 to get Mhz. */
+                       if (fgets(s, sizeof(s), f)) {
+                               s[strlen(s) - 1] = '\0';
+                               freq = strtod(s, NULL);
+                       }
+                       fclose(f);
+                       snprintf(p_client_buffer, client_buffer_size, p_format,
+                               (freq / 1000) / divisor);
+                       return 1;
+               }
+       }
+
+       // open the CPU information file
+       f = open_file("/proc/cpuinfo", &rep);
        if (!f) {
                perror("Conky: Failed to access '/proc/cpuinfo' at get_freq()");
                return 0;
        }
 
-       while (fgets(s, sizeof(s), f) != NULL){         //read the file
+       // read the file
+       while (fgets(s, sizeof(s), f) != NULL) {
 
 #if defined(__i386) || defined(__x86_64)
-               if (strncmp(s, "cpu MHz", 7) == 0 && cpu == 0) {        //and search for the cpu mhz
+               // and search for the cpu mhz
+               if (strncmp(s, "cpu MHz", 7) == 0 && cpu == 0) {
 #else
 #if defined(__alpha)
-               if (strncmp(s, "cycle frequency [Hz]", 20) == 0 && cpu == 0) {          // different on alpha
+               // different on alpha
+               if (strncmp(s, "cycle frequency [Hz]", 20) == 0 && cpu == 0) {
 #else
-               if (strncmp(s, "clock", 5) == 0 && cpu == 0) {  // this is different on ppc for some reason
+               // this is different on ppc for some reason
+               if (strncmp(s, "clock", 5) == 0 && cpu == 0) {
 #endif // defined(__alpha)
 #endif // defined(__i386) || defined(__x86_64)
 
-               strcpy(frequency, strchr(s, ':') + 2);  //copy just the number
+                       // copy just the number
+                       strcpy(frequency, strchr(s, ':') + 2);
 #if defined(__alpha)
-               frequency[strlen(frequency) - 6] = '\0';// strip " est.\n"
-               freq = strtod(frequency, NULL)/1000000; // kernel reports in Hz
+                       // strip " est.\n"
+                       frequency[strlen(frequency) - 6] = '\0';
+                       // kernel reports in Hz
+                       freq = strtod(frequency, NULL) / 1000000;
 #else
-               frequency[strlen(frequency) - 1] = '\0'; // strip \n
-               freq = strtod(frequency, NULL);
+                       // strip \n
+                       frequency[strlen(frequency) - 1] = '\0';
+                       freq = strtod(frequency, NULL);
 #endif
-               break;
+                       break;
                }
                if (strncmp(s, "processor", 9) == 0) {
-                   cpu--;
-                   continue;
+                       cpu--;
+                       continue;
                }
-
        }
 
        fclose(f);
-       snprintf( p_client_buffer, client_buffer_size, p_format, (float)freq/divisor );
+       snprintf(p_client_buffer, client_buffer_size, p_format,
+               (float) freq / divisor);
        return 1;
 }
 
 #define CPUFREQ_VOLTAGE "cpufreq/scaling_voltages"
 
-/* return cpu voltage in mV (use divisor=1) or V (use divisor=1000) */
-char get_voltage( char * p_client_buffer, size_t client_buffer_size, char * p_format, int divisor, unsigned int cpu )
-{
-/* /sys/devices/system/cpu/cpu0/cpufreq/scaling_voltages looks
-   something like this:
+/* /sys/devices/system/cpu/cpu0/cpufreq/scaling_voltages looks something
+ * like this:
 # frequency voltage
 1800000 1340
 1600000 1292
@@ -1009,9 +1033,12 @@ char get_voltage( char * p_client_buffer, size_t client_buffer_size, char * p_fo
 1000000 1116
 800000 1004
 600000 988
-*/
+ * Peter Tarjan (ptarjan@citromail.hu) */
 
-/* Peter Tarjan (ptarjan@citromail.hu) */
+/* return cpu voltage in mV (use divisor=1) or V (use divisor=1000) */
+char get_voltage(char *p_client_buffer, size_t client_buffer_size,
+               char *p_format, int divisor, unsigned int cpu)
+{
        FILE *f;
        char s[256];
        int freq = 0;
@@ -1019,23 +1046,24 @@ char get_voltage( char * p_client_buffer, size_t client_buffer_size, char * p_fo
        char current_freq_file[128];
        int freq_comp = 0;
 
-
-/* build the voltage file name */
+       /* build the voltage file name */
        cpu--;
-       snprintf(current_freq_file, 127, "%s/cpu%d/%s",
-                CPUFREQ_PREFIX, cpu, CPUFREQ_POSTFIX);
+       snprintf(current_freq_file, 127, "%s/cpu%d/%s", CPUFREQ_PREFIX, cpu,
+               CPUFREQ_POSTFIX);
 
-       if ( !p_client_buffer || client_buffer_size <= 0 || !p_format || divisor <= 0 )
+       if (!p_client_buffer || client_buffer_size <= 0 || !p_format
+                       || divisor <= 0) {
                return 0;
+       }
 
        /* read the current cpu frequency from the /sys node */
        f = fopen(current_freq_file, "r");
        if (f) {
-           if (fgets(s, sizeof(s), f)) {
-               s[strlen(s)-1] = '\0';
-               freq = strtod(s, NULL);
-           }
-           fclose(f);
+               if (fgets(s, sizeof(s), f)) {
+                       s[strlen(s) - 1] = '\0';
+                       freq = strtod(s, NULL);
+               }
+               fclose(f);
        } else {
                fprintf(stderr, "Conky: Failed to access '%s' at ", current_freq_file);
                perror("get_voltage()");
@@ -1043,20 +1071,25 @@ char get_voltage( char * p_client_buffer, size_t client_buffer_size, char * p_fo
                        fclose(f);
                }
                return 0;
-           }
+       }
 
-       snprintf(current_freq_file, 127, "%s/cpu%d/%s",
-                CPUFREQ_PREFIX, cpu, CPUFREQ_VOLTAGE);
+       snprintf(current_freq_file, 127, "%s/cpu%d/%s", CPUFREQ_PREFIX, cpu,
+               CPUFREQ_VOLTAGE);
 
-/* use the current cpu frequency to find the corresponding voltage */
+       /* use the current cpu frequency to find the corresponding voltage */
        f = fopen(current_freq_file, "r");
 
        if (f) {
                while (!feof(f)) {
                        char line[256];
-                       if (fgets(line, 255, f) == NULL) break;
+
+                       if (fgets(line, 255, f) == NULL) {
+                               break;
+                       }
                        sscanf(line, "%d %d", &freq_comp, &voltage);
-                       if(freq_comp == freq) break;
+                       if (freq_comp == freq) {
+                               break;
+                       }
                }
                fclose(f);
        } else {
@@ -1067,80 +1100,77 @@ char get_voltage( char * p_client_buffer, size_t client_buffer_size, char * p_fo
                }
                return 0;
        }
-       snprintf( p_client_buffer, client_buffer_size, p_format, (float)voltage/divisor );
+       snprintf(p_client_buffer, client_buffer_size, p_format,
+               (float) voltage / divisor);
        return 1;
-
 }
 
 #define ACPI_FAN_DIR "/proc/acpi/fan/"
 
-void get_acpi_fan( char * p_client_buffer, size_t client_buffer_size )
+void get_acpi_fan(char *p_client_buffer, size_t client_buffer_size)
 {
        static int rep = 0;
        char buf[256];
        char buf2[256];
        FILE *fp;
 
-       if ( !p_client_buffer || client_buffer_size <= 0 )
+       if (!p_client_buffer || client_buffer_size <= 0) {
                return;
+       }
 
        /* yeah, slow... :/ */
-       if (!get_first_file_in_a_directory(ACPI_FAN_DIR, buf, &rep))
-       {
-               snprintf( p_client_buffer, client_buffer_size, "no fans?" );
+       if (!get_first_file_in_a_directory(ACPI_FAN_DIR, buf, &rep)) {
+               snprintf(p_client_buffer, client_buffer_size, "no fans?");
                return;
        }
 
-       snprintf(buf2, sizeof(buf2), "%s%s/state", ACPI_FAN_DIR, buf );
+       snprintf(buf2, sizeof(buf2), "%s%s/state", ACPI_FAN_DIR, buf);
 
        fp = open_file(buf2, &rep);
        if (!fp) {
-               snprintf( p_client_buffer, client_buffer_size, "can't open fan's state file" );
+               snprintf(p_client_buffer, client_buffer_size,
+                       "can't open fan's state file");
                return;
        }
-       memset(buf,0,sizeof(buf));
+       memset(buf, 0, sizeof(buf));
        fscanf(fp, "%*s %99s", buf);
        fclose(fp);
 
-       snprintf( p_client_buffer, client_buffer_size, "%s", buf );
-
-       return;
+       snprintf(p_client_buffer, client_buffer_size, "%s", buf);
 }
 
 #define ACPI_AC_ADAPTER_DIR "/proc/acpi/ac_adapter/"
 
-void get_acpi_ac_adapter( char * p_client_buffer, size_t client_buffer_size )
+void get_acpi_ac_adapter(char *p_client_buffer, size_t client_buffer_size)
 {
        static int rep = 0;
        char buf[256];
        char buf2[256];
        FILE *fp;
 
-       if ( !p_client_buffer || client_buffer_size <= 0 )
+       if (!p_client_buffer || client_buffer_size <= 0) {
                return;
+       }
 
        /* yeah, slow... :/ */
-       if (!get_first_file_in_a_directory(ACPI_AC_ADAPTER_DIR, buf, &rep))
-       {
-               snprintf( p_client_buffer, client_buffer_size, "no ac_adapters?" );
+       if (!get_first_file_in_a_directory(ACPI_AC_ADAPTER_DIR, buf, &rep)) {
+               snprintf(p_client_buffer, client_buffer_size, "no ac_adapters?");
                return;
        }
 
-       snprintf(buf2, sizeof(buf2), "%s%s/state", ACPI_AC_ADAPTER_DIR, buf );
-
+       snprintf(buf2, sizeof(buf2), "%s%s/state", ACPI_AC_ADAPTER_DIR, buf);
 
        fp = open_file(buf2, &rep);
        if (!fp) {
-               snprintf( p_client_buffer, client_buffer_size, "No ac adapter found.... where is it?" );
+               snprintf(p_client_buffer, client_buffer_size,
+                       "No ac adapter found.... where is it?");
                return;
        }
-       memset(buf,0,sizeof(buf));
-       fscanf(fp, "%*s %99s", buf );
+       memset(buf, 0, sizeof(buf));
+       fscanf(fp, "%*s %99s", buf);
        fclose(fp);
 
-       snprintf( p_client_buffer, client_buffer_size, "%s", buf );
-
-       return;
+       snprintf(p_client_buffer, client_buffer_size, "%s", buf);
 }
 
 /*
@@ -1168,17 +1198,19 @@ int open_acpi_temperature(const char *name)
 
        if (name == NULL || strcmp(name, "*") == 0) {
                static int rep = 0;
-               if (!get_first_file_in_a_directory
-                   (ACPI_THERMAL_DIR, buf, &rep))
+
+               if (!get_first_file_in_a_directory(ACPI_THERMAL_DIR, buf, &rep)) {
                        return -1;
+               }
                name = buf;
        }
 
        snprintf(path, 255, ACPI_THERMAL_FORMAT, name);
 
        fd = open(path, O_RDONLY);
-       if (fd < 0)
+       if (fd < 0) {
                ERR("can't open '%s': %s", path, strerror(errno));
+       }
 
        return fd;
 }
@@ -1188,8 +1220,9 @@ static double last_acpi_temp_time;
 
 double get_acpi_temperature(int fd)
 {
-       if (fd <= 0)
+       if (fd <= 0) {
                return 0;
+       }
 
        /* don't update acpi temperature too often */
        if (current_update_time - last_acpi_temp_time < 11.32) {
@@ -1204,10 +1237,11 @@ double get_acpi_temperature(int fd)
        {
                char buf[256];
                int n;
+
                n = read(fd, buf, 255);
-               if (n < 0)
+               if (n < 0) {
                        ERR("can't read fd %d: %s", fd, strerror(errno));
-               else {
+               } else {
                        buf[n] = '\0';
                        sscanf(buf, "temperature: %lf", &last_acpi_temp);
                }
@@ -1244,17 +1278,17 @@ present voltage:         16608 mV
 */
 
 /*
-2213<@jupet kellari ö> jupet@lagi-unstable:~$ cat /proc/apm
-2213<@jupet kellari ö> 1.16 1.2 0x03 0x01 0xff 0x10 -1% -1 ?
-2213<@jupet kellari ö> (-1 ollee ei akkua kiinni, koska akku on pöydällä)
-2214<@jupet kellari ö> jupet@lagi-unstable:~$ cat /proc/apm
-2214<@jupet kellari ö> 1.16 1.2 0x03 0x01 0x03 0x09 98% -1 ?
+2213<@jupet�kellari��> jupet@lagi-unstable:~$ cat /proc/apm
+2213<@jupet�kellari��> 1.16 1.2 0x03 0x01 0xff 0x10 -1% -1 ?
+2213<@jupet�kellari��> (-1 ollee ei akkua kiinni, koska akku on p�yd�ll�)
+2214<@jupet�kellari��> jupet@lagi-unstable:~$ cat /proc/apm
+2214<@jupet�kellari��> 1.16 1.2 0x03 0x01 0x03 0x09 98% -1 ?
 
-2238<@jupet kellari ö> 1.16 1.2 0x03 0x00 0x00 0x01 100% -1 ? ilman verkkovirtaa
-2239<@jupet kellari ö> 1.16 1.2 0x03 0x01 0x00 0x01 99% -1 ? verkkovirralla
+2238<@jupet�kellari��> 1.16 1.2 0x03 0x00 0x00 0x01 100% -1 ? ilman verkkovirtaa
+2239<@jupet�kellari��> 1.16 1.2 0x03 0x01 0x00 0x01 99% -1 ? verkkovirralla
 
-2240<@jupet kellari ö> 1.16 1.2 0x03 0x01 0x03 0x09 100% -1 ? verkkovirralla ja monitori päällä
-2241<@jupet kellari ö> 1.16 1.2 0x03 0x00 0x00 0x01 99% -1 ? monitori päällä mutta ilman verkkovirtaa
+2240<@jupet�kellari��> 1.16 1.2 0x03 0x01 0x03 0x09 100% -1 ? verkkovirralla ja monitori p��ll�
+2241<@jupet�kellari��> 1.16 1.2 0x03 0x00 0x00 0x01 99% -1 ? monitori p��ll� mutta ilman verkkovirtaa
 */
 
 #define ACPI_BATTERY_BASE_PATH "/proc/acpi/battery"
@@ -1270,35 +1304,43 @@ static char batteries[MAX_BATTERY_COUNT][32];
 static int acpi_last_full[MAX_BATTERY_COUNT];
 static int acpi_design_capacity[MAX_BATTERY_COUNT];
 
-static char last_battery_str[MAX_BATTERY_COUNT][64];   /* e.g. "charging 75%" */
-static char last_battery_time_str[MAX_BATTERY_COUNT][64];      /* e.g. "3h 15m" */
+/* e.g. "charging 75%" */
+static char last_battery_str[MAX_BATTERY_COUNT][64];
+/* e.g. "3h 15m" */
+static char last_battery_time_str[MAX_BATTERY_COUNT][64];
 
 static double last_battery_time[MAX_BATTERY_COUNT];
 
 static int last_battery_perct[MAX_BATTERY_COUNT];
 static double last_battery_perct_time[MAX_BATTERY_COUNT];
 
-
 void init_batteries(void)
 {
        int idx;
-       if(batteries_initialized)
+
+       if (batteries_initialized) {
                return;
-       for(idx = 0; idx < MAX_BATTERY_COUNT; idx++)
+       }
+       for (idx = 0; idx < MAX_BATTERY_COUNT; idx++) {
                batteries[idx][0] = '\0';
+       }
        batteries_initialized = 1;
 }
 
 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))
+
+       for (idx = 0; idx < MAX_BATTERY_COUNT; idx++) {
+               if (!strlen(batteries[idx]) || !strcmp(batteries[idx], bat)) {
                        break;
+               }
+       }
 
        /* if not found, enter a new entry */
-       if(!strlen(batteries[idx]))
+       if (!strlen(batteries[idx])) {
                snprintf(batteries[idx], 31, "%s", bat);
+       }
 
        return idx;
 }
@@ -1307,6 +1349,7 @@ void get_battery_stuff(char *buf, unsigned int n, const char *bat, int item)
 {
        static int idx, rep = 0, rep2 = 0;
        char acpi_path[128];
+
        snprintf(acpi_path, 127, ACPI_BATTERY_BASE_PATH "/%s/state", bat);
 
        init_batteries();
@@ -1314,18 +1357,20 @@ void get_battery_stuff(char *buf, unsigned int n, const char *bat, int item)
        idx = get_battery_idx(bat);
 
        /* don't update battery too often */
-       if (current_update_time - last_battery_time[idx] < 29.5)
+       if (current_update_time - last_battery_time[idx] < 29.5) {
                goto set_return_value;
+       }
 
        last_battery_time[idx] = current_update_time;
 
-       memset (last_battery_str[idx], 0, sizeof (last_battery_str[idx]));
-       memset (last_battery_time_str[idx], 0, sizeof (last_battery_time_str[idx]));
+       memset(last_battery_str[idx], 0, sizeof(last_battery_str[idx]));
+       memset(last_battery_time_str[idx], 0, sizeof(last_battery_time_str[idx]));
 
        /* first try ACPI */
 
-       if (acpi_bat_fp[idx] == NULL && apm_bat_fp[idx] == NULL)
+       if (acpi_bat_fp[idx] == NULL && apm_bat_fp[idx] == NULL) {
                acpi_bat_fp[idx] = open_file(acpi_path, &rep);
+       }
 
        if (acpi_bat_fp[idx] != NULL) {
                int present_rate = -1;
@@ -1338,15 +1383,18 @@ void get_battery_stuff(char *buf, unsigned int n, const char *bat, int item)
                        static int rep = 0;
                        char path[128];
                        FILE *fp;
-                       snprintf(path, 127,
-                                ACPI_BATTERY_BASE_PATH "/%s/info", bat);
+
+                       snprintf(path, 127, ACPI_BATTERY_BASE_PATH "/%s/info", bat);
                        fp = open_file(path, &rep);
                        if (fp != NULL) {
                                while (!feof(fp)) {
                                        char b[256];
-                                       if (fgets(b, 256, fp) == NULL)
+
+                                       if (fgets(b, 256, fp) == NULL) {
                                                break;
-                                       if (sscanf(b, "last full capacity: %d", &acpi_last_full[idx]) != 0) {
+                                       }
+                                       if (sscanf(b, "last full capacity: %d",
+                                                       &acpi_last_full[idx]) != 0) {
                                                break;
                                        }
                                }
@@ -1361,107 +1409,115 @@ void get_battery_stuff(char *buf, unsigned int n, const char *bat, int item)
 
                while (!feof(acpi_bat_fp[idx])) {
                        char buf[256];
-                       if (fgets(buf, 256, acpi_bat_fp[idx]) == NULL)
+
+                       if (fgets(buf, 256, acpi_bat_fp[idx]) == NULL) {
                                break;
+                       }
 
                        /* let's just hope units are ok */
-                       if (strncmp (buf, "present:", 8) == 0)
+                       if (strncmp(buf, "present:", 8) == 0) {
                                sscanf(buf, "present: %4s", present);
-                       else if (strncmp (buf, "charging state:", 15) == 0)
+                       } else if (strncmp(buf, "charging state:", 15) == 0) {
                                sscanf(buf, "charging state: %63s", charging_state);
-                       else if (strncmp (buf, "present rate:", 13) == 0)
+                       } else if (strncmp(buf, "present rate:", 13) == 0) {
                                sscanf(buf, "present rate: %d", &present_rate);
-                       else if (strncmp(buf, "remaining capacity:", 19) == 0)
+                       } else if (strncmp(buf, "remaining capacity:", 19) == 0) {
                                sscanf(buf, "remaining capacity: %d", &remaining_capacity);
+                       }
                }
-
                /* Hellf[i]re notes that remaining capacity can exceed acpi_last_full */
-               if (remaining_capacity > acpi_last_full[idx])
-                       acpi_last_full[idx] = remaining_capacity;  /* normalize to 100% */
+               if (remaining_capacity > acpi_last_full[idx]) {
+                       /* normalize to 100% */
+                       acpi_last_full[idx] = remaining_capacity;
+               }
 
                /* not present */
                if (strcmp(present, "no") == 0) {
                        strncpy(last_battery_str[idx], "not present", 64);
-               }
                /* charging */
-               else if (strcmp(charging_state, "charging") == 0) {
+               } else if (strcmp(charging_state, "charging") == 0) {
                        if (acpi_last_full[idx] != 0 && present_rate > 0) {
                                /* e.g. charging 75% */
-                               snprintf(last_battery_str[idx], sizeof(last_battery_str[idx])-1, "charging %i%%",
+                               snprintf(last_battery_str[idx],
+                                       sizeof(last_battery_str[idx]) - 1, "charging %i%%",
                                        (int) ((remaining_capacity * 100) / acpi_last_full[idx]));
                                /* e.g. 2h 37m */
-                               format_seconds(last_battery_time_str[idx], sizeof(last_battery_time_str[idx])-1,
-                                             (long) (((acpi_last_full[idx] - remaining_capacity) * 3600) /
-                                                     present_rate));
+                               format_seconds(last_battery_time_str[idx],
+                                       sizeof(last_battery_time_str[idx]) - 1,
+                                       (long) (((acpi_last_full[idx] - remaining_capacity) *
+                                       3600) / present_rate));
                        } else if (acpi_last_full[idx] != 0 && present_rate <= 0) {
-                               snprintf(last_battery_str[idx], sizeof(last_battery_str[idx])-1, "charging %d%%",
+                               snprintf(last_battery_str[idx],
+                                       sizeof(last_battery_str[idx]) - 1, "charging %d%%",
                                        (int) ((remaining_capacity * 100) / acpi_last_full[idx]));
                        } else {
-                               strncpy(last_battery_str[idx], "charging", sizeof(last_battery_str[idx])-1);
+                               strncpy(last_battery_str[idx], "charging",
+                                       sizeof(last_battery_str[idx]) - 1);
                        }
-               }
                /* discharging */
-               else if (strncmp(charging_state, "discharging", 64) == 0) {
+               } else if (strncmp(charging_state, "discharging", 64) == 0) {
                        if (present_rate > 0) {
                                /* e.g. discharging 35% */
-                               snprintf(last_battery_str[idx], sizeof(last_battery_str[idx])-1, "discharging %i%%",
+                               snprintf(last_battery_str[idx],
+                                       sizeof(last_battery_str[idx]) - 1, "discharging %i%%",
                                        (int) ((remaining_capacity * 100) / acpi_last_full[idx]));
                                /* e.g. 1h 12m */
-                               format_seconds(last_battery_time_str[idx], sizeof(last_battery_time_str[idx])-1,
-                                             (long) ((remaining_capacity * 3600) / present_rate));
-                       } else if (present_rate == 0) { /* Thanks to Nexox for this one */
-                               snprintf(last_battery_str[idx], sizeof(last_battery_str[idx])-1, "full");
+                               format_seconds(last_battery_time_str[idx],
+                                       sizeof(last_battery_time_str[idx]) - 1,
+                                       (long) ((remaining_capacity * 3600) / present_rate));
+                       } else if (present_rate == 0) { /* Thanks to Nexox for this one */
+                               snprintf(last_battery_str[idx],
+                                       sizeof(last_battery_str[idx]) - 1, "full");
                        } else {
-                               snprintf(last_battery_str[idx], sizeof(last_battery_str[idx])-1,
-                                       "discharging %d%%",
+                               snprintf(last_battery_str[idx],
+                                       sizeof(last_battery_str[idx]) - 1, "discharging %d%%",
                                        (int) ((remaining_capacity * 100) / acpi_last_full[idx]));
                        }
-               }
                /* charged */
-               /* thanks to Lukas Zapletal <lzap@seznam.cz> */
-               else if (strncmp(charging_state, "charged", 64) == 0) {
-                               /* Below happens with the second battery on my X40,
-                                * when the second one is empty and the first one
-                                * being charged. */
-                               if (remaining_capacity == 0)
-                                       strcpy(last_battery_str[idx], "empty");
-                               else
-                                       strcpy(last_battery_str[idx], "charged");
-               }
+               } else if (strncmp(charging_state, "charged", 64) == 0) {
+                       /* thanks to Lukas Zapletal <lzap@seznam.cz> */
+                       /* Below happens with the second battery on my X40,
+                        * when the second one is empty and the first one being charged. */
+                       if (remaining_capacity == 0) {
+                               strcpy(last_battery_str[idx], "empty");
+                       } else {
+                               strcpy(last_battery_str[idx], "charged");
+                       }
                /* unknown, probably full / AC */
-               else {
+               } else {
                        if (acpi_last_full[idx] != 0
-                           && remaining_capacity != acpi_last_full[idx])
+                                       && remaining_capacity != acpi_last_full[idx]) {
                                snprintf(last_battery_str[idx], 64, "unknown %d%%",
                                        (int) ((remaining_capacity * 100) / acpi_last_full[idx]));
-                       else
+                       } else {
                                strncpy(last_battery_str[idx], "AC", 64);
+                       }
                }
        } else {
                /* APM */
-               if (apm_bat_fp[idx] == NULL)
+               if (apm_bat_fp[idx] == NULL) {
                        apm_bat_fp[idx] = open_file(APM_PATH, &rep2);
+               }
 
                if (apm_bat_fp[idx] != NULL) {
                        int ac, status, flag, life;
 
-                       fscanf(apm_bat_fp[idx],
-                              "%*s %*s %*x %x   %x       %x     %d%%",
-                              &ac, &status, &flag, &life);
+                       fscanf(apm_bat_fp[idx], "%*s %*s %*x %x   %x       %x     %d%%",
+                               &ac, &status, &flag, &life);
 
                        if (life == -1) {
                                /* could check now that there is ac */
                                snprintf(last_battery_str[idx], 64, "AC");
-                       } else if (ac && life != 100) { /* could check that status==3 here? */
-                               snprintf(last_battery_str[idx], 64,
-                                        "charging %d%%", life);
+
+                       /* could check that status == 3 here? */
+                       } else if (ac && life != 100) {
+                               snprintf(last_battery_str[idx], 64, "charging %d%%", life);
                        } else {
-                               snprintf(last_battery_str[idx], 64, "%d%%",
-                                        life);
+                               snprintf(last_battery_str[idx], 64, "%d%%", life);
                        }
 
-                       /* it seemed to buffer it so file must be closed (or could use syscalls
-                        * directly but I don't feel like coding it now) */
+                       /* it seemed to buffer it so file must be closed (or could use
+                        * syscalls directly but I don't feel like coding it now) */
                        fclose(apm_bat_fp[idx]);
                        apm_bat_fp[idx] = NULL;
                }
@@ -1469,20 +1525,15 @@ void get_battery_stuff(char *buf, unsigned int n, const char *bat, int item)
 
 set_return_value:
        switch (item) {
-        case BATTERY_STATUS:
-               {
-                       snprintf(buf, n, "%s", last_battery_str[idx]);
-                       break;
-               }
-        case BATTERY_TIME:
-               {
-                       snprintf(buf, n, "%s", last_battery_time_str[idx]);
-                       break;
-               }
-       default:
-                       break;
-        }
-       return;
+               case BATTERY_STATUS:
+                       snprintf(buf, n, "%s", last_battery_str[idx]);
+                       break;
+               case BATTERY_TIME:
+                       snprintf(buf, n, "%s", last_battery_time_str[idx]);
+                       break;
+               default:
+                       break;
+       }
 }
 
 int get_battery_perct(const char *bat)
@@ -1490,6 +1541,7 @@ int get_battery_perct(const char *bat)
        static int rep;
        int idx;
        char acpi_path[128];
+
        snprintf(acpi_path, 127, ACPI_BATTERY_BASE_PATH "/%s/state", bat);
 
        init_batteries();
@@ -1504,25 +1556,30 @@ int get_battery_perct(const char *bat)
 
        /* Only check for ACPI */
 
-       if (acpi_bat_fp[idx] == NULL && apm_bat_fp[idx] == NULL)
+       if (acpi_bat_fp[idx] == NULL && apm_bat_fp[idx] == NULL) {
                acpi_bat_fp[idx] = open_file(acpi_path, &rep);
+       }
 
        int remaining_capacity = -1;
+
        if (acpi_bat_fp[idx] != NULL) {
                /* read last full capacity if it's zero */
                if (acpi_design_capacity[idx] == 0) {
                        static int rep;
                        char path[128];
                        FILE *fp;
-                       snprintf(path, 127,
-                                ACPI_BATTERY_BASE_PATH "/%s/info", bat);
+
+                       snprintf(path, 127, ACPI_BATTERY_BASE_PATH "/%s/info", bat);
                        fp = open_file(path, &rep);
                        if (fp != NULL) {
                                while (!feof(fp)) {
                                        char b[256];
-                                       if (fgets(b, 256, fp) == NULL)
+
+                                       if (fgets(b, 256, fp) == NULL) {
                                                break;
-                                       if (sscanf(b, "last full capacity: %d", &acpi_design_capacity[idx]) != 0) {
+                                       }
+                                       if (sscanf(b, "last full capacity: %d",
+                                                       &acpi_design_capacity[idx]) != 0) {
                                                break;
                                        }
                                }
@@ -1534,32 +1591,34 @@ int get_battery_perct(const char *bat)
 
                while (!feof(acpi_bat_fp[idx])) {
                        char buf[256];
-                       if (fgets(buf, 256, acpi_bat_fp[idx]) == NULL)
+
+                       if (fgets(buf, 256, acpi_bat_fp[idx]) == NULL) {
                                break;
+                       }
 
-                       if (buf[0] == 'r')
-                               sscanf(buf, "remaining capacity: %d",
-                                      &remaining_capacity);
+                       if (buf[0] == 'r') {
+                               sscanf(buf, "remaining capacity: %d", &remaining_capacity);
+                       }
                }
        }
-       if(remaining_capacity < 0)
+       if (remaining_capacity < 0) {
                return 0;
+       }
        /* compute the battery percentage */
        last_battery_perct[idx] =
-               (int) (((float)remaining_capacity/acpi_design_capacity[idx]) * 100);
+               (int) (((float) remaining_capacity / acpi_design_capacity[idx]) * 100);
        return last_battery_perct[idx];
 }
 
 int get_battery_perct_bar(const char *bar)
 {
        int idx;
+
        get_battery_perct(bar);
        idx = get_battery_idx(bar);
        return (int) (last_battery_perct[idx] * 2.56 - 1);
 }
 
-
-
 /* On Apple powerbook and ibook:
 $ cat /proc/pmu/battery_0
 flags      : 00000013
@@ -1576,94 +1635,104 @@ Battery count          : 1
 */
 
 /* defines as in <linux/pmu.h> */
-#define PMU_BATT_PRESENT        0x00000001
-#define PMU_BATT_CHARGING       0x00000002
+#define PMU_BATT_PRESENT               0x00000001
+#define PMU_BATT_CHARGING              0x00000002
 
-static FILE* pmu_battery_fp;
-static FILE* pmu_info_fp;
+static FILE *pmu_battery_fp;
+static FILE *pmu_info_fp;
 static char pb_battery_info[3][32];
 static double pb_battery_info_update;
 
 #define PMU_PATH "/proc/pmu"
 void get_powerbook_batt_info(char *buf, size_t n, int i)
 {
-        static int rep = 0;
-        const char* batt_path = PMU_PATH "/battery_0";
-        const char* info_path = PMU_PATH "/info";
-        int flags, charge, max_charge, ac = -1;
-        long time = -1;
-
-        /* don't update battery too often */
-        if (current_update_time - pb_battery_info_update < 29.5) {
-                snprintf(buf, n, "%s", pb_battery_info[i]);
-                return;
-        }
-        pb_battery_info_update = current_update_time;
-
-        if (pmu_battery_fp == NULL)
-                pmu_battery_fp = open_file(batt_path, &rep);
-
-        if (pmu_battery_fp != NULL) {
-               rewind(pmu_battery_fp);
-                while (!feof(pmu_battery_fp)) {
-                        char buf[32];
-                        if (fgets(buf, sizeof(buf), pmu_battery_fp) == NULL)
-                                break;
-
-                        if (buf[0] == 'f')
-                                sscanf(buf, "flags      : %8x", &flags);
-                        else if (buf[0] == 'c' && buf[1] == 'h')
-                                sscanf(buf, "charge     : %d", &charge);
-                        else if (buf[0] == 'm')
-                                sscanf(buf, "max_charge : %d", &max_charge);
-                        else if (buf[0] == 't')
-                                sscanf(buf, "time rem.  : %ld", &time);
-                }
-        }
-        if (pmu_info_fp == NULL)
-                pmu_info_fp = open_file(info_path, &rep);
-
-        if (pmu_info_fp != NULL) {
-               rewind(pmu_info_fp);
-                while (!feof(pmu_info_fp)) {
-                        char buf[32];
-                        if (fgets(buf, sizeof(buf), pmu_info_fp) == NULL)
-                                break;
-                        if (buf[0] == 'A')
-                                sscanf(buf, "AC Power               : %d", &ac);
-                }
-        }
-        /* update status string */
-        if ((ac && !(flags & PMU_BATT_PRESENT)))
-                strcpy(pb_battery_info[PB_BATT_STATUS], "AC");
-        else if (ac && (flags & PMU_BATT_PRESENT)
-                  && !(flags & PMU_BATT_CHARGING))
-                strcpy(pb_battery_info[PB_BATT_STATUS], "charged");
-        else if ((flags & PMU_BATT_PRESENT)
-                && (flags & PMU_BATT_CHARGING))
-                strcpy(pb_battery_info[PB_BATT_STATUS], "charging");
-        else
-                strcpy(pb_battery_info[PB_BATT_STATUS], "discharging");
-
-        /* update percentage string */
-        if (time == 0)
-                pb_battery_info[PB_BATT_PERCENT][0] = 0;
-        else
-                snprintf(pb_battery_info[PB_BATT_PERCENT],
-                        sizeof(pb_battery_info[PB_BATT_PERCENT]),
-                        "%d%%", (charge * 100)/max_charge);
-
-        /* update time string */
-        if (time == 0) /* fully charged or battery not present */
-                pb_battery_info[PB_BATT_TIME][0] = 0;
-        else if (time < 60*60) /* don't show secs */
-                format_seconds_short(pb_battery_info[PB_BATT_TIME],
-                        sizeof(pb_battery_info[PB_BATT_TIME]), time);
-        else
-                format_seconds(pb_battery_info[PB_BATT_TIME],
-                        sizeof(pb_battery_info[PB_BATT_TIME]), time);
-
-        snprintf(buf, n, "%s", pb_battery_info[i]);
+       static int rep = 0;
+       const char *batt_path = PMU_PATH "/battery_0";
+       const char *info_path = PMU_PATH "/info";
+       int flags, charge, max_charge, ac = -1;
+       long time = -1;
+
+       /* don't update battery too often */
+       if (current_update_time - pb_battery_info_update < 29.5) {
+               snprintf(buf, n, "%s", pb_battery_info[i]);
+               return;
+       }
+       pb_battery_info_update = current_update_time;
+
+       if (pmu_battery_fp == NULL) {
+               pmu_battery_fp = open_file(batt_path, &rep);
+       }
+
+       if (pmu_battery_fp != NULL) {
+               rewind(pmu_battery_fp);
+               while (!feof(pmu_battery_fp)) {
+                       char buf[32];
+
+                       if (fgets(buf, sizeof(buf), pmu_battery_fp) == NULL) {
+                               break;
+                       }
+
+                       if (buf[0] == 'f') {
+                               sscanf(buf, "flags      : %8x", &flags);
+                       } else if (buf[0] == 'c' && buf[1] == 'h') {
+                               sscanf(buf, "charge     : %d", &charge);
+                       } else if (buf[0] == 'm') {
+                               sscanf(buf, "max_charge : %d", &max_charge);
+                       } else if (buf[0] == 't') {
+                               sscanf(buf, "time rem.  : %ld", &time);
+                       }
+               }
+       }
+       if (pmu_info_fp == NULL) {
+               pmu_info_fp = open_file(info_path, &rep);
+       }
+
+       if (pmu_info_fp != NULL) {
+               rewind(pmu_info_fp);
+               while (!feof(pmu_info_fp)) {
+                       char buf[32];
+
+                       if (fgets(buf, sizeof(buf), pmu_info_fp) == NULL) {
+                               break;
+                       }
+                       if (buf[0] == 'A') {
+                               sscanf(buf, "AC Power               : %d", &ac);
+                       }
+               }
+       }
+       /* update status string */
+       if ((ac && !(flags & PMU_BATT_PRESENT))) {
+               strcpy(pb_battery_info[PB_BATT_STATUS], "AC");
+       } else if (ac && (flags & PMU_BATT_PRESENT)
+                       && !(flags & PMU_BATT_CHARGING)) {
+               strcpy(pb_battery_info[PB_BATT_STATUS], "charged");
+       } else if ((flags & PMU_BATT_PRESENT) && (flags & PMU_BATT_CHARGING)) {
+               strcpy(pb_battery_info[PB_BATT_STATUS], "charging");
+       } else {
+               strcpy(pb_battery_info[PB_BATT_STATUS], "discharging");
+       }
+
+       /* update percentage string */
+       if (time == 0) {
+               pb_battery_info[PB_BATT_PERCENT][0] = 0;
+       } else {
+               snprintf(pb_battery_info[PB_BATT_PERCENT],
+                       sizeof(pb_battery_info[PB_BATT_PERCENT]), "%d%%",
+                       (charge * 100) / max_charge);
+       }
+
+       /* update time string */
+       if (time == 0) {                        /* fully charged or battery not present */
+               pb_battery_info[PB_BATT_TIME][0] = 0;
+       } else if (time < 60 * 60) {    /* don't show secs */
+               format_seconds_short(pb_battery_info[PB_BATT_TIME],
+                       sizeof(pb_battery_info[PB_BATT_TIME]), time);
+       } else {
+               format_seconds(pb_battery_info[PB_BATT_TIME],
+                       sizeof(pb_battery_info[PB_BATT_TIME]), time);
+       }
+
+       snprintf(buf, n, "%s", pb_battery_info[i]);
 }
 
 void update_top()
@@ -1673,13 +1742,10 @@ void update_top()
        info.first_process = get_first_process();
 }
 
-
-/*
- *  The following ifdefs were adapted from gkrellm
- */
+/* The following ifdefs were adapted from gkrellm */
 #include <linux/major.h>
 
-#if ! defined (MD_MAJOR)
+#if !defined(MD_MAJOR)
 #define MD_MAJOR 9
 #endif
 
@@ -1694,38 +1760,36 @@ void update_top()
 void update_diskio()
 {
        static unsigned int last = UINT_MAX;
-       static unsigned int last_read = UINT_MAX;
-       static unsigned int last_write = UINT_MAX;
-       FILE* fp;
-       static int rep=0;
+       static unsigned int last_read = UINT_MAX;
+       static unsigned int last_write = UINT_MAX;
+       FILE *fp;
+       static int rep = 0;
 
        char buf[512], devbuf[64];
        int major, minor, i;
        unsigned int current = 0;
-       unsigned int current_read = 0;
-       unsigned int current_write = 0;
+       unsigned int current_read = 0;
+       unsigned int current_write = 0;
        unsigned int reads, writes = 0;
        int col_count = 0;
 
-       if (!(fp =open_file("/proc/diskstats", &rep))) {
-               diskio_value=0;
+       if (!(fp = open_file("/proc/diskstats", &rep))) {
+               diskio_value = 0;
                return;
        }
 
-       /* read reads and writes from all disks (minor = 0), including
-        * cd-roms and floppies, and summ them up
-        */
+       /* read reads and writes from all disks (minor = 0), including cd-roms
+        * and floppies, and sum them up */
        while (!feof(fp)) {
                fgets(buf, 512, fp);
-               col_count = sscanf(buf, "%u %u %s %*u %*u %u %*u %*u %*u %u",
-                                  &major, &minor, devbuf, &reads, &writes);
+               col_count = sscanf(buf, "%u %u %s %*u %*u %u %*u %*u %*u %u", &major,
+                       &minor, devbuf, &reads, &writes);
                /* ignore subdevices (they have only 3 matching entries in their line)
                 * and virtual devices (LVM, network block devices, RAM disks, Loopback)
                 *
-                * XXX ignore devices which are part of a SW RAID (MD_MAJOR)
-                */
-               if (col_count == 5 && major != LVM_BLK_MAJOR && major != NBD_MAJOR &&
-                   major != RAMDISK_MAJOR && major != LOOP_MAJOR) {
+                * XXX: ignore devices which are part of a SW RAID (MD_MAJOR) */
+               if (col_count == 5 && major != LVM_BLK_MAJOR && major != NBD_MAJOR
+                               && major != RAMDISK_MAJOR && major != LOOP_MAJOR) {
                        current += reads + writes;
                        current_read += reads;
                        current_write += writes;
@@ -1763,39 +1827,40 @@ void update_diskio()
                }
        }
 
-       /* since the values in /proc/diststats are absolute, we have
-        * to substract our last reading. The numbers stand for
-        * "sectors read", and we therefore have to divide by two to
-        * get KB */
-       int tot = ((double)(current-last)/2);
-       int tot_read = ((double)(current_read-last_read)/2);
-       int tot_write = ((double)(current_write-last_write)/2);
+       /* since the values in /proc/diststats are absolute, we have to substract
+        * our last reading. The numbers stand for "sectors read", and we therefore
+        * have to divide by two to get KB */
+       int tot = ((double) (current - last) / 2);
+       int tot_read = ((double) (current_read - last_read) / 2);
+       int tot_write = ((double) (current_write - last_write) / 2);
 
-       if (last_read > current_read)
-           tot_read = 0;
-       if (last_write > current_write)
-           tot_write = 0;
+       if (last_read > current_read) {
+               tot_read = 0;
+       }
+       if (last_write > current_write) {
+               tot_write = 0;
+       }
 
        if (last > current) {
-               /* we hit this either if it's the very first time we
-                 * run this, or when /proc/diskstats overflows; while
-                 * 0 is not correct, it's at least not way off */
+               /* we hit this either if it's the very first time we run this, or
+                * when /proc/diskstats overflows; while 0 is not correct, it's at
+                * least not way off */
                tot = 0;
        }
        last = current;
-       last_read = current_read;
-       last_write = current_write;
+       last_read = current_read;
+       last_write = current_write;
 
        diskio_value = tot;
-       diskio_read_value = tot_read;
-       diskio_write_value = tot_write;
+       diskio_read_value = tot_read;
+       diskio_write_value = tot_write;
 
        fclose(fp);
 }
 
 /* Here come the IBM ACPI-specific things. For reference, see
- http://ibm-acpi.sourceforge.net/README
-If IBM ACPI is installed, /proc/acpi/ibm contains the following files:
+ * http://ibm-acpi.sourceforge.net/README
+ * If IBM ACPI is installed, /proc/acpi/ibm contains the following files:
 bay
 beep
 bluetooth
@@ -1811,239 +1876,240 @@ light
 thermal
 video
 volume
-The content of these files is described in detail in the aforementioned
-README - some of them also in the following functions accessing them.
-Peter Tarjan (ptarjan@citromail.hu)
-*/
+ * The content of these files is described in detail in the aforementioned
+ * README - some of them also in the following functions accessing them.
+ * Peter Tarjan (ptarjan@citromail.hu) */
 
 #define IBM_ACPI_DIR "/proc/acpi/ibm"
 
-void get_ibm_acpi_fan( char * p_client_buffer, size_t client_buffer_size )
-{
 /* get fan speed on IBM/Lenovo laptops running the ibm acpi.
-   /proc/acpi/ibm/fan looks like this (3 lines):
+ * /proc/acpi/ibm/fan looks like this (3 lines):
 status:         disabled
 speed:          2944
 commands:       enable, disable
-Peter Tarjan (ptarjan@citromail.hu)
-*/
+ * Peter Tarjan (ptarjan@citromail.hu) */
 
-    if ( !p_client_buffer || client_buffer_size <= 0 )
-       return;
+void get_ibm_acpi_fan(char *p_client_buffer, size_t client_buffer_size)
+{
+       if (!p_client_buffer || client_buffer_size <= 0) {
+               return;
+       }
 
-    FILE *fp;
-    unsigned int speed=0;
-    char fan[128];
-    snprintf(fan, 127, "%s/fan",IBM_ACPI_DIR);
+       FILE *fp;
+       unsigned int speed = 0;
+       char fan[128];
 
-    fp = fopen(fan, "r");
-    if (fp != NULL)
-    {
-       while (!feof(fp))
-       {
-           char line[256];
-           if (fgets(line, 255, fp) == NULL) break;
-           if (sscanf(line, "speed: %d", &speed)) break;
-       }
-    }
-    else
-    {
-       CRIT_ERR("can't open '%s': %s\nYou are not using the IBM ACPI. Remove ibm* from your Conky config file.", fan, strerror(errno));
-    }
+       snprintf(fan, 127, "%s/fan", IBM_ACPI_DIR);
 
-    fclose(fp);
-    snprintf( p_client_buffer, client_buffer_size, "%d", speed );
-    return;
+       fp = fopen(fan, "r");
+       if (fp != NULL) {
+               while (!feof(fp)) {
+                       char line[256];
 
+                       if (fgets(line, 255, fp) == NULL) {
+                               break;
+                       }
+                       if (sscanf(line, "speed: %d", &speed)) {
+                               break;
+                       }
+               }
+       } else {
+               CRIT_ERR("can't open '%s': %s\nYou are not using the IBM ACPI. Remove "
+                       "ibm* from your Conky config file.", fan, strerror(errno));
+       }
+
+       fclose(fp);
+       snprintf(p_client_buffer, client_buffer_size, "%d", speed);
 }
 
+/* get the measured temperatures from the temperature sensors
+ * on IBM/Lenovo laptops running the ibm acpi.
+ * There are 8 values in /proc/acpi/ibm/thermal, and according to
+ * http://ibm-acpi.sourceforge.net/README
+ * these mean the following (at least on an IBM R51...)
+ * 0:  CPU (also on the T series laptops)
+ * 1:  Mini PCI Module (?)
+ * 2:  HDD (?)
+ * 3:  GPU (also on the T series laptops)
+ * 4:  Battery (?)
+ * 5:  N/A
+ * 6:  Battery (?)
+ * 7:  N/A
+ * I'm not too sure about those with the question mark, but the values I'm
+ * reading from *my* thermal file (on a T42p) look realistic for the
+ * hdd and the battery.
+ * #5 and #7 are always -128.
+ * /proc/acpi/ibm/thermal looks like this (1 line):
+temperatures:   41 43 31 46 33 -128 29 -128
+ * Peter Tarjan (ptarjan@citromail.hu) */
+
 static double last_ibm_acpi_temp_time;
 void get_ibm_acpi_temps()
 {
-/* get the measured temperatures from the temperature sensors
-   on IBM/Lenovo laptops running the ibm acpi.
-   There are 8 values in /proc/acpi/ibm/thermal, and according to
-   http://ibm-acpi.sourceforge.net/README
-   these mean the following (at least on an IBM R51...)
-0:  CPU (also on the T series laptops)
-1:  Mini PCI Module (?)
-2:  HDD (?)
-3:  GPU (also on the T series laptops)
-4:  Battery (?)
-5:  N/A
-6:  Battery (?)
-7:  N/A
-   I'm not too sure about those with the question mark, but the values I'm
-   reading from *my* thermal file (on a T42p) look realistic for the
-   hdd and the battery.
-   #5 and #7 are always -128.
-   /proc/acpi/ibm/thermal looks like this (1 line):
-temperatures:   41 43 31 46 33 -128 29 -128
-Peter Tarjan (ptarjan@citromail.hu)
-*/
 
-/*    don't update too often */
-    if (current_update_time - last_ibm_acpi_temp_time < 10.00)
-    {
-       return;
-    }
-    last_ibm_acpi_temp_time = current_update_time;
+       /* don't update too often */
+       if (current_update_time - last_ibm_acpi_temp_time < 10.00) {
+               return;
+       }
+       last_ibm_acpi_temp_time = current_update_time;
 
-/*    if ( !p_client_buffer || client_buffer_size <= 0 )
-      return; */
+       /* if (!p_client_buffer || client_buffer_size <= 0) {
+               return;
+       } */
 
-    FILE *fp;
+       FILE *fp;
 
-    char thermal[128];
-    snprintf(thermal, 127, "%s/thermal",IBM_ACPI_DIR);
-    fp = fopen(thermal, "r");
+       char thermal[128];
 
-    if (fp != NULL)
-    {
-       while (!feof(fp))
-       {
-           char line[256];
-           if (fgets(line, 255, fp) == NULL) break;
-           if (sscanf(line, "temperatures: %d %d %d %d %d %d %d %d",
-                      &ibm_acpi.temps[0], &ibm_acpi.temps[1],
-                      &ibm_acpi.temps[2], &ibm_acpi.temps[3],
-                      &ibm_acpi.temps[4], &ibm_acpi.temps[5],
-                      &ibm_acpi.temps[6], &ibm_acpi.temps[7])) break;
-       }
-    }
-    else
-    {
-       CRIT_ERR("can't open '%s': %s\nYou are not using the IBM ACPI. Remove ibm* from your Conky config file.", thermal, strerror(errno));
-    }
-
-    fclose(fp);
+       snprintf(thermal, 127, "%s/thermal", IBM_ACPI_DIR);
+       fp = fopen(thermal, "r");
 
-}
+       if (fp != NULL) {
+               while (!feof(fp)) {
+                       char line[256];
 
+                       if (fgets(line, 255, fp) == NULL) {
+                               break;
+                       }
+                       if (sscanf(line, "temperatures: %d %d %d %d %d %d %d %d",
+                                       &ibm_acpi.temps[0], &ibm_acpi.temps[1], &ibm_acpi.temps[2],
+                                       &ibm_acpi.temps[3], &ibm_acpi.temps[4], &ibm_acpi.temps[5],
+                                       &ibm_acpi.temps[6], &ibm_acpi.temps[7])) {
+                               break;
+                       }
+               }
+       } else {
+               CRIT_ERR("can't open '%s': %s\nYou are not using the IBM ACPI. Remove "
+                       "ibm* from your Conky config file.", thermal, strerror(errno));
+       }
 
-void get_ibm_acpi_volume( char * p_client_buffer, size_t client_buffer_size )
-{
+       fclose(fp);
+}
 
-       /* get volume (0-14) on IBM/Lenovo laptops running the ibm acpi.
-          "Volume" here is none of the mixer volumes, but a "master of masters"
-          volume adjusted by the IBM volume keys.
-          /proc/acpi/ibm/fan looks like this (4 lines):
+/* get volume (0-14) on IBM/Lenovo laptops running the ibm acpi.
+ * "Volume" here is none of the mixer volumes, but a "master of masters"
+ * volume adjusted by the IBM volume keys.
+ * /proc/acpi/ibm/fan looks like this (4 lines):
 level:          4
 mute:           off
 commands:       up, down, mute
 commands:       level <level> (<level> is 0-15)
-Peter Tarjan (ptarjan@citromail.hu)
-*/
+ * Peter Tarjan (ptarjan@citromail.hu) */
 
-       if ( !p_client_buffer || client_buffer_size <= 0 )
+void get_ibm_acpi_volume(char *p_client_buffer, size_t client_buffer_size)
+{
+       if (!p_client_buffer || client_buffer_size <= 0) {
                return;
+       }
 
        FILE *fp;
 
        char volume[128];
-       snprintf(volume, 127, "%s/volume",IBM_ACPI_DIR);
-       unsigned int vol=-1;
-       char mute[3]="";
+
+       snprintf(volume, 127, "%s/volume", IBM_ACPI_DIR);
+       unsigned int vol = -1;
+       char mute[3] = "";
 
        fp = fopen(volume, "r");
        if (fp != NULL) {
                while (!feof(fp)) {
                        char line[256];
                        unsigned int read_vol = -1;
-                       if (fgets(line, 255, fp) == NULL) break;
+
+                       if (fgets(line, 255, fp) == NULL) {
+                               break;
+                       }
                        if (sscanf(line, "level: %d", &read_vol)) {
                                vol = read_vol;
                                continue;
                        }
-                       if (sscanf(line, "mute: %s", mute)) break;
+                       if (sscanf(line, "mute: %s", mute)) {
+                               break;
+                       }
                }
-       }
-       else
-       {
-               CRIT_ERR("can't open '%s': %s\nYou are not using the IBM ACPI. Remove ibm* from your Conky config file.", volume, strerror(errno));
+       } else {
+               CRIT_ERR("can't open '%s': %s\nYou are not using the IBM ACPI. Remove "
+                       "ibm* from your Conky config file.", volume, strerror(errno));
        }
 
        fclose(fp);
 
-       if (strcmp(mute, "on")==0)
-       {
-               snprintf( p_client_buffer, client_buffer_size, "%s", "mute" );
+       if (strcmp(mute, "on") == 0) {
+               snprintf(p_client_buffer, client_buffer_size, "%s", "mute");
                return;
-       }
-       else
-       {
-               snprintf( p_client_buffer, client_buffer_size, "%d", vol );
+       } else {
+               snprintf(p_client_buffer, client_buffer_size, "%d", vol);
                return;
        }
-
 }
 
-/*static FILE *fp=NULL;*/
+/* static FILE *fp = NULL; */
 
-void get_ibm_acpi_brightness(char * p_client_buffer, size_t client_buffer_size)
-{
 /* get LCD brightness on IBM/Lenovo laptops running the ibm acpi.
-   /proc/acpi/ibm/brightness looks like this (3 lines):
+ * /proc/acpi/ibm/brightness looks like this (3 lines):
 level:          7
 commands:       up, down
 commands:       level <level> (<level> is 0-7)
-Peter Tarjan (ptarjan@citromail.hu)
-*/
+ * Peter Tarjan (ptarjan@citromail.hu) */
 
-    if ( !p_client_buffer || client_buffer_size <= 0 )
-       return;
+void get_ibm_acpi_brightness(char *p_client_buffer, size_t client_buffer_size)
+{
+       if (!p_client_buffer || client_buffer_size <= 0) {
+               return;
+       }
 
-    FILE *fp;
-    unsigned int brightness=0;
-    char filename[128];
-    snprintf(filename, 127, "%s/brightness",IBM_ACPI_DIR);
+       FILE *fp;
+       unsigned int brightness = 0;
+       char filename[128];
 
-    fp = fopen(filename, "r");
-    if (fp != NULL)
-    {
-       while (!feof(fp))
-       {
-           char line[256];
-           if (fgets(line, 255, fp) == NULL) break;
-           if (sscanf(line, "level: %d", &brightness)) break;
-       }
-    }
-    else
-    {
-       CRIT_ERR("can't open '%s': %s\nYou are not using the IBM ACPI. Remove ibm* from your Conky config file.", filename, strerror(errno));
-    }
+       snprintf(filename, 127, "%s/brightness", IBM_ACPI_DIR);
+
+       fp = fopen(filename, "r");
+       if (fp != NULL) {
+               while (!feof(fp)) {
+                       char line[256];
 
-    fclose(fp);
+                       if (fgets(line, 255, fp) == NULL) {
+                               break;
+                       }
+                       if (sscanf(line, "level: %d", &brightness)) {
+                               break;
+                       }
+               }
+       } else {
+               CRIT_ERR("can't open '%s': %s\nYou are not using the IBM ACPI. Remove "
+                       "ibm* from your Conky config file.", filename, strerror(errno));
+       }
 
-    snprintf( p_client_buffer, client_buffer_size, "%d", brightness );
-    return;
+       fclose(fp);
 
+       snprintf(p_client_buffer, client_buffer_size, "%d", brightness);
 }
 
-void update_entropy (void)
+void update_entropy(void)
 {
-  static int rep = 0;
-  const char *entropy_avail = "/proc/sys/kernel/random/entropy_avail";
-  const char *entropy_poolsize = "/proc/sys/kernel/random/poolsize";
-  FILE *fp1, *fp2;
+       static int rep = 0;
+       const char *entropy_avail = "/proc/sys/kernel/random/entropy_avail";
+       const char *entropy_poolsize = "/proc/sys/kernel/random/poolsize";
+       FILE *fp1, *fp2;
 
-  info.entropy.entropy_avail=0;
-  info.entropy.poolsize=0;
+       info.entropy.entropy_avail = 0;
+       info.entropy.poolsize = 0;
 
-  if ((fp1 = open_file (entropy_avail, &rep))==NULL)
-    return;
+       if ((fp1 = open_file(entropy_avail, &rep)) == NULL) {
+               return;
+       }
 
-  if ((fp2 = open_file (entropy_poolsize, &rep))==NULL)
-  {
-    fclose (fp1);
-    return;
-  }
+       if ((fp2 = open_file(entropy_poolsize, &rep)) == NULL) {
+               fclose(fp1);
+               return;
+       }
 
-  fscanf (fp1, "%u", &info.entropy.entropy_avail);
-  fscanf (fp2, "%u", &info.entropy.poolsize);
+       fscanf(fp1, "%u", &info.entropy.entropy_avail);
+       fscanf(fp2, "%u", &info.entropy.poolsize);
 
-  fclose (fp1);
-  fclose (fp2);
+       fclose(fp1);
+       fclose(fp2);
 
-  info.mask |= (1 << INFO_ENTROPY);
+       info.mask |= (1 << INFO_ENTROPY);
 }
index a7f0fd1..182a3eb 100644 (file)
@@ -1,5 +1,4 @@
-/*
- * Conky, a system monitor, based on torsmo
+/* Conky, a system monitor, based on torsmo
  *
  * Any original torsmo code is licensed under the BSD license
  *
@@ -8,7 +7,8 @@
  * Please see COPYING for details
  *
  * Copyright (c) 2004, Hannu Saransaari and Lauri Hakkarainen
- * Copyright (c) 2005-2007 Brenden Matthews, Philip Kovacs, et. al. (see AUTHORS)
+ * Copyright (c) 2005-2007 Brenden Matthews, Philip Kovacs, et. al.
+ *     (see AUTHORS)
  * All rights reserved.
  *
  * This program is free software: you can redistribute it and/or modify
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  * GNU General Public License for more details.
  * You should have received a copy of the GNU General Public License
- * along with this program.  If not, see <http://www.gnu.org/licenses/>. 
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
  *
- *  $Id$
- */
+ * $Id$ */
 
 #include <sys/stat.h>
 #include <sys/time.h>
@@ -42,22 +41,24 @@ void update_mail_count(struct local_mail_s *mail)
 {
        struct stat buf;
 
-       if (mail == NULL)
+       if (mail == NULL) {
                return;
+       }
 
        /* TODO: use that fine file modification notify on Linux 2.4 */
 
        /* don't check mail so often (9.5s is minimum interval) */
-       if (current_update_time - mail->last_update < 9.5)
+       if (current_update_time - mail->last_update < 9.5) {
                return;
-       else
+       } else {
                mail->last_update = current_update_time;
+       }
 
        if (stat(mail->box, &buf)) {
                static int rep;
+
                if (!rep) {
-                       ERR("can't stat %s: %s", mail->box,
-                           strerror(errno));
+                       ERR("can't stat %s: %s", mail->box, strerror(errno));
                        rep = 1;
                }
                return;
@@ -70,9 +71,7 @@ void update_mail_count(struct local_mail_s *mail)
                struct dirent *dirent;
 
                mail->mail_count = mail->new_mail_count = 0;
-               dirname =
-                   (char *) malloc(sizeof(char) *
-                                   (strlen(mail->box) + 5));
+               dirname = (char *) malloc(sizeof(char) * (strlen(mail->box) + 5));
                if (!dirname) {
                        ERR("malloc");
                        return;
@@ -135,43 +134,46 @@ void update_mail_count(struct local_mail_s *mail)
                mail->new_mail_count = mail->mail_count = 0;
 
                fp = open_file(mail->box, &rep);
-               if (!fp)
+               if (!fp) {
                        return;
+               }
 
                /* NOTE: adds mail as new if there isn't Status-field at all */
 
                while (!feof(fp)) {
                        char buf[128];
-                       if (fgets(buf, 128, fp) == NULL)
+
+                       if (fgets(buf, 128, fp) == NULL) {
                                break;
+                       }
 
                        if (strncmp(buf, "From ", 5) == 0) {
                                /* ignore MAILER-DAEMON */
-                               if (strncmp(buf + 5, "MAILER-DAEMON ", 14)
-                                   != 0) {
+                               if (strncmp(buf + 5, "MAILER-DAEMON ", 14) != 0) {
                                        mail->mail_count++;
 
-                                       if (reading_status)
+                                       if (reading_status) {
                                                mail->new_mail_count++;
-                                       else
+                                       } else {
                                                reading_status = 1;
+                                       }
                                }
                        } else {
                                if (reading_status
-                                   && strncmp(buf, "X-Mozilla-Status:",
-                                              17) == 0) {
+                                               && strncmp(buf, "X-Mozilla-Status:", 17) == 0) {
                                        /* check that mail isn't already read */
-                                       if (strchr(buf + 21, '0'))
+                                       if (strchr(buf + 21, '0')) {
                                                mail->new_mail_count++;
+                                       }
 
                                        reading_status = 0;
                                        continue;
                                }
-                               if (reading_status
-                                   && strncmp(buf, "Status:", 7) == 0) {
+                               if (reading_status && strncmp(buf, "Status:", 7) == 0) {
                                        /* check that mail isn't already read */
-                                       if (strchr(buf + 7, 'R') == NULL)
+                                       if (strchr(buf + 7, 'R') == NULL) {
                                                mail->new_mail_count++;
+                                       }
 
                                        reading_status = 0;
                                        continue;
@@ -179,14 +181,16 @@ void update_mail_count(struct local_mail_s *mail)
                        }
 
                        /* skip until \n */
-                       while (strchr(buf, '\n') == NULL && !feof(fp))
+                       while (strchr(buf, '\n') == NULL && !feof(fp)) {
                                fgets(buf, 128, fp);
+                       }
                }
 
                fclose(fp);
 
-               if (reading_status)
+               if (reading_status) {
                        mail->new_mail_count++;
+               }
 
                mail->last_mtime = buf.st_mtime;
        }
index f721470..2d4030e 100644 (file)
@@ -1,5 +1,4 @@
-/*
- * Conky, a system monitor, based on torsmo
+/* Conky, a system monitor, based on torsmo
  *
  * Any original torsmo code is licensed under the BSD license
  *
@@ -8,7 +7,8 @@
  * Please see COPYING for details
  *
  * Copyright (c) 2006 Marco Candrian <mac@calmar.ws>
- * Copyright (c) 2005-2007 Brenden Matthews, Philip Kovacs, et. al. (see AUTHORS)
+ * Copyright (c) 2005-2007 Brenden Matthews, Philip Kovacs, et. al.
+ *     (see AUTHORS)
  * All rights reserved.
  *
  * This program is free software: you can redistribute it and/or modify
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  * GNU General Public License for more details.
  * You should have received a copy of the GNU General Public License
- * along with this program.  If not, see <http://www.gnu.org/licenses/>. 
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
  *
- *  $Id$
- */
+ * $Id$ */
 
 #include "conky.h"
 #include <sys/stat.h>
@@ -57,23 +56,20 @@ static int subject_width;
 static int print_mails;
 static int time_delay;
 
-/*
- * I don't know what to use: TEXT_BUFFER_SIZE or text_buffer_size
+/* I don't know what to use: TEXT_BUFFER_SIZE or text_buffer_size
  * text_buffer_size is the maximum output in chars
- * TEXT_BUFFER_SIZE actually something like a allowed size
- * for things in the config, below 'TEXT'. Or what is more probably
- * max_user_text. Anyway, I used TEXT_BUFFER_SIZE for not 'output' things here
+ * TEXT_BUFFER_SIZE actually something like a allowed size for things in the
+ * config, below 'TEXT'. Or what is more probably max_user_text.
+ * Anyway, I used TEXT_BUFFER_SIZE for not 'output' things here
  * -- calmar
  *
- *  To clarify, TEXT_BUFFER_SIZE is used for buffers of fixed size, and 
- *  text_buffer_size is used for buffers which can change in size.
- *  text_buffer_size is just defined as TEXT_BUFFER_SIZE to start,
- *  so its okay for most things, however if something is allocated
- *  with text_buffer_size and then text_buffer_size changes but
- *  the array doesn't, you might have some issues if you are using
- *  text_buffer_size to determine the size of the array.
- *  -- brenden
- */
+ * To clarify, TEXT_BUFFER_SIZE is used for buffers of fixed size, and
+ * text_buffer_size is used for buffers which can change in size.
+ * text_buffer_size is just defined as TEXT_BUFFER_SIZE to start, so it's okay
+ * for most things, however if something is allocated with text_buffer_size and
+ * then text_buffer_size changes but the array doesn't, you might have some
+ * issues if you are using text_buffer_size to determine the size of the array.
+ * -- brenden */
 
 static char mbox_mail_spool[TEXT_BUFFER_SIZE];
 
@@ -94,6 +90,7 @@ void mbox_scan(char *args, char *output, size_t max_len)
        if (!args_ok || force_rescan) {
 
                char *substr = strstr(args, "-n");
+
                if (substr) {
                        if (sscanf(substr, "-n %i", &print_mails) != 1) {
                                print_mails = PRINT_MAILS;
@@ -101,8 +98,9 @@ void mbox_scan(char *args, char *output, size_t max_len)
                } else {
                        print_mails = PRINT_MAILS;
                }
-               if (print_mails < 1)
+               if (print_mails < 1) {
                        print_mails = 1;
+               }
 
                substr = strstr(args, "-t");
                if (substr) {
@@ -134,12 +132,14 @@ void mbox_scan(char *args, char *output, size_t max_len)
                if (args[strlen(args) - 1] == '"') {
                        strncpy(mbox_mail_spool, args, TEXT_BUFFER_SIZE);
                        char *start = strchr(mbox_mail_spool, '"') + 1;
-                       start[(long)(strrchr(mbox_mail_spool, '"') - start)] = '\0';
+
+                       start[(long) (strrchr(mbox_mail_spool, '"') - start)] = '\0';
                        strncpy(mbox_mail_spool, start, TEXT_BUFFER_SIZE);
                } else {
                        char *copy_args = strdup(args);
                        char *tmp = strtok(copy_args, " ");
                        char *start = tmp;
+
                        while (tmp) {
                                tmp = strtok(NULL, " ");
                                if (tmp) {
@@ -150,7 +150,9 @@ void mbox_scan(char *args, char *output, size_t max_len)
                        free(copy_args);
                }
                if (strlen(mbox_mail_spool) < 1) {
-                       CRIT_ERR("Usage: ${mboxscan [-n <number of messages to print>] [-fw <from width>] [-sw <subject width>] [-t <delay in sec> mbox]}");
+                       CRIT_ERR("Usage: ${mboxscan [-n <number of messages to print>] "
+                               "[-fw <from width>] [-sw <subject width>] "
+                               "[-t <delay in sec> mbox]}");
                }
 
                /* allowing $MAIL in the config */
@@ -165,8 +167,9 @@ void mbox_scan(char *args, char *output, size_t max_len)
        }
 
        /* if time_delay not yet reached, then return */
-       if (current_update_time - last_update < time_delay && !force_rescan)
+       if (current_update_time - last_update < time_delay && !force_rescan) {
                return;
+       }
 
        last_update = current_update_time;
 
@@ -178,25 +181,28 @@ void mbox_scan(char *args, char *output, size_t max_len)
        }
 
        /* modification time has not changed, so skip scanning the box */
-       if (statbuf.st_ctime == last_ctime && statbuf.st_mtime == last_mtime && !force_rescan) {
+       if (statbuf.st_ctime == last_ctime && statbuf.st_mtime == last_mtime
+                       && !force_rescan) {
                return;
        }
 
        last_ctime = statbuf.st_ctime;
        last_mtime = statbuf.st_mtime;
 
-       /* build up double-linked ring-list to hold data, while scanning down * the mbox */
+       /* build up double-linked ring-list to hold data, while scanning down the
+        * mbox */
        struct ring_list *curr = 0, *prev = 0, *startlist = 0;
 
        for (i = 0; i < print_mails; i++) {
-               curr = (struct ring_list *)malloc(sizeof(struct ring_list));
-               curr->from = (char *)malloc(sizeof(char[from_width + 1]));
-               curr->subject = (char *)malloc(sizeof(char[subject_width + 1]));
+               curr = (struct ring_list *) malloc(sizeof(struct ring_list));
+               curr->from = (char *) malloc(sizeof(char[from_width + 1]));
+               curr->subject = (char *) malloc(sizeof(char[subject_width + 1]));
                curr->from[0] = '\0';
                curr->subject[0] = '\0';
 
-               if (i == 0)
+               if (i == 0) {
                        startlist = curr;
+               }
                if (i > 0) {
                        curr->previous = prev;
                        prev->next = curr;
@@ -216,17 +222,20 @@ void mbox_scan(char *args, char *output, size_t max_len)
                return;
        }
 
-       flag = 1;               /* first find a "From " to set it to 0 for header-sarchings */
+       /* first find a "From " to set it to 0 for header-sarchings */
+       flag = 1;
        while (!feof(fp)) {
-               if (fgets(buf, text_buffer_size, fp) == NULL)
+               if (fgets(buf, text_buffer_size, fp) == NULL) {
                        break;
+               }
 
                if (strncmp(buf, "From ", 5) == 0) {
                        curr = curr->next;
 
                        /* skip until \n */
-                       while (strchr(buf, '\n') == NULL && !feof(fp))
+                       while (strchr(buf, '\n') == NULL && !feof(fp)) {
                                fgets(buf, text_buffer_size, fp);
+                       }
 
                        flag = 0;       /* in the headers now */
                        continue;
@@ -240,23 +249,26 @@ void mbox_scan(char *args, char *output, size_t max_len)
                        /* beyond the headers now (empty line), skip until \n */
                        /* then search for new mail ("From ") */
 
-                       while (strchr(buf, '\n') == NULL && !feof(fp))
+                       while (strchr(buf, '\n') == NULL && !feof(fp)) {
                                fgets(buf, text_buffer_size, fp);
+                       }
                        flag = 1;       /* in the body now */
                        continue;
                }
 
                if ((strncmp(buf, "X-Status: ", 10) == 0)
-                   || (strncmp(buf, "Status: R", 9) == 0)) {
+                               || (strncmp(buf, "Status: R", 9) == 0)) {
 
                        /* Mail was read or something, so skip that message */
                        flag = 1;       /* search for next From */
                        curr->subject[0] = '\0';
                        curr->from[0] = '\0';
-                       curr = curr->previous;  /* (will get current again on new * 'From ' finding) */
+                       /* (will get current again on new 'From ' finding) */
+                       curr = curr->previous;
                        /* Skip until \n */
-                       while (strchr(buf, '\n') == NULL && !feof(fp))
+                       while (strchr(buf, '\n') == NULL && !feof(fp)) {
                                fgets(buf, text_buffer_size, fp);
+                       }
                        continue;
                }
 
@@ -272,12 +284,14 @@ void mbox_scan(char *args, char *output, size_t max_len)
                                        continue;
                                }
 
-                               if (buf[u] == '<' && i > 1) {   /* some are: From: * <foo@bar.com> */
+                               /* some are: From: <foo@bar.com> */
+                               if (buf[u] == '<' && i > 1) {
 
                                        curr->from[i] = '\0';
                                        /* skip until \n */
-                                       while (strchr(buf, '\n') == NULL && !feof(fp))
+                                       while (strchr(buf, '\n') == NULL && !feof(fp)) {
                                                fgets(buf, text_buffer_size, fp);
+                                       }
                                        break;
                                }
 
@@ -294,8 +308,9 @@ void mbox_scan(char *args, char *output, size_t max_len)
                                if (i >= from_width) {
                                        curr->from[i] = '\0';
                                        /* skip until \n */
-                                       while (strchr(buf, '\n') == NULL && !feof(fp))
+                                       while (strchr(buf, '\n') == NULL && !feof(fp)) {
                                                fgets(buf, text_buffer_size, fp);
+                                       }
                                        break;
                                }
 
@@ -323,8 +338,9 @@ void mbox_scan(char *args, char *output, size_t max_len)
                                        curr->subject[i] = '\0';
 
                                        /* skip until \n */
-                                       while (strchr(buf, '\n') == NULL && !feof(fp))
+                                       while (strchr(buf, '\n') == NULL && !feof(fp)) {
                                                fgets(buf, text_buffer_size, fp);
+                                       }
                                        break;
                                }
 
@@ -332,22 +348,23 @@ void mbox_scan(char *args, char *output, size_t max_len)
                                curr->subject[i++] = buf[u++];
                        }
                }
-
        }
 
        fclose(fp);
 
        output[0] = '\0';
        struct ring_list *tmp;
+
        i = print_mails;
        while (i) {
                if (curr->from[0] != '\0') {
                        if (i != print_mails) {
-                               snprintf(buf, text_buffer_size, "\nF: %-*s S: %-*s", from_width, curr->from, subject_width, curr->subject);
+                               snprintf(buf, text_buffer_size, "\nF: %-*s S: %-*s", from_width,
+                                       curr->from, subject_width, curr->subject);
                        } else {        /* first time - no \n in front */
-                               snprintf(buf, text_buffer_size, "F: %-*s S: %-*s", from_width, curr->from, subject_width, curr->subject);
+                               snprintf(buf, text_buffer_size, "F: %-*s S: %-*s", from_width,
+                                       curr->from, subject_width, curr->subject);
                        }
-
                } else {
                        snprintf(buf, text_buffer_size, "\n");
                }
index e539f30..0d3c601 100644 (file)
@@ -1,5 +1,4 @@
-/*
- * Conky, a system monitor, based on torsmo
+/* Conky, a system monitor, based on torsmo
  *
  * Any original torsmo code is licensed under the BSD license
  *
@@ -8,7 +7,8 @@
  * Please see COPYING for details
  *
  * Copyright (c) 2006 Marco Candrian <mac@calmar.ws>
- * Copyright (c) 2005-2007 Brenden Matthews, Philip Kovacs, et. al. (see AUTHORS)
+ * Copyright (c) 2005-2007 Brenden Matthews, Philip Kovacs, et. al.
+ *     (see AUTHORS)
  * All rights reserved.
  *
  * This program is free software: you can redistribute it and/or modify
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  * GNU General Public License for more details.
  * You should have received a copy of the GNU General Public License
- * along with this program.  If not, see <http://www.gnu.org/licenses/>. 
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
  *
- *  $Id$
- */
+ * $Id$ */
 
 #ifndef _MBOXSCAN_H_
 #define _MBOXSCAN_H_
index 512a197..4c001ee 100644 (file)
@@ -1,5 +1,4 @@
-/*
- * Conky, a system monitor, based on torsmo
+/* Conky, a system monitor, based on torsmo
  *
  * Any original torsmo code is licensed under the BSD license
  *
@@ -8,7 +7,8 @@
  * Please see COPYING for details
  *
  * Copyright (c) 2004, Hannu Saransaari and Lauri Hakkarainen
- * Copyright (c) 2005-2007 Brenden Matthews, Philip Kovacs, et. al. (see AUTHORS)
+ * Copyright (c) 2005-2007 Brenden Matthews, Philip Kovacs, et. al.
+ *     (see AUTHORS)
  * All rights reserved.
  *
  * This program is free software: you can redistribute it and/or modify
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  * GNU General Public License for more details.
  * You should have received a copy of the GNU General Public License
- * along with this program.  If not, see <http://www.gnu.org/licenses/>. 
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
  *
- *  $Id$
- */
+ * $Id$ */
 
 #include <sys/ioctl.h>
 
@@ -42,8 +41,8 @@
 #include <soundcard.h>
 #else
 #include <sys/soundcard.h>
-#endif                         /* __OpenBSD__ */
-#endif                         /* HAVE_LINUX_SOUNDCARD_H */
+#endif /* __OpenBSD__ */
+#endif /* HAVE_LINUX_SOUNDCARD_H */
 
 #define MIXER_DEV "/dev/mixer"
 
@@ -54,15 +53,15 @@ int mixer_init(const char *name)
 {
        unsigned int i;
 
-       if (name == 0 || name[0] == '\0')
+       if (name == 0 || name[0] == '\0') {
                name = "vol";
+       }
 
        /* open mixer */
        if (mixer_fd <= 0) {
                mixer_fd = open(MIXER_DEV, O_RDONLY);
                if (mixer_fd == -1) {
-                       ERR("can't open %s: %s", MIXER_DEV,
-                           strerror(errno));
+                       ERR("can't open %s: %s", MIXER_DEV, strerror(errno));
                        return -1;
                }
        }
@@ -82,8 +81,9 @@ static int mixer_get(int i)
        int val = -1;
 
        if (ioctl(mixer_fd, MIXER_READ(i), &val) == -1) {
-               if (!rep)
+               if (!rep) {
                        ERR("mixer ioctl: %s", strerror(errno));
+               }
                rep = 1;
                return 0;
        }
@@ -95,6 +95,7 @@ static int mixer_get(int i)
 int mixer_get_avg(int i)
 {
        int v = mixer_get(i);
+
        return ((v >> 8) + (v & 0xFF)) / 2;
 }
 
index 4ac578a..e055dc3 100644 (file)
--- a/src/mpd.c
+++ b/src/mpd.c
@@ -1,5 +1,4 @@
-/*
- * Conky, a system monitor, based on torsmo
+/* Conky, a system monitor, based on torsmo
  *
  * Any original torsmo code is licensed under the BSD license
  *
@@ -7,7 +6,8 @@
  *
  * Please see COPYING for details
  *
- * Copyright (c) 2005-2007 Brenden Matthews, Philip Kovacs, et. al. (see AUTHORS)
+ * Copyright (c) 2005-2007 Brenden Matthews, Philip Kovacs, et. al.
+ *     (see AUTHORS)
  * All rights reserved.
  *
  * This program is free software: you can redistribute it and/or modify
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  * GNU General Public License for more details.
  * You should have received a copy of the GNU General Public License
- * along with this program.  If not, see <http://www.gnu.org/licenses/>. 
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
  *
- *  $Id$
- */
+ * $Id$ */
 
 #include "conky.h"
 #include <stdio.h>
 #include "libmpdclient.h"
 
 timed_thread *mpd_timed_thread = NULL;
+
 void clear_mpd_stats(struct information *current_info);
 
 void init_mpd_stats(struct information *current_info)
 {
-       if (current_info->mpd.artist == NULL)
+       if (current_info->mpd.artist == NULL) {
                current_info->mpd.artist = malloc(TEXT_BUFFER_SIZE);
-       if (current_info->mpd.album == NULL)
+       }
+       if (current_info->mpd.album == NULL) {
                current_info->mpd.album = malloc(TEXT_BUFFER_SIZE);
-       if (current_info->mpd.title == NULL)
+       }
+       if (current_info->mpd.title == NULL) {
                current_info->mpd.title = malloc(TEXT_BUFFER_SIZE);
-       if (current_info->mpd.random == NULL)
+       }
+       if (current_info->mpd.random == NULL) {
                current_info->mpd.random = malloc(TEXT_BUFFER_SIZE);
-       if (current_info->mpd.repeat == NULL)
+       }
+       if (current_info->mpd.repeat == NULL) {
                current_info->mpd.repeat = malloc(TEXT_BUFFER_SIZE);
-       if (current_info->mpd.track == NULL)
+       }
+       if (current_info->mpd.track == NULL) {
                current_info->mpd.track = malloc(TEXT_BUFFER_SIZE);
-       if (current_info->mpd.status == NULL)
+       }
+       if (current_info->mpd.status == NULL) {
                current_info->mpd.status = malloc(TEXT_BUFFER_SIZE);
-       if (current_info->mpd.name == NULL)
+       }
+       if (current_info->mpd.name == NULL) {
                current_info->mpd.name = malloc(TEXT_BUFFER_SIZE);
-       if (current_info->mpd.file == NULL)
+       }
+       if (current_info->mpd.file == NULL) {
                current_info->mpd.file = malloc(TEXT_BUFFER_SIZE);
+       }
        clear_mpd_stats(current_info);
 }
 
 void clear_mpd_stats(struct information *current_info)
 {
-       *current_info->mpd.name=0;
-       *current_info->mpd.file=0;
-       *current_info->mpd.artist=0;
-       *current_info->mpd.album=0;
-       *current_info->mpd.title=0;
-       *current_info->mpd.random=0;
-       *current_info->mpd.repeat=0;
-       *current_info->mpd.track=0;
-       *current_info->mpd.status=0;
+       *current_info->mpd.name = 0;
+       *current_info->mpd.file = 0;
+       *current_info->mpd.artist = 0;
+       *current_info->mpd.album = 0;
+       *current_info->mpd.title = 0;
+       *current_info->mpd.random = 0;
+       *current_info->mpd.repeat = 0;
+       *current_info->mpd.track = 0;
+       *current_info->mpd.status = 0;
        current_info->mpd.bitrate = 0;
        current_info->mpd.progress = 0;
        current_info->mpd.elapsed = 0;
@@ -77,80 +86,89 @@ void clear_mpd_stats(struct information *current_info)
 void *update_mpd(void)
 {
        struct information *current_info = &info;
+
        while (1) {
                if (!current_info->conn) {
-                       current_info->conn = mpd_newConnection(current_info->mpd.host, current_info->mpd.port, 10);
+                       current_info->conn = mpd_newConnection(current_info->mpd.host,
+                               current_info->mpd.port, 10);
                }
                if (strlen(current_info->mpd.password) > 1) {
                        mpd_sendPasswordCommand(current_info->conn,
-                                       current_info->mpd.password);
+                               current_info->mpd.password);
                        mpd_finishCommand(current_info->conn);
                }
-               
+
                timed_thread_lock(mpd_timed_thread);
 
                if (current_info->conn->error || current_info->conn == NULL) {
-                       //ERR("%MPD error: s\n", current_info->conn->errorStr);
+                       // ERR("%MPD error: s\n", current_info->conn->errorStr);
                        mpd_closeConnection(current_info->conn);
                        current_info->conn = 0;
                        clear_mpd_stats(current_info);
 
-                       strncpy(current_info->mpd.status, "MPD not responding", TEXT_BUFFER_SIZE - 1);
+                       strncpy(current_info->mpd.status, "MPD not responding",
+                               TEXT_BUFFER_SIZE - 1);
                        timed_thread_unlock(mpd_timed_thread);
-                       if (timed_thread_test(mpd_timed_thread)) timed_thread_exit(mpd_timed_thread);
+                       if (timed_thread_test(mpd_timed_thread)) {
+                               timed_thread_exit(mpd_timed_thread);
+                       }
                        continue;
                }
 
                mpd_Status *status;
                mpd_InfoEntity *entity;
+
                mpd_sendStatusCommand(current_info->conn);
                if ((status = mpd_getStatus(current_info->conn)) == NULL) {
-                       //ERR("MPD error: %s\n", current_info->conn->errorStr);
+                       // ERR("MPD error: %s\n", current_info->conn->errorStr);
                        mpd_closeConnection(current_info->conn);
                        current_info->conn = 0;
                        clear_mpd_stats(current_info);
 
-                       strncpy(current_info->mpd.status, "MPD not responding", TEXT_BUFFER_SIZE - 1);
+                       strncpy(current_info->mpd.status, "MPD not responding",
+                               TEXT_BUFFER_SIZE - 1);
                        timed_thread_unlock(mpd_timed_thread);
-                       if (timed_thread_test(mpd_timed_thread)) timed_thread_exit(mpd_timed_thread);
+                       if (timed_thread_test(mpd_timed_thread)) {
+                               timed_thread_exit(mpd_timed_thread);
+                       }
                        continue;
                }
                mpd_finishCommand(current_info->conn);
                if (current_info->conn->error) {
-                       //fprintf(stderr, "%s\n", current_info->conn->errorStr);
+                       // fprintf(stderr, "%s\n", current_info->conn->errorStr);
                        mpd_closeConnection(current_info->conn);
                        current_info->conn = 0;
                        timed_thread_unlock(mpd_timed_thread);
-                       if (timed_thread_test(mpd_timed_thread)) timed_thread_exit(mpd_timed_thread);
+                       if (timed_thread_test(mpd_timed_thread)) {
+                               timed_thread_exit(mpd_timed_thread);
+                       }
                        continue;
                }
 
                current_info->mpd.volume = status->volume;
-               //if (status->error)
-               //printf("error: %s\n", status->error);
+               /* if (status->error) {
+                       printf("error: %s\n", status->error);
+               } */
 
                if (status->state == MPD_STATUS_STATE_PLAY) {
-                       strncpy(current_info->mpd.status, "Playing",
-                                       TEXT_BUFFER_SIZE - 1);
+                       strncpy(current_info->mpd.status, "Playing", TEXT_BUFFER_SIZE - 1);
                }
                if (status->state == MPD_STATUS_STATE_STOP) {
                        clear_mpd_stats(current_info);
-                       strncpy(current_info->mpd.status, "Stopped",
-                                       TEXT_BUFFER_SIZE - 1);
+                       strncpy(current_info->mpd.status, "Stopped", TEXT_BUFFER_SIZE - 1);
                }
                if (status->state == MPD_STATUS_STATE_PAUSE) {
-                       strncpy(current_info->mpd.status, "Paused",
-                                       TEXT_BUFFER_SIZE - 1);
+                       strncpy(current_info->mpd.status, "Paused", TEXT_BUFFER_SIZE - 1);
                }
                if (status->state == MPD_STATUS_STATE_UNKNOWN) {
                        clear_mpd_stats(current_info);
-                       *current_info->mpd.status=0;
+                       *current_info->mpd.status = 0;
                }
-               if (status->state == MPD_STATUS_STATE_PLAY ||
-                               status->state == MPD_STATUS_STATE_PAUSE) {
+               if (status->state == MPD_STATUS_STATE_PLAY
+                               || status->state == MPD_STATUS_STATE_PAUSE) {
                        current_info->mpd.bitrate = status->bitRate;
-                       current_info->mpd.progress =
-                               (float) status->elapsedTime / status->totalTime;
+                       current_info->mpd.progress = (float) status->elapsedTime /
+                               status->totalTime;
                        current_info->mpd.elapsed = status->elapsedTime;
                        current_info->mpd.length = status->totalTime;
                        if (status->random == 0) {
@@ -158,29 +176,32 @@ void *update_mpd(void)
                        } else if (status->random == 1) {
                                strcpy(current_info->mpd.random, "On");
                        } else {
-                               *current_info->mpd.random=0;
+                               *current_info->mpd.random = 0;
                        }
                        if (status->repeat == 0) {
                                strcpy(current_info->mpd.repeat, "Off");
                        } else if (status->repeat == 1) {
                                strcpy(current_info->mpd.repeat, "On");
                        } else {
-                               *current_info->mpd.repeat=0;
+                               *current_info->mpd.repeat = 0;
                        }
                }
 
                if (current_info->conn->error) {
-                       //fprintf(stderr, "%s\n", current_info->conn->errorStr);
+                       // fprintf(stderr, "%s\n", current_info->conn->errorStr);
                        mpd_closeConnection(current_info->conn);
                        current_info->conn = 0;
                        timed_thread_unlock(mpd_timed_thread);
-                       if (timed_thread_test(mpd_timed_thread)) timed_thread_exit(mpd_timed_thread);
+                       if (timed_thread_test(mpd_timed_thread)) {
+                               timed_thread_exit(mpd_timed_thread);
+                       }
                        continue;
                }
 
                mpd_sendCurrentSongCommand(current_info->conn);
                while ((entity = mpd_getNextInfoEntity(current_info->conn))) {
                        mpd_Song *song = entity->info.song;
+
                        if (entity->type != MPD_INFO_ENTITY_TYPE_SONG) {
                                mpd_freeInfoEntity(entity);
                                continue;
@@ -188,39 +209,39 @@ void *update_mpd(void)
 
                        if (song->artist) {
                                strncpy(current_info->mpd.artist, song->artist,
-                                               TEXT_BUFFER_SIZE - 1);
+                                       TEXT_BUFFER_SIZE - 1);
                        } else {
-                               *current_info->mpd.artist=0;
+                               *current_info->mpd.artist = 0;
                        }
                        if (song->album) {
                                strncpy(current_info->mpd.album, song->album,
-                                               TEXT_BUFFER_SIZE - 1);
+                                       TEXT_BUFFER_SIZE - 1);
                        } else {
-                               *current_info->mpd.album=0;
+                               *current_info->mpd.album = 0;
                        }
                        if (song->title) {
                                strncpy(current_info->mpd.title, song->title,
-                                               TEXT_BUFFER_SIZE - 1);
+                                       TEXT_BUFFER_SIZE - 1);
                        } else {
-                               *current_info->mpd.title=0;
+                               *current_info->mpd.title = 0;
                        }
                        if (song->track) {
                                strncpy(current_info->mpd.track, song->track,
-                                               TEXT_BUFFER_SIZE - 1);
+                                       TEXT_BUFFER_SIZE - 1);
                        } else {
-                               *current_info->mpd.track=0;
+                               *current_info->mpd.track = 0;
                        }
                        if (song->name) {
                                strncpy(current_info->mpd.name, song->name,
-                                               TEXT_BUFFER_SIZE - 1);
+                                       TEXT_BUFFER_SIZE - 1);
                        } else {
-                               *current_info->mpd.name=0;
+                               *current_info->mpd.name = 0;
                        }
                        if (song->file) {
-                               strncpy(current_info->mpd.file,
-                                               song->file, TEXT_BUFFER_SIZE - 1);
+                               strncpy(current_info->mpd.file, song->file,
+                                       TEXT_BUFFER_SIZE - 1);
                        } else {
-                               *current_info->mpd.file=0;
+                               *current_info->mpd.file = 0;
                        }
                        if (entity != NULL) {
                                mpd_freeInfoEntity(entity);
@@ -233,29 +254,35 @@ void *update_mpd(void)
                }
                mpd_finishCommand(current_info->conn);
                if (current_info->conn->error) {
-                       //fprintf(stderr, "%s\n", current_info->conn->errorStr);
+                       // fprintf(stderr, "%s\n", current_info->conn->errorStr);
                        mpd_closeConnection(current_info->conn);
                        current_info->conn = 0;
                        timed_thread_unlock(mpd_timed_thread);
-                       if (timed_thread_test(mpd_timed_thread)) timed_thread_exit(mpd_timed_thread);
+                       if (timed_thread_test(mpd_timed_thread)) {
+                               timed_thread_exit(mpd_timed_thread);
+                       }
                        continue;
                }
 
                timed_thread_unlock(mpd_timed_thread);
                if (current_info->conn->error) {
-                       //fprintf(stderr, "%s\n", current_info->conn->errorStr);
+                       // fprintf(stderr, "%s\n", current_info->conn->errorStr);
                        mpd_closeConnection(current_info->conn);
                        current_info->conn = 0;
-                       if (timed_thread_test(mpd_timed_thread)) timed_thread_exit(mpd_timed_thread);
+                       if (timed_thread_test(mpd_timed_thread)) {
+                               timed_thread_exit(mpd_timed_thread);
+                       }
                        continue;
                }
 
                mpd_freeStatus(status);
-/*             if (current_info->conn) {
+               /* if (current_info->conn) {
                        mpd_closeConnection(current_info->conn);
                        current_info->conn = 0;
-               }*/
-               if (timed_thread_test(mpd_timed_thread)) timed_thread_exit(mpd_timed_thread);
+               } */
+               if (timed_thread_test(mpd_timed_thread)) {
+                       timed_thread_exit(mpd_timed_thread);
+               }
                continue;
        }
        return 0;
index 846596c..01feed5 100644 (file)
@@ -1,5 +1,4 @@
-/*
- * Conky, a system monitor, based on torsmo
+/* Conky, a system monitor, based on torsmo
  *
  * Any original torsmo code is licensed under the BSD license
  *
@@ -8,7 +7,8 @@
  * Please see COPYING for details
  *
  * Copyright (c) 2004, Hannu Saransaari and Lauri Hakkarainen
- * Copyright (c) 2005-2007 Brenden Matthews, Philip Kovacs, et. al. (see AUTHORS)
+ * Copyright (c) 2005-2007 Brenden Matthews, Philip Kovacs, et. al.
+ *     (see AUTHORS)
  * All rights reserved.
  *
  * This program is free software: you can redistribute it and/or modify
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  * GNU General Public License for more details.
  * You should have received a copy of the GNU General Public License
- * along with this program.  If not, see <http://www.gnu.org/licenses/>. 
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
  *
- *  $Id$
- */
+ * $Id$ */
 
 #include <stdio.h>
 #include <stdlib.h>
@@ -57,7 +56,6 @@
 
 #include "conky.h"
 
-
 static kvm_t *kd = NULL;
 int kd_init = 0, nkd_init = 0;
 u_int32_t sensvalue;
@@ -65,12 +63,13 @@ char errbuf[_POSIX2_LINE_MAX];
 
 static int init_kvm(void)
 {
-       if (kd_init)
+       if (kd_init) {
                return 0;
+       }
 
        kd = kvm_openfiles(NULL, NULL, NULL, KVM_NO_FILES, errbuf);
        if (kd == NULL) {
-               (void) warnx("cannot kvm_openfiles: %s", errbuf);
+               warnx("cannot kvm_openfiles: %s", errbuf);
                return -1;
        }
        kd_init = 1;
@@ -88,25 +87,24 @@ static int swapmode(int *retavail, int *retfree)
        n = swapctl(SWAP_NSWAP, 0, 0);
 
        if (n < 1) {
-               (void) warn("could not get swap information");
+               warn("could not get swap information");
                return 0;
        }
 
        sep = (struct swapent *) malloc(n * (sizeof(*sep)));
 
        if (sep == NULL) {
-               (void) warn("memory allocation failed");
+               warn("memory allocation failed");
                return 0;
        }
 
        if (swapctl(SWAP_STATS, (void *) sep, n) < n) {
-               (void) warn("could not get swap stats");
+               warn("could not get swap stats");
                return 0;
        }
        for (; n > 0; n--) {
                *retavail += (int) dbtob(sep[n - 1].se_nblks);
-               *retfree +=
-                   (int) dbtob(sep[n - 1].se_nblks - sep[n - 1].se_inuse);
+               *retfree += (int) dbtob(sep[n - 1].se_nblks - sep[n - 1].se_inuse);
        }
        *retavail = (int) (*retavail / 1024);
        *retfree = (int) (*retfree / 1024);
@@ -114,7 +112,6 @@ static int swapmode(int *retavail, int *retfree)
        return 1;
 }
 
-
 void prepare_update()
 {
 }
@@ -127,11 +124,11 @@ void update_uptime()
        int size = sizeof(boottime);
 
        if ((sysctl(mib, 2, &boottime, &size, NULL, 0) != -1)
-           && (boottime.tv_sec != 0)) {
-               (void) time(&now);
+                       && (boottime.tv_sec != 0)) {
+               time(&now);
                info.uptime = now - boottime.tv_sec;
        } else {
-               (void) warn("could not get uptime");
+               warn("could not get uptime");
                info.uptime = 0;
        }
 }
@@ -154,7 +151,6 @@ void update_meminfo()
        info.memmax = info.mem = 0;
        info.swapmax = info.swap = 0;
 
-
        if (sysctl(mib, 2, &uvmexp, &size, NULL, 0) < 0) {
                warn("could not get memory info");
                return;
@@ -165,8 +161,7 @@ void update_meminfo()
        inactive_pages = uvmexp.inactive;
 
        info.memmax = (total_pages * pagesize) >> 10;
-       info.mem =
-           ((total_pages - free_pages - inactive_pages) * pagesize) >> 10;
+       info.mem = ((total_pages - free_pages - inactive_pages) * pagesize) >> 10;
 
        if (swapmode(&swap_avail, &swap_free) >= 0) {
                info.swapmax = swap_avail;
@@ -182,67 +177,65 @@ void update_net_stats()
        struct ifnet_head ifhead;       /* interfaces are in a tail queue */
        u_long ifnetaddr;
        static struct nlist namelist[] = {
-               {"_ifnet"},
-               {NULL},
+               { "_ifnet" },
+               { NULL }
        };
        static kvm_t *nkd;
 
        if (!nkd_init) {
                nkd = kvm_openfiles(NULL, NULL, NULL, O_RDONLY, errbuf);
                if (nkd == NULL) {
-                       (void) warnx("cannot kvm_openfiles: %s", errbuf);
-                       (void)
-                           warnx
-                           ("maybe you need to setgid kmem this program?");
+                       warnx("cannot kvm_openfiles: %s", errbuf);
+                       warnx("maybe you need to setgid kmem this program?");
                        return;
                } else if (kvm_nlist(nkd, namelist) != 0) {
-                       (void) warn("cannot kvm_nlist");
+                       warn("cannot kvm_nlist");
                        return;
-               } else
+               } else {
                        nkd_init = 1;
+               }
        }
 
        if (kvm_read(nkd, (u_long) namelist[0].n_value, (void *) &ifhead,
-                    sizeof(ifhead)) < 0) {
-               (void) warn("cannot kvm_read");
+                       sizeof(ifhead)) < 0) {
+               warn("cannot kvm_read");
                return;
        }
 
        /* get delta */
        delta = current_update_time - last_update_time;
-       if (delta <= 0.0001)
+       if (delta <= 0.0001) {
                return;
+       }
 
        for (i = 0, ifnetaddr = (u_long) ifhead.tqh_first;
-            ifnet.if_list.tqe_next && i < 16;
-            ifnetaddr = (u_long) ifnet.if_list.tqe_next, i++) {
+                       ifnet.if_list.tqe_next && i < 16;
+                       ifnetaddr = (u_long) ifnet.if_list.tqe_next, i++) {
 
                struct net_stat *ns;
                long long last_recv, last_trans;
 
-               (void) kvm_read(nkd, (u_long) ifnetaddr, (void *) &ifnet,
-                               sizeof(ifnet));
+               kvm_read(nkd, (u_long) ifnetaddr, (void *) &ifnet, sizeof(ifnet));
                ns = get_net_stat(ifnet.if_xname);
                ns->up = 1;
                last_recv = ns->recv;
                last_trans = ns->trans;
 
-               if (ifnet.if_ibytes < ns->last_read_recv)
-                       ns->recv +=
-                           ((long long) 4294967295U -
-                            ns->last_read_recv) + ifnet.if_ibytes;
-               else
+               if (ifnet.if_ibytes < ns->last_read_recv) {
+                       ns->recv += ((long long) 4294967295U - ns->last_read_recv) +
+                               ifnet.if_ibytes;
+               } else {
                        ns->recv += (ifnet.if_ibytes - ns->last_read_recv);
+               }
 
                ns->last_read_recv = ifnet.if_ibytes;
 
-               if (ifnet.if_obytes < ns->last_read_trans)
-                       ns->trans +=
-                           ((long long) 4294967295U -
-                            ns->last_read_trans) + ifnet.if_obytes;
-               else
-                       ns->trans +=
-                           (ifnet.if_obytes - ns->last_read_trans);
+               if (ifnet.if_obytes < ns->last_read_trans) {
+                       ns->trans += ((long long) 4294967295U - ns->last_read_trans) +
+                               ifnet.if_obytes;
+               } else {
+                       ns->trans += (ifnet.if_obytes - ns->last_read_trans);
+               }
 
                ns->last_read_trans = ifnet.if_obytes;
 
@@ -264,11 +257,12 @@ void update_total_processes()
 
        info.procs = 0;
 
-       if (init_kvm() < 0)
+       if (init_kvm() < 0) {
                return;
-       else
-               kvm_getproc2(kd, KERN_PROC_ALL, 0,
-                            sizeof(struct kinfo_proc2), &n_processes);
+       } else {
+               kvm_getproc2(kd, KERN_PROC_ALL, 0, sizeof(struct kinfo_proc2),
+                       &n_processes);
+       }
 
        info.procs = n_processes;
 }
@@ -281,15 +275,17 @@ void update_running_processes()
 
        info.run_procs = 0;
 
-       if (init_kvm() < 0)
+       if (init_kvm() < 0) {
                return;
-       else {
-               p = kvm_getproc2(kd, KERN_PROC_ALL, 0,
-                                sizeof(struct kinfo_proc2), &n_processes);
-               for (i = 0; i < n_processes; i++)
-                       if (p[i].p_stat == LSRUN || p[i].p_stat == LSIDL ||
-                           p[i].p_stat == LSONPROC)
+       } else {
+               p = kvm_getproc2(kd, KERN_PROC_ALL, 0, sizeof(struct kinfo_proc2),
+                       &n_processes);
+               for (i = 0; i < n_processes; i++) {
+                       if (p[i].p_stat == LSRUN || p[i].p_stat == LSIDL
+                                       || p[i].p_stat == LSONPROC) {
                                cnt++;
+                       }
+               }
        }
 
        info.run_procs = cnt;
@@ -313,9 +309,9 @@ void update_cpu_usage()
 
        info.cpu_usage = 0;
 
-       if (sysctlbyname("kern.cp_time", &cp_time, &len, NULL, 0) < 0)
-               (void) warn("cannot get kern.cp_time");
-
+       if (sysctlbyname("kern.cp_time", &cp_time, &len, NULL, 0) < 0) {
+               warn("cannot get kern.cp_time");
+       }
 
        fresh.load[0] = cp_time[CP_USER];
        fresh.load[1] = cp_time[CP_NICE];
@@ -324,19 +320,17 @@ void update_cpu_usage()
        fresh.load[4] = cp_time[CP_IDLE];
 
        used = fresh.load[0] + fresh.load[1] + fresh.load[2];
-       total =
-           fresh.load[0] + fresh.load[1] + fresh.load[2] + fresh.load[3];
-
-       if ((total - oldtotal) != 0)
-               info.cpu_usage =
-                   ((double) (used - oldused)) / (double) (total -
-                                                           oldtotal);
-       else
+       total = fresh.load[0] + fresh.load[1] + fresh.load[2] + fresh.load[3];
+
+       if ((total - oldtotal) != 0) {
+               info.cpu_usage = ((double) (used - oldused)) /
+                       (double) (total - oldtotal);
+       } else {
                info.cpu_usage = 0;
+       }
 
        oldused = used;
        oldtotal = total;
-
 }
 
 double get_sysfs_info(int *fd, int div, char *devtype)
@@ -347,6 +341,7 @@ double get_sysfs_info(int *fd, int div, char *devtype)
 void update_load_average()
 {
        double v[3];
+
        getloadavg(v, 3);
 
        info.loadavg[0] = (float) v[0];
@@ -363,8 +358,8 @@ void get_battery_stuff(char *buf, unsigned int n, const char *bat, int item)
 {
 }
 
-int
-open_sysfs_sensor(const char *dir, const char *dev, const char *type, int n, int *div, char *devtype)
+int open_sysfs_sensor(const char *dir, const char *dev, const char *type, int n,
+               int *div, char *devtype)
 {
        return -1;
 }
@@ -374,29 +369,27 @@ int open_acpi_temperature(const char *name)
        return -1;
 }
 
-void get_acpi_ac_adapter( char * p_client_buffer, size_t client_buffer_size )
+void get_acpi_ac_adapter(char *p_client_buffer, size_t client_buffer_size)
 {
-       if ( !p_client_buffer || client_buffer_size <= 0 )
+       if (!p_client_buffer || client_buffer_size <= 0) {
                return;
+       }
 
        /* not implemented */
-       memset(p_client_buffer,0,client_buffer_size);
-
-       return;
+       memset(p_client_buffer, 0, client_buffer_size);
 }
 
-/*char *get_acpi_fan()*/
-void get_acpi_fan( char * p_client_buffer, size_t client_buffer_size )
+/* char *get_acpi_fan() */
+void get_acpi_fan(char *p_client_buffer, size_t client_buffer_size)
 {
-       if ( !p_client_buffer || client_buffer_size <= 0 )
+       if (!p_client_buffer || client_buffer_size <= 0) {
                return;
+       }
 
        /* not implemented */
-       memset(p_client_buffer,0,client_buffer_size);
-
-       return;
+       memset(p_client_buffer, 0, client_buffer_size);
 }
 
-void update_entropy (void)
+void update_entropy(void)
 {
 }
index 2090bcc..6685858 100644 (file)
@@ -1,5 +1,4 @@
-/*
- * Conky, a system monitor, based on torsmo
+/* Conky, a system monitor, based on torsmo
  *
  * Any original torsmo code is licensed under the BSD license
  *
@@ -8,7 +7,8 @@
  * Please see COPYING for details
  *
  * Copyright (c) 2007 Toni Spets
- * Copyright (c) 2005-2007 Brenden Matthews, Philip Kovacs, et. al. (see AUTHORS)
+ * Copyright (c) 2005-2007 Brenden Matthews, Philip Kovacs, et. al.
+ *     (see AUTHORS)
  * All rights reserved.
  *
  * This program is free software: you can redistribute it and/or modify
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  * GNU General Public License for more details.
  * You should have received a copy of the GNU General Public License
- * along with this program.  If not, see <http://www.gnu.org/licenses/>. 
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
  *
- *  $Id$
- */
+ * $Id$ */
 
 #include <sys/dkstat.h>
 #include <sys/param.h>
@@ -79,39 +78,42 @@ int init_sensors = 0;
 
 static int kvm_init()
 {
-       if(init_kvm)
+       if (init_kvm) {
                return 1;
+       }
 
        kd = kvm_open(NULL, NULL, NULL, KVM_NO_FILES, NULL);
-       if(kd == NULL)
+       if (kd == NULL) {
                ERR("error opening kvm");
-       else    init_kvm = 1;
+       } else {
+               init_kvm = 1;
+       }
 
        return 1;
 }
 
 /* note: swapmode taken from 'top' source */
-/*
- * swapmode is rewritten by Tobias Weingartner <weingart@openbsd.org>
- * to be based on the new swapctl(2) system call.
- */
-static int
-swapmode(int *used, int *total)
+/* swapmode is rewritten by Tobias Weingartner <weingart@openbsd.org>
+ * to be based on the new swapctl(2) system call. */
+static int swapmode(int *used, int *total)
 {
        struct swapent *swdev;
        int nswap, rnswap, i;
 
        nswap = swapctl(SWAP_NSWAP, 0, 0);
-       if (nswap == 0)
+       if (nswap == 0) {
                return 0;
+       }
 
        swdev = malloc(nswap * sizeof(*swdev));
-       if (swdev == NULL)
+       if (swdev == NULL) {
                return 0;
+       }
 
        rnswap = swapctl(SWAP_STATS, swdev, nswap);
-       if (rnswap == -1)
+       if (rnswap == -1) {
                return 0;
+       }
 
        /* if rnswap != nswap, then what? */
 
@@ -133,16 +135,15 @@ int check_mount(char *s)
        return 0;
 }
 
-void
-update_uptime()
+void update_uptime()
 {
        int mib[2] = { CTL_KERN, KERN_BOOTTIME };
        struct timeval boottime;
        time_t now;
-       size_t size = sizeof (boottime);
+       size_t size = sizeof(boottime);
 
-       if ((sysctl(mib, 2, &boottime, &size, NULL, 0) != -1) &&
-                       (boottime.tv_sec != 0)) {
+       if ((sysctl(mib, 2, &boottime, &size, NULL, 0) != -1)
+                       && (boottime.tv_sec != 0)) {
                time(&now);
                info.uptime = now - boottime.tv_sec;
        } else {
@@ -151,10 +152,9 @@ update_uptime()
        }
 }
 
-void
-update_meminfo()
+void update_meminfo()
 {
-       static int mib[2] = {CTL_VM, VM_METER};
+       static int mib[2] = { CTL_VM, VM_METER };
        struct vmtotal vmtotal;
        size_t size;
        int pagesize, pageshift, swap_avail, swap_used;
@@ -176,7 +176,7 @@ update_meminfo()
                bzero(&vmtotal, sizeof(vmtotal));
        }
 
-       info.memmax =  pagetok(vmtotal.t_rm) + pagetok(vmtotal.t_free);
+       info.memmax = pagetok(vmtotal.t_rm) + pagetok(vmtotal.t_free);
        info.mem = pagetok(vmtotal.t_rm);
 
        if ((swapmode(&swap_used, &swap_avail)) >= 0) {
@@ -188,8 +188,7 @@ update_meminfo()
        }
 }
 
-void
-update_net_stats()
+void update_net_stats()
 {
        struct net_stat *ns;
        double delta;
@@ -197,14 +196,15 @@ update_net_stats()
        struct ifaddrs *ifap, *ifa;
        struct if_data *ifd;
 
-
        /* get delta */
        delta = current_update_time - last_update_time;
-       if (delta <= 0.0001)
+       if (delta <= 0.0001) {
                return;
+       }
 
-       if (getifaddrs(&ifap) < 0)
+       if (getifaddrs(&ifap) < 0) {
                return;
+       }
 
        for (ifa = ifap; ifa; ifa = ifa->ifa_next) {
                ns = get_net_stat((const char *) ifa->ifa_name);
@@ -216,35 +216,36 @@ update_net_stats()
                        last_recv = ns->recv;
                        last_trans = ns->trans;
 
-                       if (ifa->ifa_addr->sa_family != AF_LINK)
+                       if (ifa->ifa_addr->sa_family != AF_LINK) {
                                continue;
+                       }
 
-                       for (iftmp = ifa->ifa_next; iftmp != NULL &&
-                               strcmp(ifa->ifa_name, iftmp->ifa_name) == 0;
-                               iftmp = iftmp->ifa_next)
-                               if (iftmp->ifa_addr->sa_family == AF_INET)
+                       for (iftmp = ifa->ifa_next;
+                                       iftmp != NULL && strcmp(ifa->ifa_name, iftmp->ifa_name) == 0;
+                                       iftmp = iftmp->ifa_next) {
+                               if (iftmp->ifa_addr->sa_family == AF_INET) {
                                        memcpy(&(ns->addr), iftmp->ifa_addr,
                                                iftmp->ifa_addr->sa_len);
+                               }
+                       }
 
                        ifd = (struct if_data *) ifa->ifa_data;
                        r = ifd->ifi_ibytes;
                        t = ifd->ifi_obytes;
 
-                       if (r < ns->last_read_recv)
-                               ns->recv +=
-                                   ((long long) 4294967295U -
-                                       ns->last_read_recv) + r;
-                       else
+                       if (r < ns->last_read_recv) {
+                               ns->recv += ((long long) 4294967295U - ns->last_read_recv) + r;
+                       } else {
                                ns->recv += (r - ns->last_read_recv);
+                       }
 
                        ns->last_read_recv = r;
 
-                       if (t < ns->last_read_trans)
-                               ns->trans +=
-                                   ((long long) 4294967295U -
-                                       ns->last_read_trans) + t;
-                       else
+                       if (t < ns->last_read_trans) {
+                               ns->trans += (long long) 4294967295U - ns->last_read_trans + t;
+                       } else {
                                ns->trans += (t - ns->last_read_trans);
+                       }
 
                        ns->last_read_trans = t;
 
@@ -259,19 +260,17 @@ update_net_stats()
        freeifaddrs(ifap);
 }
 
-void
-update_total_processes()
+void update_total_processes()
 {
        int n_processes;
 
        kvm_init();
-       kvm_getprocs(kd, KERN_PROC_ALL, 0, &n_processes); 
+       kvm_getprocs(kd, KERN_PROC_ALL, 0, &n_processes);
 
        info.procs = n_processes;
 }
 
-void
-update_running_processes()
+void update_running_processes()
 {
        struct kinfo_proc2 *p;
        int n_processes;
@@ -279,10 +278,12 @@ update_running_processes()
 
        kvm_init();
        int max_size = sizeof(struct kinfo_proc2);
+
        p = kvm_getproc2(kd, KERN_PROC_ALL, 0, max_size, &n_processes);
        for (i = 0; i < n_processes; i++) {
-               if (p[i].p_stat == SRUN)
+               if (p[i].p_stat == SRUN) {
                        cnt++;
+               }
        }
 
        info.run_procs = cnt;
@@ -300,44 +301,47 @@ struct cpu_load_struct fresh = { {0, 0, 0, 0, 0} };
 long cpu_used, oldtotal, oldused;
 #else
 #include <assert.h>
-int64_t* fresh = NULL;
-/* XXX is 8 enough? - What's the constant for MAXCPU?*/
-/* allocate this with malloc would be better*/
+int64_t *fresh = NULL;
+
+/* XXX is 8 enough? - What's the constant for MAXCPU? */
+/* allocate this with malloc would be better */
 int64_t oldtotal[8], oldused[8];
 #endif
 
-void
-get_cpu_count()
+void get_cpu_count()
 {
-       int cpu_count = 1; /* default to 1 cpu */
+       int cpu_count = 1;      /* default to 1 cpu */
 #ifndef OLDCPU
        int mib[2] = { CTL_HW, HW_NCPU };
        size_t len = sizeof(cpu_count);
-       if(sysctl(mib, 2, &cpu_count, &len, NULL, 0) != 0)
+
+       if (sysctl(mib, 2, &cpu_count, &len, NULL, 0) != 0) {
                ERR("error getting cpu count, defaulting to 1");
+       }
 #endif
        info.cpu_count = cpu_count;
 
-       info.cpu_usage = malloc(info.cpu_count * sizeof (float));
-       if (info.cpu_usage == NULL)
+       info.cpu_usage = malloc(info.cpu_count * sizeof(float));
+       if (info.cpu_usage == NULL) {
                CRIT_ERR("malloc");
+       }
 
 #ifndef OLDCPU
-       assert(fresh == NULL); /* XXX Is this leaking memory?*/
-       /* XXX Where shall I free this?*/
-       if (NULL == (fresh = calloc(cpu_count, sizeof(int64_t) * CPUSTATES)))
+       assert(fresh == NULL);  /* XXX Is this leaking memory? */
+       /* XXX Where shall I free this? */
+       if (NULL == (fresh = calloc(cpu_count, sizeof(int64_t) * CPUSTATES))) {
                CRIT_ERR("calloc");
+       }
 #endif
 }
 
-void
-update_cpu_usage()
+void update_cpu_usage()
 {
 #ifdef OLDCPU
        int mib[2] = { CTL_KERN, KERN_CPTIME };
        long used, total;
        long cp_time[CPUSTATES];
-       size_t len = sizeof (cp_time);
+       size_t len = sizeof(cp_time);
 #else
        size_t size;
        unsigned int i;
@@ -361,8 +365,7 @@ update_cpu_usage()
        fresh.load[4] = cp_time[CP_IDLE];
 
        used = fresh.load[0] + fresh.load[1] + fresh.load[2];
-       total =
-           fresh.load[0] + fresh.load[1] + fresh.load[2] + fresh.load[3];
+       total = fresh.load[0] + fresh.load[1] + fresh.load[2] + fresh.load[3];
 
        if ((total - oldtotal) != 0) {
                info.cpu_usage[0] = ((double) (used - oldused)) /
@@ -377,23 +380,27 @@ update_cpu_usage()
        if (info.cpu_count > 1) {
                size = CPUSTATES * sizeof(int64_t);
                for (i = 0; i < info.cpu_count; i++) {
-                       int cp_time_mib[] = {CTL_KERN, KERN_CPTIME2, i};
-                       if (sysctl(cp_time_mib, 3, &(fresh[i * CPUSTATES]), &size, NULL, 0) < 0)
+                       int cp_time_mib[] = { CTL_KERN, KERN_CPTIME2, i };
+                       if (sysctl(cp_time_mib, 3, &(fresh[i * CPUSTATES]), &size, NULL, 0)
+                                       < 0) {
                                ERR("sysctl kern.cp_time2 failed");
+                       }
                }
        } else {
-               int cp_time_mib[] = {CTL_KERN, KERN_CPTIME};
+               int cp_time_mib[] = { CTL_KERN, KERN_CPTIME };
                long cp_time_tmp[CPUSTATES];
 
                size = sizeof(cp_time_tmp);
-               if (sysctl(cp_time_mib, 2, cp_time_tmp, &size, NULL, 0) < 0)
+               if (sysctl(cp_time_mib, 2, cp_time_tmp, &size, NULL, 0) < 0) {
                        ERR("sysctl kern.cp_time failed");
+               }
 
-               for (i = 0; i < CPUSTATES; i++)
-                       fresh[i] = (int64_t)cp_time_tmp[i];
+               for (i = 0; i < CPUSTATES; i++) {
+                       fresh[i] = (int64_t) cp_time_tmp[i];
+               }
        }
 
-       /* XXX Do sg with this int64_t => long => double ? float hell.*/
+       /* XXX Do sg with this int64_t => long => double ? float hell. */
        for (i = 0; i < info.cpu_count; i++) {
                int64_t used, total;
                int at = i * CPUSTATES;
@@ -403,7 +410,7 @@ update_cpu_usage()
 
                if ((total - oldtotal[i]) != 0) {
                        info.cpu_usage[i] = ((double) (used - oldused[i])) /
-                       (double) (total - oldtotal[i]);
+                               (double) (total - oldtotal[i]);
                } else {
                        info.cpu_usage[i] = 0;
                }
@@ -414,10 +421,10 @@ update_cpu_usage()
 #endif
 }
 
-void
-update_load_average()
+void update_load_average()
 {
        double v[3];
+
        getloadavg(v, 3);
 
        info.loadavg[0] = (float) v[0];
@@ -431,7 +438,7 @@ void update_obsd_sensors()
        int sensor_cnt, dev, numt, mib[5] = { CTL_HW, HW_SENSORS, 0, 0, 0 };
        struct sensor sensor;
        struct sensordev sensordev;
-       size_t slen,sdlen;
+       size_t slen, sdlen;
        enum sensor_type type;
 
        slen = sizeof(sensor);
@@ -439,38 +446,42 @@ void update_obsd_sensors()
 
        sensor_cnt = 0;
 
-       dev = obsd_sensors.device; // FIXME: read more than one device
+       dev = obsd_sensors.device;      // FIXME: read more than one device
 
        /* for (dev = 0; dev < MAXSENSORDEVICES; dev++) { */
                mib[2] = dev;
-               if(sysctl(mib, 3, &sensordev, &sdlen, NULL, 0) == -1) {
-                       if (errno != ENOENT)
+               if (sysctl(mib, 3, &sensordev, &sdlen, NULL, 0) == -1) {
+                       if (errno != ENOENT) {
                                warn("sysctl");
+                       }
                        return;
-                       //continue;
+                       // continue;
                }
                for (type = 0; type < SENSOR_MAX_TYPES; type++) {
                        mib[3] = type;
                        for (numt = 0; numt < sensordev.maxnumt[type]; numt++) {
                                mib[4] = numt;
-                               if (sysctl(mib, 5, &sensor, &slen, NULL, 0)
-                                   == -1) {
-                                       if (errno != ENOENT)
+                               if (sysctl(mib, 5, &sensor, &slen, NULL, 0) == -1) {
+                                       if (errno != ENOENT) {
                                                warn("sysctl");
+                                       }
                                        continue;
                                }
-                               if (sensor.flags & SENSOR_FINVALID)
+                               if (sensor.flags & SENSOR_FINVALID) {
                                        continue;
+                               }
 
                                switch (type) {
                                        case SENSOR_TEMP:
-                                               obsd_sensors.temp[dev][sensor.numt] = (sensor.value - 273150000) / 1000000.0;
+                                               obsd_sensors.temp[dev][sensor.numt] =
+                                                       (sensor.value - 273150000) / 1000000.0;
                                                break;
                                        case SENSOR_FANRPM:
                                                obsd_sensors.fan[dev][sensor.numt] = sensor.value;
                                                break;
                                        case SENSOR_VOLTS_DC:
-                                               obsd_sensors.volt[dev][sensor.numt] = sensor.value/1000000.0;
+                                               obsd_sensors.volt[dev][sensor.numt] =
+                                                       sensor.value / 1000000.0;
                                                break;
                                        default:
                                                break;
@@ -488,11 +499,13 @@ void update_obsd_sensors()
 void get_obsd_vendor(char *buf, size_t client_buffer_size)
 {
        int mib[2];
+
        mib[0] = CTL_HW;
        mib[1] = HW_VENDOR;
        char vendor[64];
        size_t size = sizeof(vendor);
-       if(sysctl(mib, 2, vendor, &size, NULL, 0) == -1) {
+
+       if (sysctl(mib, 2, vendor, &size, NULL, 0) == -1) {
                ERR("error reading vendor");
                snprintf(buf, client_buffer_size, "unknown");
        } else {
@@ -504,11 +517,13 @@ void get_obsd_vendor(char *buf, size_t client_buffer_size)
 void get_obsd_product(char *buf, size_t client_buffer_size)
 {
        int mib[2];
+
        mib[0] = CTL_HW;
        mib[1] = HW_PRODUCT;
        char product[64];
        size_t size = sizeof(product);
-       if(sysctl(mib, 2, product, &size, NULL, 0) == -1) {
+
+       if (sysctl(mib, 2, product, &size, NULL, 0) == -1) {
                ERR("error reading product");
                snprintf(buf, client_buffer_size, "unknown");
        } else {
@@ -519,27 +534,26 @@ void get_obsd_product(char *buf, size_t client_buffer_size)
 /* rdtsc() and get_freq_dynamic() copied from linux.c */
 
 #if  defined(__i386) || defined(__x86_64)
-__inline__ unsigned long long int
-rdtsc()
+__inline__ unsigned long long int rdtsc()
 {
        unsigned long long int x;
+
        __asm__ volatile(".byte 0x0f, 0x31":"=A" (x));
-       return (x);
+       return x;
 }
 #endif
 
 /* return system frequency in MHz (use divisor=1) or GHz (use divisor=1000) */
-void
-get_freq_dynamic(char *p_client_buffer, size_t client_buffer_size,
+void get_freq_dynamic(char *p_client_buffer, size_t client_buffer_size,
                char *p_format, int divisor)
 {
-#if  defined(__i386) || defined(__x86_64) 
+#if  defined(__i386) || defined(__x86_64)
        struct timezone tz;
        struct timeval tvstart, tvstop;
        unsigned long long cycles[2];   /* gotta be 64 bit */
        unsigned int microseconds;      /* total time taken */
 
-       memset(&tz, 0, sizeof (tz));
+       memset(&tz, 0, sizeof(tz));
 
        /* get this function in cached memory */
        gettimeofday(&tvstart, &tz);
@@ -554,57 +568,56 @@ get_freq_dynamic(char *p_client_buffer, size_t client_buffer_size,
                (tvstop.tv_usec - tvstart.tv_usec);
 
        snprintf(p_client_buffer, client_buffer_size, p_format,
-               (float)((cycles[1] - cycles[0]) / microseconds) / divisor);
+               (float) ((cycles[1] - cycles[0]) / microseconds) / divisor);
 #else
        get_freq(p_client_buffer, client_buffer_size, p_format, divisor, 1);
 #endif
 }
 
-/*void*/
-char
-get_freq(char *p_client_buffer, size_t client_buffer_size,
-               char *p_format, int divisor, unsigned int cpu)
+/* void */
+char get_freq(char *p_client_buffer, size_t client_buffer_size, char *p_format,
+               int divisor, unsigned int cpu)
 {
        int freq = cpu;
        int mib[2] = { CTL_HW, HW_CPUSPEED };
-       
-       if (!p_client_buffer || client_buffer_size <= 0 ||
-                       !p_format || divisor <= 0)
+
+       if (!p_client_buffer || client_buffer_size <= 0 || !p_format
+                       || divisor <= 0) {
                return 0;
+       }
 
        size_t size = sizeof(freq);
-       if(sysctl(mib, 2, &freq, &size, NULL, 0) == 0)
-               snprintf(p_client_buffer, client_buffer_size,
-                               p_format, (float)freq/divisor);
-       else
+
+       if (sysctl(mib, 2, &freq, &size, NULL, 0) == 0) {
+               snprintf(p_client_buffer, client_buffer_size, p_format,
+                       (float) freq / divisor);
+       } else {
                snprintf(p_client_buffer, client_buffer_size, p_format, 0.0f);
+       }
 
        return 1;
 }
 
-void
-update_top()
+void update_top()
 {
        proc_find_top(info.cpu, info.memu);
 }
 
 #if 0
 /* deprecated, will rewrite this soon in update_net_stats() -hifi */
-void
-update_wifi_stats()
+void update_wifi_stats()
 {
-       struct net_stat * ns;
+       struct net_stat *ns;
        struct ifaddrs *ifap, *ifa;
        struct ifmediareq ifmr;
        struct ieee80211_nodereq nr;
        struct ieee80211_bssid bssid;
-       int s,ibssid;
+       int s, ibssid;
 
-       /*
-        * Get iface table
-        */
-       if (getifaddrs(&ifap) < 0)
+       /* Get iface table */
+       if (getifaddrs(&ifap) < 0) {
                return;
+       }
 
        for (ifa = ifap; ifa; ifa = ifa->ifa_next) {
                ns = get_net_stat((const char *) ifa->ifa_name);
@@ -614,15 +627,14 @@ update_wifi_stats()
                /* Get media type */
                bzero(&ifmr, sizeof(ifmr));
                strlcpy(ifmr.ifm_name, ifa->ifa_name, IFNAMSIZ);
-               if (ioctl(s, SIOCGIFMEDIA, (caddr_t) &ifmr) < 0)
+               if (ioctl(s, SIOCGIFMEDIA, (caddr_t) &ifmr) < 0) {
                        goto cleanup;
-               
-               /*
-                * We can monitor only wireless interfaces
-                * which not in hostap mode
-                */
-               if ((ifmr.ifm_active & IFM_IEEE80211) &&
-                               !(ifmr.ifm_active & IFM_IEEE80211_HOSTAP)) {
+               }
+
+               /* We can monitor only wireless interfaces
+                * which are not in hostap mode */
+               if ((ifmr.ifm_active & IFM_IEEE80211)
+                               && !(ifmr.ifm_active & IFM_IEEE80211_HOSTAP)) {
                        /* Get wi status */
 
                        memset(&bssid, 0, sizeof(bssid));
@@ -633,8 +645,9 @@ update_wifi_stats()
                        bcopy(bssid.i_bssid, &nr.nr_macaddr, sizeof(nr.nr_macaddr));
                        strlcpy(nr.nr_ifname, ifa->ifa_name, sizeof(nr.nr_ifname));
 
-                       if (ioctl(s, SIOCG80211NODE, &nr) == 0 && nr.nr_rssi)
+                       if (ioctl(s, SIOCG80211NODE, &nr) == 0 && nr.nr_rssi) {
                                ns->linkstatus = nr.nr_rssi;
+                       }
                }
 cleanup:
                close(s);
@@ -642,42 +655,40 @@ cleanup:
 }
 #endif
 
-void
-update_diskio()
+void update_diskio()
 {
-       return; /* XXX implement? hifi: not sure how */
+       return; /* XXX: implement? hifi: not sure how */
 }
 
-/*
- * While topless is obviously better, top is also not bad.
- */
+/* While topless is obviously better, top is also not bad. */
 
-int
-comparecpu(const void *a, const void *b)
+int comparecpu(const void *a, const void *b)
 {
-       if (((struct process *)a)->amount > ((struct process *)b)->amount)
-               return (-1);
+       if (((struct process *) a)->amount > ((struct process *) b)->amount) {
+               return -1;
+       }
 
-       if (((struct process *)a)->amount < ((struct process *)b)->amount)
-               return (1);
+       if (((struct process *) a)->amount < ((struct process *) b)->amount) {
+               return 1;
+       }
 
-       return (0);
+       return 0;
 }
 
-int
-comparemem(const void *a, const void *b)
+int comparemem(const void *a, const void *b)
 {
-       if (((struct process *)a)->totalmem > ((struct process *)b)->totalmem)
-               return (-1);
+       if (((struct process *) a)->totalmem > ((struct process *) b)->totalmem) {
+               return -1;
+       }
 
-       if (((struct process *)a)->totalmem < ((struct process *)b)->totalmem)
-               return (1);
+       if (((struct process *) a)->totalmem < ((struct process *) b)->totalmem) {
+               return 1;
+       }
 
-       return (0);
+       return 0;
 }
 
-inline void
-proc_find_top(struct process **cpu, struct process **mem)
+inline void proc_find_top(struct process **cpu, struct process **mem)
 {
        struct kinfo_proc2 *p;
        int n_processes;
@@ -692,32 +703,32 @@ proc_find_top(struct process **cpu, struct process **mem)
        mib[0] = CTL_HW;
        mib[1] = HW_USERMEM;
        size_t size = sizeof(total_pages);
-       if(sysctl(mib, 2, &total_pages, &size, NULL, 0) == -1)
+
+       if (sysctl(mib, 2, &total_pages, &size, NULL, 0) == -1) {
                ERR("error reading nmempages");
+       }
 
        int max_size = sizeof(struct kinfo_proc2);
-       p = kvm_getproc2(kd, KERN_PROC_ALL, 0, max_size, &n_processes);
-       processes = malloc(n_processes * sizeof (struct process));
 
+       p = kvm_getproc2(kd, KERN_PROC_ALL, 0, max_size, &n_processes);
+       processes = malloc(n_processes * sizeof(struct process));
 
        for (i = 0; i < n_processes; i++) {
-               if (!((p[i].p_flag & P_SYSTEM)) &&
-                               p[i].p_comm != NULL) {
+               if (!((p[i].p_flag & P_SYSTEM)) && p[i].p_comm != NULL) {
                        processes[j].pid = p[i].p_pid;
-                       processes[j].name =  strdup(p[i].p_comm);
-                       processes[j].amount = 100.0 *
-                               p[i].p_pctcpu / FSCALE;
-                       processes[j].totalmem = (float)(p[i].p_vm_rssize * pagesize /
-                                       (float)total_pages) * 100.0;
+                       processes[j].name = strdup(p[i].p_comm);
+                       processes[j].amount = 100.0 * p[i].p_pctcpu / FSCALE;
+                       processes[j].totalmem = (float) (p[i].p_vm_rssize * pagesize /
+                               (float) total_pages) * 100.0;
                        j++;
                }
        }
 
-       qsort(processes, j - 1, sizeof (struct process), comparemem);
+       qsort(processes, j - 1, sizeof(struct process), comparemem);
        for (i = 0; i < 10; i++) {
                struct process *tmp, *ttmp;
 
-               tmp = malloc(sizeof (struct process));
+               tmp = malloc(sizeof(struct process));
                tmp->pid = processes[i].pid;
                tmp->amount = processes[i].amount;
                tmp->totalmem = processes[i].totalmem;
@@ -731,11 +742,11 @@ proc_find_top(struct process **cpu, struct process **mem)
                }
        }
 
-       qsort(processes, j - 1, sizeof (struct process), comparecpu);
+       qsort(processes, j - 1, sizeof(struct process), comparecpu);
        for (i = 0; i < 10; i++) {
                struct process *tmp, *ttmp;
 
-               tmp = malloc(sizeof (struct process));
+               tmp = malloc(sizeof(struct process));
                tmp->pid = processes[i].pid;
                tmp->amount = processes[i].amount;
                tmp->totalmem = processes[i].totalmem;
@@ -749,101 +760,101 @@ proc_find_top(struct process **cpu, struct process **mem)
                }
        }
 
-       for (i = 0; i < j; free(processes[i++].name));
+       for (i = 0; i < j; i++) {
+               free(processes[i].name);
+       }
        free(processes);
 }
 
-#if    defined(i386) || defined(__i386__) 
+#if    defined(i386) || defined(__i386__)
 #define        APMDEV          "/dev/apm"
 #define        APM_UNKNOWN     255
 
-int
-apm_getinfo(int fd, apm_info_t aip)
+int apm_getinfo(int fd, apm_info_t aip)
 {
-       if (ioctl(fd, APM_IOC_GETPOWER, aip) == -1)
-               return (-1);
+       if (ioctl(fd, APM_IOC_GETPOWER, aip) == -1) {
+               return -1;
+       }
 
-       return (0);
+       return 0;
 }
 
-char
-*get_apm_adapter()
+char *get_apm_adapter()
 {
        int fd;
        struct apm_power_info info;
        char *out;
 
-       out  = (char *)calloc(16, sizeof (char));
+       out = (char *) calloc(16, sizeof(char));
 
        fd = open(APMDEV, O_RDONLY);
        if (fd < 0) {
                strncpy(out, "ERR", 16);
-               return (out);
+               return out;
        }
 
        if (apm_getinfo(fd, &info) != 0) {
                close(fd);
                strncpy(out, "ERR", 16);
-               return (out);
+               return out;
        }
        close(fd);
 
        switch (info.ac_state) {
                case APM_AC_OFF:
                        strncpy(out, "off-line", 16);
-                       return (out);
+                       return out;
                        break;
                case APM_AC_ON:
                        if (info.battery_state == APM_BATT_CHARGING) {
                                strncpy(out, "charging", 16);
-                               return (out);
+                               return out;
                        } else {
                                strncpy(out, "on-line", 16);
-                               return (out);
+                               return out;
                        }
                        break;
                default:
                        strncpy(out, "unknown", 16);
-                       return (out);
+                       return out;
                        break;
        }
 }
 
-char
-*get_apm_battery_life()
+char *get_apm_battery_life()
 {
        int fd;
        u_int batt_life;
        struct apm_power_info info;
        char *out;
 
-       out = (char *)calloc(16, sizeof (char));
+       out = (char *) calloc(16, sizeof(char));
 
        fd = open(APMDEV, O_RDONLY);
        if (fd < 0) {
                strncpy(out, "ERR", 16);
-               return (out);
+               return out;
        }
 
        if (apm_getinfo(fd, &info) != 0) {
                close(fd);
                strncpy(out, "ERR", 16);
-               return (out);
+               return out;
        }
        close(fd);
 
        batt_life = info.battery_life;
        if (batt_life <= 100) {
                snprintf(out, 16, "%d%%", batt_life);
-               return (out);
-       } else
+               return out;
+       } else {
                strncpy(out, "ERR", 16);
+       }
 
-       return (out);
+       return out;
 }
 
-char
-*get_apm_battery_time()
+char *get_apm_battery_time()
 {
        int fd;
        int batt_time;
@@ -851,50 +862,45 @@ char
        struct apm_power_info info;
        char *out;
 
-       out = (char *)calloc(16, sizeof (char));
+       out = (char *) calloc(16, sizeof(char));
 
        fd = open(APMDEV, O_RDONLY);
        if (fd < 0) {
                strncpy(out, "ERR", 16);
-               return (out);
+               return out;
        }
 
        if (apm_getinfo(fd, &info) != 0) {
                close(fd);
                strncpy(out, "ERR", 16);
-               return (out);
+               return out;
        }
        close(fd);
 
        batt_time = info.minutes_left;
 
-       if (batt_time == -1)
+       if (batt_time == -1) {
                strncpy(out, "unknown", 16);
-       else {
+       } else {
                h = batt_time / 60;
                m = batt_time % 60;
                snprintf(out, 16, "%2d:%02d", h, m);
        }
 
-       return (out);
+       return out;
 }
 
 #endif
 
 /* empty stubs so conky links */
-void
-prepare_update()
+void prepare_update()
 {
-       return;
 }
 
-void update_entropy (void)
+void update_entropy(void)
 {
-       return;
 }
 
-void
-free_all_processes(void)
+void free_all_processes(void)
 {
-       return;
 }
index d3d2932..a4e1fa8 100644 (file)
@@ -1,8 +1,7 @@
-/*
- * $Id$
+/* $Id$
  *
  * Copyright (c) 2007 Mikko Sysikaski <mikko.sysikaski@gmail.com>
- *                    Toni Spets <toni.spets@gmail.com>
+ *                                       Toni Spets <toni.spets@gmail.com>
  *
  * Permission to use, copy, modify, and distribute this software for any
  * purpose with or without fee is hereby granted, provided that the above
@@ -14,8 +13,7 @@
  * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
  * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
  * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
- * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
- */
+ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */
 
 #include <libxml/parser.h>
 #include <libxml/tree.h>
 #define PARSE_OPTIONS 0
 #endif
 
-PRSS* prss_parse_doc(xmlDocPtr doc);
+PRSS *prss_parse_doc(xmlDocPtr doc);
 
-PRSS* prss_parse_data(const char* xml_data)
+PRSS *prss_parse_data(const char *xml_data)
 {
-       xmlDocPtr doc = xmlReadMemory(xml_data, strlen(xml_data), "", NULL, PARSE_OPTIONS);
-       if (!doc)
+       xmlDocPtr doc = xmlReadMemory(xml_data, strlen(xml_data), "", NULL,
+               PARSE_OPTIONS);
+
+       if (!doc) {
                return NULL;
-       
+       }
+
        return prss_parse_doc(doc);
 }
-PRSS* prss_parse_file(const char* xml_file)
+
+PRSS *prss_parse_file(const char *xml_file)
 {
        xmlDocPtr doc = xmlReadFile(xml_file, NULL, PARSE_OPTIONS);
-       if (!doc)
+
+       if (!doc) {
                return NULL;
-       
+       }
+
        return prss_parse_doc(doc);
 }
-void prss_free(PRSS* data)
+
+void prss_free(PRSS *data)
 {
-       if (!data)
+       if (!data) {
                return;
+       }
        xmlFreeDoc(data->_data);
        free(data->version);
        free(data->items);
        free(data);
 }
 
-static inline void prss_null(PRSS* p)
+static inline void prss_null(PRSS *p)
 {
        memset(p, 0, sizeof(PRSS));
 }
-static inline void prss_null_item(PRSS_Item* i)
+static inline void prss_null_item(PRSS_Item *i)
 {
        memset(i, 0, sizeof(PRSS_Item));
 }
 
-static inline void read_item(PRSS_Item* res, xmlNodePtr data)
+static inline void read_item(PRSS_Item *res, xmlNodePtr data)
 {
        prss_null_item(res);
-       
+
        res->title = res->link = res->description = NULL;
-       for(; data; data = data->next) {
-               if (data->type != XML_ELEMENT_NODE)
+       for (; data; data = data->next) {
+               if (data->type != XML_ELEMENT_NODE) {
                        continue;
+               }
                xmlNodePtr child = data->children;
-               if (!child)
+
+               if (!child) {
                        continue;
-       
-               if (!strcasecmp((char*)data->name, "title")) {
-                       res->title = (char*)child->content;
-               } else if (!strcasecmp((char*)data->name, "link")) {
-                       res->link = (char*)child->content;
-               } else if (!strcasecmp((char*)data->name, "description")) {
-                       res->description = (char*)child->content;
-               } else if (!strcasecmp((char*)data->name, "category")) {
-                       res->category = (char*)child->content;
-               } else if (!strcasecmp((char*)data->name, "pubDate")) {
-                       res->pubdate = (char*)child->content;
-               } else if (!strcasecmp((char*)data->name, "guid")) {
-                       res->guid = (char*)child->content;
+               }
+
+               if (!strcasecmp((char *) data->name, "title")) {
+                       res->title = (char *) child->content;
+               } else if (!strcasecmp((char *) data->name, "link")) {
+                       res->link = (char *) child->content;
+               } else if (!strcasecmp((char *) data->name, "description")) {
+                       res->description = (char *) child->content;
+               } else if (!strcasecmp((char *) data->name, "category")) {
+                       res->category = (char *) child->content;
+               } else if (!strcasecmp((char *) data->name, "pubDate")) {
+                       res->pubdate = (char *) child->content;
+               } else if (!strcasecmp((char *) data->name, "guid")) {
+                       res->guid = (char *) child->content;
                }
        }
 }
-static inline void read_element(PRSS* res, xmlNodePtr n)
+static inline void read_element(PRSS *res, xmlNodePtr n)
 {
-       if (n->type != XML_ELEMENT_NODE)
+       if (n->type != XML_ELEMENT_NODE) {
                return;
+       }
        xmlNodePtr child = n->children;
-       if (!child)
+
+       if (!child) {
                return;
-               
-       if (!strcasecmp((char*)n->name, "title")) {
-               res->title = (char*)child->content;
-       } else if (!strcasecmp((char*)n->name, "link")) {
-               res->link = (char*)child->content;
-       } else if (!strcasecmp((char*)n->name, "description")) {
-               res->description = (char*)child->content;
-       } else if (!strcasecmp((char*)n->name, "language")) {
-               res->language = (char*)child->content;
-       } else if (!strcasecmp((char*)n->name, "pubDate")) {
-               res->pubdate = (char*)child->content;
-       } else if (!strcasecmp((char*)n->name, "lastBuildDate")) {
-               res->lastbuilddate = (char*)child->content;
-       } else if (!strcasecmp((char*)n->name, "generator")) {
-               res->generator = (char*)child->content;
-       } else if (!strcasecmp((char*)n->name, "docs")) {
-               res->docs = (char*)child->content;
-       } else if (!strcasecmp((char*)n->name, "managingEditor")) {
-               res->managingeditor = (char*)child->content;
-       } else if (!strcasecmp((char*)n->name, "webMaster")) {
-               res->webmaster = (char*)child->content;
-       } else if (!strcasecmp((char*)n->name, "copyright")) {
-               res->copyright = (char*)child->content;
-       } else if (!strcasecmp((char*)n->name, "ttl")) {
-               res->ttl = (char*)child->content;
-       } else if (!strcasecmp((char*)n->name, "item")) {
+       }
+
+       if (!strcasecmp((char *) n->name, "title")) {
+               res->title = (char *) child->content;
+       } else if (!strcasecmp((char *) n->name, "link")) {
+               res->link = (char *) child->content;
+       } else if (!strcasecmp((char *) n->name, "description")) {
+               res->description = (char *) child->content;
+       } else if (!strcasecmp((char *) n->name, "language")) {
+               res->language = (char *) child->content;
+       } else if (!strcasecmp((char *) n->name, "pubDate")) {
+               res->pubdate = (char *) child->content;
+       } else if (!strcasecmp((char *) n->name, "lastBuildDate")) {
+               res->lastbuilddate = (char *) child->content;
+       } else if (!strcasecmp((char *) n->name, "generator")) {
+               res->generator = (char *) child->content;
+       } else if (!strcasecmp((char *) n->name, "docs")) {
+               res->docs = (char *) child->content;
+       } else if (!strcasecmp((char *) n->name, "managingEditor")) {
+               res->managingeditor = (char *) child->content;
+       } else if (!strcasecmp((char *) n->name, "webMaster")) {
+               res->webmaster = (char *) child->content;
+       } else if (!strcasecmp((char *) n->name, "copyright")) {
+               res->copyright = (char *) child->content;
+       } else if (!strcasecmp((char *) n->name, "ttl")) {
+               res->ttl = (char *) child->content;
+       } else if (!strcasecmp((char *) n->name, "item")) {
                read_item(&res->items[res->item_count++], n->children);
        }
 }
 
-static inline int parse_rss_2_0(PRSS* res, xmlNodePtr root)
+static inline int parse_rss_2_0(PRSS *res, xmlNodePtr root)
 {
        xmlNodePtr channel = root->children;
-       while(channel
-                       && (channel->type!=XML_ELEMENT_NODE
-                        || strcmp((char*)channel->name, "channel")))
+
+       while (channel && (channel->type != XML_ELEMENT_NODE
+                       || strcmp((char *) channel->name, "channel"))) {
                channel = channel->next;
-       if (!channel)
+       }
+       if (!channel) {
                return 0;
+       }
 
        int items = 0;
        xmlNodePtr n;
-       for(n = channel->children; n; n = n->next)
-               if (n->type==XML_ELEMENT_NODE && !strcmp((char*)n->name, "item"))
+
+       for (n = channel->children; n; n = n->next) {
+               if (n->type == XML_ELEMENT_NODE && !strcmp((char *) n->name, "item")) {
                        ++items;
-       
+               }
+       }
+
        res->version = strdup("2.0");
-       res->items = malloc(items*sizeof(PRSS_Item));
+       res->items = malloc(items * sizeof(PRSS_Item));
        res->item_count = 0;
 
-       for(n = channel->children; n; n = n->next) {
+       for (n = channel->children; n; n = n->next) {
                read_element(res, n);
        }
 
        return 1;
 }
-static inline int parse_rss_1_0(PRSS* res, xmlNodePtr root)
+static inline int parse_rss_1_0(PRSS *res, xmlNodePtr root)
 {
        int items = 0;
        xmlNodePtr n;
-       for(n = root->children; n; n = n->next) {
-               if (n->type==XML_ELEMENT_NODE) {
-                       if (!strcmp((char*)n->name, "item"))
+
+       for (n = root->children; n; n = n->next) {
+               if (n->type == XML_ELEMENT_NODE) {
+                       if (!strcmp((char *) n->name, "item")) {
                                ++items;
-                       else if (!strcmp((char*)n->name, "channel")) {
+                       } else if (!strcmp((char *) n->name, "channel")) {
                                xmlNodePtr i;
-                               for(i = n->children; i; i = i->next) {
+
+                               for (i = n->children; i; i = i->next) {
                                        read_element(res, i);
                                }
                        }
                }
        }
-       
+
        res->version = strdup("1.0");
-       res->items = malloc(items*sizeof(PRSS_Item));
+       res->items = malloc(items * sizeof(PRSS_Item));
        res->item_count = 0;
 
-       for(n = root->children; n; n = n->next) {
-               if (n->type==XML_ELEMENT_NODE && !strcmp((char*)n->name, "item"))
+       for (n = root->children; n; n = n->next) {
+               if (n->type == XML_ELEMENT_NODE && !strcmp((char *) n->name, "item")) {
                        read_item(&res->items[res->item_count++], n->children);
+               }
        }
-       
+
        return 1;
 }
-static inline int parse_rss_0_9x(PRSS* res, xmlNodePtr root)
+static inline int parse_rss_0_9x(PRSS *res, xmlNodePtr root)
 {
        // almost same...
        return parse_rss_2_0(res, root);
 }
 
-PRSS* prss_parse_doc(xmlDocPtr doc)
+PRSS *prss_parse_doc(xmlDocPtr doc)
 {
-       // FIXME: doc shouldn't be freed after failure when called explicitly from program!
+       /* FIXME: doc shouldn't be freed after failure when called explicitly from
+        * program! */
 
        xmlNodePtr root = xmlDocGetRootElement(doc);
-       PRSS* result = malloc(sizeof(PRSS));
+       PRSS *result = malloc(sizeof(PRSS));
+
        prss_null(result);
        result->_data = doc;
        do {
                if (root->type == XML_ELEMENT_NODE) {
-                       if (!strcmp((char*)root->name, "RDF")) {
+                       if (!strcmp((char *) root->name, "RDF")) {
                                // RSS 1.0 document
                                if (!parse_rss_1_0(result, root)) {
                                        free(result);
@@ -208,7 +230,7 @@ PRSS* prss_parse_doc(xmlDocPtr doc)
                                        return NULL;
                                }
                                return result;
-                       } else if (!strcmp((char*)root->name, "rss")) {
+                       } else if (!strcmp((char *) root->name, "rss")) {
                                // RSS 2.0 or <1.0 document
                                if (!parse_rss_2_0(result, root)) {
                                        free(result);
@@ -219,7 +241,7 @@ PRSS* prss_parse_doc(xmlDocPtr doc)
                        }
                }
                root = root->next;
-       } while(root);
+       } while (root);
        free(result);
        return NULL;
 }
index fb878d2..6e5579e 100644 (file)
@@ -1,8 +1,7 @@
-/*
- * $Id$
+/* $Id$
  *
  * Copyright (c) 2007 Mikko Sysikaski <mikko.sysikaski@gmail.com>
- *                    Toni Spets <toni.spets@gmail.com>
+ *                                       Toni Spets <toni.spets@gmail.com>
  *
  * Permission to use, copy, modify, and distribute this software for any
  * purpose with or without fee is hereby granted, provided that the above
@@ -14,8 +13,7 @@
  * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
  * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
  * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
- * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
- */
+ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */
 
 #ifndef PRSS_H
 #define PRSS_H
 #include <libxml/parser.h>
 
 typedef struct PRSS_Item_ {
-       char* title;
-       char* link;
-       char* description;
-       char* category;
-       char* pubdate;
-       char* guid;
+       char *title;
+       char *link;
+       char *description;
+       char *category;
+       char *pubdate;
+       char *guid;
 } PRSS_Item;
 
 typedef struct PRSS_ {
        xmlDocPtr _data;
-       char* version;
-       
-       char* title;
-       char* link;
-       char* description;
-       char* language;
-       char* generator;
-       char* managingeditor;
-       char* webmaster;
-       char* docs;
-       char* lastbuilddate;
-       char* pubdate;
-       char* copyright;
-       char* ttl;
+       char *version;
 
-       PRSS_Item* items;
+       char *title;
+       char *link;
+       char *description;
+       char *language;
+       char *generator;
+       char *managingeditor;
+       char *webmaster;
+       char *docs;
+       char *lastbuilddate;
+       char *pubdate;
+       char *copyright;
+       char *ttl;
+
+       PRSS_Item *items;
        int item_count;
 } PRSS;
 
 /* Functions for parsing RSS-data */
-PRSS* prss_parse_data(const char *xml_data);
-PRSS* prss_parse_file(const char *xml_file);
+PRSS *prss_parse_data(const char *xml_data);
+PRSS *prss_parse_file(const char *xml_file);
 
-// Works wrong currently when called from application!
-//PRSS* prss_parse_doc(xmlDocPtr doc);
+/* // Works wrong currently when called from application!
+PRSS *prss_parse_doc(xmlDocPtr doc); */
 
 /* Frees the PRSS-stucture returned by prss_parse_*.
  * The memory area pointed by data becomes invalid
  * after call to this function. */
-void prss_free(PRSS* data);
+void prss_free(PRSS *data);
 
-#endif // PRSS_H
+#endif /* PRSS_H */
index d8db840..84d6755 100644 (file)
--- a/src/rss.c
+++ b/src/rss.c
@@ -1,5 +1,4 @@
-/*
- * Conky, a system monitor, based on torsmo
+/* Conky, a system monitor, based on torsmo
  *
  * Any original torsmo code is licensed under the BSD license
  *
@@ -8,7 +7,8 @@
  * Please see COPYING for details
  *
  * Copyright (c) 2007 Toni Spets
- * Copyright (c) 2005-2007 Brenden Matthews, Philip Kovacs, et. al. (see AUTHORS)
+ * Copyright (c) 2005-2007 Brenden Matthews, Philip Kovacs, et. al.
+ *     (see AUTHORS)
  * All rights reserved.
  *
  * This program is free software: you can redistribute it and/or modify
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  * GNU General Public License for more details.
  * You should have received a copy of the GNU General Public License
- * along with this program.  If not, see <http://www.gnu.org/licenses/>. 
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
  *
- *  $Id$
- */
+ * $Id$ */
 
 #include <stdio.h>
 #include <string.h>
@@ -44,21 +43,20 @@ struct MemoryStruct {
 };
 
 typedef struct feed_ {
-       char* uri;
+       char *uri;
        int last_update;
-       PRSS* data;
+       PRSS *data;
 } feed;
 
 int num_feeds = 0;
 feed feeds[MAX_FEEDS];
 
-size_t
-WriteMemoryCallback(void *ptr, size_t size, size_t nmemb, void *data)
+size_t WriteMemoryCallback(void *ptr, size_t size, size_t nmemb, void *data)
 {
        size_t realsize = size * nmemb;
-       struct MemoryStruct *mem = (struct MemoryStruct *)data;
+       struct MemoryStruct *mem = (struct MemoryStruct *) data;
 
-       mem->memory = (char *)realloc(mem->memory, mem->size + realsize + 1);
+       mem->memory = (char *) realloc(mem->memory, mem->size + realsize + 1);
        if (mem->memory) {
                memcpy(&(mem->memory[mem->size]), ptr, realsize);
                mem->size += realsize;
@@ -67,21 +65,22 @@ WriteMemoryCallback(void *ptr, size_t size, size_t nmemb, void *data)
        return realsize;
 }
 
-
 int rss_delay(int *wait, int delay)
 {
        time_t now = time(NULL);
 
        // make it minutes
-       if(delay < 1) delay = 1;
+       if (delay < 1) {
+               delay = 1;
+       }
        delay *= 60;
 
-       if(!*wait) {
+       if (!*wait) {
                *wait = now + delay;
                return 1;
        }
 
-       if(now >= *wait + delay) {
+       if (now >= *wait + delay) {
                *wait = now + delay;
                return 1;
        }
@@ -92,7 +91,8 @@ int rss_delay(int *wait, int delay)
 void init_rss_info()
 {
        int i;
-       for(i = 0; i < MAX_FEEDS; i++) {
+
+       for (i = 0; i < MAX_FEEDS; i++) {
                feeds[i].uri = NULL;
                feeds[i].data = NULL;
                feeds[i].last_update = 0;
@@ -102,18 +102,22 @@ void init_rss_info()
 void free_rss_info()
 {
        int i;
-       for(i = 0; i < num_feeds; i++)
-               if(feeds[i].uri != NULL)
+
+       for (i = 0; i < num_feeds; i++) {
+               if (feeds[i].uri != NULL) {
                        free(feeds[i].uri);
+               }
+       }
 }
 
-PRSS*
-get_rss_info(char *uri, int delay)
+PRSS *get_rss_info(char *uri, int delay)
 {
        CURL *curl = NULL;
        CURLcode res;
+
        // curl temps
        struct MemoryStruct chunk;
+
        chunk.memory = NULL;
        chunk.size = 0;
 
@@ -125,16 +129,19 @@ get_rss_info(char *uri, int delay)
        int i;
 
        // first seek for the uri in list
-       for(i = 0; i < num_feeds; i++) {
-               if(feeds[i].uri != NULL)
-                       if(!strcmp(feeds[i].uri, uri)) {
+       for (i = 0; i < num_feeds; i++) {
+               if (feeds[i].uri != NULL) {
+                       if (!strcmp(feeds[i].uri, uri)) {
                                curfeed = &feeds[i];
                                break;
                        }
+               }
        }
 
-       if(!curfeed) { // new feed
-               if(num_feeds == MAX_FEEDS-1) return NULL;
+       if (!curfeed) { // new feed
+               if (num_feeds == MAX_FEEDS - 1) {
+                       return NULL;
+               }
                curfeed = &feeds[num_feeds];
                curfeed->uri = strdup(uri);
                num_feeds++;
@@ -143,28 +150,30 @@ get_rss_info(char *uri, int delay)
        last_update = &curfeed->last_update;
        curdata = curfeed->data;
 
-       if(!rss_delay(last_update, delay))
-               return curdata; // wait for delay to pass
+       if (!rss_delay(last_update, delay)) {
+               return curdata; // wait for delay to pass
+       }
 
-       if(curdata != NULL) {
-               prss_free(curdata); // clean up old data
+       if (curdata != NULL) {
+               prss_free(curdata);     // clean up old data
                curdata = NULL;
        }
 
        curl = curl_easy_init();
-       if(curl) {
+       if (curl) {
                curl_easy_setopt(curl, CURLOPT_URL, uri);
                curl_easy_setopt(curl, CURLOPT_NOPROGRESS, 1);
                curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, WriteMemoryCallback);
-               curl_easy_setopt(curl, CURLOPT_WRITEDATA, (void *)&chunk);
+               curl_easy_setopt(curl, CURLOPT_WRITEDATA, (void *) &chunk);
                curl_easy_setopt(curl, CURLOPT_USERAGENT, "conky-rss/1.0");
 
                res = curl_easy_perform(curl);
-               if(chunk.size) {
+               if (chunk.size) {
                        curdata = prss_parse_data(chunk.memory);
                        free(chunk.memory);
-               } else
+               } else {
                        ERR("No data from server");
+               }
 
                curl_easy_cleanup(curl);
        }
index 76251b9..ffa7f20 100644 (file)
@@ -1,5 +1,4 @@
-/*
- * Conky, a system monitor, based on torsmo
+/* Conky, a system monitor, based on torsmo
  *
  * Any original torsmo code is licensed under the BSD license
  *
@@ -7,7 +6,8 @@
  *
  * Please see COPYING for details
  *
- * Copyright (c) 2005-2007 Brenden Matthews, Philip Kovacs, et. al. (see AUTHORS)
+ * Copyright (c) 2005-2007 Brenden Matthews, Philip Kovacs, et. al.
+ *     (see AUTHORS)
  * All rights reserved.
  *
  * This program is free software: you can redistribute it and/or modify
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  * GNU General Public License for more details.
  * You should have received a copy of the GNU General Public License
- * along with this program.  If not, see <http://www.gnu.org/licenses/>. 
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
  *
- *  $Id$
- */
+ * $Id$ */
 
 /* doesn't work, feel free to finish this */
 #include "conky.h"
@@ -62,12 +61,10 @@ double get_uptime()
        if (ksp != NULL) {
                if (kstat_read(kstat, ksp, NULL) >= 0) {
                        kstat_named_t *knp;
-                       knp =
-                           (kstat_named_t *) kstat_data_lookup(ksp,
-                                                               "boot_time");
+
+                       knp = (kstat_named_t *) kstat_data_lookup(ksp, "boot_time");
                        if (knp != NULL) {
-                               return get_time() -
-                                   (double) knp->value.ui32;
+                               return get_time() - (double) knp->value.ui32;
                        }
                }
        }
index 05d4653..70ddaf4 100644 (file)
@@ -1,7 +1,6 @@
 /* $Id$ */
 
-/* 
- * timed_thread.c: Abstraction layer for timed threads
+/* timed_thread.c: Abstraction layer for timed threads
  *
  * Copyright (C) 2006-2007 Philip Kovacs pkovacs@users.sourceforge.net
  *
@@ -18,9 +17,7 @@
  * You should have received a copy of the GNU Lesser General Public
  * License along with this library; if not, write to the Free Software
  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301
- * USA.
- *
- */
+ * USA. */
 
 #ifdef HAVE_CONFIG_H
 #include <config.h>
 
 /* Abstraction layer for timed threads */
 
-static int now (struct timespec *);
+static int now(struct timespec *);
 
 /* private */
-struct _timed_thread 
-{
-  pthread_t thread;               /* thread itself */
-  pthread_attr_t thread_attr;     /* thread attributes */
-  pthread_mutex_t cs_mutex;       /* critical section mutex */
-  pthread_mutex_t runnable_mutex; /* only for the runnable_cond */
-  pthread_cond_t runnable_cond;   /* signalled to stop the thread */
-  void *(*start_routine)(void*);  /* thread function to run */
-  void *arg;                      /* thread function argument */
-  struct timespec interval_time;  /* interval_usecs as a struct timespec */
+struct _timed_thread {
+       pthread_t thread;                               /* thread itself */
+       pthread_attr_t thread_attr;             /* thread attributes */
+       pthread_mutex_t cs_mutex;               /* critical section mutex */
+       pthread_mutex_t runnable_mutex; /* only for the runnable_cond */
+       pthread_cond_t runnable_cond;   /* signalled to stop the thread */
+       void *(*start_routine)(void *); /* thread function to run */
+       void *arg;                                              /* thread function argument */
+       struct timespec interval_time;  /* interval_usecs as a struct timespec */
 };
 
 /* linked list of created threads */
-typedef struct _timed_thread_list
-{
-  timed_thread *p_timed_thread;
-  timed_thread **addr_of_p_timed_thread;
-  struct _timed_thread_list *next;
+typedef struct _timed_thread_list {
+       timed_thread *p_timed_thread;
+       timed_thread **addr_of_p_timed_thread;
+       struct _timed_thread_list *next;
 } timed_thread_node, timed_thread_list;
 
 static timed_thread_list *p_timed_thread_list_head = NULL;
 static timed_thread_list *p_timed_thread_list_tail = NULL;
 
-static int now (struct timespec *abstime)
+static int now(struct timespec *abstime)
 {
-  if (!abstime)
-    return (-1);
+       if (!abstime) {
+               return -1;
+       }
 
 #ifdef HAVE_CLOCK_GETTIME
-  return clock_gettime (CLOCK_REALTIME, abstime);
+       return clock_gettime(CLOCK_REALTIME, abstime);
 #else
-  /* fallback to gettimeofday () */
-  struct timeval tv;
-  if (gettimeofday (&tv, NULL) != 0)
-    return (-1);
-
-  abstime->tv_sec = tv.tv_sec;
-  abstime->tv_nsec = tv.tv_usec * 1000;
-  return 0;
+       /* fallback to gettimeofday () */
+       struct timeval tv;
+
+       if (gettimeofday(&tv, NULL) != 0) {
+               return -1;
+       }
+
+       abstime->tv_sec = tv.tv_sec;
+       abstime->tv_nsec = tv.tv_usec * 1000;
+       return 0;
 #endif
 }
 
-
 /* create a timed thread (object creation only) */
-timed_thread* 
-timed_thread_create (void *(*start_routine)(void*), void *arg, unsigned int interval_usecs)
+timed_thread *timed_thread_create(void *start_routine(void *), void *arg,
+               unsigned int interval_usecs)
 {
-  timed_thread *p_timed_thread;
-
-  assert (start_routine != NULL);
-  assert (interval_usecs >= MINIMUM_INTERVAL_USECS);
-
-  if ((p_timed_thread = calloc (sizeof(timed_thread), 1)) == 0)
-    return NULL;
-
-  /* init attributes, e.g. joinable thread */
-  pthread_attr_init (&p_timed_thread->thread_attr);
-  pthread_attr_setdetachstate (&p_timed_thread->thread_attr, PTHREAD_CREATE_JOINABLE);
-  /* init mutexes */
-  pthread_mutex_init (&p_timed_thread->cs_mutex, NULL);
-  pthread_mutex_init (&p_timed_thread->runnable_mutex, NULL);
-  /* init cond */
-  pthread_cond_init (&p_timed_thread->runnable_cond, NULL);
-
-  p_timed_thread->start_routine = start_routine;
-  p_timed_thread->arg = arg;
-
-  /* seconds portion of the microseconds interval */
-  p_timed_thread->interval_time.tv_sec = (time_t)(interval_usecs / 1000000);
-  /* remaining microseconds convert to nanoseconds */
-  p_timed_thread->interval_time.tv_nsec = (long)((interval_usecs % 1000000) * 1000);
-
-  /*
-  printf ("interval_time.tv_sec = %li, .tv_nsec = %li\n",
-            p_timed_thread->interval_time.tv_sec,
-            p_timed_thread->interval_time.tv_nsec);
-  */
-  return p_timed_thread;
+       timed_thread *p_timed_thread;
+
+       assert(start_routine != NULL);
+       assert(interval_usecs >= MINIMUM_INTERVAL_USECS);
+
+       if ((p_timed_thread = calloc(sizeof(timed_thread), 1)) == 0) {
+               return NULL;
+       }
+
+       /* init attributes, e.g. joinable thread */
+       pthread_attr_init(&p_timed_thread->thread_attr);
+       pthread_attr_setdetachstate(&p_timed_thread->thread_attr,
+               PTHREAD_CREATE_JOINABLE);
+       /* init mutexes */
+       pthread_mutex_init(&p_timed_thread->cs_mutex, NULL);
+       pthread_mutex_init(&p_timed_thread->runnable_mutex, NULL);
+       /* init cond */
+       pthread_cond_init(&p_timed_thread->runnable_cond, NULL);
+
+       p_timed_thread->start_routine = start_routine;
+       p_timed_thread->arg = arg;
+
+       /* seconds portion of the microseconds interval */
+       p_timed_thread->interval_time.tv_sec = (time_t) (interval_usecs / 1000000);
+       /* remaining microseconds convert to nanoseconds */
+       p_timed_thread->interval_time.tv_nsec =
+               (long) ((interval_usecs % 1000000) * 1000);
+
+       /* printf("interval_time.tv_sec = %li, .tv_nsec = %li\n",
+               p_timed_thread->interval_time.tv_sec,
+               p_timed_thread->interval_time.tv_nsec); */
+       return p_timed_thread;
 }
 
 /* run a timed thread (drop the thread and run it) */
-int 
-timed_thread_run (timed_thread* p_timed_thread)
+int timed_thread_run(timed_thread *p_timed_thread)
 {
-  return pthread_create (&p_timed_thread->thread, &p_timed_thread->thread_attr,
-                         p_timed_thread->start_routine, p_timed_thread->arg);
+       return pthread_create(&p_timed_thread->thread, &p_timed_thread->thread_attr,
+               p_timed_thread->start_routine, p_timed_thread->arg);
 }
 
 /* destroy a timed thread.
- * optional addr_of_p_timed_thread to set callers pointer to NULL as a convenience. */
-void 
-timed_thread_destroy (timed_thread* p_timed_thread, timed_thread** addr_of_p_timed_thread)
+ * optional addr_of_p_timed_thread to set callers pointer to NULL as a
+ * convenience. */
+void timed_thread_destroy(timed_thread *p_timed_thread,
+               timed_thread **addr_of_p_timed_thread)
 {
-  assert (p_timed_thread != NULL);
-  assert ((addr_of_p_timed_thread == NULL) || (*addr_of_p_timed_thread == p_timed_thread));
-
-  /* signal thread to stop */
-  pthread_mutex_lock (&p_timed_thread->runnable_mutex);
-  pthread_cond_signal (&p_timed_thread->runnable_cond);
-  pthread_mutex_unlock (&p_timed_thread->runnable_mutex);
-
-  /* join the terminating thread */
-  if (p_timed_thread->thread)
-    pthread_join (p_timed_thread->thread, NULL);
-
-  /* clean up */
-  pthread_attr_destroy (&p_timed_thread->thread_attr);
-  pthread_mutex_destroy (&p_timed_thread->cs_mutex);
-  pthread_mutex_destroy (&p_timed_thread->runnable_mutex);
-  pthread_cond_destroy (&p_timed_thread->runnable_cond);
-
-  free (p_timed_thread);
-  if (addr_of_p_timed_thread)
-    *addr_of_p_timed_thread = NULL;
+       assert(p_timed_thread != NULL);
+       assert((addr_of_p_timed_thread == NULL)
+               || (*addr_of_p_timed_thread == p_timed_thread));
+
+       /* signal thread to stop */
+       pthread_mutex_lock(&p_timed_thread->runnable_mutex);
+       pthread_cond_signal(&p_timed_thread->runnable_cond);
+       pthread_mutex_unlock(&p_timed_thread->runnable_mutex);
+
+       /* join the terminating thread */
+       if (p_timed_thread->thread) {
+               pthread_join(p_timed_thread->thread, NULL);
+       }
+
+       /* clean up */
+       pthread_attr_destroy(&p_timed_thread->thread_attr);
+       pthread_mutex_destroy(&p_timed_thread->cs_mutex);
+       pthread_mutex_destroy(&p_timed_thread->runnable_mutex);
+       pthread_cond_destroy(&p_timed_thread->runnable_cond);
+
+       free(p_timed_thread);
+       if (addr_of_p_timed_thread) {
+               *addr_of_p_timed_thread = NULL;
+       }
 }
 
-
 /* lock a timed thread for critical section activity */
-int
-timed_thread_lock (timed_thread* p_timed_thread)
+int timed_thread_lock(timed_thread *p_timed_thread)
 {
-  assert (p_timed_thread != NULL);
+       assert(p_timed_thread != NULL);
 
-  return pthread_mutex_lock (&p_timed_thread->cs_mutex);
+       return pthread_mutex_lock(&p_timed_thread->cs_mutex);
 }
 
-
 /* unlock a timed thread after critical section activity */
-int
-timed_thread_unlock (timed_thread* p_timed_thread)
+int timed_thread_unlock(timed_thread *p_timed_thread)
 {
-  assert (p_timed_thread != NULL);
+       assert(p_timed_thread != NULL);
 
-  return pthread_mutex_unlock (&p_timed_thread->cs_mutex);
+       return pthread_mutex_unlock(&p_timed_thread->cs_mutex);
 }
 
-
-/* thread waits interval_usecs for runnable_cond to be signaled.  returns 1 if signaled, 
- * -1 on error, and 0 otherwise.  caller should call timed_thread_exit() on any non-zero 
- * return value. */
-int 
-timed_thread_test (timed_thread* p_timed_thread)
+/* thread waits interval_usecs for runnable_cond to be signaled.
+ * returns 1 if signaled, -1 on error, and 0 otherwise.
+ * caller should call timed_thread_exit() on any non-zero return value. */
+int timed_thread_test(timed_thread *p_timed_thread)
 {
-  struct timespec wait_time;
-  int rc;
-
-  assert (p_timed_thread != NULL);
-
-  if (now (&wait_time)) return (-1);
-  /*printf ("PRE:wait_time.tv_secs = %li, .tv_nsecs = %li\n", wait_time.tv_sec, wait_time.tv_nsec);*/
-  /* add in the wait interval */
-  if (1000000000-wait_time.tv_nsec <= p_timed_thread->interval_time.tv_nsec)
-  {
-    /* perform nsec->sec carry operation */
-    wait_time.tv_sec += p_timed_thread->interval_time.tv_sec + 1;
-    wait_time.tv_nsec -= 1000000000-p_timed_thread->interval_time.tv_nsec;
-    /*printf ("001:wait_time.tv_secs = %li, .tv_nsecs = %li\n", wait_time.tv_sec, wait_time.tv_nsec);*/
-  }
-  else
-  {
-    /* no carry needed, just add respective components */
-    wait_time.tv_sec += p_timed_thread->interval_time.tv_sec;
-    wait_time.tv_nsec += p_timed_thread->interval_time.tv_nsec;
-    /*printf ("002:wait_time.tv_secs = %li, .tv_nsecs = %li\n", wait_time.tv_sec, wait_time.tv_nsec);*/
-  }
-
-  /* acquire runnable_cond mutex */
-  if (pthread_mutex_lock (&p_timed_thread->runnable_mutex))
-    return (-1);  /* could not acquire runnable_cond mutex, so tell caller to exit thread */
-
-  /* release mutex and wait until future time for runnable_cond to signal */
-  rc = pthread_cond_timedwait (&p_timed_thread->runnable_cond,
-                               &p_timed_thread->runnable_mutex,
-                               &wait_time);
-  /* mutex re-acquired, so release it */
-  pthread_mutex_unlock (&p_timed_thread->runnable_mutex);
-
-  if (rc==0)
-    return 1; /* runnable_cond was signaled, so tell caller to exit thread */
-
-  /* tell caller not to exit yet */
-  return 0;
+       struct timespec wait_time;
+       int rc;
+
+       assert(p_timed_thread != NULL);
+
+       if (now(&wait_time)) {
+               return -1;
+       }
+       /* printf("PRE:wait_time.tv_secs = %li, .tv_nsecs = %li\n",
+               wait_time.tv_sec, wait_time.tv_nsec); */
+
+       /* add in the wait interval */
+       if (1000000000 - wait_time.tv_nsec
+                       <= p_timed_thread->interval_time.tv_nsec) {
+               /* perform nsec->sec carry operation */
+               wait_time.tv_sec += p_timed_thread->interval_time.tv_sec + 1;
+               wait_time.tv_nsec -= 1000000000 - p_timed_thread->interval_time.tv_nsec;
+               /* printf("001:wait_time.tv_secs = %li, .tv_nsecs = %li\n",
+                       wait_time.tv_sec, wait_time.tv_nsec); */
+       } else {
+               /* no carry needed, just add respective components */
+               wait_time.tv_sec += p_timed_thread->interval_time.tv_sec;
+               wait_time.tv_nsec += p_timed_thread->interval_time.tv_nsec;
+               /* printf("002:wait_time.tv_secs = %li, .tv_nsecs = %li\n",
+                       wait_time.tv_sec, wait_time.tv_nsec); */
+       }
+
+       /* acquire runnable_cond mutex */
+       if (pthread_mutex_lock(&p_timed_thread->runnable_mutex)) {
+               /* could not acquire runnable_cond mutex,
+                * so tell caller to exit thread */
+               return -1;
+       }
+
+       /* release mutex and wait until future time for runnable_cond to signal */
+       rc = pthread_cond_timedwait(&p_timed_thread->runnable_cond,
+               &p_timed_thread->runnable_mutex, &wait_time);
+       /* mutex re-acquired, so release it */
+       pthread_mutex_unlock(&p_timed_thread->runnable_mutex);
+
+       if (rc == 0) {
+               /* runnable_cond was signaled, so tell caller to exit thread */
+               return 1;
+       }
+
+       /* tell caller not to exit yet */
+       return 0;
 }
 
-
 /* exit a timed thread */
-void 
-timed_thread_exit (timed_thread* p_timed_thread)
+void timed_thread_exit(timed_thread *p_timed_thread)
 {
-  assert (p_timed_thread != NULL);
+       assert(p_timed_thread != NULL);
 
-  pthread_exit (NULL);
+       pthread_exit(NULL);
 }
 
-
-/* register a timed thread for future destruction via timed_thread_destroy_registered_threads() */
-int 
-timed_thread_register (timed_thread* p_timed_thread, timed_thread** addr_of_p_timed_thread)
+/* register a timed thread for future destruction via
+ * timed_thread_destroy_registered_threads() */
+int timed_thread_register(timed_thread *p_timed_thread,
+               timed_thread **addr_of_p_timed_thread)
 {
-  timed_thread_node *p_node;
-
-  assert ((addr_of_p_timed_thread == NULL) || (*addr_of_p_timed_thread == p_timed_thread));
-
-  if ((p_node = calloc (sizeof (timed_thread_node), 1)) == 0)
-    return 0;
-    
-  p_node->p_timed_thread = p_timed_thread;
-  p_node->addr_of_p_timed_thread = addr_of_p_timed_thread;
-  p_node->next = NULL;
-
-  if (!p_timed_thread_list_tail)
-  {
-    /* first node of empty list */
-    p_timed_thread_list_tail = p_node;
-    p_timed_thread_list_head = p_node;
-  }
-  else
-  {
-    /* add node to tail of non-empty list */
-    p_timed_thread_list_tail->next = p_node;
-    p_timed_thread_list_tail = p_node;
-  }
-
-  return 0;
+       timed_thread_node *p_node;
+
+       assert((addr_of_p_timed_thread == NULL)
+               || (*addr_of_p_timed_thread == p_timed_thread));
+
+       if ((p_node = calloc(sizeof(timed_thread_node), 1)) == 0) {
+               return 0;
+       }
+
+       p_node->p_timed_thread = p_timed_thread;
+       p_node->addr_of_p_timed_thread = addr_of_p_timed_thread;
+       p_node->next = NULL;
+
+       if (!p_timed_thread_list_tail) {
+               /* first node of empty list */
+               p_timed_thread_list_tail = p_node;
+               p_timed_thread_list_head = p_node;
+       } else {
+               /* add node to tail of non-empty list */
+               p_timed_thread_list_tail->next = p_node;
+               p_timed_thread_list_tail = p_node;
+       }
+
+       return 0;
 }
 
-
 /* destroy all registered timed threads */
-void 
-timed_thread_destroy_registered_threads (void)
+void timed_thread_destroy_registered_threads(void)
 {
-  timed_thread_node *p_node, *p_next;
-
-  for (p_node=p_timed_thread_list_head;
-       p_node;
-       p_node=p_next)
-  {
-    p_next = p_node->next;
-    timed_thread_destroy (p_node->p_timed_thread, p_node->addr_of_p_timed_thread);
-    free (p_node);
-    p_node = NULL;
-  }
-
-  p_timed_thread_list_head = NULL;
-  p_timed_thread_list_tail = NULL;
+       timed_thread_node *p_node, *p_next;
+
+       for (p_node = p_timed_thread_list_head; p_node; p_node = p_next) {
+               p_next = p_node->next;
+               timed_thread_destroy(p_node->p_timed_thread,
+                       p_node->addr_of_p_timed_thread);
+               free(p_node);
+               p_node = NULL;
+       }
+
+       p_timed_thread_list_head = NULL;
+       p_timed_thread_list_tail = NULL;
 }
-
index 0451c4b..13cd880 100644 (file)
@@ -1,7 +1,6 @@
 /* $Id$ */
 
-/* 
- * timed_thread.h: Abstraction layer for timed threads
+/* timed_thread.h: Abstraction layer for timed threads
  *
  * Copyright (C) 2006-2007 Philip Kovacs pkovacs@users.sourceforge.net
  *
  * You should have received a copy of the GNU Lesser General Public
  * License along with this library; if not, write to the Free Software
  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301
- * USA.
- *
- */
+ * USA. */
 
 #ifndef _TIMED_THREAD_H_
 #define _TIMED_THREAD_H_
 
-#define MINIMUM_INTERVAL_USECS 10000  /* 10000 microseconds = 10 ms =  0.01 sec */
+/* 10000 microseconds = 10 ms =  0.01 sec */
+#define MINIMUM_INTERVAL_USECS 10000
 
 /* opaque structure for clients */
 typedef struct _timed_thread timed_thread;
 
 /* create a timed thread (object creation only) */
-timed_thread* timed_thread_create (void *(*start_routine)(void*), void *arg, unsigned int interval_usecs);
+timed_thread *timed_thread_create(void *start_routine(void *), void *arg,
+       unsigned int interval_usecs);
 
 /* run a timed thread (drop the thread and run it) */
-int timed_thread_run (timed_thread* p_timed_thread);
+int timed_thread_run(timed_thread *p_timed_thread);
 
 /* destroy a timed thread */
-void timed_thread_destroy (timed_thread* p_timed_thread, timed_thread** addr_of_p_timed_thread);
+void timed_thread_destroy(timed_thread *p_timed_thread,
+       timed_thread **addr_of_p_timed_thread);
 
 /* lock a timed thread for critical section activity */
-int timed_thread_lock (timed_thread* p_timed_thread);
+int timed_thread_lock(timed_thread *p_timed_thread);
 
 /* unlock a timed thread after critical section activity */
-int timed_thread_unlock (timed_thread* p_timed_thread);
+int timed_thread_unlock(timed_thread *p_timed_thread);
 
-/* waits required interval for termination signal and returns 1 if got it, 0 otherwise */
-int timed_thread_test (timed_thread* p_timed_thread);
+/* waits required interval for termination signal
+ * returns 1 if received,
+ * 0 otherwise */
+int timed_thread_test(timed_thread *p_timed_thread);
 
 /* exit a timed thread */
-void timed_thread_exit (timed_thread* p_timed_thread);
+void timed_thread_exit(timed_thread *p_timed_thread);
 
-/* register a timed thread for future destruction via timed_thread_destroy_registered_threads() */
-int timed_thread_register (timed_thread* p_timed_thread, timed_thread** addr_of_p_timed_thread);
+/* register a timed thread for future destruction via
+ * timed_thread_destroy_registered_threads() */
+int timed_thread_register(timed_thread *p_timed_thread,
+       timed_thread **addr_of_p_timed_thread);
 
 /* destroy all registered timed threads */
-void timed_thread_destroy_registered_threads (void);
+void timed_thread_destroy_registered_threads(void);
 
 #endif /* #ifdef _TIMED_THREAD_H_ */
index 3a5f107..a5b64f5 100644 (file)
--- a/src/top.c
+++ b/src/top.c
@@ -1,5 +1,4 @@
-/*
- * Conky, a system monitor, based on torsmo
+/* Conky, a system monitor, based on torsmo
  *
  * Any original torsmo code is licensed under the BSD license
  *
@@ -8,8 +7,9 @@
  * Please see COPYING for details
  *
  * Copyright (c) 2005 Adi Zaimi, Dan Piponi <dan@tanelorn.demon.co.uk>,
- *                    Dave Clark <clarkd@skynet.ca>
- * Copyright (c) 2005-2007 Brenden Matthews, Philip Kovacs, et. al. (see AUTHORS)
+ *                                       Dave Clark <clarkd@skynet.ca>
+ * Copyright (c) 2005-2007 Brenden Matthews, Philip Kovacs, et. al.
+ *     (see AUTHORS)
  * All rights reserved.
  *
  * This program is free software: you can redistribute it and/or modify
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  * GNU General Public License for more details.
  * You should have received a copy of the GNU General Public License
- * along with this program.  If not, see <http://www.gnu.org/licenses/>. 
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
  *
- *  $Id$
- */
+ * $Id$ */
 
 #include "top.h"
 
@@ -38,11 +37,10 @@ struct process *get_first_process()
        return first_process;
 }
 
-
-
 void free_all_processes()
 {
        struct process *next = NULL, *pr = first_process;
+
        while (pr) {
                next = pr->next;
                if (pr->name) {
@@ -57,33 +55,32 @@ void free_all_processes()
 static struct process *find_process(pid_t pid)
 {
        struct process *p = first_process;
+
        while (p) {
-               if (p->pid == pid)
+               if (p->pid == pid) {
                        return p;
+               }
                p = p->next;
        }
        return 0;
 }
 
-/*
-* Create a new process object and insert it into the process list
-*/
+/* Create a new process object and insert it into the process list */
 static struct process *new_process(int p)
 {
        struct process *process;
-       process = (struct process*)malloc(sizeof(struct process));
+       process = (struct process *) malloc(sizeof(struct process));
 
        // clean up memory first
        memset(process, 0, sizeof(struct process));
 
-       /*
-        * Do stitching necessary for doubly linked list
-        */
+       /* Do stitching necessary for doubly linked list */
        process->name = 0;
        process->previous = 0;
        process->next = first_process;
-       if (process->next)
+       if (process->next) {
                process->next->previous = process;
+       }
        first_process = process;
 
        process->pid = p;
@@ -92,37 +89,25 @@ static struct process *new_process(int p)
        process->previous_kernel_time = ULONG_MAX;
        process->counted = 1;
 
-       
-       /*    process_find_name(process); */
+       /* process_find_name(process); */
 
        return process;
 }
 
-/******************************************/
-/* Functions                              */
-/******************************************/
-
-static int process_parse_stat(struct process *);
-static int update_process_table(void);
-static int calculate_cpu(struct process *);
-static void process_cleanup(void);
-static void delete_process(struct process *);
-/*inline void draw_processes(void);*/
-static unsigned long long calc_cpu_total(void);
-static void calc_cpu_each(unsigned long long);
+/******************************************
+ * Functions                                                     *
+ ******************************************/
 
+/******************************************
+ * Extract information from /proc                *
+ ******************************************/
 
-/******************************************/
-/* Extract information from /proc         */
-/******************************************/
-
-/*
-* These are the guts that extract information out of /proc.
-* Anyone hoping to port wmtop should look here first.
-*/
+/* These are the guts that extract information out of /proc.
+ * Anyone hoping to port wmtop should look here first. */
 static int process_parse_stat(struct process *process)
 {
        struct information *cur;
+
        cur = &info;
        char line[BUFFER_LEN] = { 0 }, filename[BUFFER_LEN], procname[BUFFER_LEN];
        int ps;
@@ -134,50 +119,42 @@ static int process_parse_stat(struct process *process)
        int endl;
        int nice_val;
 
-       snprintf(filename, sizeof(filename), PROCFS_TEMPLATE,
-                process->pid);
+       snprintf(filename, sizeof(filename), PROCFS_TEMPLATE, process->pid);
 
        ps = open(filename, O_RDONLY);
-       if (ps < 0)
-               /*
-                * The process must have finished in the last few jiffies!
-                */
+       if (ps < 0) {
+               /* The process must have finished in the last few jiffies! */
                return 1;
+       }
 
-       /*
-        * Mark process as up-to-date.
-        */
+       /* Mark process as up-to-date. */
        process->time_stamp = g_time;
 
        rc = read(ps, line, sizeof(line));
        close(ps);
-       if (rc < 0)
+       if (rc < 0) {
                return 1;
+       }
 
-       /*
-        * Extract cpu times from data in /proc filesystem
-        */
-       rc = sscanf(line,
-                   "%*s %s %*s %*s %*s %*s %*s %*s %*s %*s %*s %*s %*s %lu %lu %*s %*s %*s %d %*s %*s %*s %d %d",
-                   procname, &process->user_time, &process->kernel_time,
-                   &nice_val, &process->vsize, &process->rss);
-       if (rc < 5)
+       /* Extract cpu times from data in /proc filesystem */
+       rc = sscanf(line, "%*s %s %*s %*s %*s %*s %*s %*s %*s %*s %*s %*s %*s %lu "
+               "%lu %*s %*s %*s %d %*s %*s %*s %d %d", procname, &process->user_time,
+               &process->kernel_time, &nice_val, &process->vsize, &process->rss);
+       if (rc < 5) {
                return 1;
-       /*
-        * Remove parentheses from the process name stored in /proc/ under Linux...
-        */
+       }
+       /* Remove parentheses from the process name stored in /proc/ under Linux */
        r = procname + 1;
        /* remove any "kdeinit: " */
        if (r == strstr(r, "kdeinit")) {
-               snprintf(filename, sizeof(filename),
-                        PROCFS_CMDLINE_TEMPLATE, process->pid);
+               snprintf(filename, sizeof(filename), PROCFS_CMDLINE_TEMPLATE,
+                       process->pid);
 
                ps = open(filename, O_RDONLY);
-               if (ps < 0)
-                       /*
-                        * The process must have finished in the last few jiffies!
-                        */
+               if (ps < 0) {
+                       /* The process must have finished in the last few jiffies! */
                        return 1;
+               }
 
                endl = read(ps, line, sizeof(line));
                close(ps);
@@ -185,20 +162,23 @@ static int process_parse_stat(struct process *process)
                /* null terminate the input */
                line[endl] = 0;
                /* account for "kdeinit: " */
-               if ((char *) line == strstr(line, "kdeinit: "))
+               if ((char *) line == strstr(line, "kdeinit: ")) {
                        r = ((char *) line) + 9;
-               else
+               } else {
                        r = (char *) line;
+               }
 
                q = deparenthesised_name;
                /* stop at space */
-               while (*r && *r != ' ')
+               while (*r && *r != ' ') {
                        *q++ = *r++;
+               }
                *q = 0;
        } else {
                q = deparenthesised_name;
-               while (*r && *r != ')')
+               while (*r && *r != ')') {
                        *q++ = *r++;
+               }
                *q = 0;
        }
 
@@ -208,17 +188,18 @@ static int process_parse_stat(struct process *process)
        process->name = strdup(deparenthesised_name);
        process->rss *= getpagesize();
 
-       if (!cur->memmax)
+       if (!cur->memmax) {
                update_total_processes();
-
-
+       }
 
        process->total_cpu_time = process->user_time + process->kernel_time;
-       process->totalmem = (float)(((float) process->rss / cur->memmax) / 10);
-       if (process->previous_user_time == ULONG_MAX)
+       process->totalmem = (float) (((float) process->rss / cur->memmax) / 10);
+       if (process->previous_user_time == ULONG_MAX) {
                process->previous_user_time = process->user_time;
-       if (process->previous_kernel_time == ULONG_MAX)
+       }
+       if (process->previous_kernel_time == ULONG_MAX) {
                process->previous_kernel_time = process->kernel_time;
+       }
 
        /* store the difference of the user_time */
        user_time = process->user_time - process->previous_user_time;
@@ -231,44 +212,68 @@ static int process_parse_stat(struct process *process)
        /* store only the difference of the user_time here... */
        process->user_time = user_time;
        process->kernel_time = kernel_time;
-                 
 
        return 0;
 }
 
-/******************************************/
-/* Update process table                   */
-/******************************************/
+/******************************************
+ * Get process structure for process pid  *
+ ******************************************/
+
+/* This function seems to hog all of the CPU time.
+ * I can't figure out why - it doesn't do much. */
+static int calculate_cpu(struct process *process)
+{
+       int rc;
+
+       /* compute each process cpu usage by reading /proc/<proc#>/stat */
+       rc = process_parse_stat(process);
+       if (rc)
+               return 1;
+       /* rc = process_parse_statm(process); if (rc) return 1; */
+
+       /*
+        * Check name against the exclusion list
+        */
+       /* if (process->counted && exclusion_expression &&
+        * !regexec(exclusion_expression, process->name, 0, 0, 0))
+        * process->counted = 0; */
+
+       return 0;
+}
+
+/******************************************
+ * Update process table                                          *
+ ******************************************/
 
 static int update_process_table()
 {
        DIR *dir;
        struct dirent *entry;
 
-       if (!(dir = opendir("/proc")))
+       if (!(dir = opendir("/proc"))) {
                return 1;
+       }
 
        ++g_time;
 
-       /*
-        * Get list of processes from /proc directory
-        */
+       /* Get list of processes from /proc directory */
        while ((entry = readdir(dir))) {
                pid_t pid;
 
                if (!entry) {
-                       /*
-                        * Problem reading list of processes
-                        */
+                       /* Problem reading list of processes */
                        closedir(dir);
                        return 1;
                }
 
                if (sscanf(entry->d_name, "%d", &pid) > 0) {
                        struct process *p;
+
                        p = find_process(pid);
-                       if (!p)
+                       if (!p) {
                                p = new_process(pid);
+                       }
 
                        /* compute each process cpu usage */
                        calculate_cpu(p);
@@ -280,64 +285,9 @@ static int update_process_table()
        return 0;
 }
 
-/******************************************/
-/* Get process structure for process pid  */
-/******************************************/
-
-/*
-* This function seems to hog all of the CPU time. I can't figure out why - it
-* doesn't do much.
-*/
-static int calculate_cpu(struct process *process)
-{
-       int rc;
-
-       /* compute each process cpu usage by reading /proc/<proc#>/stat */
-       rc = process_parse_stat(process);
-       if (rc)
-               return 1;
-       /*rc = process_parse_statm(process);
-          if (rc)
-          return 1; */
-
-       /*
-        * Check name against the exclusion list
-        */
-/*     if (process->counted && exclusion_expression
-           && !regexec(exclusion_expression, process->name, 0, 0, 0))
-               process->counted = 0;
-*/
-
-       return 0;
-}
-
-/******************************************/
-/* Strip dead process entries             */
-/******************************************/
-
-static void process_cleanup()
-{
-
-       struct process *p = first_process;
-       while (p) {
-               struct process *current = p;
-
-#if defined(PARANOID)
-               assert(p->id == 0x0badfeed);
-#endif                         /* defined(PARANOID) */
-
-               p = p->next;
-               /*
-                * Delete processes that have died
-                */
-               if (current->time_stamp != g_time)
-                       delete_process(current);
-       }
-}
-
-/******************************************/
-/* Destroy and remove a process           */
-/******************************************/
+/******************************************
+ * Destroy and remove a process           *
+ ******************************************/
 
 static void delete_process(struct process *p)
 {
@@ -348,7 +298,7 @@ static void delete_process(struct process *p)
         * Ensure that deleted processes aren't reused.
         */
        p->id = 0x007babe;
-#endif                         /* defined(PARANOID) */
+#endif /* defined(PARANOID) */
 
        /*
         * Maintain doubly linked list.
@@ -366,9 +316,33 @@ static void delete_process(struct process *p)
        free(p);
 }
 
-/******************************************/
-/* Calculate cpu total                    */
-/******************************************/
+/******************************************
+ * Strip dead process entries                    *
+ ******************************************/
+
+static void process_cleanup()
+{
+
+       struct process *p = first_process;
+
+       while (p) {
+               struct process *current = p;
+
+#if defined(PARANOID)
+               assert(p->id == 0x0badfeed);
+#endif /* defined(PARANOID) */
+
+               p = p->next;
+               /* Delete processes that have died */
+               if (current->time_stamp != g_time) {
+                       delete_process(current);
+               }
+       }
+}
+
+/******************************************
+ * Calculate cpu total                                   *
+ ******************************************/
 #define TMPL_SHORTPROC "%*s %llu %llu %llu %llu"
 #define TMPL_LONGPROC "%*s %llu %llu %llu %llu %llu %llu %llu %llu"
 
@@ -387,15 +361,18 @@ static unsigned long long calc_cpu_total()
        unsigned long long irq = 0;
        unsigned long long softirq = 0;
        unsigned long long steal = 0;
-       char * template = KFLAG_ISSET(KFLAG_IS_LONGSTAT) ? TMPL_LONGPROC : TMPL_SHORTPROC; 
+       char *template =
+               KFLAG_ISSET(KFLAG_IS_LONGSTAT) ? TMPL_LONGPROC : TMPL_SHORTPROC;
+
        ps = open("/proc/stat", O_RDONLY);
        rc = read(ps, line, sizeof(line));
        close(ps);
-       if (rc < 0)
+       if (rc < 0) {
                return 0;
+       }
 
-       sscanf(line, template, &cpu, &nice, &system, &idle, &iowait, &irq, &softirq, &steal);
+       sscanf(line, template, &cpu, &nice, &system, &idle, &iowait, &irq,
+               &softirq, &steal);
        total = cpu + nice + system + idle + iowait + irq + softirq + steal;
 
        t = total - previous_total;
@@ -404,102 +381,112 @@ static unsigned long long calc_cpu_total()
        return t;
 }
 
-/******************************************/
-/* Calculate each processes cpu           */
-/******************************************/
+/******************************************
+ * Calculate each processes cpu                          *
+ ******************************************/
 
 inline static void calc_cpu_each(unsigned long long total)
 {
        struct process *p = first_process;
+
        while (p) {
-               p->amount =
-                   100.0 * (cpu_separate ? info.cpu_count : 1) * (p->user_time + p->kernel_time) / (float)total;
+               p->amount = 100.0 * (cpu_separate ? info.cpu_count : 1) *
+                       (p->user_time + p->kernel_time) / (float) total;
 
                p = p->next;
        }
 }
 
-/******************************************/
-/* Find the top processes                 */
-/******************************************/
+/******************************************
+ * Find the top processes                                *
+ ******************************************/
 
-/*
- * free a  sp_process structure
-*/
-void free_sp(struct sorted_process * sp) {
+/* free a sp_process structure */
+void free_sp(struct sorted_process *sp)
+{
        free(sp);
 }
 
-/*
- * create a new sp_process structure
-*/
-struct sorted_process * malloc_sp(struct process * proc) {
-       struct sorted_process * sp;
+/* create a new sp_process structure */
+struct sorted_process *malloc_sp(struct process *proc)
+{
+       struct sorted_process *sp;
        sp = malloc(sizeof(struct sorted_process));
        sp->greater = NULL;
        sp->less = NULL;
        sp->proc = proc;
-       return(sp);
-} 
-
-/*
- * cpu comparison function for insert_sp_element 
- */
-int compare_cpu(struct process *a, struct process *b) {
-       if (a->amount < b->amount) return 1; 
-       return 0;
+       return sp;
 }
 
-/*
- * mem comparison function for insert_sp_element 
- */
-int compare_mem(struct process *a, struct process *b) {
-       if (a->totalmem < b->totalmem) return 1; 
-       return 0;
+/* cpu comparison function for insert_sp_element */
+int compare_cpu(struct process *a, struct process *b)
+{
+       if (a->amount < b->amount) {
+               return 1;
+       } else if (a->amount > b->amount) {
+               return -1;
+       } else {
+               return 0;
+       }
+}
+
+/* mem comparison function for insert_sp_element */
+int compare_mem(struct process *a, struct process *b)
+{
+       if (a->totalmem < b->totalmem) {
+               return 1;
+       } else if (a->totalmem > b->totalmem) {
+               return -1;
+       } else {
+               return 0;
+       }
 }
 
-/*
- * insert this process into the list in a sorted fashion,
- * or destroy it if it doesn't fit on the list
-*/ 
-int insert_sp_element(
-                     struct sorted_process * sp_cur
-                   , struct sorted_process ** p_sp_head
-                   , struct sorted_process ** p_sp_tail
-                  , int max_elements
-                   , int (*compare_funct) (struct process *, struct process *)
-                 ) {
-
-       struct sorted_process * sp_readthru=NULL, * sp_destroy=NULL;
+/* insert this process into the list in a sorted fashion,
+ * or destroy it if it doesn't fit on the list */
+int insert_sp_element(struct sorted_process *sp_cur,
+               struct sorted_process **p_sp_head, struct sorted_process **p_sp_tail,
+               int max_elements, int compare_funct(struct process *, struct process *))
+{
+
+       struct sorted_process *sp_readthru = NULL, *sp_destroy = NULL;
        int did_insert = 0, x = 0;
 
        if (*p_sp_head == NULL) {
                *p_sp_head = sp_cur;
                *p_sp_tail = sp_cur;
-               return(1);
+               return 1;
        }
-       for(sp_readthru=*p_sp_head, x=0; sp_readthru != NULL && x < max_elements; sp_readthru=sp_readthru->less, x++) {
-               if (compare_funct(sp_readthru->proc, sp_cur->proc) && !did_insert) {
-                       /* sp_cur is bigger than sp_readthru so insert it before sp_readthru */
-                       sp_cur->less=sp_readthru;
-                       if (sp_readthru == *p_sp_head) { 
-                               *p_sp_head = sp_cur;  /* insert as the new head of the list */
+       for (sp_readthru = *p_sp_head, x = 0;
+                       sp_readthru != NULL && x < max_elements;
+                       sp_readthru = sp_readthru->less, x++) {
+               if (compare_funct(sp_readthru->proc, sp_cur->proc) > 0 && !did_insert) {
+                       /* sp_cur is bigger than sp_readthru
+                        * so insert it before sp_readthru */
+                       sp_cur->less = sp_readthru;
+                       if (sp_readthru == *p_sp_head) {
+                               /* insert as the new head of the list */
+                               *p_sp_head = sp_cur;
                        } else {
-                               sp_readthru->greater->less = sp_cur;  /* insert inside  the list */
-                               sp_cur->greater = sp_readthru->greater; 
+                               /* insert inside the list */
+                               sp_readthru->greater->less = sp_cur;
+                               sp_cur->greater = sp_readthru->greater;
                        }
-                       sp_readthru->greater=sp_cur;
-                       did_insert = ++x;  /* element was inserted, so increase the counter */
+                       sp_readthru->greater = sp_cur;
+                       /* element was inserted, so increase the counter */
+                       did_insert = ++x;
                }
        }
        if (x < max_elements && sp_readthru == NULL && !did_insert) {
-               /* sp_cur is the smallest element and list isn't full, so insert at the end */  
-               (*p_sp_tail)->less=sp_cur;
-               sp_cur->greater=*p_sp_tail;
+               /* sp_cur is the smallest element and list isn't full,
+                * so insert at the end */
+               (*p_sp_tail)->less = sp_cur;
+               sp_cur->greater = *p_sp_tail;
                *p_sp_tail = sp_cur;
-               did_insert=x;
+               did_insert = x;
        } else if (x >= max_elements) {
-               /* we inserted an element and now the list is too big by one. Destroy the smallest element */
+               /* We inserted an element and now the list is too big by one.
+                * Destroy the smallest element */
                sp_destroy = *p_sp_tail;
                *p_sp_tail = sp_destroy->greater;
                (*p_sp_tail)->less = NULL;
@@ -511,27 +498,26 @@ int insert_sp_element(
        }
        return did_insert;
 }
-  
-/*
- * copy the procs in the sorted list to the array, and destroy the list 
- */
-void sp_acopy(struct sorted_process *sp_head, struct process ** ar, int max_size)
+
+/* copy the procs in the sorted list to the array, and destroy the list */
+void sp_acopy(struct sorted_process *sp_head, struct process **ar, int max_size)
 {
-       struct sorted_process * sp_cur, * sp_tmp;
+       struct sorted_process *sp_cur, *sp_tmp;
        int x;
+
        sp_cur = sp_head;
-       for (x=0; x < max_size && sp_cur != NULL; x++) {
-               ar[x] = sp_cur->proc;   
+       for (x = 0; x < max_size && sp_cur != NULL; x++) {
+               ar[x] = sp_cur->proc;
                sp_tmp = sp_cur;
-               sp_cur= sp_cur->less;
-               free_sp(sp_tmp);        
+               sp_cur = sp_cur->less;
+               free_sp(sp_tmp);
        }
 }
 
-/* ****************************************************************** */
-/* Get a sorted list of the top cpu hogs and top mem hogs.            */
-/* Results are stored in the cpu,mem arrays in decreasing order[0-9]. */
-/* ****************************************************************** */
+/* ****************************************************************** *
+ * Get a sorted list of the top cpu hogs and top mem hogs.                       *
+ * Results are stored in the cpu,mem arrays in decreasing order[0-9]. *
+ * ****************************************************************** */
 
 inline void process_find_top(struct process **cpu, struct process **mem)
 {
@@ -540,27 +526,30 @@ inline void process_find_top(struct process **cpu, struct process **mem)
        struct process *cur_proc = NULL;
        unsigned long long total = 0;
 
-       if (!top_cpu && !top_mem) return;
+       if (!top_cpu && !top_mem) {
+               return;
+       }
 
        total = calc_cpu_total();       /* calculate the total of the processor */
-       update_process_table();         /* update the table with process list */
-       calc_cpu_each(total);           /* and then the percentage for each task */
-       process_cleanup();              /* cleanup list from exited processes */
-       
+       update_process_table();         /* update the table with process list */
+       calc_cpu_each(total);           /* and then the percentage for each task */
+       process_cleanup();                      /* cleanup list from exited processes */
+
        cur_proc = first_process;
 
-       while (cur_proc !=NULL) {
+       while (cur_proc != NULL) {
                if (top_cpu) {
                        spc_cur = malloc_sp(cur_proc);
-                       insert_sp_element(spc_cur, &spc_head, &spc_tail, MAX_SP, &compare_cpu);
+                       insert_sp_element(spc_cur, &spc_head, &spc_tail, MAX_SP,
+                               &compare_cpu);
                }
                if (top_mem) {
                        spm_cur = malloc_sp(cur_proc);
-                       insert_sp_element(spm_cur, &spm_head, &spm_tail, MAX_SP, &compare_mem);
+                       insert_sp_element(spm_cur, &spm_head, &spm_tail, MAX_SP,
+                               &compare_mem);
                }
                cur_proc = cur_proc->next;
        }
        sp_acopy(spc_head, cpu, MAX_SP);
        sp_acopy(spm_head, mem, MAX_SP);
 }
-
index ba132fb..ebad73a 100644 (file)
--- a/src/top.h
+++ b/src/top.h
@@ -1,5 +1,4 @@
-/*
- * Conky, a system monitor, based on torsmo
+/* Conky, a system monitor, based on torsmo
  *
  * Any original torsmo code is licensed under the BSD license
  *
@@ -8,8 +7,9 @@
  * Please see COPYING for details
  *
  * Copyright (c) 2005 Adi Zaimi, Dan Piponi <dan@tanelorn.demon.co.uk>,
- *                    Dave Clark <clarkd@skynet.ca>
- * Copyright (c) 2005-2007 Brenden Matthews, Philip Kovacs, et. al. (see AUTHORS)
+ *                                       Dave Clark <clarkd@skynet.ca>
+ * Copyright (c) 2005-2007 Brenden Matthews, Philip Kovacs, et. al.
+ *     (see AUTHORS)
  * All rights reserved.
  *
  * This program is free software: you can redistribute it and/or modify
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  * GNU General Public License for more details.
  * You should have received a copy of the GNU General Public License
- * along with this program.  If not, see <http://www.gnu.org/licenses/>. 
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
  *
- *  $Id$
- */
+ * $Id$ */
 
-/*
- * Ensure there's an operating system defined. There is *no* default
- * because every OS has it's own way of revealing CPU/memory usage.
+/* Ensure there's an operating system defined.
  * compile with gcc -DOS ...
- */
+ * There is *no* default because every OS has it's own way of revealing
+ * CPU/memory usage. */
 
-/******************************************/
-/* Includes                               */
-/******************************************/
+/******************************************
+ * Includes                                                              *
+ ******************************************/
 
 #include "conky.h"
-#define CPU_THRESHHOLD   0     /* threshhold for the cpu diff to appear */
+#define CPU_THRESHHOLD 0       /* threshhold for the cpu diff to appear */
 #include <stdlib.h>
 #include <stdio.h>
 #include <time.h>
 
 #include <regex.h>
 
-/******************************************/
-/* Defines                                */
-/******************************************/
+/******************************************
+ * Defines                                                               *
+ ******************************************/
 
-
-/*
- * XXX: I shouldn't really use this BUFFER_LEN variable but scanf is so
- * lame and it'll take me a while to write a replacement.
- */
+/* XXX: I shouldn't really use this BUFFER_LEN variable but scanf is so lame
+ * and it'll take me a while to write a replacement. */
 #define BUFFER_LEN 1024
 
 #define PROCFS_TEMPLATE "/proc/%d/stat"
 #define PROCFS_TEMPLATE_MEM "/proc/%d/statm"
 #define PROCFS_CMDLINE_TEMPLATE "/proc/%d/cmdline"
-#define MAX_SP 10  //number of elements to sort
+#define MAX_SP 10      // number of elements to sort
 
+/******************************************
+ * Globals                                                               *
+ ******************************************/
 
 extern int cpu_separate;
 
-/******************************************/
-/* Process class                          */
-/******************************************/
+/******************************************
+ * Process class                                                 *
+ ******************************************/
 
 struct sorted_process {
        struct sorted_process *greater;
-       struct sorted_process *less;    
+       struct sorted_process *less;
        struct process *proc;
-}; 
+};
 
-/*
- * Pointer to head of process list
- */
+/* Pointer to head of process list */
 void process_find_top(struct process **, struct process **);
index 380d221..64bf6a8 100644 (file)
--- a/src/x11.c
+++ b/src/x11.c
@@ -1,5 +1,4 @@
-/*
- * Conky, a system monitor, based on torsmo
+/* Conky, a system monitor, based on torsmo
  *
  * Any original torsmo code is licensed under the BSD license
  *
@@ -8,7 +7,8 @@
  * Please see COPYING for details
  *
  * Copyright (c) 2004, Hannu Saransaari and Lauri Hakkarainen
- * Copyright (c) 2005-2007 Brenden Matthews, Philip Kovacs, et. al. (see AUTHORS)
+ * Copyright (c) 2005-2007 Brenden Matthews, Philip Kovacs, et. al.
+ *     (see AUTHORS)
  * All rights reserved.
  *
  * This program is free software: you can redistribute it and/or modify
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  * GNU General Public License for more details.
  * You should have received a copy of the GNU General Public License
- * along with this program.  If not, see <http://www.gnu.org/licenses/>. 
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
  *
- *  $Id$
- */
+ * $Id$ */
 
 #include "conky.h"
 
@@ -67,8 +66,9 @@ static Window find_subwindow(Window win, int w, int h);
 /* X11 initializer */
 void init_X11()
 {
-       if ((display = XOpenDisplay(0)) == NULL)
+       if ((display = XOpenDisplay(0)) == NULL) {
                CRIT_ERR("can't open display: %s", XDisplayName(0));
+       }
 
        screen = DefaultScreen(display);
        display_width = DisplayWidth(display, screen);
@@ -92,17 +92,15 @@ static void update_workarea()
        workarea[3] = display_height;
 
        /* get current desktop */
-       if (XGetWindowProperty(display, root, ATOM(_NET_CURRENT_DESKTOP),
-                              0, 1, False, XA_CARDINAL, &type, &format,
-                              &nitems, &bytes, &buf) == Success
-           && type == XA_CARDINAL && nitems > 0) {
+       if (XGetWindowProperty(display, root, ATOM(_NET_CURRENT_DESKTOP), 0, 1,
+                       False, XA_CARDINAL, &type, &format, &nitems, &bytes, &buf)
+                       == Success && type == XA_CARDINAL && nitems > 0) {
 
-               //Currently unused 
-               /*  long desktop = * (long *) buf; */
+               // Currently unused
+               /* long desktop = *(long *) buf; */
 
                XFree(buf);
                buf = 0;
-
        }
 
        if (buf) {
@@ -111,8 +109,10 @@ static void update_workarea()
        }
 }
 
-/* Find root window and desktop window.  Return desktop window on success, 
- * and set root and desktop byref return values.  Return 0 on failure. */  
+/* Find root window and desktop window.
+ * Return desktop window on success,
+ * and set root and desktop byref return values.
+ * Return 0 on failure. */
 static Window find_desktop_window(Window *p_root, Window *p_desktop)
 {
        Atom type;
@@ -124,25 +124,26 @@ static Window find_desktop_window(Window *p_root, Window *p_desktop)
        Window troot, parent, *children;
        unsigned char *buf = NULL;
 
-       if (!p_root || !p_desktop)
-           return(0);
+       if (!p_root || !p_desktop) {
+               return 0;
+       }
 
        /* some window managers set __SWM_VROOT to some child of root window */
 
        XQueryTree(display, root, &troot, &parent, &children, &n);
        for (i = 0; i < (int) n; i++) {
-               if (XGetWindowProperty
-                   (display, children[i], ATOM(__SWM_VROOT), 0, 1, False,
-                    XA_WINDOW, &type, &format, &nitems, &bytes,
-                    &buf) == Success && type == XA_WINDOW) {
+               if (XGetWindowProperty(display, children[i], ATOM(__SWM_VROOT), 0, 1,
+                               False, XA_WINDOW, &type, &format, &nitems, &bytes, &buf)
+                               == Success && type == XA_WINDOW) {
                        win = *(Window *) buf;
                        XFree(buf);
                        XFree(children);
                        fprintf(stderr,
-                               "Conky: desktop window (%lx) found from __SWM_VROOT property\n", win);
+                               "Conky: desktop window (%lx) found from __SWM_VROOT property\n",
+                               win);
                        fflush(stderr);
-                       *p_root=win;
-                       *p_desktop=win;
+                       *p_root = win;
+                       *p_desktop = win;
                        return win;
                }
 
@@ -165,16 +166,18 @@ static Window find_desktop_window(Window *p_root, Window *p_desktop)
                buf = 0;
        }
 
-       if (win != root)
+       if (win != root) {
                fprintf(stderr,
-                       "Conky: desktop window (%lx) is subwindow of root window (%lx)\n",win,root);
-       else
-               fprintf(stderr, "Conky: desktop window (%lx) is root window\n",win);
+                       "Conky: desktop window (%lx) is subwindow of root window (%lx)\n",
+                       win, root);
+       } else {
+               fprintf(stderr, "Conky: desktop window (%lx) is root window\n", win);
+       }
 
        fflush(stderr);
 
-       *p_root=root;
-       *p_desktop=win;
+       *p_root = root;
+       *p_desktop = win;
 
        return win;
 }
@@ -183,268 +186,237 @@ static Window find_desktop_window(Window *p_root, Window *p_desktop)
 inline void set_transparent_background(Window win)
 {
        static int colour_set = -1;
+
        if (set_transparent) {
                Window parent = win;
                unsigned int i;
+
                for (i = 0; i < 50 && parent != RootWindow(display, screen); i++) {
                        Window r, *children;
                        unsigned int n;
-                       
+
                        XSetWindowBackgroundPixmap(display, parent, ParentRelative);
-       
+
                        XQueryTree(display, parent, &r, &parent, &children, &n);
                        XFree(children);
-                       }
+               }
        } else if (colour_set != background_colour) {
                XSetWindowBackground(display, win, background_colour);
                colour_set = background_colour;
-}
-       //XClearWindow(display, win); not sure why this was here
+       }
+       // XClearWindow(display, win); not sure why this was here
 }
 
-void init_window(int own_window, int w, int h, int set_trans, int back_colour, 
-                            char **argv, int argc)
+void init_window(int own_window, int w, int h, int set_trans, int back_colour,
+               char **argv, int argc)
 {
-       /* There seems to be some problems with setting transparent background (on
-        * fluxbox this time). It doesn't happen always and I don't know why it
+       /* There seems to be some problems with setting transparent background
+        * (on fluxbox this time). It doesn't happen always and I don't know why it
         * happens but I bet the bug is somewhere here. */
        set_transparent = set_trans;
        background_colour = back_colour;
 
 #ifdef OWN_WINDOW
        if (own_window) {
-               
-               if ( !find_desktop_window( &window.root, &window.desktop ) )
-                       return;
 
-               if (window.type == TYPE_OVERRIDE) {
-       
-                       /* 
-                          An override_redirect True window.  No WM hints or button processing needed. 
-                       */
-                       XSetWindowAttributes attrs = {
-                               ParentRelative,0L,0,0L,0,0,Always,0L,0L,False,
-                               StructureNotifyMask|ExposureMask,
-                               0L,
-                               True,
-                               0,0 };
+               if (!find_desktop_window(&window.root, &window.desktop)) {
+                       return;
+               }
 
-                       /* Parent is desktop window (which might be a child of root) */
-                       window.window = XCreateWindow(display, 
-                                                  window.desktop, 
-                                                  window.x, window.y, w, h, 0, 
-                                                  CopyFromParent,
-                                                  InputOutput,
-                                                  CopyFromParent,
-                                                  CWBackPixel|CWOverrideRedirect,
-                                                  &attrs);
+               if (window.type == TYPE_OVERRIDE) {
 
-                       XLowerWindow(display, window.window);   
+                       /* An override_redirect True window.
+                        * No WM hints or button processing needed. */
+                       XSetWindowAttributes attrs = { ParentRelative, 0L, 0, 0L, 0, 0,
+                               Always, 0L, 0L, False, StructureNotifyMask | ExposureMask, 0L,
+                               True, 0, 0 };
 
-                       fprintf(stderr, "Conky: window type - override\n"); fflush(stderr);
+                       /* Parent is desktop window (which might be a child of root) */
+                       window.window = XCreateWindow(display, window.desktop, window.x,
+                               window.y, w, h, 0, CopyFromParent, InputOutput, CopyFromParent,
+                               CWBackPixel | CWOverrideRedirect, &attrs);
 
-               }
+                       XLowerWindow(display, window.window);
 
-               else { /* window.type != TYPE_OVERRIDE */
+                       fprintf(stderr, "Conky: window type - override\n");
+                       fflush(stderr);
+               } else { /* window.type != TYPE_OVERRIDE */
 
-                       /* 
-                          A window managed by the window manager.  Process hints and buttons. 
-                       */
-                       XSetWindowAttributes attrs = {
-                               ParentRelative,0L,0,0L,0,0,Always,0L,0L,False,
-                               StructureNotifyMask|ExposureMask|ButtonPressMask|ButtonReleaseMask,
-                               0L,
-                               False,
-                               0,0 };
+                       /* A window managed by the window manager.
+                        * Process hints and buttons. */
+                       XSetWindowAttributes attrs = { ParentRelative, 0L, 0, 0L, 0, 0,
+                               Always, 0L, 0L, False, StructureNotifyMask | ExposureMask |
+                               ButtonPressMask | ButtonReleaseMask, 0L, False, 0, 0 };
 
                        XClassHint classHint;
                        XWMHints wmHint;
                        Atom xa;
 
                        /* Parent is root window so WM can take control */
-                       window.window = XCreateWindow(display, 
-                                                  window.root, 
-                                            window.x, window.y, w, h, 0, 
-                                                  CopyFromParent,
-                                                  InputOutput,
-                                                  CopyFromParent,
-                                                  CWBackPixel|CWOverrideRedirect,
-                                                  &attrs);
+                       window.window = XCreateWindow(display, window.root, window.x,
+                               window.y, w, h, 0, CopyFromParent, InputOutput, CopyFromParent,
+                               CWBackPixel | CWOverrideRedirect, &attrs);
 
                        classHint.res_name = window.class_name;
                        classHint.res_class = classHint.res_name;
 
                        wmHint.flags = InputHint | StateHint;
-      /* allow decorated windows to be given input focus by WM */
-                       wmHint.input = TEST_HINT(window.hints,HINT_UNDECORATED) ? False : True;
+                       /* allow decorated windows to be given input focus by WM */
+                       wmHint.input =
+                               TEST_HINT(window.hints, HINT_UNDECORATED) ? False : True;
                        wmHint.initial_state = NormalState;
 
-                       XmbSetWMProperties (display, window.window, window.title, NULL, 
-                                           argv, argc,
-                                           NULL, &wmHint, &classHint);
+                       XmbSetWMProperties(display, window.window, window.title, NULL, argv,
+                               argc, NULL, &wmHint, &classHint);
 
                        /* Sets an empty WM_PROTOCOLS property */
-                       XSetWMProtocols(display,window.window,NULL,0);
-
+                       XSetWMProtocols(display, window.window, NULL, 0);
 
                        /* Set window type */
-                       if ( (xa = ATOM(_NET_WM_WINDOW_TYPE)) != None ) 
-                       {
+                       if ((xa = ATOM(_NET_WM_WINDOW_TYPE)) != None) {
                                Atom prop;
-                               switch(window.type) {
-                               case TYPE_DESKTOP:
-                                       {
-                                       prop = ATOM(_NET_WM_WINDOW_TYPE_DESKTOP);
-                                       fprintf(stderr, "Conky: window type - desktop\n"); fflush(stderr);
-                                       }
-                                       break;                          
-                               case TYPE_NORMAL:
-                               default:
-                                       {
-                                       prop = ATOM(_NET_WM_WINDOW_TYPE_NORMAL);
-                                       fprintf(stderr, "Conky: window type - normal\n"); fflush(stderr);
-                                       }
-                                       break;
+
+                               switch (window.type) {
+                                       case TYPE_DESKTOP:
+                                               prop = ATOM(_NET_WM_WINDOW_TYPE_DESKTOP);
+                                               fprintf(stderr, "Conky: window type - desktop\n");
+                                               fflush(stderr);
+                                               break;
+                                       case TYPE_NORMAL:
+                                       default:
+                                               prop = ATOM(_NET_WM_WINDOW_TYPE_NORMAL);
+                                               fprintf(stderr, "Conky: window type - normal\n");
+                                               fflush(stderr);
+                                               break;
                                }
-                               XChangeProperty(display, window.window, xa,
-                                               XA_ATOM, 32,
-                                               PropModeReplace,
-                                               (unsigned char *) &prop, 1);
+                               XChangeProperty(display, window.window, xa, XA_ATOM, 32,
+                                       PropModeReplace, (unsigned char *) &prop, 1);
                        }
 
                        /* Set desired hints */
-                       
+
                        /* Window decorations */
-                       if (TEST_HINT(window.hints,HINT_UNDECORATED)) {
-                           /*fprintf(stderr, "Conky: hint - undecorated\n"); fflush(stderr);*/
-
-                           xa = ATOM(_MOTIF_WM_HINTS);
-                           if (xa != None) {
-                               long prop[5] = { 2, 0, 0, 0, 0 };
-                               XChangeProperty(display, window.window, xa,
-                                               xa, 32, PropModeReplace,
-                                               (unsigned char *) prop, 5);
-                           }
+                       if (TEST_HINT(window.hints, HINT_UNDECORATED)) {
+                               /* fprintf(stderr, "Conky: hint - undecorated\n");
+                               fflush(stderr); */
+
+                               xa = ATOM(_MOTIF_WM_HINTS);
+                               if (xa != None) {
+                                       long prop[5] = { 2, 0, 0, 0, 0 };
+                                       XChangeProperty(display, window.window, xa, xa, 32,
+                                               PropModeReplace, (unsigned char *) prop, 5);
+                               }
                        }
 
                        /* Below other windows */
-                       if (TEST_HINT(window.hints,HINT_BELOW)) {
-                           /*fprintf(stderr, "Conky: hint - below\n"); fflush(stderr); */
-
-                           xa = ATOM(_WIN_LAYER);
-                           if (xa != None) {
-                               long prop = 0;
-                               XChangeProperty(display, window.window, xa,
-                                               XA_CARDINAL, 32,
-                                               PropModeAppend,
-                                               (unsigned char *) &prop, 1);
-                           }
-                       
-                           xa = ATOM(_NET_WM_STATE);
-                           if (xa != None) {
-                               Atom xa_prop = ATOM(_NET_WM_STATE_BELOW);
-                               XChangeProperty(display, window.window, xa,
-                                       XA_ATOM, 32,
-                                       PropModeAppend,
-                                       (unsigned char *) &xa_prop,
-                                       1);
-                           }
+                       if (TEST_HINT(window.hints, HINT_BELOW)) {
+                               /* fprintf(stderr, "Conky: hint - below\n");
+                               fflush(stderr); */
+
+                               xa = ATOM(_WIN_LAYER);
+                               if (xa != None) {
+                                       long prop = 0;
+
+                                       XChangeProperty(display, window.window, xa, XA_CARDINAL, 32,
+                                               PropModeAppend, (unsigned char *) &prop, 1);
+                               }
+
+                               xa = ATOM(_NET_WM_STATE);
+                               if (xa != None) {
+                                       Atom xa_prop = ATOM(_NET_WM_STATE_BELOW);
+
+                                       XChangeProperty(display, window.window, xa, XA_ATOM, 32,
+                                               PropModeAppend, (unsigned char *) &xa_prop, 1);
+                               }
                        }
 
                        /* Above other windows */
-                       if (TEST_HINT(window.hints,HINT_ABOVE)) {
-                            /*fprintf(stderr, "Conky: hint - above\n"); fflush(stderr);*/
-
-                            xa = ATOM(_WIN_LAYER);
-                            if (xa != None) {
-                                long prop = 6;
-                                XChangeProperty(display, window.window, xa,
-                                                XA_CARDINAL, 32,
-                                                PropModeAppend,
-                                                (unsigned char *) &prop, 1);
-                            }
-
-                            xa = ATOM(_NET_WM_STATE);
-                            if (xa != None) {
-                                Atom xa_prop = ATOM(_NET_WM_STATE_ABOVE);
-                                XChangeProperty(display, window.window, xa,
-                                        XA_ATOM, 32,
-                                        PropModeAppend,
-                                        (unsigned char *) &xa_prop,
-                                        1);
-                            }
-                        }
+                       if (TEST_HINT(window.hints, HINT_ABOVE)) {
+                               /* fprintf(stderr, "Conky: hint - above\n");
+                               fflush(stderr); */
+
+                               xa = ATOM(_WIN_LAYER);
+                               if (xa != None) {
+                                       long prop = 6;
+
+                                       XChangeProperty(display, window.window, xa, XA_CARDINAL, 32,
+                                               PropModeAppend, (unsigned char *) &prop, 1);
+                               }
+
+                               xa = ATOM(_NET_WM_STATE);
+                               if (xa != None) {
+                                       Atom xa_prop = ATOM(_NET_WM_STATE_ABOVE);
+
+                                       XChangeProperty(display, window.window, xa, XA_ATOM, 32,
+                                               PropModeAppend, (unsigned char *) &xa_prop, 1);
+                               }
+                       }
 
                        /* Sticky */
-                       if (TEST_HINT(window.hints,HINT_STICKY)) {
-                            /*fprintf(stderr, "Conky: hint - sticky\n"); fflush(stderr); */
-
-                            xa = ATOM(_NET_WM_DESKTOP);
-                            if (xa != None) {
-                                CARD32 xa_prop = 0xFFFFFFFF;
-                                XChangeProperty(display, window.window, xa,
-                                        XA_CARDINAL, 32,
-                                        PropModeAppend,
-                                        (unsigned char *) &xa_prop,
-                                        1);
-                            }
-
-                           xa = ATOM(_NET_WM_STATE);
-                            if (xa != None) {
-                                Atom xa_prop = ATOM(_NET_WM_STATE_STICKY);
-                                XChangeProperty(display, window.window, xa,
-                                        XA_ATOM, 32,
-                                        PropModeAppend,
-                                        (unsigned char *) &xa_prop,
-                                        1);
-                            }
-                        }
+                       if (TEST_HINT(window.hints, HINT_STICKY)) {
+                               /* fprintf(stderr, "Conky: hint - sticky\n");
+                               fflush(stderr); */
+
+                               xa = ATOM(_NET_WM_DESKTOP);
+                               if (xa != None) {
+                                       CARD32 xa_prop = 0xFFFFFFFF;
+
+                                       XChangeProperty(display, window.window, xa, XA_CARDINAL, 32,
+                                               PropModeAppend, (unsigned char *) &xa_prop, 1);
+                               }
+
+                               xa = ATOM(_NET_WM_STATE);
+                               if (xa != None) {
+                                       Atom xa_prop = ATOM(_NET_WM_STATE_STICKY);
+
+                                       XChangeProperty(display, window.window, xa, XA_ATOM, 32,
+                                               PropModeAppend, (unsigned char *) &xa_prop, 1);
+                               }
+                       }
 
                        /* Skip taskbar */
-                        if (TEST_HINT(window.hints,HINT_SKIP_TASKBAR)) {
-                            /*fprintf(stderr, "Conky: hint - skip_taskbar\n"); fflush(stderr);*/
-
-                            xa = ATOM(_NET_WM_STATE);
-                            if (xa != None) {
-                                Atom xa_prop = ATOM(_NET_WM_STATE_SKIP_TASKBAR);
-                                XChangeProperty(display, window.window, xa,
-                                        XA_ATOM, 32,
-                                        PropModeAppend,
-                                        (unsigned char *) &xa_prop,
-                                        1);
-                            }
-                        }
+                       if (TEST_HINT(window.hints, HINT_SKIP_TASKBAR)) {
+                               /* fprintf(stderr, "Conky: hint - skip_taskbar\n");
+                               fflush(stderr); */
+
+                               xa = ATOM(_NET_WM_STATE);
+                               if (xa != None) {
+                                       Atom xa_prop = ATOM(_NET_WM_STATE_SKIP_TASKBAR);
+
+                                       XChangeProperty(display, window.window, xa, XA_ATOM, 32,
+                                               PropModeAppend, (unsigned char *) &xa_prop, 1);
+                               }
+                       }
 
                        /* Skip pager */
-                        if (TEST_HINT(window.hints,HINT_SKIP_PAGER)) {
-                            /*fprintf(stderr, "Conky: hint - skip_pager\n"); fflush(stderr);*/
-
-                            xa = ATOM(_NET_WM_STATE);
-                            if (xa != None) {
-                                Atom xa_prop = ATOM(_NET_WM_STATE_SKIP_PAGER);
-                                XChangeProperty(display, window.window, xa,
-                                        XA_ATOM, 32,
-                                        PropModeAppend,
-                                        (unsigned char *) &xa_prop,
-                                        1);
-                            }
-                        }
+                       if (TEST_HINT(window.hints, HINT_SKIP_PAGER)) {
+                               /* fprintf(stderr, "Conky: hint - skip_pager\n");
+                               fflush(stderr); */
 
+                               xa = ATOM(_NET_WM_STATE);
+                               if (xa != None) {
+                                       Atom xa_prop = ATOM(_NET_WM_STATE_SKIP_PAGER);
+
+                                       XChangeProperty(display, window.window, xa, XA_ATOM, 32,
+                                               PropModeAppend, (unsigned char *) &xa_prop, 1);
+                               }
+                       }
                } /* else { window.type != TYPE_OVERRIDE */
-                       
-               fprintf(stderr, "Conky: drawing to created window (%lx)\n", window.window);
+
+               fprintf(stderr, "Conky: drawing to created window (%lx)\n",
+                       window.window);
                fflush(stderr);
 
                XMapWindow(display, window.window);
-
        } else /* if (own_window) { */
 #endif
-               /* root / desktop window */
+       /* root / desktop window */
        {
                XWindowAttributes attrs;
 
-               if (!window.window)
-                       window.window = find_desktop_window( &window.root, &window.desktop );
+               if (!window.window) {
+                       window.window = find_desktop_window(&window.root, &window.desktop);
+               }
 
                if (XGetWindowAttributes(display, window.window, &attrs)) {
                        window.width = attrs.width;
@@ -460,44 +432,46 @@ void init_window(int own_window, int w, int h, int set_trans, int back_colour,
 #ifdef HAVE_XDBE
        if (use_xdbe) {
                int major, minor;
+
                if (!XdbeQueryExtension(display, &major, &minor)) {
                        use_xdbe = 0;
                } else {
-                       window.back_buffer =
-                           XdbeAllocateBackBufferName(display,
-                                                      window.window,
-                                                      XdbeBackground);
+                       window.back_buffer = XdbeAllocateBackBufferName(display,
+                               window.window, XdbeBackground);
                        if (window.back_buffer != None) {
                                window.drawable = window.back_buffer;
-                               fprintf(stderr,
-                                       "Conky: drawing to double buffer\n");
-                       } else
+                               fprintf(stderr, "Conky: drawing to double buffer\n");
+                       } else {
                                use_xdbe = 0;
+                       }
                }
-               if (!use_xdbe)
+               if (!use_xdbe) {
                        ERR("failed to set up double buffer");
+               }
        }
-       if (!use_xdbe)
+       if (!use_xdbe) {
                fprintf(stderr, "Conky: drawing to single buffer\n");
+       }
 #endif
 
        XFlush(display);
 
-       /*set_transparent_background(window.window); must be done after double buffer stuff? */
+       /* set_transparent_background(window.window);
+        * must be done after double buffer stuff? */
 #ifdef OWN_WINDOW
-       /*if (own_window) {
-       set_transparent_background(window.window);
+       /* if (own_window) {
+               set_transparent_background(window.window);
                XClearWindow(display, window.window);
-}*/
+       } */
 #endif
 
-       XSelectInput(display, window.window, ExposureMask
 #ifdef OWN_WINDOW
-                    | (own_window
-                       ? (StructureNotifyMask | PropertyChangeMask | 
-                          ButtonPressMask | ButtonReleaseMask) : 0)
+       XSelectInput(display, window.window, ExposureMask |
+               (own_window ? (StructureNotifyMask | PropertyChangeMask |
+               ButtonPressMask | ButtonReleaseMask) : 0));
+#else
+       XSelectInput(display, window.window, ExposureMask);
 #endif
-           );
 }
 
 static Window find_subwindow(Window win, int w, int h)
@@ -514,14 +488,12 @@ static Window find_subwindow(Window win, int w, int h)
                for (j = 0; j < n; j++) {
                        XWindowAttributes attrs;
 
-                       if (XGetWindowAttributes
-                           (display, children[j], &attrs)) {
-                               /* Window must be mapped and same size as display or work space */
-                               if (attrs.map_state != 0 &&
-                                   ((attrs.width == display_width
-                                     && attrs.height == display_height)
-                                    || (attrs.width == w
-                                        && attrs.height == h))) {
+                       if (XGetWindowAttributes(display, children[j], &attrs)) {
+                               /* Window must be mapped and same size as display or
+                                * work space */
+                               if (attrs.map_state != 0 && ((attrs.width == display_width
+                                               && attrs.height == display_height)
+                                               || (attrs.width == w && attrs.height == h))) {
                                        win = children[j];
                                        break;
                                }
@@ -529,8 +501,9 @@ static Window find_subwindow(Window win, int w, int h)
                }
 
                XFree(children);
-               if (j == n)
+               if (j == n) {
                        break;
+               }
        }
 
        return win;
@@ -539,24 +512,25 @@ static Window find_subwindow(Window win, int w, int h)
 long get_x11_color(const char *name)
 {
        XColor color;
+
        color.pixel = 0;
-       if (!XParseColor
-           (display, DefaultColormap(display, screen), name, &color)) {
+       if (!XParseColor(display, DefaultColormap(display, screen), name, &color)) {
                /* lets check if it's a hex colour with the # missing in front
-                * if yes, then do something about it
-                */
+                * if yes, then do something about it */
                char newname[64];
+
                newname[0] = '#';
                strncpy(&newname[1], name, 62);
                /* now lets try again */
-               if (!XParseColor(display, DefaultColormap(display, screen), &newname[0], &color)) {
+               if (!XParseColor(display, DefaultColormap(display, screen), &newname[0],
+                               &color)) {
                        ERR("can't parse X color '%s'", name);
                        return 0xFF00FF;
                }
        }
-       if (!XAllocColor
-           (display, DefaultColormap(display, screen), &color))
+       if (!XAllocColor(display, DefaultColormap(display, screen), &color)) {
                ERR("can't allocate X color '%s'", name);
+       }
 
        return (long) color.pixel;
 }
@@ -564,10 +538,11 @@ long get_x11_color(const char *name)
 void create_gc()
 {
        XGCValues values;
+
        values.graphics_exposures = 0;
        values.function = GXcopy;
        window.gc = XCreateGC(display, window.drawable,
-                             GCFunction | GCGraphicsExposures, &values);
+               GCFunction | GCGraphicsExposures, &values);
 }
 
 #endif /* X11 */
index 1c0d0ff..dbf977f 100644 (file)
@@ -1,5 +1,4 @@
-/*
- * Conky, a system monitor, based on torsmo
+/* Conky, a system monitor, based on torsmo
  *
  * Any original torsmo code is licensed under the BSD license
  *
@@ -7,7 +6,8 @@
  *
  * Please see COPYING for details
  *
- * Copyright (c) 2005-2007 Brenden Matthews, Philip Kovacs, et. al. (see AUTHORS)
+ * Copyright (c) 2005-2007 Brenden Matthews, Philip Kovacs, et. al.
+ *     (see AUTHORS)
  * All rights reserved.
  *
  * This program is free software: you can redistribute it and/or modify
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  * GNU General Public License for more details.
  * You should have received a copy of the GNU General Public License
- * along with this program.  If not, see <http://www.gnu.org/licenses/>. 
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
  *
- *  $Id$
- */
+ * $Id$ */
 
 #include "conky.h"
 #include <stdio.h>
@@ -31,9 +30,9 @@
 #include <stdlib.h>
 #include <xmmsclient/xmmsclient.h>
 
-#define CONN_INIT    0
-#define CONN_OK      1
-#define CONN_NO      2
+#define CONN_INIT      0
+#define CONN_OK                1
+#define CONN_NO                2
 
 /* callbacks */
 
@@ -90,7 +89,8 @@ static void xmms_alloc(struct information *ptr)
        }
 }
 
-static void xmms_clear(struct information *ptr) {
+static void xmms_clear(struct information *ptr)
+{
        xmms_alloc(ptr);
        ptr->xmms2.status[0] = '\0';
        ptr->xmms2.artist[0] = '\0';
@@ -107,6 +107,7 @@ static void xmms_clear(struct information *ptr) {
 void connection_lost(void *p)
 {
        struct information *ptr = p;
+
        ptr->xmms2_conn_state = CONN_NO;
 
        xmms_clear(ptr);
@@ -121,250 +122,263 @@ void connection_lost(void *p)
 
 void handle_curent_id(xmmsc_result_t *res, void *p)
 {
-    uint current_id;
-    struct information *ptr = p;
-
-    if ( xmmsc_result_get_uint( res, &current_id ) ) {
-
-        xmmsc_result_t *res2;
-        res2 = xmmsc_medialib_get_info(ptr->xmms2_conn, current_id);
-        xmmsc_result_wait( res2 );
-               
-               xmms_clear(ptr);
-
-        ptr->xmms2.id = current_id;
-
-        char *temp;
-        xmmsc_result_get_dict_entry_string( res2, "artist", &temp );
-        if ( temp != NULL ) {
-            strncpy(ptr->xmms2.artist, temp, TEXT_BUFFER_SIZE - 1);
-        } else {
-            strncpy(ptr->xmms2.artist, "[Unknown]", TEXT_BUFFER_SIZE - 1);
-        }
-
-
-        xmmsc_result_get_dict_entry_string( res2, "title", &temp );
-        if ( temp != NULL ) {
-            strncpy(ptr->xmms2.title, temp, TEXT_BUFFER_SIZE - 1);
-        } else {
-            strncpy(ptr->xmms2.title, "[Unknown]", TEXT_BUFFER_SIZE - 1);
-        }
-
-        xmmsc_result_get_dict_entry_string( res2, "album", &temp );
-        if ( temp != NULL ) {
-            strncpy(ptr->xmms2.album, temp, TEXT_BUFFER_SIZE - 1);
-        } else {
-            strncpy(ptr->xmms2.album, "[Unknown]", TEXT_BUFFER_SIZE - 1);
-        }
-
-
-        xmmsc_result_get_dict_entry_string( res2, "genre", &temp );
-        if ( temp != NULL ) {
-
-            strncpy(ptr->xmms2.genre, temp, TEXT_BUFFER_SIZE - 1);
-        } else {
-            strncpy(ptr->xmms2.genre, "[Unknown]", TEXT_BUFFER_SIZE - 1);
-        }
-
-
-        xmmsc_result_get_dict_entry_string( res2, "comment", &temp );
-        if ( temp != NULL ) {
-            strncpy(ptr->xmms2.comment, temp, TEXT_BUFFER_SIZE - 1);
-        } else {
-            strncpy(ptr->xmms2.comment, "", TEXT_BUFFER_SIZE - 1);
-        }
-
-
-        xmmsc_result_get_dict_entry_string( res2, "decoder", &temp );
-        if ( temp != NULL ) {
-            strncpy(ptr->xmms2.decoder, temp, TEXT_BUFFER_SIZE - 1);
-        } else {
-            strncpy(ptr->xmms2.decoder, "[Unknown]", TEXT_BUFFER_SIZE - 1);
-        }
-
-
-        xmmsc_result_get_dict_entry_string( res2, "transport", &temp );
-        if ( temp != NULL ) {
-            strncpy(ptr->xmms2.transport, temp, TEXT_BUFFER_SIZE - 1);
-        } else {
-            strncpy(ptr->xmms2.transport, "[Unknown]", TEXT_BUFFER_SIZE - 1);
-        }
+       uint current_id;
+       struct information *ptr = p;
 
+       if (xmmsc_result_get_uint(res, &current_id)) {
+
+               xmmsc_result_t *res2;
+
+               res2 = xmmsc_medialib_get_info(ptr->xmms2_conn, current_id);
+               xmmsc_result_wait(res2);
+
+               xmms_clear(ptr);
+
+               ptr->xmms2.id = current_id;
+
+               char *temp;
+
+               xmmsc_result_get_dict_entry_string(res2, "artist", &temp);
+               if (temp != NULL) {
+                       strncpy(ptr->xmms2.artist, temp, TEXT_BUFFER_SIZE - 1);
+               } else {
+                       strncpy(ptr->xmms2.artist, "[Unknown]", TEXT_BUFFER_SIZE - 1);
+               }
+
+               xmmsc_result_get_dict_entry_string(res2, "title", &temp);
+               if (temp != NULL) {
+                       strncpy(ptr->xmms2.title, temp, TEXT_BUFFER_SIZE - 1);
+               } else {
+                       strncpy(ptr->xmms2.title, "[Unknown]", TEXT_BUFFER_SIZE - 1);
+               }
+
+               xmmsc_result_get_dict_entry_string(res2, "album", &temp);
+               if (temp != NULL) {
+                       strncpy(ptr->xmms2.album, temp, TEXT_BUFFER_SIZE - 1);
+               } else {
+                       strncpy(ptr->xmms2.album, "[Unknown]", TEXT_BUFFER_SIZE - 1);
+               }
+
+               xmmsc_result_get_dict_entry_string(res2, "genre", &temp);
+               if (temp != NULL) {
+
+                       strncpy(ptr->xmms2.genre, temp, TEXT_BUFFER_SIZE - 1);
+               } else {
+                       strncpy(ptr->xmms2.genre, "[Unknown]", TEXT_BUFFER_SIZE - 1);
+               }
+
+               xmmsc_result_get_dict_entry_string(res2, "comment", &temp);
+               if (temp != NULL) {
+                       strncpy(ptr->xmms2.comment, temp, TEXT_BUFFER_SIZE - 1);
+               } else {
+                       strncpy(ptr->xmms2.comment, "", TEXT_BUFFER_SIZE - 1);
+               }
+
+               xmmsc_result_get_dict_entry_string(res2, "decoder", &temp);
+               if (temp != NULL) {
+                       strncpy(ptr->xmms2.decoder, temp, TEXT_BUFFER_SIZE - 1);
+               } else {
+                       strncpy(ptr->xmms2.decoder, "[Unknown]", TEXT_BUFFER_SIZE - 1);
+               }
+
+               xmmsc_result_get_dict_entry_string(res2, "transport", &temp);
+               if (temp != NULL) {
+                       strncpy(ptr->xmms2.transport, temp, TEXT_BUFFER_SIZE - 1);
+               } else {
+                       strncpy(ptr->xmms2.transport, "[Unknown]", TEXT_BUFFER_SIZE - 1);
+               }
+
+               xmmsc_result_get_dict_entry_string(res2, "url", &temp);
+               if (temp != NULL) {
+                       strncpy(ptr->xmms2.url, temp, TEXT_BUFFER_SIZE - 1);
+               } else {
+                       strncpy(ptr->xmms2.url, "[Unknown]", TEXT_BUFFER_SIZE - 1);
+               }
+
+               xmmsc_result_get_dict_entry_string(res2, "date", &temp);
+               if (temp != NULL) {
+                       strncpy(ptr->xmms2.date, temp, TEXT_BUFFER_SIZE - 1);
+               } else {
+                       strncpy(ptr->xmms2.date, "????", TEXT_BUFFER_SIZE - 1);
+               }
+
+               int itemp;
+
+               xmmsc_result_get_dict_entry_int(res2, "tracknr", &itemp);
+               ptr->xmms2.tracknr = itemp;
+
+               xmmsc_result_get_dict_entry_int(res2, "duration", &itemp);
+               ptr->xmms2.duration = itemp;
+
+               xmmsc_result_get_dict_entry_int(res2, "bitrate", &itemp);
+               ptr->xmms2.bitrate = itemp / 1000;
+
+               xmmsc_result_get_dict_entry_int(res2, "size", &itemp);
+               ptr->xmms2.size = (float) itemp / 1048576;
+
+               xmmsc_result_unref(res2);
+       }
+}
 
-        xmmsc_result_get_dict_entry_string( res2, "url", &temp );
-        if ( temp != NULL ) {
-            strncpy(ptr->xmms2.url, temp, TEXT_BUFFER_SIZE - 1);
-        } else {
-            strncpy(ptr->xmms2.url, "[Unknown]", TEXT_BUFFER_SIZE - 1);
-        }
+void handle_playtime(xmmsc_result_t *res, void *p)
+{
+       struct information *ptr = p;
+       xmmsc_result_t *res2;
+       uint play_time;
 
+       if (xmmsc_result_iserror(res)) {
+               return;
+       }
 
-        xmmsc_result_get_dict_entry_string( res2, "date", &temp );
-        if ( temp != NULL ) {
-            strncpy(ptr->xmms2.date, temp, TEXT_BUFFER_SIZE - 1);
-        } else {
-            strncpy(ptr->xmms2.date, "????", TEXT_BUFFER_SIZE - 1);
-        }
+       if (!xmmsc_result_get_uint(res, &play_time)) {
+               return;
+       }
 
+       res2 = xmmsc_result_restart(res);
+       xmmsc_result_unref(res2);
 
-        int itemp;
-        xmmsc_result_get_dict_entry_int( res2, "tracknr", &itemp );
-        ptr->xmms2.tracknr = itemp;
+       ptr->xmms2.elapsed = play_time;
+       ptr->xmms2.progress = (float) play_time / ptr->xmms2.duration;
+}
 
-        xmmsc_result_get_dict_entry_int( res2, "duration", &itemp );
-        ptr->xmms2.duration = itemp;
+void handle_playback_state_change(xmmsc_result_t *res, void *p)
+{
+       struct information *ptr = p;
+       uint pb_state = 0;
 
-        xmmsc_result_get_dict_entry_int( res2, "bitrate", &itemp );
-        ptr->xmms2.bitrate = itemp / 1000;
+       if (xmmsc_result_iserror(res)) {
+               return;
+       }
 
-        xmmsc_result_get_dict_entry_int( res2, "size", &itemp );
-        ptr->xmms2.size = (float)itemp / 1048576;
+       if (!xmmsc_result_get_uint(res, &pb_state)) {
+               return;
+       }
 
-        xmmsc_result_unref( res2 );
-    }
+       switch (pb_state) {
+               case XMMS_PLAYBACK_STATUS_PLAY:
+                       strncpy(ptr->xmms2.status, "Playing", TEXT_BUFFER_SIZE - 1);
+                       break;
+               case XMMS_PLAYBACK_STATUS_PAUSE:
+                       strncpy(ptr->xmms2.status, "Paused", TEXT_BUFFER_SIZE - 1);
+                       break;
+               case XMMS_PLAYBACK_STATUS_STOP:
+                       strncpy(ptr->xmms2.status, "Stopped", TEXT_BUFFER_SIZE - 1);
+                       break;
+               default:
+                       strncpy(ptr->xmms2.status, "Unknown", TEXT_BUFFER_SIZE - 1);
+       }
 }
 
-void handle_playtime(xmmsc_result_t *res, void *p) {
-       struct information *ptr = p;
-    xmmsc_result_t * res2;
-    uint play_time;
-
-    if ( xmmsc_result_iserror( res ) )
-        return;
+void update_xmms2()
+{
+       struct information *current_info = &info;
 
-    if ( !xmmsc_result_get_uint( res, &play_time ) )
-        return;
+       /* initialize connection */
+       if (current_info->xmms2_conn_state == CONN_INIT) {
 
-    res2 = xmmsc_result_restart( res );
-    xmmsc_result_unref( res2 );
+               if (current_info->xmms2_conn == NULL) {
+                       current_info->xmms2_conn = xmmsc_init("conky");
+               }
 
-    ptr->xmms2.elapsed = play_time;
-    ptr->xmms2.progress = (float) play_time / ptr->xmms2.duration;
-}
+               /* did init fail? */
+               if (current_info->xmms2_conn == NULL) {
+                       fprintf(stderr, "Conky: xmms2 init failed. %s\n",
+                               xmmsc_get_last_error(current_info->xmms2_conn));
+                       fflush(stderr);
+                       return;
+               }
 
-void handle_playback_state_change(xmmsc_result_t *res, void *p) {
-       struct information *ptr = p;
-    uint pb_state = 0;
-    if ( xmmsc_result_iserror( res ) )
-        return;
-
-    if ( !xmmsc_result_get_uint( res, &pb_state ) )
-        return;
-
-    switch (pb_state) {
-    case XMMS_PLAYBACK_STATUS_PLAY:
-        strncpy(ptr->xmms2.status, "Playing", TEXT_BUFFER_SIZE - 1);
-        break;
-    case XMMS_PLAYBACK_STATUS_PAUSE:
-        strncpy(ptr->xmms2.status, "Paused", TEXT_BUFFER_SIZE - 1);
-        break;
-    case XMMS_PLAYBACK_STATUS_STOP:
-        strncpy(ptr->xmms2.status, "Stopped", TEXT_BUFFER_SIZE - 1);
-        break;
-    default:
-        strncpy(ptr->xmms2.status, "Unknown", TEXT_BUFFER_SIZE - 1);
-    }
-}
+               /* init ok but not connected yet.. */
+               current_info->xmms2_conn_state = CONN_NO;
 
+               /* clear all values */
+               xmms_clear(current_info);
 
-void update_xmms2() {
-    struct information * current_info = &info;
+               current_info->xmms2.tracknr = 0;
+               current_info->xmms2.id = 0;
+               current_info->xmms2.bitrate = 0;
+               current_info->xmms2.duration = 0;
+               current_info->xmms2.elapsed = 0;
+               current_info->xmms2.size = 0;
+               current_info->xmms2.progress = 0;
 
-    /* initialize connection */
-    if ( current_info->xmms2_conn_state == CONN_INIT ) {
+               /* fprintf(stderr, "Conky: xmms2 init ok.\n");
+               fflush(stderr); */
+       }
 
-        if ( current_info->xmms2_conn == NULL ) {
-            current_info->xmms2_conn = xmmsc_init( "conky" );
-        }
+       /* connect */
+       if (current_info->xmms2_conn_state == CONN_NO) {
+
+               char *path = getenv("XMMS_PATH");
+
+               if (!xmmsc_connect(current_info->xmms2_conn, path)) {
+                       fprintf(stderr, "Conky: xmms2 connection failed. %s\n",
+                               xmmsc_get_last_error(current_info->xmms2_conn));
+                       fflush(stderr);
+                       current_info->xmms2_conn_state = CONN_NO;
+                       return;
+               }
+
+               /* set callbacks */
+               xmmsc_disconnect_callback_set(current_info->xmms2_conn, connection_lost,
+                       current_info);
+               XMMS_CALLBACK_SET(current_info->xmms2_conn, xmmsc_playback_current_id,
+                       handle_curent_id, current_info);
+               XMMS_CALLBACK_SET(current_info->xmms2_conn,
+                       xmmsc_broadcast_playback_current_id, handle_curent_id,
+                       current_info);
+               XMMS_CALLBACK_SET(current_info->xmms2_conn,
+                       xmmsc_signal_playback_playtime, handle_playtime, current_info);
+               XMMS_CALLBACK_SET(current_info->xmms2_conn,
+                       xmmsc_broadcast_playback_status, handle_playback_state_change,
+                       current_info);
+
+               /* get playback status, it wont be broadcasted untill it chages */
+               xmmsc_result_t *res = xmmsc_playback_status(current_info->xmms2_conn);
+
+               xmmsc_result_wait(res);
+               unsigned int pb_state;
+
+               xmmsc_result_get_uint(res, &pb_state);
+               switch (pb_state) {
+                       case XMMS_PLAYBACK_STATUS_PLAY:
+                               strncpy(current_info->xmms2.status, "Playing",
+                                       TEXT_BUFFER_SIZE - 1);
+                               break;
+                       case XMMS_PLAYBACK_STATUS_PAUSE:
+                               strncpy(current_info->xmms2.status, "Paused",
+                                       TEXT_BUFFER_SIZE - 1);
+                               break;
+                       case XMMS_PLAYBACK_STATUS_STOP:
+                               strncpy(current_info->xmms2.status, "Stopped",
+                                       TEXT_BUFFER_SIZE - 1);
+                               break;
+                       default:
+                               strncpy(current_info->xmms2.status, "Unknown",
+                                       TEXT_BUFFER_SIZE - 1);
+               }
+               xmmsc_result_unref(res);
+
+               /* everything seems to be ok */
+               current_info->xmms2_conn_state = CONN_OK;
+
+               /* fprintf(stderr, "Conky: xmms2 connected.\n");
+               fflush(stderr); */
+       }
 
-        /* did init fail? */
-        if ( current_info->xmms2_conn == NULL ) {
-            fprintf(stderr,"Conky: xmms2 init failed. %s\n", xmmsc_get_last_error ( current_info->xmms2_conn ));
-            fflush(stderr);
-            return;
-        }
+       /* handle callbacks */
+       if (current_info->xmms2_conn_state == CONN_OK) {
+               struct timeval tmout;
 
-        /* init ok but not connected yet.. */
-        current_info->xmms2_conn_state = CONN_NO;
+               tmout.tv_sec = 0;
+               tmout.tv_usec = 100;
 
-        /* clear all values */
-               xmms_clear(current_info);
+               select(current_info->xmms2_fd + 1, &current_info->xmms2_fdset, NULL,
+                       NULL, &tmout);
 
-        current_info->xmms2.tracknr = 0;
-        current_info->xmms2.id = 0;
-        current_info->xmms2.bitrate = 0;
-        current_info->xmms2.duration = 0;
-        current_info->xmms2.elapsed = 0;
-        current_info->xmms2.size = 0;
-        current_info->xmms2.progress = 0;
-
-        /*    fprintf(stderr,"Conky: xmms2 init ok.\n");
-            fflush(stderr); */
-    }
-
-    /* connect */
-    if ( current_info->xmms2_conn_state == CONN_NO ) {
-
-        char *path = getenv ( "XMMS_PATH" );
-        if ( !xmmsc_connect( current_info->xmms2_conn, path ) ) {
-            fprintf(stderr,"Conky: xmms2 connection failed. %s\n",
-                    xmmsc_get_last_error ( current_info->xmms2_conn ));
-            fflush(stderr);
-            current_info->xmms2_conn_state = CONN_NO;
-            return;
-        }
-
-        /* set callbacks */
-        xmmsc_disconnect_callback_set( current_info->xmms2_conn, connection_lost, current_info );
-        XMMS_CALLBACK_SET( current_info->xmms2_conn, xmmsc_playback_current_id, handle_curent_id, current_info );
-        XMMS_CALLBACK_SET( current_info->xmms2_conn, xmmsc_broadcast_playback_current_id, handle_curent_id, current_info );
-        XMMS_CALLBACK_SET( current_info->xmms2_conn, xmmsc_signal_playback_playtime, handle_playtime, current_info );
-        XMMS_CALLBACK_SET( current_info->xmms2_conn, xmmsc_broadcast_playback_status, handle_playback_state_change, current_info );
-
-       /* get playback status, it wont be broadcasted untill it chages */
-       xmmsc_result_t * res = xmmsc_playback_status( current_info->xmms2_conn );
-        xmmsc_result_wait ( res );
-        unsigned int pb_state;
-
-        xmmsc_result_get_uint( res, &pb_state );
-        switch (pb_state) {
-        case XMMS_PLAYBACK_STATUS_PLAY:
-            strncpy(current_info->xmms2.status,
-                     "Playing", TEXT_BUFFER_SIZE - 1 );
-            break;
-        case XMMS_PLAYBACK_STATUS_PAUSE:
-            strncpy( current_info->xmms2.status,
-                     "Paused", TEXT_BUFFER_SIZE - 1 );
-            break;
-        case XMMS_PLAYBACK_STATUS_STOP:
-            strncpy( current_info->xmms2.status,
-                     "Stopped", TEXT_BUFFER_SIZE - 1 );
-            break;
-        default:
-            strncpy( current_info->xmms2.status,
-                     "Unknown", TEXT_BUFFER_SIZE - 1 );
-        }
-        xmmsc_result_unref ( res );
-       
-        /* everything seems to be ok */
-        current_info->xmms2_conn_state = CONN_OK;
-
-        /*   fprintf(stderr,"Conky: xmms2 connected.\n");
-              fflush(stderr);  */
-    }
-
-
-    /* handle callbacks */
-    if ( current_info->xmms2_conn_state == CONN_OK ) {
-        struct timeval tmout;
-        tmout.tv_sec = 0;
-        tmout.tv_usec = 100;
-
-        select( current_info->xmms2_fd + 1, &current_info->xmms2_fdset, NULL, NULL, &tmout );
-
-        xmmsc_io_in_handle(current_info->xmms2_conn);
-        if (xmmsc_io_want_out(current_info->xmms2_conn)) {
-            xmmsc_io_out_handle(current_info->xmms2_conn);
-        }
-    }
+               xmmsc_io_in_handle(current_info->xmms2_conn);
+               if (xmmsc_io_want_out(current_info->xmms2_conn)) {
+                       xmmsc_io_out_handle(current_info->xmms2_conn);
+               }
+       }
 }