summaryrefslogtreecommitdiff
path: root/H64E-2/h64e.c
diff options
context:
space:
mode:
authorsystemcoder <systemcoder@protonmail.com>2020-03-17 19:25:03 +0000
committersystemcoder <systemcoder@protonmail.com>2020-03-17 19:25:03 +0000
commite1e7859ef4b3353a8ac182fd456b053c653239d1 (patch)
tree7132c3f792ba8a6f3343cfa7aa7ed23f242c9167 /H64E-2/h64e.c
parent784076d51c3d95443b53416e593c38c612c14bbe (diff)
downloadH64D-2-e1e7859ef4b3353a8ac182fd456b053c653239d1.tar.gz
H64D-2-e1e7859ef4b3353a8ac182fd456b053c653239d1.zip
Add support for ascii, column output. Space no space is added
Diffstat (limited to 'H64E-2/h64e.c')
-rw-r--r--H64E-2/h64e.c44
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)
{