RT-Thread RTOS 1.2.0
An open source embedded real-time operating system
载入中...
搜索中...
未找到
msh.h 文件参考
#include <rtthread.h>
+ msh.h 的引用(Include)关系图:
+ 此图展示该文件被哪些文件直接或间接地引用了:

浏览该文件的源代码.

函数

int msh_exec (char *cmd, rt_size_t length)
 
void msh_auto_complete (char *prefix)
 
int msh_exec_module (const char *cmd_line, int size)
 
int msh_exec_script (const char *cmd_line, int size)
 

函数说明

◆ msh_exec()

int msh_exec ( char * cmd,
rt_size_t length )

在文件 msh.c540 行定义.

541{
542 int cmd_ret = 0;
543
544 /* strim the beginning of command */
545 while ((length > 0) && (*cmd == ' ' || *cmd == '\t'))
546 {
547 cmd++;
548 length--;
549 }
550
551 if (length == 0)
552 return 0;
553
554 /* Exec sequence:
555 * 1. built-in command
556 * 2. module(if enabled)
557 */
558 if (_msh_exec_cmd(cmd, length, &cmd_ret) == 0)
559 {
560 if(cmd_ret < 0)
561 {
562 rt_kprintf("%s: command failed %d.\n", cmd, cmd_ret);
563 }
564 return cmd_ret;
565 }
566#ifdef DFS_USING_POSIX
567#ifdef DFS_USING_WORKDIR
568 if (msh_exec_script(cmd, length) == 0)
569 {
570 return 0;
571 }
572#endif
573
574#ifdef RT_USING_MODULE
575 if (msh_exec_module(cmd, length) == 0)
576 {
577 return 0;
578 }
579#endif /* RT_USING_MODULE */
580
581#ifdef RT_USING_SMART
582 /* exec from msh_exec , debug = 0*/
583 /* _msh_exec_lwp return is pid , <= 0 means failed */
584 cmd_ret = _msh_exec_lwp(0, cmd, length);
585 if (cmd_ret > 0)
586 {
587 return 0;
588 }
589#endif /* RT_USING_SMART */
590#endif /* DFS_USING_POSIX */
591
592 /* truncate the cmd at the first space. */
593 {
594 char *tcmd;
595 tcmd = cmd;
596 while (*tcmd != ' ' && *tcmd != '\0')
597 {
598 tcmd++;
599 }
600 *tcmd = '\0';
601 }
602#ifdef RT_USING_SMART
603 if (cmd_ret == -EACCES)
604 {
605 rt_kprintf("%s: Permission denied.\n", cmd);
606 }
607 else
608#endif
609 {
610 rt_kprintf("%s: command not found.\n", cmd);
611 }
612 return -1;
613}
#define rt_kprintf(...)
int msh_exec_script(const char *cmd_line, int size)
int msh_exec_module(const char *cmd_line, int size)

引用了 msh_exec_module(), msh_exec_script() , 以及 rt_kprintf.

+ 函数调用图:

◆ msh_auto_complete()

void msh_auto_complete ( char * prefix)

在文件 msh.c775 行定义.

776{
777 int length, min_length;
778 const char *name_ptr, *cmd_name;
779 struct finsh_syscall *index;
780
781 min_length = 0;
782 name_ptr = RT_NULL;
783
784 if (*prefix == '\0')
785 {
786 msh_help(0, RT_NULL);
787 return;
788 }
789
790#ifdef DFS_USING_POSIX
791 /* check whether a spare in the command */
792 {
793 char *ptr;
794
795 ptr = prefix + rt_strlen(prefix);
796 while (ptr != prefix)
797 {
798 if (*ptr == ' ')
799 {
800 msh_auto_complete_path(ptr + 1);
801 break;
802 }
803
804 ptr --;
805 }
806#if defined(RT_USING_MODULE) || defined(RT_USING_SMART)
807 /* There is a chance that the user want to run the module directly. So
808 * try to complete the file names. If the completed path is not a
809 * module, the system won't crash anyway. */
810 if (ptr == prefix)
811 {
812 msh_auto_complete_path(ptr);
813 }
814#endif /* RT_USING_MODULE */
815 }
816#endif /* DFS_USING_POSIX */
817
818 /* checks in internal command */
819 {
820 for (index = _syscall_table_begin; index < _syscall_table_end; FINSH_NEXT_SYSCALL(index))
821 {
822 /* skip finsh shell function */
823 cmd_name = (const char *) index->name;
824 if (strncmp(prefix, cmd_name, strlen(prefix)) == 0)
825 {
826 if (min_length == 0)
827 {
828 /* set name_ptr */
829 name_ptr = cmd_name;
830 /* set initial length */
831 min_length = strlen(name_ptr);
832 }
833
834 length = str_common(name_ptr, cmd_name);
835 if (length < min_length)
836 min_length = length;
837
838 rt_kprintf("%s\n", cmd_name);
839 }
840 }
841 }
842
843 /* auto complete string */
844 if (name_ptr != NULL)
845 {
846 rt_strncpy(prefix, name_ptr, min_length);
847 }
848
849 return ;
850}
struct finsh_syscall * _syscall_table_end
#define FINSH_NEXT_SYSCALL(index)
struct finsh_syscall * _syscall_table_begin
定义 shell.c:50
#define RT_NULL

引用了 _syscall_table_begin, _syscall_table_end, FINSH_NEXT_SYSCALL, finsh_syscall::name, rt_kprintf , 以及 RT_NULL.

◆ msh_exec_module()

int msh_exec_module ( const char * cmd_line,
int size )
+ 这是这个函数的调用关系图:

◆ msh_exec_script()

int msh_exec_script ( const char * cmd_line,
int size )
+ 这是这个函数的调用关系图: