1*6fb1af7bStb /* $OpenBSD: apmsubr.c,v 1.12 2021/07/08 18:54:21 tb Exp $ */
2a831c31eSmickey
3054c7b81Shvozda /*
4054c7b81Shvozda * Copyright (c) 1995,1996 John T. Kohl
5054c7b81Shvozda * All rights reserved.
6054c7b81Shvozda *
7054c7b81Shvozda * Redistribution and use in source and binary forms, with or without
8054c7b81Shvozda * modification, are permitted provided that the following conditions
9054c7b81Shvozda * are met:
10054c7b81Shvozda * 1. Redistributions of source code must retain the above copyright
11054c7b81Shvozda * notice, this list of conditions and the following disclaimer.
12054c7b81Shvozda * 2. Redistributions in binary form must reproduce the above copyright
13054c7b81Shvozda * notice, this list of conditions and the following disclaimer in the
14054c7b81Shvozda * documentation and/or other materials provided with the distribution.
15054c7b81Shvozda * 3. The name of the author may not be used to endorse or promote products
16054c7b81Shvozda * derived from this software without specific prior written permission.
17054c7b81Shvozda *
18054c7b81Shvozda * THIS SOFTWARE IS PROVIDED BY THE AUTHOR `AS IS'' AND ANY EXPRESS OR
19054c7b81Shvozda * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
20054c7b81Shvozda * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
21054c7b81Shvozda * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT,
22054c7b81Shvozda * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
23054c7b81Shvozda * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
24054c7b81Shvozda * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
25054c7b81Shvozda * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
26054c7b81Shvozda * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
27054c7b81Shvozda * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
28054c7b81Shvozda * POSSIBILITY OF SUCH DAMAGE.
29054c7b81Shvozda *
30054c7b81Shvozda */
31054c7b81Shvozda
32054c7b81Shvozda #include <sys/types.h>
33054c7b81Shvozda #include <machine/apmvar.h>
34054c7b81Shvozda #include "apm-proto.h"
35054c7b81Shvozda
36054c7b81Shvozda const char *
battstate(int state)37054c7b81Shvozda battstate(int state)
38054c7b81Shvozda {
39054c7b81Shvozda switch (state) {
40054c7b81Shvozda case APM_BATT_HIGH:
41054c7b81Shvozda return "high";
42054c7b81Shvozda case APM_BATT_LOW:
43054c7b81Shvozda return "low";
44054c7b81Shvozda case APM_BATT_CRITICAL:
45054c7b81Shvozda return "CRITICAL";
46054c7b81Shvozda case APM_BATT_CHARGING:
47054c7b81Shvozda return "charging";
48054c7b81Shvozda case APM_BATTERY_ABSENT:
49054c7b81Shvozda return "absent";
50054c7b81Shvozda case APM_BATT_UNKNOWN:
51afc54a00Ssturm return "unknown";
52054c7b81Shvozda default:
53054c7b81Shvozda return "invalid battery state";
54054c7b81Shvozda }
55054c7b81Shvozda }
56054c7b81Shvozda
57054c7b81Shvozda const char *
ac_state(int state)58054c7b81Shvozda ac_state(int state)
59054c7b81Shvozda {
60054c7b81Shvozda switch (state) {
61054c7b81Shvozda case APM_AC_OFF:
62054c7b81Shvozda return "not connected";
63054c7b81Shvozda case APM_AC_ON:
64054c7b81Shvozda return "connected";
65054c7b81Shvozda case APM_AC_BACKUP:
66054c7b81Shvozda return "backup power source";
67054c7b81Shvozda case APM_AC_UNKNOWN:
68054c7b81Shvozda return "not known";
69054c7b81Shvozda default:
70054c7b81Shvozda return "invalid AC status";
71054c7b81Shvozda }
72054c7b81Shvozda }
73f6da2e61Ssturm
74f6da2e61Ssturm const char *
perf_mode(int mode)75a99a7ef6Ssturm perf_mode(int mode)
76f6da2e61Ssturm {
77a99a7ef6Ssturm switch (mode) {
78a99a7ef6Ssturm case PERF_MANUAL:
79a99a7ef6Ssturm return "manual";
80f6da2e61Ssturm case PERF_AUTO:
81f6da2e61Ssturm return "auto";
82f6da2e61Ssturm default:
83a99a7ef6Ssturm return "invalid";
84f6da2e61Ssturm }
85f6da2e61Ssturm }
86c7cff24eSkn
87c7cff24eSkn const char *
apm_state(int apm_state)88c7cff24eSkn apm_state(int apm_state)
89c7cff24eSkn {
90c7cff24eSkn switch (apm_state) {
91c7cff24eSkn case NORMAL:
92c7cff24eSkn return "normal";
93c7cff24eSkn case SUSPENDING:
94c7cff24eSkn return "suspend";
95c7cff24eSkn case STANDING_BY:
96c7cff24eSkn return "standby";
97c7cff24eSkn case HIBERNATING:
98*6fb1af7bStb return "hibernate";
99c7cff24eSkn default:
100c7cff24eSkn return "unknown";
101c7cff24eSkn }
102c7cff24eSkn }
103