A simple C/C++ class to parse configuration files and return requested key value
C++ C
Latest commit fc6a8fb Mar 21, 2014 @bmaynard Merge pull request #2 from Madball/patch-1
Patch - Solve Warning "deprecated conversion" error
Permalink
Failed to load latest commit information.
C++ Solve Warning "deprecated conversion" error Oct 25, 2013
C New C Version Mar 8, 2011
.gitignore New C Version Mar 8, 2011
LICENSE + License file Sep 13, 2010
README.md New C Version Mar 8, 2011

README.md

IniReader

This library is a simple configuration class that will parse configuration file in a key = value format. This library was used for the CPUHog application (https://github.com/bmaynard/CPUHog) which was originally written in C++ then re-written in C hence why there are 2 different versions.

The C version is very simple and more efficient but will only copy the values into a char pointer with the length of 60, where the C++ library can return string, char and int versions.

Including IniReader (Both Versions)

Include the the files when building your project and add the following to include the iniReader library:

#include <iniReader.h>

C Usage:

char *mysql_host[60];

parseIniFile("sample.cfg");

if (getConfigValue(mysql_host, "mysql_host") != 1)
{
	printf("Can not find 'mysql_host' in configuration file.");
	return(-1);
}

Please see main.c for a full usage and example.

C++ Usage:

parseIniFile("sample.ini");
cout << getOption("mysql_host") << "\n"; //Return string
cout << getOption("mysql_user") << "\n"; //Return string
cout << getOption("mysql_pass") << "\n"; //Return string
cout << getOptionChar("mysql_db") << "\n"; //Return char
cout << getOptionChar("mysql_socket") << "\n"; //Return char
cleanupIniReader();

Please see main.cpp for a full usage and example.