dmi_version_format

Synopsis

#include <opendmi/utils/version.h>

char *dmi_version_format(dmi_version_t version);

Description

The dmi_version_format function formats an SMBIOS version number as a human-readable, dynamically allocated string.

If the revision component of version is zero, the result uses the "major.minor" form (e.g., "3.4"). Otherwise, the full "major.minor.revision" form is used (e.g., "3.4.1").

The caller is responsible for freeing the returned string.

Parameters

version

SMBIOS version number constructed with dmi_version or the DMI_VERSION macro.

Return value

On success, returns a newly allocated null-terminated string containing the formatted version. On failure (e.g., allocation error), returns nullptr.

Errors

None.

Examples

dmi_version_t ver = dmi_version(3, 4, 0);
char *str = dmi_version_format(ver);
if (str != nullptr) {
    printf("SMBIOS version: %s\n", str); // "3.4"
    free(str);
}