GithubHelp home page GithubHelp logo

hulkiedo17 / libconf Goto Github PK

View Code? Open in Web Editor NEW
6.0 6.0 0.0 80 KB

libconf - small library to process config files

License: Apache License 2.0

C 93.85% Shell 2.92% CMake 3.23%
c config files library linux processing unix utility-library

libconf's People

Contributors

bellrise avatar hulkiedo17 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

libconf's Issues

Library redesign

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.

Namespace pollution

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 file location

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.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.