u-boot readline

本文介绍了U-Boot中的Readline模块,该模块模仿GNU Readline库,为用户提供命令行编辑功能,支持Emacs和vi两种编辑模式,并提供历史命令记录和回溯等功能。文章重点解析了关键函数cread_line。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

u-boot readline是模仿GNU中的Readline库编写的,实现的功能也类似:provides a set of functions for use by applications that allow users to edit command lines as they are typed in. Both Emacs and vi editing modes are available. It includes additional functions to maintain a list of previously-entered command lines, to recall and perhaps reedit those lines, and perform csh-like history expansion on previous commands.

/*
* Prompt for input and read a line.
* Return: number of read characters
*   -1 if break
*   -2 if timed out
*/
int readline (const char *const prompt)
{
char *p = console_buffer;
unsigned int len=MAX_CMDBUF_SIZE;
int rc;
static int initted = 0;

if (!initted) {
   hist_init();
   initted = 1;
}

puts (prompt);

rc = cread_line(p, &len);
return rc < 0 ? rc : len;
}
现在的关键就是cread_line这个函数了。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值