rewrite linux diskio code
[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(float);
41
42 extern unsigned long long need_mask;
43 extern int no_buffers;
44
45 struct dns_data {
46         int nscount;
47         char **ns_list;
48 };
49 void free_dns_data(void);
50
51 struct net_stat {
52         const char *dev;
53         int up;
54         long long last_read_recv, last_read_trans;
55         long long recv, trans;
56         double recv_speed, trans_speed;
57         struct sockaddr addr;
58         char* addrs;
59         double net_rec[15], net_trans[15];
60         // wireless extensions
61         char essid[32];
62         char bitrate[16];
63         char mode[16];
64         int link_qual;
65         int link_qual_max;
66         char ap[18];
67 };
68 void clear_net_stats(void);
69 struct net_stat *get_net_stat(const char *);
70
71 int open_sysfs_sensor(const char *dir, const char *dev, const char *type, int n,
72         int *divisor, char *devtype);
73
74 #define open_i2c_sensor(dev, type, n, divisor, devtype) \
75         open_sysfs_sensor("/sys/bus/i2c/devices/", dev, type, n, divisor, devtype)
76 #define open_platform_sensor(dev, type, n, divisor, devtype) \
77         open_sysfs_sensor("/sys/bus/platform/devices/", dev, type, n, divisor, devtype)
78 #define open_hwmon_sensor(dev, type, n, divisor, devtype) \
79         open_sysfs_sensor("/sys/class/hwmon/", dev, type, n, divisor, devtype)
80
81 double get_sysfs_info(int *fd, int arg, char *devtype, char *type);
82
83 void get_adt746x_cpu(char *, size_t);
84 void get_adt746x_fan(char *, size_t);
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 void get_battery_short_status(char *buf, unsigned int n, const char *bat);
94
95 #endif /* _COMMON_H */