summaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorMatthias Vogelgesang <matthias.vogelgesang@kit.edu>2012-04-13 15:42:47 +0200
committerMatthias Vogelgesang <matthias.vogelgesang@kit.edu>2012-04-13 15:42:47 +0200
commitdcbecf78c3700c2029f675d2c688318f50891712 (patch)
tree591b1fa26361d97aba8b60b0402e35767fb9a50c /test
parent31ea348c969792a1da6189106c36804934cd7c7e (diff)
downloadlibufodecode-dcbecf78c3700c2029f675d2c688318f50891712.tar.gz
libufodecode-dcbecf78c3700c2029f675d2c688318f50891712.tar.bz2
libufodecode-dcbecf78c3700c2029f675d2c688318f50891712.tar.xz
libufodecode-dcbecf78c3700c2029f675d2c688318f50891712.zip
Add usage and issue message if no input
Diffstat (limited to 'test')
-rw-r--r--test/ipedec.c17
1 files changed, 15 insertions, 2 deletions
diff --git a/test/ipedec.c b/test/ipedec.c
index 800905f..5994fee 100644
--- a/test/ipedec.c
+++ b/test/ipedec.c
@@ -34,6 +34,11 @@ static int read_raw_file(const char *filename, char **buffer, size_t *length)
return 0;
}
+static void usage(void)
+{
+ printf("usage: ipedec [--num-rows=ROWS] [--clear-frame] FILE [FILE ...]\n");
+}
+
static void process_file(const char *filename, int rows, int clear_frame)
{
char *buffer = NULL;
@@ -100,14 +105,19 @@ int main(int argc, char const* argv[])
static struct option long_options[] = {
{ "num-rows", required_argument, 0, 'r' },
{ "clear-frame", no_argument, 0, 'c' },
- { "help", no_argument, 0, '?' },
+ { "help", no_argument, 0, 'h' },
{ 0, 0, 0, 0 }
};
int clear_frame = 0;
int rows = -1;
- while ((getopt_ret = getopt_long(argc, (char *const *) argv, "r:c:?", long_options, &index)) != -1) {
+ if (argc == 1) {
+ printf("ipedec: no input files\n");
+ return 0;
+ }
+
+ while ((getopt_ret = getopt_long(argc, (char *const *) argv, "r:c:h", long_options, &index)) != -1) {
switch (getopt_ret) {
case 'r':
rows = atoi(optarg);
@@ -115,6 +125,9 @@ int main(int argc, char const* argv[])
case 'c':
clear_frame = 1;
break;
+ case 'h':
+ usage();
+ return 0;
default:
break;
}