dump_data: display a human readable Data type.

This commit is contained in:
Alexandre Perrin 2016-07-18 14:27:17 +02:00
parent 3a6efb3d84
commit d78123da72

View file

@ -21,14 +21,24 @@
#include <jpeglib.h> #include <jpeglib.h>
#include <png.h> #include <png.h>
#include <quirc.h>
#include "dbgutil.h" #include "dbgutil.h"
void dump_data(const struct quirc_data *data) void dump_data(const struct quirc_data *data)
{ {
static const char *data_type_str[] = {
[QUIRC_DATA_TYPE_NUMERIC] = "NUMERIC",
[QUIRC_DATA_TYPE_ALPHA] = "ALPHANUMERIC",
[QUIRC_DATA_TYPE_BYTE] = "BINARY",
[QUIRC_DATA_TYPE_KANJI] = "KANJI",
};
printf(" Version: %d\n", data->version); printf(" Version: %d\n", data->version);
printf(" ECC level: %c\n", "MLHQ"[data->ecc_level]); printf(" ECC level: %c\n", "MLHQ"[data->ecc_level]);
printf(" Mask: %d\n", data->mask); printf(" Mask: %d\n", data->mask);
printf(" Data type: %d\n", data->data_type); printf(" Data type: %d (%s)\n",
data->data_type, data_type_str[data->data_type]);
printf(" Length: %d\n", data->payload_len); printf(" Length: %d\n", data->payload_len);
printf(" Payload: %s\n", data->payload); printf(" Payload: %s\n", data->payload);
} }