summaryrefslogtreecommitdiffstats
path: root/H64E-2/main.c
diff options
context:
space:
mode:
Diffstat (limited to 'H64E-2/main.c')
-rw-r--r--H64E-2/main.c46
1 files changed, 41 insertions, 5 deletions
diff --git a/H64E-2/main.c b/H64E-2/main.c
index c95291f..07e96d8 100644
--- a/H64E-2/main.c
+++ b/H64E-2/main.c
@@ -180,8 +180,9 @@ void helper( char *progname )
" -c - column size in bytes\n"
" -e - interp data output: u8,i8,u16,i16,u32,i32,u64,i64\n"
" -s - disable space between columns\n"
+ " -t - show offset numbers\n"
" -h - extra hex output\n"
- "Version: 2.0.4 \n"
+ "Version: 2.1.0 \n"
"\n"
, progname);
}
@@ -229,7 +230,7 @@ int main(int argc, const char * argv[]) {
//set all params from arguments
/*get cmd args and set options */
- while ( (c = getopt(argc, argv, "abo:il:vc:e:sh")) != -1 )
+ while ( (c = getopt(argc, argv, "abo:il:vc:e:sht")) != -1 )
{
switch(c)
{
@@ -266,6 +267,9 @@ int main(int argc, const char * argv[]) {
case 'h':
h64e.fmt.flag_hex = 0;
break;
+ case 't':
+ h64e.fmt.flag_show_offset = 1;
+ break;
case 'v':
version();
exit(1);
@@ -312,14 +316,25 @@ int main(int argc, const char * argv[]) {
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.offset_addr = h64e.fmt.offset_addr;
int8_fmt.f_output_types = h64e.fmt.flag_output_types;
int8_fmt.output_fmt = h64e.fmt.output_type;
int8_fmt.f_ascii = h64e.fmt.flag_ascii;
int8_fmt.f_hex = h64e.fmt.flag_hex;
+ int8_fmt.f_show_offset = h64e.fmt.flag_show_offset;
-
-
+ if (param_length > -1)
+ {
+ printf("param length %d\n", param_length);
+ int8_fmt.length = param_length;
+ int8_fmt.f_length = 1;
+ }
+
+ //set offset in file
+ if (int8_fmt.f_offset)
+ {
+ file_seek(fd, int8_fmt.offset_addr);
+ }
//do conversation, reading input and outputing
while ((in_bytes = file_read(fd,(char *)&buf_in,int8_fmt.column_size)) != -1)
{
@@ -329,6 +344,27 @@ int main(int argc, const char * argv[]) {
break;
}
+ if (in_total == int8_fmt.length)
+ {
+ break;
+ }
+
+ if (int8_fmt.f_length == 1)
+ {
+ /*
+ printf("-->\n");
+ printf("in_total %d\n", in_total);
+ printf("in_bytes %d\n", in_bytes);
+ printf("(in_total+in_bytes)=%d",(in_total+in_bytes));
+ */
+ //if ((int8_fmt.total_output+in_bytes) >= int8_fmt.length)
+ if ((in_total+in_bytes) >= int8_fmt.length)
+ {
+ in_bytes = int8_fmt.length - in_total;
+ //printf("in_bytes %d\n", in_bytes);
+ }
+ }
+
//write to input stream, connect all streams in a pipe
in_total += in_bytes;
//printf("Read from file %d bytes %d bytes total\n",in_bytes,in_total);