A collection of config items. More...
#include "config.h"
#include <limits.h>
#include <stdio.h>
#include "mutt/lib.h"
#include "set.h"
#include "inheritance.h"
#include "types.h"
Go to the source code of this file.
Functions | |
static void | destroy (int type, void *obj, intptr_t data) |
Callback function for the Hash Table - Implements hash_hdata_free_t. More... | |
static struct HashElem * | create_synonym (const struct ConfigSet *cs, struct ConfigDef *cdef, struct Buffer *err) |
Create an alternative name for a config item. More... | |
static struct HashElem * | reg_one_var (const struct ConfigSet *cs, struct ConfigDef *cdef, struct Buffer *err) |
Register one config item. More... | |
struct ConfigSet * | cs_new (size_t size) |
Create a new Config Set. More... | |
void | cs_free (struct ConfigSet **ptr) |
Free a Config Set. More... | |
struct HashElem * | cs_get_base (struct HashElem *he) |
Find the root Config Item. More... | |
struct HashElem * | cs_get_elem (const struct ConfigSet *cs, const char *name) |
Get the HashElem representing a config item. More... | |
const struct ConfigSetType * | cs_get_type_def (const struct ConfigSet *cs, unsigned int type) |
Get the definition for a type. More... | |
bool | cs_register_type (struct ConfigSet *cs, const struct ConfigSetType *cst) |
Register a type of config item. More... | |
bool | cs_register_variables (const struct ConfigSet *cs, struct ConfigDef vars[], int flags) |
Register a set of config items. More... | |
struct HashElem * | cs_inherit_variable (const struct ConfigSet *cs, struct HashElem *parent, const char *name) |
Create in inherited config item. More... | |
void | cs_uninherit_variable (const struct ConfigSet *cs, const char *name) |
Remove an inherited config item. More... | |
int | cs_he_reset (const struct ConfigSet *cs, struct HashElem *he, struct Buffer *err) |
Reset a config item to its initial value. More... | |
int | cs_str_reset (const struct ConfigSet *cs, const char *name, struct Buffer *err) |
Reset a config item to its initial value. More... | |
int | cs_he_initial_set (const struct ConfigSet *cs, struct HashElem *he, const char *value, struct Buffer *err) |
Set the initial value of a config item. More... | |
int | cs_str_initial_set (const struct ConfigSet *cs, const char *name, const char *value, struct Buffer *err) |
Set the initial value of a config item. More... | |
int | cs_he_initial_get (const struct ConfigSet *cs, struct HashElem *he, struct Buffer *result) |
Get the initial, or parent, value of a config item. More... | |
int | cs_str_initial_get (const struct ConfigSet *cs, const char *name, struct Buffer *result) |
Get the initial, or parent, value of a config item. More... | |
int | cs_he_string_set (const struct ConfigSet *cs, struct HashElem *he, const char *value, struct Buffer *err) |
Set a config item by string. More... | |
int | cs_str_string_set (const struct ConfigSet *cs, const char *name, const char *value, struct Buffer *err) |
Set a config item by string. More... | |
int | cs_he_string_get (const struct ConfigSet *cs, struct HashElem *he, struct Buffer *result) |
Get a config item as a string. More... | |
int | cs_str_string_get (const struct ConfigSet *cs, const char *name, struct Buffer *result) |
Get a config item as a string. More... | |
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. More... | |
int | cs_str_native_set (const struct ConfigSet *cs, const char *name, intptr_t value, struct Buffer *err) |
Natively set the value of a string config item. More... | |
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. More... | |
intptr_t | cs_str_native_get (const struct ConfigSet *cs, const char *name, struct Buffer *err) |
Natively get the value of a string config item. More... | |
int | cs_he_string_plus_equals (const struct ConfigSet *cs, struct HashElem *he, const char *value, struct Buffer *err) |
Add to a config item by string. More... | |
int | cs_str_string_plus_equals (const struct ConfigSet *cs, const char *name, const char *value, struct Buffer *err) |
Add to a config item by string. More... | |
int | cs_he_string_minus_equals (const struct ConfigSet *cs, struct HashElem *he, const char *value, struct Buffer *err) |
Remove from a config item by string. More... | |
int | cs_str_string_minus_equals (const struct ConfigSet *cs, const char *name, const char *value, struct Buffer *err) |
Remove from a config item by string. More... | |
Variables | |
struct ConfigSetType | RegisteredTypes [18] |
A collection of config items.
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 set.c.
|
static |
Callback function for the Hash Table - Implements hash_hdata_free_t.
type | Object type, e.g. DT_STRING |
obj | Object to destroy |
data | ConfigSet associated with the object |
Definition at line 47 of file set.c.
|
static |
Create an alternative name for a config item.
cs | Config items |
cdef | Variable definition |
err | Buffer for error messages |
ptr | New HashElem representing the config item synonym |
Definition at line 99 of file set.c.
|
static |
Register one config item.
cs | Config items |
cdef | Variable definition |
err | Buffer for error messages |
ptr | New HashElem representing the config item |
Definition at line 129 of file set.c.
struct ConfigSet* cs_new | ( | size_t | size | ) |
Create a new Config Set.
size | Number of expected config items |
ptr | New ConfigSet object |
Definition at line 166 of file set.c.
void cs_free | ( | struct ConfigSet ** | ptr | ) |
Find the root Config Item.
he | Config Item to examine |
ptr | Root Config Item |
Given an inherited HashElem, find the HashElem representing the original Config Item.
Definition at line 199 of file set.c.
Get the HashElem representing a config item.
cs | Config items |
name | Name of config item |
ptr | HashElem representing the config item |
Definition at line 214 of file set.c.
const struct ConfigSetType* cs_get_type_def | ( | const struct ConfigSet * | cs, |
unsigned int | type | ||
) |
Get the definition for a type.
cs | Config items |
type | Type to lookup, e.g. DT_NUMBER |
ptr | ConfigSetType representing the type |
Definition at line 237 of file set.c.
bool cs_register_type | ( | struct ConfigSet * | cs, |
const struct ConfigSetType * | cst | ||
) |
Register a type of config item.
cs | Config items |
cst | Structure defining the type |
bool | True, if type was registered successfully |
Definition at line 258 of file set.c.
Register a set of config items.
cs | Config items |
vars | Variable definition |
flags | Flags, e.g. DT_NO_VARIABLE |
bool | True, if all variables were registered successfully |
Definition at line 286 of file set.c.
struct HashElem* cs_inherit_variable | ( | const struct ConfigSet * | cs, |
struct HashElem * | parent, | ||
const char * | name | ||
) |
Create in inherited config item.
cs | Config items |
parent | HashElem of parent config item |
name | Name of account-specific config item |
ptr | New HashElem representing the inherited config item |
Definition at line 316 of file set.c.
void cs_uninherit_variable | ( | const struct ConfigSet * | cs, |
const char * | name | ||
) |
Remove an inherited config item.
cs | Config items |
name | Name of config item to remove |
Definition at line 341 of file set.c.
Reset a config item to its initial value.
num | Result, e.g. CSR_SUCCESS |
Definition at line 356 of file set.c.
Reset a config item to its initial value.
cs | Config items |
name | Name of config item |
err | Buffer for error messages |
num | Result, e.g. CSR_SUCCESS |
Definition at line 408 of file set.c.
int cs_he_initial_set | ( | const struct ConfigSet * | cs, |
struct HashElem * | he, | ||
const char * | value, | ||
struct Buffer * | err | ||
) |
Set the initial value of a config item.
cs | Config items |
he | HashElem representing config item |
value | Value to set |
err | Buffer for error messages |
num | Result, e.g. CSR_SUCCESS |
Definition at line 431 of file set.c.
int cs_str_initial_set | ( | const struct ConfigSet * | cs, |
const char * | name, | ||
const char * | value, | ||
struct Buffer * | err | ||
) |
Set the initial value of a config item.
cs | Config items |
name | Name of config item |
value | Value to set |
err | Buffer for error messages |
num | Result, e.g. CSR_SUCCESS |
Definition at line 473 of file set.c.
Get the initial, or parent, value of a config item.
cs | Config items |
he | HashElem representing config item |
result | Buffer for results or error messages |
num | Result, e.g. CSR_SUCCESS |
If a config item is inherited from another, then this will get the parent's value. Otherwise, it will get the config item's initial value.
Definition at line 499 of file set.c.
Get the initial, or parent, value of a config item.
cs | Config items |
name | Name of config item |
result | Buffer for results or error messages |
num | Result, e.g. CSR_SUCCESS |
If a config item is inherited from another, then this will get the parent's value. Otherwise, it will get the config item's initial value.
Definition at line 535 of file set.c.
int cs_he_string_set | ( | const struct ConfigSet * | cs, |
struct HashElem * | he, | ||
const char * | value, | ||
struct Buffer * | err | ||
) |
Set a config item by string.
cs | Config items |
he | HashElem representing config item |
value | Value to set |
err | Buffer for error messages |
num | Result, e.g. CSR_SUCCESS |
Definition at line 558 of file set.c.
int cs_str_string_set | ( | const struct ConfigSet * | cs, |
const char * | name, | ||
const char * | value, | ||
struct Buffer * | err | ||
) |
Set a config item by string.
cs | Config items |
name | Name of config item |
value | Value to set |
err | Buffer for error messages |
num | Result, e.g. CSR_SUCCESS |
Definition at line 613 of file set.c.
Get a config item as a string.
cs | Config items |
he | HashElem representing config item |
result | Buffer for results or error messages |
num | Result, e.g. CSR_SUCCESS |
Definition at line 636 of file set.c.
Get a config item as a string.
cs | Config items |
name | Name of config item |
result | Buffer for results or error messages |
num | Result, e.g. CSR_SUCCESS |
Definition at line 683 of file set.c.
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.
cs | Config items |
he | HashElem representing config item |
value | Native pointer/value to set |
err | Buffer for error messages |
num | Result, e.g. CSR_SUCCESS |
Definition at line 706 of file set.c.
int cs_str_native_set | ( | const struct ConfigSet * | cs, |
const char * | name, | ||
intptr_t | value, | ||
struct Buffer * | err | ||
) |
Natively set the value of a string config item.
cs | Config items |
name | Name of config item |
value | Native pointer/value to set |
err | Buffer for error messages |
num | Result, e.g. CSR_SUCCESS |
Definition at line 761 of file set.c.
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.
cs | Config items |
he | HashElem representing config item |
err | Buffer for results or error messages |
intptr_t | Native pointer/value |
INT_MIN | Error |
Definition at line 817 of file set.c.
Natively get the value of a string config item.
cs | Config items |
name | Name of config item |
err | Buffer for error messages |
intptr_t | Native pointer/value |
INT_MIN | Error |
Definition at line 871 of file set.c.
int cs_he_string_plus_equals | ( | const struct ConfigSet * | cs, |
struct HashElem * | he, | ||
const char * | value, | ||
struct Buffer * | err | ||
) |
Add to a config item by string.
cs | Config items |
he | HashElem representing config item |
value | Value to set |
err | Buffer for error messages |
num | Result, e.g. CSR_SUCCESS |
Definition at line 888 of file set.c.
int cs_str_string_plus_equals | ( | const struct ConfigSet * | cs, |
const char * | name, | ||
const char * | value, | ||
struct Buffer * | err | ||
) |
Add to a config item by string.
cs | Config items |
name | Name of config item |
value | Value to set |
err | Buffer for error messages |
num | Result, e.g. CSR_SUCCESS |
Definition at line 950 of file set.c.
int cs_he_string_minus_equals | ( | const struct ConfigSet * | cs, |
struct HashElem * | he, | ||
const char * | value, | ||
struct Buffer * | err | ||
) |
Remove from a config item by string.
cs | Config items |
he | HashElem representing config item |
value | Value to set |
err | Buffer for error messages |
num | Result, e.g. CSR_SUCCESS |
Definition at line 974 of file set.c.
int cs_str_string_minus_equals | ( | const struct ConfigSet * | cs, |
const char * | name, | ||
const char * | value, | ||
struct Buffer * | err | ||
) |
Remove from a config item by string.
cs | Config items |
name | Name of config item |
value | Value to set |
err | Buffer for error messages |
num | Result, e.g. CSR_SUCCESS |
Definition at line 1036 of file set.c.
struct ConfigSetType RegisteredTypes[18] |