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

potrGetServiceType 関数の実装。 More...

#include <porter_const.h>
#include <porter.h>
#include "../protocol/config.h"
Include dependency graph for potrGetServiceType.c:

Go to the source code of this file.

Functions

POTR_EXPORT int POTR_API potrGetServiceType (const char *config_path, int64_t service_id, PotrType *type)
 設定ファイルから指定サービスの通信種別を取得します。

Detailed Description

potrGetServiceType 関数の実装。

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

Definition in file potrGetServiceType.c.

Function Documentation

◆ potrGetServiceType()

POTR_EXPORT int POTR_API potrGetServiceType ( const char * config_path,
int64_t service_id,
PotrType * type )

設定ファイルから指定サービスの通信種別を取得します。

Parameters
[in]config_path設定ファイルのパス。
[in]service_id照会するサービスの ID。
[out]type成功時に通信種別 (PotrType) を格納するポインタ。
Returns
成功時は POTR_SUCCESS、失敗時は POTR_ERROR を返します。

設定ファイルを解析して指定サービスの通信種別を返します。
potrOpenService() の前に呼び出すことで、ロール・コールバックの要否を アプリケーション側で判断できます。
本関数はソケットの作成や通信スレッドの起動を行いません。

使用例
PotrType type;
if (potrGetServiceType("porter-services.conf", 1031, &type) == POTR_SUCCESS) {
if (type == POTR_TYPE_UNICAST_BIDIR) {
// unicast_bidir: コールバックが必須
potrOpenService("porter-services.conf", 1031,
}
}
#define POTR_SUCCESS
成功の戻り値を表す定数。
POTR_EXPORT int POTR_API potrGetServiceType(const char *config_path, int64_t service_id, PotrType *type)
設定ファイルから指定サービスの通信種別を取得します。
POTR_EXPORT int POTR_API potrOpenService(const PotrGlobalConfig *global, const PotrServiceDef *service, PotrRole role, PotrRecvCallback callback, PotrHandle *handle)
設定構造体から指定サービスを開きます。
PotrType
通信種別。
Definition porter_type.h:85
@ POTR_TYPE_UNICAST_BIDIR
双方向 1:1 通信 (UDP ユニキャスト)。
Definition porter_type.h:94
@ POTR_ROLE_SENDER
送信者。
static void on_recv(int64_t service_id, PotrPeerId peer_id, PotrEvent event, const void *data, size_t len)
受信コールバック関数。
Definition recv.c:122
スレッド セーフティ
本関数はスレッドセーフです。
グローバルな共有状態にアクセスしないため、複数スレッドから並行して呼び出せます。
Warning
config_path または type が NULL の場合は失敗を返します。
指定した service_id が設定ファイルに存在しない場合は失敗を返します。

Definition at line 20 of file potrGetServiceType.c.

References config_load_service(), POTR_API, POTR_ERROR, POTR_EXPORT, POTR_SUCCESS, and PotrServiceDef::type.

Referenced by main().

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