A minimal properties file parser.
- compatible with C99
- no dependencies
- ~100 LOC
- simple API
- no memory leaks (tested with valgrind)
- no overflows (tested with valgrind)
- shared library
size_t cprops_file_parse(FILE *fp, cprops_data_t *data, int *err,
enum cprops_parse_flags flag);
View example.c.
$ 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)
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
- Tests
- Parse multiline properties e.g
message = Welcome to \
Wikipedia!