Merge pull request #197 from brianpow/PrintAndLogOptions

add PrintAndLogOptions
This commit is contained in:
Iceman 2018-03-01 16:43:03 +01:00 committed by GitHub
commit ce0d614a40
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 27 additions and 1 deletions

View file

@ -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<size-1)
strncat(buff, "\n", sizeof(buff)-strlen(buff) -1);
}
PrintAndLogEx(NORMAL, buff);
}
void PrintAndLogEx(logLevel_t level, char *fmt, ...) {
// skip debug messages if client debugging is turned off i.e. 'DATA SETDEBUG 0'

View file

@ -36,6 +36,7 @@ void HideGraphWindow(void);
void ShowGraphWindow(void);
void RepaintGraphWindow(void);
extern void PrintAndLog(char *fmt, ...);
void PrintAndLogOptions(char *str[][2], size_t size, size_t space);
void PrintAndLogEx(logLevel_t level, char *fmt, ...);
extern void SetLogFilename(char *fn);