mirror of
https://github.com/Proxmark/proxmark3.git
synced 2025-07-16 02:03:00 -07:00
dump only leaf TLV data
This commit is contained in:
parent
43912d6349
commit
33a9982c76
4 changed files with 8 additions and 4 deletions
|
@ -17,6 +17,7 @@
|
|||
#define DUMP_H
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdbool.h>
|
||||
|
||||
void dump_buffer_simple(const unsigned char *ptr, size_t len, FILE *f);
|
||||
void dump_buffer(const unsigned char *ptr, size_t len, FILE *f, int level);
|
||||
|
|
|
@ -10,9 +10,11 @@
|
|||
|
||||
#include "emvcore.h"
|
||||
|
||||
static bool print_cb(void *data, const struct tlv *tlv, int level) {
|
||||
static bool print_cb(void *data, const struct tlv *tlv, int level, bool is_leaf) {
|
||||
emv_tag_dump(tlv, stdout, level);
|
||||
dump_buffer(tlv->value, tlv->len, stdout, level);
|
||||
if (is_leaf) {
|
||||
dump_buffer(tlv->value, tlv->len, stdout, level);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -317,7 +317,8 @@ void tlvdb_visit(const struct tlvdb *tlvdb, tlv_cb cb, void *data, int level)
|
|||
|
||||
for (; tlvdb; tlvdb = next) {
|
||||
next = tlvdb->next;
|
||||
cb(data, &tlvdb->tag, level);
|
||||
bool is_leaf = (tlvdb->children == NULL);
|
||||
cb(data, &tlvdb->tag, level, is_leaf);
|
||||
tlvdb_visit(tlvdb->children, cb, data, level+1);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -31,7 +31,7 @@ struct tlv {
|
|||
};
|
||||
|
||||
struct tlvdb;
|
||||
typedef bool (*tlv_cb)(void *data, const struct tlv *tlv, int level);
|
||||
typedef bool (*tlv_cb)(void *data, const struct tlv *tlv, int level, bool is_leaf);
|
||||
|
||||
struct tlvdb *tlvdb_fixed(tlv_tag_t tag, size_t len, const unsigned char *value);
|
||||
struct tlvdb *tlvdb_external(tlv_tag_t tag, size_t len, const unsigned char *value);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue