/*
 * This file is auto-generated, do not modify!
 *
 * SPDX-License-Identifier: LGPL-2.1-or-later
 */

#include "config.h"

#include <glib.h>

#include "fu-intel-me-smbios-struct.h"
#include "fu-byte-array.h"
#include "fu-bytes.h"
#include "fu-mem-private.h"
#include "fu-string.h"
#include "fu-intel-me-struct.h"
#include "fu-smbios-struct.h"

#ifdef G_LOG_DOMAIN
  #undef G_LOG_DOMAIN
#endif
#define G_LOG_DOMAIN "FuStruct"


/**
 * fu_smbios_fwsts_component_name_to_string:
 * @val: value, e.g. %FU_SMBIOS_FWSTS_COMPONENT_NAME_MEI2
 *
 * Converts an enumerated value to a string.
 *
 * Returns: identifier string
 **/
static const gchar *
fu_smbios_fwsts_component_name_to_string(FuSmbiosFwstsComponentName val)
{
    if (val == FU_SMBIOS_FWSTS_COMPONENT_NAME_MEI1)
        return "mei1";
    if (val == FU_SMBIOS_FWSTS_COMPONENT_NAME_MEI2)
        return "mei2";
    if (val == FU_SMBIOS_FWSTS_COMPONENT_NAME_MEI3)
        return "mei3";
    if (val == FU_SMBIOS_FWSTS_COMPONENT_NAME_MEI4)
        return "mei4";
    return NULL;
}
/**
 * fu_struct_me_version_ref: (skip):
 **/
FuStructMeVersion *
fu_struct_me_version_ref(FuStructMeVersion *st)
{
    g_return_val_if_fail(st != NULL, NULL);
    st->refcount++;
    return st;
}
/**
 * fu_struct_me_version_unref: (skip):
 **/
void
fu_struct_me_version_unref(FuStructMeVersion *st)
{
    g_return_if_fail(st != NULL);
    if (st->refcount == 0) {
        g_critical("FuStructMeVersion refcount already zero");
        return;
    }
    if (--st->refcount > 0)
        return;
    if (st->buf != NULL)
        g_byte_array_unref(st->buf);
    g_free(st);
}
/**
 * fu_struct_me_version_new_internal: (skip):
 **/
static FuStructMeVersion *
fu_struct_me_version_new_internal(void)
{
    FuStructMeVersion *st = g_new0(FuStructMeVersion, 1);
    st->refcount = 1;
    return st;
}

/* getters */
/**
 * fu_struct_me_version_get_major: (skip):
 **/
guint8
fu_struct_me_version_get_major(const FuStructMeVersion *st)
{
    g_return_val_if_fail(st != NULL, 0x0);
    return st->buf->data[0];
}
/**
 * fu_struct_me_version_get_minor: (skip):
 **/
guint8
fu_struct_me_version_get_minor(const FuStructMeVersion *st)
{
    g_return_val_if_fail(st != NULL, 0x0);
    return st->buf->data[1];
}
/**
 * fu_struct_me_version_get_patch: (skip):
 **/
guint8
fu_struct_me_version_get_patch(const FuStructMeVersion *st)
{
    g_return_val_if_fail(st != NULL, 0x0);
    return st->buf->data[2];
}
/**
 * fu_struct_me_version_get_build: (skip):
 **/
guint16
fu_struct_me_version_get_build(const FuStructMeVersion *st)
{
    g_return_val_if_fail(st != NULL, 0x0);
    return fu_memread_uint16(st->buf->data + 3, G_LITTLE_ENDIAN);
}

/* setters */
/**
 * fu_struct_me_version_to_string: (skip):
 **/
static gchar *
fu_struct_me_version_to_string(const FuStructMeVersion *st)
{
    g_autoptr(GString) str = g_string_new("FuStructMeVersion:\n");
    g_return_val_if_fail(st != NULL, NULL);
    g_string_append_printf(str, "  major: 0x%x\n",
                           (guint) fu_struct_me_version_get_major(st));
    g_string_append_printf(str, "  minor: 0x%x\n",
                           (guint) fu_struct_me_version_get_minor(st));
    g_string_append_printf(str, "  patch: 0x%x\n",
                           (guint) fu_struct_me_version_get_patch(st));
    g_string_append_printf(str, "  build: 0x%x\n",
                           (guint) fu_struct_me_version_get_build(st));
    if (str->len > 0)
        g_string_set_size(str, str->len - 1);
    return g_string_free(g_steal_pointer(&str), FALSE);
}
static gboolean
fu_struct_me_version_validate_internal(FuStructMeVersion *st, GError **error)
{
    g_return_val_if_fail(st != NULL, FALSE);
    return TRUE;
}
/**
 * fu_struct_me_fvi_header_ref: (skip):
 **/
FuStructMeFviHeader *
fu_struct_me_fvi_header_ref(FuStructMeFviHeader *st)
{
    g_return_val_if_fail(st != NULL, NULL);
    st->refcount++;
    return st;
}
/**
 * fu_struct_me_fvi_header_unref: (skip):
 **/
void
fu_struct_me_fvi_header_unref(FuStructMeFviHeader *st)
{
    g_return_if_fail(st != NULL);
    if (st->refcount == 0) {
        g_critical("FuStructMeFviHeader refcount already zero");
        return;
    }
    if (--st->refcount > 0)
        return;
    if (st->buf != NULL)
        g_byte_array_unref(st->buf);
    g_free(st);
}
/**
 * fu_struct_me_fvi_header_new_internal: (skip):
 **/
static FuStructMeFviHeader *
fu_struct_me_fvi_header_new_internal(void)
{
    FuStructMeFviHeader *st = g_new0(FuStructMeFviHeader, 1);
    st->refcount = 1;
    return st;
}

/* getters */
/**
 * fu_struct_me_fvi_header_get_count: (skip):
 **/
guint8
fu_struct_me_fvi_header_get_count(const FuStructMeFviHeader *st)
{
    g_return_val_if_fail(st != NULL, 0x0);
    return st->buf->data[0];
}

/* setters */
/**
 * fu_struct_me_fvi_header_to_string: (skip):
 **/
static gchar *
fu_struct_me_fvi_header_to_string(const FuStructMeFviHeader *st)
{
    g_autoptr(GString) str = g_string_new("FuStructMeFviHeader:\n");
    g_return_val_if_fail(st != NULL, NULL);
    g_string_append_printf(str, "  count: 0x%x\n",
                           (guint) fu_struct_me_fvi_header_get_count(st));
    if (str->len > 0)
        g_string_set_size(str, str->len - 1);
    return g_string_free(g_steal_pointer(&str), FALSE);
}
static gboolean
fu_struct_me_fvi_header_validate_internal(FuStructMeFviHeader *st, GError **error)
{
    g_return_val_if_fail(st != NULL, FALSE);
    return TRUE;
}
static gboolean
fu_struct_me_fvi_header_parse_internal(FuStructMeFviHeader *st, GError **error)
{
    if (g_log_get_debug_enabled()) {
        g_autofree gchar *str = fu_struct_me_fvi_header_to_string(st);
        g_debug("%s", str);
    }
    if (!fu_struct_me_fvi_header_validate_internal(st, error))
        return FALSE;
    return TRUE;
}

/**
 * fu_struct_me_fvi_header_parse: (skip):
 **/
static FuStructMeFviHeader *
fu_struct_me_fvi_header_parse(const guint8 *buf, gsize bufsz, gsize offset, GError **error)
{
    g_autoptr(FuStructMeFviHeader) st = fu_struct_me_fvi_header_new_internal();
    g_return_val_if_fail(buf != NULL, NULL);
    g_return_val_if_fail(error == NULL || *error == NULL, NULL);
    if (!fu_memchk_read(bufsz, offset, 1, error)) {
        g_prefix_error_literal(error, "invalid struct FuStructMeFviHeader: ");
        return NULL;
    }
    st->buf = g_byte_array_new();
    g_byte_array_append(st->buf, buf + offset, 1);
    if (!fu_struct_me_fvi_header_parse_internal(st, error))
        return NULL;
    return g_steal_pointer(&st);
}
/**
 * fu_struct_me_fvi_header_parse_bytes: (skip):
 **/
FuStructMeFviHeader *
fu_struct_me_fvi_header_parse_bytes(GBytes *blob, gsize offset, GError **error)
{
    gsize bufsz = 0;
    const guint8 *buf = fu_bytes_get_data_safe(blob, &bufsz, error);
    if (buf == NULL)
        return NULL;
    return fu_struct_me_fvi_header_parse(buf, bufsz, offset, error);
}
/**
 * fu_struct_me_fvi_data_ref: (skip):
 **/
FuStructMeFviData *
fu_struct_me_fvi_data_ref(FuStructMeFviData *st)
{
    g_return_val_if_fail(st != NULL, NULL);
    st->refcount++;
    return st;
}
/**
 * fu_struct_me_fvi_data_unref: (skip):
 **/
void
fu_struct_me_fvi_data_unref(FuStructMeFviData *st)
{
    g_return_if_fail(st != NULL);
    if (st->refcount == 0) {
        g_critical("FuStructMeFviData refcount already zero");
        return;
    }
    if (--st->refcount > 0)
        return;
    if (st->buf != NULL)
        g_byte_array_unref(st->buf);
    g_free(st);
}
/**
 * fu_struct_me_fvi_data_new_internal: (skip):
 **/
static FuStructMeFviData *
fu_struct_me_fvi_data_new_internal(void)
{
    FuStructMeFviData *st = g_new0(FuStructMeFviData, 1);
    st->refcount = 1;
    return st;
}

/* getters */
/**
 * fu_struct_me_fvi_data_get_component_name: (skip):
 **/
guint8
fu_struct_me_fvi_data_get_component_name(const FuStructMeFviData *st)
{
    g_return_val_if_fail(st != NULL, 0x0);
    return st->buf->data[0];
}
/**
 * fu_struct_me_fvi_data_get_component_string: (skip):
 **/
guint8
fu_struct_me_fvi_data_get_component_string(const FuStructMeFviData *st)
{
    g_return_val_if_fail(st != NULL, 0x0);
    return st->buf->data[1];
}
/**
 * fu_struct_me_fvi_data_get_version: (skip):
 **/
FuStructMeVersion *
fu_struct_me_fvi_data_get_version(const FuStructMeFviData *st)
{
    g_autoptr(FuStructMeVersion) st_tmp = fu_struct_me_version_new_internal();
    g_return_val_if_fail(st != NULL, NULL);
    st_tmp->buf = g_byte_array_new();
    g_byte_array_append(st_tmp->buf, st->buf->data + FU_STRUCT_ME_FVI_DATA_OFFSET_VERSION, 5);
    return g_steal_pointer(&st_tmp);
}

/* setters */
/**
 * fu_struct_me_fvi_data_to_string: (skip):
 **/
static gchar *
fu_struct_me_fvi_data_to_string(const FuStructMeFviData *st)
{
    g_autoptr(GString) str = g_string_new("FuStructMeFviData:\n");
    g_return_val_if_fail(st != NULL, NULL);
    g_string_append_printf(str, "  component_name: 0x%x\n",
                           (guint) fu_struct_me_fvi_data_get_component_name(st));
    g_string_append_printf(str, "  component_string: 0x%x\n",
                           (guint) fu_struct_me_fvi_data_get_component_string(st));
    {
        g_autoptr(FuStructMeVersion) st_tmp = fu_struct_me_fvi_data_get_version(st);
        g_autofree gchar *tmp = fu_struct_me_version_to_string(st_tmp);
        g_string_append_printf(str, "  version: %s\n", tmp);
    }
    if (str->len > 0)
        g_string_set_size(str, str->len - 1);
    return g_string_free(g_steal_pointer(&str), FALSE);
}
static gboolean
fu_struct_me_fvi_data_validate_internal(FuStructMeFviData *st, GError **error)
{
    g_return_val_if_fail(st != NULL, FALSE);
    {
        GByteArray buf_tmp = {
            .data = (guint8*) st->buf->data + 0x2,
            .len = 5,
        };
        FuStructMeVersion st_tmp = { .buf = &buf_tmp };
        if (!fu_struct_me_version_validate_internal(&st_tmp, error))
            return FALSE;
    }
    return TRUE;
}
static gboolean
fu_struct_me_fvi_data_parse_internal(FuStructMeFviData *st, GError **error)
{
    if (g_log_get_debug_enabled()) {
        g_autofree gchar *str = fu_struct_me_fvi_data_to_string(st);
        g_debug("%s", str);
    }
    if (!fu_struct_me_fvi_data_validate_internal(st, error))
        return FALSE;
    return TRUE;
}

/**
 * fu_struct_me_fvi_data_parse: (skip):
 **/
static FuStructMeFviData *
fu_struct_me_fvi_data_parse(const guint8 *buf, gsize bufsz, gsize offset, GError **error)
{
    g_autoptr(FuStructMeFviData) st = fu_struct_me_fvi_data_new_internal();
    g_return_val_if_fail(buf != NULL, NULL);
    g_return_val_if_fail(error == NULL || *error == NULL, NULL);
    if (!fu_memchk_read(bufsz, offset, 7, error)) {
        g_prefix_error_literal(error, "invalid struct FuStructMeFviData: ");
        return NULL;
    }
    st->buf = g_byte_array_new();
    g_byte_array_append(st->buf, buf + offset, 7);
    if (!fu_struct_me_fvi_data_parse_internal(st, error))
        return NULL;
    return g_steal_pointer(&st);
}
/**
 * fu_struct_me_fvi_data_parse_bytes: (skip):
 **/
FuStructMeFviData *
fu_struct_me_fvi_data_parse_bytes(GBytes *blob, gsize offset, GError **error)
{
    gsize bufsz = 0;
    const guint8 *buf = fu_bytes_get_data_safe(blob, &bufsz, error);
    if (buf == NULL)
        return NULL;
    return fu_struct_me_fvi_data_parse(buf, bufsz, offset, error);
}
/**
 * fu_struct_smbios_fwsts_ref: (skip):
 **/
FuStructSmbiosFwsts *
fu_struct_smbios_fwsts_ref(FuStructSmbiosFwsts *st)
{
    g_return_val_if_fail(st != NULL, NULL);
    st->refcount++;
    return st;
}
/**
 * fu_struct_smbios_fwsts_unref: (skip):
 **/
void
fu_struct_smbios_fwsts_unref(FuStructSmbiosFwsts *st)
{
    g_return_if_fail(st != NULL);
    if (st->refcount == 0) {
        g_critical("FuStructSmbiosFwsts refcount already zero");
        return;
    }
    if (--st->refcount > 0)
        return;
    if (st->buf != NULL)
        g_byte_array_unref(st->buf);
    g_free(st);
}
/**
 * fu_struct_smbios_fwsts_new_internal: (skip):
 **/
static FuStructSmbiosFwsts *
fu_struct_smbios_fwsts_new_internal(void)
{
    FuStructSmbiosFwsts *st = g_new0(FuStructSmbiosFwsts, 1);
    st->refcount = 1;
    return st;
}

/* getters */
/**
 * fu_struct_smbios_fwsts_get_type: (skip):
 **/
static guint8
fu_struct_smbios_fwsts_get_type(const FuStructSmbiosFwsts *st)
{
    g_return_val_if_fail(st != NULL, 0x0);
    return st->buf->data[0];
}
/**
 * fu_struct_smbios_fwsts_get_length: (skip):
 **/
guint8
fu_struct_smbios_fwsts_get_length(const FuStructSmbiosFwsts *st)
{
    g_return_val_if_fail(st != NULL, 0x0);
    return st->buf->data[1];
}
/**
 * fu_struct_smbios_fwsts_get_handle: (skip):
 **/
guint16
fu_struct_smbios_fwsts_get_handle(const FuStructSmbiosFwsts *st)
{
    g_return_val_if_fail(st != NULL, 0x0);
    return fu_memread_uint16(st->buf->data + 2, G_LITTLE_ENDIAN);
}
/**
 * fu_struct_smbios_fwsts_get_version: (skip):
 **/
static guint8
fu_struct_smbios_fwsts_get_version(const FuStructSmbiosFwsts *st)
{
    g_return_val_if_fail(st != NULL, 0x0);
    return st->buf->data[4];
}
/**
 * fu_struct_smbios_fwsts_get_count: (skip):
 **/
guint8
fu_struct_smbios_fwsts_get_count(const FuStructSmbiosFwsts *st)
{
    g_return_val_if_fail(st != NULL, 0x0);
    return st->buf->data[5];
}

/* setters */
/**
 * fu_struct_smbios_fwsts_to_string: (skip):
 **/
static gchar *
fu_struct_smbios_fwsts_to_string(const FuStructSmbiosFwsts *st)
{
    g_autoptr(GString) str = g_string_new("FuStructSmbiosFwsts:\n");
    g_return_val_if_fail(st != NULL, NULL);
    g_string_append_printf(str, "  type: 0x%x\n",
                           (guint) fu_struct_smbios_fwsts_get_type(st));
    g_string_append_printf(str, "  length: 0x%x\n",
                           (guint) fu_struct_smbios_fwsts_get_length(st));
    g_string_append_printf(str, "  handle: 0x%x\n",
                           (guint) fu_struct_smbios_fwsts_get_handle(st));
    g_string_append_printf(str, "  version: 0x%x\n",
                           (guint) fu_struct_smbios_fwsts_get_version(st));
    g_string_append_printf(str, "  count: 0x%x\n",
                           (guint) fu_struct_smbios_fwsts_get_count(st));
    if (str->len > 0)
        g_string_set_size(str, str->len - 1);
    return g_string_free(g_steal_pointer(&str), FALSE);
}
static gboolean
fu_struct_smbios_fwsts_validate_internal(FuStructSmbiosFwsts *st, GError **error)
{
    g_return_val_if_fail(st != NULL, FALSE);
    if (fu_struct_smbios_fwsts_get_type(st) != 0xDB) {
        g_set_error_literal(error,
                            FWUPD_ERROR,
                            FWUPD_ERROR_INVALID_DATA,
                            "constant FuStructSmbiosFwsts.type was not valid");
        return FALSE;
    }
    if (fu_struct_smbios_fwsts_get_version(st) != 0x01) {
        g_set_error_literal(error,
                            FWUPD_ERROR,
                            FWUPD_ERROR_INVALID_DATA,
                            "constant FuStructSmbiosFwsts.version was not valid");
        return FALSE;
    }
    return TRUE;
}
static gboolean
fu_struct_smbios_fwsts_parse_internal(FuStructSmbiosFwsts *st, GError **error)
{
    if (g_log_get_debug_enabled()) {
        g_autofree gchar *str = fu_struct_smbios_fwsts_to_string(st);
        g_debug("%s", str);
    }
    if (!fu_struct_smbios_fwsts_validate_internal(st, error))
        return FALSE;
    return TRUE;
}

/**
 * fu_struct_smbios_fwsts_parse: (skip):
 **/
static FuStructSmbiosFwsts *
fu_struct_smbios_fwsts_parse(const guint8 *buf, gsize bufsz, gsize offset, GError **error)
{
    g_autoptr(FuStructSmbiosFwsts) st = fu_struct_smbios_fwsts_new_internal();
    g_return_val_if_fail(buf != NULL, NULL);
    g_return_val_if_fail(error == NULL || *error == NULL, NULL);
    if (!fu_memchk_read(bufsz, offset, 6, error)) {
        g_prefix_error_literal(error, "invalid struct FuStructSmbiosFwsts: ");
        return NULL;
    }
    st->buf = g_byte_array_new();
    g_byte_array_append(st->buf, buf + offset, 6);
    if (!fu_struct_smbios_fwsts_parse_internal(st, error))
        return NULL;
    return g_steal_pointer(&st);
}
/**
 * fu_struct_smbios_fwsts_parse_bytes: (skip):
 **/
FuStructSmbiosFwsts *
fu_struct_smbios_fwsts_parse_bytes(GBytes *blob, gsize offset, GError **error)
{
    gsize bufsz = 0;
    const guint8 *buf = fu_bytes_get_data_safe(blob, &bufsz, error);
    if (buf == NULL)
        return NULL;
    return fu_struct_smbios_fwsts_parse(buf, bufsz, offset, error);
}
/**
 * fu_struct_smbios_fwsts_record_ref: (skip):
 **/
FuStructSmbiosFwstsRecord *
fu_struct_smbios_fwsts_record_ref(FuStructSmbiosFwstsRecord *st)
{
    g_return_val_if_fail(st != NULL, NULL);
    st->refcount++;
    return st;
}
/**
 * fu_struct_smbios_fwsts_record_unref: (skip):
 **/
void
fu_struct_smbios_fwsts_record_unref(FuStructSmbiosFwstsRecord *st)
{
    g_return_if_fail(st != NULL);
    if (st->refcount == 0) {
        g_critical("FuStructSmbiosFwstsRecord refcount already zero");
        return;
    }
    if (--st->refcount > 0)
        return;
    if (st->buf != NULL)
        g_byte_array_unref(st->buf);
    g_free(st);
}
/**
 * fu_struct_smbios_fwsts_record_new_internal: (skip):
 **/
static FuStructSmbiosFwstsRecord *
fu_struct_smbios_fwsts_record_new_internal(void)
{
    FuStructSmbiosFwstsRecord *st = g_new0(FuStructSmbiosFwstsRecord, 1);
    st->refcount = 1;
    return st;
}

/* getters */
/**
 * fu_struct_smbios_fwsts_record_get_component_name: (skip):
 **/
FuSmbiosFwstsComponentName
fu_struct_smbios_fwsts_record_get_component_name(const FuStructSmbiosFwstsRecord *st)
{
    g_return_val_if_fail(st != NULL, 0x0);
    return st->buf->data[0];
}
/**
 * fu_struct_smbios_fwsts_record_get_fwsts: (skip):
 **/
FuStructIntelMeHfsts *
fu_struct_smbios_fwsts_record_get_fwsts(const FuStructSmbiosFwstsRecord *st, guint idx)
{
    g_autoptr(FuStructIntelMeHfsts) st_tmp = fu_struct_intel_me_hfsts_new_internal();
    g_return_val_if_fail(st != NULL, NULL);
    g_return_val_if_fail(idx < 6, NULL);
    st_tmp->buf = g_byte_array_new();
    g_byte_array_append(st_tmp->buf,
                        st->buf->data
                            + FU_STRUCT_SMBIOS_FWSTS_RECORD_OFFSET_FWSTS
                            + (FU_STRUCT_INTEL_ME_HFSTS_SIZE * idx),
                        4);
    return g_steal_pointer(&st_tmp);
}

/* setters */
/**
 * fu_struct_smbios_fwsts_record_to_string: (skip):
 **/
static gchar *
fu_struct_smbios_fwsts_record_to_string(const FuStructSmbiosFwstsRecord *st)
{
    g_autoptr(GString) str = g_string_new("FuStructSmbiosFwstsRecord:\n");
    g_return_val_if_fail(st != NULL, NULL);
    {
        const gchar *tmp = fu_smbios_fwsts_component_name_to_string(fu_struct_smbios_fwsts_record_get_component_name(st));
        if (tmp != NULL) {
            g_string_append_printf(str, "  component_name: 0x%x [%s]\n", (guint) fu_struct_smbios_fwsts_record_get_component_name(st), tmp);
        } else {
            g_string_append_printf(str, "  component_name: 0x%x\n", (guint) fu_struct_smbios_fwsts_record_get_component_name(st));
        }
    }
    for (guint i = 0; i < 6; i++) {
        g_autoptr(FuStructIntelMeHfsts) st_tmp = fu_struct_smbios_fwsts_record_get_fwsts(st, i);
        g_autofree gchar *tmp = fu_struct_intel_me_hfsts_to_string(st_tmp);
        g_string_append_printf(str, "  fwsts[%u]: %s\n", i, tmp);
    }
    if (str->len > 0)
        g_string_set_size(str, str->len - 1);
    return g_string_free(g_steal_pointer(&str), FALSE);
}
static gboolean
fu_struct_smbios_fwsts_record_validate_internal(FuStructSmbiosFwstsRecord *st, GError **error)
{
    g_return_val_if_fail(st != NULL, FALSE);
    {
        GByteArray buf_tmp = {
            .data = (guint8*) st->buf->data + 0x1,
            .len = 24,
        };
        FuStructIntelMeHfsts st_tmp = { .buf = &buf_tmp };
        if (!fu_struct_intel_me_hfsts_validate_internal(&st_tmp, error))
            return FALSE;
    }
    return TRUE;
}
static gboolean
fu_struct_smbios_fwsts_record_parse_internal(FuStructSmbiosFwstsRecord *st, GError **error)
{
    if (g_log_get_debug_enabled()) {
        g_autofree gchar *str = fu_struct_smbios_fwsts_record_to_string(st);
        g_debug("%s", str);
    }
    if (!fu_struct_smbios_fwsts_record_validate_internal(st, error))
        return FALSE;
    return TRUE;
}

/**
 * fu_struct_smbios_fwsts_record_parse: (skip):
 **/
static FuStructSmbiosFwstsRecord *
fu_struct_smbios_fwsts_record_parse(const guint8 *buf, gsize bufsz, gsize offset, GError **error)
{
    g_autoptr(FuStructSmbiosFwstsRecord) st = fu_struct_smbios_fwsts_record_new_internal();
    g_return_val_if_fail(buf != NULL, NULL);
    g_return_val_if_fail(error == NULL || *error == NULL, NULL);
    if (!fu_memchk_read(bufsz, offset, 25, error)) {
        g_prefix_error_literal(error, "invalid struct FuStructSmbiosFwstsRecord: ");
        return NULL;
    }
    st->buf = g_byte_array_new();
    g_byte_array_append(st->buf, buf + offset, 25);
    if (!fu_struct_smbios_fwsts_record_parse_internal(st, error))
        return NULL;
    return g_steal_pointer(&st);
}
/**
 * fu_struct_smbios_fwsts_record_parse_bytes: (skip):
 **/
FuStructSmbiosFwstsRecord *
fu_struct_smbios_fwsts_record_parse_bytes(GBytes *blob, gsize offset, GError **error)
{
    gsize bufsz = 0;
    const guint8 *buf = fu_bytes_get_data_safe(blob, &bufsz, error);
    if (buf == NULL)
        return NULL;
    return fu_struct_smbios_fwsts_record_parse(buf, bufsz, offset, error);
}
