version 1.121, 2011/10/12 12:16:10 |
version 1.122, 2011/10/17 21:09:11 |
|
|
#define SNDIO_PRIO (-20) |
#define SNDIO_PRIO (-20) |
|
|
#define PROG_AUCAT "aucat" |
#define PROG_AUCAT "aucat" |
#define PROG_MIDICAT "midicat" |
|
|
|
/* |
/* |
* sample rate if no ``-r'' is used |
* sample rate if no ``-r'' is used |
|
|
"[-q port] [-r rate] [-s name] [-t mode] [-U unit] [-v volume]\n\t" |
"[-q port] [-r rate] [-s name] [-t mode] [-U unit] [-v volume]\n\t" |
"[-w flag] [-x policy] [-z nframes]\n"; |
"[-w flag] [-x policy] [-z nframes]\n"; |
|
|
char midicat_usage[] = "usage: " PROG_MIDICAT " [-dlM] [-a flag] " |
|
"[-i file] [-L addr] [-o file] [-q port]\n\t" |
|
"[-s name] [-U unit]\n"; |
|
|
|
/* |
/* |
* SIGINT handler, it raises the quit flag. If the flag is already set, |
* SIGINT handler, it raises the quit flag. If the flag is already set, |
* that means that the last SIGINT was not handled, because the process |
* that means that the last SIGINT was not handled, because the process |
|
|
int |
int |
main(int argc, char **argv) |
main(int argc, char **argv) |
{ |
{ |
char *prog, *un_path, *optstr, *usagestr; |
char *prog, *optstr, *usagestr; |
int c, background, unit, server, tcp_port, active; |
int c, background, unit, server, active; |
char base[PATH_MAX], path[PATH_MAX]; |
char base[PATH_MAX], path[PATH_MAX]; |
unsigned mode, hdr, xrun, rate, join, mmc, vol; |
unsigned mode, hdr, xrun, rate, join, mmc, vol; |
unsigned hold, autovol, bufsz, round; |
unsigned hold, autovol, bufsz, round; |
|
|
mode = MODE_MIDIMASK | MODE_PLAY | MODE_REC; |
mode = MODE_MIDIMASK | MODE_PLAY | MODE_REC; |
optstr = "a:b:c:C:de:f:h:i:j:lL:m:Mno:q:r:s:t:U:v:w:x:z:t:j:z:"; |
optstr = "a:b:c:C:de:f:h:i:j:lL:m:Mno:q:r:s:t:U:v:w:x:z:t:j:z:"; |
usagestr = aucat_usage; |
usagestr = aucat_usage; |
un_path = AUCAT_PATH; |
|
tcp_port = AUCAT_PORT; |
|
} else if (strcmp(prog, PROG_MIDICAT) == 0) { |
|
mode = MODE_MIDIMASK | MODE_THRU; |
|
optstr = "a:di:lL:Mo:q:s:U:"; |
|
usagestr = midicat_usage; |
|
un_path = MIDICAT_PATH; |
|
tcp_port = MIDICAT_PORT; |
|
mkdev("midithru", MODE_THRU, 0, 0, 1, 0); |
|
} else { |
} else { |
fprintf(stderr, "%s: can't determine program to run\n", prog); |
fprintf(stderr, "%s: can't determine program to run\n", prog); |
return 1; |
return 1; |
} |
} |
|
|
|
|
while ((c = getopt(argc, argv, optstr)) != -1) { |
while ((c = getopt(argc, argv, optstr)) != -1) { |
switch (c) { |
switch (c) { |
case 'd': |
case 'd': |
|
|
server = 1; |
server = 1; |
break; |
break; |
case 'L': |
case 'L': |
listen_new_tcp(optarg, tcp_port + unit); |
listen_new_tcp(optarg, AUCAT_PORT + unit); |
server = 1; |
server = 1; |
break; |
break; |
case 'm': |
case 'm': |
|
|
} |
} |
if (server) { |
if (server) { |
getbasepath(base, sizeof(base)); |
getbasepath(base, sizeof(base)); |
snprintf(path, PATH_MAX, "%s/%s%u", base, un_path, unit); |
snprintf(path, PATH_MAX, "%s/%s%u", base, AUCAT_PATH, unit); |
listen_new_un(path); |
listen_new_un(path); |
if (geteuid() == 0) |
if (geteuid() == 0) |
privdrop(); |
privdrop(); |