Pharos 0.7.23
Modern Web Framework & Web App Hosting Service.
Loading...
Searching...
No Matches
native_json_config.h
Go to the documentation of this file.
1/**
2 * @file
3 * @brief Declares lightweight JSON and conf value lookup helpers.
4 */
5
6#ifndef PHAROS_NATIVE_JSON_CONFIG_H
7#define PHAROS_NATIVE_JSON_CONFIG_H
8
9/** @name JSON and conf lookup helpers
10 * @{
11 */
12/**
13 * @brief Finds a JSON string value for a key after a given scan position.
14 * @param text JSON text to search.
15 * @param key Key name to locate.
16 * @param start_at Pointer within text where scanning should begin.
17 * @return Newly allocated string value, or NULL when the key is not found.
18 */
19char *json_find_string_after(const char *text, const char *key, const char *start_at);
20/**
21 * @brief Finds the first JSON string value associated with a key.
22 * @param text JSON text to search.
23 * @param key Key name to locate.
24 * @return Newly allocated string value, or NULL when the key is not found.
25 */
26char *json_find_string(const char *text, const char *key);
27/**
28 * @brief Finds a JSON string value for a key inside a named section object.
29 * @param text JSON text to search.
30 * @param section Section name that should contain the key.
31 * @param key Key name to locate inside the section.
32 * @return Newly allocated string value, or NULL when the key is not found.
33 */
34char *json_find_string_in_section(const char *text, const char *section, const char *key);
35/**
36 * @brief Extracts the raw JSON array text for a key inside a named section.
37 * @param text JSON text to search.
38 * @param section Section name that should contain the array.
39 * @param key Array-valued key to locate.
40 * @return Newly allocated raw array text, or NULL when the array is not found.
41 */
42char *json_extract_array_in_section(const char *text, const char *section, const char *key);
43/**
44 * @brief Looks up one key from Pharos conf-format text.
45 * @param text Config text to search.
46 * @param key Config key to locate.
47 * @return Newly allocated config value, or NULL when the key is not found.
48 */
49char *conf_lookup_value_in_text(const char *text, const char *key);
50/**
51 * @brief Reads a Pharos conf file and looks up one key.
52 * @param path Path to the config file.
53 * @param key Config key to locate.
54 * @return Newly allocated config value, or NULL when the key is not found or the file cannot be read.
55 */
56char *conf_lookup_value(const char *path, const char *key);
57
58
59/** @} */
60#endif
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 * 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.
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 * 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.