Document of c-modernization-kit (porter) 1.0.0
Loading...
Searching...
No Matches
potrOpenServiceFromConfig.c
Go to the documentation of this file.
1
13
14#include <inttypes.h>
15#include <porter_const.h>
16#include <porter.h>
17
18#include "../protocol/config.h"
19#include "../infra/potrLog.h"
20
21/* doxygen コメントは、ヘッダに記載 */
23 int64_t service_id,
24 PotrRole role,
25 PotrRecvCallback callback,
26 PotrHandle *handle)
27{
28 PotrGlobalConfig global;
29 PotrServiceDef service;
30
32 "potrOpenServiceFromConfig: service_id=%" PRId64 " config=%s",
33 service_id,
34 config_path != NULL ? config_path : "(null)");
35
36 if (config_path == NULL || handle == NULL)
37 {
39 "potrOpenServiceFromConfig: invalid argument"
40 " (config_path=%p handle=%p)",
41 (const void *)config_path, (const void *)handle);
42 return POTR_ERROR;
43 }
44
45 if (config_load_global(config_path, &global) != POTR_SUCCESS)
46 {
48 "potrOpenServiceFromConfig: service_id=%" PRId64
49 " failed to load global config from '%s'",
50 service_id, config_path);
51 return POTR_ERROR;
52 }
53
54 if (config_load_service(config_path, service_id, &service) != POTR_SUCCESS)
55 {
57 "potrOpenServiceFromConfig: service_id=%" PRId64 " not found in '%s'",
58 service_id, config_path);
59 return POTR_ERROR;
60 }
61
62 return potrOpenService(&global, &service, role, callback, handle);
63}
int config_load_service(const char *config_path, int64_t service_id, PotrServiceDef *def)
設定ファイルから指定サービスの定義を読み込みます。
Definition config.c:508
int config_load_global(const char *config_path, PotrGlobalConfig *global)
設定ファイルから [global] セクションを読み込みます。
Definition config.c:160
設定ファイル解析モジュールの内部ヘッダー。
#define POTR_SUCCESS
成功の戻り値を表す定数。
#define POTR_ERROR
失敗の戻り値を表す定数。
通信ライブラリ (動的リンク用) のヘッダーファイル。
#define POTR_API
呼び出し規約マクロ。
Definition porter.h:46
POTR_EXPORT int POTR_API potrOpenService(const PotrGlobalConfig *global, const PotrServiceDef *service, PotrRole role, PotrRecvCallback callback, PotrHandle *handle)
設定構造体から指定サービスを開きます。
#define POTR_EXPORT
DLL エクスポート/インポート制御マクロ。
Definition porter.h:37
通信ライブラリの定数ファイル。
@ POTR_TRACE_ERROR
エラー。操作の失敗を記録。TRACE_LV_ERROR (1) と同値。
@ POTR_TRACE_VERBOSE
詳細情報 (デバッグ)。TRACE_LV_VERBOSE (4) と同値。
void(* PotrRecvCallback)(int64_t service_id, PotrPeerId peer_id, PotrEvent event, const void *data, size_t len)
受信コールバック関数型 (全通信種別共通)。
struct PotrContext_ * PotrHandle
セッションハンドル。
PotrRole
役割種別。
porter 内部ログマクロ定義ヘッダー。
#define POTR_LOG(level,...)
porter 内部ログ出力マクロ。
Definition potrLog.h:68
POTR_EXPORT int POTR_API potrOpenServiceFromConfig(const char *config_path, int64_t service_id, PotrRole role, PotrRecvCallback callback, PotrHandle *handle)
設定ファイルから指定サービスを開きます。
グローバル設定。
サービス定義。