当前位置: 首页 > news >正文

busybox的终端图形化界面菜单

系列文章目录

GNU-ncurses库简介


文章目录

  • 系列文章目录
  • 前言
  • 总结
  • lxdialog分析
  • Config.in文件修改示例


前言

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

相关文章:

  • 电缆接地电流监测系统,为电力稳定运行保驾护航
  • Linux进程间通信
  • 《Java到Go的平滑转型指南》
  • HTML CSS JS官方文档
  • Camera2 实现重力感应四个方向调试相机预览
  • [学习笔记] VM虚拟机安装Ubuntu系统
  • SpringMVC_day02
  • 【清华大学】AIGC发展研究(3.0版)
  • ROS导航工具包Navigation
  • Scikit-learn模型评估全流程解析:从数据划分到交叉验证优化
  • Java-模块二-2
  • 【MySQL】从零开始:掌握MySQL数据库的核心概念(三)
  • 音视频学习(三十):fmp4
  • 深入浅出JVM性能优化:从理论到实践
  • string kmp java
  • 高频SQL50题 第四天 | 1251. 平均售价、620. 有趣的电影、1075. 项目员工 I、1633. 各赛事的用户注册率
  • Ubuntu修改Swap交换空间大小
  • 2.创建Collection、添加索引、加载内存、预览和搜索数据
  • 【动态规划】按摩师
  • 蓝桥杯嵌入式备赛记录—CubeMX配置
  • 刘小涛任江苏省委副书记
  • 马上评|清理“滥竽充数者”,为医者正名
  • 商务部回应稀土出口管制问题
  • 娃哈哈:自4月起已终止与今麦郎的委托代工关系,未来将坚持自有生产模式
  • 互降关税后,从中国至美国的集装箱运输预订量飙升近300%
  • 七部门:进一步增强资本市场对于科技创新企业的支持力度