wayland学习笔记(七)config的结构分析

在看weston代码的时候,发现了weston对wl_list用的那叫一个溜,尤其是在config的管理上,用到了链表嵌套

先看下几个重要的数据结构:

struct weaton_config {
    wl_list section_list;
    char path[4096];
};

struct weston_config_section {
    char* name;
    wl_list entry_list;
    wl_list link;
};

struct weston_config_entry {
    char* key;
    char* value;
    wl_list link;
};

这里其实weston_config包含一个section_list的链表头,然后各个section的主要内容是一个name, 以及每个section包含一个entry_list, wl_list link是用来把自身往weston_config的section_list中insert的。

然后每个weston_config_entry又是包含了key-value, 以及把自身往weston_config_section中insert的link( 可以把link理解为粘合粘钩) 画出来大概是:

 这一套机制用来管理从weston.ini中解析出来的配置。然后weston中又提供了一堆接口方便我们从weston_config中get section, 以及从section中get entry. 然后根据这些配置来初始化compositor

        

原文地址:https://www.cnblogs.com/Arnold-Zhang/p/15692834.html