.IP "" 4
% aconnect -d 64:0 65:0
.PP
+The address can be given using the client's name.
+.IP "" 4
+% aconnect External:0 Emu8000:1
+.PP
+Then the port 0 of the client matching with the string "External" is
+connected to the port 1 of the client matching with the "Emu8000".
+.PP
Another function of
.B aconnect
is to list the present ports
.br
1 'Announce ' [group=system]
.in -4
-client 64: '0: MIDI Synth' [group=] [type=kernel]
+client 64: 'External MIDI-0' [group=] [type=kernel]
.in +4
-0 'card 0: synth-midi: 0' [group=device]
+0 'MIDI 0-0 ' [group=device]
.in -4
.PP
Similary, to see the output ports, use
/*
* parse command line to client:port
+ * NB: the given string will be broken.
*/
-static int parse_address(snd_seq_addr_t *addr, char *arg)
+static int parse_address(snd_seq_t *seq, snd_seq_addr_t *addr, char *arg)
{
char *p;
+ int client, port;
- if (! isdigit(*arg))
- return -1;
if ((p = strpbrk(arg, ":.")) == NULL)
return -1;
- addr->client = atoi(arg);
- addr->port = atoi(p + 1);
+ if ((port = atoi(p + 1)) < 0)
+ return -1;
+ addr->port = port;
+ if (isdigit(*arg)) {
+ client = atoi(arg);
+ if (client < 0)
+ return -1;
+ addr->client = client;
+ } else {
+ /* convert from the name */
+ snd_seq_client_info_t cinfo;
+ int len;
+
+ *p = 0;
+ len = strlen(arg);
+ if (len <= 0)
+ return -1;
+ cinfo.client = -1;
+ while (snd_seq_query_next_client(seq, &cinfo) >= 0) {
+ if (! strncmp(cinfo.name, arg, len)) {
+ addr->client = cinfo.client;
+ return 0;
+ }
+ }
+ return -1; /* not found */
+ }
return 0;
}
/* set subscription */
memset(&subs, 0, sizeof(subs));
- if (parse_address(&subs.sender, argv[optind]) < 0) {
+ if (parse_address(seq, &subs.sender, argv[optind]) < 0) {
fprintf(stderr, "invalid sender address %s\n", argv[optind]);
return 1;
}
- if (parse_address(&subs.dest, argv[optind + 1]) < 0) {
+ if (parse_address(seq, &subs.dest, argv[optind + 1]) < 0) {
fprintf(stderr, "invalid destination address %s\n", argv[optind + 1]);
return 1;
}
}
/*
- * parse client:port argument
+ * parse command line to client:port
+ * NB: the given string will be broken.
*/
-static int parse_addr(snd_seq_addr_t *addr, char *arg)
+static int parse_address(snd_seq_t *seq, snd_seq_addr_t *addr, char *arg)
{
char *p;
+ int client, port;
- if (! isdigit(*arg))
- return -1;
if ((p = strpbrk(arg, ":.")) == NULL)
return -1;
- addr->client = atoi(arg);
- addr->port = atoi(p + 1);
+ if ((port = atoi(p + 1)) < 0)
+ return -1;
+ addr->port = port;
+ if (isdigit(*arg)) {
+ client = atoi(arg);
+ if (client < 0)
+ return -1;
+ addr->client = client;
+ } else {
+ /* convert from the name */
+ snd_seq_client_info_t cinfo;
+ int len;
+
+ *p = 0;
+ len = strlen(arg);
+ if (len <= 0)
+ return -1;
+ cinfo.client = -1;
+ while (snd_seq_query_next_client(seq, &cinfo) >= 0) {
+ if (! strncmp(cinfo.name, arg, len)) {
+ addr->client = cinfo.client;
+ return 0;
+ }
+ }
+ return -1; /* not found */
+ }
return 0;
}
/* explicit subscriptions */
if (source) {
/* read subscription */
- if (parse_addr(&addr, source) < 0) {
+ if (parse_address(handle, &addr, source) < 0) {
fprintf(stderr, "invalid source address %s\n", source);
exit(1);
}
}
if (dest) {
/* write subscription */
- if (parse_addr(&addr, dest) < 0) {
+ if (parse_address(handle, &addr, dest) < 0) {
fprintf(stderr, "invalid destination address %s\n", dest);
exit(1);
}