wmbiff: Fix segfault when -display or -geometry argument is missing.
[dockapps.git] / wmsupermon / stat_dev.h
blob1a51759718714b3587a76ff3dd5103eae073462c
1 /* Copyright (C) 2006 Sergei Golubchik
3 This program is free software; you can redistribute it and/or modify
4 it under the terms of the GNU General Public License version 2
5 as published by the Free Software Foundation
7 This program is distributed in the hope that it will be useful,
8 but WITHOUT ANY WARRANTY; without even the implied warranty of
9 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10 GNU General Public License for more details.
12 You should have received a copy of the GNU General Public License
13 along with this program; if not, write to the Free Software
14 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */
17 originally based on
18 WMgMon - Window Maker Generic Monitor
19 by Nicolas Chauvat <nico@caesium.fr>
20 which was based on
21 WMMon from Antoine Nulle and Martijn Pieterse.
24 #ifndef __STAT_DEV_H
25 #define __STAT_DEV_H
27 #include <string.h>
28 #include <stdio.h>
30 #define INIT 0
31 #define NORMAL 1
32 #define CLOSE 2
34 #define TEMP_SIZE 128
35 #define STRARG_LEN 255
36 #define NAME_LEN 3
37 #define MIN_FILE_LEN 8192
38 /******************************************************************************/
39 /* stat_dev structure and related functions */
40 /******************************************************************************/
42 #define HIST_SIZE 55
43 #define HIST_LAST 54
44 #define SMOOTH_SIZE 8
46 /* note that P_SMOOTH and P_LOG *must* be 0 and 1 respectively */
47 #define P_SMOOTH (1L << 0)
48 #define P_LOG (1L << 1)
49 #define P_LABEL (1L << 2)
50 #define P_FLOAT (1L << 3)
51 #define P_SMALL (1L << 4)
52 #define P_MEDIUM (1L << 5)
53 #define P_BIG (1L << 6)
54 #define P_SCALEDOWN (1L << 7)
56 #define P_SIZE (P_SMALL | P_MEDIUM | P_BIG)
57 /* the following is an index in stat_dev::hist[] array */
58 #define P_HIST (P_SMOOTH | P_LOG)
60 #define F_SINGLE_LINE 1 /* regex flag */
61 #define F_DEBUG 2
62 #define F_USED 4
64 typedef struct {
65 double data[HIST_SIZE];
66 double max;
67 unsigned count;
68 } history;
70 typedef struct {
71 char name[NAME_LEN+1]; /* cpu, mem, swap, i/o, etc. */
72 double scale;
73 double min,max; /* range for the bar/graph */
74 unsigned flags; /* F_xxx from above */
75 char *action;
76 char *source;
78 regex_t regex;
79 Expr *expr;
80 double *diff_old, *diff_new, *sum_acc;
81 unsigned nsum; /* number of elements in sum_acc */
83 double value[P_SMOOTH+1]; /* "real-time" stat */
84 double *smooth; /* 0 if unused */
85 history *hist[P_HIST+1]; /* 0 if unused */
87 unsigned update_interval;
88 unsigned next_update;
89 unsigned hist_update_interval;
90 unsigned hist_next_update;
91 } stat_dev;
93 void stat_dev_init(stat_dev * st);
94 void stat_dev_initstat(stat_dev * st);
95 void stat_dev_update_history (stat_dev * st);
96 void update_stat(stat_dev *);
99 * END
101 #endif