home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
ftp.ee.lbl.gov
/
2014.05.ftp.ee.lbl.gov.tar
/
ftp.ee.lbl.gov
/
bmd-1.0beta.tar.Z
/
bmd-1.0beta.tar
/
bmd-1.0beta
/
app
/
mtools
/
mrsel.c
< prev
next >
Wrap
C/C++ Source or Header
|
1991-08-21
|
2KB
|
85 lines
/*
* Copyright (c) 1990 Regents of the University of California.
* All rights reserved.
*
* Redistribution and use in source and binary forms are permitted
* provided that the above copyright notice and this paragraph are
* duplicated in all such forms and that any documentation,
* advertising materials, and other materials related to such
* distribution and use acknowledge that the software was developed
* by the University of California, Lawrence Berkeley Laboratory,
* Berkeley, CA. The name of the University may not be used to
* endorse or promote products derived from this software without
* specific prior written permission.
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
* WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*/
#include <stdio.h>
#include <sys/types.h>
#include <sys/time.h>
#include <sys/file.h>
#include <sys/ioctl.h>
#include <sundev/midi.h>
#ifndef lint
static char rcsid[] =
"@(#) $Header: mrsel.c,v 1.1 91/08/20 22:14:50 mccanne Exp $";
#endif
usage()
{
fprintf(stderr, "Usage: msel [-p port] [-a]\n");
exit(1);
}
main(argc, argv)
int argc;
char **argv;
{
int fd, cc, c, port;
struct midibuf mb;
int aflag = 0;
fd_set fds, fdinit;
extern char *optarg;
port = 1;
while ((c = getopt(argc, argv, "ap:")) != -1) {
switch(c) {
case 'a':
++aflag;
break;
case 'p':
port = atoi(optarg);
break;
default:
usage();
}
}
fd = midi_open(O_RDONLY, port);
if (aflag && ioctl(fd, BMDFILTER, 0) < 0) {
perror("BMDFILTER");
exit(1);
}
FD_ZERO(&fdinit);
FD_SET(fd, &fdinit);
while (1) {
fds = fdinit;
if (select(fd + 1, &fds, 0, 0, 0) < 0) {
perror("select");
exit(1);
}
cc = read(fd, &mb, sizeof mb);
if (cc < 0) {
perror("read");
exit(-1);
}
printf("read %d\n", cc);
}
}