include详解 shell_基于C语言实现shell指令的详解

源代码来自于TI开发板在ARM上实现shell命令解析第一步:构建命令实现函数和命令表1,定义结构体 和命令表typedef int (*pfnCmdLine)(int argc, char *argv[]);//*****************************************************************************////! Structure ...
摘要由CSDN通过智能技术生成

源代码来自于TI开发板

在ARM上实现shell命令解析

第一步:构建命令实现函数和命令表

1,定义结构体 和命令表

typedef int (*pfnCmdLine)(int argc, char *argv[]);

//*****************************************************************************

//

//! Structure for an entry in the command list table.

//

//*****************************************************************************

typedef struct

{

//

//! A pointer to a string containing the name of the command.

//

const char *pcCmd;

//

//! A function pointer to the implementation of the command.

//

pfnCmdLine pfnCmd;

//

//! A pointer to a string of brief help text for the command.

//

const char *pcHelp;

}

tCmdLineEntry;

//*****************************************************************************

//

//! This is the command table that must be provided by the application.

//

//*****************************************************************************

extern tCmdLineEntry g_sCmdTable[];

2,编写命令执行函数  实现命令表

int

Cmd_help(int argc, char *argv[])

{

tCmdLineEntry *pEntry;

//

// Print some header text.

//

UARTprintf("\nAvailable commands\n");

UARTprintf("------------------\n");

//

// Point at the beginning of the command table.

//

pEntry = &g_sCmdTable[0];

//

// Enter a loop to read each entry from the command table.  The

// end of the table has been reached when the command name is NULL.

//

while(pEntry->pcCmd)

{

//

// Print the command name and the brief description.

//

UARTprintf("%s%s\n", pEntry->pcCmd, pEntry->pcHelp);

//

// Advance to the next entry in the table.

//

pEntry++;

}

//

// Return success.

//

return(0);

}

int

Cmd_ls(int argc, char *argv[])

{

unsigned long ulTotalSize;

unsigned long ulFileCount;

unsigned long ulDirCount;

FRESULT fresult;

FATFS *pFatFs;

//

// Open the current directory for access.

//

fresult = f_opendir(&g_sDirObject, g_cCwdBuf);

//

// Check for error and retur

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值