version 1.117, 2011/06/03 17:04:47 |
version 1.118, 2011/06/20 20:18:44 |
|
|
cfmid_add(struct cfmidlist *list, char *path) |
cfmid_add(struct cfmidlist *list, char *path) |
{ |
{ |
struct cfmid *cm; |
struct cfmid *cm; |
|
|
cm = malloc(sizeof(struct cfmid)); |
cm = malloc(sizeof(struct cfmid)); |
if (cm == NULL) { |
if (cm == NULL) { |
perror("malloc"); |
perror("malloc"); |
|
|
while (!SLIST_EMPTY(&cd->mids)) { |
while (!SLIST_EMPTY(&cd->mids)) { |
cm = SLIST_FIRST(&cd->mids); |
cm = SLIST_FIRST(&cd->mids); |
SLIST_REMOVE_HEAD(&cd->mids, entry); |
SLIST_REMOVE_HEAD(&cd->mids, entry); |
if (!dev_thruadd(d, cm->path, 1, 1)) |
if (!devctl_add(d, cm->path, MODE_MIDIMASK)) |
errx(1, "%s: can't open device", cm->path); |
errx(1, "%s: can't open port", cm->path); |
free(cm); |
free(cm); |
} |
} |
|
|
|
|
void |
void |
midicat_usage(void) |
midicat_usage(void) |
{ |
{ |
(void)fputs("usage: " PROG_MIDICAT " [-dl] " |
(void)fputs("usage: " PROG_MIDICAT " [-dl] [-a flag] " |
"[-i file] [-L addr] [-o file] [-q port] [-s name] [-U unit]\n", |
"[-i file] [-L addr] [-o file] [-q port]\n\t" |
|
"[-s name] [-U unit]\n", |
stderr); |
stderr); |
} |
} |
|
|
|
|
cs = cfstr_new(NULL); |
cs = cfstr_new(NULL); |
cd = cfdev_new(NULL); |
cd = cfdev_new(NULL); |
|
|
while ((c = getopt(argc, argv, "di:o:ls:q:U:L:")) != -1) { |
while ((c = getopt(argc, argv, "di:o:ls:a:q:U:L:")) != -1) { |
switch (c) { |
switch (c) { |
case 'd': |
case 'd': |
#ifdef DEBUG |
#ifdef DEBUG |
|
|
cfstr_add(&cd->outs, cs, optarg); |
cfstr_add(&cd->outs, cs, optarg); |
cs = cfstr_new(cs); |
cs = cfstr_new(cs); |
break; |
break; |
|
case 'a': |
|
cd->hold = opt_onoff(); |
|
break; |
case 'q': |
case 'q': |
cfmid_add(&cd->mids, optarg); |
cfmid_add(&cd->mids, optarg); |
break; |
break; |
|
|
cd = SLIST_FIRST(&cfdevs); |
cd = SLIST_FIRST(&cfdevs); |
SLIST_REMOVE_HEAD(&cfdevs, entry); |
SLIST_REMOVE_HEAD(&cfdevs, entry); |
|
|
d = dev_new_thru(); |
d = dev_new_thru(cd->hold); |
if (d == NULL) |
if (d == NULL) |
errx(1, "%s: can't open device", cd->path); |
errx(1, "%s: can't open device", cd->path); |
if (SLIST_EMPTY(&cd->opts) && APROC_OK(d->midi)) |
if (SLIST_EMPTY(&cd->opts) && APROC_OK(d->midi)) |
|
|
while (!SLIST_EMPTY(&cd->mids)) { |
while (!SLIST_EMPTY(&cd->mids)) { |
cm = SLIST_FIRST(&cd->mids); |
cm = SLIST_FIRST(&cd->mids); |
SLIST_REMOVE_HEAD(&cd->mids, entry); |
SLIST_REMOVE_HEAD(&cd->mids, entry); |
if (!dev_thruadd(d, cm->path, 1, 1)) |
if (!devctl_add(d, cm->path, MODE_MIDIMASK)) |
errx(1, "%s: can't open device", cm->path); |
errx(1, "%s: can't open port", cm->path); |
free(cm); |
free(cm); |
} |
} |
|
|