# oomsveta/get-next-line architecture

> Architecture diagram of the GitHub repository oomsveta/get-next-line, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-11-18). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/oomsveta/get-next-line
- Repository: https://github.com/oomsveta/get-next-line

## Overview

This is a small C library that returns one allocated line per call from a file descriptor, using bounded reads and retaining unread bytes between calls. The mandatory implementation keeps one static buffer; the bonus implementation tracks a separate buffer per descriptor. Both grow reusable storage, locate line boundaries, and extract results. The README also documents arbitrary BUFFER_SIZE and binary-data handling. Relationships below follow the sampled implementations and README; no unsampled components are inferred.

Main entry points: [`get_next_line.c`](https://github.com/oomsveta/get-next-line/blob/main/get_next_line.c) (Single-FD reader), [`get_next_line_bonus.c`](https://github.com/oomsveta/get-next-line/blob/main/get_next_line_bonus.c) (Multi-FD reader), [`get_next_line_utils.c`](https://github.com/oomsveta/get-next-line/blob/main/get_next_line_utils.c) (Single-buffer utilities), [`get_next_line_utils_bonus.c`](https://github.com/oomsveta/get-next-line/blob/main/get_next_line_utils_bonus.c) (FD buffer utilities)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_api["Line readers"]
  node_standard["Single-FD reader<br/>[get_next_line.c]"]
  node_bonus["Multi-FD reader"]
end

subgraph group_storage["Buffer management"]
  node_standard_utils["Single-buffer utilities"]
  node_bonus_utils["FD buffer utilities"]
  node_standard_state["Single buffer state<br/>[get_next_line.h]"]
  node_bonus_state["Per-FD state"]
end

subgraph group_io["Stream I/O"]
  node_read["read syscall"]
end

node_client(("Library caller"))

node_client -->|"calls"| node_standard
node_standard -->|"returns line"| node_client
node_standard -->|"reads bytes"| node_read
node_standard -->|"uses helpers"| node_standard_utils
node_standard -->|"uses state"| node_standard_state
node_client -->|"calls"| node_bonus
node_bonus -->|"returns line"| node_client
node_bonus -->|"reads bytes"| node_read
node_bonus -->|"manages FD buffers"| node_bonus_utils
node_bonus -->|"uses state"| node_bonus_state

click node_standard "https://github.com/oomsveta/get-next-line/blob/main/get_next_line.c"
click node_bonus "https://github.com/oomsveta/get-next-line/blob/main/get_next_line_bonus.c"
click node_standard_utils "https://github.com/oomsveta/get-next-line/blob/main/get_next_line_utils.c"
click node_bonus_utils "https://github.com/oomsveta/get-next-line/blob/main/get_next_line_utils_bonus.c"
click node_standard_state "https://github.com/oomsveta/get-next-line/blob/main/get_next_line.h"
click node_bonus_state "https://github.com/oomsveta/get-next-line/blob/main/get_next_line_bonus.h"

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_standard,node_bonus toneBlue
class node_standard_utils,node_bonus_utils,node_standard_state,node_bonus_state toneAmber
class node_read toneMint
class node_client toneIndigo
```

## Components

### Line readers

- [Single-FD reader](https://github.com/oomsveta/get-next-line/blob/main/get_next_line.c): `get_next_line.c`
- [Multi-FD reader](https://github.com/oomsveta/get-next-line/blob/main/get_next_line_bonus.c): `get_next_line_bonus.c`

### Buffer management

- [Single-buffer utilities](https://github.com/oomsveta/get-next-line/blob/main/get_next_line_utils.c): `get_next_line_utils.c`
- [FD buffer utilities](https://github.com/oomsveta/get-next-line/blob/main/get_next_line_utils_bonus.c): `get_next_line_utils_bonus.c`
- [Single buffer state](https://github.com/oomsveta/get-next-line/blob/main/get_next_line.h): `get_next_line.h`
- [Per-FD state](https://github.com/oomsveta/get-next-line/blob/main/get_next_line_bonus.h): `get_next_line_bonus.h`

### Stream I/O

- **read syscall**

### Other components

- **Library caller**

## Connections

- Library caller → Single-FD reader: calls (evidence: `README.md`)
- Single-FD reader → Library caller: returns line (evidence: `README.md`)
- Single-FD reader → read syscall: reads bytes (evidence: `README.md`)
- Single-FD reader → Single-buffer utilities: uses helpers (evidence: `get_next_line.c`)
- Single-FD reader → Single buffer state: uses state (evidence: `get_next_line.c`)
- Library caller → Multi-FD reader: calls (evidence: `README.md`)
- Multi-FD reader → Library caller: returns line (evidence: `README.md`)
- Multi-FD reader → read syscall: reads bytes (evidence: `README.md`)
- Multi-FD reader → FD buffer utilities: manages FD buffers (evidence: `get_next_line_bonus.c`)
- Multi-FD reader → Per-FD state: uses state (evidence: `get_next_line_bonus.c`)
