mirror of
https://github.com/openharmony/startup_init_lite.git
synced 2026-07-23 13:35:22 -04:00
4056bc9ba4
Signed-off-by: sun_fan <sun_fan@hoperun.com>
56 lines
1.8 KiB
C
56 lines
1.8 KiB
C
/*
|
|
* Copyright (c) 2021 Huawei Device Co., Ltd.
|
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
* you may not use this file except in compliance with the License.
|
|
* You may obtain a copy of the License at
|
|
*
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
|
*
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
* See the License for the specific language governing permissions and
|
|
* limitations under the License.
|
|
*/
|
|
|
|
#include <string.h>
|
|
#include <stdio.h>
|
|
#include "sys_param.h"
|
|
|
|
#define HELP_PARAM "--help"
|
|
#define BUFFER_SIZE 256
|
|
|
|
static void ProcessParam(ParamHandle handle, void* cookie)
|
|
{
|
|
SystemGetParameterName(handle, (char*)cookie, BUFFER_SIZE);
|
|
u_int32_t size = BUFFER_SIZE;
|
|
SystemGetParameterValue(handle, ((char*)cookie) + BUFFER_SIZE, &size);
|
|
printf("\t%s = %s \n", (char*)cookie, ((char*)cookie) + BUFFER_SIZE);
|
|
}
|
|
|
|
int main(int argc, char* argv[])
|
|
{
|
|
if (argc == 1) { // 显示所有的记录
|
|
char value[BUFFER_SIZE + BUFFER_SIZE] = {0};
|
|
SystemTraversalParameter(ProcessParam, (void*)value);
|
|
return 0;
|
|
}
|
|
if (argc == 2 && strncmp(argv[1], HELP_PARAM, strlen(HELP_PARAM)) == 0) { // 显示帮助
|
|
printf("usage: getparam NAME VALUE\n");
|
|
return 0;
|
|
}
|
|
if (argc != 2) {
|
|
printf("usage: getparam NAME VALUE\n");
|
|
return 0;
|
|
}
|
|
char value[BUFFER_SIZE] = {0};
|
|
u_int32_t size = BUFFER_SIZE;
|
|
int ret = SystemGetParameter(argv[1], value, &size);
|
|
if (ret == 0) {
|
|
printf("%s \n", value);
|
|
} else {
|
|
printf("getparam %s %s fail\n", argv[1], value);
|
|
}
|
|
|
|
}
|