/[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 35 by schoenebeck, Fri Mar 5 13:46:15 2004 UTC revision 2516 by schoenebeck, Thu Feb 6 21:11:23 2014 UTC
# Line 2  Line 2 
2   *                                                                         *   *                                                                         *
3   *   LinuxSampler - modular, streaming capable sampler                     *   *   LinuxSampler - modular, streaming capable sampler                     *
4   *                                                                         *   *                                                                         *
5   *   Copyright (C) 2003 by Benno Senoner and Christian Schoenebeck         *   *   Copyright (C) 2003, 2004 by Benno Senoner and Christian Schoenebeck   *
6     *   Copyright (C) 2005 - 2014 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 24  Line 25 
25  #define __LSCPPARSER_H__  #define __LSCPPARSER_H__
26    
27  #include <sys/types.h>  #include <sys/types.h>
28    #if defined(WIN32)
29    #include <windows.h>
30    #else
31  #include <sys/socket.h>  #include <sys/socket.h>
32    #endif
33    
34  #include <stdlib.h>  #include <stdlib.h>
35  #include <iostream>  #include <iostream>
36  #include <sstream>  #include <sstream>
37  #include <string>  #include <string>
38    #include <stdint.h>
39    #include <set>
40    
41  #include "../global.h"  #include "../common/global_private.h"
42    #include "../common/Path.h"
43    #include "lscpevent.h"
44    #include "../Sampler.h"
45    #include "../drivers/midi/MidiInstrumentMapper.h"
46    
47    namespace LinuxSampler {
48    
49  /// Will be returned by the parser in case of syntax errors.  /// Will be returned by the parser in case of syntax errors.
50  #define LSCP_SYNTAX_ERROR       -69  #define LSCP_SYNTAX_ERROR       -69
51    #define LSCP_QUIT               -1
52    #define LSCP_DONE               0
53    
54    // just symbol prototyping
55    class LSCPServer;
56    
57  /**  /**
58   * How the fill states of disk stream buffers should be reflected.   * How the fill states of disk stream buffers should be reflected.
# Line 45  enum fill_response_t { Line 63  enum fill_response_t {
63  };  };
64    
65  /**  /**
  * Which audio output system to be used.  
  */  
 enum audio_output_type_t {  
     audio_output_type_alsa,  
     audio_output_type_jack  
 };  
   
 /**  
66   * Semantic value of the lookahead symbol.   * Semantic value of the lookahead symbol.
67   *   *
68   * Structure that is used by the parser to process and return values from the   * Structure that is used by the parser to process and return values from the
# Line 60  enum audio_output_type_t { Line 70  enum audio_output_type_t {
70   * 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
71   * value for each of it's rules.   * value for each of it's rules.
72   */   */
73  struct YYSTYPE {  struct _YYSTYPE {
74      union {      union {
75          char                Char;          char                         Char;
76          unsigned int        Number;          unsigned int                 Number;
77          double              Dotnum;          bool                         Bool;
78          fill_response_t     FillResponse;          double                       Dotnum;
79          audio_output_type_t AudioOutput;          fill_response_t              FillResponse;
80            LSCPEvent::event_t           Event;
81            MidiInstrumentMapper::mode_t LoadMode;
82      };      };
83      std::string  String;      std::string                       String;
84        std::map<std::string,std::string> KeyValList;
85        Path                              UniversalPath;
86  };  };
87    #define YYSTYPE _YYSTYPE
88  #define yystype YYSTYPE         ///< For backward compatibility.  #define yystype YYSTYPE         ///< For backward compatibility.
89  #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.
90    #define YYTYPE_INT16 int16_t
91  // just symbol prototyping  #define YYDEBUG 1
 class LSCPServer;  
   
 // pointer to an (reentrant) scanner / lexical analyzer  
 typedef void* yyscan_t;  
92    
93  /**  /**
94   * Parameters given to the parser on every yyparse() call.   * Parameters given to the parser on every yyparse() call.
95   */   */
96  struct yyparse_param_t {  struct yyparse_param_t {
97      LSCPServer* pServer;      LSCPServer* pServer;
98      yyscan_t    pScanner;      int         hSession;
99        bool        bVerbose; ///< if true then all commands will immediately sent back (echo)
100        bool        bShellInteract; ///< if true: then client is the LSCP shell
101        bool        bShellAutoCorrect; ///< if true: try to automatically correct obvious syntax mistakes
102        int         iLine;    ///< Current line (just for verbosity / messages)
103        int         iColumn;  ///< Current column (just for verbosity / messages)
104        YYTYPE_INT16** ppStackBottom; ///< Bottom end of the Bison parser's state stack.
105        YYTYPE_INT16** ppStackTop;    ///< Current position (heap) of the Bison parser's state stack.
106    
107        yyparse_param_t() {
108            pServer  = NULL;
109            hSession = -1;
110            bVerbose = false;
111            bShellInteract = bShellAutoCorrect = false;
112            iLine = iColumn = 0;
113            ppStackBottom = ppStackTop = NULL;
114        }
115  };  };
116  #define YYPARSE_PARAM yyparse_param  #define YYPARSE_PARAM yyparse_param
117    
118  /**  /**
119   * Prototype of the main scanner function (lexical analyzer).   * Prototype of the main scanner function (lexical analyzer).
120   */   */
121  #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); \  
         }\  
122    
123    }
124    
125  #endif // __LSCPPARSER_H__  #endif // __LSCPPARSER_H__

Legend:
Removed from v.35  
changed lines
  Added in v.2516

  ViewVC Help
Powered by ViewVC