linux下读取conf配置文件c语言函数库ccl
2017-12-22 18:34
791 查看
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)) != 0) { 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下读取conf配置文件c语言函数库ccl
- 读取配置文件GetProfileString(linux版)
- 用C读取INI配置文件 (可在linux平台上用)
- linux编程(C语言读取配置文件)
- Linux下的samba服务器配置文件详解 smb.conf
- linux读取自定义的配置文件方法
- linux httpd.conf文件配置详解
- linux中的vsftp服务配置文件vsftpd.conf详解
- linux读取配置文件(C语言版)
- linux中DHCP服务配置文件/etc/dhcpd.conf详细说明
- JAVA读取classess下的.properties配置文件封装类,linux和windows上都可以使用
- linux读取配置文件(C语言版)
- Linux下的samba服务器配置文件详解 smb.conf
- Linux下DHCP服务器介绍:dhcpd.conf配置文件
- Linux内核参数配置文件修改(/proc/sys与/etc/sysctl.conf变量对应关系)
- 读取配置文件源代码[linux c]
- Linux资源使用配置文件 /etc/security/limits.conf
- Linux:vsftpd.conf文件中的缺省配置含义
- Linux启动时读取配置文件的顺序
- Linux下的samba服务器配置文件详解 smb.conf