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