Skip to content
Snippets Groups Projects
Commit c884303e authored by yanmorin's avatar yanmorin
Browse files

Working flexlexer
parent 23783531
No related branches found
No related tags found
No related merge requests found
...@@ -65,13 +65,13 @@ public: ...@@ -65,13 +65,13 @@ public:
virtual void yy_delete_buffer( struct yy_buffer_state* b ) = 0; virtual void yy_delete_buffer( struct yy_buffer_state* b ) = 0;
virtual void yyrestart( std::istream* s ) = 0; virtual void yyrestart( std::istream* s ) = 0;
virtual int yylex() = 0; virtual int yylex(void *) = 0;
// Call yylex with new input/output sources. // Call yylex with new input/output sources.
int yylex( std::istream* new_in, std::ostream* new_out = 0 ) int yylex( std::istream* new_in, std::ostream* new_out = 0, void *p=0)
{ {
switch_streams( new_in, new_out ); switch_streams( new_in, new_out );
return yylex(); return yylex(p);
} }
// Switch to new input/output streams. A nil stream pointer // Switch to new input/output streams. A nil stream pointer
...@@ -113,7 +113,7 @@ public: ...@@ -113,7 +113,7 @@ public:
void yy_delete_buffer( struct yy_buffer_state* b ); void yy_delete_buffer( struct yy_buffer_state* b );
void yyrestart( std::istream* s ); void yyrestart( std::istream* s );
virtual int yylex(); virtual int yylex(void *);
virtual void switch_streams( std::istream* new_in, std::ostream* new_out ); virtual void switch_streams( std::istream* new_in, std::ostream* new_out );
protected: protected:
......
...@@ -4,7 +4,7 @@ libsflphoneguiserver_la_SOURCES = \ ...@@ -4,7 +4,7 @@ libsflphoneguiserver_la_SOURCES = \
$(BUILT_SOURCES) \ $(BUILT_SOURCES) \
guiserver.cpp \ guiserver.cpp \
lex.yy.cc \ lex.yy.cc \
y.tab.cc protocol.tab.cc
libsflphoneguiserver_la_CXXFLAGS = -DPREFIX=\"$(prefix)\" -DPROGSHAREDIR=\"${datadir}/sflphone\" libsflphoneguiserver_la_CXXFLAGS = -DPREFIX=\"$(prefix)\" -DPROGSHAREDIR=\"${datadir}/sflphone\"
libsflphoneguiserver_la_LIBADD = libsflphoneguiserver_la_LIBADD =
......
#ifndef __TCPSTREAMLEXER_H__
#define __TCPSTREAMLEXER_H__
#include <cc++/socket.h> #include <cc++/socket.h>
//#include "y.tab.h"
#include "FlexLexer.h" #include "FlexLexer.h"
static FlexLexer* lexer;
class yyFlexLexer;
class GUIServer; class GUIServer;
class TCPStreamLexer : public ost::TCPStream { class TCPStreamLexer : public ost::TCPStream {
public: public:
TCPStreamLexer(ost::TCPSocket &socket, GUIServer* gui) : ost::TCPStream(socket) { TCPStreamLexer(ost::TCPSocket &socket, GUIServer* gui) : ost::TCPStream(socket) {
_lexer = new yyFlexLexer(this, this);
_gui = gui; _gui = gui;
lexer = new yyFlexLexer(this, this);
} }
~TCPStreamLexer() { delete lexer; } ~TCPStreamLexer() { }
void parse(void); void parse(void);
void sip(YYSTYPE &y); void sip();
void callsip(YYSTYPE &y); void callsip();
yyFlexLexer *_lexer;
private: private:
GUIServer *_gui; GUIServer *_gui;
}; };
#endif // __TCPSTREAMLEXER_H__
...@@ -20,9 +20,10 @@ ...@@ -20,9 +20,10 @@
#include "guiserver.h" #include "guiserver.h"
#include <string> #include <string>
#include <iostream> #include <iostream>
#include "y.tab.h" // need by TCPStreamLexer.h but can't put in it #include "protocol.tab.h" // need by TCPStreamLexer.h but can't put in it
#include "TCPStreamLexer.h" #include "TCPStreamLexer.h"
// default constructor // default constructor
GUIServer::GUIServer() GUIServer::GUIServer()
{ {
...@@ -45,6 +46,7 @@ GUIServer::exec() { ...@@ -45,6 +46,7 @@ GUIServer::exec() {
int callid; int callid;
std::string status; std::string status;
while (std::cin.good()) { while (std::cin.good()) {
// waiting for a new connection // waiting for a new connection
...@@ -59,7 +61,6 @@ GUIServer::exec() { ...@@ -59,7 +61,6 @@ GUIServer::exec() {
std::string output; std::string output;
*aServerStream << "Welcome to this serveur2" << std::endl; *aServerStream << "Welcome to this serveur2" << std::endl;
lexer = new yyFlexLexer(aServerStream, aServerStream);
while(aServerStream->good() && output!="quit") { while(aServerStream->good() && output!="quit") {
// lire // lire
//std::getline(*aServerStream, output); //std::getline(*aServerStream, output);
...@@ -67,7 +68,10 @@ GUIServer::exec() { ...@@ -67,7 +68,10 @@ GUIServer::exec() {
// analyser // analyser
//std::cout << output << ":" << output.length() << std::endl; //std::cout << output << ":" << output.length() << std::endl;
aServerStream->parse(); aServerStream->parse();
/*
if ( output.find("call ") == 0 ) { if ( output.find("call ") == 0 ) {
callid = outgoingCall(output.substr(5,output.size()-5)); callid = outgoingCall(output.substr(5,output.size()-5));
if ( callid ) { if ( callid ) {
...@@ -85,11 +89,11 @@ GUIServer::exec() { ...@@ -85,11 +89,11 @@ GUIServer::exec() {
status += " Hangup."; status += " Hangup.";
displayStatus(status); displayStatus(status);
} }
*/
// repondre // repondre
//*aServerStream << output.length() << std::endl; //*aServerStream << output.length() << std::endl;
} }
delete lexer;
delete aServerStream; delete aServerStream;
std::cout << "end of connection\n"; std::cout << "end of connection\n";
} }
......
...@@ -235,7 +235,7 @@ typedef unsigned char YY_CHAR; ...@@ -235,7 +235,7 @@ typedef unsigned char YY_CHAR;
#define yytext_ptr yytext #define yytext_ptr yytext
#define YY_INTERACTIVE #define YY_INTERACTIVE
#include <FlexLexer.h> #include "FlexLexer.h"
/* Done after the current pattern has been matched and before the /* Done after the current pattern has been matched and before the
...@@ -370,11 +370,19 @@ static yyconst short int yy_chk[111] = ...@@ -370,11 +370,19 @@ static yyconst short int yy_chk[111] =
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
#include "y.tab.h" #include "protocol.tab.h"
extern YYSTYPE yylval; extern YYSTYPE yylval;
#define YY_FATAL_ERROR #define YY_FATAL_ERROR
#define YY_DECL int yyFlexLexer::yylex( void * )
#define YY_MAIN 0
#line 378 "lex.yy.cc" struct parser_control
{
int nastiness;
int randomness;
};
#line 386 "lex.yy.cc"
/* Macros after this point can all be overridden by user definitions in /* Macros after this point can all be overridden by user definitions in
* section 1. * section 1.
...@@ -501,9 +509,9 @@ YY_DECL ...@@ -501,9 +509,9 @@ YY_DECL
register char *yy_cp = NULL, *yy_bp = NULL; register char *yy_cp = NULL, *yy_bp = NULL;
register int yy_act; register int yy_act;
#line 12 "protocol.l" #line 20 "protocol.l"
#line 507 "lex.yy.cc" #line 515 "lex.yy.cc"
if ( yy_init ) if ( yy_init )
{ {
...@@ -588,95 +596,95 @@ do_action: /* This label is used only to access EOF actions. */ ...@@ -588,95 +596,95 @@ do_action: /* This label is used only to access EOF actions. */
case 1: case 1:
YY_RULE_SETUP YY_RULE_SETUP
#line 13 "protocol.l" #line 21 "protocol.l"
return AROBASE; return AROBASE;
YY_BREAK YY_BREAK
case 2: case 2:
YY_RULE_SETUP YY_RULE_SETUP
#line 14 "protocol.l" #line 22 "protocol.l"
yylval.number=atoi(yytext); return NUMBER; return NUMBER;
YY_BREAK YY_BREAK
case 3: case 3:
YY_RULE_SETUP YY_RULE_SETUP
#line 15 "protocol.l" #line 23 "protocol.l"
return SIP_URL_PREFIX; return SIP_URL_PREFIX;
YY_BREAK YY_BREAK
case 4: case 4:
YY_RULE_SETUP YY_RULE_SETUP
#line 16 "protocol.l" #line 24 "protocol.l"
return TOKEN_VOICEMAIL; return TOKEN_VOICEMAIL;
YY_BREAK YY_BREAK
case 5: case 5:
YY_RULE_SETUP YY_RULE_SETUP
#line 17 "protocol.l" #line 25 "protocol.l"
return TOKEN_RECEPTION; return TOKEN_RECEPTION;
YY_BREAK YY_BREAK
case 6: case 6:
YY_RULE_SETUP YY_RULE_SETUP
#line 18 "protocol.l" #line 26 "protocol.l"
return TOKEN_ALL; return TOKEN_ALL;
YY_BREAK YY_BREAK
case 7: case 7:
YY_RULE_SETUP YY_RULE_SETUP
#line 19 "protocol.l" #line 27 "protocol.l"
return TOKEN_GET; return TOKEN_GET;
YY_BREAK YY_BREAK
case 8: case 8:
YY_RULE_SETUP YY_RULE_SETUP
#line 20 "protocol.l" #line 28 "protocol.l"
return TOKEN_SET; return TOKEN_SET;
YY_BREAK YY_BREAK
case 9: case 9:
YY_RULE_SETUP YY_RULE_SETUP
#line 21 "protocol.l" #line 29 "protocol.l"
return CMD_CALL; return CMD_CALL;
YY_BREAK YY_BREAK
case 10: case 10:
YY_RULE_SETUP YY_RULE_SETUP
#line 22 "protocol.l" #line 30 "protocol.l"
return CMD_HANGUP; return CMD_HANGUP;
YY_BREAK YY_BREAK
case 11: case 11:
YY_RULE_SETUP YY_RULE_SETUP
#line 23 "protocol.l" #line 31 "protocol.l"
return CMD_HOLD; return CMD_HOLD;
YY_BREAK YY_BREAK
case 12: case 12:
YY_RULE_SETUP YY_RULE_SETUP
#line 24 "protocol.l" #line 32 "protocol.l"
return CMD_TRANSFER; return CMD_TRANSFER;
YY_BREAK YY_BREAK
case 13: case 13:
YY_RULE_SETUP YY_RULE_SETUP
#line 25 "protocol.l" #line 33 "protocol.l"
return CMD_QUIT; return CMD_QUIT;
YY_BREAK YY_BREAK
case 14: case 14:
YY_RULE_SETUP YY_RULE_SETUP
#line 26 "protocol.l" #line 34 "protocol.l"
return CMD_CONFIG; return CMD_CONFIG;
YY_BREAK YY_BREAK
case 15: case 15:
YY_RULE_SETUP YY_RULE_SETUP
#line 27 "protocol.l" #line 35 "protocol.l"
yylval.username=strdup(yytext); return USERNAME; return USERNAME;
YY_BREAK YY_BREAK
case 16: case 16:
YY_RULE_SETUP YY_RULE_SETUP
#line 28 "protocol.l" #line 36 "protocol.l"
/* ignore */ /* ignore */
YY_BREAK YY_BREAK
case 17: case 17:
YY_RULE_SETUP YY_RULE_SETUP
#line 29 "protocol.l" #line 37 "protocol.l"
/* ignore blanks */ /* ignore blanks */
YY_BREAK YY_BREAK
case 18: case 18:
YY_RULE_SETUP YY_RULE_SETUP
#line 30 "protocol.l" #line 38 "protocol.l"
ECHO; ECHO;
YY_BREAK YY_BREAK
#line 680 "lex.yy.cc" #line 688 "lex.yy.cc"
case YY_STATE_EOF(INITIAL): case YY_STATE_EOF(INITIAL):
yyterminate(); yyterminate();
...@@ -1481,5 +1489,5 @@ int main() ...@@ -1481,5 +1489,5 @@ int main()
return 0; return 0;
} }
#endif #endif
#line 30 "protocol.l" #line 38 "protocol.l"
...@@ -63,7 +63,6 @@ private: ...@@ -63,7 +63,6 @@ private:
std::list<std::string> _regtypeList; std::list<std::string> _regtypeList;
}; };
void DNSServiceAddServicesCallback(DNSServiceRef sdRef, void DNSServiceAddServicesCallback(DNSServiceRef sdRef,
DNSServiceFlags flags, DNSServiceFlags flags,
uint32_t interfaceIndex, uint32_t interfaceIndex,
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment