INI file parsing C library (Iniparser)

Source: Internet
Author: User
Tags int size

I. Cross-compilation INI parsing library

1. Official website Http://ndevilla.free.fr/iniparser

Download iniparser-3.1.tar.gz

2. Decompression

TAR-ZXVF iniparser-3.1.tar.gz 
CD TAR-ZXVF Iniparser

3. Modify Makefile

CC	= gcc  modified to--> cc	= arm-none-linux-gnueabi-gcc
ar	= ar   modified to--> ar	= Arm-none-linux-gnueabi-ar

4. Compile

Make

5. The header files under the copy src Dictionary.h and iniparser.h as well as the static library LIBINIPARSER.A and the dynamic library under the compressed package directory libiniparser.so.0 to the corresponding directory of the target file system

Two. Iniparser Library API

int iniparser_getnsec (dictionary * d);	Gets the section number char * Iniparser_getsecname (dictionary * d, int n) of the Dictionary object;	Gets the name of the nth section of the Dictionary object, void Iniparser_dump_ini (dictionary * d, FILE * f);	Save the Dictionary object to the file void Iniparser_dumpsection_ini (dictionary * d, char * s, file * f);	Saves the Dictionary object a section to the file void Iniparser_dump (dictionary * d, FILE * f);	Save the Dictionary object to the file int Iniparser_getsecnkeys (dictionary * d, char * s);	Gets the key number char * * Iniparser_getseckeys (dictionary * d, char * s) under a section of the Dictionary object;	Gets all key char * iniparser_getstring (dictionary * d, const char * key, char * def) under a section of the Dictionary object;	Returns the string value of the section:key corresponding to the Dictionary object int Iniparser_getint (dictionary * d, const char * key, int notfound);	Returns the Section:key value of the IDictionary object double iniparser_getdouble (dictionary * d, const char * key, double notfound);	Returns the double floating-point value int Iniparser_getboolean (dictionary * d, const char * key, int notfound) corresponding to the Section:key of the Dictionary object; Returns the section:key corresponding to the Dictionary object.boolean int iniparser_set (dictionary * ini, const char * entry, const char * val);	Sets the value of a section:key of the Dictionary object void Iniparser_unset (dictionary * ini, const char * entry);	Deletes a section:key int iniparser_find_entry (dictionary * ini, const char * entry) in the Dictionary object;	Determines whether a section:key dictionary * iniparser_load (const char * ininame) exists in the Dictionary object;	Resolves the Dictionary object and returns (allocates memory) Dictionary object void Iniparser_freedict (dictionary * d); Free Dictionary object (memory)
unsigned dictionary_hash (const char * key);	Compute the hash value of the keyword
dictionary * dictionary_new (int size);	Creates a Dictionary object
void Dictionary_del (dictionary * VD);	Delete Dictionary object
char * dictionary_get (dictionary * d, const char * key, char * def);	Gets the key value int Dictionary_set of the Dictionary object
(dictionary * VD, const char * key, const char * val);	Sets the key value of the Dictionary object
void Dictionary_unset (dictionary * d, const char * key);	Deletes the key value of the Dictionary object
void Dictionary_dump (dictionary * d, FILE * out);	Save Dictionary Object

INI file Format (dictionary)

[Section0]

Key0 = Value0

Key1=value1

[Section1]

Key0 = Value0

Key1=value1

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.