All Projects → madmurphy → libconfini

madmurphy / libconfini

Licence: GPL-3.0 license
Yet another INI parser

Programming Languages

c
50402 projects - #5 most used programming language
M4
1887 projects
Makefile
30231 projects
shell
77523 projects
Batchfile
5799 projects

Projects that are alternatives of or similar to libconfini

ini
📝 Go INI config management. support multi file load, data override merge. parse ENV variable, parse variable reference. Dotenv file parse and loader. INI配置读取管理,支持多文件加载,数据覆盖合并, 解析ENV变量, 解析变量引用。DotEnv 解析加载
Stars: ✭ 72 (-32.08%)
Mutual labels:  config, configuration-management, ini, ini-parser, ini-config
parse it
A python library for parsing multiple types of config files, envvars & command line arguments that takes the headache out of setting app configurations.
Stars: ✭ 86 (-18.87%)
Mutual labels:  config, configuration, configuration-management, ini, configuration-file
config-parser
A slim, fully managed C# library for reading/writing .ini, .conf, .cfg etc configuration files.
Stars: ✭ 67 (-36.79%)
Mutual labels:  config, configuration, ini, configuration-file, conf
Ini Parser
Read/Write an INI file the easy way!
Stars: ✭ 643 (+506.6%)
Mutual labels:  config, configuration, configuration-management, ini
dotfiles
My personal app/env configs and dotfiles.
Stars: ✭ 27 (-74.53%)
Mutual labels:  config, configuration, configuration-management
Centraldogma
Highly-available version-controlled service configuration repository based on Git, ZooKeeper and HTTP/2
Stars: ✭ 378 (+256.6%)
Mutual labels:  config, configuration, configuration-management
Koanf
Light weight, extensible configuration management library for Go. Built in support for JSON, TOML, YAML, env, command line, file, S3 etc. Alternative to viper.
Stars: ✭ 450 (+324.53%)
Mutual labels:  config, configuration, configuration-management
Configuration
Library for setting values to structs' fields from env, flags, files or default tag
Stars: ✭ 37 (-65.09%)
Mutual labels:  config, configuration, configuration-management
Strictyaml
Type-safe YAML parser and validator.
Stars: ✭ 836 (+688.68%)
Mutual labels:  config, configuration, configuration-management
Node No Config
Config and resource loader
Stars: ✭ 45 (-57.55%)
Mutual labels:  config, configuration, configuration-management
sitri
Sitri - powerful settings & configs for python
Stars: ✭ 20 (-81.13%)
Mutual labels:  config, configuration, configuration-management
nest-typed-config
Intuitive, type-safe configuration module for Nest framework ✨
Stars: ✭ 47 (-55.66%)
Mutual labels:  config, configuration, configuration-management
Appconfiguration
Questions, feedback and samples for Azure App Configuration service
Stars: ✭ 116 (+9.43%)
Mutual labels:  config, configuration, configuration-management
Node Convict
Featureful configuration management library for Node.js
Stars: ✭ 1,855 (+1650%)
Mutual labels:  config, configuration, configuration-management
Gcfg
read INI-style configuration files into Go structs; supports user-defined types and subsections
Stars: ✭ 146 (+37.74%)
Mutual labels:  config, configuration, ini
Config Rs
⚙️ Layered configuration system for Rust applications (with strong support for 12-factor applications).
Stars: ✭ 915 (+763.21%)
Mutual labels:  config, configuration, configuration-management
i3
Archivos de configuraciones de i3
Stars: ✭ 32 (-69.81%)
Mutual labels:  config, configuration-file, conf
climatecontrol
Python library for loading settings and config data from files and environment variables
Stars: ✭ 20 (-81.13%)
Mutual labels:  config, configuration, configuration-management
Dynaconf
Configuration Management for Python ⚙
Stars: ✭ 2,082 (+1864.15%)
Mutual labels:  config, configuration, configuration-management
Config
Easiest way to add multi-environment yaml settings to Rails, Sinatra, Pandrino and other Ruby projects.
Stars: ✭ 1,821 (+1617.92%)
Mutual labels:  config, configuration, configuration-management

libconfini {#readme}

libconfini is the ultimate and most consistent INI file parser library written in C. Originally designed for parsing configuration files written by other programs, it focuses on standardization and parsing exactness and is at ease with almost every type of file containing key/value pairs.

The library is fast and suitable for embedded systems. Its algorithms are written from scratch and do not depend on any external library, except for the C standard headers stdio.h, stdlib.h, stdbool.h and stdint.h (and for extreme platforms the code can be also compiled as “bare metal”, with few or no strings attached to the C Standard Library).

Rather than storing the parsed data, libconfini gives the developer the freedom to choose what to do with them through a custom callback invoked for each INI node read. The API has been designed to be powerful, flexible and simple to use.

With libconfini you will find in INI files the same serialization power that you would normally find in other heavily structured formats (such as JSON, YAML, TOML), but with the advantage of using the most human-friendly configuration format ever invented (thanks to their informal status, INI files are indeed more fluid, expressive and human-friendly than formats explicitly designed with the same purpose, such as YAML and TOML). The library's main goal is to be uncommonly powerful in the most tedious and error-prone task when parsing a text file in C: string handling. Thanks to this, the programmer is left free to organize the content parsed as (s)he pleases, assisted by a rich set of fine-tuning tools.

Features

  • Typed data support (each value can be parsed as a boolean, a number, a string, an array)
  • Single/double quotes support in Bash style (i.e. quotes can be opened and closed multiple times within the same value)
  • Multi-line support
  • Comment support
  • Disabled entry support
  • INI sectioning support (single-level sectioning, as in [foo]; absolute nesting, as in [foo.bar]; relative nesting, as in [.bar])
  • Automatic sanitization of values, key names and section paths
  • Comparison functions designed just for INI source code (capable, for example, to recognize the equality between "Hello world" and "He"l'lo' world, or between foo bar and foo    bar)
  • Callback pattern
  • Thread-safety (each parsing process is fully reentrant)
  • Highly optimized code (single memory allocation for each parsing, heuristic programming, optimization flags)
  • Function modularity (each public function is independent from all other public functions)
  • K.I.S.S. (no public functions are automatically invoked during the parsing -- for example, not even single/double quotes are automatically removed from values unless the developer explicitly decides to use the formatting functions provided by the API)
  • Robust and cross-platform file access (UTF-8 support; protection against null byte injection; support of all code representations of new lines -- i.e. ubiquitous support of Classic Mac OS' CR, Unix' LF, Windows' CR+LF, RISC OS Open's LF+CR)

Sample usage

log.ini:

[users]
have_visited = ronnie, lilly82, robrob

[last_update]
date = 12.03.2017

example.c:

#include <confini.h>

static int callback (IniDispatch * disp, void * v_other) {

  #define IS_KEY(SECTION, KEY) \
    (ini_array_match(SECTION, disp->append_to, '.', disp->format) && \
    ini_string_match_ii(KEY, disp->data, disp->format))

  if (disp->type == INI_KEY) {

    if (IS_KEY("users", "have_visited")) {

      /* No need to parse this field as an array right now */
      printf("People who have visited: %s\n", disp->value);

    } else if (IS_KEY("last_update", "date")) {

      printf("Last update: %s\n", disp->value);

    }

  }

  #undef IS_KEY

  return 0;

}

int main () {

  if (load_ini_path("log.ini", INI_DEFAULT_FORMAT, NULL, callback, NULL)) {

    fprintf(stderr, "Sorry, something went wrong :-(\n");
    return 1;

  }

  return 0;

}

Output:

People who have visited: ronnie, lilly82, robrob
Last update: 12.03.2017

If you are using C++, under examples/cplusplus/map.cpp you can find a snippet for storing an INI file into a class that relies on a std::unordered_map object.

For more details, please read the Library Functions Manual (man libconfini) -- a standalone HTML version is available here -- and the manual of the header file (man confini.h). The code is available on GitHub under madmurphy/libconfini).

Installation

Despite the small footprint, libconfini has been conceived as a shared library (but it can be used as a static library as well). An automatic list of the distributions that ship the library already compiled is available here.

If a pre-compiled package for your platform is not available, on most Unix-like systems it is possible to install libconfini using the following common steps:

./configure
make
make install-strip

If the strip utility is not available on your machine, use make install instead (it will produce larger binaries)

For a minimum installation without development files (i.e. static libraries, headers, documentation, examples, etc.) use ./configure --disable-devel.

If the configure script is missing you need to generate it by running the bootstrap script. By default, bootstrap will also run the configure script immediately after having generated it, so you may type the make command directly after bootstrap. To list different options use ./bootstrap --help.

If you are using Microsoft Windows, a batch script for compiling libconfini with MinGW without Bash is available (mgwmake.bat). If you are interested in using GNU Make for compiling libconfini, you can integrate MinGW with MSYS, or you can directly use MSYS2 and its official port of the library. Alternatively, an unofficial port of libconfini for Cygwin is available.

For further information, see INSTALL.

Bindings

Danilo Spinella maintains a D binding package of libconfini.

Free software

This library is free software. You can redistribute it and/or modify it under the terms of the GPL license version 3 or any later version. See COPYING for details.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].