]> git.zerfleddert.de Git - proxmark3-svn/commitdiff
dump only leaf TLV data 470/head
authorpwpiwi <pwpiwi@users.noreply.github.com>
Fri, 10 Nov 2017 22:09:08 +0000 (23:09 +0100)
committerpwpiwi <pwpiwi@users.noreply.github.com>
Fri, 10 Nov 2017 22:09:08 +0000 (23:09 +0100)
client/emv/dump.h
client/emv/emvcore.c
client/emv/tlv.c
client/emv/tlv.h

index ad69ea834e63a3c73323cedd69efa3f325546709..567a134f63db71f6cf13ea693425885fc19188aa 100644 (file)
@@ -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);
index 8dc9325964142dedc24d6633c4838e7db0bfba61..63a69baab82176ac48a68c0667bff163250ae703 100644 (file)
 
 #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;
 }
index 7feaa9aa9377d794418bde7c3cdaeb5ea33e2c37..24125cc7d3175dd341eac4811dcdf4f9904cd94e 100644 (file)
@@ -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);
        }
 }
index 187781f88767fc6b1f5338fc381abdb71772f720..5a573566644e8991ab1fe8a2ed82bdf8e7233440 100644 (file)
@@ -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);
Impressum, Datenschutz