static void usage(const char *argv0)
{
- fprintf(stderr, "Usage: %s [-b | --buffer-size <buffer-size>] [-d | --delay <packet-delay>] <server-host> <server-port>\n", argv0);
+ fprintf(stderr, "Usage: %s [-h | --help] [-b | --buffer-size <buffer-size>] [-d | --delay <packet-delay>] <server-host> <server-port>\n", argv0);
}
static void print_args(void)
while (1) {
int option_index = 0;
static struct option long_options[] = {
- {"buffer-size", 1, NULL, 0},
- {"packet-delay", 1, NULL, 0},
+ {"buffer-size", 1, NULL, 'b'},
+ {"packet-delay", 1, NULL, 'd'},
+ {"help", 0, NULL, 'h'},
{0, 0, 0, 0}
};
- c = getopt_long(argc, argv, "b:d:",
+ c = getopt_long(argc, argv, "hb:d:",
long_options, &option_index);
if (c == -1)
break;
cmd_args.packet_delay = atoi(optarg);
break;
+ case 'h':
+ usage(argv[0]);
+ exit(EXIT_SUCCESS);
+ break;
+
case '?':
break;