Code Monkey home page Code Monkey logo

tconfig's Introduction

A basic INI reader/writer built in C, with minimal dependencies.

This was an attempt to write something compact and easy to use for reading and writing INI files in my projects.

It's able to read most INI formats without any issues. Comments are delimited by the ';' character.

A basic usage example would be something like this:

#include <stdio.h>
#include "config.h"

int main()
{
        ini_table_s* config = ini_table_create();
        if (!ini_table_read_from_file(config, "test.ini")) {
                puts("test.ini does not exist! Adding entries!");
                ini_table_create_entry(config, "Section", "one", "two");
                ini_table_write_to_file(config, "test.ini");
        }else {
                printf("Entry one is: %s\n", ini_table_get_entry(config, "Section", "one"));
        }
        ini_table_destroy(config);
        return 0;
}

You don't need to check for NULL on ini_table_create(), since it creates an empty structure. Always make sure to call ini_table_destroy() when you're finished using the data, however.

There's currently no support for saving comment lines, but I may bother to add it in the future if I get bored.

For more information on these functions, check out config.h, which I spent a bit of time documenting for easy reading.

tconfig's People

Contributors

teklad avatar johlim avatar

Watchers

James Cloos avatar  avatar

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.