Fix buffer overflows in eve.c (sf.net #3034056)
[monky] / src / netbsd.c
index 82bcacf..d1236bb 100644 (file)
@@ -1,4 +1,7 @@
-/* Conky, a system monitor, based on torsmo
+/* -*- mode: c; c-basic-offset: 4; tab-width: 4; indent-tabs-mode: t -*-
+ * vim: ts=4 sw=4 noet ai cindent syntax=c
+ *
+ * Conky, a system monitor, based on torsmo
  *
  * Any original torsmo code is licensed under the BSD license
  *
@@ -7,7 +10,7 @@
  * Please see COPYING for details
  *
  * Copyright (c) 2004, Hannu Saransaari and Lauri Hakkarainen
- * Copyright (c) 2005-2008 Brenden Matthews, Philip Kovacs, et. al.
+ * Copyright (c) 2005-2010 Brenden Matthews, Philip Kovacs, et. al.
  *     (see AUTHORS)
  * All rights reserved.
  *
  * You should have received a copy of the GNU General Public License
  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
  *
- * $Id$ */
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <fcntl.h>
-#include <time.h>
-#include <unistd.h>
-#include <err.h>
-#include <limits.h>
-#include <paths.h>
-
-#include <kvm.h>
-#include <nlist.h>
-
-#include <sys/time.h>
-#include <sys/param.h>
-#include <sys/sysctl.h>
-#include <sys/types.h>
-#include <sys/user.h>
-#include <sys/socket.h>
-#include <sys/swap.h>
-#include <sys/sched.h>
-#include <sys/envsys.h>
-
-#include <net/if.h>
-
-#include <uvm/uvm_extern.h>
+ */
 
-#include <machine/param.h>
-
-#include "conky.h"
+#include "netbsd.h"
+#include "net_stat.h"
 
 static kvm_t *kd = NULL;
 int kd_init = 0, nkd_init = 0;
@@ -148,9 +123,6 @@ void update_meminfo()
        struct uvmexp_sysctl uvmexp;
        size_t size = sizeof(uvmexp);
 
-       info.memmax = info.mem = 0;
-       info.swapmax = info.swap = 0;
-
        if (sysctl(mib, 2, &uvmexp, &size, NULL, 0) < 0) {
                warn("could not get memory info");
                return;
@@ -162,10 +134,12 @@ void update_meminfo()
 
        info.memmax = (total_pages * pagesize) >> 10;
        info.mem = ((total_pages - free_pages - inactive_pages) * pagesize) >> 10;
+       info.memeasyfree = info.memfree = info.memmax - info.mem;
 
        if (swapmode(&swap_avail, &swap_free) >= 0) {
                info.swapmax = swap_avail;
                info.swap = (swap_avail - swap_free);
+               info.swapfree = swap_free;
        }
 }
 
@@ -216,7 +190,7 @@ void update_net_stats()
                long long last_recv, last_trans;
 
                kvm_read(nkd, (u_long) ifnetaddr, (void *) &ifnet, sizeof(ifnet));
-               ns = get_net_stat(ifnet.if_xname);
+               ns = get_net_stat(ifnet.if_xname, NULL, NULL);
                ns->up = 1;
                last_recv = ns->recv;
                last_trans = ns->trans;
@@ -333,11 +307,6 @@ void update_cpu_usage()
        oldtotal = total;
 }
 
-double get_sysfs_info(int *fd, int div, char *devtype)
-{
-       return -1;
-}
-
 void update_load_average()
 {
        double v[3];
@@ -358,19 +327,15 @@ void get_battery_stuff(char *buf, unsigned int n, const char *bat, int item)
 {
 }
 
-int open_sysfs_sensor(const char *dir, const char *dev, const char *type, int n,
-               int *div, char *devtype)
-{
-       return -1;
-}
-
 int open_acpi_temperature(const char *name)
 {
        return -1;
 }
 
-void get_acpi_ac_adapter(char *p_client_buffer, size_t client_buffer_size)
+void get_acpi_ac_adapter(char *p_client_buffer, size_t client_buffer_size, const char *adapter)
 {
+       (void) adapter; // only linux uses this
+
        if (!p_client_buffer || client_buffer_size <= 0) {
                return;
        }
@@ -390,6 +355,12 @@ void get_acpi_fan(char *p_client_buffer, size_t client_buffer_size)
        memset(p_client_buffer, 0, client_buffer_size);
 }
 
-void update_entropy(void)
+int get_entropy_avail(unsigned int *val)
 {
+       return 1;
+}
+
+int get_entropy_poolsize(unsigned int *val)
+{
+       return 1;
 }