here comes the big header include rewrite
[monky] / src / common.h
1 #ifndef _COMMON_H
2 #define _COMMON_H
3
4 #include <stdio.h>
5 #include <sys/socket.h>
6
7 int check_mount(char *s);
8 void update_diskio(void);
9 void prepare_update(void);
10 void update_uptime(void);
11 void update_meminfo(void);
12 void update_net_stats(void);
13 void update_cpu_usage(void);
14 void update_total_processes(void);
15 void update_uname(void);
16 void update_running_processes(void);
17 void update_i8k(void);
18 void update_stuff(void);
19 char get_freq(char *, size_t, const char *, int, unsigned int);
20 void get_freq_dynamic(char *, size_t, const char *, int);
21 char get_voltage(char *, size_t, const char *, int, unsigned int);      /* ptarjan */
22 void update_load_average(void);
23 void update_top(void);
24 void free_all_processes(void);
25 struct process *get_first_process(void);
26 void get_cpu_count(void);
27 double get_time(void);
28
29 FILE *open_file(const char *, int *);
30 void variable_substitute(const char *s, char *dest, unsigned int n);
31
32 void format_seconds(char *buf, unsigned int n, long t);
33 void format_seconds_short(char *buf, unsigned int n, long t);
34
35 #ifdef X11
36 void update_x11info(void);
37 #endif
38
39 int round_to_int(float);
40
41 extern unsigned long long need_mask;
42 extern int no_buffers;
43
44 struct dns_data {
45         int nscount;
46         char **ns_list;
47 };
48 void free_dns_data(void);
49
50 struct net_stat {
51         const char *dev;
52         int up;
53         long long last_read_recv, last_read_trans;
54         long long recv, trans;
55         double recv_speed, trans_speed;
56         struct sockaddr addr;
57         char* addrs;
58         double net_rec[15], net_trans[15];
59         // wireless extensions
60         char essid[32];
61         char bitrate[16];
62         char mode[16];
63         int link_qual;
64         int link_qual_max;
65         char ap[18];
66 };
67 void clear_net_stats(void);
68 struct net_stat *get_net_stat(const char *);
69
70 int open_sysfs_sensor(const char *dir, const char *dev, const char *type, int n,
71         int *divisor, char *devtype);
72
73 #define open_i2c_sensor(dev, type, n, divisor, devtype) \
74         open_sysfs_sensor("/sys/bus/i2c/devices/", dev, type, n, divisor, devtype)
75 #define open_platform_sensor(dev, type, n, divisor, devtype) \
76         open_sysfs_sensor("/sys/bus/platform/devices/", dev, type, n, divisor, devtype)
77 #define open_hwmon_sensor(dev, type, n, divisor, devtype) \
78         open_sysfs_sensor("/sys/class/hwmon/", dev, type, n, divisor, devtype)
79
80 double get_sysfs_info(int *fd, int arg, char *devtype, char *type);
81
82 void get_adt746x_cpu(char *, size_t);
83 void get_adt746x_fan(char *, size_t);
84 unsigned int get_diskio(void);
85
86 int open_acpi_temperature(const char *name);
87 double get_acpi_temperature(int fd);
88 void get_acpi_ac_adapter(char *, size_t);
89 void get_acpi_fan(char *, size_t);
90 void get_battery_stuff(char *buf, unsigned int n, const char *bat, int item);
91 int get_battery_perct(const char *bat);
92 int get_battery_perct_bar(const char *bat);
93
94 #endif /* _COMMON_H */