1 /*
2  * Copyright (C) 2022 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 "coauth_funcs.h"
17 
18 #include "securec.h"
19 
20 #include "adaptor_algorithm.h"
21 #include "adaptor_log.h"
22 #include "adaptor_memory.h"
23 #include "adaptor_time.h"
24 #include "defines.h"
25 #include "executor_message.h"
26 #include "pool.h"
27 
RegisterExecutor(const ExecutorInfoHal * registerInfo,uint64_t * executorIndex)28 ResultCode RegisterExecutor(const ExecutorInfoHal *registerInfo, uint64_t *executorIndex)
29 {
30     if (registerInfo == NULL || executorIndex == NULL) {
31         LOG_ERROR("param is null");
32         return RESULT_BAD_PARAM;
33     }
34 
35     ExecutorInfoHal executorInfo = *registerInfo;
36     ResultCode ret = RegisterExecutorToPool(&executorInfo);
37     if (ret != RESULT_SUCCESS) {
38         LOG_ERROR("register failed");
39         return ret;
40     }
41     *executorIndex = executorInfo.executorIndex;
42     return RESULT_SUCCESS;
43 }
44 
UnRegisterExecutor(uint64_t executorIndex)45 ResultCode UnRegisterExecutor(uint64_t executorIndex)
46 {
47     ResultCode ret = UnregisterExecutorToPool(executorIndex);
48     if (ret != RESULT_SUCCESS) {
49         LOG_ERROR("unregister failed");
50     }
51     return ret;
52 }