Initial revision
[ardour.git] / libs / midi++2 / port_request.cc
1 /*
2     Copyright (C) 2000 Paul Barton-Davis 
3
4     This program is free software; you can redistribute it and/or modify
5     it under the terms of the GNU General Public License as published by
6     the Free Software Foundation; either version 2 of the License, or
7     (at your option) any later version.
8
9     This program is distributed in the hope that it will be useful,
10     but WITHOUT ANY WARRANTY; without even the implied warranty of
11     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12     GNU General Public License for more details.
13
14     You should have received a copy of the GNU General Public License
15     along with this program; if not, write to the Free Software
16     Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
17
18     $Id$
19 */
20
21 #include <fcntl.h>
22 #include <string.h>
23 #include <midi++/port.h>
24 #include <midi++/port_request.h>
25
26 using namespace std;
27 using namespace MIDI;
28
29 PortRequest::PortRequest (const string &xdev, 
30                           const string &xtag, 
31                           const string &xmode,
32                           const string &xtype)
33
34 {
35         status = OK;
36         
37         devname = strdup (xdev.c_str());
38         tagname = strdup (xtag.c_str());
39
40         if (xmode == "output" ||
41             xmode == "out" || 
42             xmode == "OUTPUT" ||
43             xmode == "OUT") {
44                 mode = O_WRONLY;
45
46         } else if (xmode == "input" ||
47                    xmode == "in" ||
48                    xmode == "INPUT" ||
49                    xmode == "IN") {
50                 mode = O_RDONLY;
51
52         } else if (xmode == "duplex" ||
53                    xmode == "DUPLEX" ||
54                    xmode == "inout" || 
55                    xmode == "INOUT") {
56                 mode = O_RDWR;
57         } else {
58                 status = Unknown;
59         }
60
61         if (xtype == "ALSA/RAW" ||
62                    xtype == "alsa/raw") {
63                 type = Port::ALSA_RawMidi;
64         } else if (xtype == "ALSA/SEQUENCER" ||
65                    xtype == "alsa/sequencer") {
66                 type = Port::ALSA_Sequencer;
67         } else if (xtype == "COREMIDI" ||
68                    xtype == "coremidi") {
69                 type = Port::CoreMidi_MidiPort;
70         } else if (xtype == "NULL" ||
71                    xtype == "null") {
72                 type = Port::Null;
73         } else if (xtype == "FIFO" ||
74                    xtype == "fifo") {
75                 type = Port::FIFO;
76         } else {
77                 status = Unknown;
78         }
79 }
80