import sys import os import ctypes from enum import IntEnum dir_path = os.path.dirname(os.path.realpath(__file__)) handle = ctypes.CDLL(dir_path + "/../SDK/Bin/libEOSSDK-Mac-Shipping.dylib") class CtypesEnum(IntEnum): @classmethod def from_param(cls, obj): return int(obj) EOS_EResult_ToString = handle.EOS_EResult_ToString EOS_EResult_ToString.restype = ctypes.c_char_p EOS_EResult_ToString.argtypes = [ctypes.c_int] class EOS_EpicAccountIdDetails(ctypes.Structure): pass EOS_EpicAccountId = ctypes.POINTER(EOS_EpicAccountIdDetails) # Set the argument and return types for the C functions handle.EOS_EpicAccountId_ToString.argtypes = [ EOS_EpicAccountId, ctypes.c_char_p, ctypes.POINTER(ctypes.c_int32) ] handle.EOS_EpicAccountId_ToString.restype = ctypes.c_int handle.EOS_EpicAccountId_FromString.argtypes = [ctypes.c_char_p] handle.EOS_EpicAccountId_FromString.restype = EOS_EpicAccountId # Example usage of the C functions def epic_account_id_to_string(account_id): buffer_length = 512 # You can adjust this buffer size based on your needs out_buffer = ctypes.create_string_buffer(buffer_length) in_out_buffer_length = ctypes.c_int32(buffer_length) result = handle.EOS_EpicAccountId_ToString( account_id, out_buffer, ctypes.byref(in_out_buffer_length) ) if result == 0: # 0 indicates success return out_buffer.value else: return None def epic_account_id_from_string(account_id_string): return handle.EOS_EpicAccountId_FromString(account_id_string) def is_valid(account_id): handle.EOS_EpicAccountId_IsValid.restype = ctypes.c_int handle.EOS_EpicAccountId_IsValid.argtypes = [EOS_EpicAccountId] print(handle.EOS_EpicAccountId_IsValid(account_id)) # id = epic_account_id_from_string(b'15e2c4cabad149d69d2b12d3cf06f459') # print(epic_account_id_to_string(id)) # is_valid(id)