infopipe improvements
[monky] / src / conky.h
index a5e1492..9de5c55 100644 (file)
@@ -9,6 +9,9 @@
 #ifndef _conky_h_
 #define _conky_h_
 
+#ifdef INFOPIPE
+#include <pthread.h>
+#endif
 #if defined(HAS_MCHECK_H)
 #include <mcheck.h>
 #endif /* HAS_MCHECK_H */
@@ -19,8 +22,8 @@
 #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>
 #endif /* __FreeBSD__ */
@@ -45,6 +48,7 @@
 #define TOP_MEM 4
 
 #define TEXT_BUFFER_SIZE 1024
+#define P_MAX_SIZE ((TEXT_BUFFER_SIZE * 4) - 2) 
 
 #include <sys/socket.h>
 
@@ -55,8 +59,14 @@ fprintf(stderr, "Conky: " s "\n", ##varargs)
 #define CRIT_ERR(s, varargs...) \
 { fprintf(stderr, "Conky: " s "\n", ##varargs);  exit(EXIT_FAILURE); }
 
+/* in sys/param.h
+#ifndef MIN
 #define MIN(a,b) (a>b ? b : a)
+#endif
+#ifndef MAX
 #define MAX(a,b) (a<b ? b : a)
+#endif
+*/
 
 struct i8k_struct {
        char *version;
@@ -90,6 +100,7 @@ struct fs_stat {
        char *path;
        long long size;
        long long avail;
+       long long free;
 };
 
 /*struct cpu_stat {
@@ -116,6 +127,30 @@ struct mpd_s {
 };
 #endif
 
+#ifdef BMPX
+void update_bmpx();
+struct bmpx_s {
+       char *title;
+       char *artist;
+       char *album;
+       char *uri;
+       int bitrate;
+       int track;
+};
+#endif
+
+#ifdef INFOPIPE
+#include "infopipe.h"
+struct infopipe_s {
+       infopipe_t items;               /* e.g. items[INFOPIPE_STATUS] yields char[] */
+       int runnable;                   /* used to signal infopipe thread to stop */
+       pthread_t thread;               /* worker thread for infopipe updating */
+       pthread_attr_t thread_attr;     /* thread attributes */
+       pthread_mutex_t item_mutex;     /* mutex for item array */
+       pthread_mutex_t runnable_mutex; /* mutex for runnable flag */
+};
+#endif
+
 #ifdef TCP_PORT_MONITOR
 #include "libtcp-portmon.h"
 #define MIN_PORT_MONITORS_DEFAULT 16
@@ -153,6 +188,12 @@ enum {
 #ifdef TCP_PORT_MONITOR
         INFO_TCP_PORT_MONITOR = 22,
 #endif
+#ifdef BMPX
+       INFO_BMPX = 23,
+#endif
+#ifdef INFOPIPE
+       INFO_INFOPIPE = 24,
+#endif
 };
 
 
@@ -196,6 +237,12 @@ struct information {
        struct mpd_s mpd;
        mpd_Connection *conn;
 #endif
+#ifdef BMPX
+       struct bmpx_s bmpx;
+#endif
+#ifdef INFOPIPE
+       struct infopipe_s infopipe;
+#endif
        struct process *cpu[10];
        struct process *memu[10];
        struct process *first_process;