转自:http://www.cnblogs.com/dyllove98/archive/2013/07/28/3221732.html
一.交叉编译ini解析库 1.官方网站http://ndevilla.free.fr/iniparser 下载iniparser-3.1.tar.gz 2.解压 tar -zxvf iniparser-3.1.tar.gz cd tar -zxvf iniparser 3.修改makefile CC = gcc 修改为--> CC = arm-none-linux-gnueabi-gcc AR = ar 修改为--> AR = arm-none-linux-gnueabi-ar 4.编译 make 5.拷贝src下的头文件dictionary.h和iniparser.h以及压缩包目录下的静态库libiniparser.a和动态库libiniparser.so.0到目标文件系统的对应目录下 二.iniparser库API int iniparser_getnsec(dictionary * d); //获取dictionary对象的section个数 char * iniparser_getsecname(dictionary * d, int n); //获取dictionary对象的第n个section的名字 void iniparser_dump_ini(dictionary * d, FILE * f); //保存dictionary对象到file void iniparser_dumpsection_ini(dictionary * d, char * s, FILE * f); //保存dictionary对象一个section到file void iniparser_dump(dictionary * d, FILE * f); //保存dictionary对象到file int iniparser_getsecnkeys(dictionary * d, char * s); //获取dictionary对象某个section下的key个数 char ** iniparser_getseckeys(dictionary * d, char * s); //获取dictionary对象某个section下所有的key char * iniparser_getstring(dictionary * d, const char * key, char * def); //返回dictionary对象的section:key对应的字串值 int iniparser_getint(dictionary * d, const char * key, int notfound); //返回idictionary对象的section:key对应的整形值 double iniparser_getdouble(dictionary * d, const char * key, double notfound); //返回dictionary对象的section:key对应的双浮点值 int iniparser_getboolean(dictionary * d, const char * key, int notfound); //返回dictionary对象的section:key对应的布尔值 int iniparser_set(dictionary * ini, const char * entry, const char * val); //设置dictionary对象的某个section:key的值 void iniparser_unset(dictionary * ini, const char * entry); //删除dictionary对象中某个section:key int iniparser_find_entry(dictionary * ini, const char * entry) ; //判断dictionary对象中是否存在某个section:key dictionary * iniparser_load(const char * ininame); //解析dictionary对象并返回(分配内存)dictionary对象 void iniparser_freedict(dictionary * d); //释放dictionary对象(内存) unsigned dictionary_hash(const char * key); //计算关键词的hash值 dictionary * dictionary_new(int size); //创建dictionary对象 void dictionary_del(dictionary * vd); //删除dictionary对象 char * dictionary_get(dictionary * d, const char * key, char * def); //获取dictionary对象的key值 int dictionary_set(dictionary * vd, const char * key, const char * val); //设置dictionary对象的key值 void dictionary_unset(dictionary * d, const char * key); //删除dictionary对象的key值 void dictionary_dump(dictionary * d, FILE * out); //保存dictionary对象 ini文件的格式(dictionary) [section0] key0 = value0 key1=value1 [section1] key0 = value0 key1=value1