140f5d65dSopenharmony_ci/*
240f5d65dSopenharmony_ci * Copyright (c) 2022-2023 Huawei Device Co., Ltd.
340f5d65dSopenharmony_ci * Licensed under the Apache License, Version 2.0 (the "License");
440f5d65dSopenharmony_ci * you may not use this file except in compliance with the License.
540f5d65dSopenharmony_ci * You may obtain a copy of the License at
640f5d65dSopenharmony_ci *
740f5d65dSopenharmony_ci *     http://www.apache.org/licenses/LICENSE-2.0
840f5d65dSopenharmony_ci *
940f5d65dSopenharmony_ci * Unless required by applicable law or agreed to in writing, software
1040f5d65dSopenharmony_ci * distributed under the License is distributed on an "AS IS" BASIS,
1140f5d65dSopenharmony_ci * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1240f5d65dSopenharmony_ci * See the License for the specific language governing permissions and
1340f5d65dSopenharmony_ci * limitations under the License.
1440f5d65dSopenharmony_ci */
1540f5d65dSopenharmony_ci
1640f5d65dSopenharmony_ci#include "parameter.h"
1740f5d65dSopenharmony_ci
1840f5d65dSopenharmony_ci#include <string.h>
1940f5d65dSopenharmony_ci
2040f5d65dSopenharmony_ci#include "securec.h"
2140f5d65dSopenharmony_ci
2240f5d65dSopenharmony_cistatic int g_bMockParameter = 0;
2340f5d65dSopenharmony_ci
2440f5d65dSopenharmony_civoid SetMockParameter(bool para)
2540f5d65dSopenharmony_ci{
2640f5d65dSopenharmony_ci    g_bMockParameter = para;
2740f5d65dSopenharmony_ci}
2840f5d65dSopenharmony_ci
2940f5d65dSopenharmony_cibool GetMockParameter(void)
3040f5d65dSopenharmony_ci{
3140f5d65dSopenharmony_ci    return g_bMockParameter;
3240f5d65dSopenharmony_ci}
3340f5d65dSopenharmony_ci
3440f5d65dSopenharmony_ciuint32_t FindParameter(const char *key)
3540f5d65dSopenharmony_ci{
3640f5d65dSopenharmony_ci    return 1;
3740f5d65dSopenharmony_ci}
3840f5d65dSopenharmony_ci
3940f5d65dSopenharmony_ciint GetParameterValue(uint32_t handle, char *value, uint32_t len)
4040f5d65dSopenharmony_ci{
4140f5d65dSopenharmony_ci    errno_t ret = EOK;
4240f5d65dSopenharmony_ci    if (GetMockParameter()) {
4340f5d65dSopenharmony_ci        char src[] = "true";
4440f5d65dSopenharmony_ci        ret = strncpy_s(value, len, src, strlen(src));
4540f5d65dSopenharmony_ci    } else {
4640f5d65dSopenharmony_ci        char src[] = "false";
4740f5d65dSopenharmony_ci        ret = strncpy_s(value, len, src, strlen(src));
4840f5d65dSopenharmony_ci    }
4940f5d65dSopenharmony_ci    return ret == EOK ? 1 : -1;
5040f5d65dSopenharmony_ci}