This change introduces a --libxo <fmt> option to /sbin/ifconfig which provides a means to export interface state data as JSON, XML, or HTML.
Summary of what has changed:
- refactored printf output into individual function calls; all reside in new file: ifconfig_output.c
- Each function in ifconfig_output.c also uses an ifdef gate to separate printf output from libxo output (libxo functionality is optional at build time)
- existing printf related functions were also moved to ifconfig_output.c and also now have ifdef gates
- all functions are prefixed with the name of the file that their printf statements came from:
- ifconfig_print_metric
- ifieee80211_print_channels
- af_inet_print_addr_ppp
- af_inet6_print_scopeid
- etc
- if_err, if_errc, if_errx, if_warn, if_warnc, if_warnx wrappers were created and all standard err/errx/warn/warnx/c calls were refactored to use the wrappers; the wrappers are gated to use either the standard calls or the libxo-provided err/warn functions.
- in several cases, the print functions that already existed like print_media, etc referenced utility functions that were kept in their respective source files but converted to non-static; in cases where this was done a .h file was created for their prototypes and they get included by ifconfig_output.c.
- Added a basic test that builds ifconfig with and without libxo, creates anumber of cloneable interfaces, then tests that the output of ifconfig with and without libxo are consistent.
- Formatted ifconfig_output.c and ifconfig_output.h with clang-format; used the .clang-format file in the root of the freebsd-src tree.