# benhoyt/inih architecture

> Architecture diagram of the GitHub repository benhoyt/inih, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-15). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/benhoyt/inih
- Repository: https://github.com/benhoyt/inih

## Overview

inih is a small C INI parser: callers supply file, FILE, string, or custom-reader input and receive parsed section/name/value records through a callback. The C++ INIReader wraps that callback into case-insensitive lookups, typed accessors, and section/key queries. The README documents syntax, error, and memory options; those are parser configuration rather than separate runtime subsystems. Relationships shown are limited to the README and sampled source; unsampled example clients are not mapped.

Main entry points: [`cpp/INIReader.h`](https://github.com/benhoyt/inih/blob/master/cpp/INIReader.h) (INIReader API), [`ini.h`](https://github.com/benhoyt/inih/blob/master/ini.h) (Parser API), [`ini.c`](https://github.com/benhoyt/inih/blob/master/ini.c) (Stream parser), [`cpp/INIReader.cpp`](https://github.com/benhoyt/inih/blob/master/cpp/INIReader.cpp) (Reader parsing)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_cparser["C parser"]
  node_ini_api["Parser API<br/>[ini.h]"]
  node_parse_stream["Stream parser<br/>[ini.c]"]
  node_file_input["File input<br/>[ini.c]"]
  node_string_input["String input<br/>[ini.c]"]
  node_custom_reader["Custom reader<br/>[ini.h]"]
end

subgraph group_cppreader["C++ reader"]
  node_cpp_api["INIReader API<br/>[INIReader.h]"]
  node_cpp_parse["Reader parsing<br/>[INIReader.cpp]"]
  node_value_store[("Value map<br/>[INIReader.cpp]")]
  node_typed_access["Typed accessors<br/>[INIReader.cpp]"]
  node_section_queries["Section queries<br/>[INIReader.cpp]"]
  node_error_status["Parse status<br/>[INIReader.cpp]"]
end

node_caller(("Application caller"))
node_callback["Value callback"]

node_caller -->|"calls parse"| node_ini_api
node_ini_api -->|"dispatches file"| node_file_input
node_ini_api -->|"dispatches string"| node_string_input
node_ini_api -->|"exposes stream"| node_parse_stream
node_file_input -->|"delegates to"| node_parse_stream
node_string_input -->|"delegates to"| node_parse_stream
node_custom_reader -->|"supplies reader"| node_parse_stream
node_parse_stream -->|"emits records"| node_callback
node_caller -->|"constructs reader"| node_cpp_api
node_cpp_api -->|"implemented by"| node_cpp_parse
node_cpp_parse -->|"calls parser"| node_ini_api
node_cpp_parse -->|"callback stores values"| node_value_store
node_cpp_api -->|"offers typed reads"| node_typed_access
node_typed_access -->|"looks up values"| node_value_store
node_cpp_api -->|"offers queries"| node_section_queries
node_section_queries -->|"scans values"| node_value_store
node_cpp_api -->|"offers status"| node_error_status

click node_ini_api "https://github.com/benhoyt/inih/blob/master/ini.h"
click node_parse_stream "https://github.com/benhoyt/inih/blob/master/ini.c"
click node_file_input "https://github.com/benhoyt/inih/blob/master/ini.c"
click node_string_input "https://github.com/benhoyt/inih/blob/master/ini.c"
click node_custom_reader "https://github.com/benhoyt/inih/blob/master/ini.h"
click node_cpp_api "https://github.com/benhoyt/inih/blob/master/cpp/INIReader.h"
click node_cpp_parse "https://github.com/benhoyt/inih/blob/master/cpp/INIReader.cpp"
click node_value_store "https://github.com/benhoyt/inih/blob/master/cpp/INIReader.cpp"
click node_typed_access "https://github.com/benhoyt/inih/blob/master/cpp/INIReader.cpp"
click node_section_queries "https://github.com/benhoyt/inih/blob/master/cpp/INIReader.cpp"
click node_error_status "https://github.com/benhoyt/inih/blob/master/cpp/INIReader.cpp"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_ini_api,node_parse_stream,node_file_input,node_string_input,node_custom_reader toneBlue
class node_cpp_api,node_cpp_parse,node_value_store,node_typed_access,node_section_queries,node_error_status toneAmber
class node_caller,node_callback toneIndigo
```

## Components

### C parser

- [Parser API](https://github.com/benhoyt/inih/blob/master/ini.h): `ini.h`
- [Stream parser](https://github.com/benhoyt/inih/blob/master/ini.c): `ini.c`
- [File input](https://github.com/benhoyt/inih/blob/master/ini.c): `ini.c`
- [String input](https://github.com/benhoyt/inih/blob/master/ini.c): `ini.c`
- [Custom reader](https://github.com/benhoyt/inih/blob/master/ini.h): `ini.h`

### C++ reader

- [INIReader API](https://github.com/benhoyt/inih/blob/master/cpp/INIReader.h): `cpp/INIReader.h`
- [Reader parsing](https://github.com/benhoyt/inih/blob/master/cpp/INIReader.cpp): `cpp/INIReader.cpp`
- [Value map](https://github.com/benhoyt/inih/blob/master/cpp/INIReader.cpp): `cpp/INIReader.cpp`
- [Typed accessors](https://github.com/benhoyt/inih/blob/master/cpp/INIReader.cpp): `cpp/INIReader.cpp`
- [Section queries](https://github.com/benhoyt/inih/blob/master/cpp/INIReader.cpp): `cpp/INIReader.cpp`
- [Parse status](https://github.com/benhoyt/inih/blob/master/cpp/INIReader.cpp): `cpp/INIReader.cpp`

### Other components

- **Application caller**
- **Value callback**

## Connections

- Application caller → Parser API: calls parse (evidence: `README.md`)
- Parser API → File input: dispatches file (evidence: `ini.c`)
- Parser API → String input: dispatches string (evidence: `ini.c`)
- Parser API → Stream parser: exposes stream (evidence: `ini.c`)
- File input → Stream parser: delegates to (evidence: `ini.c`)
- String input → Stream parser: delegates to (evidence: `ini.c`)
- Custom reader → Stream parser: supplies reader (evidence: `ini.c`)
- Stream parser → Value callback: emits records (evidence: `ini.c`)
- Application caller → INIReader API: constructs reader (evidence: `README.md`)
- INIReader API → Reader parsing: implemented by (evidence: `cpp/INIReader.cpp`)
- Reader parsing → Parser API: calls parser (evidence: `cpp/INIReader.cpp`)
- Reader parsing → Value map: callback stores values (evidence: `cpp/INIReader.cpp`)
- INIReader API → Typed accessors: offers typed reads (evidence: `cpp/INIReader.h`)
- Typed accessors → Value map: looks up values (evidence: `cpp/INIReader.cpp`)
- INIReader API → Section queries: offers queries (evidence: `cpp/INIReader.h`)
- Section queries → Value map: scans values (evidence: `cpp/INIReader.cpp`)
- INIReader API → Parse status: offers status (evidence: `cpp/INIReader.h`)
