1 /*
2 * Copyright (c) 2025 Huawei Device Co., Ltd.
3 * Licensed under the Apache License, Version 2.0 (the "License");
4 * you may not use this file except in compliance with the License.
5 * You may obtain a copy of the License at
6 *
7 * http://www.apache.org/licenses/LICENSE-2.0
8 *
9 * Unless required by applicable law or agreed to in writing, software
10 * distributed under the License is distributed on an "AS IS" BASIS,
11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 * See the License for the specific language governing permissions and
13 * limitations under the License.
14 */
15
16 #include "softbus_disc_init.h"
17 #include "softbus_init_common.h"
18 #include "softbus_error_code.h"
19 #include "comm_log.h"
20
DiscOpenFuncInit(void * soHandle)21 int32_t DiscOpenFuncInit(void *soHandle)
22 {
23 if (soHandle == NULL) {
24 COMM_LOGE(COMM_SVC, "libdsoftbus_server_plugin.z.so soHandle is null");
25 return SOFTBUS_NETWORK_DLOPEN_FAILED;
26 }
27 int32_t (*discRegisterOpenfunc)(void);
28
29 int ret = SOFTBUS_OK;
30
31 ret = SoftBusDlsym(soHandle, "DiscRegisterOpenFunc", (void**)&discRegisterOpenfunc);
32 if (ret != SOFTBUS_OK) {
33 COMM_LOGE(COMM_SVC, "dlsym DiscRegisterOpenFunc failed, ret=%d", ret);
34 return SOFTBUS_NETWORK_DLSYM_FAILED;
35 }
36
37 if (discRegisterOpenfunc() != SOFTBUS_OK) {
38 COMM_LOGE(COMM_SVC, "DiscRegisterOpenFunc return failed, ret=%d", ret);
39 return SOFTBUS_NETWORK_DISC_OPEN_FUNC_INIT_FAILED;
40 }
41
42 return ret;
43 }