some small fixes, and begining of reverse
This commit is contained in:
parent
ec3a1d44d4
commit
1eda825308
@ -21,6 +21,8 @@ void init_flags(struct flags* flags)
|
|||||||
|
|
||||||
flags->littleendian = false;
|
flags->littleendian = false;
|
||||||
|
|
||||||
|
flags->reverse_op = false;
|
||||||
|
|
||||||
flags->octets = 2;
|
flags->octets = 2;
|
||||||
flags->customoctets = false;
|
flags->customoctets = false;
|
||||||
|
|
||||||
|
@ -29,6 +29,8 @@ struct flags {
|
|||||||
|
|
||||||
bool littleendian;
|
bool littleendian;
|
||||||
|
|
||||||
|
bool reverse_op;
|
||||||
|
|
||||||
uint offset;
|
uint offset;
|
||||||
int seek;
|
int seek;
|
||||||
|
|
||||||
|
@ -25,6 +25,7 @@ static struct argp_option options[] = {
|
|||||||
{0, 'o', "off", 0, "add <off> to the displayed file position.", 0},
|
{0, 'o', "off", 0, "add <off> to the displayed file position.", 0},
|
||||||
{0, 'e', 0, 0, "little-endian dump (incompatible with -ps,-i,-r).", 0},
|
{0, 'e', 0, 0, "little-endian dump (incompatible with -ps,-i,-r).", 0},
|
||||||
{0, 's', "seek", 0, "start at <[+][-] seek> bytes abs. infile offset.", 0},
|
{0, 's', "seek", 0, "start at <[+][-] seek> bytes abs. infile offset.", 0},
|
||||||
|
{0, 'r', 0, 0, "reverse operation: convert (or patch) hexdump into binary.", 0},
|
||||||
{0}
|
{0}
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -65,6 +66,9 @@ static error_t parse_opt(int key, char* arg, struct argp_state* state)
|
|||||||
else
|
else
|
||||||
flags->coloured = true;
|
flags->coloured = true;
|
||||||
break;
|
break;
|
||||||
|
case 'r':
|
||||||
|
flags->reverse_op = true;
|
||||||
|
flags->coloured = false;
|
||||||
case 'l':
|
case 'l':
|
||||||
flags->len = atoi(arg);
|
flags->len = atoi(arg);
|
||||||
break;
|
break;
|
||||||
@ -126,11 +130,11 @@ static void do_text_parse(hex_chunk_t** lines, bool interactive)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (flags.seek >= 0) {
|
if (flags.seek >= 0) {
|
||||||
if (flags.seek > strlen(file_content))
|
if (flags.seek > (int) strlen(file_content))
|
||||||
exit(EXIT_SUCCESS);
|
exit(EXIT_SUCCESS);
|
||||||
seek = flags.seek;
|
seek = flags.seek;
|
||||||
} else {
|
} else {
|
||||||
if ((flags.seek * -1) > strlen(file_content)) {
|
if ((flags.seek * -1) > (int) strlen(file_content)) {
|
||||||
fprintf(stderr, "xxd: Sorry, cannot seek.\n");
|
fprintf(stderr, "xxd: Sorry, cannot seek.\n");
|
||||||
exit(EXIT_FAILURE);
|
exit(EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user