diff options
Diffstat (limited to 'H64E-2/h64e.c')
-rw-r--r-- | H64E-2/h64e.c | 44 |
1 files changed, 38 insertions, 6 deletions
diff --git a/H64E-2/h64e.c b/H64E-2/h64e.c index 1e0662c..decaff5 100644 --- a/H64E-2/h64e.c +++ b/H64E-2/h64e.c @@ -67,31 +67,44 @@ int h64e_fmt_byte(H64E_format *fs, uint8_t *in_data, int32_t in_size, uint8_t *o int cur_size=0; int i,j=0; const int SZ=16; - uint8_t buf[SZ]; + uint8_t buf[SZ+1]; int buf_sz=0; int trail_size=0; for (i=0; i<in_size; i++) { - buf_sz = snprintf(&buf[0], SZ, "%02x",in_data[i]); + //group byte output string + if (((fs->group_fmt == H64E_G_BYTE)||(fs->group_fmt == H64E_G_NONE)) && (fs->output_fmt == H64E_O_STRING)) + { + if (isprint(in_data[i])) + { + buf_sz = snprintf(&buf[0], SZ, "%c",(unsigned char)in_data[i]); + } else { + buf_sz = snprintf(&buf[0], SZ, ".",(unsigned char)in_data[i]); + } + } else { + //group byte output + buf_sz = snprintf(&buf[0], SZ, "%02x",in_data[i]); + + } //count converted chars per line - fs->cur_pos += 1; + fs->column_pos += 1; //add space if configured if (fs->f_space) { - if (buf_sz+1<SZ) + if (buf_sz<SZ) { buf[buf_sz] = ' '; buf_sz += 1; } } - if (fs->cur_pos == fs->column_size) + if (fs->column_pos == fs->column_size) { if (fs->f_new_line) { //set triger to newline fs->t_new_line = 1; - fs->cur_pos = 0; + fs->column_pos = 0; //set new line to buffer if (buf_sz+1<SZ) { @@ -126,6 +139,25 @@ int h64e_fmt_byte(H64E_format *fs, uint8_t *in_data, int32_t in_size, uint8_t *o return ret; } +int h64e_fmt_word( H64E_format *fs, uint8_t *in_data, int32_t in_size, uint8_t *out_data, int32_t out_size) +{ + return 0; +} + +int h64e_fmt_dword( H64E_format *fs, uint8_t *in_data, int32_t in_size, uint8_t *out_data, int32_t out_size) +{ + return 0; +} + +int h64e_fmt_qword( H64E_format *fs, uint8_t *in_data, int32_t in_size, uint8_t *out_data, int32_t out_size) +{ + return 0; +} +int h64e_fmt_string( H64E_format *fs, uint8_t *in_data, int32_t in_size, uint8_t *out_data, int32_t out_size) +{ + return 0; +} + int h64e_fmt_finish(H64E_format *fs) { |