• Home
  • Raw
  • Download

Lines Matching refs:shellCB

52 char *GetCmdline(ShellCB *shellCB)  in GetCmdline()  argument
54 CmdKeyLink *cmdkey = shellCB->cmdKeyLink; in GetCmdline()
57 (void)pthread_mutex_lock(&shellCB->keyMutex); in GetCmdline()
59 (void)pthread_mutex_unlock(&shellCB->keyMutex); in GetCmdline()
65 (void)pthread_mutex_unlock(&shellCB->keyMutex); in GetCmdline()
70 (void)pthread_mutex_unlock(&shellCB->keyMutex); in GetCmdline()
80 static void ShellSaveHistoryCmd(char *string, ShellCB *shellCB) in ShellSaveHistoryCmd() argument
82 CmdKeyLink *cmdHistory = shellCB->cmdHistoryKeyLink; in ShellSaveHistoryCmd()
91 (void)pthread_mutex_lock(&shellCB->historyMutex); in ShellSaveHistoryCmd()
96 (void)pthread_mutex_unlock(&shellCB->historyMutex); in ShellSaveHistoryCmd()
106 (void)pthread_mutex_unlock(&shellCB->historyMutex); in ShellSaveHistoryCmd()
113 (void)pthread_mutex_unlock(&shellCB->historyMutex); in ShellSaveHistoryCmd()
117 int ShellPend(ShellCB *shellCB) in ShellPend() argument
119 if (shellCB == NULL) { in ShellPend()
123 return sem_wait(&shellCB->shellSem); in ShellPend()
126 int ShellNotify(ShellCB *shellCB) in ShellNotify() argument
128 if (shellCB == NULL) { in ShellNotify()
132 return sem_post(&shellCB->shellSem); in ShellNotify()
141 static int ShellCmdLineCheckUDRL(const char ch, ShellCB *shellCB) in ShellCmdLineCheckUDRL() argument
145 shellCB->shellKeyType = STAT_ESC_KEY; in ShellCmdLineCheckUDRL()
148 if (shellCB->shellKeyType == STAT_ESC_KEY) { in ShellCmdLineCheckUDRL()
149 shellCB->shellKeyType = STAT_MULTI_KEY; in ShellCmdLineCheckUDRL()
153 if (shellCB->shellKeyType == STAT_MULTI_KEY) { in ShellCmdLineCheckUDRL()
154 OsShellHistoryShow(CMD_KEY_UP, shellCB); in ShellCmdLineCheckUDRL()
155 shellCB->shellKeyType = STAT_NORMAL_KEY; in ShellCmdLineCheckUDRL()
159 if (shellCB->shellKeyType == STAT_MULTI_KEY) { in ShellCmdLineCheckUDRL()
160 shellCB->shellKeyType = STAT_NORMAL_KEY; in ShellCmdLineCheckUDRL()
161 OsShellHistoryShow(CMD_KEY_DOWN, shellCB); in ShellCmdLineCheckUDRL()
165 if (shellCB->shellKeyType == STAT_MULTI_KEY) { in ShellCmdLineCheckUDRL()
166 shellCB->shellKeyType = STAT_NORMAL_KEY; in ShellCmdLineCheckUDRL()
170 if (shellCB->shellKeyType == STAT_MULTI_KEY) { in ShellCmdLineCheckUDRL()
171 shellCB->shellKeyType = STAT_NORMAL_KEY; in ShellCmdLineCheckUDRL()
178 void ShellTaskNotify(ShellCB *shellCB) in ShellTaskNotify() argument
182 (void)pthread_mutex_lock(&shellCB->keyMutex); in ShellTaskNotify()
183 OsShellCmdPush(shellCB->shellBuf, shellCB->cmdKeyLink); in ShellTaskNotify()
184 (void)pthread_mutex_unlock(&shellCB->keyMutex); in ShellTaskNotify()
186 ret = ShellNotify(shellCB); in ShellTaskNotify()
188 printf("command execute failed, \"%s\"", shellCB->shellBuf); in ShellTaskNotify()
192 void ParseEnterKey(OutputFunc outputFunc, ShellCB *shellCB) in ParseEnterKey() argument
194 if ((shellCB == NULL) || (outputFunc == NULL)) { in ParseEnterKey()
198 if (shellCB->shellBufOffset == 0) { in ParseEnterKey()
199 shellCB->shellBuf[shellCB->shellBufOffset] = '\n'; in ParseEnterKey()
200 shellCB->shellBuf[shellCB->shellBufOffset + 1] = '\0'; in ParseEnterKey()
204 if (shellCB->shellBufOffset <= (SHOW_MAX_LEN - 1)) { in ParseEnterKey()
205 shellCB->shellBuf[shellCB->shellBufOffset] = '\0'; in ParseEnterKey()
208 shellCB->shellBufOffset = 0; in ParseEnterKey()
209 ShellTaskNotify(shellCB); in ParseEnterKey()
212 void ParseCancelKey(OutputFunc outputFunc, ShellCB *shellCB) in ParseCancelKey() argument
214 if ((shellCB == NULL) || (outputFunc == NULL)) { in ParseCancelKey()
218 if (shellCB->shellBufOffset <= (SHOW_MAX_LEN - 1)) { in ParseCancelKey()
219 shellCB->shellBuf[0] = CHAR_CTRL_C; in ParseCancelKey()
220 shellCB->shellBuf[1] = '\0'; in ParseCancelKey()
223 shellCB->shellBufOffset = 0; in ParseCancelKey()
224 ShellTaskNotify(shellCB); in ParseCancelKey()
227 void ParseDeleteKey(OutputFunc outputFunc, ShellCB *shellCB) in ParseDeleteKey() argument
229 if ((shellCB == NULL) || (outputFunc == NULL)) { in ParseDeleteKey()
233 if ((shellCB->shellBufOffset > 0) && (shellCB->shellBufOffset <= (SHOW_MAX_LEN - 1))) { in ParseDeleteKey()
234 shellCB->shellBuf[shellCB->shellBufOffset - 1] = '\0'; in ParseDeleteKey()
235 shellCB->shellBufOffset--; in ParseDeleteKey()
240 void ParseTabKey(OutputFunc outputFunc, ShellCB *shellCB) in ParseTabKey() argument
244 if ((shellCB == NULL) || (outputFunc == NULL)) { in ParseTabKey()
248 if ((shellCB->shellBufOffset > 0) && (shellCB->shellBufOffset < (SHOW_MAX_LEN - 1))) { in ParseTabKey()
249 ret = OsTabCompletion(shellCB->shellBuf, &shellCB->shellBufOffset); in ParseTabKey()
251 outputFunc(SHELL_PROMPT"%s", shellCB->shellBuf); in ParseTabKey()
256 void ParseNormalChar(char ch, OutputFunc outputFunc, ShellCB *shellCB) in ParseNormalChar() argument
258 if ((shellCB == NULL) || (outputFunc == NULL) || !VISIABLE_CHAR(ch)) { in ParseNormalChar()
262 if ((ch != '\0') && (shellCB->shellBufOffset < (SHOW_MAX_LEN - 1))) { in ParseNormalChar()
263 shellCB->shellBuf[shellCB->shellBufOffset] = ch; in ParseNormalChar()
264 shellCB->shellBufOffset++; in ParseNormalChar()
268 shellCB->shellKeyType = STAT_NORMAL_KEY; in ParseNormalChar()
271 void ShellCmdLineParse(char c, OutputFunc outputFunc, ShellCB *shellCB) in ShellCmdLineParse() argument
276 if ((shellCB->shellBufOffset == 0) && (ch != '\n') && (ch != CHAR_CTRL_C) && (ch != '\0')) { in ShellCmdLineParse()
277 (void)memset_s(shellCB->shellBuf, SHOW_MAX_LEN, 0, SHOW_MAX_LEN); in ShellCmdLineParse()
283 ParseEnterKey(outputFunc, shellCB); in ShellCmdLineParse()
286 ParseCancelKey(outputFunc, shellCB); in ShellCmdLineParse()
290 ParseDeleteKey(outputFunc, shellCB); in ShellCmdLineParse()
293 ParseTabKey(outputFunc, shellCB); in ShellCmdLineParse()
297 ret = ShellCmdLineCheckUDRL(ch, shellCB); in ShellCmdLineParse()
301 ParseNormalChar(ch, outputFunc, shellCB); in ShellCmdLineParse()
582 static void ShellCmdProcess(ShellCB *shellCB) in ShellCmdProcess() argument
585 char *buf = GetCmdline(shellCB); in ShellCmdProcess()
595 ShellSaveHistoryCmd(buf, shellCB); in ShellCmdProcess()
596 shellCB->cmdMaskKeyLink = shellCB->cmdHistoryKeyLink; in ShellCmdProcess()
604 ShellCB *shellCB = (ShellCB *)argv; in ShellTask() local
606 if (shellCB == NULL) { in ShellTask()
617 ret = ShellPend(shellCB); in ShellTask()
619 ShellCmdProcess(shellCB); in ShellTask()
628 int ShellTaskInit(ShellCB *shellCB) in ShellTaskInit() argument
635 if (shellCB == NULL) { in ShellTaskInit()
645 arg = (void *)shellCB; in ShellTaskInit()
646 ret = pthread_create(&shellCB->shellTaskHandle, &attr, &ShellTask, arg); in ShellTaskInit()
659 void ShellEntry(ShellCB *shellCB) in ShellEntry() argument
666 if (shellCB == NULL) { in ShellEntry()
670 (void)memset_s(shellCB->shellBuf, SHOW_MAX_LEN, 0, SHOW_MAX_LEN); in ShellEntry()
681 ShellCmdLineParse(ch, (OutputFunc)printf, shellCB); in ShellEntry()