diff options
Diffstat (limited to 'H64E-2')
-rw-r--r-- | H64E-2/h64e.c | 46 | ||||
-rw-r--r-- | H64E-2/main.c | 24 |
2 files changed, 55 insertions, 15 deletions
diff --git a/H64E-2/h64e.c b/H64E-2/h64e.c index 0a68734..f381d89 100644 --- a/H64E-2/h64e.c +++ b/H64E-2/h64e.c @@ -185,7 +185,7 @@ int h64e_fmt_byte_align16(H64E_format *fs, uint8_t *in_data, int32_t in_size, ui { //printf("Print offset\n"); int offset = fs->start_offset + fs->total_output; - buf_offset_sz = snprintf((char *)&buf_offset[0], BUF_SZ, "%08x: ",offset); + buf_offset_sz = snprintf((char *)&buf_offset[0], BUF_SZ, "%08x: ",offset); //make it wider } if (in_size%fs->column_size != 0) @@ -206,7 +206,6 @@ int h64e_fmt_byte_align16(H64E_format *fs, uint8_t *in_data, int32_t in_size, ui //group byte output if (fs->f_hex) { - buf1_sz = snprintf((char *)&buf1[0], BUF_SZ, "%02x",in_data[i]); } @@ -241,8 +240,7 @@ int h64e_fmt_byte_align16(H64E_format *fs, uint8_t *in_data, int32_t in_size, ui } } } - - + if (fs->f_output_types) { if (fs->output_fmt == H64E_O_INT8) @@ -254,11 +252,11 @@ int h64e_fmt_byte_align16(H64E_format *fs, uint8_t *in_data, int32_t in_size, ui buf3_sz = snprintf((char *)&buf3[0], BUF_SZ, "%4u ", uu); } } - - + } else { - printf("Empty spaces\n"); + //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)) { buf2_sz = snprintf((char *)&buf2[0], BUF_SZ, " "); @@ -266,19 +264,39 @@ int h64e_fmt_byte_align16(H64E_format *fs, uint8_t *in_data, int32_t in_size, ui //group byte output buf2_sz = snprintf((char *)&buf2[0], BUF_SZ, " "); } + */ + if (fs->f_hex) + { + buf1_sz = snprintf((char *)&buf1[0], BUF_SZ, " "); + } + + if (fs->f_ascii) + { + buf2_sz = snprintf((char *)&buf2[0], BUF_SZ, " "); + } + if (fs->f_space) { - if (buf2_sz<BUF_SZ) + //printf("Space enabled\n"); + if (fs->f_ascii) { - buf2[buf2_sz] = ' '; - buf2_sz += 1; + if (buf2_sz<BUF_SZ) + { + buf2[buf2_sz] = ' '; + buf2_sz += 1; + } } - if (buf3_sz<BUF_SZ) + if (fs->f_hex) { - buf3[buf3_sz] = ' '; - buf3_sz += 1; + if (buf1_sz<BUF_SZ) + { + buf1[buf1_sz] = ' '; + buf1_sz += 1; + } } } + + } //count converted chars per line fs->column_pos += 1; @@ -310,7 +328,7 @@ int h64e_fmt_byte_align16(H64E_format *fs, uint8_t *in_data, int32_t in_size, ui } } - if ((fs->f_output_types==1)) + if (fs->f_output_types==1) { if (fs->f_output_types) { diff --git a/H64E-2/main.c b/H64E-2/main.c index 673aa43..02a5551 100644 --- a/H64E-2/main.c +++ b/H64E-2/main.c @@ -357,11 +357,33 @@ int main(int argc, const char * argv[]) { //check and empty all buffers while (h64e_si_len(&sin)>0) { + int cnv_num = -1; if (h64e_si_len(&sin)>int8_fmt.column_size) { - + //printf("Full column buffer\n"); + cnv_bytes = h64e_si_data_out(&sin, &buf_cnv_in[0], int8_fmt.column_size); + cnv_num = h64e_fmt_byte_align16(&int8_fmt, &buf_cnv_in[0], cnv_bytes, buf_cnv_out, 2048); + + cnv_bytes = h64e_so_data_in(&sout, &buf_cnv_out[0], cnv_num); + cnv_total += cnv_num; } else { + //printf("some buffer!!!\n"); + //less then column size + cnv_bytes = h64e_si_data_out(&sin, &buf_cnv_in[0], int8_fmt.column_size); + //printf("cnv_bytes %d\n", cnv_bytes); + cnv_num = h64e_fmt_byte_align16(&int8_fmt, &buf_cnv_in[0], cnv_bytes, buf_cnv_out, 2048); + //printf("cnv_num %d\n", cnv_num); + cnv_bytes = h64e_so_data_in(&sout, &buf_cnv_out[0], cnv_num); + cnv_total += cnv_num; } + + if ((out_bytes = h64e_so_len(&sout)) > 0) + { + out_bytes = h64e_so_data_out(&sout, &buf_out[0],512); + buf_out[out_bytes] = 0x00; + printf("%s",buf_out); + } + break; } |