busybox的终端图形化界面菜单

系列文章目录

GNU-ncurses库简介



前言

busybox终端图形化配置界面,和内核的相似


总结

进程启动,准备数据调用子程序
子程序负责渲染

line [0]: ./scripts/kconfig/lxdialog/lxdialog

line [1]: --backtitle

line [2]: BusyBox 1.37.0 Configuration

line [3]: --title

line [4]: README

line [5]: --textbox

line [6]: .help.tmp

line [7]: 40

line [8]: 96

backtitle(BusyBox 1.37.0 Configuration)
---------------------------------------
             title(README)
menu_instructions
+-------------------------------------
| textbox read from temp file .help.tmp
|
+

line [7]: height
line [8]: width

char* args[1024] = {bufptr1, bufptr2...}
**argptr = args

+-----------------
| buf
+-----------------

^
|
bufptr

显示内容通过文件配置,主进程负责读取和解析Config.in,并为子进程生成要渲染的数据,子进程负责实际的渲染工作。

内容配置文件有简单的语法定义

void conf_parse(const char *name);
// 解析 conf_parse 文件

struct expr {
	enum expr_type type;
	union expr_data left, right;
};
struct property {
	struct property *next;
	struct symbol *sym;
	enum prop_type type;
	const char *text;    // 显示的文本 Busybox Configuration
	struct expr_value visible;
	struct expr *expr;   // 
	struct menu *menu;
	struct file *file;
	int lineno;
};
struct symbol {
	struct symbol *next;  // 用于 hash 冲突的表链
	char *name;           // sym name
	char *help;
	enum symbol_type type;   // 符号的数据类型
	struct symbol_value curr, user;
	tristate visible;
	int flags;             // 一些flag
	struct property *prop;  // 属性链表,新增属性放入链表后面
	struct expr *dep, *dep2;
	struct expr_value rev_dep;
};

1. zconf_initscan(name); 打开文件 current_file指向它
2. sym_init();
	struct symbol *sym_lookup(const char *name, int isconst)struct symbol *symbol_hash[257]; 中找到name对应的符号,若找到则返回,否则放入hash table
	"ARCH", 0   "KERNELVERSION", 0  "UNAME_RELEASE", 0
	初始化3符号
3. void menu_init(void)
	此时menu为空

4.	struct property *menu_add_prop(enum prop_type type, char *prompt, struct expr *expr, struct expr *dep)

conf_read(NULL);

保存文件的结构

[glogal] file_list is a list point to head

struct file {
	struct file *next;
	struct file *parent;
	char *name;
	int lineno;
	int flags;
};

父进程的主要初始化操作:


	setlocale(LC_ALL, "");
	bindtextdomain(PACKAGE, LOCALEDIR);
	textdomain(PACKAGE);

	tcgetattr(1, &ios_org);

	void init_wsize(void); 检查窗口大小

	conf(&rootmenu); loop here  
	子进程 fd=2为管道写端

lxdialog分析

argc = 5
argv[4]
offset < 4

offset = 0 1 2 3^

xx --title title-name --backtitle name --yesno txt prompt 16 141
offset+1 offset+2 ^

–title title-name --backtitle name --yesno promt 30 30

Config.in文件修改示例

部分 xxx/Config.in文件是从代码中的注释生成的

#
# For a description of the syntax of this configuration file,
# see docs/Kconfig-language.txt.
#

mainmenu "Configuration"

config HAVE_DOT_CONFIG
	bool
	default y

menu "Settings"

choice
	prompt "Additional debugging library"
	default NO_DEBUG_LIB
	help
	Using an additional debugging library will make busybox become
	considerably larger and will cause it to run more slowly. You
	should always leave this option disabled for production use.

	dmalloc support:
	----------------
	This enables compiling with dmalloc ( http://dmalloc.com/ )
	which is an excellent public domain mem leak and malloc problem
	detector. To enable dmalloc, before running busybox you will
	want to properly set your environment, for example:
		export DMALLOC_OPTIONS=debug=0x34f47d83,inter=100,log=logfile
	The 'debug=' value is generated using the following command
	dmalloc -p log-stats -p log-non-free -p log-bad-space \
		-p log-elapsed-time -p check-fence -p check-heap \
		-p check-lists -p check-blank -p check-funcs -p realloc-copy \
		-p allow-free-null

	Electric-fence support:
	-----------------------
	This enables compiling with Electric-fence support. Electric
	fence is another very useful malloc debugging library which uses
	your computer's virtual memory hardware to detect illegal memory
	accesses. This support will make busybox be considerably larger
	and run slower, so you should leave this option disabled unless
	you are hunting a hard to find memory problem.


config NO_DEBUG_LIB
	bool "None"

config DMALLOC
	bool "Dmalloc"

config EFENCE
	bool "Electric-fence"

endchoice

#source libbb/Config.in

endmenu

comment "Appletsxx"
comment "UserDefined2"

#source init/Config.in

#source archival/Config.in
#source coreutils/Config.in
#source console-tools/Config.in

#source debianutils/Config.in
source klibc-utils/Config.in
#source editors/Config.in

#source findutils/Config.in
#source loginutils/Config.in
#source e2fsprogs/Config.in
#source modutils/Config.in
#source util-linux/Config.in
#source miscutils/Config.in
#source networking/Config.in
#source printutils/Config.in
#source mailutils/Config.in
#source procps/Config.in
#source runit/Config.in
#source selinux/Config.in
#ource shell/Config.in
#source sysklogd/Config.in

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值