[hackers] [ubase] Use eprintf() wherever possible, add -h to options || sin
commit 7fa098ace67f2089710608f788259931a118acc6
Author: sin <sin_AT_2f30.org>
Date: Wed Jun 4 12:59:45 2014 +0100
Use eprintf() wherever possible, add -h to options
diff --git a/dd.c b/dd.c
index f472c88..c4db974 100644
--- a/dd.c
+++ b/dd.c
_AT_@ -20,6 +20,7 @@
#include <sys/vfs.h>
#include <time.h>
#include <unistd.h>
+#include "util.h"
struct dd_config {
const char *in, *out;
_AT_@ -191,8 +192,7 @@ copy(struct dd_config *ddc)
static void
usage(void)
{
- fprintf(stderr, "Usage: odd [if=F1] [of=F2] [bsize] [skip=N] [count=N] [quiet] [nosync]
");
- exit(EXIT_FAILURE);
+ eprintf("usage: %s [-h] [if=F1] [of=F2] [bsize] [skip=N] [count=N] [quiet] [nosync]
", argv0);
}
static void
_AT_@ -223,6 +223,7 @@ main(int argc, char *argv[])
char buf[1024];
struct dd_config config;
+ argv0 = argv[0];
memset(&config, 0, sizeof(config));
config.bs = 1<<16;
config.in = "/dev/stdin";
_AT_@ -251,6 +252,8 @@ main(int argc, char *argv[])
config.quiet = 1;
else if (strcmp(argv[i], "nosync") == 0)
config.nosync = 1;
+ else if (strcmp(argv[i], "-h") == 0)
+ usage();
}
if (!config.in || !config.out)
_AT_@ -260,7 +263,7 @@ main(int argc, char *argv[])
signal(SIGINT, sig_int);
if (copy(&config) < 0)
- fprintf(stderr, "Error: %s
", strerror(config.saved_errno));
+ eprintf("copy:");
print_stat(&config);
if (config.nosync == 0)
Received on Wed Jun 04 2014 - 14:04:49 CEST
This archive was generated by hypermail 2.3.0
: Wed Jun 04 2014 - 14:12:07 CEST