mirror of
https://github.com/Llewellynvdm/conky.git
synced 2024-12-28 13:00:45 +00:00
Compile under FreeBSD
This allows compilation under FreeBSD without errors. read_tcpip.cc: Avoid using of SOCK_NONBLOCK argument for socket(). SOCK_NONBLOCK is Linux-specific and its use was substituted with a fcntl() call after socket(). freebsd.cc: Change return type of update_*() to int, as required by common.h. Signed-off-by: Alexander Graf <agraf@znc.in> Signed-off-by: Pavel Labath <pavelo@centrum.sk>
This commit is contained in:
parent
7a61fe8504
commit
696d841e97
@ -121,7 +121,7 @@ void prepare_update(void)
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
void update_uptime(void)
|
int update_uptime(void)
|
||||||
{
|
{
|
||||||
int mib[2] = { CTL_KERN, KERN_BOOTTIME };
|
int mib[2] = { CTL_KERN, KERN_BOOTTIME };
|
||||||
struct timeval boottime;
|
struct timeval boottime;
|
||||||
@ -136,6 +136,8 @@ void update_uptime(void)
|
|||||||
fprintf(stderr, "Could not get uptime\n");
|
fprintf(stderr, "Could not get uptime\n");
|
||||||
info.uptime = 0;
|
info.uptime = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int check_mount(struct text_object *obj)
|
int check_mount(struct text_object *obj)
|
||||||
@ -156,7 +158,7 @@ int check_mount(struct text_object *obj)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void update_meminfo(void)
|
int update_meminfo(void)
|
||||||
{
|
{
|
||||||
u_int total_pages, inactive_pages, free_pages;
|
u_int total_pages, inactive_pages, free_pages;
|
||||||
unsigned long swap_avail, swap_free;
|
unsigned long swap_avail, swap_free;
|
||||||
@ -189,9 +191,11 @@ void update_meminfo(void)
|
|||||||
info.swap = 0;
|
info.swap = 0;
|
||||||
info.swapfree = 0;
|
info.swapfree = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void update_net_stats(void)
|
int update_net_stats(void)
|
||||||
{
|
{
|
||||||
struct net_stat *ns;
|
struct net_stat *ns;
|
||||||
double delta;
|
double delta;
|
||||||
@ -202,11 +206,11 @@ void update_net_stats(void)
|
|||||||
/* get delta */
|
/* get delta */
|
||||||
delta = current_update_time - last_update_time;
|
delta = current_update_time - last_update_time;
|
||||||
if (delta <= 0.0001) {
|
if (delta <= 0.0001) {
|
||||||
return;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (getifaddrs(&ifap) < 0) {
|
if (getifaddrs(&ifap) < 0) {
|
||||||
return;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (ifa = ifap; ifa; ifa = ifa->ifa_next) {
|
for (ifa = ifap; ifa; ifa = ifa->ifa_next) {
|
||||||
@ -262,18 +266,20 @@ void update_net_stats(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
freeifaddrs(ifap);
|
freeifaddrs(ifap);
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void update_total_processes(void)
|
int update_total_processes(void)
|
||||||
{
|
{
|
||||||
int n_processes;
|
int n_processes;
|
||||||
|
|
||||||
kvm_getprocs(kd, KERN_PROC_ALL, 0, &n_processes);
|
kvm_getprocs(kd, KERN_PROC_ALL, 0, &n_processes);
|
||||||
|
|
||||||
info.procs = n_processes;
|
info.procs = n_processes;
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void update_running_processes(void)
|
int update_running_processes(void)
|
||||||
{
|
{
|
||||||
struct kinfo_proc *p;
|
struct kinfo_proc *p;
|
||||||
int n_processes;
|
int n_processes;
|
||||||
@ -291,6 +297,7 @@ void update_running_processes(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
info.run_procs = cnt;
|
info.run_procs = cnt;
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void get_cpu_count(void)
|
void get_cpu_count(void)
|
||||||
@ -316,7 +323,7 @@ struct cpu_info {
|
|||||||
long oldused;
|
long oldused;
|
||||||
};
|
};
|
||||||
|
|
||||||
void update_cpu_usage(void)
|
int update_cpu_usage(void)
|
||||||
{
|
{
|
||||||
int i, j = 0;
|
int i, j = 0;
|
||||||
long used, total;
|
long used, total;
|
||||||
@ -394,9 +401,10 @@ void update_cpu_usage(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
free(cp_time);
|
free(cp_time);
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void update_load_average(void)
|
int update_load_average(void)
|
||||||
{
|
{
|
||||||
double v[3];
|
double v[3];
|
||||||
|
|
||||||
@ -405,6 +413,8 @@ void update_load_average(void)
|
|||||||
info.loadavg[0] = (double) v[0];
|
info.loadavg[0] = (double) v[0];
|
||||||
info.loadavg[1] = (double) v[1];
|
info.loadavg[1] = (double) v[1];
|
||||||
info.loadavg[2] = (double) v[2];
|
info.loadavg[2] = (double) v[2];
|
||||||
|
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
double get_acpi_temperature(int fd)
|
double get_acpi_temperature(int fd)
|
||||||
@ -585,9 +595,10 @@ char get_freq(char *p_client_buffer, size_t client_buffer_size, const char *p_fo
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
void update_top(void)
|
int update_top(void)
|
||||||
{
|
{
|
||||||
proc_find_top(info.cpu, info.memu);
|
proc_find_top(info.cpu, info.memu);
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if 0
|
#if 0
|
||||||
@ -645,7 +656,7 @@ cleanup:
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
void update_diskio(void)
|
int update_diskio(void)
|
||||||
{
|
{
|
||||||
int devs_count, num_selected, num_selections, dn;
|
int devs_count, num_selected, num_selections, dn;
|
||||||
struct device_selection *dev_select = NULL;
|
struct device_selection *dev_select = NULL;
|
||||||
@ -663,7 +674,7 @@ void update_diskio(void)
|
|||||||
|
|
||||||
if (devstat_getdevs(NULL, &statinfo_cur) < 0) {
|
if (devstat_getdevs(NULL, &statinfo_cur) < 0) {
|
||||||
free(statinfo_cur.dinfo);
|
free(statinfo_cur.dinfo);
|
||||||
return;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
devs_count = statinfo_cur.dinfo->numdevs;
|
devs_count = statinfo_cur.dinfo->numdevs;
|
||||||
@ -695,6 +706,7 @@ void update_diskio(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
free(statinfo_cur.dinfo);
|
free(statinfo_cur.dinfo);
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* While topless is obviously better, top is also not bad. */
|
/* While topless is obviously better, top is also not bad. */
|
||||||
|
@ -35,6 +35,8 @@
|
|||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
#include <errno.h>
|
||||||
|
#include <fcntl.h>
|
||||||
#include <netinet/in.h>
|
#include <netinet/in.h>
|
||||||
#include <sys/time.h>
|
#include <sys/time.h>
|
||||||
#include <cinttypes>
|
#include <cinttypes>
|
||||||
@ -104,11 +106,13 @@ void print_tcp_ping(struct text_object *obj, char *p, int p_max_size)
|
|||||||
struct timeval tv1, tv2, timeout;
|
struct timeval tv1, tv2, timeout;
|
||||||
struct sockaddr_in *addr = (struct sockaddr_in *) obj->data.opaque;
|
struct sockaddr_in *addr = (struct sockaddr_in *) obj->data.opaque;
|
||||||
int addrlen = sizeof(struct sockaddr);
|
int addrlen = sizeof(struct sockaddr);
|
||||||
int sock = socket(addr->sin_family, SOCK_STREAM | SOCK_NONBLOCK, IPPROTO_TCP);
|
int sock = socket(addr->sin_family, SOCK_STREAM, IPPROTO_TCP);
|
||||||
unsigned long long usecdiff;
|
unsigned long long usecdiff;
|
||||||
fd_set writefds;
|
fd_set writefds;
|
||||||
|
|
||||||
if(sock != -1) {
|
if(sock != -1) {
|
||||||
|
fcntl(sock, F_SETFL, O_NONBLOCK | fcntl(sock, F_GETFL));
|
||||||
|
|
||||||
FD_ZERO(&writefds);
|
FD_ZERO(&writefds);
|
||||||
FD_SET(sock, &writefds);
|
FD_SET(sock, &writefds);
|
||||||
#define TCP_PING_TIMEOUT 10
|
#define TCP_PING_TIMEOUT 10
|
||||||
|
Loading…
Reference in New Issue
Block a user