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 43extern "C" { 44#endif /* __cplusplus */ 45#endif /* __cplusplus */ 46 47typedef BOOL (*CmdVerifyTransID)(UINT32 transID); 48 49typedef struct { 50 CmdType cmdType; 51 const CHAR *cmdKey; 52 UINT32 paraNum; 53 CmdCallBackFunc cmdHook; 54} CmdItem; 55 56typedef struct { 57 LOS_DL_LIST list; 58 CmdItem *cmd; 59} CmdItemNode; 60 61/* global info for shell module */ 62typedef struct { 63 CmdItemNode cmdList; 64 UINT32 listNum; 65 UINT32 initMagicFlag; 66 UINT32 muxLock; 67 CmdVerifyTransID transIdHook; 68} CmdModInfo; 69 70typedef 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 87extern CmdModInfo *OsCmdInfoGet(VOID); 88extern UINT32 OsCmdExec(CmdParsed *cmdParsed); 89extern UINT32 OsCmdKeyShift(const CHAR *cmdKey, CHAR *cmdOut, UINT32 size); 90extern UINT32 OsShellKeyInit(ShellCB *shellCB); 91extern VOID OsShellKeyDeInit(CmdKeyLink *cmdKeyLink); 92extern UINT32 OsShellSysCmdRegister(VOID); 93extern INT32 VfsNormalizePath(const CHAR *directory, const CHAR *filename, CHAR **pathname); 94extern INT32 OsShellCmdDate(INT32 argc, const CHAR **argv); 95extern INT32 OsShellCmdDumpTask(INT32 argc, const CHAR **argv); 96extern UINT32 OsShellCmdFree(INT32 argc, const CHAR **argv); 97extern UINT32 OsShellCmdWaterLine(INT32 argc, const CHAR **argv); 98extern UINT32 lwip_ifconfig(INT32 argc, const CHAR **argv); 99extern UINT32 OsShellPing(INT32 argc, const CHAR **argv); 100extern INT32 OsShellCmdTouch(INT32 argc, const CHAR **argv); 101extern INT32 OsShellCmdLs(INT32 argc, const CHAR **argv); 102extern INT32 OsShellCmdPwd(INT32 argc, const CHAR **argv); 103extern INT32 OsShellCmdCd(INT32 argc, const CHAR **argv); 104extern INT32 OsShellCmdCat(INT32 argc, const CHAR **argv); 105extern INT32 OsShellCmdRm(INT32 argc, const CHAR **argv); 106extern INT32 OsShellCmdRmdir(INT32 argc, const CHAR **argv); 107extern INT32 OsShellCmdMkdir(INT32 argc, const CHAR **argv); 108extern INT32 OsShellCmdCp(INT32 argc, const CHAR **argv); 109extern INT32 OsShellCmdHelp(INT32 argc, const CHAR **argv); 110extern UINT32 OsCmdInit(VOID); 111 112#ifdef __cplusplus 113#if __cplusplus 114} 115#endif 116#endif 117 118#endif /* _HWLITEOS_SHELL_SHCMD_H */ 119