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来 ...
随机推荐
- SQL远程创建数据库
CREATE PROCEDURE [dbo].[p_CreateDB] @Des_DB sysname, @ServerName sysname=N'', @UserName sysname= ...
- socket.io遇到的问题
一.socket.io指定客户端html文件所用到的sendFile()方法中的文件路径必须是绝对路径,而且要符合一定规则: app.get('/',function(req,res){ res.se ...
- bzoj 1877: [SDOI2009]晨跑
#include<cstdio> #include<iostream> #include<cstring> #define M 6009 #define inf 2 ...
- 3.5电子书pc显示
使用svgalib 下载地址:https://launchpad.net/ubuntu/+source/svgalib/1:1.4.3-30svgalib_1.4.3.orig.tar.gzsvgal ...
- Linux配置防火墙 开启80端口
vi /etc/sysconfig/iptables -A INPUT -m state –state NEW -m tcp -p tcp –dport 80 -j ACCEPT(允许80端口通过防火 ...
- This absolute uri http://java.sun.com/jsp/jstl/core cannot be resolved in either web.xml or the jar files deployed with this application
部署生产环境出现以上错误,原因是jsp页面中使用了jstl的标签,但没有导入相应的jar包.因为开发环境 myeclipse10 自带类库已经集成 解决方法 ①将jstl.jar和standard.j ...
- IntelliJ IDEA 12.0
User name:JavaDeveloper Serial number:92547-KY2BB-QZ0S1-PEZCV-HUT8Q-6RYY4
- 《剑指offer-名企面试官精讲典型编程题》读后感
首先,不得不说这是一本好书!!! 我接触这本书是在学长的推荐下去看的,而且口碑还是挺好的一本书,豆瓣的评分也比较高,当我刚看了它,我就深深的爱上了这本书,到现在为止,我已经看了三遍这本书了,平时无聊时 ...
- new work
果不其然,还是电子工程师适合我.
- AutoCAD ObjectARX(VC)开发基础与实例教程2014版光盘镜像
AutoCAD ObjectARX(VC)开发基础与实例教程2014,最新版,光盘镜像 作者:张帆 朱文俊 编著 出版社:中国电力出版社 出版时间:2014年6月 点击一下