Added support for APC UPS daemon monitoring.
[monky] / src / conky.h
1 /* Conky, a system monitor, based on torsmo
2  *
3  * Any original torsmo code is licensed under the BSD license
4  *
5  * All code written since the fork of torsmo is licensed under the GPL
6  *
7  * Please see COPYING for details
8  *
9  * Copyright (c) 2004, Hannu Saransaari and Lauri Hakkarainen
10  * Copyright (c) 2005-2009 Brenden Matthews, Philip Kovacs, et. al.
11  *      (see AUTHORS)
12  * All rights reserved.
13  *
14  * This program is free software: you can redistribute it and/or modify
15  * it under the terms of the GNU General Public License as published by
16  * the Free Software Foundation, either version 3 of the License, or
17  * (at your option) any later version.
18  *
19  * This program is distributed in the hope that it will be useful,
20  * but WITHOUT ANY WARRANTY; without even the implied warranty of
21  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
22  * GNU General Public License for more details.
23  * You should have received a copy of the GNU General Public License
24  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
25  *
26  */
27
28 #ifndef _conky_h_
29 #define _conky_h_
30
31 #include "config.h"     /* defines */
32 #include "common.h"     /* at least for struct dns_data */
33 #include <sys/utsname.h> /* struct uname_s */
34
35 #if defined(HAS_MCHECK_H)
36 #include <mcheck.h>
37 #endif /* HAS_MCHECK_H */
38
39 #undef EQUAL
40 #undef FALSE
41 #undef TRUE
42 #define EQUAL 0 //returnvalue of strcmp-variants when strings are equal
43 #define FALSE 0
44 #define TRUE 1
45
46
47 #if !defined(__GNUC__)
48 #  define __attribute__(x) /* nothing */
49 #endif
50
51 #ifndef HAVE_STRNDUP
52 // use our own strndup() if it's not available
53 char *strndup(const char *s, size_t n);
54 #endif /* HAVE_STRNDUP */
55
56 /* headers of optional features
57  * include them here, so we don't need to run the check
58  * in every code file optionally using the feature
59  */
60
61 #ifdef AUDACIOUS
62 #include "audacious.h"
63 #endif
64
65 #ifdef BMPX
66 #include "bmpx.h"
67 #endif
68
69 #ifdef EVE
70 #include "eve.h"
71 #endif
72
73 #ifdef HDDTEMP
74 #include "hddtemp.h"
75 #endif /* HDDTEMP */
76
77 #ifdef MOC
78 #include "moc.h"
79 #endif
80
81 #ifdef MPD
82 #include "mpd.h"
83 #endif
84
85 #ifdef NVIDIA
86 #include "nvidia.h"
87 #endif
88
89 #ifdef RSS
90 #include "rss.h"
91 #endif
92
93 #ifdef TCP_PORT_MONITOR
94 #include "tcp-portmon.h"
95 #endif
96
97 #ifdef XMMS2
98 #include "xmms2.h"
99 #endif
100
101 #ifdef IBM
102 #include "ibm.h"
103 #include "smapi.h"
104 #endif
105
106 #ifdef APCUPSD
107 #include "apcupsd.h"
108 #endif
109
110 /* sony support */
111 #include "sony.h"
112
113 /* A size for temporary, static buffers to use when
114  * one doesn't know what to choose. Defaults to 256.  */
115 extern unsigned int text_buffer_size;
116
117 struct entropy_s {
118         unsigned int entropy_avail;
119         unsigned int poolsize;
120 };
121
122 struct usr_info {
123         char *names;
124         char *times;
125         char *terms;
126         int number;
127 };
128
129 struct gateway_info {
130         char *iface;
131         char *ip;
132         int count;
133 };
134
135 #ifdef X11
136 struct monitor_info {
137         int number;
138         int current;
139 };
140
141 struct x11_info {
142         struct monitor_info monitor;
143 };
144 #endif
145
146 enum {
147         INFO_CPU = 0,
148         INFO_MAIL = 1,
149         INFO_MEM = 2,
150         INFO_NET = 3,
151         INFO_PROCS = 4,
152         INFO_RUN_PROCS = 5,
153         INFO_UPTIME = 6,
154         INFO_BUFFERS = 7,
155         INFO_FS = 8,
156         INFO_SYSFS = 9,
157         INFO_MIXER = 10,
158         INFO_LOADAVG = 11,
159         INFO_UNAME = 12,
160         INFO_FREQ = 13,
161 #ifdef MPD
162         INFO_MPD = 14,
163 #endif
164         INFO_TOP = 15,
165         INFO_WIFI = 16,
166         INFO_DISKIO = 17,
167         INFO_I8K = 18,
168 #ifdef TCP_PORT_MONITOR
169         INFO_TCP_PORT_MONITOR = 19,
170 #endif
171 #ifdef AUDACIOUS
172         INFO_AUDACIOUS = 20,
173 #endif
174 #ifdef BMPX
175         INFO_BMPX = 21,
176 #endif
177 #ifdef XMMS2
178         INFO_XMMS2 = 22,
179 #endif
180         INFO_ENTROPY = 23,
181 #ifdef RSS
182         INFO_RSS = 24,
183 #endif
184 #ifdef IBM
185         INFO_SMAPI = 25,
186 #endif
187         INFO_USERS = 26,
188         INFO_GW = 27,
189 #ifdef NVIDIA
190         INFO_NVIDIA = 28,
191 #endif
192 #ifdef X11
193         INFO_X11 = 29,
194 #endif
195         INFO_DNS = 30,
196 #ifdef MOC
197         INFO_MOC = 31,
198 #endif
199 #ifdef APCUPSD
200         INFO_APCUPSD = 32,
201 #endif
202 };
203
204 /* get_battery_stuff() item selector
205  * needed by conky.c, linux.c and freebsd.c */
206 enum {
207         BATTERY_STATUS,
208         BATTERY_TIME
209 };
210
211 /* if_up strictness selector
212  * needed by conky.c and linux.c (and potentially others) */
213 enum {
214         IFUP_UP,
215         IFUP_LINK,
216         IFUP_ADDR
217 } ifup_strictness;
218
219 struct information {
220         unsigned int mask;
221
222         struct utsname uname_s;
223
224         char freq[10];
225
226         double uptime;
227
228         /* memory information in kilobytes */
229         unsigned long long mem, memeasyfree, memfree, memmax, swap, swapmax;
230         unsigned long long bufmem, buffers, cached;
231
232         unsigned short procs;
233         unsigned short run_procs;
234
235         float *cpu_usage;
236         /* struct cpu_stat cpu_summed; what the hell is this? */
237         unsigned int cpu_count;
238         int cpu_avg_samples;
239
240         int net_avg_samples;
241
242         int diskio_avg_samples;
243
244         float loadavg[3];
245
246         struct mail_s *mail;
247         int mail_running;
248 #ifdef XMMS2
249         struct xmms2_s xmms2;
250 #endif
251 #ifdef AUDACIOUS
252         AUDACIOUS_S audacious;
253 #endif
254 #ifdef BMPX
255         struct bmpx_s bmpx;
256 #endif
257         struct usr_info users;
258         struct gateway_info gw_info;
259         struct dns_data nameserver_info;
260         struct process *cpu[10];
261         struct process *memu[10];
262         struct process *time[10];
263         struct process *first_process;
264         unsigned long looped;
265         struct entropy_s entropy;
266         double music_player_interval;
267
268 #ifdef X11
269         struct x11_info x11;
270 #endif
271
272 #ifdef APCUPSD
273         APCUPSD_S apcupsd;
274 #endif
275
276         short kflags;   /* kernel settings, see enum KFLAG */
277 };
278
279 /* needed by linux.c and top.c -> outsource somewhere */
280 enum {
281         /* set to true if kernel uses "long" format for /proc/stats */
282         KFLAG_IS_LONGSTAT = 0x01,
283         /* set to true if kernel shows # of threads for the proc value
284          * in sysinfo() call */
285         KFLAG_PROC_IS_THREADS = 0x02
286         /* bits 0x04, 0x08, 0x10, 0x20, 0x40, 0x80 available for future use */
287         /* KFLAG_NEXT_ONE = 0x04 */
288 };
289 #define KFLAG_SETON(a) info.kflags |= a
290 #define KFLAG_SETOFF(a) info.kflags &= (~a)
291 #define KFLAG_FLIP(a) info.kflags ^= a
292 #define KFLAG_ISSET(a) info.kflags & a
293
294 /* defined in conky.c, needed by top.c */
295 extern int top_cpu, top_mem, top_time;
296
297 /* defined in conky.c, needed by top.c */
298 extern int cpu_separate;
299
300 /* struct that has all info to be shared between
301  * instances of the same text object */
302 extern struct information info;
303
304 /* defined in users.c */
305 void update_users(void);
306
307 /* defined in conky.c */
308 extern double current_update_time, last_update_time, update_interval;
309
310 /* defined in conky.c */
311 int spaced_print(char *, int, const char *, int, ...)
312         __attribute__((format(printf, 3, 5)));
313
314 #define TO_X 1
315 #define TO_STDOUT 2
316 #define TO_STDERR 4
317 #define OVERWRITE_FILE 8
318 #define APPEND_FILE 16
319 enum x_initialiser_state {
320         NO = 0,
321         YES = 1,
322         NEVER = 2
323 };
324 extern int output_methods;
325 extern enum x_initialiser_state x_initialised;
326
327 #endif /* _conky_h_ */