<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="color-scheme" content="dark light">
<meta name="description" content="htoprs — a faithful Rust port of htop, the interactive process viewer. The htop 3.5.1 C source is the spec; every function under src/ported/ ports a specific htop C function, cited by File.c:line, enforced by a build-time port-purity gate.">
<title>htoprs — Documentation</title>
<link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<link href="https://fonts.googleapis.com/css2?family=Orbitron:wght@400;600;700;900&family=Share+Tech+Mono&display=swap" rel="stylesheet">
<link rel="stylesheet" href="hud-static.css">
<link rel="stylesheet" href="tutorial.css">
<style>
.tutorial-main { max-width: 68rem; }
.docs-build-line {
margin: 0.35rem 0 0;
font-family: 'Share Tech Mono', ui-monospace, monospace;
font-size: 11px;
color: var(--text-dim);
letter-spacing: 0.03em;
max-width: 46rem;
opacity: 0.75;
}
.example-tbl { width: 100%; border-collapse: collapse; margin: 0.6rem 0; font-size: 12.5px; }
.example-tbl td {
padding: 6px 10px;
border: 1px solid var(--border);
vertical-align: top;
color: var(--text-dim);
}
.example-tbl td:first-child { width: 40%; color: var(--cyan); font-family: 'Share Tech Mono', monospace; }
.example-tbl td code { color: var(--accent-light); background: var(--bg); padding: 1px 5px; font-size: 12px; }
</style>
</head>
<body>
<div class="app tutorial-app" id="docsApp">
<div class="crt-scanline" id="crtH" aria-hidden="true"></div>
<div class="crt-scanline-v" id="crtV" aria-hidden="true"></div>
<header class="tutorial-header">
<div class="tutorial-header-inner">
<div>
<h1 class="tutorial-brand">// HTOPRS — A FAITHFUL RUST PORT OF HTOP</h1>
<nav class="tutorial-crumbs" aria-label="Breadcrumb">
<span class="current">Docs</span>
<span class="sep">/</span>
<a href="report.html">Engineering report</a>
<span class="sep">/</span>
<a href="port_report.html">Port report</a>
<span class="sep">/</span>
<a href="https://github.com/MenkeTechnologies/htoprs" target="_blank" rel="noopener noreferrer">GitHub</a>
<span class="sep">/</span>
<a href="https://github.com/MenkeTechnologies/MenkeTechnologiesMeta" target="_blank" rel="noopener noreferrer">Meta</a>
</nav>
<p class="docs-build-line">faithful port · htop 3.5.1 is the spec · C source at ~/forkedRepos/htop · function-for-function, cited File.c:line · build-time port-purity gate</p>
</div>
<div class="tutorial-toolbar">
<button type="button" class="btn btn-secondary" id="btnTheme" title="Toggle light/dark">Theme</button>
<button type="button" class="btn btn-secondary active" id="btnCrt" title="CRT scanline overlay">CRT</button>
<button type="button" class="btn btn-secondary active" id="btnNeon" title="Neon border pulse">Neon</button>
<a class="btn btn-secondary" href="report.html">Report</a>
<a class="btn btn-secondary" href="port_report.html">Port report</a>
<a class="btn btn-secondary" href="https://github.com/MenkeTechnologies/htoprs" target="_blank" rel="noopener noreferrer">GitHub</a>
</div>
</div>
</header>
<main class="tutorial-main">
<h2 class="tutorial-title"><span class="step-hash">>_</span>HTOPRS</h2>
<p class="tutorial-subtitle"><strong>The htop C source is the spec.</strong> htoprs is a faithful Rust port of <a href="https://github.com/htop-dev/htop" target="_blank" rel="noopener noreferrer">htop</a>, the interactive process viewer. The upstream C is translated <strong>function-for-function</strong>, never reimplemented from scratch. Every function under <code>src/ported/</code> ports a specific htop C function and cites its origin (<code><File>.c:<line></code>) in its doc comment.</p>
<section class="tutorial-section">
<h2>Porting methodology</h2>
<table class="example-tbl">
<tbody>
<tr><td>Spec</td><td>htop <strong>3.5.1</strong> at <code>~/forkedRepos/htop</code> (131 <code>.c</code> files, platform-split darwin / linux / freebsd / …)</td></tr>
<tr><td>Port tree</td><td><code>src/ported/<file>.rs</code> — one Rust module per C file; each <code>fn</code> cites <code>/// Port of</code> its <code><File>.c:<line></code> origin</td></tr>
<tr><td>Port-purity gate</td><td><code>build.rs</code> checks every free <code>fn</code> name under <code>src/ported/</code> against the htop C-function snapshot; a name with no C counterpart fails the build. Cannot be bypassed by <code>cargo test --test X</code></td></tr>
<tr><td>C-name snapshot</td><td><code>tests/data/htop_c_fn_names.txt</code>, regenerated by <code>tests/data/extract_c_fn_names.sh</code> after pulling upstream htop</td></tr>
<tr><td>Allowlist</td><td><code>tests/data/fake_fn_allowlist.txt</code> — genuine Rust-only architectural helpers only, each justified</td></tr>
<tr><td>Port report</td><td><code>scripts/gen_port_report.py</code> → <a href="port_report.html">port_report.html</a>, per-file + overall coverage derived from source at run time</td></tr>
</tbody>
</table>
</section>
<section class="tutorial-section">
<h2>Ported so far — <code>XUtils.c</code></h2>
<p>htop's string and math utility layer. The pure string/math functions port faithfully; the C allocation wrappers, null-terminated helpers, varargs formatters, and <code>String_freeArray</code> have no faithful safe-Rust analog (Rust owns its allocation, bounds, and lifetimes) and are intentionally not ported.</p>
<table class="example-tbl">
<tbody>
<tr><td><code>String_cat</code></td><td>concatenation</td></tr>
<tr><td><code>String_trim</code></td><td>trims leading/trailing space, tab, newline (only those three)</td></tr>
<tr><td><code>String_split</code></td><td>splits on a separator; interior empties kept, trailing empty dropped</td></tr>
<tr><td><code>String_splitFirst</code></td><td>splits on the first separator only</td></tr>
<tr><td><code>String_contains_i</code></td><td>case-insensitive substring; pipe-separated multi-needle mode</td></tr>
<tr><td><code>compareRealNumbers</code></td><td>NaN-aware ordering (NaN sorts first)</td></tr>
<tr><td><code>sumPositiveValues</code></td><td>sum of strictly-positive values, NaN skipped</td></tr>
<tr><td><code>countDigits</code></td><td>digit count in a given base, with overflow guard</td></tr>
<tr><td><code>countTrailingZeros</code></td><td>mod-37 lowest-set-bit table</td></tr>
</tbody>
</table>
</section>
<section class="tutorial-section">
<h2>Build & test</h2>
<pre>cargo build # runs the port-purity gate
cargo test # hand-crafted unit tests pin the C edge behavior
python3 scripts/gen_port_report.py # regenerate docs/port_report.html</pre>
<p>The snapshot is regenerated with <code>HTOP_C_SOURCE=~/forkedRepos/htop tests/data/extract_c_fn_names.sh</code> after pulling new upstream htop commits.</p>
</section>
<section class="tutorial-section">
<h2>The MenkeTechnologies stack</h2>
<p>htoprs follows the same faithful-port precedent as <a href="https://github.com/MenkeTechnologies/zshrs" target="_blank" rel="noopener noreferrer">zshrs</a> (the first compiled Unix shell, a 1:1 port of zsh's C). Browse the rest via the <a href="https://github.com/MenkeTechnologies/MenkeTechnologiesMeta" target="_blank" rel="noopener noreferrer">MenkeTechnologiesMeta</a> umbrella repo.</p>
</section>
</main>
</div>
<script src="hud-theme.js"></script>
</body>
</html>