here comes the big header include rewrite
[monky] / src / conky.h
index 4293aba..d87ab3c 100644 (file)
 #ifndef _conky_h_
 #define _conky_h_
 
+#include "config.h"    /* defines */
+#include "common.h"    /* at least for struct dns_data */
+#include <sys/utsname.h> /* struct uname_s */
+
 #if defined(HAS_MCHECK_H)
 #include <mcheck.h>
 #endif /* HAS_MCHECK_H */
 #define FALSE 0
 #define TRUE 1
 
-#include "config.h"
-#include <sys/utsname.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <locale.h>
-#include <langinfo.h>
-#include <wchar.h>
-#include <sys/param.h>
 
 #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 <xmmsclient/xmmsclient.h>
-#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 <sys/socket.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__)
-
-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