ini檔案解析c庫 iniparser

2021-09-03 02:17:16 字數 3444 閱讀 6409

一.交叉編譯ini解析庫

1.官方**

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

intiniparser_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

intiniparser_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對應的字串值

intiniparser_getint

(dictionary * d, const

char * key, int notfound)

; //返回idictionary物件的section:key對應的整形值

double

iniparser_getdouble

(dictionary * d, const

char * key, double notfound)

; //返回dictionary物件的section:key對應的雙浮點值

intiniparser_getboolean

(dictionary * d, const

char * key, int notfound)

; //返回dictionary物件的section:key對應的布林值

intiniparser_set

(dictionary * ini, const

char * entry, const

char * val)

; //設定dictionary物件的某個section:key的值

void

iniparser_unset

(dictionary * ini, const

char * entry)

; //刪除dictionary物件中某個section:key

intiniparser_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)

;

dictionary * dictionary_new

(int size)

; //建立dictionary物件

void

dictionary_del

(dictionary * vd)

; //刪除dictionary物件

char * dictionary_get

(dictionary * d, const

char * key, char * def)

; //獲取dictionary物件的key值

intdictionary_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

ini檔案解析c庫 iniparser

github 一.交叉編譯ini解析庫 1.官方 2.解壓 cpp view plain copy tar zxvf iniparser 3.1.tar.gz cd tar zxvf iniparser 3.修改makefile cpp view plain copy cc gcc 修改為 cc a...

ini檔案解析c庫 iniparser

一.交叉編譯ini解析庫 1.官方 2.解壓 tar zxvf iniparser 3.1.tar.gz cd tar zxvf iniparser3.修改makefile cc gcc 修改為 cc arm none linux gnueabi gcc ar ar 修改為 ar arm none ...

python解析ini檔案

python解析ini檔案 使用configparser configuration file parser sections add section section has section section 操作section options section has option section,o...