shithub: libini

ref: 6c63e71880f8bcdf597548e8bbaba165c4fe7d38
dir: /README/

View raw version

     INI(2)                                                     INI(2)

     NAME
          parseini - parse ini files

     SYNOPSIS
          #include <ini.h>

          int    parseini(char *file, void (*f)(char*, char*, char*),
          int forcelower)

          int    iniconfig(char *file, int forcelower)
          int    freeini(int config)

          char*  getinivalue(int config, char *section, char *key)
          char** getiniarray(int config, char *section, char *key, int
          *num)

     DESCRIPTION
          This library function provides simple parsing of INI files
          using bio(2). For each key-value pair within the INI file it
          calls the provided callback function f.

          The callback function gets the section, key and value as
          parameters.

          The forcelower flag tells the function to return all strings
          as lowercase strings, which can be helpful for some cases.
          Otherwise, all strings are returned as entered in the INI
          file.

          Iniconfig parses the given file into a convenient config
          database.  It returns the id of the parsed config file
          that's needed for future lookups.  It is possible to parse
          multiple INI files within one program this way.  Freeini
          frees the whole loaded INI configuration specified by the
          config parameter.

          The functions getinivalue and getiniarray can be used to
          fetch the parsed config values.  Both functions expect the
          configuration id received by the previous iniconfig call, as
          well as strings for section and key.

          Getinivalue returns the string value for the given combina-
          tion.

          Getiniarray returns an array of all value strings for the
          given combination.  It sets num to the number of elements
          within this list.

     SOURCE
          /sys/src/libini

     SEE ALSO
          bio(2)

     DIAGNOSTICS
          Parseini returns 0 on failure and sets errstr.

     BUGS
          Sure.

          Freeini potentially leaks memory.