if (pctx->token.type == isc_tokentype_string &&
strcasecmp(TOKEN_STRING(pctx), "local") == 0)
{
- cfg_obj_t *obj = NULL;
- cfg_obj_create(pctx->mctx, cfg_parser_currentfile(pctx),
- pctx->line, &cfg_type_ustring, &obj);
- obj->value.string.length = strlen("local");
- obj->value.string.base =
- isc_mem_get(pctx->mctx, obj->value.string.length + 1);
- memmove(obj->value.string.base, "local", 5);
- obj->value.string.base[5] = '\0';
- *ret = obj;
+ cfg_string_create(pctx, "local", &cfg_type_ustring, ret);
return ISC_R_SUCCESS;
}
static void
create_listelt(cfg_obj_t *list, cfg_listelt_t **eltp);
-static void
-create_string(cfg_parser_t *pctx, const char *contents, const cfg_type_t *type,
- cfg_obj_t **ret);
static void
free_string(cfg_obj_t *obj);
goto cleanup;
}
- create_string(pctx, filename, &cfg_type_qstring, &stringobj);
create_listelt(pctx->open_files, &elt);
+ cfg_string_create(pctx, filename, &cfg_type_qstring, &stringobj);
elt->obj = stringobj;
ISC_LIST_APPEND(pctx->open_files->value.list, elt, link);
*/
/* Create a string object from a null-terminated C string. */
-static void
-create_string(cfg_parser_t *pctx, const char *contents, const cfg_type_t *type,
- cfg_obj_t **ret) {
+void
+cfg_string_create(cfg_parser_t *pctx, const char *contents,
+ const cfg_type_t *type, cfg_obj_t **ret) {
cfg_obj_t *obj = NULL;
int len;
cfg_parser_error(pctx, CFG_LOG_NEAR, "expected quoted string");
return ISC_R_UNEXPECTEDTOKEN;
}
- create_string(pctx, TOKEN_STRING(pctx), &cfg_type_qstring, ret);
+ cfg_string_create(pctx, TOKEN_STRING(pctx), &cfg_type_qstring, ret);
return ISC_R_SUCCESS;
cleanup:
"expected unquoted string");
return ISC_R_UNEXPECTEDTOKEN;
}
- create_string(pctx, TOKEN_STRING(pctx), &cfg_type_ustring, ret);
+ cfg_string_create(pctx, TOKEN_STRING(pctx), &cfg_type_ustring, ret);
return ISC_R_SUCCESS;
cleanup:
REQUIRE(ret != NULL && *ret == NULL);
CHECK(cfg_getstringtoken(pctx));
- create_string(pctx, TOKEN_STRING(pctx), &cfg_type_qstring, ret);
+ cfg_string_create(pctx, TOKEN_STRING(pctx), &cfg_type_qstring, ret);
return ISC_R_SUCCESS;
cleanup:
REQUIRE(ret != NULL && *ret == NULL);
CHECK(cfg_getstringtoken(pctx));
- create_string(pctx, TOKEN_STRING(pctx), &cfg_type_sstring, ret);
+ cfg_string_create(pctx, TOKEN_STRING(pctx), &cfg_type_sstring, ret);
return ISC_R_SUCCESS;
cleanup:
cfg_parser_error(pctx, CFG_LOG_NEAR, "expected bracketed text");
return ISC_R_UNEXPECTEDTOKEN;
}
- create_string(pctx, TOKEN_STRING(pctx), &cfg_type_bracketed_text, ret);
+ cfg_string_create(pctx, TOKEN_STRING(pctx), &cfg_type_bracketed_text,
+ ret);
return ISC_R_SUCCESS;
cleanup: