Document of c-modernization-kit (porter) 1.0.0
Loading...
Searching...
No Matches
config.h File Reference

設定ファイル解析モジュールの内部ヘッダー。 More...

#include <porter_type.h>
Include dependency graph for config.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

int config_load_global (const char *config_path, PotrGlobalConfig *global)
 設定ファイルから [global] セクションを読み込みます。
int config_load_service (const char *config_path, int64_t service_id, PotrServiceDef *def)
 設定ファイルから指定サービスの定義を読み込みます。
int config_list_service_ids (const char *config_path, int64_t **ids_out, int *count_out)
 設定ファイルに登録されているすべてのサービス ID を列挙します。

Detailed Description

設定ファイル解析モジュールの内部ヘッダー。

Author
c-modernization-kit sample team
Date
2026/03/04
Version
1.0.0

Definition in file config.h.

Function Documentation

◆ config_load_global()

int config_load_global ( const char * config_path,
PotrGlobalConfig * global )
extern

設定ファイルから [global] セクションを読み込みます。

Parameters
[in]config_path設定ファイルのパス。
[out]global読み込み結果を格納する構造体へのポインタ。
Returns
成功時は POTR_SUCCESS、失敗時は POTR_ERROR を返します。

[global] セクションが存在しない場合はデフォルト値を設定します。

Definition at line 160 of file config.c.

References CONFIG_KEY_MAX, CONFIG_LINE_MAX, CONFIG_SECTION_MAX, CONFIG_VAL_MAX, PotrGlobalConfig::health_interval_ms, PotrGlobalConfig::health_timeout_ms, PotrGlobalConfig::max_message_size, PotrGlobalConfig::max_payload, open_config_file_read(), parse_kv(), POTR_DEFAULT_HEALTH_INTERVAL_MS, POTR_DEFAULT_HEALTH_TIMEOUT_MS, POTR_DEFAULT_MAX_PAYLOAD, POTR_DEFAULT_WINDOW_SIZE, POTR_ERROR, POTR_LOG, POTR_MAX_MESSAGE_SIZE, POTR_SEND_QUEUE_DEPTH, POTR_SUCCESS, POTR_TRACE_VERBOSE, PotrGlobalConfig::reorder_timeout_ms, PotrGlobalConfig::send_queue_depth, PotrGlobalConfig::tcp_health_interval_ms, PotrGlobalConfig::tcp_health_timeout_ms, trim(), and PotrGlobalConfig::window_size.

Referenced by potrOpenServiceFromConfig().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ config_load_service()

int config_load_service ( const char * config_path,
int64_t service_id,
PotrServiceDef * def )
extern

設定ファイルから指定サービスの定義を読み込みます。

Parameters
[in]config_path設定ファイルのパス。
[in]service_id読み込むサービスの ID。
[out]def読み込み結果を格納する構造体へのポインタ。
Returns
成功時は POTR_SUCCESS、サービスが見つからない場合は POTR_ERROR を返します。

[service.<id>] 形式のセクション名から <id> 部分を取得し、service_id と照合します。
サービスの識別子はセクション名の <id> であり、ポート番号とは無関係です。

Definition at line 508 of file config.c.

References apply_service_kv(), CONFIG_KEY_MAX, CONFIG_LINE_MAX, CONFIG_SECTION_MAX, CONFIG_VAL_MAX, PotrServiceDef::connect_timeout_ms, PotrServiceDef::dst_addr, PotrServiceDef::dst_port, PotrServiceDef::health_interval_ms, PotrServiceDef::health_timeout_ms, PotrServiceDef::max_peers, open_config_file_read(), PotrServiceDef::pack_wait_ms, parse_kv(), POTR_DEFAULT_CONNECT_TIMEOUT_MS, POTR_DEFAULT_PACK_WAIT_MS, POTR_DEFAULT_RECONNECT_INTERVAL_MS, POTR_DEFAULT_TTL, POTR_ERROR, POTR_LOG, POTR_SUCCESS, POTR_TRACE_VERBOSE, PotrServiceDef::reconnect_interval_ms, PotrServiceDef::service_id, PotrServiceDef::src_addr, PotrServiceDef::src_port, trim(), PotrServiceDef::ttl, and PotrServiceDef::type.

Referenced by potrGetServiceType(), and potrOpenServiceFromConfig().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ config_list_service_ids()

int config_list_service_ids ( const char * config_path,
int64_t ** ids_out,
int * count_out )
extern

設定ファイルに登録されているすべてのサービス ID を列挙します。

Parameters
[in]config_path設定ファイルのパス。
[out]ids_outサービス ID 配列へのポインタを格納する変数。 呼び出し元が free(*ids_out) の責務を持つ。
[out]count_out列挙したサービス ID 数。
Returns
成功時は POTR_SUCCESS、失敗時は POTR_ERROR を返します。

初期容量 POTR_MAX_SERVICES で配列を確保し、超過時は realloc で 2 倍に拡張します。

Definition at line 628 of file config.c.

References CONFIG_LINE_MAX, CONFIG_SECTION_MAX, open_config_file_read(), POTR_ERROR, POTR_MAX_SERVICES, POTR_SUCCESS, and trim().

Here is the call graph for this function: