diff options
-rw-r--r-- | H64E-2/h64e-model.h | 1 | ||||
-rw-r--r-- | H64E-2/h64e.c | 39 | ||||
-rw-r--r-- | H64E-2/h64e.h | 3 | ||||
-rw-r--r-- | H64E-2/main.c | 16 |
4 files changed, 42 insertions, 17 deletions
diff --git a/H64E-2/h64e-model.h b/H64E-2/h64e-model.h index 761d327..6e5e32b 100644 --- a/H64E-2/h64e-model.h +++ b/H64E-2/h64e-model.h @@ -12,6 +12,7 @@ #include <stdio.h> #include <stdlib.h> #include <string.h> +#include <stdint.h> typedef int (*trnf_clb)(char*); diff --git a/H64E-2/h64e.c b/H64E-2/h64e.c index 35875a2..a508fd3 100644 --- a/H64E-2/h64e.c +++ b/H64E-2/h64e.c @@ -221,6 +221,15 @@ int h64e_fmt_byte_align16(H64E_format *fs, uint8_t *in_data, int32_t in_size, ui buf1_sz += 1; } } + if (fs->f_output_types) + { + if (fs->output_fmt == H64E_O_INT8) + { + buf2_sz = snprintf((char *)&buf2[0], BUF_SZ, "%4d ", (int8_t)in_data[i]); + } else if (fs->output_fmt == H64E_O_UINT8) { + buf2_sz = snprintf((char *)&buf2[0], BUF_SZ, "%4u ", (uint8_t)in_data[i]); + } + } } else { printf("Empty spaces\n"); @@ -241,24 +250,24 @@ int h64e_fmt_byte_align16(H64E_format *fs, uint8_t *in_data, int32_t in_size, ui } } } - //count converted chars per line - fs->column_pos += 1; - fs->total_output += 1; + //count converted chars per line + fs->column_pos += 1; + fs->total_output += 1; - if (fs->column_pos == fs->column_size) - { - if (fs->f_new_line) { - //set triger to newline - fs->t_new_line = 1; - fs->column_pos = 0; - //set new line to buffer - if (buf1_sz+1<BUF_SZ) - { - buf1[buf1_sz] = '\n'; - buf1_sz += 1; - } + if (fs->column_pos == fs->column_size) + { + if (fs->f_new_line) { + //set triger to newline + fs->t_new_line = 1; + fs->column_pos = 0; + //set new line to buffer + if (buf1_sz+1<BUF_SZ) + { + buf1[buf1_sz] = '\n'; + buf1_sz += 1; } } + } //copy data to buffer after each iteration diff --git a/H64E-2/h64e.h b/H64E-2/h64e.h index c8a210b..7cc2d41 100644 --- a/H64E-2/h64e.h +++ b/H64E-2/h64e.h @@ -11,6 +11,8 @@ #include <stdio.h> #include <ctype.h> +#include <stdlib.h> +#include <stdint.h> #include "h64e-model.h" /* Set data structure from arguments and use to handle data @@ -71,6 +73,7 @@ int h64e_destroy(H64E_t *s); #define H64E_FMT_STATE_FINISH 3 typedef struct H64E_format { + int f_output_types; int group_fmt; int output_fmt; int min_input; diff --git a/H64E-2/main.c b/H64E-2/main.c index 791cc18..e83ddf9 100644 --- a/H64E-2/main.c +++ b/H64E-2/main.c @@ -269,18 +269,20 @@ int main(int argc, const char * argv[]) { //configure format of u8 to terminate on new line and have space between types //printf("Column size set to %d\n",h64e.fmt.column_size); int8_fmt.f_space = !h64e.fmt.flag_space; - printf("h64e.fmt.flag_space %d\n",h64e.fmt.flag_space); + //printf("h64e.fmt.flag_space %d\n",h64e.fmt.flag_space); int8_fmt.f_new_line = 1; int8_fmt.column_size = h64e.fmt.column_size; int8_fmt.group_fmt = h64e.fmt.group; int8_fmt.output_fmt = h64e.fmt.output_type; int8_fmt.f_offset = h64e.fmt.flag_offset; int8_fmt.start_offset = h64e.fmt.offset_addr; + int8_fmt.f_output_types = h64e.fmt.flag_output_types; + int8_fmt.output_fmt = h64e.fmt.output_type; //do conversation, reading input and outputing - while ((in_bytes = file_read(fd,(char *)&buf_in,1)) != -1) + while ((in_bytes = file_read(fd,(char *)&buf_in,int8_fmt.column_size)) != -1) { if (in_bytes == 0) { @@ -351,6 +353,16 @@ int main(int argc, const char * argv[]) { } //check and empty all buffers + while (h64e_si_len(&sin)>0) + { + if (h64e_si_len(&sin)>int8_fmt.column_size) { + + } else { + + } + break; + } + //deinit all structures h64e_destroy(&h64e); |