Lines Matching refs:shellCB
50 CHAR *ShellGetInputBuf(ShellCB *shellCB) in ShellGetInputBuf() argument
52 CmdKeyLink *cmdkey = shellCB->cmdKeyLink; in ShellGetInputBuf()
55 (VOID)pthread_mutex_lock(&shellCB->keyMutex); in ShellGetInputBuf()
57 (VOID)pthread_mutex_unlock(&shellCB->keyMutex); in ShellGetInputBuf()
63 (VOID)pthread_mutex_unlock(&shellCB->keyMutex); in ShellGetInputBuf()
68 STATIC VOID ShellSaveHistoryCmd(const CHAR *string, ShellCB *shellCB) in ShellSaveHistoryCmd() argument
70 CmdKeyLink *cmdHistory = shellCB->cmdHistoryKeyLink; in ShellSaveHistoryCmd()
78 (VOID)pthread_mutex_lock(&shellCB->historyMutex); in ShellSaveHistoryCmd()
83 (VOID)pthread_mutex_unlock(&shellCB->historyMutex); in ShellSaveHistoryCmd()
93 (VOID)pthread_mutex_unlock(&shellCB->historyMutex); in ShellSaveHistoryCmd()
100 (VOID)pthread_mutex_unlock(&shellCB->historyMutex); in ShellSaveHistoryCmd()
104 STATIC VOID ShellNotify(ShellCB *shellCB) in ShellNotify() argument
106 (VOID)LOS_EventWrite(&shellCB->shellEvent, SHELL_CMD_PARSE_EVENT); in ShellNotify()
115 STATIC INT32 ShellCmdLineCheckUDRL(const CHAR ch, ShellCB *shellCB) in ShellCmdLineCheckUDRL() argument
119 shellCB->shellKeyType = STAT_ESC_KEY; in ShellCmdLineCheckUDRL()
122 if (shellCB->shellKeyType == STAT_ESC_KEY) { in ShellCmdLineCheckUDRL()
123 shellCB->shellKeyType = STAT_MULTI_KEY; in ShellCmdLineCheckUDRL()
127 if (shellCB->shellKeyType == STAT_MULTI_KEY) { in ShellCmdLineCheckUDRL()
128 OsShellHistoryShow(CMD_KEY_UP, shellCB); in ShellCmdLineCheckUDRL()
129 shellCB->shellKeyType = STAT_NORMAL_KEY; in ShellCmdLineCheckUDRL()
133 if (shellCB->shellKeyType == STAT_MULTI_KEY) { in ShellCmdLineCheckUDRL()
134 shellCB->shellKeyType = STAT_NORMAL_KEY; in ShellCmdLineCheckUDRL()
135 OsShellHistoryShow(CMD_KEY_DOWN, shellCB); in ShellCmdLineCheckUDRL()
139 if (shellCB->shellKeyType == STAT_MULTI_KEY) { in ShellCmdLineCheckUDRL()
140 shellCB->shellKeyType = STAT_NORMAL_KEY; in ShellCmdLineCheckUDRL()
144 if (shellCB->shellKeyType == STAT_MULTI_KEY) { in ShellCmdLineCheckUDRL()
145 shellCB->shellKeyType = STAT_NORMAL_KEY; in ShellCmdLineCheckUDRL()
152 LITE_OS_SEC_TEXT_MINOR VOID ShellCmdLineParse(CHAR c, pf_OUTPUT outputFunc, ShellCB *shellCB) in ShellCmdLineParse() argument
157 if ((shellCB->shellBufOffset == 0) && (ch != '\n') && (ch != '\0')) { in ShellCmdLineParse()
158 (VOID)memset_s(shellCB->shellBuf, SHOW_MAX_LEN, 0, SHOW_MAX_LEN); in ShellCmdLineParse()
162 if (shellCB->shellBufOffset < (SHOW_MAX_LEN - 1)) { in ShellCmdLineParse()
163 shellCB->shellBuf[shellCB->shellBufOffset] = '\0'; in ShellCmdLineParse()
165 shellCB->shellBufOffset = 0; in ShellCmdLineParse()
166 (VOID)pthread_mutex_lock(&shellCB->keyMutex); in ShellCmdLineParse()
167 OsShellCmdPush(shellCB->shellBuf, shellCB->cmdKeyLink); in ShellCmdLineParse()
168 (VOID)pthread_mutex_unlock(&shellCB->keyMutex); in ShellCmdLineParse()
169 ShellNotify(shellCB); in ShellCmdLineParse()
172 if ((shellCB->shellBufOffset > 0) && (shellCB->shellBufOffset < (SHOW_MAX_LEN - 1))) { in ShellCmdLineParse()
173 shellCB->shellBuf[shellCB->shellBufOffset - 1] = '\0'; in ShellCmdLineParse()
174 shellCB->shellBufOffset--; in ShellCmdLineParse()
179 if ((shellCB->shellBufOffset > 0) && (shellCB->shellBufOffset < (SHOW_MAX_LEN - 1))) { in ShellCmdLineParse()
180 ret = OsTabCompletion(shellCB->shellBuf, &shellCB->shellBufOffset); in ShellCmdLineParse()
182 outputFunc("OHOS # %s", shellCB->shellBuf); in ShellCmdLineParse()
188 ret = ShellCmdLineCheckUDRL(ch, shellCB); in ShellCmdLineParse()
194 if (shellCB->shellBufOffset < (SHOW_MAX_LEN - 1)) { in ShellCmdLineParse()
195 shellCB->shellBuf[shellCB->shellBufOffset] = ch; in ShellCmdLineParse()
197 shellCB->shellBuf[SHOW_MAX_LEN - 1] = '\0'; in ShellCmdLineParse()
199 shellCB->shellBufOffset++; in ShellCmdLineParse()
203 shellCB->shellKeyType = STAT_NORMAL_KEY; in ShellCmdLineParse()
333 ShellCB *shellCB = (ShellCB *)param; in ShellEntry() local
335 CONSOLE_CB *consoleCB = OsGetConsoleByID((INT32)shellCB->consoleID); in ShellEntry()
341 (VOID)memset_s(shellCB->shellBuf, SHOW_MAX_LEN, 0, SHOW_MAX_LEN); in ShellEntry()
350 ShellCmdLineParse(ch, (pf_OUTPUT)dprintf, shellCB); in ShellEntry()
362 STATIC VOID ShellCmdProcess(ShellCB *shellCB) in ShellCmdProcess() argument
366 buf = ShellGetInputBuf(shellCB); in ShellCmdProcess()
371 ShellSaveHistoryCmd(buf, shellCB); in ShellCmdProcess()
372 shellCB->cmdMaskKeyLink = shellCB->cmdHistoryKeyLink; in ShellCmdProcess()
382 ShellCB *shellCB = (ShellCB *)param1; in ShellTask() local
389 ret = LOS_EventRead(&shellCB->shellEvent, in ShellTask()
392 ShellCmdProcess(shellCB); in ShellTask()
397 OsShellKeyDeInit((CmdKeyLink *)shellCB->cmdKeyLink); in ShellTask()
398 OsShellKeyDeInit((CmdKeyLink *)shellCB->cmdHistoryKeyLink); in ShellTask()
399 (VOID)LOS_EventDestroy(&shellCB->shellEvent); in ShellTask()
400 (VOID)LOS_MemFree((VOID *)m_aucSysMem0, shellCB); in ShellTask()
409 LITE_OS_SEC_TEXT_MINOR UINT32 ShellTaskInit(ShellCB *shellCB) in ShellTaskInit() argument
414 if (shellCB->consoleID == CONSOLE_SERIAL) { in ShellTaskInit()
416 } else if (shellCB->consoleID == CONSOLE_TELNET) { in ShellTaskInit()
424 initParam.auwArgs[0] = (UINTPTR)shellCB; in ShellTaskInit()
429 (VOID)LOS_EventInit(&shellCB->shellEvent); in ShellTaskInit()
431 return LOS_TaskCreate(&shellCB->shellTaskHandle, &initParam); in ShellTaskInit()
434 LITE_OS_SEC_TEXT_MINOR UINT32 ShellEntryInit(ShellCB *shellCB) in ShellEntryInit() argument
440 if (shellCB->consoleID == CONSOLE_SERIAL) { in ShellEntryInit()
442 } else if (shellCB->consoleID == CONSOLE_TELNET) { in ShellEntryInit()
450 initParam.auwArgs[0] = (UINTPTR)shellCB; in ShellEntryInit()
455 ret = LOS_TaskCreate(&shellCB->shellEntryHandle, &initParam); in ShellEntryInit()
457 (VOID)ConsoleTaskReg((INT32)shellCB->consoleID, shellCB->shellEntryHandle); in ShellEntryInit()