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