da91d60f752dce3bf747bc38cd4c11b8cc9a27ba
[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 "structs.h"
7
8 #include <stdio.h>
9 #include <stdlib.h>
10 #include <string.h>
11 #include <sys/socket.h>
12
13 void strfold(char *start, int count);
14 int check_mount(char *s);
15 void prepare_update(void);
16 void update_uptime(void);
17 void update_meminfo(void);
18 void update_net_stats(void);
19 void update_cpu_usage(void);
20 void update_total_processes(void);
21 void update_uname(conky_context *ctx);
22 void update_running_processes(void);
23 void update_i8k(void);
24 void update_stuff(conky_context *ctx);
25 char get_freq(char *, size_t, const char *, int, unsigned int);
26 void get_freq_dynamic(char *, size_t, const char *, int);
27 char get_voltage(char *, size_t, const char *, int, unsigned int);      /* ptarjan */
28 void update_load_average(void);
29 void update_top(void);
30 void free_all_processes(void);
31 struct process *get_first_process(void);
32 void get_cpu_count(void);
33 double get_time(void);
34
35 /* Converts '~/...' paths to '/home/blah/...' assumes that 'dest' is at least
36  * DEFAULT_TEXT_BUFFER_SIZE.  It's similar to variable_substitute, except only
37  * cheques for $HOME and ~/ in path */
38 void to_real_path(char *dest, const char *source);
39 FILE *open_file(const char *file, int *reported);
40 int open_fifo(const char *file, int *reported);
41 void variable_substitute(const char *s, char *dest, unsigned int n);
42
43 void format_seconds(char *buf, unsigned int n, long t);
44 void format_seconds_short(char *buf, unsigned int n, long t);
45
46 #ifdef X11
47 void update_x11info(void);
48 #endif
49
50 int round_to_int_temp(float);
51
52 unsigned int round_to_int(float);
53
54 extern unsigned long long need_mask;
55 extern int no_buffers;
56
57 void free_dns_data(conky_context *ctx);
58
59 struct net_stat {
60         char *dev;
61         int up;
62         long long last_read_recv, last_read_trans;
63         long long recv, trans;
64         double recv_speed, trans_speed;
65         struct sockaddr addr;
66 #if defined(__linux__)
67         char addrs[273];
68 #endif /* __linux__ */
69         double net_rec[15], net_trans[15];
70         // wireless extensions
71         char essid[32];
72         char bitrate[16];
73         char mode[16];
74         int link_qual;
75         int link_qual_max;
76         char ap[18];
77 };
78 void clear_net_stats(void);
79 void clear_cpu_stats(void);
80 struct net_stat *get_net_stat(const char *dev, void *free_at_crash1, void *free_at_crash2);
81 int interface_up(const char *dev);
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 */