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来 ...
随机推荐
- java面向对象编程——第四章 类和对象
OO:面向对象 OOP:面向对象编程 OOA:面向对象分析 OOD:面向对象设计 结构化编程:从顶向下,将一个大问题分解成更小的任务,然后为每一个更小的任务编写一个过程.最后程序员会编写一个主过程来启 ...
- velocity插件 veloeclipse 支持eclipse4.4
分享主页:http://pan.baidu.com/share/home?uk=2737650112#category/type=0 http://pan.baidu.com/s/12RSAy 感谢究 ...
- POJ 1012 Joseph 推导,暴力,约瑟夫环,打表 难度:2
http://poj.org/problem?id=1012 答案以954ms飘过,不过这道题可以轻松用打表过 思路:如果我们把每个人位于数组中的原始编号记为绝对编号,每次循环过后相对于绝对编号为0的 ...
- libpng交叉编译安装
tar xzf libpng-1.5.22.tar.gz cd libpng-1.5.22 mkdir tmp 打开Makefile文件并修改CC=arm-linux-gcc ./configure ...
- 蓝桥杯 2015年省赛最后一题 生命之树(树形dp)
题目描述: 生命之树 在X森林里,上帝创建了生命之树. 他给每棵树的每个节点(叶子也称为一个节点)上,都标了一个整数,代表这个点的和谐值.上帝要在这棵树内选出一个非空节点集S,使得对于S中的任意两个点 ...
- Android Studio 使用genymotion 模拟器运行app时 提示找不到任何设备
原因是使用了genymotion 默认的Android toos .打开genymotion 选择设置 ADB 使用自己的SDKtools 选择Android Studio 使用的SDK位置就行 ...
- Linux内核-链表
linux内核链表的定义(定义了双向链表,不含数据域) 定义在 /linux-source-3.13.0/include/linux/types.h 头文件中. struct list_head { ...
- Dom操作html详细
<p name='pn'>xxx</p> <p name='pn'>xxx</p> <p name='pn'>xxx</p> & ...
- GCD常用剖析
介绍:Grand Central Dispatch 简称(GCD)是苹果公司开发的技术,以优化的应用程序支持多核心处理器和其他的对称多处理系统的系统.这建立在任务并行执行的线程池模式的基础上的.它首次 ...
- NSString和data转换
NSStringEncoding enc = CFStringConvertEncodingToNSStringEncoding(kCFStringEncodingGB_18030_2000); NS ...