format::ini +linux +x86_64

format::ini provides a parser for DOS-style INI files:

# This is a comment
description=The Hare programming language

# Unicode



type entry;

// Undocumented types:
type scanner;


type error;
type syntaxerr;


fn entry_dup(entry) entry;
fn entry_finish(entry) void;
fn finish(*scanner) void;
fn next(*scanner) (entry | io::EOF | error);
fn scan(io::handle) scanner;
fn strerror(error) const str;


type entry[link]

type entry = (const str,
const str,
const str);

An entry in an INI file: (section, key, value).

type scanner[link]

Show undocumented member
type scanner = struct {
	in: io::handle,
	line: str,
	lineno: size,
	section: str,


type error[link]

type error = !(io::error | utf8::invalid | syntaxerr);

Any error that may occur during parsing.

type syntaxerr[link]

type syntaxerr = !size;

A syntax error occurred during parsing.


fn entry_dup[link]

fn entry_dup(ent: entry) entry;

Duplicates an entry. Use entry_finish to get rid of it.

fn entry_finish[link]

fn entry_finish(ent: entry) void;

Frees an entry previously duplicated with entry_dup.

fn finish[link]

fn finish(sc: *scanner) void;

Frees resources associated with a scanner.

fn next[link]

fn next(sc: *scanner) (entry | io::EOF | error);

Returns the next entry from an INI file. The return value is overwritten on subsequent calls, use entry_dup or strings::dup to extend the lifetime of the entry or its fields respectively.

fn scan[link]

fn scan(in: io::handle) scanner;

Creates an INI file scanner. Use next to read entries. The caller must call finish once they're done with this object.

fn strerror[link]

fn strerror(err: error) const str;

Returns a user-friendly representation of error.