From 9a85812e06f8a278d36b988765c102eaf1c60f88 Mon Sep 17 00:00:00 2001 From: Phil Sutter Date: Mon, 15 Dec 2008 22:40:24 +0100 Subject: [PATCH] here comes the big header include rewrite Some statics are now defined by configure.ac.in, conky.h got a lot smaller, which I see as a positive sign. This patch should not change any functionality, just change what's defined where. Some features I did/could not test are probably broken, also compiling for any other OS surely won't complete now. Though I think fixing these problems is as easy as including some missing headers. I've done compile checks with the following configure options: ./configure --enable-eve --enable-rss --enable-smapi --enable-wlan --enable-debug --enable-testing So what needs to be tested is: - audacious - BMPx - xmms2 - nvidia --- configure.ac.in | 7 +- src/Makefile.am | 1 + src/audacious.c | 10 +-- src/bmpx.c | 6 +- src/common.c | 18 +++- src/common.h | 53 ++++++++++- src/conky.c | 68 ++++++++++++-- src/conky.h | 253 ++++++++++------------------------------------------- src/diskio.c | 7 +- src/fs.c | 2 + src/fs.h | 18 +++- src/hddtemp.c | 1 + src/linux.c | 3 + src/linux.h | 6 +- src/logging.h | 51 +++++++++++ src/mail.c | 17 ++++ src/mail.h | 26 +++++- src/mboxscan.c | 2 + src/mixer.c | 1 + src/moc.c | 1 + src/mpd.c | 1 + src/rss.c | 1 + src/smapi.c | 9 +- src/smapi.h | 9 +- src/solaris.c | 1 + src/tcp-portmon.c | 1 + src/text_object.c | 2 +- src/text_object.h | 1 + src/x11.c | 12 +-- 29 files changed, 335 insertions(+), 253 deletions(-) create mode 100644 src/logging.h diff --git a/configure.ac.in b/configure.ac.in index c850260..d7ed523 100644 --- a/configure.ac.in +++ b/configure.ac.in @@ -249,7 +249,7 @@ dnl EVE Skill Monitor dnl AC_ARG_ENABLE([eve], - EC_HELP_STRING([--enable-eve], [Eve-Online skill monitor @<:@default=no@:>@]), + AC_HELP_STRING([--enable-eve], [Eve-Online skill monitor @<:@default=no@:>@]), [want_eve="$enableval"], [want_eve=no]) AM_CONDITIONAL(BUILD_EVE, test x$want_eve = xyes) @@ -552,6 +552,9 @@ dnl AC_DEFINE(DEFAULTNETDEV, "eth0", [Default networkdevice]) AC_DEFINE(CONFIG_FILE, "$HOME/.conkyrc", [Configfile of the user]) +AC_DEFINE(MAX_SPECIALS_DEFAULT, 512, [Default maximum number of special things, e.g. fonts, offsets, aligns, etc.]) +AC_DEFINE(MAX_USER_TEXT_DEFAULT, 16384, [Default maximum size of config TEXT buffer, i.e. below TEXT line.]) +AC_DEFINE(DEFAULT_TEXT_BUFFER_SIZE, 256, [Default size used for temporary, static text buffers]) dnl dnl Some functions @@ -656,7 +659,7 @@ AC_ARG_ENABLE([debug], if test "x$want_debug" = "xyes" -a $ac_cv_c_compiler_gnu != no; then CFLAGS="$CFLAGS -g3" - AC_DEFINE([DEBUG], [], [Define for debugging]) + AC_DEFINE([DEBUG], 1, [Define for debugging]) fi dnl diff --git a/src/Makefile.am b/src/Makefile.am index 6470c2f..0b16dcb 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -123,6 +123,7 @@ conky_SOURCES = \ fs.c \ $(hddtemp) \ $(linux) \ + logging.h \ $(nvidia) \ mail.c \ mixer.c \ diff --git a/src/audacious.c b/src/audacious.c index a9886cd..ebe6cbe 100644 --- a/src/audacious.c +++ b/src/audacious.c @@ -17,9 +17,10 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 * USA. */ -#ifdef HAVE_CONFIG_H -#include -#endif +#include "config.h" +#include "conky.h" +#include "logging.h" +#include "audacious.h" #include #ifndef AUDACIOUS_LEGACY @@ -50,9 +51,6 @@ xmms_remote_get_playlist_length(x) #endif -#include "conky.h" -#include "audacious.h" - /* access to this item array is synchronized */ static audacious_t audacious_items; diff --git a/src/bmpx.c b/src/bmpx.c index 4dd19af..d3d25b8 100644 --- a/src/bmpx.c +++ b/src/bmpx.c @@ -24,11 +24,13 @@ * */ +#include "config.h" +#include "conky.h" +#include "logging.h" + #include #include -#include "conky.h" - #define DBUS_TYPE_G_STRING_VALUE_HASHTABLE \ (dbus_g_type_get_map("GHashTable", G_TYPE_STRING, G_TYPE_VALUE)) diff --git a/src/common.c b/src/common.c index 68a8eb8..aff0bcd 100644 --- a/src/common.c +++ b/src/common.c @@ -25,12 +25,27 @@ * */ +#include "config.h" #include "conky.h" +#include "fs.h" +#include "logging.h" #include #include #include #include +/* check for OS and include appropriate headers */ +#if defined(__linux__) +#include "linux.h" +#elif defined(__FreeBSD__) || defined(__FreeBSD_kernel__) +#include "freebsd.h" +#elif defined(__OpenBSD__) +#include "openbsd.h" +#endif + +/* OS specific prototypes to be implemented by linux.c & Co. */ +void update_entropy(void); + #ifndef HAVE_STRNDUP // use our own strndup() if it's not available char *strndup(const char *s, size_t n) @@ -183,7 +198,7 @@ void free_dns_data(void) //static double last_dns_update; -void update_dns_data(void) +static void update_dns_data(void) { FILE *fp; char line[256]; @@ -258,6 +273,7 @@ static double last_meminfo_update; static double last_fs_update; unsigned long long need_mask; +int no_buffers; #define NEED(a) ((need_mask & (1 << a)) && ((info.mask & (1 << a)) == 0)) diff --git a/src/common.h b/src/common.h index 710ee7e..d68d075 100644 --- a/src/common.h +++ b/src/common.h @@ -1,5 +1,8 @@ -#ifndef COMMON_H_ -#define COMMON_H_ +#ifndef _COMMON_H +#define _COMMON_H + +#include +#include int check_mount(char *s); void update_diskio(void); @@ -9,8 +12,10 @@ void update_meminfo(void); void update_net_stats(void); void update_cpu_usage(void); void update_total_processes(void); +void update_uname(void); void update_running_processes(void); void update_i8k(void); +void update_stuff(void); char get_freq(char *, size_t, const char *, int, unsigned int); void get_freq_dynamic(char *, size_t, const char *, int); char get_voltage(char *, size_t, const char *, int, unsigned int); /* ptarjan */ @@ -19,6 +24,48 @@ void update_top(void); void free_all_processes(void); struct process *get_first_process(void); void get_cpu_count(void); +double get_time(void); + +FILE *open_file(const char *, int *); +void variable_substitute(const char *s, char *dest, unsigned int n); + +void format_seconds(char *buf, unsigned int n, long t); +void format_seconds_short(char *buf, unsigned int n, long t); + +#ifdef X11 +void update_x11info(void); +#endif + +int round_to_int(float); + +extern unsigned long long need_mask; +extern int no_buffers; + +struct dns_data { + int nscount; + char **ns_list; +}; +void free_dns_data(void); + +struct net_stat { + const char *dev; + int up; + long long last_read_recv, last_read_trans; + long long recv, trans; + double recv_speed, trans_speed; + struct sockaddr addr; + char* addrs; + double net_rec[15], net_trans[15]; + // wireless extensions + char essid[32]; + char bitrate[16]; + char mode[16]; + int link_qual; + int link_qual_max; + char ap[18]; +}; +void clear_net_stats(void); +struct net_stat *get_net_stat(const char *); int open_sysfs_sensor(const char *dir, const char *dev, const char *type, int n, int *divisor, char *devtype); @@ -44,4 +91,4 @@ 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); -#endif /*COMMON_H_*/ +#endif /* _COMMON_H */ diff --git a/src/conky.c b/src/conky.c index 94980da..d9c82d6 100644 --- a/src/conky.c +++ b/src/conky.c @@ -25,8 +25,10 @@ * */ +#include "config.h" #include "text_object.h" #include "conky.h" +#include "common.h" #include #include #include @@ -40,6 +42,7 @@ #endif #include #ifdef X11 +#include "x11.h" #include #ifdef HAVE_XDAMAGE #include @@ -55,6 +58,35 @@ #include #include +/* local headers */ +#include "build.h" +#include "diskio.h" +#include "fs.h" +#include "logging.h" +#include "mixer.h" +#include "mail.h" +#include "mboxscan.h" +#include "temphelper.h" +#include "top.h" + +/* check for OS and include appropriate headers */ +#if defined(__linux__) +#include "linux.h" +#elif defined(__FreeBSD__) || defined(__FreeBSD_kernel__) +#include "freebsd.h" +#elif defined(__OpenBSD__) +#include "openbsd.h" +#endif + +/* FIXME: apm_getinfo is unused here. maybe it's meant for common.c */ +#if (defined(__FreeBSD__) || defined(__FreeBSD_kernel__) \ + || defined(__OpenBSD__)) && (defined(i386) || defined(__i386__)) +int apm_getinfo(int fd, apm_info_t aip); +char *get_apm_adapter(void); +char *get_apm_battery_life(void); +char *get_apm_battery_time(void); +#endif + #ifdef HAVE_ICONV #include #endif @@ -66,10 +98,6 @@ #endif #endif -#include "build.h" - -#include "temphelper.h" - #ifndef S_ISSOCK #define S_ISSOCK(x) ((x & S_IFMT) == S_IFSOCK) #endif @@ -81,10 +109,30 @@ //#define SIGNAL_BLOCKING #undef SIGNAL_BLOCKING -/* debugging level */ +/* debugging level, used by logging.h */ int global_debug_level = 0; +/* two strings for internal use */ +static char *tmpstring1, *tmpstring2; + +/* variables holding various config settings */ +int short_units; +int cpu_separate; +static int use_spacer; +int top_cpu, top_mem; +#define TO_X 1 +#define TO_STDOUT 2 +static int output_methods; +static volatile int g_signal_pending; +/* Update interval */ +static double update_interval; + + +/* prototypes for internally used functions */ +static void signal_handler(int); static void print_version(void) __attribute__((noreturn)); +static void reload_config(void); +static void clean_up(void); static void print_version(void) { @@ -339,6 +387,10 @@ static void load_fonts(void) #endif /* X11 */ +/* struct that has all info to be shared between + * instances of the same text object */ +struct information info; + /* default config file */ static char *current_config; @@ -6931,7 +6983,7 @@ static void main_loop(void) static void load_config_file(const char *); /* reload the config file */ -void reload_config(void) +static void reload_config(void) { timed_thread_destroy_registered_threads(); @@ -7034,7 +7086,7 @@ void reload_config(void) } } -void clean_up(void) +static void clean_up(void) { timed_thread_destroy_registered_threads(); @@ -8399,7 +8451,7 @@ int main(int argc, char **argv) return 0; } -void signal_handler(int sig) +static void signal_handler(int sig) { /* signal handler is light as a feather, as it should be. * we will poll g_signal_pending with each loop of conky diff --git a/src/conky.h b/src/conky.h index 4293aba..d87ab3c 100644 --- a/src/conky.h +++ b/src/conky.h @@ -28,6 +28,10 @@ #ifndef _conky_h_ #define _conky_h_ +#include "config.h" /* defines */ +#include "common.h" /* at least for struct dns_data */ +#include /* struct uname_s */ + #if defined(HAS_MCHECK_H) #include #endif /* HAS_MCHECK_H */ @@ -39,171 +43,69 @@ #define FALSE 0 #define TRUE 1 -#include "config.h" -#include -#include -#include -#include -#include -#include -#include -#include #if !defined(__GNUC__) # define __attribute__(x) /* nothing */ #endif -#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__) -#include "freebsd.h" -#endif /* __FreeBSD__ || __FreeBSD_kernel__ */ - -#if defined(__OpenBSD__) -#include "openbsd.h" -#endif /* __OpenBSD__ */ - #ifndef HAVE_STRNDUP // use our own strndup() if it's not available char *strndup(const char *s, size_t n); #endif /* HAVE_STRNDUP */ +/* headers of optional features + * include them here, so we don't need to run the check + * in every code file optionally using the feature + */ + #ifdef AUDACIOUS #include "audacious.h" #endif -#ifdef XMMS2 -#include -#endif - -#ifdef RSS -#include "rss.h" +#ifdef BMPX +#include "bmpx.h" #endif #ifdef EVE #include "eve.h" #endif -#ifdef SMAPI -#include "smapi.h" +#ifdef HDDTEMP +#include "hddtemp.h" +#endif /* HDDTEMP */ + +#ifdef MOC +#include "moc.h" +#endif + +#ifdef MPD +#include "mpd.h" #endif #ifdef NVIDIA #include "nvidia.h" #endif -#include "mboxscan.h" -#include "timed_thread.h" -#include "top.h" - -#define DEFAULT_TEXT_BUFFER_SIZE 256 -extern unsigned int text_buffer_size; - -/* maximum number of special things, e.g. fonts, offsets, aligns, etc. */ -#define MAX_SPECIALS_DEFAULT 512 - -/* maximum size of config TEXT buffer, i.e. below TEXT line. */ -#define MAX_USER_TEXT_DEFAULT 16384 - -#include - -#define ERR(...) { \ - fprintf(stderr, PACKAGE_NAME": "); \ - fprintf(stderr, __VA_ARGS__); \ - fprintf(stderr, "\n"); \ -} - -/* critical error */ -#define CRIT_ERR(...) \ - { ERR(__VA_ARGS__); exit(EXIT_FAILURE); } - -/* debugging output */ -extern int global_debug_level; -#define __DBGP(level, ...) \ - if (global_debug_level > level) { \ - fprintf(stderr, "DEBUG(%d) [" __FILE__ ":%d]: ", level, __LINE__); \ - fprintf(stderr, __VA_ARGS__); \ - fprintf(stderr, "\n"); \ - } -#define DBGP(...) __DBGP(0, __VA_ARGS__) -#define DBGP2(...) __DBGP(1, __VA_ARGS__) - -struct net_stat { - const char *dev; - int up; - long long last_read_recv, last_read_trans; - long long recv, trans; - double recv_speed, trans_speed; - struct sockaddr addr; - char* addrs; - double net_rec[15], net_trans[15]; - // wireless extensions - char essid[32]; - char bitrate[16]; - char mode[16]; - int link_qual; - int link_qual_max; - char ap[18]; -}; - -struct dns_data { - int nscount; - char **ns_list; -}; - -struct fs_stat { - char path[DEFAULT_TEXT_BUFFER_SIZE]; - char type[DEFAULT_TEXT_BUFFER_SIZE]; - long long size; - long long avail; - long long free; - char set; -}; - -#include "diskio.h" - -struct mail_s { // for imap and pop3 - unsigned long unseen; - unsigned long messages; - unsigned long used; - unsigned long quota; - unsigned long port; - unsigned int retries; - float interval; - double last_update; - char host[128]; - char user[128]; - char pass[128]; - char command[1024]; - char folder[128]; - timed_thread *p_timed_thread; - char secure; -}; - -/* struct cpu_stat { - unsigned int user, nice, system, idle, iowait, irq, softirq; - int cpu_avg_samples; -}; */ +#ifdef RSS +#include "rss.h" +#endif -#ifdef MPD -#include "mpd.h" +#ifdef SMAPI +#include "smapi.h" #endif -#ifdef MOC -#include "moc.h" +#ifdef TCP_PORT_MONITOR +#include "tcp-portmon.h" #endif #ifdef XMMS2 #include "xmms2.h" #endif -#ifdef AUDACIOUS -#include "audacious.h" -#endif - -#ifdef BMPX -#include "bmpx.h" -#endif +/* A size for temporary, static buffers to use when + * one doesn't know what to choose. Defaults to 256. */ +extern unsigned int text_buffer_size; -void update_entropy(void); struct entropy_s { unsigned int entropy_avail; unsigned int poolsize; @@ -233,10 +135,6 @@ struct x11_info { }; #endif -#ifdef TCP_PORT_MONITOR -#include "tcp-portmon.h" -#endif - enum { INFO_CPU = 0, INFO_MAIL = 1, @@ -292,24 +190,21 @@ enum { #endif }; -/* get_battery_stuff() item selector */ +/* get_battery_stuff() item selector + * needed by conky.c, linux.c and freebsd.c */ enum { BATTERY_STATUS, BATTERY_TIME }; -/* if_up strictness selector */ +/* if_up strictness selector + * needed by conky.c and linux.c (and potentially others) */ enum { IFUP_UP, IFUP_LINK, IFUP_ADDR } ifup_strictness; -/* Update interval */ -double update_interval; - -volatile int g_signal_pending; - struct information { unsigned int mask; @@ -377,6 +272,7 @@ struct information { unsigned int diskio_write_value; }; +/* needed by linux.c and top.c -> outsource somewhere */ enum { /* set to true if kernel uses "long" format for /proc/stats */ KFLAG_IS_LONGSTAT = 0x01, @@ -386,84 +282,27 @@ enum { /* bits 0x04, 0x08, 0x10, 0x20, 0x40, 0x80 available for future use */ /* KFLAG_NEXT_ONE = 0x04 */ }; - #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 -#define TO_X 1 -#define TO_STDOUT 2 -int output_methods; - -int top_cpu; -int top_mem; - -int use_spacer; +/* defined in conky.c, needed by top.c */ +extern int top_cpu, top_mem; enum spacer_opts { NO_SPACER = 0, LEFT_SPACER, RIGHT_SPACER }; -char *tmpstring1; -char *tmpstring2; - -#ifdef X11 -#include "x11.h" -#endif /* X11 */ - -int cpu_separate; -int short_units; - -/* struct that has all info */ -struct information info; - -void signal_handler(int); -void reload_config(void); -void clean_up(void); - -void update_uname(void); -double get_time(void); -FILE *open_file(const char *file, int *reported); -void variable_substitute(const char *s, char *dest, unsigned int n); -void format_seconds(char *buf, unsigned int n, long t); -void format_seconds_short(char *buf, unsigned int n, long t); -struct net_stat *get_net_stat(const char *dev); -void clear_net_stats(void); -void free_dns_data(void); -void update_dns_data(void); -void update_users(void); - -#ifdef X11 -void update_x11info(void); -#endif +/* defined in conky.c, needed by top.c */ +extern int cpu_separate; -void update_stuff(void); +/* struct that has all info to be shared between + * instances of the same text object */ +extern struct information info; -int round_to_int(float f); - -extern unsigned long long need_mask; +/* defined in users.c */ +void update_users(void); +/* defined in conky.c */ extern double current_update_time, last_update_time; -extern int no_buffers; - -#if defined(__linux__) -#include "linux.h" -#endif - -#include "fs.h" -#include "mixer.h" -#include "mail.h" - -#if (defined(__FreeBSD__) || defined(__FreeBSD_kernel__) \ - || defined(__OpenBSD__)) && (defined(i386) || defined(__i386__)) -int apm_getinfo(int fd, apm_info_t aip); -char *get_apm_adapter(void); -char *get_apm_battery_life(void); -char *get_apm_battery_time(void); -#endif - -#ifdef HDDTEMP -#include "hddtemp.h" -#endif /* HDDTEMP */ - #endif diff --git a/src/diskio.c b/src/diskio.c index 56fa744..60b6352 100644 --- a/src/diskio.c +++ b/src/diskio.c @@ -26,7 +26,12 @@ * */ -#include "conky.h" +#include "config.h" +#include "conky.h" /* text_buffer_size */ +#include "logging.h" +#include "diskio.h" +#include "common.h" +#include #include /* The following ifdefs were adapted from gkrellm */ #include diff --git a/src/fs.c b/src/fs.c index a668002..dbdea8e 100644 --- a/src/fs.c +++ b/src/fs.c @@ -26,6 +26,8 @@ */ #include "conky.h" +#include "logging.h" +#include "fs.h" #include #include #include diff --git a/src/fs.h b/src/fs.h index f786b74..f1690ab 100644 --- a/src/fs.h +++ b/src/fs.h @@ -1,8 +1,20 @@ -#ifndef FS_H_ -#define FS_H_ +#ifndef _FS_H +#define _FS_H + +#include "conky.h" /* DEFAULT_TEXT_BUFFER_SIZE */ + +/* needed here and by fs.c */ +struct fs_stat { + char path[DEFAULT_TEXT_BUFFER_SIZE]; + char type[DEFAULT_TEXT_BUFFER_SIZE]; + long long size; + long long avail; + long long free; + char set; +}; void update_fs_stats(void); struct fs_stat *prepare_fs_stat(const char *path); void clear_fs_stats(void); -#endif /*FS_H_*/ +#endif /* _FS_H */ diff --git a/src/hddtemp.c b/src/hddtemp.c index 7b2f042..3e66a29 100644 --- a/src/hddtemp.c +++ b/src/hddtemp.c @@ -26,6 +26,7 @@ */ #include "conky.h" +#include "logging.h" #include #include #include diff --git a/src/linux.c b/src/linux.c index ab4d709..57b6f59 100644 --- a/src/linux.c +++ b/src/linux.c @@ -27,6 +27,9 @@ */ #include "conky.h" +#include "logging.h" +#include "common.h" +#include "linux.h" #include #include #include diff --git a/src/linux.h b/src/linux.h index 8b4346a..ec484cd 100644 --- a/src/linux.h +++ b/src/linux.h @@ -1,5 +1,5 @@ -#ifndef LINUX_H_ -#define LINUX_H_ +#ifndef _LINUX_H +#define _LINUX_H #include "common.h" @@ -38,4 +38,4 @@ void update_gateway_info(void); enum { PB_BATT_STATUS, PB_BATT_PERCENT, PB_BATT_TIME }; void get_powerbook_batt_info(char *, size_t, int); -#endif /*LINUX_H_*/ +#endif /* _LINUX_H */ diff --git a/src/logging.h b/src/logging.h new file mode 100644 index 0000000..1d02fbc --- /dev/null +++ b/src/logging.h @@ -0,0 +1,51 @@ +/* Conky, a system monitor, based on torsmo + * + * Any original torsmo code is licensed under the BSD license + * + * All code written since the fork of torsmo is licensed under the GPL + * + * Please see COPYING for details + * + * Copyright (c) 2004, Hannu Saransaari and Lauri Hakkarainen + * Copyright (c) 2005-2008 Brenden Matthews, Philip Kovacs, et. al. + * (see AUTHORS) + * All rights reserved. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * + */ +#ifndef _LOGGING_H +#define _LOGGING_H + +#define ERR(...) { \ + fprintf(stderr, PACKAGE_NAME": "); \ + fprintf(stderr, __VA_ARGS__); \ + fprintf(stderr, "\n"); \ +} + +/* critical error */ +#define CRIT_ERR(...) \ + { ERR(__VA_ARGS__); exit(EXIT_FAILURE); } + +/* debugging output */ +extern int global_debug_level; +#define __DBGP(level, ...) \ + if (global_debug_level > level) { \ + fprintf(stderr, "DEBUG(%d) [" __FILE__ ":%d]: ", level, __LINE__); \ + fprintf(stderr, __VA_ARGS__); \ + fprintf(stderr, "\n"); \ + } +#define DBGP(...) __DBGP(0, __VA_ARGS__) +#define DBGP2(...) __DBGP(1, __VA_ARGS__) + +#endif /* _LOGGING_H */ diff --git a/src/mail.c b/src/mail.c index d8a0099..e1bd0ce 100644 --- a/src/mail.c +++ b/src/mail.c @@ -25,8 +25,18 @@ * */ +#include "config.h" #include "conky.h" +#include "common.h" +#include "logging.h" +#include "mail.h" +#include +#include +#include +#include +#include +#include #include #include @@ -34,6 +44,13 @@ #include #include +/* MAX() is defined by a header included from conky.h + * maybe once this is not true anymore, so have an alternative + * waiting to drop in. + * + * #define MAX(a, b) ((a > b) ? a : b) + */ + char *current_mail_spool; void update_mail_count(struct local_mail_s *mail) diff --git a/src/mail.h b/src/mail.h index f12d8a1..45f5866 100644 --- a/src/mail.h +++ b/src/mail.h @@ -1,8 +1,28 @@ -#ifndef _MAIL_H_ -#define _MAIL_H_ +#ifndef _MAIL_H +#define _MAIL_H + +#include "timed_thread.h" extern char *current_mail_spool; +struct mail_s { // for imap and pop3 + unsigned long unseen; + unsigned long messages; + unsigned long used; + unsigned long quota; + unsigned long port; + unsigned int retries; + float interval; + double last_update; + char host[128]; + char user[128]; + char pass[128]; + char command[1024]; + char folder[128]; + timed_thread *p_timed_thread; + char secure; +}; + struct local_mail_s { char *box; int mail_count; @@ -21,4 +41,4 @@ struct mail_s *parse_mail_args(char type, const char *arg); void *imap_thread(void *arg); void *pop3_thread(void *arg); -#endif /* _MAIL_H_ */ +#endif /* _MAIL_H */ diff --git a/src/mboxscan.c b/src/mboxscan.c index 03e5609..3986609 100644 --- a/src/mboxscan.c +++ b/src/mboxscan.c @@ -26,6 +26,8 @@ */ #include "conky.h" +#include "logging.h" +#include "mail.h" #include #include #include diff --git a/src/mixer.c b/src/mixer.c index 3d72ba0..312aa13 100644 --- a/src/mixer.c +++ b/src/mixer.c @@ -26,6 +26,7 @@ */ #include "conky.h" +#include "logging.h" #include #include #include diff --git a/src/moc.c b/src/moc.c index 3fe827f..6e74f9c 100644 --- a/src/moc.c +++ b/src/moc.c @@ -19,6 +19,7 @@ */ #include "conky.h" +#include "logging.h" #include "moc.h" #include diff --git a/src/mpd.c b/src/mpd.c index a484484..6c7cebe 100644 --- a/src/mpd.c +++ b/src/mpd.c @@ -25,6 +25,7 @@ */ #include "conky.h" +#include "logging.h" void init_mpd_stats(struct mpd_s *mpd) { diff --git a/src/rss.c b/src/rss.c index 1938cb4..ec01e4e 100644 --- a/src/rss.c +++ b/src/rss.c @@ -26,6 +26,7 @@ */ #include "conky.h" +#include "logging.h" #include "prss.h" #include #include diff --git a/src/smapi.c b/src/smapi.c index 1a2d330..e0ca9e1 100644 --- a/src/smapi.c +++ b/src/smapi.c @@ -18,8 +18,15 @@ * USA. * */ - +#define _GNU_SOURCE +#include "conky.h" /* text_buffer_size, PACKAGE_NAME, maybe more */ #include "smapi.h" +#include "logging.h" +#include +#include +#include +#include +#include #define SYS_SMAPI_PATH "/sys/devices/platform/smapi" diff --git a/src/smapi.h b/src/smapi.h index b8272d1..eebe9df 100644 --- a/src/smapi.h +++ b/src/smapi.h @@ -19,11 +19,8 @@ * */ -#ifndef SMAPI_H -#define SMAPI_H - -#include "conky.h" -#include +#ifndef _SMAPI_H +#define _SMAPI_H int smapi_bat_installed(int); @@ -37,4 +34,4 @@ char *smapi_get_bat_str(int, const char *); int smapi_get_bat_int(int, const char *); char *smapi_get_bat_val(const char *); -#endif /* SMAPI_H */ +#endif /* _SMAPI_H */ diff --git a/src/solaris.c b/src/solaris.c index 701f1a8..15c7875 100644 --- a/src/solaris.c +++ b/src/solaris.c @@ -26,6 +26,7 @@ /* doesn't work, feel free to finish this */ #include "conky.h" +#include "common.h" #include static kstat_ctl_t *kstat; diff --git a/src/tcp-portmon.c b/src/tcp-portmon.c index 705d382..987f1ab 100644 --- a/src/tcp-portmon.c +++ b/src/tcp-portmon.c @@ -18,6 +18,7 @@ * */ #include "conky.h" +#include "logging.h" #include "tcp-portmon.h" #include "libtcp-portmon.h" diff --git a/src/text_object.c b/src/text_object.c index e473e67..dd21140 100644 --- a/src/text_object.c +++ b/src/text_object.c @@ -25,7 +25,7 @@ * */ #include "text_object.h" -#include "conky.h" /* not as worse: only for the printing macros */ +#include "logging.h" /* text_object_list * diff --git a/src/text_object.h b/src/text_object.h index 27fa67a..fb22ad3 100644 --- a/src/text_object.h +++ b/src/text_object.h @@ -35,6 +35,7 @@ #endif #include "mail.h" /* local_mail_s */ +#include "fs.h" /* struct fs_stat */ #ifdef NVIDIA #include "nvidia.h" /* nvidia_s */ diff --git a/src/x11.c b/src/x11.c index 0e48bd1..ee59e68 100644 --- a/src/x11.c +++ b/src/x11.c @@ -25,25 +25,26 @@ * */ +#include "config.h" #include "conky.h" +#include "logging.h" +#include "common.h" -#ifdef X11 +#include "x11.h" #include #include #include #include + #ifdef XFT #include +int use_xft = 0; #endif #ifdef HAVE_XDBE int use_xdbe; #endif -#ifdef XFT -int use_xft = 0; -#endif - /* some basic X11 stuff */ Display *display; int display_width; @@ -560,4 +561,3 @@ void update_x11info(void) current_info->x11.monitor.number = XScreenCount(display); current_info->x11.monitor.current = XDefaultScreen(display); } -#endif /* X11 */ -- 1.7.9.5