/[svn]/linuxsampler/trunk/src/network/lscpparser.h
ViewVC logotype

Contents of /linuxsampler/trunk/src/network/lscpparser.h

Parent Directory Parent Directory | Revision Log Revision Log


Revision 64 - (show annotations) (download) (as text)
Thu May 6 20:06:20 2004 UTC (19 years, 11 months ago) by schoenebeck
File MIME type: text/x-c++hdr
File size: 5318 byte(s)
* src/Sampler.cpp: fixed 3 stupid but fatal bugs that left in the rush (in
  method SamplerChannels(), CreateAudioOutputDevice() and
  CreateMidiInputDevice())
* src/network/lscpserver.cpp: implemented LSCP command
  'SET CHANNEL MIDI_INPUT_CHANNEL'
* src/Sampler.h: moved enums 'audio_output_type_t', 'midi_input_type_t'
  and 'engine_type_t' into the respective base classes
  ('AudioOutputDevice', 'MidiInputDevice', 'Engine')

1 /***************************************************************************
2 * *
3 * LinuxSampler - modular, streaming capable sampler *
4 * *
5 * Copyright (C) 2003, 2004 by Benno Senoner and Christian Schoenebeck *
6 * *
7 * This program is free software; you can redistribute it and/or modify *
8 * it under the terms of the GNU General Public License as published by *
9 * the Free Software Foundation; either version 2 of the License, or *
10 * (at your option) any later version. *
11 * *
12 * This program is distributed in the hope that it will be useful, *
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
15 * GNU General Public License for more details. *
16 * *
17 * You should have received a copy of the GNU General Public License *
18 * along with this program; if not, write to the Free Software *
19 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, *
20 * MA 02111-1307 USA *
21 ***************************************************************************/
22
23 #ifndef __LSCPPARSER_H__
24 #define __LSCPPARSER_H__
25
26 #include <sys/types.h>
27 #include <sys/socket.h>
28
29 #include <stdlib.h>
30 #include <iostream>
31 #include <sstream>
32 #include <string>
33
34 #include "../common/global.h"
35 #include "../Sampler.h"
36
37 /// Will be returned by the parser in case of syntax errors.
38 #define LSCP_SYNTAX_ERROR -69
39
40 using namespace LinuxSampler;
41
42 /**
43 * How the fill states of disk stream buffers should be reflected.
44 */
45 enum fill_response_t {
46 fill_response_bytes, ///< The returned values are meant in bytes.
47 fill_response_percentage ///< The returned values are meant in percentage.
48 };
49
50 /**
51 * Semantic value of the lookahead symbol.
52 *
53 * Structure that is used by the parser to process and return values from the
54 * input text. The lexical analyzer for example returns a number for
55 * recognized number strings in the input text and the parser might return a
56 * value for each of it's rules.
57 */
58 struct YYSTYPE {
59 union {
60 char Char;
61 unsigned int Number;
62 double Dotnum;
63 fill_response_t FillResponse;
64 AudioOutputDevice::type_t AudioOutput;
65 MidiInputDevice::type_t MidiInput;
66 };
67 std::string String;
68 };
69 #define yystype YYSTYPE ///< For backward compatibility.
70 #define YYSTYPE_IS_DECLARED ///< We tell the lexer / parser that we use our own data structure as defined above.
71
72 // just symbol prototyping
73 class LSCPServer;
74
75 // pointer to an (reentrant) scanner / lexical analyzer
76 typedef void* yyscan_t;
77
78 /**
79 * Parameters given to the parser on every yyparse() call.
80 */
81 struct yyparse_param_t {
82 LSCPServer* pServer;
83 yyscan_t pScanner;
84 };
85 #define YYPARSE_PARAM yyparse_param
86
87 /**
88 * Prototype of the main scanner function (lexical analyzer).
89 */
90 #define YY_DECL int yylex(YYSTYPE* yylval, yyscan_t yyscanner)
91
92 /**
93 * Override lex's input function which just reads from stdin by default.
94 * We read from a socket instead.
95 */
96 #define YY_INPUT(buf,result,max_size) \
97 errno=0; \
98 while ( (result = recv(hSession, buf, max_size, 0)) < 0 ) \
99 { \
100 if(errno != EINTR) \
101 { \
102 switch(errno) { \
103 case EBADF: \
104 dmsg(2,("LSCPScanner: The argument s is an invalid descriptor.\n")); \
105 break; \
106 case ECONNREFUSED: \
107 dmsg(2,("LSCPScanner: A remote host refused to allow the network connection (typically because it is not running the requested service).\n")); \
108 break; \
109 case ENOTCONN: \
110 dmsg(2,("LSCPScanner: The socket is associated with a connection-oriented protocol and has not been connected (see connect(2) and accept(2)).\n")); \
111 break; \
112 case ENOTSOCK: \
113 dmsg(2,("LSCPScanner: The argument s does not refer to a socket.\n")); \
114 break; \
115 case EAGAIN: \
116 dmsg(2,("LSCPScanner: The socket is marked non-blocking and the receive operation would block, or a receive timeout had been set and the timeout expired before data was received.\n")); \
117 break; \
118 case EINTR: \
119 dmsg(2,("LSCPScanner: The receive was interrupted by delivery of a signal before any data were available.\n")); \
120 break; \
121 case EFAULT: \
122 dmsg(2,("LSCPScanner: The receive buffer pointer(s) point outside the process's address space.\n")); \
123 break; \
124 case EINVAL: \
125 dmsg(2,("LSCPScanner: Invalid argument passed.\n")); \
126 break; \
127 case ENOMEM: \
128 dmsg(2,("LSCPScanner: Could not allocate memory for recvmsg.\n")); \
129 break; \
130 default: \
131 dmsg(2,("LSCPScanner: Unknown recv() error.\n")); \
132 break; \
133 } \
134 YY_FATAL_ERROR( "input in flex scanner failed" ); \
135 break; \
136 } \
137 errno=0; \
138 clearerr(yyin); \
139 }\
140
141
142 #endif // __LSCPPARSER_H__

  ViewVC Help
Powered by ViewVC