RSS was not really disabled when it was supposed to be. Experimental wireless support.
[monky] / src / conky.h
index fa95ba4..d941121 100644 (file)
 #include <sys/utsname.h>
 #include <stdio.h>
 #include <stdlib.h>
+#include <string.h>
 #include <locale.h>
 #include <langinfo.h>
 #include <wchar.h>
-#if defined(__FreeBSD__)
 #include <sys/param.h>
+#if defined(__FreeBSD__)
 #include <sys/mount.h>
 #include <sys/ucred.h>
+#include <fcntl.h>
+#include <kvm.h>
 #endif /* __FreeBSD__ */
 
-#ifdef X11
-#if defined(HAVE_CAIRO_H) && defined(HAVE_CAIRO_XLIB_H) && defined(WANT_CAIRO)
-#define CAIRO
-#include <X11/Xlib.h>
-#include <X11/Xutil.h>
-#include <cairo.h>
-#include <cairo-xlib.h>
-#endif
-#endif /* X11 */
-
 #if defined(__FreeBSD__) && (defined(i386) || defined(__i386__))
 #include <machine/apm_bios.h>
 #endif /* __FreeBSD__ */
 
+#if defined(__OpenBSD__)
+#include <sys/sysctl.h>
+#include <sys/sensors.h>
+#include <machine/apmvar.h>
+#endif /* __OpenBSD__ */
+
+#ifdef AUDACIOUS
+#include "audacious.h"
+#endif
+
+#ifdef XMMS2
+#include <xmmsclient/xmmsclient.h>
+#endif
+
+#ifdef RSS
+#include "prss.h"
+#endif
+
+#include "mboxscan.h"
+#include "timed_thread.h"
+
 #define TOP_CPU 1
 #define TOP_NAME 2
 #define TOP_PID 3
 #define TOP_MEM 4
 
-#define TEXT_BUFFER_SIZE 1024
+#define TEXT_BUFFER_SIZE 1280
+#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. */
+#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>
 
@@ -79,17 +101,43 @@ struct net_stat {
        struct sockaddr addr;
        int linkstatus;
        double net_rec[15], net_trans[15];
+       // wireless extensions
+       char essid[32];
+       char bitrate[16];
+       char mode[16];
+       char ap[18];
+       int link_qual;
+       int link_qual_max;
 };
 
 unsigned int diskio_value;
+unsigned int diskio_read_value;
+unsigned int diskio_write_value;
 
 struct fs_stat {
-       int fd;
        char *path;
        long long size;
        long long avail;
+       long long free;
 };
 
+struct mail_s {                        // for imap and pop3
+       unsigned long unseen;
+       unsigned long messages;
+       unsigned long used;
+       unsigned long quota;
+       unsigned long port;
+       float interval;
+       double last_update;
+       char host[128];
+       char user[128];
+       char pass[128];
+       char command[1024];
+       char folder[128];
+       char secure;
+       timed_thread *p_timed_thread;
+} mail;
+
 /*struct cpu_stat {
        unsigned int user, nice, system, idle, iowait, irq, softirq;
        int cpu_avg_samples;
@@ -104,51 +152,130 @@ struct mpd_s {
        char *random;
        char *repeat;
        char *track;
+       char *name;
+       char *file;
        int volume;
        unsigned int port;
        char host[128];
+       char password[128];
        float progress;
        int bitrate;
        int length;
        int elapsed;
+       int max_title_len;              /* e.g. ${mpd_title 50} */
+};
+#endif
+
+#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;
+};
+#endif
+
+#ifdef AUDACIOUS
+struct audacious_s {
+       audacious_t items;              /* e.g. items[AUDACIOUS_STATUS] */
+       int max_title_len;              /* e.g. ${audacious_title 50} */
+       timed_thread *p_timed_thread;
 };
 #endif
 
+#ifdef BMPX
+void update_bmpx();
+struct bmpx_s {
+       char *title;
+       char *artist;
+       char *album;
+       char *uri;
+       int bitrate;
+       int track;
+};
+#endif
+
+void update_entropy();
+struct entropy_s {
+       unsigned int entropy_avail;
+       unsigned int poolsize;
+};
+
+#ifdef TCP_PORT_MONITOR
+#include "libtcp-portmon.h"
+#define MAX_PORT_MONITOR_CONNECTIONS_DEFAULT 256
+#endif
+
 enum {
        INFO_CPU = 0,
        INFO_MAIL = 1,
        INFO_MEM = 2,
        INFO_NET = 3,
-#ifdef SETI
-       INFO_SETI = 4,
-#endif
-       INFO_PROCS = 5,
-       INFO_RUN_PROCS = 6,
-       INFO_UPTIME = 7,
-       INFO_BUFFERS = 8,
-       INFO_FS = 9,
-       INFO_I2C = 10,
-       INFO_MIXER = 11,
-       INFO_LOADAVG = 12,
-       INFO_UNAME = 13,
-       INFO_FREQ = 14,
+       INFO_PROCS = 4,
+       INFO_RUN_PROCS = 5,
+       INFO_UPTIME = 6,
+       INFO_BUFFERS = 7,
+       INFO_FS = 8,
+       INFO_I2C = 9,
+       INFO_MIXER = 10,
+       INFO_LOADAVG = 11,
+       INFO_UNAME = 12,
+       INFO_FREQ = 13,
 #ifdef MPD
-       INFO_MPD = 15,
+       INFO_MPD = 14,
 #endif
-       INFO_TOP = 16,
-#ifdef MLDONKEY
-       INFO_MLDONKEY = 18,
+       INFO_TOP = 15,
+       INFO_WIFI = 16,
+       INFO_DISKIO = 17,
+       INFO_I8K = 18,
+#ifdef TCP_PORT_MONITOR
+        INFO_TCP_PORT_MONITOR = 19,
+#endif
+#ifdef AUDACIOUS
+       INFO_AUDACIOUS = 20,
+#endif
+#ifdef BMPX
+       INFO_BMPX = 21,
+#endif
+#ifdef XMMS2
+       INFO_XMMS2 = 22,
+#endif
+       INFO_ENTROPY = 23,
+#ifdef RSS
+       INFO_RSS = 24,
 #endif
-       INFO_WIFI = 19,
-       INFO_DISKIO = 20,
-       INFO_I8K = 21,
 };
 
 
+/* get_battery_stuff() item selector */
+enum {
+       BATTERY_STATUS,
+       BATTERY_TIME
+};
+
 #ifdef MPD
 #include "libmpdclient.h"
 #endif
 
+/* Update interval */
+double update_interval;
+
+volatile int g_signal_pending;
+
 struct information {
        unsigned int mask;
 
@@ -159,11 +286,11 @@ struct information {
        double uptime;
 
        /* memory information in kilobytes */
-       unsigned long mem, memmax, swap, swapmax;
-       unsigned long bufmem, buffers, cached;
+       unsigned long long mem, memmax, swap, swapmax;
+       unsigned long long bufmem, buffers, cached;
 
-       unsigned int procs;
-       unsigned int run_procs;
+       unsigned short procs;
+       unsigned short run_procs;
 
        float *cpu_usage;
        /*      struct cpu_stat cpu_summed; what the hell is this? */
@@ -175,19 +302,48 @@ struct information {
        float loadavg[3];
 
        int new_mail_count, mail_count;
-#ifdef SETI
-       float seti_prog;
-       float seti_credit;
-#endif
+       struct mail_s* mail;
+       int mail_running;
 #ifdef MPD
        struct mpd_s mpd;
        mpd_Connection *conn;
 #endif
+#ifdef XMMS2
+       struct xmms2_s xmms2;
+       int xmms2_conn_state;
+       xmms_socket_t xmms2_fd; 
+       fd_set xmms2_fdset;
+       xmmsc_connection_t *xmms2_conn;
+#endif
+#ifdef AUDACIOUS
+       struct audacious_s audacious;
+#endif
+#ifdef BMPX
+       struct bmpx_s bmpx;
+#endif
        struct process *cpu[10];
        struct process *memu[10];
+       struct process *first_process;
        unsigned long looped;
+#ifdef TCP_PORT_MONITOR
+  tcp_port_monitor_collection_t * p_tcp_port_monitor_collection;
+#endif
+       short kflags;  /* kernel settings, see enum KFLAG */
+       struct entropy_s entropy;
 };
 
+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 */
+     };        
+
+#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;
@@ -195,8 +351,8 @@ int top_mem;
 
 int use_spacer;
 
-char *tmpstring1;
-char *tmpstring2;
+char tmpstring1[TEXT_BUFFER_SIZE];
+char tmpstring2[TEXT_BUFFER_SIZE];
 
 #ifdef X11
 /* in x11.c */
@@ -209,18 +365,35 @@ char *tmpstring2;
 #include <X11/Xft/Xft.h>
 #endif
 
-#if defined(HAVE_XDBE) && defined(DOUBLE_BUFFER)
-#define XDBE
+#ifdef HAVE_XDBE
 #include <X11/extensions/Xdbe.h>
 #endif
 
 #define ATOM(a) XInternAtom(display, #a, False)
 
+#ifdef OWN_WINDOW
+enum _window_type {
+        TYPE_NORMAL = 0,
+        TYPE_DESKTOP,
+       TYPE_OVERRIDE
+};
+
+enum _window_hints {
+       HINT_UNDECORATED = 0,
+       HINT_BELOW,
+       HINT_ABOVE,
+       HINT_STICKY,
+       HINT_SKIP_TASKBAR,
+       HINT_SKIP_PAGER
+};
+#define SET_HINT(mask,hint)    (mask |= (1<<hint))
+#define TEST_HINT(mask,hint)   (mask & (1<<hint))
+#endif
 struct conky_window {
-       Window window;
+       Window root,window,desktop;
        Drawable drawable;
        GC gc;
-#ifdef XDBE
+#ifdef HAVE_XDBE
        XdbeBackBuffer back_buffer;
 #endif
 #ifdef XFT
@@ -230,12 +403,16 @@ struct conky_window {
        int width;
        int height;
 #ifdef OWN_WINDOW
+       char class_name[256];
+  char title[256];
        int x;
        int y;
+       unsigned int type;
+       unsigned long hints;
 #endif
 };
 
-#ifdef XDBE
+#ifdef HAVE_XDBE
 extern int use_xdbe;
 #endif
 
@@ -254,11 +431,8 @@ extern int workarea[4];
 extern struct conky_window window;
 
 void init_X11();
-#if defined OWN_WINDOW
-void init_window(int use_own_window, int width, int height, int on_bottom, int fixed_pos, int set_trans, int back_colour);
-#else
-void init_window(int use_own_window, int width, int height, int on_bottom, int set_trans, int back_colour);
-#endif
+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 *);
@@ -270,6 +444,10 @@ long get_x11_color(const char *);
 /* struct that has all info */
 struct information info;
 
+void signal_handler(int);
+void reload_config(void);
+void clean_up(void);
+
 void update_uname();
 double get_time(void);
 FILE *open_file(const char *file, int *reported);
@@ -277,6 +455,7 @@ 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 update_stuff();
 
@@ -291,32 +470,68 @@ extern int no_buffers;
 
 /* system dependant (in linux.c) */
 
+int check_mount(char *s);
 void update_diskio(void);
 void prepare_update(void);
 void update_uptime(void);
 void update_meminfo(void);
 void update_net_stats(void);
+#if 0
 void update_wifi_stats(void);
+#endif
 void update_cpu_usage(void);
 void update_total_processes(void);
 void update_running_processes(void);
 void update_i8k(void);
-float get_freq();
-float get_freq_dynamic();
+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_i2c_sensor(const char *dev, const char *type, int n, int *div,
                    char *devtype);
 double get_i2c_info(int *fd, int arg, char *devtype, char *type);
 
-char *get_adt746x_cpu(void);
-char *get_adt746x_fan(void);
+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);
-char *get_acpi_ac_adapter(void);
-char *get_acpi_fan(void);
-void get_battery_stuff(char *buf, unsigned int n, const char *bat);
+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);
+void get_ibm_acpi_fan(char *buf, size_t client_buffer_size);
+void get_ibm_acpi_temps(void);
+void get_ibm_acpi_volume(char *buf, size_t client_buffer_size);
+void get_ibm_acpi_brightness(char *buf, size_t client_buffer_size);
+void get_cpu_count();
+
+struct ibm_acpi_struct {
+    unsigned int temps[8];
+};
+
+struct ibm_acpi_struct ibm_acpi;
+
+#if defined(__OpenBSD__)
+void update_obsd_sensors(void);
+void get_obsd_vendor(char *buf, size_t client_buffer_size);
+void get_obsd_product(char *buf, size_t client_buffer_size);
+
+#define OBSD_MAX_SENSORS 256
+struct obsd_sensors_struct {
+       int device;
+       float temp[MAXSENSORDEVICES][OBSD_MAX_SENSORS];
+       unsigned int fan[MAXSENSORDEVICES][OBSD_MAX_SENSORS];
+       float volt[MAXSENSORDEVICES][OBSD_MAX_SENSORS];
+};
+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);
 
 struct process {
        struct process *next;
@@ -325,11 +540,11 @@ struct process {
        pid_t pid;
        char *name;
        float amount;
-       unsigned int user_time;
-       unsigned int total;
-       unsigned int kernel_time;
-       unsigned int previous_user_time;
-       unsigned int previous_kernel_time;
+       unsigned long user_time;
+       unsigned long total;
+       unsigned long kernel_time;
+       unsigned long previous_user_time;
+       unsigned long previous_kernel_time;
        unsigned int vsize;
        unsigned int rss;
        unsigned int time_stamp;
@@ -339,6 +554,8 @@ struct process {
 };
 
 void update_top();
+void free_all_processes();
+struct process *get_first_process();
 
 /* fs-stuff is possibly system dependant (in fs.c) */
 
@@ -359,66 +576,50 @@ extern char *current_mail_spool;
 
 void update_mail_count();
 
-/* in seti.c */
-
-#ifdef SETI
-extern char *seti_dir;
-
-void update_seti();
+/* in freebsd.c */
+#if defined(__FreeBSD__)
+kvm_t *kd;
 #endif
 
-/* in freebsd.c */
-#if defined(__FreeBSD__) && (defined(i386) || defined(__i386__))
+#if (defined(__FreeBSD__) || defined(__OpenBSD__)) && (defined(i386) || defined(__i386__))
+#ifdef __OpenBSD__
+typedef struct apm_power_info *apm_info_t;
+#endif
 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
-/* in mpd.c */
 
+/* in mpd.c */
 #ifdef MPD
 void update_mpd();
 #endif
 
-#ifdef MLDONKEY
-/* in mldonkey.c */
-typedef long long int64;
-/* The info necessary to connect to mldonkey. login and password can be NULL. */
-typedef struct mldonkey_config {
-       char *mldonkey_hostname;
-       int mldonkey_port;
-       char *mldonkey_login;
-       char *mldonkey_password;
-} mldonkey_config;
-
-/* The MLDonkey status returned */
-typedef struct mldonkey_info {
-       int64 upload_counter;
-       int64 download_counter;
-       int nshared_files;
-       int64 shared_counter;
-       int tcp_upload_rate;
-       int tcp_download_rate;
-       int udp_upload_rate;
-       int udp_download_rate;
-       int ndownloaded_files;
-       int ndownloading_files;
-       int nconnected_networks;
-       int connected_networks[1];
-} mldonkey_info;
-
-extern mldonkey_info mlinfo;
-extern mldonkey_config mlconfig;
-
-int get_mldonkey_status(mldonkey_config * config, mldonkey_info * info);
+/* in xmms2.c */
+#ifdef XMMS2
+void update_xmms2();
 #endif
 
-/* in linux.c */
+/* in hddtemp.c */
+#ifdef HDDTEMP
+int scan_hddtemp(const char *arg, char **dev, char **addr, int *port);
+char *get_hddtemp_info(char *dev, char *addr, int port, char *unit);
+#endif /* HDDTEMP */
 
-/* nothing to see here */
+/* in rss.c */
+#ifdef RSS
+PRSS* get_rss_info(char *uri, int delay);
+void init_rss_info();
+void free_rss_info();
+#endif /* RSS */
 
-/* in cairo.c */
+#if defined(__linux__)
+extern int post_21_kernel;
+#endif /* __linux__ */
 
-extern int do_it(void);
+/* in linux.c */
 
 #endif
+
+