]> git.webhop.me Git - lcd4linux.git/commitdiff
Ticket 182
authorvolker <volker@3ae390bd-cb1e-0410-b409-cd5a39f66f1f>
Fri, 15 Jan 2010 21:44:04 +0000 (21:44 +0000)
committervolker <volker@3ae390bd-cb1e-0410-b409-cd5a39f66f1f>
Fri, 15 Jan 2010 21:44:04 +0000 (21:44 +0000)
git-svn-id: https://ssl.bulix.org/svn/lcd4linux/trunk@1079 3ae390bd-cb1e-0410-b409-cd5a39f66f1f

plugin_cpuinfo.c
plugin_netinfo.c
plugin_proc_stat.c

index 8c87573bf1af77980b0f213591766858e545a013..0669c7cef51499bd8d744d726637eece3afc990d 100644 (file)
@@ -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
index 57c79b267014d71ddd9bfe4a44ab73312d7eb0ba..08eaee9be2a56c16544c49ef318c4f24e2a7f447 100644 (file)
@@ -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);
index a8c91cebd76959392fc638f34726e085bf58a554..e5fc3c44c6bdb8f30768586931a694657e4aae05 100644 (file)
@@ -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);