1*4d6d5f5aSEd Maste /*-
2*4d6d5f5aSEd Maste * SPDX-License-Identifier: BSD-2-Clause
3*4d6d5f5aSEd Maste *
4*4d6d5f5aSEd Maste * Copyright (c) 2023 Jean-Sébastien Pédron <dumbbell@FreeBSD.org>
5*4d6d5f5aSEd Maste *
6*4d6d5f5aSEd Maste * Redistribution and use in source and binary forms, with or without
7*4d6d5f5aSEd Maste * modification, are permitted provided that the following conditions
8*4d6d5f5aSEd Maste * are met:
9*4d6d5f5aSEd Maste * 1. Redistributions of source code must retain the above copyright
10*4d6d5f5aSEd Maste * notice unmodified, this list of conditions, and the following
11*4d6d5f5aSEd Maste * disclaimer.
12*4d6d5f5aSEd Maste * 2. Redistributions in binary form must reproduce the above copyright
13*4d6d5f5aSEd Maste * notice, this list of conditions and the following disclaimer in the
14*4d6d5f5aSEd Maste * documentation and/or other materials provided with the distribution.
15*4d6d5f5aSEd Maste *
16*4d6d5f5aSEd Maste * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
17*4d6d5f5aSEd Maste * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
18*4d6d5f5aSEd Maste * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
19*4d6d5f5aSEd Maste * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
20*4d6d5f5aSEd Maste * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
21*4d6d5f5aSEd Maste * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
22*4d6d5f5aSEd Maste * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
23*4d6d5f5aSEd Maste * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24*4d6d5f5aSEd Maste * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
25*4d6d5f5aSEd Maste * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26*4d6d5f5aSEd Maste */
27*4d6d5f5aSEd Maste
28*4d6d5f5aSEd Maste #ifndef _LINUXKPI_LINUX_STRING_CHOICES_H_
29*4d6d5f5aSEd Maste #define _LINUXKPI_LINUX_STRING_CHOICES_H_
30*4d6d5f5aSEd Maste
31*4d6d5f5aSEd Maste #include <sys/types.h>
32*4d6d5f5aSEd Maste
33*4d6d5f5aSEd Maste static inline const char *
str_yes_no(bool value)34*4d6d5f5aSEd Maste str_yes_no(bool value)
35*4d6d5f5aSEd Maste {
36*4d6d5f5aSEd Maste if (value)
37*4d6d5f5aSEd Maste return "yes";
38*4d6d5f5aSEd Maste else
39*4d6d5f5aSEd Maste return "no";
40*4d6d5f5aSEd Maste }
41*4d6d5f5aSEd Maste
42*4d6d5f5aSEd Maste static inline const char *
str_on_off(bool value)43*4d6d5f5aSEd Maste str_on_off(bool value)
44*4d6d5f5aSEd Maste {
45*4d6d5f5aSEd Maste if (value)
46*4d6d5f5aSEd Maste return "on";
47*4d6d5f5aSEd Maste else
48*4d6d5f5aSEd Maste return "off";
49*4d6d5f5aSEd Maste }
50*4d6d5f5aSEd Maste
51*4d6d5f5aSEd Maste static inline const char *
str_enabled_disabled(bool value)52*4d6d5f5aSEd Maste str_enabled_disabled(bool value)
53*4d6d5f5aSEd Maste {
54*4d6d5f5aSEd Maste if (value)
55*4d6d5f5aSEd Maste return "enabled";
56*4d6d5f5aSEd Maste else
57*4d6d5f5aSEd Maste return "disabled";
58*4d6d5f5aSEd Maste }
59*4d6d5f5aSEd Maste
60*4d6d5f5aSEd Maste static inline const char *
str_enable_disable(bool value)61*4d6d5f5aSEd Maste str_enable_disable(bool value)
62*4d6d5f5aSEd Maste {
63*4d6d5f5aSEd Maste if (value)
64*4d6d5f5aSEd Maste return "enable";
65*4d6d5f5aSEd Maste else
66*4d6d5f5aSEd Maste return "disable";
67*4d6d5f5aSEd Maste }
68*4d6d5f5aSEd Maste
69*4d6d5f5aSEd Maste #define str_disable_enable(_v) str_enable_disable(!(_v))
70*4d6d5f5aSEd Maste
71*4d6d5f5aSEd Maste #endif
72