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