diff options
Diffstat (limited to 'H64E-2/h64e.c')
-rw-r--r-- | H64E-2/h64e.c | 56 |
1 files changed, 35 insertions, 21 deletions
diff --git a/H64E-2/h64e.c b/H64E-2/h64e.c index 8a1325a..35875a2 100644 --- a/H64E-2/h64e.c +++ b/H64E-2/h64e.c @@ -176,6 +176,7 @@ int h64e_fmt_byte_align16(H64E_format *fs, uint8_t *in_data, int32_t in_size, ui //set offset to output if (fs->f_offset) { + //printf("Print offset\n"); int offset = fs->start_offset + fs->total_output; buf1_sz = snprintf((char *)&buf1[0], BUF_SZ, "%08x: ",offset); //no error check @@ -193,9 +194,10 @@ int h64e_fmt_byte_align16(H64E_format *fs, uint8_t *in_data, int32_t in_size, ui //size shout be allways matching (size mod columnsize == 0) //non matching size should be used at the end, on last line of output + //printf("Loop_size %d\n",loop_size); for (i=0; i<loop_size; i++) { - if (i>in_size) + if (i<in_size) { //group byte output string if (((fs->group_fmt == H64E_G_BYTE)||(fs->group_fmt == H64E_G_NONE)) && (fs->output_fmt == H64E_O_STRING)) @@ -210,18 +212,38 @@ int h64e_fmt_byte_align16(H64E_format *fs, uint8_t *in_data, int32_t in_size, ui //group byte output buf1_sz = snprintf((char *)&buf1[0], BUF_SZ, "%02x",in_data[i]); } - //count converted chars per line - fs->column_pos += 1; - fs->total_output += 1; - //add space if configured if (fs->f_space) { + //printf("Space enabled\n"); if (buf1_sz<BUF_SZ) { buf1[buf1_sz] = ' '; buf1_sz += 1; } } + + } else { + printf("Empty spaces\n"); + //group byte output string + if (((fs->group_fmt == H64E_G_BYTE)||(fs->group_fmt == H64E_G_NONE)) && (fs->output_fmt == H64E_O_STRING)) + { + buf1_sz = snprintf((char *)&buf1[0], BUF_SZ, " "); + } else { + //group byte output + buf1_sz = snprintf((char *)&buf1[0], BUF_SZ, " "); + } + if (fs->f_space) + { + if (buf1_sz<BUF_SZ) + { + buf1[buf1_sz] = ' '; + buf1_sz += 1; + } + } + } + //count converted chars per line + fs->column_pos += 1; + fs->total_output += 1; if (fs->column_pos == fs->column_size) { @@ -237,16 +259,7 @@ int h64e_fmt_byte_align16(H64E_format *fs, uint8_t *in_data, int32_t in_size, ui } } } - } else { - //group byte output string - if (((fs->group_fmt == H64E_G_BYTE)||(fs->group_fmt == H64E_G_NONE)) && (fs->output_fmt == H64E_O_STRING)) - { - buf1_sz = snprintf((char *)&buf1[0], BUF_SZ, " "); - } else { - //group byte output - buf1_sz = snprintf((char *)&buf1[0], BUF_SZ, " "); - } - } + //copy data to buffer after each iteration for (j=0; j<buf1_sz; j++) @@ -262,28 +275,29 @@ int h64e_fmt_byte_align16(H64E_format *fs, uint8_t *in_data, int32_t in_size, ui out_part2_sz += buf2_sz; } + //printf("out_part1_sz %d\n",out_part1_sz); + //printf("out_part2_sz %d\n",out_part2_sz); //concat all data from 2 buffers for (i=0;i<out_part1_sz;i++) { - if (out_size<i) + if (i<out_size) { out_data[i] = out_part1[i]; trail_size += 1; - } else { - ret = trail_size; } } for (i=0;i<out_part2_sz;i++) { - if (out_size < out_part1_sz+i) + if (out_part1_sz+i<out_size) { out_data[i] = out_part2[i]; - } else { - ret = trail_size+i; + trail_size += 1; } } + ret = trail_size; + //printf("ret %d\n",ret); #if 0 printf("D:["); |