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

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

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 64 by schoenebeck, Thu May 6 20:06:20 2004 UTC revision 1244 by schoenebeck, Mon Jun 18 08:47:15 2007 UTC
# Line 3  Line 3 
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  *
# Line 32  Line 33 
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   */   */
# Line 55  enum fill_response_t { Line 63  enum fill_response_t {
63   * recognized number strings in the input text and the parser might return a   * recognized number strings in the input text and the parser might return a
64   * value for each of it's rules.   * value for each of it's rules.
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
80  #define yystype YYSTYPE         ///< For backward compatibility.  #define yystype YYSTYPE         ///< For backward compatibility.
81  #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.
82    
 // just symbol prototyping  
 class LSCPServer;  
   
 // pointer to an (reentrant) scanner / lexical analyzer  
 typedef void* yyscan_t;  
   
83  /**  /**
84   * Parameters given to the parser on every yyparse() call.   * Parameters given to the parser on every yyparse() call.
85   */   */
86  struct yyparse_param_t {  struct yyparse_param_t {
87      LSCPServer* pServer;      LSCPServer* pServer;
88      yyscan_t    pScanner;      int         hSession;
89        bool        bVerbose; ///< if true then all commands will immediately sent back (echo)
90    
91        yyparse_param_t() {
92            pServer  = NULL;
93            hSession = -1;
94            bVerbose = false;
95        }
96  };  };
97  #define YYPARSE_PARAM yyparse_param  #define YYPARSE_PARAM yyparse_param
98    
99  /**  /**
100   * Prototype of the main scanner function (lexical analyzer).   * Prototype of the main scanner function (lexical analyzer).
101   */   */
102  #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); \  
         }\  
   
103    
104  #endif // __LSCPPARSER_H__  #endif // __LSCPPARSER_H__

Legend:
Removed from v.64  
changed lines
  Added in v.1244

  ViewVC Help
Powered by ViewVC