62 lines
1.6 KiB
C
62 lines
1.6 KiB
C
#ifndef __ACE_SDK_SERVER_TICKET_IMPL_H__
|
|
#define __ACE_SDK_SERVER_TICKET_IMPL_H__
|
|
|
|
#include "ace_sdk_server.h"
|
|
|
|
struct __AceSdkTicket;
|
|
|
|
#if defined(ACE_CGO)
|
|
extern int __ace_sdk_ticket_init_succ;
|
|
#elif defined(_WIN32) && defined(_MSC_VER)
|
|
__declspec(selectany) int __ace_sdk_ticket_init_succ = 0;
|
|
#else
|
|
__attribute__((weak)) int __ace_sdk_ticket_init_succ = 0;
|
|
#endif
|
|
|
|
inline int ace_sdk_server_init_ticket() {
|
|
int ret = 0;
|
|
if (!__ace_sdk_init_succ)
|
|
{
|
|
return -1;
|
|
}
|
|
if (__ace_sdk_ticket_init_succ)
|
|
{
|
|
return ret;
|
|
}
|
|
|
|
typedef int32_t(ACE_SDK_CALL* __AceSdkServerInitTicket)();
|
|
__AceSdkServerInitTicket func = (__AceSdkServerInitTicket)__ace_sdk_get_symbol("__ace_sdk_server_init_ticket");
|
|
if (func == NULL)
|
|
{
|
|
return -1;
|
|
}
|
|
ret = func();
|
|
if (ret == 0)
|
|
{
|
|
__ace_sdk_ticket_init_succ = 1;
|
|
}
|
|
return ret;
|
|
}
|
|
|
|
inline AceSdkResult ace_sdk_server_get_ticket(const AceSdkAccount* account, struct __AceSdkTicket* ticket)
|
|
{
|
|
if (ace_sdk_server_init_ticket() != 0)
|
|
{
|
|
return ACE_SDK_RESULT_INIT_NOT_CALLED_OR_FAILED;
|
|
}
|
|
|
|
if (account == NULL || ticket == NULL)
|
|
{
|
|
return ACE_SDK_RESULT_INVALID_PARAMETER;
|
|
}
|
|
typedef int32_t(ACE_SDK_CALL* __AceSdkServerGetTicket)(const AceSdkAccount*, struct __AceSdkTicket*);
|
|
__AceSdkServerGetTicket func = (__AceSdkServerGetTicket)__ace_sdk_get_symbol("__ace_sdk_server_get_ticket");
|
|
if (func == NULL)
|
|
{
|
|
return ACE_SDK_RESULT_SYMBOL_NOT_FOUND;
|
|
}
|
|
func(account, ticket);
|
|
return ACE_SDK_RESULT_OK;
|
|
}
|
|
|
|
#endif // __ACE_SDK_SERVER_TICKET_IMPL_H__
|