Build fixes for bmpx
[monky] / src / solaris.c
1 /* -*- mode: c; c-basic-offset: 4; tab-width: 4; indent-tabs-mode: t -*-
2  * vim: ts=4 sw=4 noet ai cindent syntax=c
3  *
4  * Conky, a system monitor, based on torsmo
5  *
6  * Any original torsmo code is licensed under the BSD license
7  *
8  * All code written since the fork of torsmo is licensed under the GPL
9  *
10  * Please see COPYING for details
11  *
12  * Copyright (c) 2005-2010 Brenden Matthews, Philip Kovacs, et. al.
13  *      (see AUTHORS)
14  * All rights reserved.
15  *
16  * This program is free software: you can redistribute it and/or modify
17  * it under the terms of the GNU General Public License as published by
18  * the Free Software Foundation, either version 3 of the License, or
19  * (at your option) any later version.
20  *
21  * This program is distributed in the hope that it will be useful,
22  * but WITHOUT ANY WARRANTY; without even the implied warranty of
23  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
24  * GNU General Public License for more details.
25  * You should have received a copy of the GNU General Public License
26  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
27  *
28  */
29
30 /* doesn't work, feel free to finish this */
31 #include "conky.h"
32 #include "common.h"
33 #include <kstat.h>
34
35 static kstat_ctl_t *kstat;
36 static int kstat_updated;
37
38 static void update_kstat()
39 {
40         if (kstat == NULL) {
41                 kstat = kstat_open();
42                 if (kstat == NULL) {
43                         NORM_ERR("can't open kstat: %s", strerror(errno));
44                 }
45         }
46
47         if (kstat_chain_update(kstat) == -1) {
48                 perror("kstat_chain_update");
49                 return;
50         }
51 }
52
53 void prepare_update()
54 {
55         kstat_updated = 0;
56 }
57
58 double get_uptime()
59 {
60         kstat_t *ksp;
61
62         update_kstat();
63
64         ksp = kstat_lookup(kstat, "unix", -1, "system_misc");
65         if (ksp != NULL) {
66                 if (kstat_read(kstat, ksp, NULL) >= 0) {
67                         kstat_named_t *knp;
68
69                         knp = (kstat_named_t *) kstat_data_lookup(ksp, "boot_time");
70                         if (knp != NULL) {
71                                 return get_time() - (double) knp->value.ui32;
72                         }
73                 }
74         }
75 }
76
77 void update_meminfo()
78 {
79         /* TODO */
80 }
81
82 int check_mount(char *s)
83 {
84         /* stub */
85         return 0;
86 }