hexdump: add cli arguments
This commit is contained in:
parent
1359b66b21
commit
104fdea113
|
@ -8,4 +8,4 @@ main: $(OBJFILES)
|
||||||
$(CC) hexdump.c -o hexdump
|
$(CC) hexdump.c -o hexdump
|
||||||
|
|
||||||
test: main
|
test: main
|
||||||
./hexdump
|
./hexdump ../tests/test2.bin
|
||||||
|
|
|
@ -50,7 +50,6 @@ int hexdump(char *data) {
|
||||||
}
|
}
|
||||||
if (dumpgroup == 2) {
|
if (dumpgroup == 2) {
|
||||||
dumpgroup = 0;
|
dumpgroup = 0;
|
||||||
cur_start_of_line = 0;
|
|
||||||
chardump(data, cur_start_of_line, i);
|
chardump(data, cur_start_of_line, i);
|
||||||
hexnum = 0;
|
hexnum = 0;
|
||||||
cur_start_of_line = i;
|
cur_start_of_line = i;
|
||||||
|
@ -58,14 +57,18 @@ int hexdump(char *data) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int main() {
|
int main(int argc, char *argv[]) {
|
||||||
FILE *infile = fopen("../tests/test2.bin", "r");//fopen("test.bin", "r");
|
if (argc < 2) {
|
||||||
|
printf("%s: not enought arguments\n", argv[0]);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
FILE *infile = fopen(argv[1], "r");
|
||||||
char data[10000]; // FIXME
|
char data[10000]; // FIXME
|
||||||
char ch;
|
char ch;
|
||||||
int byte = 0; // FIXME
|
int byte = 0; // FIXME
|
||||||
if (infile == NULL) {
|
if (infile == NULL) {
|
||||||
printf("Cannot find file: \n");
|
printf("Cannot find file: \n");
|
||||||
return 0;
|
return 1;
|
||||||
}
|
}
|
||||||
while ((ch = fgetc(infile)) != EOF)
|
while ((ch = fgetc(infile)) != EOF)
|
||||||
{
|
{
|
||||||
|
|
|
@ -0,0 +1,22 @@
|
||||||
|
LONG file
|
||||||
|
LONG file
|
||||||
|
LONG file
|
||||||
|
LONG file
|
||||||
|
LONG file
|
||||||
|
LONG file
|
||||||
|
LONG file
|
||||||
|
LONG file
|
||||||
|
LONG file
|
||||||
|
LONG file
|
||||||
|
LONG file
|
||||||
|
123
|
||||||
|
456
|
||||||
|
123
|
||||||
|
123
|
||||||
|
123
|
||||||
|
123
|
||||||
|
456
|
||||||
|
456
|
||||||
|
456
|
||||||
|
456
|
||||||
|
|
Loading…
Reference in New Issue