From 88073dc5ce584e28ace84ebd0cae45ba624f5c48 Mon Sep 17 00:00:00 2001 From: Brian Pow Date: Thu, 1 Mar 2018 23:34:14 +0800 Subject: [PATCH] add PrintAndLogOptions --- client/ui.c | 27 ++++++++++++++++++++++++++- client/ui.h | 1 + 2 files changed, 27 insertions(+), 1 deletion(-) diff --git a/client/ui.c b/client/ui.c index 4cce0e497..60ccf4ac9 100644 --- a/client/ui.c +++ b/client/ui.c @@ -21,7 +21,32 @@ bool showDemod = true; pthread_mutex_t print_lock = PTHREAD_MUTEX_INITIALIZER; static char *logfilename = "proxmark3.log"; - +void PrintAndLogOptions(char *str[][2], size_t size, size_t space) +{ + char buff[2000] = "Options:\n"; + char format[2000] = ""; + size_t counts[2] = {0, 0}; + for(int i = 0; i < size; i++) + for(int j = 0 ; j < 2 ; j++) + if(counts[j] < strlen(str[i][j])) + { + counts[j] = strlen(str[i][j]); + } + for(int i = 0; i < size; i++) + { + for(int j = 0; j < 2; j++) + { + if(j == 0) + snprintf(format, sizeof(format), "%%%us%%%us", space, counts[j]); + else + snprintf(format, sizeof(format), "%%%us%%-%us", space, counts[j]); + snprintf(buff + strlen(buff), sizeof(buff) - strlen(buff), format, " ", str[i][j]); + } + if(i