Skip to content

Commit 5838c7f

Browse files
committed
Simplify print_emv_tlv()
It was only used internally so it made more sense to simplify it for external use while creating a new print_emv_tlv_internal() function for internal use. This also allows print_emv_tlv_internal() to gain extra parameters in future without impacting print_emv_tlv().
1 parent d11f31a commit 5838c7f

File tree

2 files changed

+14
-11
lines changed

2 files changed

+14
-11
lines changed

tools/print_helpers.c

+8-3
Original file line numberDiff line numberDiff line change
@@ -392,7 +392,7 @@ void print_ber_buf(const void* ptr, size_t len, const char* prefix, unsigned int
392392
}
393393
}
394394

395-
void print_emv_tlv(const struct emv_tlv_t* tlv, const char* prefix, unsigned int depth)
395+
static void print_emv_tlv_internal(const struct emv_tlv_t* tlv, const char* prefix, unsigned int depth)
396396
{
397397
struct emv_tlv_info_t info;
398398
char value_str[2048];
@@ -464,20 +464,25 @@ void print_emv_buf(const void* ptr, size_t len, const char* prefix, unsigned int
464464
while ((r = iso8825_ber_itr_next(&itr, &tlv)) > 0) {
465465
struct emv_tlv_t emv_tlv;
466466
emv_tlv.ber = tlv;
467-
print_emv_tlv(&emv_tlv, prefix, depth);
467+
print_emv_tlv_internal(&emv_tlv, prefix, depth);
468468
}
469469

470470
if (r < 0) {
471471
printf("BER decoding error %d\n", r);
472472
}
473473
}
474474

475+
void print_emv_tlv(const struct emv_tlv_t* tlv)
476+
{
477+
print_emv_tlv_internal(tlv, " ", 0);
478+
}
479+
475480
void print_emv_tlv_list(const struct emv_tlv_list_t* list)
476481
{
477482
const struct emv_tlv_t* tlv;
478483

479484
for (tlv = list->front; tlv != NULL; tlv = tlv->next) {
480-
print_emv_tlv(tlv, " ", 1);
485+
print_emv_tlv_internal(tlv, " ", 1);
481486
}
482487
}
483488

tools/print_helpers.h

+6-8
Original file line numberDiff line numberDiff line change
@@ -101,14 +101,6 @@ void print_sw1sw2(uint8_t SW1, uint8_t SW2);
101101
*/
102102
void print_ber_buf(const void* ptr, size_t len, const char* prefix, unsigned int depth);
103103

104-
/**
105-
* Print EMV TLV field
106-
* @param tlv EMV TLV field
107-
* @param prefix Recursion prefix to print before every string
108-
* @param depth Depth of current recursion
109-
*/
110-
void print_emv_tlv(const struct emv_tlv_t* tlv, const char* prefix, unsigned int depth);
111-
112104
/**
113105
* Print EMV TLV data
114106
* @param ptr EMV TLV data
@@ -118,6 +110,12 @@ void print_emv_tlv(const struct emv_tlv_t* tlv, const char* prefix, unsigned int
118110
*/
119111
void print_emv_buf(const void* ptr, size_t len, const char* prefix, unsigned int depth);
120112

113+
/**
114+
* Print EMV TLV field
115+
* @param tlv EMV TLV field
116+
*/
117+
void print_emv_tlv(const struct emv_tlv_t* tlv);
118+
121119
/**
122120
* Print EMV TLV list
123121
* @param list EMV TLV list object

0 commit comments

Comments
 (0)