NeoMutt  2019-12-07-60-g0cfa53
Teaching an old dog new tricks
DOXYGEN
quad.h File Reference

Type representing a quad-option. More...

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

Go to the source code of this file.

Enumerations

enum  QuadOption {
  MUTT_ABORT = -1, MUTT_NO, MUTT_YES, MUTT_ASKNO,
  MUTT_ASKYES
}
 Possible values for a quad-option. More...
 

Functions

void quad_init (struct ConfigSet *cs)
 Register the Quad-option config type. More...
 
int quad_he_toggle (struct ConfigSubset *sub, struct HashElem *he, struct Buffer *err)
 Toggle the value of a quad. More...
 
int quad_str_toggle (struct ConfigSubset *sub, const char *name, struct Buffer *err)
 Toggle the value of a quad. More...
 

Variables

const char * QuadValues []
 Valid strings for creating a QuadValue. More...
 

Detailed Description

Type representing a quad-option.

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 quad.h.

Enumeration Type Documentation

◆ QuadOption

enum QuadOption

Possible values for a quad-option.

Enumerator
MUTT_ABORT 

User aborted the question (with Ctrl-G)

MUTT_NO 

User answered 'No', or assume 'No'.

MUTT_YES 

User answered 'Yes', or assume 'Yes'.

MUTT_ASKNO 

Ask the user, defaulting to 'No'.

MUTT_ASKYES 

Ask the user, defaulting to 'Yes'.

Definition at line 36 of file quad.h.

37 {
38  MUTT_ABORT = -1,
39  MUTT_NO,
40  MUTT_YES,
41  MUTT_ASKNO,
42  MUTT_ASKYES,
43 };
User aborted the question (with Ctrl-G)
Definition: quad.h:38
User answered 'Yes', or assume 'Yes'.
Definition: quad.h:40
Ask the user, defaulting to 'Yes'.
Definition: quad.h:42
User answered 'No', or assume 'No'.
Definition: quad.h:39
Ask the user, defaulting to 'No'.
Definition: quad.h:41

Function Documentation

◆ quad_init()

void quad_init ( struct ConfigSet cs)

Register the Quad-option config type.

Parameters
csConfig items

Definition at line 192 of file quad.c.

193 {
194  const struct ConfigSetType cst_quad = {
195  "quad",
200  quad_reset,
201  NULL,
202  };
203  cs_register_type(cs, DT_QUAD, &cst_quad);
204 }
Type definition for a config item.
Definition: set.h:149
static int quad_string_get(const struct ConfigSet *cs, void *var, const struct ConfigDef *cdef, struct Buffer *result)
Get a Quad-option as a string - Implements cst_string_get()
Definition: quad.c:99
#define DT_QUAD
quad-option (no/yes/ask-no/ask-yes)
Definition: types.h:36
static int quad_string_set(const struct ConfigSet *cs, void *var, struct ConfigDef *cdef, const char *value, struct Buffer *err)
Set a Quad-option by string - Implements cst_string_set()
Definition: quad.c:51
static int quad_reset(const struct ConfigSet *cs, void *var, const struct ConfigDef *cdef, struct Buffer *err)
Reset a Quad-option to its initial value - Implements cst_reset()
Definition: quad.c:167
static int quad_native_set(const struct ConfigSet *cs, void *var, const struct ConfigDef *cdef, intptr_t value, struct Buffer *err)
Set a Quad-option config item by int - Implements cst_native_set()
Definition: quad.c:125
bool cs_register_type(struct ConfigSet *cs, unsigned int type, const struct ConfigSetType *cst)
Register a type of config item.
Definition: set.c:247
static intptr_t quad_native_get(const struct ConfigSet *cs, void *var, const struct ConfigDef *cdef, struct Buffer *err)
Get an int object from a Quad-option config item - Implements cst_native_get()
Definition: quad.c:155
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ quad_he_toggle()

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

Toggle the value of a quad.

Parameters
subConfig subset
heHashElem representing config item
errBuffer for error messages
Return values
numResult, e.g. CSR_SUCCESS
See also
quad_toggle()

Definition at line 228 of file quad.c.

229 {
230  if (!sub || !he || !he->data)
231  return CSR_ERR_CODE;
232 
233  struct HashElem *he_base = cs_get_base(he);
234  if (DTYPE(he_base->type) != DT_QUAD)
235  return CSR_ERR_CODE;
236 
237  intptr_t value = cs_he_native_get(sub->cs, he, err);
238  if (value == INT_MIN)
239  return CSR_ERR_CODE;
240 
241  value = quad_toggle(value);
242  int rc = cs_he_native_set(sub->cs, he, value, err);
243 
244  if ((CSR_RESULT(rc) == CSR_SUCCESS) && !(rc & CSR_SUC_NO_CHANGE))
246 
247  return rc;
248 }
static int quad_toggle(int opt)
Toggle (invert) the value of a quad option.
Definition: quad.c:214
#define CSR_RESULT(x)
Definition: set.h:53
void cs_subset_notify_observers(const struct ConfigSubset *sub, struct HashElem *he, enum NotifyConfig ev)
Notify all observers of an event.
Definition: subset.c:169
struct HashElem * cs_get_base(struct HashElem *he)
Find the root Config Item.
Definition: set.c:187
#define DT_QUAD
quad-option (no/yes/ask-no/ask-yes)
Definition: types.h:36
#define DTYPE(x)
Mask for the Data Type.
Definition: types.h:43
struct ConfigSet * cs
Parent ConfigSet.
Definition: subset.h:49
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:685
#define CSR_SUCCESS
Action completed successfully.
Definition: set.h:37
Config item has been set.
Definition: subset.h:58
void * data
Definition: hash.h:46
#define CSR_ERR_CODE
Problem with the code.
Definition: set.h:38
int type
Definition: hash.h:44
The item stored in a Hash Table.
Definition: hash.h:42
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:787
#define CSR_SUC_NO_CHANGE
The value hasn't changed.
Definition: set.h:46
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ quad_str_toggle()

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

Toggle the value of a quad.

Parameters
subConfig subset
nameHashElem representing config item
errBuffer for error messages
Return values
numResult, e.g. CSR_SUCCESS
See also
quad_toggle()

Definition at line 259 of file quad.c.

260 {
261  struct HashElem *he = cs_subset_create_inheritance(sub, name);
262 
263  return quad_he_toggle(sub, he, err);
264 }
struct HashElem * cs_subset_create_inheritance(const struct ConfigSubset *sub, const char *name)
Create a Subset config item (inherited)
Definition: subset.c:140
const char * name
Definition: pgpmicalg.c:46
int quad_he_toggle(struct ConfigSubset *sub, struct HashElem *he, struct Buffer *err)
Toggle the value of a quad.
Definition: quad.c:228
The item stored in a Hash Table.
Definition: hash.h:42
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Variable Documentation

◆ QuadValues

const char* QuadValues[]

Valid strings for creating a QuadValue.

These strings are case-insensitive.

Definition at line 44 of file quad.c.