dmi_create
Description
The dmi_create function creates a context, which holds the SMBIOS data it
is given, read from the system with dmi_open or from a dump file with
dmi_load, along with everything decoded from it, the errors raised
while doing so, and the logging handler.
A context is created closed: it holds no data until it is opened, and may be
opened again once it has been closed with dmi_close. The caller
destroys it with dmi_destroy.
The flags choose how the data is decoded, and are combined with the bitwise OR:
DMI_CONTEXT_FLAG_RELAXED, which is zero, makes as much of the table
available as possible: malformed structures are left undecoded, broken
references and invalid additional information entries are skipped, and the
errors are left in the error queue. A structure of an invalid length ends
the table, and missing firmware information leaves the vendor unknown.
DMI_CONTEXT_FLAG_STRICT makes opening fail if the table has any error.
Decoding and linking still go on after the first error, so that all of the
errors are reported to the error queue.
DMI_CONTEXT_FLAG_LINK resolves the references between the structures once
they are decoded, and attaches string properties (type 46) to the structures
they describe.
DMI_CONTEXT_FLAG_OVERLAY decodes the structures with the values of
additional information entries (type 40) applied. Entries usually carry
annotations with placeholder values rather than the values of fields, so
this is not done by default.
DMI_CONTEXT_FLAG_AUTO_MODULES enables the extension modules of the
platform as the context is opened, in addition to the ones enabled with
dmi_add_extension, unless their types conflict with the types of the
modules enabled before. The platform is told from the firmware and system
information, see dmi_get_platform, and the modules enabled this way
stay enabled until the context is closed.
A new context logs nothing, since it has no logging handler until
dmi_set_logger gives it one. Its logging level is DMI_LOG_DEBUG.
Return value
On success, returns the context. On failure, returns nullptr, which
happens when memory is exhausted only, and is not reported to any error
queue, since there is no context to hold it.
Examples
dmi_context_t *context = dmi_create(DMI_CONTEXT_FLAG_LINK);
if (context == nullptr)
return false;
if (dmi_open(context, nullptr)) {
...
}
dmi_destroy(context);