1 /* GKrellM
2 | Copyright (C) 1999-2019 Bill Wilson
3 |
4 | Author: Bill Wilson billw@gkrellm.net
5 | Latest versions might be found at: http://gkrellm.net
6 |
7 |
8 | GKrellM is free software: you can redistribute it and/or modify it
9 | under the terms of the GNU General Public License as published by
10 | the Free Software Foundation, either version 3 of the License, or
11 | (at your option) any later version.
12 |
13 | GKrellM is distributed in the hope that it will be useful, but WITHOUT
14 | ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
15 | or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
16 | License for more details.
17 |
18 | You should have received a copy of the GNU General Public License
19 | along with this program. If not, see http://www.gnu.org/licenses/
20 |
21 |
22 | Additional permission under GNU GPL version 3 section 7
23 |
24 | If you modify this program, or any covered work, by linking or
25 | combining it with the OpenSSL project's OpenSSL library (or a
26 | modified version of that library), containing parts covered by
27 | the terms of the OpenSSL or SSLeay licenses, you are granted
28 | additional permission to convey the resulting work.
29 | Corresponding Source for a non-source form of such a combination
30 | shall include the source code for the parts of OpenSSL used as well
31 | as that of the covered work.
32 */
33
34 #include "gkrellm.h"
35 #include "gkrellm-private.h"
36 #include "gkrellm-sysdeps.h"
37
38
39
40 #if defined(__linux__)
41 #include "sysdeps/linux.c"
42 #include "sysdeps/sensors-common.c"
43 #endif
44
45 #if defined(__APPLE__)
46 #include "sysdeps/darwin.c"
47 #include "sysdeps/bsd-common.c"
48 #endif
49
50 #if defined(__FreeBSD__)
51 #include "sysdeps/freebsd.c"
52 #include "sysdeps/bsd-common.c"
53 #include "sysdeps/sensors-common.c"
54 #endif
55
56 #if defined(__DragonFly__)
57 #include "sysdeps/dragonfly.c"
58 #include "sysdeps/bsd-common.c"
59 #include "sysdeps/sensors-common.c"
60 #endif
61
62 #if defined(__NetBSD__)
63 #include "sysdeps/netbsd.c"
64 #include "sysdeps/bsd-net-open.c"
65 #include "sysdeps/bsd-common.c"
66 #include "sysdeps/sensors-common.c"
67 #endif
68
69 #if defined(__OpenBSD__)
70 #include "sysdeps/openbsd.c"
71 #include "sysdeps/bsd-net-open.c"
72 #include "sysdeps/bsd-common.c"
73 #endif
74
75 #if defined(__solaris__)
76 #include "sysdeps/solaris.c"
77 #endif
78
79 #if defined(USE_LIBGTOP)
80 #include "sysdeps/gtop.c"
81 #endif
82
83 #if defined(WIN32)
84 #include "sysdeps/win32.c"
85 #endif
86
87 #if !defined(WIN32)
88 #include <sys/utsname.h>
89 #endif
90
91 #if !defined(SENSORS_COMMON) && !defined(WIN32)
92 static gboolean (*mbmon_check_func)();
93 #endif
94
95 gchar *
gkrellm_sys_get_host_name(void)96 gkrellm_sys_get_host_name(void)
97 {
98 static gboolean have_it;
99 static gchar buf[128];
100
101 if (!have_it && gethostname(buf, sizeof(buf)) != 0)
102 strcpy(buf, "unknown");
103 have_it = TRUE;
104 return buf;
105 }
106
107 #if !defined(WIN32)
108 gchar *
gkrellm_sys_get_system_name(void)109 gkrellm_sys_get_system_name(void)
110 {
111 static gchar *sname;
112 struct utsname utsn;
113
114 if (!sname && uname(&utsn) > -1)
115 sname = g_strdup_printf("%s %s", utsn.sysname, utsn.release);
116 if (!sname)
117 sname = g_strdup("unknown name");
118 return sname;
119 }
120 #endif
121
122 gboolean
gkrellm_sys_sensors_mbmon_port_change(gint port)123 gkrellm_sys_sensors_mbmon_port_change(gint port)
124 {
125 gboolean result = FALSE;
126 #if !defined(WIN32)
127 _GK.mbmon_port = port;
128
129 /* mbmon_check_func will be set if sysdep code has included
130 | sensors_common.c and has run gkrellm_sys_sensors_mbmon_check()
131 */
132 if (mbmon_check_func)
133 {
134 gkrellm_sensors_interface_remove(MBMON_INTERFACE);
135 result = (*mbmon_check_func)(TRUE);
136 gkrellm_sensors_model_update();
137 gkrellm_sensors_rebuild(TRUE, TRUE, TRUE);
138 }
139 #endif
140 return result;
141 }
142
143 gboolean
gkrellm_sys_sensors_mbmon_supported(void)144 gkrellm_sys_sensors_mbmon_supported(void)
145 {
146 #if !defined(WIN32)
147 return mbmon_check_func ? TRUE : FALSE;
148 #else
149 return FALSE;
150 #endif
151 }
152