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_list.h" 38 #include "shcmdparse.h" 39 #include "show.h" 40 41 #ifdef __cplusplus 42 #if __cplusplus 43 extern "C" { 44 #endif /* __cplusplus */ 45 #endif /* __cplusplus */ 46 47 typedef BOOL (*CmdVerifyTransID)(UINT32 transID); 48 49 typedef struct { 50 CmdType cmdType; 51 const CHAR *cmdKey; 52 UINT32 paraNum; 53 CmdCallBackFunc cmdHook; 54 } CmdItem; 55 56 typedef struct { 57 LOS_DL_LIST list; 58 CmdItem *cmd; 59 } CmdItemNode; 60 61 /* global info for shell module */ 62 typedef struct { 63 CmdItemNode cmdList; 64 UINT32 listNum; 65 UINT32 initMagicFlag; 66 UINT32 muxLock; 67 CmdVerifyTransID transIdHook; 68 } CmdModInfo; 69 70 typedef struct { 71 UINT32 count; 72 LOS_DL_LIST list; 73 CHAR cmdString[0]; 74 } CmdKeyLink; 75 76 #define SHELLCMD_ENTRY(l, cmdType, cmdKey, paraNum, cmdHook) \ 77 CmdItem l LOS_HAL_TABLE_ENTRY(shellcmd) = { \ 78 cmdType, \ 79 cmdKey, \ 80 paraNum, \ 81 cmdHook \ 82 } 83 84 #define NEED_NEW_LINE(timesPrint, lineCap) ((timesPrint) % (lineCap) == 0) 85 #define SCREEN_IS_FULL(timesPrint, lineCap) ((timesPrint) >= ((lineCap) * DEFAULT_SCREEN_HEIGNT)) 86 87 extern CmdModInfo *OsCmdInfoGet(VOID); 88 extern UINT32 OsCmdExec(CmdParsed *cmdParsed); 89 extern UINT32 OsCmdKeyShift(const CHAR *cmdKey, CHAR *cmdOut, UINT32 size); 90 extern UINT32 OsShellKeyInit(ShellCB *shellCB); 91 extern VOID OsShellKeyDeInit(CmdKeyLink *cmdKeyLink); 92 extern UINT32 OsShellSysCmdRegister(VOID); 93 extern INT32 VfsNormalizePath(const CHAR *directory, const CHAR *filename, CHAR **pathname); 94 extern INT32 OsShellCmdDate(INT32 argc, const CHAR **argv); 95 extern INT32 OsShellCmdDumpTask(INT32 argc, const CHAR **argv); 96 extern UINT32 OsShellCmdFree(INT32 argc, const CHAR **argv); 97 extern UINT32 OsShellCmdWaterLine(INT32 argc, const CHAR **argv); 98 extern UINT32 lwip_ifconfig(INT32 argc, const CHAR **argv); 99 extern UINT32 OsShellPing(INT32 argc, const CHAR **argv); 100 extern INT32 OsShellCmdTouch(INT32 argc, const CHAR **argv); 101 extern INT32 OsShellCmdLs(INT32 argc, const CHAR **argv); 102 extern INT32 OsShellCmdPwd(INT32 argc, const CHAR **argv); 103 extern INT32 OsShellCmdCd(INT32 argc, const CHAR **argv); 104 extern INT32 OsShellCmdCat(INT32 argc, const CHAR **argv); 105 extern INT32 OsShellCmdRm(INT32 argc, const CHAR **argv); 106 extern INT32 OsShellCmdRmdir(INT32 argc, const CHAR **argv); 107 extern INT32 OsShellCmdMkdir(INT32 argc, const CHAR **argv); 108 extern INT32 OsShellCmdCp(INT32 argc, const CHAR **argv); 109 extern INT32 OsShellCmdHelp(INT32 argc, const CHAR **argv); 110 extern UINT32 OsCmdInit(VOID); 111 112 #ifdef __cplusplus 113 #if __cplusplus 114 } 115 #endif 116 #endif 117 118 #endif /* _HWLITEOS_SHELL_SHCMD_H */ 119