#include <tr_cfgwatch.h>
/**
+ * Parse a boolean
+ *
+ * If the key does not exist in the src object, returns success but does fill in *dest.
+ *
+ * @param src JSON object to pull a value from
+ * @param key key to pull
+ * @param dest (output) pointer to an allocated integer
+ * @return TR_CFG_SUCCESS or an error code
+ */
+static TR_CFG_RC tr_cfg_parse_boolean(json_t *src, const char *key, int *dest)
+{
+ json_t *jtmp;
+
+ /* Validate parameters */
+ if ((src == NULL) || (key == NULL) || (dest == NULL))
+ return TR_CFG_BAD_PARAMS;
+
+ /* See if we have a value for this key; do nothing if not */
+ jtmp = json_object_get(src, key);
+ if (jtmp) {
+ if (json_is_boolean(jtmp)) {
+ *dest = json_boolean_value(jtmp);
+ } else {
+ tr_debug("tr_cfg_parse_unsigned: Parsing error, %s is not a boolean.", key);
+ return TR_CFG_NOPARSE;
+ }
+ }
+
+ return TR_CFG_SUCCESS;
+}
+
+/**
* Parse an unsigned integer
*
* If the key does not exist in the src object, returns success but does fill in *dest.
cfg->max_tree_depth = TR_DEFAULT_MAX_TREE_DEPTH;
cfg->tids_port = TR_DEFAULT_TIDS_PORT;
cfg->trps_port = TR_DEFAULT_TRPS_PORT;
+ cfg->monitoring_port = TR_DEFAULT_MONITORING_PORT;
cfg->cfg_poll_interval = TR_CFGWATCH_DEFAULT_POLL;
cfg->cfg_settling_time = TR_CFGWATCH_DEFAULT_SETTLE;
cfg->trp_connect_interval = TR_DEFAULT_TRP_CONNECT_INTERVAL;
cfg->tid_resp_denom = TR_DEFAULT_TID_RESP_DENOM;
cfg->log_threshold = TR_DEFAULT_LOG_THRESHOLD;
cfg->console_threshold = TR_DEFAULT_CONSOLE_THRESHOLD;
+ cfg->monitoring_credentials = NULL;
}
/* Helper that checks return value of a parse fn and returns if it failed */