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

#include "config.h"

#include <glib.h>

#include "fu-uefi-mok-struct.h"

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

/**
 * fu_uefi_mok_hsi_key_from_string:
 * @val: (nullable): a string, e.g. `shim-has-nx-compat-set`
 *
 * Converts a string to an enumerated value.
 *
 * Returns: enumerated value
 **/
FuUefiMokHsiKey
fu_uefi_mok_hsi_key_from_string(const gchar *val)
{
    FuUefiMokHsiKey value = 0;
    g_auto(GStrv) split = NULL;
    g_return_val_if_fail(val != NULL, 0);
    split = g_strsplit(val, ",", -1);
    for (guint i = 0; split[i] != NULL; i++) {
        if (g_strcmp0(split[i], "none") == 0) {
            value |= FU_UEFI_MOK_HSI_KEY_NONE;
            continue;
        }
        if (g_strcmp0(split[i], "shim-has-nx-compat-set") == 0) {
            value |= FU_UEFI_MOK_HSI_KEY_SHIM_HAS_NX_COMPAT_SET;
            continue;
        }
        if (g_strcmp0(split[i], "heap-is-executable") == 0) {
            value |= FU_UEFI_MOK_HSI_KEY_HEAP_IS_EXECUTABLE;
            continue;
        }
        if (g_strcmp0(split[i], "stack-is-executable") == 0) {
            value |= FU_UEFI_MOK_HSI_KEY_STACK_IS_EXECUTABLE;
            continue;
        }
        if (g_strcmp0(split[i], "ro-sections-are-writable") == 0) {
            value |= FU_UEFI_MOK_HSI_KEY_RO_SECTIONS_ARE_WRITABLE;
            continue;
        }
        if (g_strcmp0(split[i], "has-memory-attribute-protocol") == 0) {
            value |= FU_UEFI_MOK_HSI_KEY_HAS_MEMORY_ATTRIBUTE_PROTOCOL;
            continue;
        }
        if (g_strcmp0(split[i], "has-dxe-services-table") == 0) {
            value |= FU_UEFI_MOK_HSI_KEY_HAS_DXE_SERVICES_TABLE;
            continue;
        }
        if (g_strcmp0(split[i], "has-get-memory-space-descriptor") == 0) {
            value |= FU_UEFI_MOK_HSI_KEY_HAS_GET_MEMORY_SPACE_DESCRIPTOR;
            continue;
        }
        if (g_strcmp0(split[i], "has-set-memory-space-attributes") == 0) {
            value |= FU_UEFI_MOK_HSI_KEY_HAS_SET_MEMORY_SPACE_ATTRIBUTES;
            continue;
        }
    }
    return value;
}
