Browse Source

Add choice of output mode

master
Damien Goutte-Gattat 10 years ago
parent
commit
729ca21c80
  1. 24
      src/asysex.c

24
src/asysex.c

@ -58,6 +58,12 @@ Read/write MIDI SysEx messages.\n");
-I, --inquiry Identify the MIDI device and exit.\n\
");
puts("\
-r, --raw Write output in raw binary format.\n\
-H, --hex Write output in hex format. This is the\n\
default.\n\
");
printf("Report bugs to <%s>.\n", PACKAGE_BUGREPORT);
exit(status);
@ -168,6 +174,12 @@ print_midi_hex(FILE *out, unsigned char *buffer, size_t len)
}
}
static void
print_midi_raw(FILE *out, unsigned char *buffer, size_t len)
{
fwrite(buffer, 1, len, out);
}
/* Mode functions. */
@ -229,6 +241,8 @@ main(int argc, char **argv)
{ "version", 0, NULL, 'v' },
{ "port", 1, NULL, 'p' },
{ "inquiry", 0, NULL, 'I' },
{ "raw", 0, NULL, 'r' },
{ "hex", 0, NULL, 'H' },
{ NULL, 0, NULL, 0 }
};
@ -240,7 +254,7 @@ main(int argc, char **argv)
mode = ASYSEX_MODE_QUERY;
print_midi = print_midi_hex;
while ( (c = getopt_long(argc, argv, "hvp:I", options, NULL)) != -1 ) {
while ( (c = getopt_long(argc, argv, "hvp:IrH", options, NULL)) != -1 ) {
switch ( c ) {
case 'h':
usage(EXIT_SUCCESS);
@ -261,6 +275,14 @@ main(int argc, char **argv)
case 'I':
mode = ASYSEX_MODE_INQUIRY;
break;
case 'r':
print_midi = print_midi_raw;
break;
case 'H':
print_midi = print_midi_hex;
break;
}
}

Loading…
Cancel
Save