clarifying licensing
[monky] / src / solaris.c
1 /*
2  * Conky, a system monitor, based on torsmo
3  *
4  * Any original torsmo code is licensed under the BSD license
5  *
6  * All code written since the fork of torsmo is licensed under the GPL
7  *
8  * Please see COPYING for details
9  *
10  * Copyright (c) 2005-2007 Brenden Matthews, Philip Kovacs, et. al. (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  *  $Id$
26  */
27
28 /* doesn't work, feel free to finish this */
29 #include "conky.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                         knp =
66                             (kstat_named_t *) kstat_data_lookup(ksp,
67                                                                 "boot_time");
68                         if (knp != NULL) {
69                                 return get_time() -
70                                     (double) knp->value.ui32;
71                         }
72                 }
73         }
74 }
75
76 void update_meminfo()
77 {
78         /* TODO */
79 }
80
81 int check_mount(char *s)
82 {
83         /* stub */
84         return 0;
85 }