Add dfu_firmware_format_from_string()

This commit is contained in:
Richard Hughes 2016-08-26 17:56:04 +01:00
parent 3667ee7b22
commit 8e7f50056f
2 changed files with 27 additions and 0 deletions

View File

@ -738,6 +738,32 @@ dfu_firmware_format_to_string (DfuFirmwareFormat format)
return NULL;
}
/**
* dfu_firmware_format_from_string:
* @format: a format string, e.g. `dfuse`
*
* Returns an enumerated version of the format.
*
* Return value: a #DfuFirmwareFormat, e.g. %DFU_FIRMWARE_FORMAT_DFUSE
*
* Since: 0.7.3
**/
DfuFirmwareFormat
dfu_firmware_format_from_string (const gchar *format)
{
if (g_strcmp0 (format, "raw") == 0)
return DFU_FIRMWARE_FORMAT_RAW;
if (g_strcmp0 (format, "dfu") == 0)
return DFU_FIRMWARE_FORMAT_DFU_1_0;
if (g_strcmp0 (format, "dfuse") == 0)
return DFU_FIRMWARE_FORMAT_DFUSE;
if (g_strcmp0 (format, "ihex") == 0)
return DFU_FIRMWARE_FORMAT_INTEL_HEX;
if (g_strcmp0 (format, "elf") == 0)
return DFU_FIRMWARE_FORMAT_ELF;
return DFU_FIRMWARE_FORMAT_UNKNOWN;
}
/**
* dfu_firmware_get_cipher_kind:
* @firmware: a #DfuFirmware

View File

@ -92,6 +92,7 @@ typedef enum {
DfuFirmware *dfu_firmware_new (void);
const gchar *dfu_firmware_format_to_string (DfuFirmwareFormat format);
DfuFirmwareFormat dfu_firmware_format_from_string(const gchar *format);
DfuImage *dfu_firmware_get_image (DfuFirmware *firmware,
guint8 alt_setting);