init_cmds.h 2.0 KB
Newer Older
W
wenjun 已提交
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
/*
 * Copyright (c) 2020 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.
 */

#ifndef BASE_STARTUP_INITLITE_CMDS_H
#define BASE_STARTUP_INITLITE_CMDS_H

#ifdef __cplusplus
#if __cplusplus
extern "C" {
#endif
#endif

Z
zhong_ning 已提交
25
#define MAX_CMD_NAME_LEN 32
Z
zhong_ning 已提交
26 27 28 29
#define MAX_CMD_CONTENT_LEN 256
#define MAX_CMD_CNT_IN_ONE_JOB 200
#define MAX_COPY_BUF_SIZE 256
#define DEFAULT_COPY_ARGS_CNT 2
Z
zhong_ning 已提交
30 31 32 33 34 35

#ifndef OHOS_LITE
// Limit max length of parameter value to 96
#define MAX_PARAM_VALUE_LEN 96
// Limit max length of parameter name to 96
#define MAX_PARAM_NAME_LEN 96
S
sun_fan 已提交
36 37 38 39
#else
// For lite ohos, do not support parameter operation
#define MAX_PARAM_VALUE_LEN 0
#define MAX_PARAM_NAME_LEN 0
Z
zhong_ning 已提交
40 41
#endif

W
wenjun 已提交
42 43 44 45 46 47
// one cmd line
typedef struct {
    char name[MAX_CMD_NAME_LEN + 1];
    char cmdContent[MAX_CMD_CONTENT_LEN + 1];
} CmdLine;

Z
zhong_ning 已提交
48 49 50 51 52
struct CmdArgs {
    int argc;
    char **argv;
};

S
sun_fan 已提交
53
int GetParamValue(const char *symValue, char *paramValue, unsigned int paramLen);
S
sun_fan 已提交
54
struct CmdArgs* GetCmd(const char *cmdContent, const char *delim, int argsCount);
S
sun_fan 已提交
55
void FreeCmd(struct CmdArgs *cmd);
Z
zhong_ning 已提交
56

W
wenjun 已提交
57 58 59
void ParseCmdLine(const char* cmdStr, CmdLine* resCmd);
void DoCmd(const CmdLine* curCmd);

Z
zhong_ning 已提交
60
void DoCmdByName(const char *name, const char *cmdContent);
S
sun_fan 已提交
61 62 63
const char *GetMatchCmd(const char *cmdStr, unsigned int *index);
const char *GetCmdKey(unsigned int index);

W
wenjun 已提交
64 65 66 67 68 69 70
#ifdef __cplusplus
#if __cplusplus
}
#endif
#endif

#endif // BASE_STARTUP_INITLITE_CMDS_H