Browse Source

Add -h and -v options

master
Damien Goutte-Gattat 9 years ago
parent
commit
0cfad1b6ee
  1. 61
      src/asysex.c

61
src/asysex.c

@ -22,6 +22,42 @@
#include <stdio.h>
#include <stdlib.h>
#include <locale.h>
#include <getopt.h>
/* Help and informations about the program. */
static void
usage(int status)
{
puts("\
Usage: asysex [options]\n\
Read/write MIDI SysEx messages.\n");
puts("Options:\n\
-h, --help Display this help message.\n\
-v, --version Display the version message.\n\
");
printf("Report bugs to <%s>.\n", PACKAGE_BUGREPORT);
exit(status);
}
static void
info(void)
{
printf("\
asysex %s\n\
Copyright (C) 2012 Damien Goutte-Gattat\n\
\n\
This program is released under the GNU General Public License.\n\
See the COPYING file or <http://www.gnu.org/licenses/gpl.html>.\n\
", VERSION);
exit(EXIT_SUCCESS);
}
/* Main function. */
@ -29,7 +65,32 @@
int
main(int argc, char **argv)
{
char c;
struct option options[] = {
{ "help", 0, NULL, 'h' },
{ "version", 0, NULL, 'v' },
{ NULL, 0, NULL, 0 }
};
setprogname(argv[0]);
setlocale(LC_ALL, "");
while ( (c = getopt_long(argc, argv, "hv", options, NULL)) != -1 ) {
switch ( c ) {
case 'h':
usage(EXIT_SUCCESS);
break;
case '?':
usage(EXIT_FAILURE);
break;
case 'v':
info();
break;
}
}
return EXIT_SUCCESS;
}
Loading…
Cancel
Save