File: parse-bool.h

package info (click to toggle)
labwc 0.9.2-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 2,980 kB
  • sloc: ansic: 34,416; perl: 5,836; xml: 875; sh: 162; python: 131; makefile: 12
file content (35 lines) | stat: -rw-r--r-- 1,123 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
/* SPDX-License-Identifier: GPL-2.0-only */
#ifndef LABWC_PARSE_BOOL_H
#define LABWC_PARSE_BOOL_H

#include <stdbool.h>
#include "config/types.h"

/**
 * parse_tristate() - Parse boolean value of string as a three-state enum.
 * @string: String to interpret. This check is case-insensitive.
 *
 * Return: LAB_STATE_DISABLED for false; LAB_STATE_ENABLED for true;
 * LAB_STATE_UNSPECIFIED for non-boolean
 */
enum lab_tristate parse_tristate(const char *str);

/**
 * parse_bool() - Parse boolean value of string.
 * @string: String to interpret. This check is case-insensitive.
 * @default_value: Default value to use if string is not a recognised boolean.
 *                 Use -1 to avoid setting a default value.
 *
 * Return: 0 for false; 1 for true; -1 for non-boolean
 */
int parse_bool(const char *str, int default_value);

/**
 * set_bool() - Parse boolean text and set variable iff text is valid boolean
 * @string: Boolean text to interpret.
 * @variable: Variable to set.
 */
void set_bool(const char *str, bool *variable);
void set_bool_as_int(const char *str, int *variable);

#endif /* LABWC_PARSE_BOOL_H */