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