hulkiedo17 / libconf Goto Github PK
View Code? Open in Web Editor NEWlibconf - small library to process config files
License: Apache License 2.0
libconf - small library to process config files
License: Apache License 2.0
This library contains a major design flaw. All these functions operate on a file, not an in-memory representation of the configuration fields. This is a problem for performance reasons, because I/O is very slow compared to a linked list or a hash map (whichever memory structure can be used to represent the configuration fields).
The change would mean replacing the char *file
based API with a faster and safer, state based API. For example:
char *lc_create_config(char *file)
could be replaced with lc_config_t *lc_load_config(char *path)
, which would return a (possibly opaque) structure containing the loaded fields, or NULL
, depending if the function succeeds. The user then could read and write to this structure using other API functions. After finishing, a lc_dump_config
or lc_write_config
function could be called to write the data contained in the structure back into the file system.void lc_free_config(lc_config_t *config)
would free the created structure.The safety from this approach would come from using the in-memory data structure, which can be loaded and written only once, before and after any modifications. This would mean that the library doesn't have to depend on some other program or even user changing the config file mid-processing, which could possibly break the parsing system or just load invalid data.
This may be a totally different goal which you had over this library, but if you decide to migrate I'll be glad to help.
This library looks promising, but I have a problem about namespace pollution with by the functions defined in the header. They all have very generic names like create_file
, which could very well be a user-defined function. I'm proposing a change to prefix all the public symbols with something like lc_
for "libconf".
Also, I forked the project to remove CMake from the dependency list :)
lc_create_config
places the created file in the home directory, which is very unexpected. After reading the section about the function in library.md, it's still unclear to why this works this way.
I propose changing the functionality of this function to:
lc_create_config(path)
will create a config file at path
. If path
is not a full path, start at the working directory. If such file already exists, don't create it, just return the path. If the file cannot be created or read, return NULL
.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.