mirror of
https://github.com/RfidResearchGroup/proxmark3.git
synced 2025-08-22 22:33:48 -07:00
preparing for better output of configuration data
This commit is contained in:
parent
6170eea81e
commit
0e937e8cc6
2 changed files with 67 additions and 0 deletions
|
@ -558,6 +558,64 @@ char *sprint_ascii(const uint8_t *data, const size_t len) {
|
||||||
return sprint_ascii_ex(data, len, 0);
|
return sprint_ascii_ex(data, len, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
char *sprint_breakdown_bin(color_t color, const char* bs, int width, int padn, int bits, const char* msg) {
|
||||||
|
|
||||||
|
if (bs == NULL || width > 32) {
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
const char *prepad = " ";
|
||||||
|
const char *postmarker = "................................";
|
||||||
|
static char buf[32 + 120] = {0};
|
||||||
|
memset(buf, 0, sizeof(buf));
|
||||||
|
|
||||||
|
int8_t end = (width - padn - 1 - bits);
|
||||||
|
if (end < 0) {
|
||||||
|
end = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
switch (color) {
|
||||||
|
case C_GREEN: {
|
||||||
|
snprintf(buf, sizeof(buf), "%.*s" _GREEN_("%.*s") " %.*s - " _GREEN_("%s")
|
||||||
|
, padn, prepad
|
||||||
|
, bits, bs + padn
|
||||||
|
, end, postmarker
|
||||||
|
, msg
|
||||||
|
);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case C_RED: {
|
||||||
|
snprintf(buf, sizeof(buf), "%.*s" _RED_("%.*s") " %.*s - " _RED_("%s")
|
||||||
|
, padn, prepad
|
||||||
|
, bits, bs + padn
|
||||||
|
, end, postmarker
|
||||||
|
, msg
|
||||||
|
);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case C_YELLOW: {
|
||||||
|
snprintf(buf, sizeof(buf), "%.*s" _YELLOW_("%.*s") " %.*s - " _YELLOW_("%s")
|
||||||
|
, padn, prepad
|
||||||
|
, bits, bs + padn
|
||||||
|
, end, postmarker
|
||||||
|
, msg
|
||||||
|
);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case C_NONE:
|
||||||
|
default: {
|
||||||
|
snprintf(buf, sizeof(buf), "%.*s%.*s %.*s - %s"
|
||||||
|
, padn, prepad
|
||||||
|
, bits, bs + padn
|
||||||
|
, end, postmarker
|
||||||
|
, msg
|
||||||
|
);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return buf;
|
||||||
|
}
|
||||||
|
|
||||||
int hex_to_bytes(const char *hexValue, uint8_t *bytesValue, size_t maxBytesValueLen) {
|
int hex_to_bytes(const char *hexValue, uint8_t *bytesValue, size_t maxBytesValueLen) {
|
||||||
char buf[4] = {0};
|
char buf[4] = {0};
|
||||||
int indx = 0;
|
int indx = 0;
|
||||||
|
|
|
@ -54,6 +54,13 @@ extern int g_numCPUs;
|
||||||
#define PM3_RET_IF_ERR_WITH_MSG(res, ...) if (res != PM3_SUCCESS) { PrintAndLogEx(ERR, __VA_ARGS__); return res; }
|
#define PM3_RET_IF_ERR_WITH_MSG(res, ...) if (res != PM3_SUCCESS) { PrintAndLogEx(ERR, __VA_ARGS__); return res; }
|
||||||
#define PM3_RET_IF_ERR_MAYBE_MSG(res, verbose, ...) if (res != PM3_SUCCESS) { if (verbose) PrintAndLogEx(ERR, __VA_ARGS__); return res; }
|
#define PM3_RET_IF_ERR_MAYBE_MSG(res, verbose, ...) if (res != PM3_SUCCESS) { if (verbose) PrintAndLogEx(ERR, __VA_ARGS__); return res; }
|
||||||
|
|
||||||
|
typedef enum {
|
||||||
|
C_NONE,
|
||||||
|
C_GREEN,
|
||||||
|
C_RED,
|
||||||
|
C_YELLOW,
|
||||||
|
} color_t;
|
||||||
|
|
||||||
int kbd_enter_pressed(void);
|
int kbd_enter_pressed(void);
|
||||||
void FillFileNameByUID(char *filenamePrefix, const uint8_t *uid, const char *ext, const int uidlen);
|
void FillFileNameByUID(char *filenamePrefix, const uint8_t *uid, const char *ext, const int uidlen);
|
||||||
// fill buffer from structure [{uint8_t data, size_t length},...]
|
// fill buffer from structure [{uint8_t data, size_t length},...]
|
||||||
|
@ -81,6 +88,8 @@ char *sprint_hex_ascii(const uint8_t *data, const size_t len);
|
||||||
char *sprint_ascii(const uint8_t *data, const size_t len);
|
char *sprint_ascii(const uint8_t *data, const size_t len);
|
||||||
char *sprint_ascii_ex(const uint8_t *data, const size_t len, const size_t min_str_len);
|
char *sprint_ascii_ex(const uint8_t *data, const size_t len, const size_t min_str_len);
|
||||||
|
|
||||||
|
char *sprint_breakdown_bin(color_t color, const char* bs, int width, int padn, int bits, const char* msg);
|
||||||
|
|
||||||
void print_buffer_with_offset(const uint8_t *data, const size_t len, int offset, bool print_header);
|
void print_buffer_with_offset(const uint8_t *data, const size_t len, int offset, bool print_header);
|
||||||
void print_buffer(const uint8_t *data, const size_t len, int level);
|
void print_buffer(const uint8_t *data, const size_t len, int level);
|
||||||
void print_blocks(uint32_t *data, size_t len);
|
void print_blocks(uint32_t *data, size_t len);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue