Handles configuration for the entire server and exposes a remote-management/monitoring interface.
More...
Go to the source code of this file.
|
|
#define | QEV_CFG_GROUP "quick-event" |
| | The name of the group quick-event uses in configuration files.
|
| |
|
#define | QEV_CFG_INCLUDE "include" |
| | The magic name that causes other config files to be loaded.
|
| |
|
#define | QEV_CFG_LIST_SEPARATOR ',' |
| | The value used to separate lists in the config file.
|
| |
|
#define | QEV_CFG_WRAP_AT 75 |
| | When generating a config file, wrap long lines at this length.
|
| |
|
| void | qev_cfg_set_default_file (const gchar *file_pattern) |
| | Set the default path to look for the config file(s). More...
|
| |
| void | qev_cfg_add (const gchar *group_name, const struct qev_cfg *opts, const guint opts_len) |
| | Add config options under the given group. More...
|
| |
| void | qev_cfg_listen (const gchar *group_name, const qev_cfg_listener_cb cb) |
| | Receive a callback for every key and value found in group_name. More...
|
| |
| void | qev_cfg_set (const gchar *group_name, const gchar *name, union qev_cfg_val val, GError **error) |
| | Dynamically change an option at run time, executing all callbacks, validators, and etc. More...
|
| |
|
void | qev_cfg_validate_port (const gchar *name, union qev_cfg_val *val, GError **error) |
| | Validating ports is a fairly common task.
|
| |
|
guint64 | qev_cfg_get_max_clients () |
| | Gets that maximum number of clients that may be connected.
|
| |
|
guint64 | qev_cfg_get_timeout () |
| | Gets the timeout.
|
| |
Handles configuration for the entire server and exposes a remote-management/monitoring interface.
Command line arguments only allow setting configuration file locations.
- Note
- All config options are expected to be registered at start up, from the same thread, before qev_run() is called, so none of these functions are thread safe, and once the server is up, you probably shouldn't alter anything.
- Author
- Andrew Stone andre.nosp@m.w@cl.nosp@m.ovar..nosp@m.com
- Copyright
- 2012-2014 Clear Channel Inc.
Callback type for after an option has been set / updated, included when it's initialized to its default value.
- Note
- Only 1 callback will ever be executing at a time, so you don't need to worry about configuration updates stepping on other updates.
- Parameters
-
| name | The name of the config value |
| curr_val | The current value. If you need to synchronize threads on this value (which is particularly important for strings), feel free to do any necessary locking and and set curr_val to new_val while holing the lock. To set the new value, do something like the following, based on the data type. 1) *curr_val.bool = new_val.bool; 2) *curr_val.dbl = new_val.dbl; 3) *curr_val.i64 = new_val.i64; 4) *curr_val.str = new_val.str; 5) *curr_val.strv = new_val.strv; 6) *curr_val.ui64 = new_val.ui64; |
| new_val | The value that will be set |
| typedef void(* qev_cfg_listener_cb)(const gchar *name, const gchar *val) |
Callback for listeners.
- Note
- Only 1 callback will ever be executing at a time, so you don't need to worry threading issues here.
- Parameters
-
| name | The key that was found |
| vals | The value |
| typedef void(* qev_cfg_validator)(const gchar *name, union qev_cfg_val *val, GError **error) |
Validation callback for options.
- Parameters
-
| name | The name of the config option |
| type | Type of the value |
| val | The value; the callback may modify this value if it sees fit. Just be sure to free any strings/string vectors that are replaced. |
| [out] | error | Where the error should be placed; QEV will only see the value as invalid if an error is set, so the callback MUST return a new GError describing the error if the value is invalid. [transfer-full] |
Supported option types.
| Enumerator |
|---|
| QEV_CFG_BOOL |
A boolean.
|
| QEV_CFG_INT64 |
Signed, 64bit integer.
|
| QEV_CFG_UINT64 |
Unsigned, 64bit integer.
|
| QEV_CFG_DBL |
A double.
|
| QEV_CFG_STR |
A string.
|
| QEV_CFG_STRV |
A string array.
|
| void qev_cfg_add |
( |
const gchar * |
group_name, |
|
|
const struct qev_cfg * |
opts, |
|
|
const guint |
opts_len |
|
) |
| |
Add config options under the given group.
If any duplicate configuration options are encountered, a warning is emitted, and life moves on. All options are immediately initialized to their default values when they're encountered, even if a duplicate exists.
- Parameters
-
| group_name | The name of the group where the set of options can be located |
| opts | An array of options |
| opts_len | The number of items in opts |
Receive a callback for every key and value found in group_name.
Callbacks are sent for all values that do not have a more specific configuration set; that is, if an option is qev_cfg_add()ed, then that value will not be given the listener; it will just be set like any other value.
- Note
- All values given to the callback will be strings.
-
Only a single listener per group may exist
- Parameters
-
| group_name | The name of the group to get all keys and values for |
| cb | Function to call when values discovered |
| void qev_cfg_set |
( |
const gchar * |
group_name, |
|
|
const gchar * |
name, |
|
|
union qev_cfg_val |
val, |
|
|
GError ** |
error |
|
) |
| |
Dynamically change an option at run time, executing all callbacks, validators, and etc.
- Parameters
-
| group_name | The name of the group the option is part of |
| name | The name of the option to update |
| val | The value that should be set |
| [out] | error | If you wish, you may ask for the error to be returned here; NULL will cause any errors to be written to the server log. On return, if this value is still NULL, it means no errors were encountered. [transfer-full] |
| void qev_cfg_set_default_file |
( |
const gchar * |
file_pattern | ) |
|
Set the default path to look for the config file(s).
- Parameters
-
| file_pattern | A globbing pattern to search for config files. |