Pharos 0.7.23
Modern Web Framework & Web App Hosting Service.
Loading...
Searching...
No Matches
native_json_config.c File Reference

Provides lightweight JSON and conf value extraction helpers for manifests and config files. More...

#include "native_json_config.h"
#include "native_support.h"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

Go to the source code of this file.

Macros

#define pharos_json_strdup   strdup

Functions

char * json_find_string_after (const char *text, const char *key, const char *start_at)
 Finds a JSON string value for a key after a given scan position.
char * json_find_string (const char *text, const char *key)
 Finds the first JSON string value associated with a key.
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.
char * json_extract_array_in_section (const char *text, const char *section, const char *key)
 Extracts the raw JSON array text for a key inside a named section.
char * conf_lookup_value_in_text (const char *text, const char *key)
 Looks up one key from Pharos conf-format text.
char * conf_lookup_value (const char *path, const char *key)
 Reads a Pharos conf file and looks up one key.

Detailed Description

Provides lightweight JSON and conf value extraction helpers for manifests and config files.

Definition in file native_json_config.c.

Macro Definition Documentation

◆ pharos_json_strdup

#define pharos_json_strdup   strdup

Definition at line 17 of file native_json_config.c.

Referenced by conf_lookup_value_in_text().

Function Documentation

◆ conf_lookup_value()

char * conf_lookup_value ( const char * path,
const char * key )

◆ conf_lookup_value_in_text()

char * conf_lookup_value_in_text ( const char * text,
const char * key )

Looks up one key from Pharos conf-format text.

Parameters
textConfig text to search.
keyConfig key to locate.
Returns
Newly allocated config value, or NULL when the key is not found.

Definition at line 139 of file native_json_config.c.

References dup_range(), pharos_json_strdup, and trim_in_place().

Referenced by conf_lookup_value(), and load_app_local_config_native().

◆ json_extract_array_in_section()

char * json_extract_array_in_section ( const char * text,
const char * section,
const char * key )

Extracts the raw JSON array text for a key inside a named section.

Parameters
textJSON text to search.
sectionSection name that should contain the array.
keyArray-valued key to locate.
Returns
Newly allocated raw array text, or NULL when the array is not found.

Definition at line 81 of file native_json_config.c.

References len.

Referenced by build_app_from_root_native().

◆ json_find_string()

char * json_find_string ( const char * text,
const char * key )

Finds the first JSON string value associated with a key.

Parameters
textJSON text to search.
keyKey name to locate.
Returns
Newly allocated string value, or NULL when the key is not found.

Definition at line 58 of file native_json_config.c.

References json_find_string_after().

Referenced by add_runtime_app_native(), build_app_from_root_native(), capture_migrate_verify_report_json(), load_app_runtime_for_single_app(), load_app_runtime_from_artifact_native(), load_runtime_stack(), match_app_root_in_directory(), and resolve_website_root().

◆ json_find_string_after()

char * json_find_string_after ( const char * text,
const char * key,
const char * start_at )

Finds a JSON string value for a key after a given scan position.

Parameters
textJSON text to search.
keyKey name to locate.
start_atPointer within text where scanning should begin.
Returns
Newly allocated string value, or NULL when the key is not found.

Definition at line 20 of file native_json_config.c.

References dup_range().

Referenced by json_find_string(), json_find_string_in_section(), and native_dispatch_response_file_for_request().

◆ json_find_string_in_section()

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.

Parameters
textJSON text to search.
sectionSection name that should contain the key.
keyKey name to locate inside the section.
Returns
Newly allocated string value, or NULL when the key is not found.

Definition at line 62 of file native_json_config.c.

References json_find_string_after().

Referenced by app_runtime_host_profile_native(), build_app_from_root_native(), load_app_local_config_native(), load_app_runtime_for_single_app(), load_app_runtime_from_artifact_native(), native_metadata_artifact_value(), native_migration_fixture_path(), and resolve_seed_entrypoint_native().