lazybios 3.0.0
Lightweight SMBIOS/DMI parsing library
Loading...
Searching...
No Matches
Getting Started

Minimal workflows for reading SMBIOS data and accessing parsed structures.

Required lifecycle

Every ordinary workflow follows the same ownership sequence:

  1. Allocate a lazybiosCTX with lazybiosCTXNew.
  2. Load raw SMBIOS data with lazybiosInit, from the host system or from captured files.
  3. Parse the structures you need with the corresponding getter, which takes only the raw lazybiosDMI_t table, or parse every implemented type at once with lazybiosParseAll.
  4. Store the returned result set in the context when lazybiosCleanup should own it.
  5. Call lazybiosCleanup exactly once.

Choosing an input mode

lazybiosInit is the only loader. Its two path arguments select where the data comes from:

Call Source
lazybiosInit(ctx, NULL, NULL) this machine, through the platform backend
lazybiosInit(ctx, NULL, "dump.bin") one merged file holding both parts
lazybiosInit(ctx, "smbios_entry_point", "DMI") two separate raw files

The entry point comes first because it describes the table that follows. Passing an entry point with no table is rejected. File modes need no privileges and behave identically on every platform, which makes them the practical choice for tests and for reproducing a report from another machine.

Read from the host system

int read_host_bios(void) {
lazybiosCTX_t* ctx = lazybiosCTXNew();
if (!ctx) return -1;
if (lazybiosInit(ctx, NULL, NULL) != 0) {
return -1;
}
ctx->Type0 = lazybiosGetType0(ctx->DMIData);
if (!ctx->Type0) {
return -1;
}
return 0;
}

Read from separate dump files

int read_dump_files(const char* entry_path, const char* dmi_path) {
lazybiosCTX_t* ctx = lazybiosCTXNew();
if (!ctx) return -1;
if (lazybiosInit(ctx, entry_path, dmi_path) != 0) {
return -1;
}
ctx->Type1 = lazybiosGetType1(ctx->DMIData);
int result = ctx->Type1 ? 0 : -1;
return result;
}

Read from a merged dump file

int read_merged_dump(const char* binary_path) {
lazybiosCTX_t* ctx = lazybiosCTXNew();
if (!ctx) return -1;
int result = lazybiosInit(ctx, NULL, binary_path);
return result;
}

Read a repeated SMBIOS structure

Every getter returns a result set holding an entries array and its count, so the two can never drift apart. A non-NULL set whose count is zero means the table holds no structure of that type; NULL means the call itself failed.

int inspect_processors(lazybiosCTX_t* ctx) {
ctx->Type4 = lazybiosGetType4(ctx->DMIData);
if (!ctx->Type4) return -1;
for (size_t i = 0; i < ctx->Type4->count; ++i) {
const char* family = ctx->Type4->entries[i].decoded.processor_family;
(void)family;
}
return 0;
}

Parse everything at once

When an application wants the whole table rather than a few types, lazybiosParseAll fills every context member in one call. It skips members that are already populated, so calling it after parsing some types by hand does not strand the earlier results.

int parse_everything(lazybiosCTX_t* ctx) {
if (lazybiosParseAll(ctx) != 0) return -1;
/* Every implemented type is now populated, or NULL if that parse failed. */
if (ctx->Type17) {
for (size_t i = 0; i < ctx->Type17->count; ++i) {
const char* locator = ctx->Type17->entries[i].device_locator;
(void)locator;
}
}
return 0;
}

Next steps

Continue with Backends and Input Modes for backend behavior, Core Concepts and Ownership for ownership and field-status rules, and Standard SMBIOS Type Guides for field interpretation. The complete declarations are organized under Public API.