Browse Source

Add the --port option

master
Damien Goutte-Gattat 9 years ago
parent
commit
94da5f7d1f
  1. 37
      src/asysex.c

37
src/asysex.c

@ -25,6 +25,12 @@
#include <locale.h>
#include <getopt.h>
#include <sysex.h>
/* Globals. */
static midi_io_t *midi = NULL;
/* Help and informations about the program. */
@ -40,6 +46,10 @@ Read/write MIDI SysEx messages.\n");
-v, --version Display the version message.\n\
");
puts("\
-p, --port PORT Specify MIDI port to use.\n\
");
printf("Report bugs to <%s>.\n", PACKAGE_BUGREPORT);
exit(status);
@ -60,23 +70,39 @@ See the COPYING file or <http://www.gnu.org/licenses/gpl.html>.\n\
}
/* Helper functions. */
static void
cleanup(void)
{
if ( midi ) {
midi_close(midi);
midi = NULL;
}
}
/* Main function. */
int
main(int argc, char **argv)
{
char c;
char c, *port;
struct option options[] = {
{ "help", 0, NULL, 'h' },
{ "version", 0, NULL, 'v' },
{ "port", 1, NULL, 'p' },
{ NULL, 0, NULL, 0 }
};
setprogname(argv[0]);
setlocale(LC_ALL, "");
atexit(cleanup);
while ( (c = getopt_long(argc, argv, "hv", options, NULL)) != -1 ) {
port = "hw:1,0,0";
while ( (c = getopt_long(argc, argv, "hvp:", options, NULL)) != -1 ) {
switch ( c ) {
case 'h':
usage(EXIT_SUCCESS);
@ -89,8 +115,15 @@ main(int argc, char **argv)
case 'v':
info();
break;
case 'p':
port = optarg;
break;
}
}
if ( ! (midi = midi_open(port)) )
errx(EXIT_FAILURE, "cannot open MIDI port %s", port);
return EXIT_SUCCESS;
}
Loading…
Cancel
Save