aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorvolker <volker@3ae390bd-cb1e-0410-b409-cd5a39f66f1f>2010-01-15 21:44:04 +0000
committervolker <volker@3ae390bd-cb1e-0410-b409-cd5a39f66f1f>2010-01-15 21:44:04 +0000
commit69fecdd3d64aac4d19a2fa5777ea2b6c017fe9cf (patch)
tree67eb5f0c723e5942405bae3f8a4aef62ec1c35df
parentac266e1877dfa2042a00b239ac184ce40e538770 (diff)
downloadlcd4linux-69fecdd3d64aac4d19a2fa5777ea2b6c017fe9cf.tar.gz
Ticket 182
git-svn-id: https://ssl.bulix.org/svn/lcd4linux/trunk@1079 3ae390bd-cb1e-0410-b409-cd5a39f66f1f
-rw-r--r--plugin_cpuinfo.c14
-rw-r--r--plugin_netinfo.c22
-rw-r--r--plugin_proc_stat.c16
3 files changed, 31 insertions, 21 deletions
diff --git a/plugin_cpuinfo.c b/plugin_cpuinfo.c
index 8c87573..0669c7c 100644
--- a/plugin_cpuinfo.c
+++ b/plugin_cpuinfo.c
@@ -113,18 +113,18 @@ static int parse_cpuinfo(char *oid)
size_t val_len;
if (sysctlbyname(oid, NULL, &val_len, NULL, 0) != 0) {
- error("Error %d by sysctl(%s): %s", errno, oid, strerror(errno));
- return -1;
+ error("Error %d by sysctl(%s): %s", errno, oid, strerror(errno));
+ return -1;
}
if (val_len > sizeof(val_ret)) {
- error("Error: Result of sysctl(%s) too big (%zd > %zd)!", oid, val_len, sizeof(val_ret));
- return -1;
+ error("Error: Result of sysctl(%s) too big (%zd > %zd)!", oid, val_len, sizeof(val_ret));
+ return -1;
}
sysctlbyname(oid, &val_ret, &val_len, NULL, 0);
if (val_len == sizeof(int)) {
- /* we got an integer instead of a string */
- val = (int*)val_ret;
- snprintf(val_ret, sizeof(val_ret), "%d", *val);
+ /* we got an integer instead of a string */
+ val = (int *) val_ret;
+ snprintf(val_ret, sizeof(val_ret), "%d", *val);
}
hash_put(&CPUinfo, oid, val_ret);
#endif
diff --git a/plugin_netinfo.c b/plugin_netinfo.c
index 57c79b2..08eaee9 100644
--- a/plugin_netinfo.c
+++ b/plugin_netinfo.c
@@ -143,19 +143,26 @@ static void my_hwaddr(RESULT * result, RESULT * arg1)
}
strncpy(ifreq.ifr_name, R2S(arg1), sizeof(ifreq.ifr_name));
- // if (ioctl(socknr, SIOCGIFHWADDR, &ifreq) < 0) {
- // if (ioctl(socknr, SIOCGIFMAC, &ifreq) < 0) {
+#ifndef __MAC_OS_X_VERSION_10_3
+ // Linux: get interface MAC address
+ if (ioctl(socknr, SIOCGIFHWADDR, &ifreq) < 0) {
+#else
+ // MacOS: get interface MAC address
if (ioctl(socknr, SIOCGLIFPHYADDR, &ifreq) < 0) {
- errcount++;
+#endif
+ errcount++;
if (1 == errcount % 1000) {
- error("%s: ioctl(IFHWADDR %s) failed: %s", "plugin_netinfo", ifreq.ifr_name, strerror(errno));
+ error("%s: ioctl(IF_HARDW_ADDR %s) failed: %s", "plugin_netinfo", ifreq.ifr_name, strerror(errno));
error(" (skip next 1000 errors)");
}
SetResult(&result, R_STRING, "");
return;
}
- // hw = (unsigned char *) ifreq.ifr_hwaddr.sa_data;
+#ifndef __MAC_OS_X_VERSION_10_3
+ hw = (unsigned char *) ifreq.ifr_hwaddr.sa_data;
+#else
hw = (unsigned char *) ifreq.ifr_data;
+#endif
qprintf(value, sizeof(value), "%02x:%02x:%02x:%02x:%02x:%02x",
*hw, *(hw + 1), *(hw + 2), *(hw + 3), *(hw + 4), *(hw + 5));
@@ -218,8 +225,11 @@ static void my_netmask(RESULT * result, RESULT * arg1)
SetResult(&result, R_STRING, "");
return;
}
- // sin = (struct sockaddr_in *) &ifreq.ifr_netmask;
+#ifndef __MAC_OS_X_VERSION_10_3
+ sin = (struct sockaddr_in *) &ifreq.ifr_netmask;
+#else
sin = (struct sockaddr_in *) &ifreq.ifr_data;
+#endif
qprintf(value, sizeof(value), "%s", inet_ntoa(sin->sin_addr));
SetResult(&result, R_STRING, value);
diff --git a/plugin_proc_stat.c b/plugin_proc_stat.c
index a8c91ce..e5fc3c4 100644
--- a/plugin_proc_stat.c
+++ b/plugin_proc_stat.c
@@ -89,7 +89,7 @@ static int parse_proc_stat(void)
if (age > 0 && age <= 10)
return 0;
-#if 0
+#ifndef __MAC_OS_X_VERSION_10_3
/* Linux Kernel, /proc-filesystem */
@@ -228,18 +228,18 @@ static int parse_proc_stat(void)
/* MACH Kernel, MacOS X */
- kern_return_t err;
- mach_msg_type_number_t count;
- host_info_t r_load;
- host_cpu_load_info_data_t cpu_load;
- char s_val[8];
+ kern_return_t err;
+ mach_msg_type_number_t count;
+ host_info_t r_load;
+ host_cpu_load_info_data_t cpu_load;
+ char s_val[8];
r_load = &cpu_load;
count = HOST_CPU_LOAD_INFO_COUNT;
err = host_statistics(mach_host_self(), HOST_CPU_LOAD_INFO, r_load, &count);
if (KERN_SUCCESS != err) {
- error("Error getting cpu load");
- return -1;
+ error("Error getting cpu load");
+ return -1;
}
snprintf(s_val, sizeof(s_val), "%d", cpu_load.cpu_ticks[CPU_STATE_USER]);
hash_put2("cpu", "user", s_val);