Skip to content

BlazeWasHere/libcprops

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

libcprops

A minimal properties file parser.

Features

  • compatible with C99
  • no dependencies
  • ~100 LOC
  • simple API
  • no memory leaks (tested with valgrind)
  • no overflows (tested with valgrind)
  • shared library

API

size_t cprops_file_parse(FILE *fp, cprops_data_t *data, int *err,
                         enum cprops_parse_flags flag);

Usage

View example.c.

Example

$ make example
[...]
$ ./example
written: 9, errno: 0
file close ret: 0
key: website, value: https://en.wikipedia.org/
key: language, value: English
key: message, value: Welcome to 
key: key, value: valueOverOneLine\
key: key with spaces, value: This is the value that could be looked up with the key "key with spaces".
key: key:with=colonAndEqualsSign, value: This is the value for the key "key:with=colonAndEqualsSign"
key: tab, value: u0009
key: path, value: c:\wiki\templates
key: escape, value: back\nslash
key: (null), value: (null)

Shared Library

To build the shared library run:

$ make
[...]
$ ls
example  libcprops.so    libcprops.so.0.0.1  object     src
include  libcprops.so.0  Makefile            README.md  tests

TODO

  • Tests
  • Parse multiline properties e.g
message = Welcome to \
          Wikipedia!

License

BSL-1.0 License