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