• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
3  * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
4  *
5  * Redistribution and use in source and binary forms, with or without modification,
6  * are permitted provided that the following conditions are met:
7  *
8  * 1. Redistributions of source code must retain the above copyright notice, this list of
9  *    conditions and the following disclaimer.
10  *
11  * 2. Redistributions in binary form must reproduce the above copyright notice, this list
12  *    of conditions and the following disclaimer in the documentation and/or other materials
13  *    provided with the distribution.
14  *
15  * 3. Neither the name of the copyright holder nor the names of its contributors may be used
16  *    to endorse or promote products derived from this software without specific prior written
17  *    permission.
18  *
19  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
21  * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22  * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
23  * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24  * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25  * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
26  * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
27  * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
28  * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
29  * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30  */
31 
32 #ifndef _HWLITEOS_SHELL_SHCMD_H
33 #define _HWLITEOS_SHELL_SHCMD_H
34 
35 #include "string.h"
36 #include "stdlib.h"
37 #include "los_base.h"
38 #include "los_list.h"
39 #include "shcmdparse.h"
40 #include "show.h"
41 
42 #include "los_tables.h"
43 #include "console.h"
44 
45 #ifdef  __cplusplus
46 #if  __cplusplus
47 extern "C" {
48 #endif /* __cplusplus */
49 #endif /* __cplusplus */
50 
51 typedef BOOL (*CmdVerifyTransID)(UINT32 transID);
52 
53 typedef struct {
54     CmdType cmdType;
55     const CHAR *cmdKey;
56     UINT32 paraNum;
57     CmdCallBackFunc cmdHook;
58 } CmdItem;
59 
60 typedef struct {
61     LOS_DL_LIST list;
62     CmdItem *cmd;
63 } CmdItemNode;
64 
65 /* global info for shell module */
66 typedef struct {
67     CmdItemNode cmdList;
68     UINT32 listNum;
69     UINT32 initMagicFlag;
70     LosMux muxLock;
71     CmdVerifyTransID transIdHook;
72 } CmdModInfo;
73 
74 typedef struct {
75     UINT32 count;
76     LOS_DL_LIST list;
77     CHAR cmdString[0];
78 } CmdKeyLink;
79 
80 #define SHELLCMD_ENTRY(l, cmdType, cmdKey, paraNum, cmdHook)    \
81     CmdItem l LOS_HAL_TABLE_ENTRY(shellcmd) = {                 \
82         cmdType,                                                \
83         cmdKey,                                                 \
84         paraNum,                                                \
85         cmdHook                                                 \
86     }
87 
88 #define NEED_NEW_LINE(timesPrint, lineCap) ((timesPrint) % (lineCap) == 0)
89 #define SCREEN_IS_FULL(timesPrint, lineCap) ((timesPrint) >= ((lineCap) * DEFAULT_SCREEN_HEIGHT))
90 
91 extern UINT32 OsCmdInit(VOID);
92 extern CmdModInfo *OsCmdInfoGet(VOID);
93 extern UINT32 OsCmdExec(CmdParsed *cmdParsed, CHAR *cmdStr);
94 extern UINT32 OsCmdKeyShift(const CHAR *cmdKey, CHAR *cmdOut, UINT32 size);
95 extern INT32 OsTabCompletion(CHAR *cmdKey, UINT32 *len);
96 extern VOID OsShellCmdPush(const CHAR *string, CmdKeyLink *cmdKeyLink);
97 extern VOID OsShellHistoryShow(UINT32 value, ShellCB *shellCB);
98 extern UINT32 OsShellKeyInit(ShellCB *shellCB);
99 extern VOID OsShellKeyDeInit(CmdKeyLink *cmdKeyLink);
100 extern UINT32 OsShellSysCmdRegister(VOID);
101 
102 #ifdef __cplusplus
103 #if __cplusplus
104 }
105 #endif
106 #endif
107 
108 #endif /* _HWLITEOS_SHELL_SHCMD_H */
109