Teach libc5 what a sighandler_t is
[oweals/busybox.git] / dd.c
diff --git a/dd.c b/dd.c
index 75bbfbac2d4778db4d75fe3d6b47a2b14c1757c1..d46db82a03074c94e19359548b9d10ea4a091a4e 100644 (file)
--- a/dd.c
+++ b/dd.c
  *
  */
 
-#include "busybox.h"
-
 #include <sys/types.h>
 #include <stdlib.h>
 #include <stdio.h>
 #include <unistd.h>
 #include <string.h>
 #include <fcntl.h>
+#include "busybox.h"
+
 
 static const struct suffix_mult dd_suffixes[] = {
        { "c", 1 },
@@ -45,12 +45,11 @@ static const struct suffix_mult dd_suffixes[] = {
 
 int dd_main(int argc, char **argv)
 {
-       int i, ifd, ofd, oflag, sync = FALSE, trunc = TRUE;
+       int i, ifd, ofd, oflag, sync_flag = FALSE, trunc = TRUE;
        size_t in_full = 0, in_part = 0, out_full = 0, out_part = 0;
        size_t bs = 512, count = -1;
        ssize_t n;
        off_t seek = 0, skip = 0;
-       FILE *statusfp;
        char *infile = NULL, *outfile = NULL, *buf;
 
        for (i = 1; i < argc; i++) {
@@ -73,7 +72,7 @@ int dd_main(int argc, char **argv)
                                        trunc = FALSE;
                                        buf += 7;
                                } else if (strncmp("sync", buf, 4) == 0) {
-                                       sync = TRUE;
+                                       sync_flag = TRUE;
                                        buf += 4;
                                } else {
                                        error_msg_and_die("invalid conversion `%s'", argv[i]+5);
@@ -84,7 +83,7 @@ int dd_main(int argc, char **argv)
                                        buf++;
                        }
                } else
-                       usage(dd_usage);
+                       show_usage();
        }
 
        buf = xmalloc(bs);
@@ -110,12 +109,9 @@ int dd_main(int argc, char **argv)
                        if (ftruncate(ofd, seek * bs) < 0)
                                perror_msg_and_die("%s", outfile);
                }
-
-               statusfp = stdout;
        } else {
                ofd = STDOUT_FILENO;
                outfile = "standard output";
-               statusfp = stderr;
        }
 
        if (skip) {
@@ -138,7 +134,7 @@ int dd_main(int argc, char **argv)
                        in_full++;
                else
                        in_part++;
-               if (sync) {
+               if (sync_flag) {
                        memset(buf + n, '\0', bs - n);
                        n = bs;
                }
@@ -151,8 +147,8 @@ int dd_main(int argc, char **argv)
                        out_part++;
        }
 
-       fprintf(statusfp, "%d+%d records in\n", in_full, in_part);
-       fprintf(statusfp, "%d+%d records out\n", out_full, out_part);
+       fprintf(stderr, "%ld+%ld records in\n", (long)in_full, (long)in_part);
+       fprintf(stderr, "%ld+%ld records out\n", (long)out_full, (long)out_part);
 
        return EXIT_SUCCESS;
 }