From 50ac591a82fb5cdf24a40ace241bce345b299e59 Mon Sep 17 00:00:00 2001 From: yejian <596306006@qq.com> Date: Sun, 17 Sep 2023 13:19:02 +0800 Subject: [PATCH] set_print --- c_wrapper/export.go | 12 +----------- c_wrapper/protocol.go | 17 +++++++++++++++++ 2 files changed, 18 insertions(+), 11 deletions(-) diff --git a/c_wrapper/export.go b/c_wrapper/export.go index b1253d1..8ed37dd 100644 --- a/c_wrapper/export.go +++ b/c_wrapper/export.go @@ -12,14 +12,6 @@ extern void Call_CB_S_I_S_S(CB_S_I_S_S func,char *,int errCode,char* errMsg,char extern void Call_CB_S_I_S_S_I(CB_S_I_S_S_I func,char *,int errCode,char* errMsg,char* data,int progress); extern CB_S DebugPrint; -int CheckDebugPrint(){ - if(DebugPrint == NULL){ - return 0; - }else{ - return 1; - } -} - */ import "C" @@ -33,9 +25,7 @@ func set_print(print C.CB_S) { } func DebugPrint(info string) { - if C.CheckDebugPrint() > 0 { - C.Call_CB_S(C.DebugPrint, C.CString(info)) - } + C.Call_CB_S(C.DebugPrint, C.CString("DLL:"+info)) } type Base struct { diff --git a/c_wrapper/protocol.go b/c_wrapper/protocol.go index 65ef0f2..c9aa97e 100644 --- a/c_wrapper/protocol.go +++ b/c_wrapper/protocol.go @@ -12,12 +12,20 @@ CB_S DebugPrint; void Call_CB_S(CB_S func,char* data) { + if(func == NULL){ + printf("callback func is null\n"); + return; + } func(data); } void Call_CB_I_S(CB_I_S func,int event,char* data) { + if(func == NULL){ + printf("callback func is null\n"); + return; + } func(event,data); if (data != NULL && data[0] != '\0') { @@ -27,6 +35,10 @@ void Call_CB_I_S(CB_I_S func,int event,char* data) } void Call_CB_S_I_S_S(CB_S_I_S_S func,char* operationID, int errCode,char* errMsg,char* data) { + if(func == NULL){ + printf("callback func is null\n"); + return; + } func(operationID,errCode,errMsg,data); if (errMsg != NULL && errMsg[0] != '\0') { @@ -46,6 +58,10 @@ void Call_CB_S_I_S_S(CB_S_I_S_S func,char* operationID, int errCode,char* errMsg } void Call_CB_S_I_S_S_I(CB_S_I_S_S_I func,char* operationID,int errCode,char* errMsg,char* data,int progress) { + if(func == NULL){ + printf("callback func is null\n"); + return; + } func(operationID,errCode,errMsg,data,progress); if (errMsg != NULL && errMsg[0] != '\0') { @@ -63,6 +79,7 @@ void Call_CB_S_I_S_S_I(CB_S_I_S_S_I func,char* operationID,int errCode,char* err free(operationID); } } + enum CONN_EVENT{ CONNECTING, CONNECT_SUCCESS,