diff options
Diffstat (limited to 'easytool/utils.c')
-rw-r--r-- | easytool/utils.c | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/easytool/utils.c b/easytool/utils.c new file mode 100644 index 0000000..ab8fb72 --- /dev/null +++ b/easytool/utils.c @@ -0,0 +1,23 @@ + +#include <stdlib.h> +#include <unistd.h> +#include <stdint.h> +#include <stdio.h> + +#include "utils.h" + +static char namebuf[255]; +const char *get_value_string(const struct value_string *vs, uint32_t val) +{ + int i; + + for (i = 0;; i++) { + if (vs[i].value == 0 && vs[i].str == NULL) + break; + if (vs[i].value == val) + return vs[i].str; + } + + snprintf(namebuf, sizeof(namebuf), "unknown 0x%x", val); + return namebuf; +} |