diff options
-rw-r--r-- | include/datatype.h | 14 | ||||
-rw-r--r-- | src/datatype.c | 7 | ||||
-rw-r--r-- | src/services.c | 3 |
3 files changed, 20 insertions, 4 deletions
diff --git a/include/datatype.h b/include/datatype.h index a7db1df4..9f127f29 100644 --- a/include/datatype.h +++ b/include/datatype.h @@ -176,12 +176,24 @@ struct symbolic_constant { #define SYMBOL_LIST_END (struct symbolic_constant) { } /** + * enum base - indicate how to display symbol table values + * + * @BASE_HEXADECIMAL: hexadecimal + * @BASE_DECIMAL: decimal + */ +enum base { + BASE_HEXADECIMAL, + BASE_DECIMAL, +}; + +/** * struct symbol_table - type construction from symbolic values * + * @base: base of symbols representation * @symbols: the symbols */ struct symbol_table { - int gcc_workaround; + enum base base; struct symbolic_constant symbols[]; }; diff --git a/src/datatype.c b/src/datatype.c index 5600efcc..ec0b1201 100644 --- a/src/datatype.c +++ b/src/datatype.c @@ -204,8 +204,11 @@ void symbol_table_print(const struct symbol_table *tbl, if (byteorder == BYTEORDER_BIG_ENDIAN) switch_byteorder(&value, len); - printf("\t%-30s\t0x%.*" PRIx64 "\n", - s->identifier, 2 * len, value); + if (tbl->base == BASE_DECIMAL) + printf("\t%-30s\t%20lu\n", s->identifier, value); + else + printf("\t%-30s\t0x%.*" PRIx64 "\n", + s->identifier, 2 * len, value); } } diff --git a/src/services.c b/src/services.c index 0ba195e9..83c26723 100644 --- a/src/services.c +++ b/src/services.c @@ -2,7 +2,8 @@ #include <datatype.h> const struct symbol_table inet_service_tbl = { - .symbols = { + .base = BASE_DECIMAL, + .symbols = { SYMBOL("tcpmux", __constant_htons(1)), SYMBOL("echo", __constant_htons(7)), SYMBOL("discard", __constant_htons(9)), |