All Projects → LloydLabs → Librini

LloydLabs / Librini

Licence: mit
Rini is a tiny, non-libc dependant, .ini file parser programmed from scratch in C99.

Programming Languages

c
50402 projects - #5 most used programming language

Projects that are alternatives of or similar to Librini

Pegparser
💡 Build your own programming language! A C++17 PEG parser generator supporting parser combination, memoization, left-recursion and context-dependent grammars.
Stars: ✭ 164 (+556%)
Mutual labels:  parser, parse
Lwesp
Lightweight Espressif AT parser library for ESP8266 and ESP32 devices.
Stars: ✭ 212 (+748%)
Mutual labels:  parser, embedded
Snapdragon
snapdragon is an extremely pluggable, powerful and easy-to-use parser-renderer factory.
Stars: ✭ 180 (+620%)
Mutual labels:  parser, parse
Parjs
JavaScript parser-combinator library
Stars: ✭ 145 (+480%)
Mutual labels:  parser, parse
Demoinfocs Golang
High performance CS:GO demo parser for Go (demoinfo)
Stars: ✭ 288 (+1052%)
Mutual labels:  parser, parse
Genieparser
sub-component of Genie that parse the device output into structured datastructure
Stars: ✭ 146 (+484%)
Mutual labels:  parser, parse
Tsql Parser
Library Written in C# For Parsing SQL Server T-SQL Scripts in .Net
Stars: ✭ 203 (+712%)
Mutual labels:  parser, parse
Postcss Less
PostCSS Syntax for parsing LESS
Stars: ✭ 93 (+272%)
Mutual labels:  parser, parse
wymlp
tiny fast portable real-time deep neural network for regression and classification within 50 LOC.
Stars: ✭ 36 (+44%)
Mutual labels:  embedded, tiny
pixie
Tiny template functions.
Stars: ✭ 14 (-44%)
Mutual labels:  parse, tiny
Json Autotype
Automatic Haskell type inference from JSON input
Stars: ✭ 139 (+456%)
Mutual labels:  parser, parse
Nom
Rust parser combinator framework
Stars: ✭ 5,987 (+23848%)
Mutual labels:  parser, parse
Tiny Json
The tiny-json is a versatile and easy to use json parser in C suitable for embedded systems. It is fast, robust and portable.
Stars: ✭ 127 (+408%)
Mutual labels:  parser, embedded
Libnmea
Lightweight C library for parsing NMEA 0183 sentences
Stars: ✭ 146 (+484%)
Mutual labels:  parser, parse
Netcopa
Network Configuration Parser
Stars: ✭ 112 (+348%)
Mutual labels:  parser, parse
Lark
Lark is a parsing toolkit for Python, built with a focus on ergonomics, performance and modularity.
Stars: ✭ 2,916 (+11564%)
Mutual labels:  parser, parse
Algebra Latex
Parse and calculate latex formatted math
Stars: ✭ 20 (-20%)
Mutual labels:  parser, parse
Parser
Generate a JSON documentation for a SFC Vue component. Contribute: https://gitlab.com/vuedoc/parser#contribute
Stars: ✭ 74 (+196%)
Mutual labels:  parser, parse
Subtitle.js
Stream-based library for parsing and manipulating subtitle files
Stars: ✭ 234 (+836%)
Mutual labels:  parser, parse
Js Quantities
JavaScript library for quantity calculation and unit conversion
Stars: ✭ 335 (+1240%)
Mutual labels:  parser, parse

MIT Licence

Rini - librini

Rini (really small ini parser) is a tiny, standalone, blazing fast .ini file parser. All other parsers rely on libc functions such as 'strtok', however Rini is in complete raw C code designed to handle the 'ini' format thus is much faster and efficient. This is the first parser I've made completely from scratch, feedback is welcome. I'll be removing the libc helper functions in the next release.

Advantages over other parsers

  • No overhead of using functions such as strtok.
  • Much smaller in size compared to other parsers.
  • Clean, maintainable code.
  • Much faster than its counterparts.
  • Tiny footprint. Great for an embedded environment.
  • Does not touch the heap at all, meaning less overhead of useless allocations. It is stack based only.
  • Support for inline comments and the escaping of special characters.

Supported data types

  • Strings, ASCII strings - no support for wide characters currently. Rini supports "quoted strings" too. When it comes to strings too, Rini supports all escaped special characters. For example, to escape the ';' character which is used for inline comments: "$x = 0;".
  • Booleans, tokens such as 'TRUE', '1', 'ON', 'YES', 'Y' are all accepted (and all of their lowercase equivalents).
  • Signed integers, Rini has a built-in signed integer converter.

MAX_NAME is the set maximum length of keys (not values) and headers and has a default value of 256, you may however change this macro in rini.h.

Building

cmake --build .

Usage

The only method exported by librini is rini_get_key which is located in the API header rini.h.

int rini_get_key(const char* parent, const char* key, const char* config, unsigned config_size, const void* out, unsigned out_size, value_types_t type)

Consider we have the following INI format in a variable named config in the type const char:

[server.main]
# This server is used for clustering..
hostname="root"
distro=Ubuntu
ssh_port=99
[server.labs]
hostname=honeypot
distro=Debian
ssh_port=80 ; this is the SSH port
char server_hostname[MAX_NAME], distro_name[MAX_NAME];
memset(server_hostname, 0, sizeof(server_hostname));
memset(distro_name, 0, sizeof(distro_name));

int main_port = 0;

if (rini_get_key("server.main", "hostname", config, sizeof(config), server_hostname, sizeof(server_hostname), STRING_VAL))
{
  printf("Name of main server: %s\n", server_hostname);
}

if (rini_get_key("server.main", "ssh_port", config, sizeof(config), &main_port, sizeof(main_port), INT_VAL))
{
  if (main_port <= 1024)
  {
    printf("Please change the port from %d to a number above 1024\n", main_port);
  }
}

if (rini_get_key("server.labs", "distro", config, sizeof(config), distro_name, sizeof(distro_name), STRING_VAL))
{
  if (strncmp(distro_name, "Arch", sizeof(distro_name)) == 0)
  {
    puts("You have a proper distro installed");
  }
}
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].