-void tr_print_config (FILE *stream, TR_CFG *cfg) {
- fprintf(stream, "tr_print_config: Not yet implemented.");
- return;
-}
-
-void tr_cfg_free (TR_CFG *cfg) {
- talloc_free(cfg);
- return;
-}
-
-TR_CFG_RC tr_apply_new_config (TR_INSTANCE *tr) {
- if (!tr)
- return TR_CFG_BAD_PARAMS;
-
- if (tr->active_cfg)
- tr_cfg_free(tr->active_cfg);
-
- tr->active_cfg = tr->new_cfg;
-
- tr_log_threshold(tr->active_cfg->internal->log_threshold);
- tr_console_threshold(tr->active_cfg->internal->console_threshold);
-
- return TR_CFG_SUCCESS;
-}
-
-static TR_CFG_RC tr_cfg_parse_internal (TR_CFG *trc, json_t *jcfg) {
- json_t *jint = NULL;
- json_t *jmtd = NULL;
- json_t *jtp = NULL;
- json_t *jhname = NULL;
- json_t *jlog = NULL;
- json_t *jconthres = NULL;
- json_t *jlogthres = NULL;
-
- if ((!trc) || (!jcfg))
- return TR_CFG_BAD_PARAMS;
-
- if (NULL == trc->internal) {
- if (NULL == (trc->internal = talloc(trc, TR_CFG_INTERNAL)))
- return TR_CFG_NOMEM;
-
- memset(trc->internal, 0, sizeof(TR_CFG_INTERNAL));
- }
-
- if (NULL != (jint = json_object_get(jcfg, "tr_internal"))) {
- if (NULL != (jmtd = json_object_get(jint, "max_tree_depth"))) {
- if (json_is_number(jmtd)) {
- trc->internal->max_tree_depth = json_integer_value(jmtd);
- } else {
- tr_debug("tr_cfg_parse_internal: Parsing error, max_tree_depth is not a number.");
- return TR_CFG_NOPARSE;
- }
- } else {
- /* If not configured, use the default */
- trc->internal->max_tree_depth = TR_DEFAULT_MAX_TREE_DEPTH;
- }
- if (NULL != (jtp = json_object_get(jint, "tids_port"))) {
- if (json_is_number(jtp)) {
- trc->internal->tids_port = json_integer_value(jtp);
- } else {
- tr_debug("tr_cfg_parse_internal: Parsing error, port is not a number.");
- return TR_CFG_NOPARSE;
- }
- } else {
- /* If not configured, use the default */
- trc->internal->tids_port = TR_DEFAULT_TIDS_PORT;
- }
- if (NULL != (jhname = json_object_get(jint, "hostname"))) {
- if (json_is_string(jhname)) {
- trc->internal->hostname = json_string_value(jhname);
- } else {
- tr_debug("tr_cfg_parse_internal: Parsing error, hostname is not a string.");
- return TR_CFG_NOPARSE;
- }
- }
-
- if (NULL != (jlog = json_object_get(jcfg, "logging"))) {
- if (NULL != (jlogthres = json_object_get(jint, "log_threshold"))) {
- if (json_is_string(jlogthres)) {
- trc->internal->log_threshold = str2sev(json_string_value(jlogthres));
- } else {
- tr_debug("tr_cfg_parse_internal: Parsing error, log_threshold is not a string.");
- return TR_CFG_NOPARSE;
- }
- } else {
- /* If not configured, use the default */
- trc->internal->log_threshold = TR_DEFAULT_LOG_THRESHOLD;
- }
-
- if (NULL != (jconthres = json_object_get(jint, "console_threshold"))) {
- if (json_is_string(jconthres)) {
- trc->internal->console_threshold = str2sev(json_string_value(jconthres));
- } else {
- tr_debug("tr_cfg_parse_internal: Parsing error, console_threshold is not a string.");
- return TR_CFG_NOPARSE;
- }
- } else {
- /* If not configured, use the default */
- trc->internal->console_threshold = TR_DEFAULT_CONSOLE_THRESHOLD;
- }
- } else {
- /* If not configured, use the default */
- trc->internal->console_threshold = TR_DEFAULT_CONSOLE_THRESHOLD;
- trc->internal->log_threshold = TR_DEFAULT_LOG_THRESHOLD;
- }