From 84c60fc46182f8ddd3b96aeac4991a383ff1aaa4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mario=20H=C3=BCttel?= Date: Sun, 15 Jan 2023 21:09:46 +0100 Subject: [PATCH] Add test output value to CRC list --- src/named_crcs.c | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/src/named_crcs.c b/src/named_crcs.c index 119cf50..20be93c 100644 --- a/src/named_crcs.c +++ b/src/named_crcs.c @@ -110,19 +110,26 @@ void list_predefined_crcs(void) { ft_table_t *table; const struct named_crc *iter; + struct crc_calc crc; table = ft_create_table(); ft_set_cell_prop(table, 0, FT_ANY_COLUMN, FT_CPROP_ROW_TYPE, FT_ROW_HEADER); - ft_write_ln(table, "Name", "Polynomial", "Reversed", "Start Value", "Output XOR"); + ft_write_ln(table, "Name", "Polynomial", "Reversed", "Start Value", "Output XOR", "Test Value"); for (iter = predefined_crc_table; iter->name; iter++) { - ft_printf_ln(table, "%s|0x%lx|%s|0x%x|0x%x", + crc_init(&crc, &iter->settings); + /* Calculate the test value */ + crc_push_bytes(&crc, (const uint8_t *)"123456789", 9); + crc_finish_calc(&crc); + ft_printf_ln(table, "%s|0x%lx|%s|0x%x|0x%x|0x%x", iter->name, iter->settings.polynomial, iter->settings.rev ? "yes" : "no", iter->settings.start_value, - iter->settings.xor); + iter->settings.xor, + crc_get_value(&crc)); + crc_destroy(&crc); } printf("%s\n", ft_to_string(table));