轉自: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