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:

  1. #include "ccl/ccl.h"
  2.  
  3. struct ccl_t config;
  4. const struct ccl_pair_t *iter;
  5.  
  6. /* Set configuration file details */
  7. config.comment_char = '#';
  8. config.sep_char = '=';
  9. config.str_char = '"';
  10.  
  11. /* Parse the file */
  12. ccl_parse(&config, "example.conf");
  13.  
  14. /* Iterate through all key/value pairs */
  15. while((iter = ccl_iterate(&config)) != ) {
  16. printf("(%s,%s)n", iter->key, iter->value);
  17. }
  18.  
  19. /* Clean up */
  20. 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这样。的更多相关文章

  1. MySQL入门——Linux下安装后的配置文件

    MySQL入门——Linux下安装后的配置文件 摘要:本文主要了解了在Linux环境下安装MySQL后的配置文件的位置,以及如何创建配置文件. 查看配置文件的加载顺序 找到mysqld的路径 通过wh ...

  2. Linux下的sudo及其配置文件/etc/sudoers的详细配置说明

    http://www.osedu.net/article/linux/2011-01-03/178.html Linux下的sudo及其配置文件/etc/sudoers的详细配置说明 1.sudo介绍 ...

  3. linux下重要的网络配置文件

    linux下重要的网络配置文件:一; /etc/sysconfig/network  文件内容: NETWORKING=yes                                <= ...

  4. linux下如何查找nginx配置文件的位置

    nginx的配置放在nginx.conf文件中,一般我们可以使用以下命令查看服务器中存在的nginx.conf文件. locate nginx.conf /usr/local/etc/nginx/ng ...

  5. python读取配置文件(ini、yaml、xml)

    python读取配置文件(ini.yaml.xml)  

  6. 用python读取配置文件config.ini

    还在学习中...写的有点凌乱 感觉还是应该先学会读取配置文件才行,把一些经常需要修改的但是又经常需要用到的参数放到配置文件中方便使用(我是这么觉得的) 首先是config.ini的存放位置,我们把它放 ...

  7. Python使用ConfigParser模块读取配置文件(config.ini)以及写入配置文件

    前言 使用配置文件来灵活的配置一些参数是一件很常见的事情,配置文件的解析并不复杂,在python里更是如此,在官方发布的库中就包含有做这件事情的库,那就是configParser.configPars ...

  8. Linux下实现视频读取

    V4L(video4linux是一些视频系统,视频软件.音频软件的基础,经常时候在需要采集图像的场合,如视频监控,webcam,可视电话,经常使用在embedded linux中是linux嵌入式开发 ...

  9. Linux下实现视频读取(二)---camera參数设定

    Camera的可设置项极多,V4L2 支持了不少.但Sam之前对这些设置的使用方法和涵义都是在看videodev2.h中边看边理解.感觉很生涩. 直到写这篇blog时,才发现v4l2有专门的SPEC来 ...

随机推荐

  1. 使用Socket进行通信

    客户端通常可使用Socket的构造器来连接到指定服务器,Socket通常可使用如下两个构造器. Socket(lnetAddress/String  remoteAddress , int  port ...

  2. CentOS hadoop配置错误Incorrect configuration: namenode address dfs.namenode.servicerpc-address ...

    # ./sbin/start-all.sh                     This script is Deprecated. Instead use start-dfs.sh and st ...

  3. 如何整治那些敢偷用你Wi-Fi的人

    我的邻居正在盗用我的WiFi,唔,对此我可以直接选择加密口令,或者…作为一名极客我也可以耍耍他.那么,我就从划分网络开始吧.我把网络划分成两部分,受信任部分和非受信任部分.受信任部分组成一个子网,而非 ...

  4. RM报表的打印偏移

    自己摸索一下 RMReport1.SaveReportOptions.AutoLoadSaveSetting := True; RMReport1.SaveReportOptions.UseRegis ...

  5. SO从 \u 这样的字符串 构建对象

    ShowMessage(SO('\u4F18\u8D28\u670D\u52A112').AsString); 正确 得到 优质服务12 ShowMessage(so( 个数字,后面的中文未能解析出.

  6. web安全测试-AppScan

    安全测试应该是测试中非常重要的一部分,但他常常最容易被忽视掉. 尽管国内经常出现各种安全事件,但没有真正的引起人们的注意.不管是开发还是测试都不太关注产品的安全.当然,这也不能怪我们苦B的“民工兄弟” ...

  7. SharePoint安全 - 攻破SharePoint(黑客工具介绍)

    博客地址 http://blog.csdn.net/foxdave SharePoint的安全性很高,这是我们潜意识里的第一印象,所以具体的安全性体现在哪并没仔细研究过.但是事实上确实没有绝对安全的东 ...

  8. SecureCRT下的串口无法输入

    用串口配置交换机的时候,出现的问题: 用secureCRT建了一个串口COM1后,连接上开发板后,可以正确接受和显示串口的输出,但是按键输入无效. 解决方法: Session Options -> ...

  9. explain分析查询

    参考以下文章,在此非常感谢原作者 explain分析查询

  10. JS - To my gril

    /* 这个程序的流程是 , 首先执行 构造函数 (), 然后 就去执行那个 render 渲染 , 在 render 哪里 的if else 转向应该执行的渲染方法 , 例如 commitsrende ...