Linux下用C读取配置文件。类似ini这样。
Introduction
ccl is the customizable configuration library, a collection of functions
for application programmers wishing to interface with user-editable
configuration files containing key/value pairs.
ccl is customizable because it allows the comment, key/value, and string
literal delimiters to be programatically specified at runtime.
ccl is designed to be simple and portable; it has a small interface
consisting of five functions and is written in ANSI/ISO C. ccl uses
avl's implemenation of binary search trees for backend storage.
Download
ccl is available via ftp from http://files.sbooth.org/.
Documentation
You can browse the library's contents by using the navigation
bar at the top of this page. A good starting point is the globals page.
Example
An example is the best way to understand how ccl works. A configuration file named example.conf might contain:
## Sample configuration file
Desktop-Picture = /usr/images/earth.jpg
Position = Centered
"Background Color" = Black
The following code demonstrates how to parse and access this file using ccl:
#include "ccl/ccl.h" struct ccl_t config;
const struct ccl_pair_t *iter; /* Set configuration file details */
config.comment_char = '#';
config.sep_char = '=';
config.str_char = '"'; /* Parse the file */
ccl_parse(&config, "example.conf"); /* Iterate through all key/value pairs */
while((iter = ccl_iterate(&config)) != ) {
printf("(%s,%s)n", iter->key, iter->value);
} /* Clean up */
ccl_release(&config);
When compiled, the snippet above produces the output
(Background Color,Black)
(Desktop-Picture,/usr/images/earth.jpg)
(Position,Centered)
Linux下用C读取配置文件。类似ini这样。的更多相关文章
- MySQL入门——Linux下安装后的配置文件
MySQL入门——Linux下安装后的配置文件 摘要:本文主要了解了在Linux环境下安装MySQL后的配置文件的位置,以及如何创建配置文件. 查看配置文件的加载顺序 找到mysqld的路径 通过wh ...
- Linux下的sudo及其配置文件/etc/sudoers的详细配置说明
http://www.osedu.net/article/linux/2011-01-03/178.html Linux下的sudo及其配置文件/etc/sudoers的详细配置说明 1.sudo介绍 ...
- linux下重要的网络配置文件
linux下重要的网络配置文件:一; /etc/sysconfig/network 文件内容: NETWORKING=yes <= ...
- linux下如何查找nginx配置文件的位置
nginx的配置放在nginx.conf文件中,一般我们可以使用以下命令查看服务器中存在的nginx.conf文件. locate nginx.conf /usr/local/etc/nginx/ng ...
- python读取配置文件(ini、yaml、xml)
python读取配置文件(ini.yaml.xml)
- 用python读取配置文件config.ini
还在学习中...写的有点凌乱 感觉还是应该先学会读取配置文件才行,把一些经常需要修改的但是又经常需要用到的参数放到配置文件中方便使用(我是这么觉得的) 首先是config.ini的存放位置,我们把它放 ...
- Python使用ConfigParser模块读取配置文件(config.ini)以及写入配置文件
前言 使用配置文件来灵活的配置一些参数是一件很常见的事情,配置文件的解析并不复杂,在python里更是如此,在官方发布的库中就包含有做这件事情的库,那就是configParser.configPars ...
- Linux下实现视频读取
V4L(video4linux是一些视频系统,视频软件.音频软件的基础,经常时候在需要采集图像的场合,如视频监控,webcam,可视电话,经常使用在embedded linux中是linux嵌入式开发 ...
- Linux下实现视频读取(二)---camera參数设定
Camera的可设置项极多,V4L2 支持了不少.但Sam之前对这些设置的使用方法和涵义都是在看videodev2.h中边看边理解.感觉很生涩. 直到写这篇blog时,才发现v4l2有专门的SPEC来 ...
随机推荐
- 选择最适合你的Linux学习方法
我们知道Linux只是一个内核,现在的Linux操作系统底层都是用这个内核,包括Android手机,所以Linux操作系统其实是将Linux内核与应用软件做一个打包,我们称之为Linux发行版.现在比 ...
- Js练习题之字数判断
目标:控制某个栏目里每行字数,当字数超出时,以省略号显示 $("元素").each(function(){ var maxlength=9; //最大字数 if($(this).t ...
- S1:变量
接触JS一段时间了,但总感觉不得要领,技术得不到提升,翻来覆去,决定对基础知识做一次系统的整理,要坚持每一天都有新的收获 ! 变量,即通过一个名字将一个值关联起来,以后通过变量就可以引用到该值,比如: ...
- java引用类型
java数据类型图: java的数据类型分基本数据类型(原始数据类型)和引用数据类型:1.基本八大类,图中可以很清楚的看到:这种类型的数据变量在声明之后java就会立刻分配给他内存空间.如:sho ...
- DataGridView的按钮列的点击事件
private void dataGridView1_CellContentClick(object sender, DataGridViewCellEventArgs e) { ) { DataGr ...
- PhpStorm注册码 key license
User name: EMBRACE License key: ===== LICENSE BEGIN =====43136-1204201000002UsvSON704l"dILe1PVx ...
- Hibernate4 No Session found for current thread原因
Hibernate4 与 spring3 集成之后, 如果在取得session 的地方使用了getCurrentSession, 可能会报一个错:“No Session found for curre ...
- CCNA 6.3
no encapsulation ppp(默认是encapsulation hdlc 在encapsulation ppp 后想要改回 hdlc 除了可用encapsulation hdlc外,还可以 ...
- 提示框alertmsg
初始化: 1.Data属性:DOM添加属性data-toggle="alertmsg",并定义type及msg参数 示例代码: <button type="butt ...
- Volatile vs VolatileRead/Write?
You should never use Thread.VolatileRead/Write(). It was a design mistake in .NET 1.1, it uses a ful ...