15#define pharos_app_config_strdup _strdup
17#define pharos_app_config_strdup strdup
23 if (raw_value == NULL || raw_value[0] ==
'\0') {
27 if ((strlen(raw_value) > 2 && raw_value[1] ==
':') || raw_value[0] ==
'\\' || raw_value[0] ==
'/') {
31 if (raw_value[0] ==
'/') {
36 if (conf_dir == NULL) {
39 resolved =
path_join(conf_dir, raw_value);
45 char *path =
path_join(app_root,
"app.conf");
50 path =
path_join(app_root,
"pharos.conf");
67 if (
streq(key,
"app_dir") ||
streq(key,
"build_dir") ||
streq(key,
"state_dir") ||
streq(key,
"state_path") ||
streq(key,
"log_path") ||
streq(key,
"socket_path") ||
streq(key,
"error_report_path")) {
74 const char *
const *field;
78 field = (
const char *
const *)((
const char *)config + offset);
79 if (field == NULL || *field == NULL) {
103 if (key != NULL &&
streq(key,
"app_dir")) {
109 for (index = 0; index <
sizeof(key_map) /
sizeof(key_map[0]); index++) {
110 if (!
streq(key, key_map[index].key)) {
122 char *conf_text = NULL;
123 char *manifest_path = NULL;
124 char *manifest_text = NULL;
126 if (config == NULL) {
129 memset(config, 0,
sizeof(*config));
130 if (app_root == NULL || app_root[0] ==
'\0') {
134 if (conf_path != NULL) {
138 manifest_path =
path_join(app_root,
"pharos.app.json");
139 if (manifest_path != NULL &&
path_exists(manifest_path)) {
143 if (config->
conf_path != NULL && conf_text != NULL) {
170 if (manifest_text != NULL) {
181 if (config == NULL) {
196 memset(config, 0,
sizeof(*config));
203 if (raw_value == NULL || raw_value[0] ==
'\0' ||
streq(raw_value,
"/") ||
streq(raw_value,
"null")) {
211 while (*trimmed ==
'/') {
214 len = strlen(trimmed);
215 while (
len > 0 && trimmed[
len - 1] ==
'/') {
216 trimmed[--
len] =
'\0';
223 char *normalized = (
char *)malloc(
len + 2);
224 if (normalized == NULL) {
229 memcpy(normalized + 1, trimmed,
len + 1);
void free_app_local_config_native(AppLocalConfigNative *config)
Releases heap-owned fields in an app-local configuration record.
char * app_local_conf_path_native(const char *app_root)
Builds the path to an app-local runtime configuration file.
static char * resolve_conf_value_key_native(const char *conf_path, const char *key, const char *value)
char * app_local_conf_value_native(const char *app_root, const char *key)
Looks up one key from the app-local runtime configuration.
static char * duplicate_config_field_native(const AppLocalConfigNative *config, size_t offset)
char * resolve_conf_relative_path_native(const char *conf_path, const char *raw_value)
Resolves a config value relative to the directory that owns a config file.
char * normalize_base_path_native(const char *raw_value)
Normalizes a configured app base path into Pharos runtime form.
#define pharos_app_config_strdup
int load_app_local_config_native(const char *app_root, AppLocalConfigNative *config)
Loads app-local configuration and manifest-derived path hints into a config record.
Declares app-local runtime configuration helpers and the app-local configuration record.
char * conf_lookup_value_in_text(const char *text, const char *key)
Looks up one key from Pharos conf-format text.
char * json_find_string_in_section(const char *text, const char *section, const char *key)
Finds a JSON string value for a key inside a named section object.
Declares lightweight JSON and conf value lookup helpers.
char * path_join(const char *left, const char *right)
Joins two path segments using the native path separator.
int streq(const char *a, const char *b)
Tests whether two strings are exactly equal.
char * path_dirname(const char *path)
Returns the parent directory component of a path.
char * read_file_text(const char *path)
Reads an entire file into a newly allocated text buffer.
int path_exists(const char *path)
Tests whether a filesystem path currently exists.
Declares shared low-level support helpers used across the Pharos native runtime.
App-local configuration values loaded from app-local config and manifest authority fields.
char * manifest_base_path
char * manifest_state_path
char * manifest_build_artifact_dir