NeoMutt  2020-11-20
Teaching an old dog new tricks
DOXYGEN
bool.h File Reference

Type representing a boolean. More...

+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

int bool_he_toggle (struct ConfigSubset *sub, struct HashElem *he, struct Buffer *err)
 Toggle the value of a bool. More...
 
int bool_str_toggle (struct ConfigSubset *sub, const char *name, struct Buffer *err)
 Toggle the value of a bool. More...
 

Variables

const char * BoolValues []
 Valid strings for creating a Bool. More...
 

Detailed Description

Type representing a boolean.

Authors
  • Richard Russon

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/.

Definition in file bool.h.

Function Documentation

◆ bool_he_toggle()

int bool_he_toggle ( struct ConfigSubset sub,
struct HashElem he,
struct Buffer err 
)

Toggle the value of a bool.

Parameters
subConfig Subset
heHashElem representing config item
errBuffer for error messages
Return values
numResult, e.g. CSR_SUCCESS

Definition at line 185 of file bool.c.

186 {
187  if (!sub || !he || !he->data)
188  return CSR_ERR_CODE;
189 
190  struct HashElem *he_base = cs_get_base(he);
191  if (DTYPE(he_base->type) != DT_BOOL)
192  return CSR_ERR_CODE;
193 
194  intptr_t value = cs_he_native_get(sub->cs, he, err);
195  if (value == INT_MIN)
196  return CSR_ERR_CODE;
197 
198  int rc = cs_he_native_set(sub->cs, he, !value, err);
199 
200  if ((CSR_RESULT(rc) == CSR_SUCCESS) && !(rc & CSR_SUC_NO_CHANGE))
202 
203  return rc;
204 }
#define CSR_SUCCESS
Action completed successfully.
Definition: set.h:35
void cs_subset_notify_observers(const struct ConfigSubset *sub, struct HashElem *he, enum NotifyConfig ev)
Notify all observers of an event.
Definition: subset.c:218
#define DTYPE(x)
Mask for the Data Type.
Definition: types.h:44
#define CSR_RESULT(x)
Definition: set.h:52
intptr_t cs_he_native_get(const struct ConfigSet *cs, struct HashElem *he, struct Buffer *err)
Natively get the value of a HashElem config item.
Definition: set.c:817
struct ConfigSet * cs
Parent ConfigSet.
Definition: subset.h:51
#define CSR_SUC_NO_CHANGE
The value hasn't changed.
Definition: set.h:44
struct HashElem * cs_get_base(struct HashElem *he)
Find the root Config Item.
Definition: set.c:199
Config item has been set.
Definition: subset.h:62
void * data
User-supplied data.
Definition: hash.h:47
int type
Type of data stored in Hash Table, e.g. DT_STRING.
Definition: hash.h:45
The item stored in a Hash Table.
Definition: hash.h:43
#define CSR_ERR_CODE
Problem with the code.
Definition: set.h:36
int cs_he_native_set(const struct ConfigSet *cs, struct HashElem *he, intptr_t value, struct Buffer *err)
Natively set the value of a HashElem config item.
Definition: set.c:706
#define DT_BOOL
boolean option
Definition: types.h:30
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ bool_str_toggle()

int bool_str_toggle ( struct ConfigSubset sub,
const char *  name,
struct Buffer err 
)

Toggle the value of a bool.

Parameters
subConfig Subset
nameName of config item
errBuffer for error messages
Return values
numResult, e.g. CSR_SUCCESS

Definition at line 213 of file bool.c.

214 {
215  struct HashElem *he = cs_subset_create_inheritance(sub, name);
216 
217  return bool_he_toggle(sub, he, err);
218 }
int bool_he_toggle(struct ConfigSubset *sub, struct HashElem *he, struct Buffer *err)
Toggle the value of a bool.
Definition: bool.c:185
struct HashElem * cs_subset_create_inheritance(const struct ConfigSubset *sub, const char *name)
Create a Subset config item (inherited)
Definition: subset.c:189
The item stored in a Hash Table.
Definition: hash.h:43
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Variable Documentation

◆ BoolValues

const char* BoolValues[]

Valid strings for creating a Bool.

These strings are case-insensitive.

Definition at line 49 of file bool.c.