Allow ~/... and $HOME/... paths for more stuff.
[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 /* Converts '~/...' paths to '/home/blah/...' assumes that 'dest' is at least
31  * DEFAULT_TEXT_BUFFER_SIZE.  It's similar to variable_substitute, except only
32  * cheques for $HOME and ~/ in path */
33 void to_real_path(char *dest, const char *source);
34 FILE *open_file(const char *, int *);
35 void variable_substitute(const char *s, char *dest, unsigned int n);
36
37 void format_seconds(char *buf, unsigned int n, long t);
38 void format_seconds_short(char *buf, unsigned int n, long t);
39
40 #ifdef X11
41 void update_x11info(void);
42 #endif
43
44 int round_to_int_temp(float);
45
46 unsigned int round_to_int(float);
47
48 extern unsigned long long need_mask;
49 extern int no_buffers;
50
51 struct dns_data {
52         int nscount;
53         char **ns_list;
54 };
55 void free_dns_data(void);
56
57 struct net_stat {
58         const char *dev;
59         int up;
60         long long last_read_recv, last_read_trans;
61         long long recv, trans;
62         double recv_speed, trans_speed;
63         struct sockaddr addr;
64 #if defined(__linux__)
65         char addrs[273];
66 #endif /* __linux__ */
67         double net_rec[15], net_trans[15];
68         // wireless extensions
69         char essid[32];
70         char bitrate[16];
71         char mode[16];
72         int link_qual;
73         int link_qual_max;
74         char ap[18];
75 };
76 void clear_net_stats(void);
77 struct net_stat *get_net_stat(const char *);
78 int interface_up(const char *dev);
79
80 void get_adt746x_cpu(char *, size_t);
81 void get_adt746x_fan(char *, size_t);
82
83 int open_acpi_temperature(const char *name);
84 double get_acpi_temperature(int fd);
85 void get_acpi_ac_adapter(char *, size_t);
86 void get_acpi_fan(char *, size_t);
87 void get_battery_stuff(char *buf, unsigned int n, const char *bat, int item);
88 int get_battery_perct(const char *bat);
89 int get_battery_perct_bar(const char *bat);
90 void get_battery_short_status(char *buf, unsigned int n, const char *bat);
91
92 #endif /* _COMMON_H */