|
@@ -783,7 +783,7 @@ static unsigned int __stdcall work_proc(void *arg)
|
|
|
}
|
|
|
|
|
|
#ifdef RVC_OS_WIN
|
|
|
-static int init_decode_func()
|
|
|
+static int init_decode_func(const bizchan_config_t* config, const bizchan_callback_t* cb)
|
|
|
{
|
|
|
int ret = -1;
|
|
|
if (!encodestring) {
|
|
@@ -827,19 +827,25 @@ static int init_decode_func()
|
|
|
}
|
|
|
|
|
|
#else
|
|
|
-static int init_decode_func()
|
|
|
+static int init_decode_func(const bizchan_config_t* config, const bizchan_callback_t* cb)
|
|
|
{
|
|
|
int ret = -1;
|
|
|
if (!encodestring) {
|
|
|
- HMODULE hInst = LoadLibraryA("acmstrenc.so");
|
|
|
+ HMODULE hInst = LoadLibraryA("libacmstrenc.so");
|
|
|
if (hInst) {
|
|
|
encodestring = (lpfn_cryptionfun)GetProcAddress(hInst, "encodestring");
|
|
|
}
|
|
|
- if (!encodestring)
|
|
|
+ else {
|
|
|
+ cb->dbg(NULL, 2, "libacmstrenc LoadLibraryA failed", cb->user_data);
|
|
|
+ }
|
|
|
+ if (!encodestring) {
|
|
|
+ cb->dbg(NULL, 2, "libacmstrenc GetProcAddress failed", cb->user_data);
|
|
|
return ret;
|
|
|
+ }
|
|
|
+
|
|
|
}
|
|
|
if (!decodestring) {
|
|
|
- HMODULE hInst = LoadLibraryA("acmstrdec.so");
|
|
|
+ HMODULE hInst = LoadLibraryA("libacmstrdec.so");
|
|
|
if (hInst) {
|
|
|
decodestring = (lpfn_cryptionfun)GetProcAddress(hInst, "decodestring");
|
|
|
}
|
|
@@ -847,26 +853,29 @@ static int init_decode_func()
|
|
|
return ret;
|
|
|
}
|
|
|
|
|
|
- if (!encodestring_mobile) {
|
|
|
- HMODULE hInst = LoadLibraryA("acmstrenc_mobile.so");
|
|
|
- if (hInst) {
|
|
|
- encodestring_mobile = (lpfn_cryptionfun)GetProcAddress(hInst, "encodestring");
|
|
|
+ if (1 == config->crypt_type) {
|
|
|
+ if (!encodestring_mobile) {
|
|
|
+ HMODULE hInst = LoadLibraryA("libacmstrenc_mobile.so");
|
|
|
+ if (hInst) {
|
|
|
+ encodestring_mobile = (lpfn_cryptionfun)GetProcAddress(hInst, "encodestring");
|
|
|
+ }
|
|
|
+ if (!encodestring_mobile)
|
|
|
+ return ret;
|
|
|
}
|
|
|
- if (!encodestring_mobile)
|
|
|
- return ret;
|
|
|
- }
|
|
|
- if (!decodestring_mobile) {
|
|
|
- HMODULE hInst = LoadLibraryA("acmstrdec_mobile.so");
|
|
|
- if (hInst) {
|
|
|
- decodestring_mobile = (lpfn_cryptionfun)GetProcAddress(hInst, "decodestring");
|
|
|
+ if (!decodestring_mobile) {
|
|
|
+ HMODULE hInst = LoadLibraryA("libacmstrdec_mobile.so");
|
|
|
+ if (hInst) {
|
|
|
+ decodestring_mobile = (lpfn_cryptionfun)GetProcAddress(hInst, "decodestring");
|
|
|
+ }
|
|
|
+ if (!decodestring_mobile)
|
|
|
+ return ret;
|
|
|
}
|
|
|
- if (!decodestring_mobile)
|
|
|
- return ret;
|
|
|
}
|
|
|
|
|
|
- if (encodestring && decodestring && encodestring_mobile && decodestring_mobile) {
|
|
|
+ if (encodestring && decodestring) {
|
|
|
ret = 0;
|
|
|
}
|
|
|
+
|
|
|
return ret;
|
|
|
}
|
|
|
#endif
|
|
@@ -875,16 +884,25 @@ BIZCHAN_API(int) bizchan_create(const bizchan_config_t *config, const bizchan_ca
|
|
|
{
|
|
|
bizchan_t *chan = NULL;
|
|
|
|
|
|
- if (-1 == init_decode_func()){
|
|
|
+ if (-1 == init_decode_func(config, cb)){
|
|
|
+ cb->dbg(chan, 2, "init_decode_func failed", cb->user_data);
|
|
|
return -1;
|
|
|
}
|
|
|
|
|
|
- if (!config || !p_chan)
|
|
|
+ if (!config || !p_chan) {
|
|
|
+ cb->dbg(chan, 2, "config or chan is null, failed", cb->user_data);
|
|
|
return -1;
|
|
|
- if (config_check(config) != 0)
|
|
|
+ }
|
|
|
+
|
|
|
+ if (config_check(config) != 0) {
|
|
|
+ cb->dbg(chan, 2, "config_check failed", cb->user_data);
|
|
|
return -1;
|
|
|
- if (callback_check(cb) != 0)
|
|
|
+ }
|
|
|
+
|
|
|
+ if (callback_check(cb) != 0) {
|
|
|
+ cb->dbg(chan, 2, "callback_check failed", cb->user_data);
|
|
|
return -1;
|
|
|
+ }
|
|
|
|
|
|
chan = (bizchan_t*)malloc(sizeof(bizchan_t));
|
|
|
if (!chan)
|
|
@@ -905,10 +923,12 @@ BIZCHAN_API(int) bizchan_create(const bizchan_config_t *config, const bizchan_ca
|
|
|
goto on_error;
|
|
|
|
|
|
*p_chan = chan;
|
|
|
+ cb->dbg(chan, 0, "bizchan_create success", cb->user_data);
|
|
|
|
|
|
return 0;
|
|
|
|
|
|
on_error:
|
|
|
+ cb->dbg(chan, 2, "bizchan_create on_error", cb->user_data);
|
|
|
bizchan_destroy(chan);
|
|
|
return -1;
|
|
|
}
|
|
@@ -961,10 +981,15 @@ BIZCHAN_API(void*) bizchan_get_tag(bizchan_t *chan)
|
|
|
|
|
|
BIZCHAN_API(int) bizchan_start_connect(bizchan_t *chan)
|
|
|
{
|
|
|
- if (!chan)
|
|
|
+ if (!chan) {
|
|
|
+ chan->cb.dbg(chan, 2, "chan is null", chan->cb.user_data);
|
|
|
return -1;
|
|
|
- if (chan->work_thread)
|
|
|
+ }
|
|
|
+
|
|
|
+ if (chan->work_thread) {
|
|
|
+ chan->cb.dbg(chan, 2, "work_thread exsit!!!", chan->cb.user_data);
|
|
|
return -1;
|
|
|
+ }
|
|
|
|
|
|
WSAResetEvent(chan->evt);
|
|
|
|
|
@@ -976,6 +1001,7 @@ BIZCHAN_API(int) bizchan_start_connect(bizchan_t *chan)
|
|
|
}
|
|
|
|
|
|
// we now return, when connected, on_connect will invoked in work_proc thread
|
|
|
+ chan->cb.dbg(chan, 0, "bizchan_start_connect success", chan->cb.user_data);
|
|
|
|
|
|
return 0;
|
|
|
}
|