Libconfig - GitHub Pages

libconfig

A Library For Processing Structured Configuration Files Version 1.7.3 20 Jun 2021

Mark A. Lindner

Copyright c 2004-2021 Mark A Lindner

Permission is granted to make and distribute verbatim copies of this manual provided the copyright notice and this permission notice are preserved on all copies.

Permission is granted to copy and distribute modified versions of this manual under the conditions for verbatim copying, provided that the entire resulting derived work is distributed under the terms of a permission notice identical to this one.

i

Table of Contents

1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1

1.1 Why Another Configuration File Library? . . . . . . . . . . . . . . . . . . . . . . 1 1.2 Using the Library from a C Program . . . . . . . . . . . . . . . . . . . . . . . . . . . 1 1.3 Using the Library from a C++ Program . . . . . . . . . . . . . . . . . . . . . . . . 1 1.4 Multithreading Issues . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2 1.5 Internationalization Issues . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2 1.6 Compiling Using pkg-config . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2 1.7 Version Test Macros . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3

2 Configuration Files . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5

2.1 Settings . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6 2.2 Groups. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6 2.3 Arrays . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6 2.4 Lists . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7 2.5 Integer Values . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7 2.6 64-bit Integer Values . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7 2.7 Floating Point Values . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7 2.8 Boolean Values . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7 2.9 String Values. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7 2.10 Comments . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9 2.11 Include Directives . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9

3 The C API . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11

4 The C++ API . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21

5 Example Programs . . . . . . . . . . . . . . . . . . . . . . . . . . . . 35

6 Other Bindings and Implementations . . . . . . . . 37

6.1 Bourne Shell . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 37 6.2 D . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 37 6.3 Haskell . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 37 6.4 Java . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 37 6.5 Lisp . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 37 6.6 Perl. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 37 6.7 Python . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 37 6.8 Ruby . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 38

Appendix A License . . . . . . . . . . . . . . . . . . . . . . . . . . . . 39

ii

Appendix B Configuration File Grammar . . . . 49 Function Index . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 51 Type Index . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 53 Concept Index . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 55

libconfig

Chapter 1: Introduction

1

1 Introduction

Libconfig is a library for reading, manipulating, and writing structured configuration files. The library features a fully reentrant parser and includes bindings for both the C and C++ programming languages.

The library runs on modern POSIX-compilant systems, such as Linux, Solaris, and Mac OS X (Darwin), as well as on Microsoft Windows 2000/XP and later (with either Microsoft Visual Studio 2005 or later, or the GNU toolchain via the MinGW environment).

1.1 Why Another Configuration File Library?

There are several open-source configuration file libraries available as of this writing. This library was written because each of those libraries falls short in one or more ways. The main features of libconfig that set it apart from the other libraries are:

? A fully reentrant parser. Independent configurations can be parsed in concurrent threads at the same time.

? Both C and C++ bindings, as well as hooks to allow for the creation of wrappers in other languages.

? A simple, structured configuration file format that is more readable and compact than XML and more flexible than the obsolete but prevalent Windows "INI" file format.

? A low-footprint implementation (just 37K for the C library and 76K for the C++ library) that is suitable for memory-constrained systems.

? Proper documentation.

1.2 Using the Library from a C Program

To use the library from C code, include the following preprocessor directive in your source files:

#include

To link with the library, specify `-lconfig' as an argument to the linker.

1.3 Using the Library from a C++ Program

To use the library from C++, include the following preprocessor directive in your source files:

#include

Or, alternatively:

#include

................
................

In order to avoid copyright disputes, this page is only a partial summary.

Google Online Preview   Download