554cbe78ff7f19265200c48343c4b672689bd338
[monky] / src / common.h
1 /* -*- mode: c; c-basic-offset: 4; tab-width: 4; indent-tabs-mode: t -*- */
2
3 #ifndef _COMMON_H
4 #define _COMMON_H
5
6 #include <stdio.h>
7 #include <stdlib.h>
8 #include <string.h>
9 #include <sys/socket.h>
10
11 void add_update_callback(void (*func)(void));
12 void free_update_callbacks(void);
13
14 void strfold(char *start, int count);
15 int check_mount(char *s);
16 void prepare_update(void);
17 void update_dns_data(void);
18 void update_uptime(void);
19 void update_meminfo(void);
20 void update_net_stats(void);
21 void update_cpu_usage(void);
22 void update_total_processes(void);
23 void update_uname(void);
24 void update_running_processes(void);
25 void update_i8k(void);
26 void update_stuff(void);
27 char get_freq(char *, size_t, const char *, int, unsigned int);
28 void get_freq_dynamic(char *, size_t, const char *, int);
29 char get_voltage(char *, size_t, const char *, int, unsigned int);      /* ptarjan */
30 void update_load_average(void);
31 void update_top(void);
32 void free_all_processes(void);
33 struct process *get_first_process(void);
34 void get_cpu_count(void);
35 double get_time(void);
36
37 /* Converts '~/...' paths to '/home/blah/...' assumes that 'dest' is at least
38  * DEFAULT_TEXT_BUFFER_SIZE.  It's similar to variable_substitute, except only
39  * cheques for $HOME and ~/ in path */
40 void to_real_path(char *dest, const char *source);
41 FILE *open_file(const char *file, int *reported);
42 int open_fifo(const char *file, int *reported);
43 void variable_substitute(const char *s, char *dest, unsigned int n);
44
45 void format_seconds(char *buf, unsigned int n, long t);
46 void format_seconds_short(char *buf, unsigned int n, long t);
47
48 #ifdef X11
49 void update_x11info(void);
50 #endif
51
52 int round_to_int_temp(float);
53
54 unsigned int round_to_int(float);
55
56 extern unsigned long long need_mask;
57 extern int no_buffers;
58
59 struct dns_data {
60         int nscount;
61         char **ns_list;
62 };
63 void free_dns_data(void);
64
65 struct net_stat {
66         char *dev;
67         int up;
68         long long last_read_recv, last_read_trans;
69         long long recv, trans;
70         double recv_speed, trans_speed;
71         struct sockaddr addr;
72 #if defined(__linux__)
73         char addrs[273];
74 #endif /* __linux__ */
75         double net_rec[15], net_trans[15];
76         // wireless extensions
77         char essid[32];
78         char bitrate[16];
79         char mode[16];
80         int link_qual;
81         int link_qual_max;
82         char ap[18];
83 };
84 void clear_net_stats(void);
85 struct net_stat *get_net_stat(const char *dev, void *free_at_crash1, void *free_at_crash2);
86 int interface_up(const char *dev);
87
88 void get_adt746x_cpu(char *, size_t);
89 void get_adt746x_fan(char *, size_t);
90
91 int open_acpi_temperature(const char *name);
92 double get_acpi_temperature(int fd);
93 void get_acpi_ac_adapter(char *, size_t);
94 void get_acpi_fan(char *, size_t);
95 void get_battery_stuff(char *buf, unsigned int n, const char *bat, int item);
96 int get_battery_perct(const char *bat);
97 int get_battery_perct_bar(const char *bat);
98 void get_battery_short_status(char *buf, unsigned int n, const char *bat);
99
100 #endif /* _COMMON_H */