31 |
|
#ifdef LINUX |
32 |
|
#include <stdio.h> |
33 |
|
#endif |
34 |
+ |
#ifdef FREEBSD |
35 |
+ |
#include <sys/types.h> |
36 |
+ |
#include <sys/sysctl.h> |
37 |
+ |
#include <time.h> |
38 |
+ |
#include <sys/time.h> |
39 |
+ |
#endif |
40 |
|
|
41 |
|
general_stat_t *get_general_stats(){ |
42 |
|
|
52 |
|
#ifdef LINUX |
53 |
|
FILE *f; |
54 |
|
#endif |
55 |
+ |
#ifdef FREEBSD |
56 |
+ |
struct timeval boottime; |
57 |
+ |
time_t curtime; |
58 |
+ |
size_t size; |
59 |
+ |
#endif |
60 |
|
|
61 |
|
if((uname(&os)) < 0){ |
62 |
|
return NULL; |
97 |
|
return NULL; |
98 |
|
} |
99 |
|
fclose(f); |
100 |
+ |
#endif |
101 |
+ |
#ifdef FREEBSD |
102 |
+ |
if (sysctlbyname("kern.boottime", NULL, &size, NULL, NULL) < 0){ |
103 |
+ |
return NULL; |
104 |
+ |
} |
105 |
+ |
if (sysctlbyname("kern.boottime", &boottime, &size, NULL, NULL) < 0){ |
106 |
+ |
return NULL; |
107 |
+ |
} |
108 |
+ |
time(&curtime); |
109 |
+ |
general_stat.uptime=curtime-boottime.tv_sec; |
110 |
|
#endif |
111 |
|
|
112 |
|
return &general_stat; |