summaryrefslogtreecommitdiff
path: root/H64E-2/main.c
diff options
context:
space:
mode:
Diffstat (limited to 'H64E-2/main.c')
-rw-r--r--H64E-2/main.c42
1 files changed, 35 insertions, 7 deletions
diff --git a/H64E-2/main.c b/H64E-2/main.c
index bd1910e..818f165 100644
--- a/H64E-2/main.c
+++ b/H64E-2/main.c
@@ -141,9 +141,9 @@ void helper( char *progname )
" -i - output hex\n"
" -l - length of output\n"
" -c - column size in byts\n"
- " -g - datatype output: byte,word,dword\n"
+ " -g - datatype output: byte,word,dword,qword\n"
" -e - interp data: u8,i8,u16,i16,u32,i32,u64,i64"
- "\nVersion: 0.1 \n"
+ "\nVersion: 2.0.0 \n"
"\n"
, progname);
}
@@ -153,7 +153,9 @@ void version()
printf("???\n");
}
-
+/*
+ Main fucntion, of this program
+ */
int main(int argc, const char * argv[]) {
// insert code here...
int c;
@@ -180,12 +182,13 @@ int main(int argc, const char * argv[]) {
H64E_format int8_fmt;
+ //list of supported formats
h64e_fmt_init(&int8_fmt);
//set all params from arguments
/*get cmd args and set options */
- while ( (c = getopt(argc, argv, "abo:il:vc:g:e:")) != -1 )
+ while ( (c = getopt(argc, argv, "abo:il:vc:g:e:s")) != -1 )
{
switch(c)
{
@@ -218,6 +221,9 @@ int main(int argc, const char * argv[]) {
h64e.fmt.flag_output = 1;
h64e.fmt.output_type = output_name2int(optarg);
break;
+ case 's':
+ h64e.fmt.flag_space = 1;
+ break;
case 'v':
version();
exit(1);
@@ -251,9 +257,14 @@ int main(int argc, const char * argv[]) {
//register formats
//configure format of u8 to terminate on new line and have space between types
- int8_fmt.f_space = 1;
+ //printf("Column size set to %d\n",h64e.fmt.column_size);
+ int8_fmt.f_space = !h64e.fmt.flag_space;
int8_fmt.f_new_line = 1;
- int8_fmt.column_size = 16;
+ int8_fmt.column_size = h64e.fmt.column_size;
+ int8_fmt.group_fmt = h64e.fmt.group;
+ 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)
@@ -280,7 +291,24 @@ int main(int argc, const char * argv[]) {
//Convert output data to desired format
//printf("Start converting to byte8\n");
- cnv_num = h64e_fmt_byte(&int8_fmt, &buf_cnv_in[0], cnv_bytes, buf_cnv_out, 512);
+ switch (h64e.fmt.group)
+ {
+ case H64E_G_BYTE:
+ cnv_num = h64e_fmt_byte(&int8_fmt, &buf_cnv_in[0], cnv_bytes, buf_cnv_out, 512);
+ break;
+ case H64E_G_WORD:
+ cnv_num = h64e_fmt_word(&int8_fmt, &buf_cnv_in[0], cnv_bytes, buf_cnv_out, 512);
+ break;
+ case H64E_G_DWORD:
+ cnv_num = h64e_fmt_dword(&int8_fmt, &buf_cnv_in[0], cnv_bytes, buf_cnv_out, 512);
+ break;
+ case H64E_G_QWORD:
+ cnv_num = h64e_fmt_qword(&int8_fmt, &buf_cnv_in[0], cnv_bytes, buf_cnv_out, 512);
+ break;
+
+ default:
+ printf("Unknown grouping\n");
+ }
//printf("Conversation amount\n");
//Push all data ot output buffer
//printf("Write to output stream data %d bytes\n",cnv_bytes);