mirror of
https://github.com/labwc/labwc.git
synced 2025-11-02 09:01:47 -05:00
common/parse-bool.c: make parse_bool() generic
...to avoid multiple versions of a boolean-parser. - Optionally take a default value - Return -1 on error - Rename get-bool.c to parse-bool.c
This commit is contained in:
parent
473f0aacbd
commit
fa50149525
7 changed files with 144 additions and 64 deletions
|
|
@ -1,15 +0,0 @@
|
|||
/* SPDX-License-Identifier: GPL-2.0-only */
|
||||
#ifndef __LABWC_GET_BOOL_H
|
||||
#define __LABWC_GET_BOOL_H
|
||||
#include <stdbool.h>
|
||||
|
||||
/**
|
||||
* get_bool - interpret string and return boolean
|
||||
* @s: string to interpret
|
||||
*
|
||||
* Note: This merely performs a case-insensitive check for 'yes' and 'true'.
|
||||
* Returns false by default.
|
||||
*/
|
||||
bool get_bool(const char *s);
|
||||
|
||||
#endif /* __LABWC_GET_BOOL_H */
|
||||
16
include/common/parse-bool.h
Normal file
16
include/common/parse-bool.h
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
/* SPDX-License-Identifier: GPL-2.0-only */
|
||||
#ifndef __LABWC_PARSE_BOOL_H
|
||||
#define __LABWC_PARSE_BOOL_H
|
||||
#include <stdbool.h>
|
||||
|
||||
/**
|
||||
* 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);
|
||||
|
||||
#endif /* __LABWC_PARSE_BOOL_H */
|
||||
Loading…
Add table
Add a link
Reference in a new issue