diff options
author | Tyler Murphy <tylerm@tylerm.dev> | 2023-05-04 16:10:37 -0400 |
---|---|---|
committer | Tyler Murphy <tylerm@tylerm.dev> | 2023-05-04 16:10:37 -0400 |
commit | b1364be7e271c5a080e29efcda209a190a82d6d9 (patch) | |
tree | fc64d1546e59b5ed1c2c204612b6181bc401c27f /src/commands/dd.c | |
parent | grep (diff) | |
download | lazysphere-b1364be7e271c5a080e29efcda209a190a82d6d9.tar.gz lazysphere-b1364be7e271c5a080e29efcda209a190a82d6d9.tar.bz2 lazysphere-b1364be7e271c5a080e29efcda209a190a82d6d9.zip |
ansii c
Diffstat (limited to '')
-rw-r--r-- | src/commands/dd.c | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/src/commands/dd.c b/src/commands/dd.c index 78f6041..1387317 100644 --- a/src/commands/dd.c +++ b/src/commands/dd.c @@ -15,10 +15,13 @@ COMMAND(dd) { FILE* out_file = stdout; int bs = 1024; int count = -1; + int i; + char* buffer; + size_t read; parse_help(argc, argv, help); - for (int i = 0; i < argc; i++) { + for (i = 0; i < argc; i++) { if (prefix("if=", argv[i])) { char* path = argv[i] + 3; in_file = get_file(path, "rb"); @@ -42,8 +45,8 @@ COMMAND(dd) { } } - char* buffer = malloc(bs); - size_t read; + buffer = malloc(bs); + while ((read = fread(buffer, 1, bs, in_file)) != 0) { fwrite(buffer, 1, read, out_file); if (--count, count == 0) break; |