|
The Assimilation Monitoring Project
|
A base class for remembering configuration values of various types in a hash table with capabilities to go to and from JSON. More...
|
Macros | |
| #define | JSONQUOTES "\\\"" |
| #define | TOKEN_COLON ':' |
| #define | GULP (void)g_scanner_get_next_token(scan) |
| #define | SYNERROR(scan, token, symbol, msg) {g_warning("In Function %s line %d", __FUNCTION__, __LINE__);g_scanner_unexp_token(scan, token, "keyword", "keyword", symbol, msg, TRUE);} |
Functions | |
| void | assim_slist_free_full (GSList *list, void(*)(gpointer)) |
| FSTATIC void | _key_free (gpointer vself) |
| ConfigContext * | configcontext_new (gsize objsize) |
| Construct a new ConfigContext object - with no values defaulted. More... | |
| FSTATIC void | _configcontext_finalize (AssimObj *aself) |
| Finalize (free) a ConfigContext object. More... | |
| FSTATIC gint | _configcontext_key_compare (gconstpointer a, gconstpointer b) |
| Compare two string keys (for GSList sorting) More... | |
| FSTATIC guint | _configcontext_keycount (const ConfigContext *cfg) |
| Return the number of keys in a ConfigContext object. More... | |
| FSTATIC GSList * | _configcontext_keys (const ConfigContext *cfg) |
| Return a GSList of all the keys in a ConfigContext object. More... | |
| FSTATIC enum ConfigValType | _configcontext_gettype (const ConfigContext *self, const char *name) |
| Return a the type of value associated with a given name. More... | |
| FSTATIC ConfigValue * | _configcontext_getvalue (const ConfigContext *self, const char *name) |
| Return a the value structure associated with a given name. More... | |
| FSTATIC gint64 | _configcontext_getint (const ConfigContext *self, const char *name) |
| Get an integer value. More... | |
| FSTATIC void | _configcontext_setint (ConfigContext *self, const char *name, gint value) |
| Set a name to an integer value. More... | |
| FSTATIC gboolean | _configcontext_getbool (const ConfigContext *self, const char *name) |
| Get an boolean value. More... | |
| FSTATIC void | _configcontext_setbool (ConfigContext *self, const char *name, gint value) |
| Set a name to an integer value. More... | |
| FSTATIC const char * | _configcontext_getstring (const ConfigContext *self, const char *name) |
| Return the value of a string name. More... | |
| FSTATIC void | _configcontext_setstring (ConfigContext *self,const char *name,const char *value) |
| Set a name to a string value. More... | |
| FSTATIC GSList * | _configcontext_getarray (const ConfigContext *, const char *name) |
| FSTATIC void | _configcontext_setarray (ConfigContext *, const char *name, GSList *value) |
| FSTATIC NetAddr * | _configcontext_getaddr (const ConfigContext *self, const char *name) |
| Return the NetAddr value of a name. More... | |
| FSTATIC void | _configcontext_setaddr (ConfigContext *self, const char *name, NetAddr *addr) |
| Set the NetAddr value of a name. More... | |
| FSTATIC Frame * | _configcontext_getframe (const ConfigContext *self, const char *name) |
| Return the Frame class value of a name. More... | |
| FSTATIC void | _configcontext_setframe (ConfigContext *self, const char *name, Frame *frame) |
| Set the signature frame to the given SignFrame. More... | |
| FSTATIC ConfigContext * | _configcontext_getconfig (const ConfigContext *self, const char *name) |
| Return a the a ConfigContext value associated with a given name. More... | |
| FSTATIC void | _configcontext_setconfig (ConfigContext *self, const char *name, ConfigContext *value) |
| Save/Set a ConfigContext value associated with a given name. More... | |
| FSTATIC char * | _configcontext_getstr (const ConfigContext *self, const char *name) |
| Return a string value (toString) associated with a given name. More... | |
| FSTATIC ConfigValue * | _configcontext_value_new (enum ConfigValType t) |
| Create a ConfigValue object (containing an object and its type) More... | |
| FSTATIC void | _configcontext_value_vfinalize (void *vself) |
| Finalize (free) a ConfigValue object. More... | |
| FSTATIC void | _configcontext_value_finalize (AssimObj *aself) |
| FSTATIC char * | JSONquotestring (char *s) |
| Escape characters in a string according to JSON conventions... More... | |
| FSTATIC char * | _configcontext_toString (gconstpointer aself) |
| Convert a ConfigContext to a printable string (in JSON notation) More... | |
| FSTATIC char * | _configcontext_elem_toString (ConfigValue *val) |
| Convert a ConfigContext element (ConfigValue) to a String. More... | |
| FSTATIC GScanner * | _configcontext_JSON_GScanner_new (void) |
| Create a GScanner object that is set up to scan JSON text. More... | |
| ConfigContext * | configcontext_new_JSON_string (const char *jsontext) |
| Construct a ConfigContext object from the given JSON string. More... | |
| FSTATIC ConfigContext * | _configcontext_JSON_parse_objandEOF (GScanner *scan) |
| Parse complete JSON object followed by EOF. More... | |
| FSTATIC ConfigContext * | _configcontext_JSON_parse_object (GScanner *scan) |
| Parse a JSON object. More... | |
| FSTATIC ConfigContext * | _configcontext_JSON_parse_members (GScanner *scan, ConfigContext *cfg) |
| Parse a JSON (object) members (a list of "name" : "value" pairs) More... | |
| FSTATIC ConfigContext * | _configcontext_JSON_parse_pair (GScanner *scan, ConfigContext *cfg) |
| FSTATIC ConfigValue * | _configcontext_JSON_parse_value (GScanner *scan) |
| FSTATIC gboolean | _configcontext_JSON_parse_array (GScanner *scan, GSList **retval) |
| typedef struct _ConfigContext | ConfigContext |
| This is the base ConfigContext class object providing configuration context for our clients, and is managed by our C-Class Management system. More... | |
A base class for remembering configuration values of various types in a hash table with capabilities to go to and from JSON.
| #define GULP (void)g_scanner_get_next_token(scan) |
Definition at line 706 of file configcontext.c.
Referenced by _configcontext_JSON_parse_array(), _configcontext_JSON_parse_members(), _configcontext_JSON_parse_object(), _configcontext_JSON_parse_pair(), and _configcontext_JSON_parse_value().
| #define JSONQUOTES "\\\"" |
Definition at line 535 of file configcontext.c.
Referenced by JSONquotestring().
| #define SYNERROR | ( | scan, | |
| token, | |||
| symbol, | |||
| msg | |||
| ) | {g_warning("In Function %s line %d", __FUNCTION__, __LINE__);g_scanner_unexp_token(scan, token, "keyword", "keyword", symbol, msg, TRUE);} |
Definition at line 708 of file configcontext.c.
Referenced by _configcontext_JSON_parse_array(), _configcontext_JSON_parse_objandEOF(), _configcontext_JSON_parse_object(), _configcontext_JSON_parse_pair(), and _configcontext_JSON_parse_value().
| #define TOKEN_COLON ':' |
Definition at line 705 of file configcontext.c.
Referenced by _configcontext_JSON_parse_pair().
| typedef struct _ConfigContext ConfigContext |
This is the base ConfigContext class object providing configuration context for our clients, and is managed by our C-Class Management system.
It provides the analog of global variables for remembering configuration defaults, etc, but in a hash table, with capabilities to go to and from JSON.
Definition at line 42 of file configcontext.h.
| FSTATIC char * _configcontext_elem_toString | ( | ConfigValue * | val | ) |
Convert a ConfigContext element (ConfigValue) to a String.
Definition at line 586 of file configcontext.c.
References _ConfigValue::addrvalue, _ConfigValue::arrayvalue, _ConfigContext::baseclass, CASTTOCLASS, CFG_ARRAY, CFG_BOOL, CFG_CFGCTX, CFG_EEXIST, CFG_FLOAT, CFG_FRAME, CFG_INT64, CFG_NETADDR, CFG_NULL, CFG_STRING, _ConfigValue::cfgctxvalue, _ConfigValue::floatvalue, FMT_64BIT, _ConfigValue::framevalue, FREE, _ConfigValue::intvalue, JSONquotestring(), _ConfigValue::strvalue, _AssimObj::toString, _ConfigValue::u, and _ConfigValue::valtype.
Referenced by _configcontext_getstr(), and _configcontext_toString().


Finalize (free) a ConfigContext object.
Definition at line 160 of file configcontext.c.
References CASTTOCLASS, and FREECLASSOBJ.
Referenced by configcontext_new().

| FSTATIC NetAddr * _configcontext_getaddr | ( | const ConfigContext * | self, |
| const char * | name | ||
| ) |
Return the NetAddr value of a name.
| [in] | self | ConfigContext object |
| [in] | name | Name to get the NetAddr value of |
Definition at line 363 of file configcontext.c.
References _ConfigValue::addrvalue, CASTTOCLASS, CFG_NETADDR, _ConfigValue::u, and _ConfigValue::valtype.
Referenced by configcontext_new().

| FSTATIC GSList * _configcontext_getarray | ( | const ConfigContext * | self, |
| const char * | name | ||
| ) |
Definition at line 333 of file configcontext.c.
References _ConfigValue::arrayvalue, CASTTOCLASS, CFG_ARRAY, _ConfigValue::u, and _ConfigValue::valtype.
Referenced by configcontext_new().

| FSTATIC gboolean _configcontext_getbool | ( | const ConfigContext * | self, |
| const char * | name | ||
| ) |
Get an boolean value.
| [in] | self | ConfigContext object |
| [in] | name | Name to get the associated int value of |
Definition at line 273 of file configcontext.c.
References CASTTOCLASS, CFG_BOOL, _ConfigValue::intvalue, _ConfigValue::u, and _ConfigValue::valtype.
Referenced by configcontext_new().

| FSTATIC ConfigContext * _configcontext_getconfig | ( | const ConfigContext * | self, |
| const char * | name | ||
| ) |
Return a the a ConfigContext value associated with a given name.
Definition at line 428 of file configcontext.c.
References CASTTOCLASS, CFG_CFGCTX, _ConfigValue::cfgctxvalue, _ConfigValue::u, and _ConfigValue::valtype.
Referenced by configcontext_new().

| FSTATIC Frame * _configcontext_getframe | ( | const ConfigContext * | self, |
| const char * | name | ||
| ) |
Return the Frame class value of a name.
| [in] | self | ConfigContext object |
| [in] | name | Name to retrieve the Frame class value of |
Definition at line 395 of file configcontext.c.
References CASTTOCLASS, CFG_FRAME, _ConfigValue::framevalue, _ConfigValue::u, and _ConfigValue::valtype.
Referenced by configcontext_new().

| FSTATIC gint64 _configcontext_getint | ( | const ConfigContext * | self, |
| const char * | name | ||
| ) |
Get an integer value.
| [in] | self | ConfigContext object |
| [in] | name | Name to get the associated int value of |
Definition at line 241 of file configcontext.c.
References CASTTOCLASS, CFG_INT64, _ConfigValue::intvalue, _ConfigValue::u, and _ConfigValue::valtype.
Referenced by configcontext_new().

| FSTATIC char * _configcontext_getstr | ( | const ConfigContext * | self, |
| const char * | name | ||
| ) |
Return a string value (toString) associated with a given name.
Definition at line 456 of file configcontext.c.
References _configcontext_elem_toString().

| FSTATIC const char * _configcontext_getstring | ( | const ConfigContext * | self, |
| const char * | name | ||
| ) |
Return the value of a string name.
| [in] | self | ConfigContext object |
| [in] | name | Name to get the associated string value of |
Definition at line 305 of file configcontext.c.
References CASTTOCLASS, CFG_STRING, _ConfigValue::strvalue, _ConfigValue::u, and _ConfigValue::valtype.
Referenced by configcontext_new().

| FSTATIC enum ConfigValType _configcontext_gettype | ( | const ConfigContext * | self, |
| const char * | name | ||
| ) |
Return a the type of value associated with a given name.
Definition at line 217 of file configcontext.c.
References CASTTOCLASS, CFG_EEXIST, and _ConfigValue::valtype.
Referenced by configcontext_new().

| FSTATIC ConfigValue * _configcontext_getvalue | ( | const ConfigContext * | self, |
| const char * | name | ||
| ) |
Return a the value structure associated with a given name.
Definition at line 230 of file configcontext.c.
References CASTTOCLASS.
Referenced by configcontext_new().

| FSTATIC GScanner * _configcontext_JSON_GScanner_new | ( | void | ) |
Create a GScanner object that is set up to scan JSON text.
See JSON web site for details on JSON syntax.
Definition at line 653 of file configcontext.c.
References cma.cma::config.
Referenced by configcontext_new_JSON_string().

| FSTATIC gboolean _configcontext_JSON_parse_array | ( | GScanner * | scan, |
| GSList ** | retval | ||
| ) |
Definition at line 927 of file configcontext.c.
References _configcontext_JSON_parse_value(), _configcontext_value_vfinalize(), g_slist_free_full, GULP, and SYNERROR.
Referenced by _configcontext_JSON_parse_value().


| FSTATIC ConfigContext * _configcontext_JSON_parse_members | ( | GScanner * | scan, |
| ConfigContext * | cfg | ||
| ) |
Parse a JSON (object) members (a list of "name" : "value" pairs)
Definition at line 772 of file configcontext.c.
References _configcontext_JSON_parse_pair(), and GULP.
Referenced by _configcontext_JSON_parse_object().


| FSTATIC ConfigContext * _configcontext_JSON_parse_objandEOF | ( | GScanner * | scan | ) |
Parse complete JSON object followed by EOF.
Definition at line 726 of file configcontext.c.
References _configcontext_JSON_parse_object(), SYNERROR, and UNREF.
Referenced by configcontext_new_JSON_string().


| FSTATIC ConfigContext * _configcontext_JSON_parse_object | ( | GScanner * | scan | ) |
Parse a JSON object.
Definition at line 739 of file configcontext.c.
References _configcontext_JSON_parse_members(), configcontext_new(), GULP, SYNERROR, and UNREF.
Referenced by _configcontext_JSON_parse_objandEOF(), and _configcontext_JSON_parse_value().


| FSTATIC ConfigContext * _configcontext_JSON_parse_pair | ( | GScanner * | scan, |
| ConfigContext * | cfg | ||
| ) |
Definition at line 787 of file configcontext.c.
References _configcontext_JSON_parse_value(), _ConfigContext::_values, GULP, SYNERROR, and TOKEN_COLON.
Referenced by _configcontext_JSON_parse_members().


| FSTATIC ConfigValue * _configcontext_JSON_parse_value | ( | GScanner * | scan | ) |
FIXME: Need to make the conversion to a NetAddr optional...
Definition at line 830 of file configcontext.c.
References _configcontext_JSON_parse_array(), _configcontext_JSON_parse_object(), _configcontext_value_new(), _ConfigValue::addrvalue, _ConfigValue::arrayvalue, CFG_ARRAY, CFG_BOOL, CFG_CFGCTX, CFG_FLOAT, CFG_INT64, CFG_NETADDR, CFG_NULL, CFG_STRING, _ConfigValue::cfgctxvalue, _ConfigValue::floatvalue, GULP, _ConfigValue::intvalue, netaddr_string_new(), _ConfigValue::strvalue, SYNERROR, and _ConfigValue::u.
Referenced by _configcontext_JSON_parse_array(), and _configcontext_JSON_parse_pair().


| FSTATIC gint _configcontext_key_compare | ( | gconstpointer | a, |
| gconstpointer | b | ||
| ) |
Compare two string keys (for GSList sorting)
Definition at line 173 of file configcontext.c.
Referenced by _configcontext_keys().

| FSTATIC guint _configcontext_keycount | ( | const ConfigContext * | cfg | ) |
Return the number of keys in a ConfigContext object.
Definition at line 180 of file configcontext.c.
References _ConfigContext::_values.
Referenced by configcontext_new().

| FSTATIC GSList * _configcontext_keys | ( | const ConfigContext * | cfg | ) |
Return a GSList of all the keys in a ConfigContext object.
Definition at line 196 of file configcontext.c.
References _configcontext_key_compare(), and _ConfigContext::_values.
Referenced by configcontext_new().


| FSTATIC void _configcontext_setaddr | ( | ConfigContext * | self, |
| const char * | name, | ||
| NetAddr * | addr | ||
| ) |
Set the NetAddr value of a name.
| [in,out] | self | ConfigContext object |
| [in] | name | Name to set to 'addr' (we copy it) |
| [in,out] | addr | Address to set it to (we hold a ref to it) |
Definition at line 381 of file configcontext.c.
References _configcontext_value_new(), _ConfigValue::addrvalue, CFG_NETADDR, REF, and _ConfigValue::u.
Referenced by configcontext_new().


| FSTATIC void _configcontext_setarray | ( | ConfigContext * | self, |
| const char * | name, | ||
| GSList * | value | ||
| ) |
Definition at line 350 of file configcontext.c.
References _configcontext_value_new(), _ConfigValue::arrayvalue, CFG_ARRAY, and _ConfigValue::u.
Referenced by configcontext_new().


| FSTATIC void _configcontext_setbool | ( | ConfigContext * | self, |
| const char * | name, | ||
| gint | value | ||
| ) |
Set a name to an integer value.
| [in,out] | self | ConfigContext Object |
| [in] | name | Name to set the associated int value of |
| [in] | value | Int value to set the 'name' to |
Definition at line 292 of file configcontext.c.
References _configcontext_value_new(), CFG_BOOL, _ConfigValue::intvalue, and _ConfigValue::u.

| FSTATIC void _configcontext_setconfig | ( | ConfigContext * | self, |
| const char * | name, | ||
| ConfigContext * | value | ||
| ) |
Save/Set a ConfigContext value associated with a given name.
Definition at line 444 of file configcontext.c.
References _configcontext_value_new(), CFG_CFGCTX, _ConfigValue::cfgctxvalue, REF, and _ConfigValue::u.
Referenced by configcontext_new().


| FSTATIC void _configcontext_setframe | ( | ConfigContext * | self, |
| const char * | name, | ||
| Frame * | frame | ||
| ) |
Set the signature frame to the given SignFrame.
| [in,out] | self | ConfigContext object |
| [in] | name | name to set value of (we copy it) |
| [in,out] | frame | Frame class value to set 'name' to (we hold a ref to it) |
Definition at line 413 of file configcontext.c.
References _configcontext_value_new(), CFG_FRAME, _ConfigValue::framevalue, REF, and _ConfigValue::u.
Referenced by configcontext_new().


| FSTATIC void _configcontext_setint | ( | ConfigContext * | self, |
| const char * | name, | ||
| gint | value | ||
| ) |
Set a name to an integer value.
| [in,out] | self | ConfigContext Object |
| [in] | name | Name to set the associated int value of |
| [in] | value | Int value to set the 'name' to |
Definition at line 260 of file configcontext.c.
References _configcontext_value_new(), CFG_INT64, _ConfigValue::intvalue, and _ConfigValue::u.
Referenced by configcontext_new().


| FSTATIC void _configcontext_setstring | ( | ConfigContext * | self, |
| const char * | name, | ||
| const char * | value | ||
| ) |
Set a name to a string value.
| [in,out] | self | ConfigContext object |
| [in] | name | Name to set the string value of (we copy it) |
| [in] | value | Value to set 'name' to (we copy it) |
Definition at line 323 of file configcontext.c.
References _configcontext_value_new(), CFG_STRING, _ConfigValue::strvalue, and _ConfigValue::u.
Referenced by configcontext_new().


| FSTATIC char * _configcontext_toString | ( | gconstpointer | aself | ) |
Convert a ConfigContext to a printable string (in JSON notation)
Definition at line 558 of file configcontext.c.
References _configcontext_elem_toString(), and CASTTOCONSTCLASS.
Referenced by configcontext_new().


Definition at line 491 of file configcontext.c.
References _configcontext_value_vfinalize(), CASTTOCLASS, CFG_ARRAY, CFG_CFGCTX, CFG_EEXIST, CFG_FRAME, CFG_NETADDR, CFG_STRING, FREECLASSOBJ, g_slist_free_full, and UNREF.
Referenced by _configcontext_value_new().


| FSTATIC ConfigValue * _configcontext_value_new | ( | enum ConfigValType | t | ) |
Create a ConfigValue object (containing an object and its type)
Definition at line 467 of file configcontext.c.
References _configcontext_value_finalize(), _AssimObj::_finalize, assimobj_new(), NEWSUBCLASS, _ConfigValue::u, and _ConfigValue::valtype.
Referenced by _configcontext_JSON_parse_value(), _configcontext_setaddr(), _configcontext_setarray(), _configcontext_setbool(), _configcontext_setconfig(), _configcontext_setframe(), _configcontext_setint(), and _configcontext_setstring().


| FSTATIC void _configcontext_value_vfinalize | ( | void * | vself | ) |
Finalize (free) a ConfigValue object.
Definition at line 482 of file configcontext.c.
References CASTTOCLASS, and UNREF.
| FSTATIC void _key_free | ( | gpointer | vself | ) |
Definition at line 114 of file configcontext.c.
Referenced by configcontext_new().

| void assim_slist_free_full | ( | GSList * | list, |
| void(*)(gpointer) | datafree | ||
| ) |
Definition at line 91 of file configcontext.c.
| ConfigContext* configcontext_new | ( | gsize | objsize | ) |
Construct a new ConfigContext object - with no values defaulted.
| objsize | size of ConfigContext structure (or zero for min size) |
Definition at line 123 of file configcontext.c.
References _configcontext_finalize(), _configcontext_getaddr(), _configcontext_getarray(), _configcontext_getbool(), _configcontext_getconfig(), _configcontext_getframe(), _configcontext_getint(), _configcontext_getstring(), _configcontext_gettype(), _configcontext_getvalue(), _configcontext_keycount(), _configcontext_keys(), _configcontext_setaddr(), _configcontext_setarray(), _configcontext_setbool(), _configcontext_setconfig(), _configcontext_setframe(), _configcontext_setint(), _configcontext_setstring(), _configcontext_toString(), _configcontext_value_vfinalize(), _AssimObj::_finalize, _key_free(), _ConfigContext::_values, assimobj_new(), _ConfigContext::getaddr, _ConfigContext::getarray, _ConfigContext::getbool, _ConfigContext::getconfig, _ConfigContext::getframe, _ConfigContext::getint, _ConfigContext::getstring, _ConfigContext::gettype, _ConfigContext::getvalue, _ConfigContext::keycount, _ConfigContext::keys, NEWSUBCLASS, _ConfigContext::setaddr, _ConfigContext::setarray, _ConfigContext::setbool, _ConfigContext::setconfig, _ConfigContext::setframe, _ConfigContext::setint, _ConfigContext::setstring, and _AssimObj::toString.
Referenced by cma.AssimCclasses.pyConfigContext::__init__(), _childprocess_toString(), _configcontext_JSON_parse_object(), _nano_send_rscexitstatus(), main(), and resourceocf_new().


| ConfigContext* configcontext_new_JSON_string | ( | const char * | jsontext | ) |
Construct a ConfigContext object from the given JSON string.
Definition at line 713 of file configcontext.c.
References _configcontext_JSON_GScanner_new(), and _configcontext_JSON_parse_objandEOF().
Referenced by cma.AssimCclasses.pyConfigContext::__init__(), check_JSON(), nano_schedule_discovery(), nano_startupidle(), nanoobey_cancelrscoperation(), nanoobey_dorscoperation(), test_childprocess_modenv(), test_invalid_queuecmd(), test_invalid_resourcecmd(), test_safe_ocfops(), and test_safe_queue_ocfops().


| FSTATIC char * JSONquotestring | ( | char * | s | ) |
Escape characters in a string according to JSON conventions...
Definition at line 538 of file configcontext.c.
References JSONQUOTES.
Referenced by _configcontext_elem_toString().
