3 |
* LinuxSampler - modular, streaming capable sampler * |
* LinuxSampler - modular, streaming capable sampler * |
4 |
* * |
* * |
5 |
* Copyright (C) 2003, 2004 by Benno Senoner and Christian Schoenebeck * |
* Copyright (C) 2003, 2004 by Benno Senoner and Christian Schoenebeck * |
6 |
|
* Copyright (C) 2005 - 2007 Christian Schoenebeck * |
7 |
* * |
* * |
8 |
* This program is free software; you can redistribute it and/or modify * |
* This program is free software; you can redistribute it and/or modify * |
9 |
* it under the terms of the GNU General Public License as published by * |
* it under the terms of the GNU General Public License as published by * |
33 |
#include <string> |
#include <string> |
34 |
|
|
35 |
#include "../common/global.h" |
#include "../common/global.h" |
36 |
|
#include "lscpevent.h" |
37 |
#include "../Sampler.h" |
#include "../Sampler.h" |
38 |
|
#include "../drivers/midi/MidiInstrumentMapper.h" |
39 |
|
|
40 |
/// Will be returned by the parser in case of syntax errors. |
/// Will be returned by the parser in case of syntax errors. |
41 |
#define LSCP_SYNTAX_ERROR -69 |
#define LSCP_SYNTAX_ERROR -69 |
42 |
|
#define LSCP_QUIT -1 |
43 |
|
#define LSCP_DONE 0 |
44 |
|
|
45 |
using namespace LinuxSampler; |
using namespace LinuxSampler; |
46 |
|
|
47 |
|
// just symbol prototyping |
48 |
|
class LSCPServer; |
49 |
|
|
50 |
/** |
/** |
51 |
* How the fill states of disk stream buffers should be reflected. |
* How the fill states of disk stream buffers should be reflected. |
52 |
*/ |
*/ |
65 |
*/ |
*/ |
66 |
struct YYSTYPE { |
struct YYSTYPE { |
67 |
union { |
union { |
68 |
char Char; |
char Char; |
69 |
unsigned int Number; |
unsigned int Number; |
70 |
double Dotnum; |
bool Bool; |
71 |
fill_response_t FillResponse; |
double Dotnum; |
72 |
AudioOutputDevice::type_t AudioOutput; |
fill_response_t FillResponse; |
73 |
MidiInputDevice::type_t MidiInput; |
LSCPEvent::event_t Event; |
74 |
|
MidiInstrumentMapper::mode_t LoadMode; |
75 |
}; |
}; |
76 |
std::string String; |
std::string String; |
77 |
|
std::map<std::string,std::string> KeyValList; |
78 |
}; |
}; |
79 |
#define yystype YYSTYPE ///< For backward compatibility. |
#define yystype YYSTYPE ///< For backward compatibility. |
80 |
#define YYSTYPE_IS_DECLARED ///< We tell the lexer / parser that we use our own data structure as defined above. |
#define YYSTYPE_IS_DECLARED ///< We tell the lexer / parser that we use our own data structure as defined above. |
81 |
|
|
|
// just symbol prototyping |
|
|
class LSCPServer; |
|
|
|
|
|
// pointer to an (reentrant) scanner / lexical analyzer |
|
|
typedef void* yyscan_t; |
|
|
|
|
82 |
/** |
/** |
83 |
* Parameters given to the parser on every yyparse() call. |
* Parameters given to the parser on every yyparse() call. |
84 |
*/ |
*/ |
85 |
struct yyparse_param_t { |
struct yyparse_param_t { |
86 |
LSCPServer* pServer; |
LSCPServer* pServer; |
87 |
yyscan_t pScanner; |
int hSession; |
88 |
|
bool bVerbose; ///< if true then all commands will immediately sent back (echo) |
89 |
|
|
90 |
|
yyparse_param_t() { |
91 |
|
pServer = NULL; |
92 |
|
hSession = -1; |
93 |
|
bVerbose = false; |
94 |
|
} |
95 |
}; |
}; |
96 |
#define YYPARSE_PARAM yyparse_param |
#define YYPARSE_PARAM yyparse_param |
97 |
|
|
98 |
/** |
/** |
99 |
* Prototype of the main scanner function (lexical analyzer). |
* Prototype of the main scanner function (lexical analyzer). |
100 |
*/ |
*/ |
101 |
#define YY_DECL int yylex(YYSTYPE* yylval, yyscan_t yyscanner) |
#define YY_DECL int yylex(YYSTYPE* yylval) |
|
|
|
|
/** |
|
|
* Override lex's input function which just reads from stdin by default. |
|
|
* We read from a socket instead. |
|
|
*/ |
|
|
#define YY_INPUT(buf,result,max_size) \ |
|
|
errno=0; \ |
|
|
while ( (result = recv(hSession, buf, max_size, 0)) < 0 ) \ |
|
|
{ \ |
|
|
if(errno != EINTR) \ |
|
|
{ \ |
|
|
switch(errno) { \ |
|
|
case EBADF: \ |
|
|
dmsg(2,("LSCPScanner: The argument s is an invalid descriptor.\n")); \ |
|
|
break; \ |
|
|
case ECONNREFUSED: \ |
|
|
dmsg(2,("LSCPScanner: A remote host refused to allow the network connection (typically because it is not running the requested service).\n")); \ |
|
|
break; \ |
|
|
case ENOTCONN: \ |
|
|
dmsg(2,("LSCPScanner: The socket is associated with a connection-oriented protocol and has not been connected (see connect(2) and accept(2)).\n")); \ |
|
|
break; \ |
|
|
case ENOTSOCK: \ |
|
|
dmsg(2,("LSCPScanner: The argument s does not refer to a socket.\n")); \ |
|
|
break; \ |
|
|
case EAGAIN: \ |
|
|
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")); \ |
|
|
break; \ |
|
|
case EINTR: \ |
|
|
dmsg(2,("LSCPScanner: The receive was interrupted by delivery of a signal before any data were available.\n")); \ |
|
|
break; \ |
|
|
case EFAULT: \ |
|
|
dmsg(2,("LSCPScanner: The receive buffer pointer(s) point outside the process's address space.\n")); \ |
|
|
break; \ |
|
|
case EINVAL: \ |
|
|
dmsg(2,("LSCPScanner: Invalid argument passed.\n")); \ |
|
|
break; \ |
|
|
case ENOMEM: \ |
|
|
dmsg(2,("LSCPScanner: Could not allocate memory for recvmsg.\n")); \ |
|
|
break; \ |
|
|
default: \ |
|
|
dmsg(2,("LSCPScanner: Unknown recv() error.\n")); \ |
|
|
break; \ |
|
|
} \ |
|
|
YY_FATAL_ERROR( "input in flex scanner failed" ); \ |
|
|
break; \ |
|
|
} \ |
|
|
errno=0; \ |
|
|
clearerr(yyin); \ |
|
|
}\ |
|
|
|
|
102 |
|
|
103 |
#endif // __LSCPPARSER_H__ |
#endif // __LSCPPARSER_H__ |