static TR_CFG_RC tr_cfg_parse_internal (TR_INSTANCE *tr, json_t *jcfg) {
json_t *jint = NULL;
json_t *jmtd = NULL;
+ json_t *jhname = NULL;
if ((!tr) || (!tr->new_cfg) || (!jcfg))
return TR_CFG_BAD_PARAMS;
memset(tr->new_cfg->internal, 0, sizeof(TR_CFG_INTERNAL));
- if ((NULL != (jint = json_object_get(jcfg, "tr_internal"))) &&
- (NULL != (jmtd = json_object_get(jint, "max_tree_depth")))) {
- if (json_is_number(jmtd)) {
- tr->new_cfg->internal->max_tree_depth = json_integer_value(jmtd);
+ if (NULL != (jint = json_object_get(jcfg, "tr_internal"))) {
+ if (NULL != (jmtd = json_object_get(jint, "max_tree_depth"))) {
+ if (json_is_number(jmtd)) {
+ tr->new_cfg->internal->max_tree_depth = json_integer_value(jmtd);
+ } else {
+ fprintf(stderr,"tr_cfg_parse_internal: Parsing error, max_tree_depth is not a number.\n");
+ return TR_CFG_NOPARSE;
+ }
} else {
- fprintf(stderr,"tr_cfg_parse_internal: Parsing error, max_tree_depth is not a number.\n");
+ /* If not configured, use the default */
+ tr->new_cfg->internal->max_tree_depth = TR_DEFAULT_MAX_TREE_DEPTH;
+ }
+ if (NULL != (jhname = json_object_get(jint, "hostname"))) {
+ if (json_is_string(jhname)) {
+ tr->new_cfg->internal->hostname = json_string_value(jhname);
+ } else {
+ fprintf(stderr,"tr_cfg_parse_internal: Parsing error, hostname is not a string.\n");
+ return TR_CFG_NOPARSE;
+ }
+ }
+ else {
+ fprintf(stderr, "tr_cfg_parse_internal: Parsing error, hostname is not found.\n");
return TR_CFG_NOPARSE;
}
- } else {
- /* If not configured, use the default */
- tr->new_cfg->internal->max_tree_depth = TR_DEFAULT_MAX_TREE_DEPTH;
- }
fprintf(stderr, "tr_cfg_parse_internal: Internal config parsed.\n");
return TR_CFG_SUCCESS;
+ }
+ else {
+ fprintf(stderr, "tr_cfg_parse_internal: Parsing error, tr_internal configuration section not found.\n");
+ return TR_CFG_NOPARSE;
+ }
}
static TR_FILTER *tr_cfg_parse_one_filter (TR_INSTANCE *tr, json_t *jfilt, TR_CFG_RC *rc)
memset(rp, 0, sizeof(TR_RP_CLIENT));
/* TBD -- support more than one filter entry per RP Client? */
- if (NULL == (rp->filters[0] = tr_cfg_parse_one_filter(tr, jfilt, rc))) {
+ if (NULL == (rp->filter = tr_cfg_parse_one_filter(tr, jfilt, rc))) {
fprintf(stderr, "tr_cfg_parse_one_rp_client: Error parsing filter.\n");
free(rp);
*rc = TR_CFG_NOPARSE;