=== Sockstat UI Improvements

Links: +
link:https://wiki.freebsd.org/SummerOfCode2025Projects/SockstatUIImprovements[Sockstat UI Improvements  wiki] URL: https://wiki.freebsd.org/SummerOfCode2025Projects/SockstatUIImprovements[] +
link:https://github.com/freebsd/freebsd-src/pull/1720[Automatic column sizing PR] URL: https://github.com/freebsd/freebsd-src/pull/1720[] +
link:https://github.com/freebsd/freebsd-src/pull/1746[Reintroduced -w flag PR] URL: https://github.com/freebsd/freebsd-src/pull/1746[] +
link:https://github.com/freebsd/freebsd-src/pull/1753[Microoptimize cap-getnameinfo PR] URL: https://github.com/freebsd/freebsd-src/pull/1753[] +
link:https://github.com/freebsd/freebsd-src/pull/1770[Libxo support PR] URL: https://github.com/freebsd/freebsd-src/pull/1770[] +
link:https://github.com/freebsd/freebsd-src/pull/1799[Revert incorrect use of path-state for SCTP connections PR] URL: https://github.com/freebsd/freebsd-src/pull/1799[] +
link:https://github.com/freebsd/freebsd-src/pull/1806[Complete libxo integration PR] URL: https://github.com/freebsd/freebsd-src/pull/1806[] +
link:https://github.com/freebsd/freebsd-src/pull/1807[Fix port parsing after libxo integration PR] URL: https://github.com/freebsd/freebsd-src/pull/1807[] +

Contact: Damin Rido <rido@FreeBSD.org>

Sockstat is a command-line tool in FreeBSD that displays detailed information about open network sockets.
However, its traditional fixed-width formatting made the output hard to read, especially when handling long addresses.
This project improves sockstat by introducing dynamically sized columns and structured output support via libxo.
With these enhancements, users can more easily read output on the terminal or export the data in formats such as JSON, XML, or HTML for scripting and integration with external tools.

The sockstat utility underwent improvements in two phases.
First, the fixed-width layout was replaced with dynamic column sizing using a two-pass algorithm to ensure proper alignment and readability, including cases with long socket addresses.
The `-w` option was redefined to enable wide, auto-sized output while maintaining compatibility with default terminal displays.
In the second phase, libxo support was integrated by replacing `printf()` calls with `xo_emit()`, applying appropriate field tagging, and validating the output using libxo's tools.
The manual pages were updated to document the libxo integration.
These changes provide machine-readable structured output while preserving traditional human-readable formatting.

Following the sockstat conversion, the `parse_ports` function was identified as broken.
Due to its complexity, the function warranted the addition of unit tests to ensure correct behavior.
The issue was addressed by fixing the function and introducing a set of unit tests.
The codebase was refactored by renaming `sockstat.c` to `main.c` .

This project was part of Google Summer of Code 2025.
It has modernized sockstat and made it both more user-friendly and better suited for integration into automated workflows.

Sponsor: Google Summer of Code 2025