# lion-simba/reink architecture

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

- Interactive diagram: https://gitdiagram.com/lion-simba/reink
- Repository: https://github.com/lion-simba/reink

## Overview

ReInk is a command-line utility for inspecting and resetting Epson printer ink and waste counters over the printer’s IEEE 1284.4 interface. The principal workflow selects a command and raw device, identifies or uses a printer model, communicates with the printer, then reports data or updates counters. The README also documents arbitrary EEPROM access and test reports. The transport implementation was not sampled, so its connection to the command layer is shown as unverified; other links use the README or excerpts as evidence.

Main entry points: [`reink.c`](https://github.com/lion-simba/reink/blob/master/reink.c) (Command handling), [`printers.c`](https://github.com/lion-simba/reink/blob/master/printers.c) (Model and counter maps), [`d4lib.h`](https://github.com/lion-simba/reink/blob/master/d4lib.h) (IEEE 1284.4 API), [`d4lib.c`](https://github.com/lion-simba/reink/blob/master/d4lib.c) (IEEE 1284.4 transport)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_cli["Command interface"]
  node_commands["Command handling<br/>[reink.c]"]
end

subgraph group_protocol["Printer communication"]
  node_protocol_api["IEEE 1284.4 API<br/>[d4lib.h]"]
  node_protocol_impl["IEEE 1284.4 transport<br/>[d4lib.c]"]
  node_printer_exchange["Printer transactions<br/>[reink.c]"]
end

subgraph group_features["Printer operations"]
  node_model_detection["Model detection<br/>[reink.c]"]
  node_ink_status["Ink level reading<br/>[reink.c]"]
  node_ink_reset["Ink counter reset<br/>[reink.c]"]
  node_waste_reset["Waste counter reset<br/>[reink.c]"]
  node_eeprom_read["EEPROM reading<br/>[reink.c]"]
  node_eeprom_write["EEPROM writing<br/>[reink.c]"]
  node_test_report["Printer test report<br/>[reink.c]"]
end

subgraph group_models["Printer profiles"]
  node_profiles[("Model and counter maps<br/>[printers.c]")]
end

node_operator(("Operator"))
node_device["Raw printer device"]

node_operator -->|"selects command"| node_commands
node_commands -->|"targets raw device"| node_device
node_commands -->|"detects model"| node_model_detection
node_model_detection -->|"queries"| node_device
node_commands -->|"requests levels"| node_ink_status
node_commands -->|"requests reset"| node_ink_reset
node_commands -->|"requests reset"| node_waste_reset
node_commands -->|"requests read"| node_eeprom_read
node_commands -->|"requests write"| node_eeprom_write
node_commands -->|"requests report"| node_test_report
node_ink_status -->|"transacts"| node_printer_exchange
node_ink_reset -.->|"transacts"| node_printer_exchange
node_waste_reset -.->|"transacts"| node_printer_exchange
node_eeprom_read -->|"reads through"| node_printer_exchange
node_eeprom_write -->|"writes through"| node_printer_exchange
node_test_report -.->|"queries printer"| node_printer_exchange
node_printer_exchange -->|"uses API"| node_protocol_api
node_protocol_api -.->|"implemented by"| node_protocol_impl
node_printer_exchange -->|"communicates with"| node_device
node_model_detection -->|"matches model"| node_profiles
node_ink_status -.->|"uses ink map"| node_profiles
node_ink_reset -.->|"uses ink map"| node_profiles
node_waste_reset -.->|"uses waste map"| node_profiles

click node_commands "https://github.com/lion-simba/reink/blob/master/reink.c"
click node_model_detection "https://github.com/lion-simba/reink/blob/master/reink.c"
click node_protocol_api "https://github.com/lion-simba/reink/blob/master/d4lib.h"
click node_protocol_impl "https://github.com/lion-simba/reink/blob/master/d4lib.c"
click node_printer_exchange "https://github.com/lion-simba/reink/blob/master/reink.c"
click node_profiles "https://github.com/lion-simba/reink/blob/master/printers.c"
click node_ink_status "https://github.com/lion-simba/reink/blob/master/reink.c"
click node_ink_reset "https://github.com/lion-simba/reink/blob/master/reink.c"
click node_waste_reset "https://github.com/lion-simba/reink/blob/master/reink.c"
click node_eeprom_read "https://github.com/lion-simba/reink/blob/master/reink.c"
click node_eeprom_write "https://github.com/lion-simba/reink/blob/master/reink.c"
click node_test_report "https://github.com/lion-simba/reink/blob/master/reink.c"

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_commands toneBlue
class node_protocol_api,node_protocol_impl,node_printer_exchange toneAmber
class node_model_detection,node_ink_status,node_ink_reset,node_waste_reset,node_eeprom_read,node_eeprom_write,node_test_report toneMint
class node_profiles toneRose
class node_operator,node_device toneIndigo
```

## Components

### Command interface

- [Command handling](https://github.com/lion-simba/reink/blob/master/reink.c): `reink.c`

### Printer communication

- [IEEE 1284.4 API](https://github.com/lion-simba/reink/blob/master/d4lib.h): `d4lib.h`
- [IEEE 1284.4 transport](https://github.com/lion-simba/reink/blob/master/d4lib.c): `d4lib.c`
- [Printer transactions](https://github.com/lion-simba/reink/blob/master/reink.c): `reink.c`

### Printer operations

- [Model detection](https://github.com/lion-simba/reink/blob/master/reink.c): `reink.c`
- [Ink level reading](https://github.com/lion-simba/reink/blob/master/reink.c): `reink.c`
- [Ink counter reset](https://github.com/lion-simba/reink/blob/master/reink.c): `reink.c`
- [Waste counter reset](https://github.com/lion-simba/reink/blob/master/reink.c): `reink.c`
- [EEPROM reading](https://github.com/lion-simba/reink/blob/master/reink.c): `reink.c`
- [EEPROM writing](https://github.com/lion-simba/reink/blob/master/reink.c): `reink.c`
- [Printer test report](https://github.com/lion-simba/reink/blob/master/reink.c): `reink.c`

### Printer profiles

- [Model and counter maps](https://github.com/lion-simba/reink/blob/master/printers.c): `printers.c`

### Other components

- **Operator**
- **Raw printer device**

## Connections

- Operator → Command handling: selects command (evidence: `README.md`)
- Command handling → Raw printer device: targets raw device (evidence: `README.md`)
- Command handling → Model detection: detects model (evidence: `reink.c`)
- Model detection → Raw printer device: queries (evidence: `reink.c`)
- Command handling → Ink level reading: requests levels (evidence: `README.md`)
- Command handling → Ink counter reset: requests reset (evidence: `README.md`)
- Command handling → Waste counter reset: requests reset (evidence: `README.md`)
- Command handling → EEPROM reading: requests read (evidence: `README.md`)
- Command handling → EEPROM writing: requests write (evidence: `README.md`)
- Command handling → Printer test report: requests report (evidence: `README.md`)
- Ink level reading → Printer transactions: transacts (evidence: `reink.c`)
- Ink counter reset → Printer transactions: transacts (evidence: `reink.c`)
- Waste counter reset → Printer transactions: transacts (evidence: `reink.c`)
- EEPROM reading → Printer transactions: reads through (evidence: `reink.c`)
- EEPROM writing → Printer transactions: writes through (evidence: `reink.c`)
- Printer test report → Printer transactions: queries printer (evidence: `reink.c`)
- Printer transactions → IEEE 1284.4 API: uses API (evidence: `reink.c`)
- IEEE 1284.4 API → IEEE 1284.4 transport: implemented by
- Printer transactions → Raw printer device: communicates with (evidence: `README.md`)
- Model detection → Model and counter maps: matches model (evidence: `reink.c`)
- Ink level reading → Model and counter maps: uses ink map
- Ink counter reset → Model and counter maps: uses ink map
- Waste counter reset → Model and counter maps: uses waste map
