Skip to content

Simple, header-only INI file loader in ANSI C

License

Notifications You must be signed in to change notification settings

roman-ra/iniload

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

iniload

iniload is an easy-to-use, header-only INI file loader written in ANSI C.

Usage example

Do not forget to #define INILOAD_IMPLEMENTATION in one of your source files before including iniload.h:

A minimal example:

#define INILOAD_IMPLEMENTATION
#include "iniload.h"

#include <stdio.h>

int main(int argc, char *argv[]) {
  ini_file *ini = ini_load("settings.ini");
  
  if (ini == NULL) {
    return -1;
  }

  float volume = ini_get_float(ini, "audio", "volume", 1.0f);
  int nproc = ini_get_int(ini, "", "nproc", 1);
  char *path = ini_get_string(ini, "", "path", "default");
  
  ini_free(ini); 
  
  printf("%f, %d, %s", volume, nproc, path);
  
  return 0;
}

By default, the names of sections and keys cannot be longer than 128. This limit can be increased by #define INILOAD_NAME_MAXLEN *your value* before including iniload.h in the file where you defined INILOAD_IMPLEMENTATION.

About

Simple, header-only INI file loader in ANSI C

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published