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

#include "config.h"

#include <glib.h>

#include "fwupd-jcat-struct.h"

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

/**
 * fwupd_jcat_blob_kind_to_string:
 * @val: value, e.g. %FWUPD_JCAT_BLOB_KIND_SHA256
 *
 * Converts an enumerated value to a string.
 *
 * Returns: identifier string
 *
 * Since: 2.1.3
 **/
const gchar *
fwupd_jcat_blob_kind_to_string(FwupdJcatBlobKind val)
{
    if (val == FWUPD_JCAT_BLOB_KIND_SHA256)
        return "sha256";
    if (val == FWUPD_JCAT_BLOB_KIND_GPG)
        return "gpg";
    if (val == FWUPD_JCAT_BLOB_KIND_PKCS7)
        return "pkcs7";
    if (val == FWUPD_JCAT_BLOB_KIND_SHA1)
        return "sha1";
    if (val == FWUPD_JCAT_BLOB_KIND_BT_MANIFEST)
        return "bt-manifest";
    if (val == FWUPD_JCAT_BLOB_KIND_BT_CHECKPOINT)
        return "bt-checkpoint";
    if (val == FWUPD_JCAT_BLOB_KIND_BT_INCLUSION_PROOF)
        return "bt-inclusion-proof";
    if (val == FWUPD_JCAT_BLOB_KIND_BT_VERIFIER)
        return "bt-verifier";
    if (val == FWUPD_JCAT_BLOB_KIND_ED25519)
        return "ed25519";
    if (val == FWUPD_JCAT_BLOB_KIND_SHA512)
        return "sha512";
    if (val == FWUPD_JCAT_BLOB_KIND_BT_LOGINDEX)
        return "bt-logindex";
    return NULL;
}
/**
 * fwupd_jcat_blob_kind_from_string:
 * @val: (nullable): a string, e.g. `sha256`
 *
 * Converts a string to an enumerated value.
 *
 * Returns: enumerated value
 *
 * Since: 2.1.3
 **/
FwupdJcatBlobKind
fwupd_jcat_blob_kind_from_string(const gchar *val)
{
    if (g_strcmp0(val, "sha256") == 0)
        return FWUPD_JCAT_BLOB_KIND_SHA256;
    if (g_strcmp0(val, "gpg") == 0)
        return FWUPD_JCAT_BLOB_KIND_GPG;
    if (g_strcmp0(val, "pkcs7") == 0)
        return FWUPD_JCAT_BLOB_KIND_PKCS7;
    if (g_strcmp0(val, "sha1") == 0)
        return FWUPD_JCAT_BLOB_KIND_SHA1;
    if (g_strcmp0(val, "bt-manifest") == 0)
        return FWUPD_JCAT_BLOB_KIND_BT_MANIFEST;
    if (g_strcmp0(val, "bt-checkpoint") == 0)
        return FWUPD_JCAT_BLOB_KIND_BT_CHECKPOINT;
    if (g_strcmp0(val, "bt-inclusion-proof") == 0)
        return FWUPD_JCAT_BLOB_KIND_BT_INCLUSION_PROOF;
    if (g_strcmp0(val, "bt-verifier") == 0)
        return FWUPD_JCAT_BLOB_KIND_BT_VERIFIER;
    if (g_strcmp0(val, "ed25519") == 0)
        return FWUPD_JCAT_BLOB_KIND_ED25519;
    if (g_strcmp0(val, "sha512") == 0)
        return FWUPD_JCAT_BLOB_KIND_SHA512;
    if (g_strcmp0(val, "bt-logindex") == 0)
        return FWUPD_JCAT_BLOB_KIND_BT_LOGINDEX;
    return FWUPD_JCAT_BLOB_KIND_UNKNOWN;
}

/**
 * fwupd_jcat_blob_method_to_string:
 * @val: value, e.g. %FWUPD_JCAT_BLOB_METHOD_CHECKSUM
 *
 * Converts an enumerated value to a string.
 *
 * Returns: identifier string
 *
 * Since: 2.1.3
 **/
const gchar *
fwupd_jcat_blob_method_to_string(FwupdJcatBlobMethod val)
{
    if (val == FWUPD_JCAT_BLOB_METHOD_CHECKSUM)
        return "checksum";
    if (val == FWUPD_JCAT_BLOB_METHOD_SIGNATURE)
        return "signature";
    return NULL;
}

/**
 * fwupd_jcat_blob_flags_to_string:
 * @val: value, e.g. %FWUPD_JCAT_BLOB_FLAG_IS_UTF8
 *
 * Converts an enumerated value to a string.
 *
 * Returns: identifier string
 *
 *
 * Since: 2.1.3
 **/
gchar *
fwupd_jcat_blob_flags_to_string(FwupdJcatBlobFlags val)
{
    const gchar *data[2] = {0};
    guint idx = 0;
    if (val == FWUPD_JCAT_BLOB_FLAG_NONE)
        return g_strdup("none");
    if (val & FWUPD_JCAT_BLOB_FLAG_IS_UTF8)
        data[idx++] = "is-utf8";
    return g_strjoinv(",", (gchar **)data);
}
