更新日期: 2022/06/01 来源: https://gitee.com/weharmony/kernel_liteos_a_note
shmsg.h 文件参考

浏览源代码.

类型定义

typedef void(* OutputFunc) (const char *fmt,...)
 

函数

int ShellTaskInit (ShellCB *shellCB)
 给控制台注册一个shell客户端任务 更多...
 
void ChildExec (const char *cmdName, char *const paramArray[], bool foreground)
 
void ShellCmdLineParse (char c, OutputFunc outputFunc, ShellCB *shellCB)
 
int ShellNotify (ShellCB *shellCB)
 发送解析事件 更多...
 

类型定义说明

◆ OutputFunc

typedef void(* OutputFunc) (const char *fmt,...)

在文件 shmsg.h63 行定义.

函数说明

◆ ChildExec()

void ChildExec ( const char *  cmdName,
char *const  paramArray[],
bool  foreground 
)

在文件 shmsg.c354 行定义.

355{
356 int ret;
357 pid_t gid;
358
359 ret = setpgrp();
360 if (ret == -1) {
361 exit(1);
362 }
363
364 gid = getpgrp();
365 if (gid < 0) {
366 printf("get group id failed, pgrpid %d, errno %d\n", gid, errno);
367 exit(1);
368 }
369
370 if (!foreground) {
371 ret = tcsetpgrp(STDIN_FILENO, gid);
372 if (ret != 0) {
373 printf("tcsetpgrp failed, errno %d\n", errno);
374 exit(1);
375 }
376 }
377
378 ret = execve(cmdName, paramArray, NULL);
379 if (ret == -1) {
380 perror("execve");
381 exit(-1);
382 }
383}
void exit(int status)
Definition: stdlib.c:60
函数调用图:
这是这个函数的调用关系图:

◆ ShellCmdLineParse()

void ShellCmdLineParse ( char  c,
OutputFunc  outputFunc,
ShellCB shellCB 
)

在文件 shmsg.c271 行定义.

272{
273 const char ch = c;
274 int ret;
275
276 if ((shellCB->shellBufOffset == 0) && (ch != '\n') && (ch != CHAR_CTRL_C) && (ch != '\0')) {
277 (void)memset_s(shellCB->shellBuf, SHOW_MAX_LEN, 0, SHOW_MAX_LEN);
278 }
279
280 switch (ch) {
281 case '\r':
282 case '\n': /* enter */
283 ParseEnterKey(outputFunc, shellCB);
284 break;
285 case CHAR_CTRL_C: /* ctrl + c */
286 ParseCancelKey(outputFunc, shellCB);
287 break;
288 case '\b': /* backspace */
289 case CHAR_CTRL_DEL: /* delete(0x7F) */
290 ParseDeleteKey(outputFunc, shellCB);
291 break;
292 case '\t': /* tab */
293 ParseTabKey(outputFunc, shellCB);
294 break;
295 default:
296 /* parse the up/down/right/left key */
297 ret = ShellCmdLineCheckUDRL(ch, shellCB);
298 if (ret == SH_OK) {
299 return;
300 }
301 ParseNormalChar(ch, outputFunc, shellCB);
302 break;
303 }
304
305 return;
306}
void ParseEnterKey(OutputFunc outputFunc, ShellCB *shellCB)
Definition: shmsg.c:192
void ParseCancelKey(OutputFunc outputFunc, ShellCB *shellCB)
Definition: shmsg.c:212
void ParseNormalChar(char ch, OutputFunc outputFunc, ShellCB *shellCB)
Definition: shmsg.c:256
void ParseTabKey(OutputFunc outputFunc, ShellCB *shellCB)
Definition: shmsg.c:240
void ParseDeleteKey(OutputFunc outputFunc, ShellCB *shellCB)
解析删除键
Definition: shmsg.c:227
static int ShellCmdLineCheckUDRL(const char ch, ShellCB *shellCB)
检查上下左右键
Definition: shmsg.c:141
char shellBuf[SHOW_MAX_LEN]
接受shell命令 buf大小
Definition: shell.h:83
unsigned int shellBufOffset
buf偏移量
Definition: shell.h:78
ARG_NUM_3 ARG_NUM_1 ARG_NUM_2 ARG_NUM_2 ARG_NUM_3 ARG_NUM_1 ARG_NUM_4 ARG_NUM_2 ARG_NUM_2 ARG_NUM_5 ARG_NUM_2 void
函数调用图:
这是这个函数的调用关系图:

◆ ShellNotify()

int ShellNotify ( ShellCB shellCB)

发送解析事件

在文件 shmsg.c126 行定义.

127{
128 if (shellCB == NULL) {
129 return SH_NOK;
130 }
131
132 return sem_post(&shellCB->shellSem);
133}
int sem_post(sem_t *sem)
增加信号量计数
Definition: semaphore.c:139
sem_t shellSem
shell信号量
Definition: shell.h:80
函数调用图:
这是这个函数的调用关系图:

◆ ShellTaskInit()

int ShellTaskInit ( ShellCB shellCB)

给控制台注册一个shell客户端任务

在文件 shmsg.c628 行定义.

函数调用图:
这是这个函数的调用关系图: