16728b0dbbfba17d6d41c46aa4cadb52945070771Max Krasnyansky%{
26728b0dbbfba17d6d41c46aa4cadb52945070771Max Krasnyansky/*
36728b0dbbfba17d6d41c46aa4cadb52945070771Max Krasnyansky *
4b66d3f9b2cb8934a0eb7ac07f347001984488ac6Marcel Holtmann *  BlueZ - Bluetooth protocol stack for Linux
56728b0dbbfba17d6d41c46aa4cadb52945070771Max Krasnyansky *
69184e2eeb7b97371c6b83b747c8984e2340d2b47Marcel Holtmann *  Copyright (C) 2002-2010  Marcel Holtmann <marcel@holtmann.org>
76728b0dbbfba17d6d41c46aa4cadb52945070771Max Krasnyansky *
86728b0dbbfba17d6d41c46aa4cadb52945070771Max Krasnyansky *
96728b0dbbfba17d6d41c46aa4cadb52945070771Max Krasnyansky *  This program is free software; you can redistribute it and/or modify
10632a9432774ff3a0c6e556e8f32a565b38890767Marcel Holtmann *  it under the terms of the GNU General Public License as published by
11632a9432774ff3a0c6e556e8f32a565b38890767Marcel Holtmann *  the Free Software Foundation; either version 2 of the License, or
12632a9432774ff3a0c6e556e8f32a565b38890767Marcel Holtmann *  (at your option) any later version.
136728b0dbbfba17d6d41c46aa4cadb52945070771Max Krasnyansky *
14632a9432774ff3a0c6e556e8f32a565b38890767Marcel Holtmann *  This program is distributed in the hope that it will be useful,
15632a9432774ff3a0c6e556e8f32a565b38890767Marcel Holtmann *  but WITHOUT ANY WARRANTY; without even the implied warranty of
16632a9432774ff3a0c6e556e8f32a565b38890767Marcel Holtmann *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17632a9432774ff3a0c6e556e8f32a565b38890767Marcel Holtmann *  GNU General Public License for more details.
186728b0dbbfba17d6d41c46aa4cadb52945070771Max Krasnyansky *
19632a9432774ff3a0c6e556e8f32a565b38890767Marcel Holtmann *  You should have received a copy of the GNU General Public License
20632a9432774ff3a0c6e556e8f32a565b38890767Marcel Holtmann *  along with this program; if not, write to the Free Software
21632a9432774ff3a0c6e556e8f32a565b38890767Marcel Holtmann *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
226728b0dbbfba17d6d41c46aa4cadb52945070771Max Krasnyansky *
236728b0dbbfba17d6d41c46aa4cadb52945070771Max Krasnyansky */
246728b0dbbfba17d6d41c46aa4cadb52945070771Max Krasnyansky
25b66d3f9b2cb8934a0eb7ac07f347001984488ac6Marcel Holtmann#ifdef HAVE_CONFIG_H
26b66d3f9b2cb8934a0eb7ac07f347001984488ac6Marcel Holtmann#include <config.h>
27b66d3f9b2cb8934a0eb7ac07f347001984488ac6Marcel Holtmann#endif
28b66d3f9b2cb8934a0eb7ac07f347001984488ac6Marcel Holtmann
29f58470a0e841d917c1d33ce5393d7882bd92d7f3Marcel Holtmann/* Nasty workaround, but flex defines isatty() twice */
30f58470a0e841d917c1d33ce5393d7882bd92d7f3Marcel Holtmann#define _UNISTD_H
31f58470a0e841d917c1d33ce5393d7882bd92d7f3Marcel Holtmann
326728b0dbbfba17d6d41c46aa4cadb52945070771Max Krasnyansky#include <stdio.h>
33632a9432774ff3a0c6e556e8f32a565b38890767Marcel Holtmann#include <errno.h>
346728b0dbbfba17d6d41c46aa4cadb52945070771Max Krasnyansky#include <sys/socket.h>
356728b0dbbfba17d6d41c46aa4cadb52945070771Max Krasnyansky
366728b0dbbfba17d6d41c46aa4cadb52945070771Max Krasnyansky#include <bluetooth/bluetooth.h>
376728b0dbbfba17d6d41c46aa4cadb52945070771Max Krasnyansky#include <bluetooth/rfcomm.h>
386728b0dbbfba17d6d41c46aa4cadb52945070771Max Krasnyansky
396728b0dbbfba17d6d41c46aa4cadb52945070771Max Krasnyansky#include "kword.h"
406728b0dbbfba17d6d41c46aa4cadb52945070771Max Krasnyansky#include "parser.h"
416728b0dbbfba17d6d41c46aa4cadb52945070771Max Krasnyansky
425e0ca52b4cc7136c11d0e9a8b97b12adb51061f8Marcel Holtmannint yylex(void);
435e0ca52b4cc7136c11d0e9a8b97b12adb51061f8Marcel Holtmann
448c288fd0984679c73398ab931bc91213d9090fcaMarcel Holtmann#define YY_NO_INPUT
456728b0dbbfba17d6d41c46aa4cadb52945070771Max Krasnyansky
466728b0dbbfba17d6d41c46aa4cadb52945070771Max Krasnyansky#define ECHO {;}
476728b0dbbfba17d6d41c46aa4cadb52945070771Max Krasnyansky#define YY_DECL int yylex(void)
486728b0dbbfba17d6d41c46aa4cadb52945070771Max Krasnyansky
496728b0dbbfba17d6d41c46aa4cadb52945070771Max Krasnyanskyint yyerror(char *str);
506728b0dbbfba17d6d41c46aa4cadb52945070771Max Krasnyansky
516728b0dbbfba17d6d41c46aa4cadb52945070771Max Krasnyansky%}
526728b0dbbfba17d6d41c46aa4cadb52945070771Max Krasnyansky
5324795de83b9f2b24bd128707770387bcddad4367Marcel Holtmann%option nounput
5424795de83b9f2b24bd128707770387bcddad4367Marcel Holtmann
556728b0dbbfba17d6d41c46aa4cadb52945070771Max Krasnyanskyspace		[ \t]
566728b0dbbfba17d6d41c46aa4cadb52945070771Max Krasnyanskylinebreak	\n
576728b0dbbfba17d6d41c46aa4cadb52945070771Max Krasnyanskycomment		\#.*\n
586728b0dbbfba17d6d41c46aa4cadb52945070771Max Krasnyanskykeyword		[A-Za-z0-9\_\-]+
596728b0dbbfba17d6d41c46aa4cadb52945070771Max Krasnyansky
606728b0dbbfba17d6d41c46aa4cadb52945070771Max Krasnyanskynumber		[0-9]+
616728b0dbbfba17d6d41c46aa4cadb52945070771Max Krasnyanskystring		\".*\"
626728b0dbbfba17d6d41c46aa4cadb52945070771Max Krasnyanskybdaddr		[A-Za-z0-9]{2}:[A-Za-z0-9]{2}:[A-Za-z0-9]{2}:[A-Za-z0-9]{2}:[A-Za-z0-9]{2}:[A-Za-z0-9]{2}
636728b0dbbfba17d6d41c46aa4cadb52945070771Max Krasnyansky
646728b0dbbfba17d6d41c46aa4cadb52945070771Max Krasnyansky%%
656728b0dbbfba17d6d41c46aa4cadb52945070771Max Krasnyansky
666728b0dbbfba17d6d41c46aa4cadb52945070771Max Krasnyansky{space}		{
676728b0dbbfba17d6d41c46aa4cadb52945070771Max Krasnyansky			/* Skip spaces and tabs */
686728b0dbbfba17d6d41c46aa4cadb52945070771Max Krasnyansky			;
696728b0dbbfba17d6d41c46aa4cadb52945070771Max Krasnyansky		}
706728b0dbbfba17d6d41c46aa4cadb52945070771Max Krasnyansky
716728b0dbbfba17d6d41c46aa4cadb52945070771Max Krasnyansky{comment}	{
726728b0dbbfba17d6d41c46aa4cadb52945070771Max Krasnyansky			/* Skip comments */
736728b0dbbfba17d6d41c46aa4cadb52945070771Max Krasnyansky			lineno++;
746728b0dbbfba17d6d41c46aa4cadb52945070771Max Krasnyansky		}
756728b0dbbfba17d6d41c46aa4cadb52945070771Max Krasnyansky
766728b0dbbfba17d6d41c46aa4cadb52945070771Max Krasnyansky{number}	{
776728b0dbbfba17d6d41c46aa4cadb52945070771Max Krasnyansky			yylval.number = atoi(yytext);
786728b0dbbfba17d6d41c46aa4cadb52945070771Max Krasnyansky			return NUMBER;
796728b0dbbfba17d6d41c46aa4cadb52945070771Max Krasnyansky		}
806728b0dbbfba17d6d41c46aa4cadb52945070771Max Krasnyansky
816728b0dbbfba17d6d41c46aa4cadb52945070771Max Krasnyansky{string}	{
826728b0dbbfba17d6d41c46aa4cadb52945070771Max Krasnyansky			yylval.string = yytext;
836728b0dbbfba17d6d41c46aa4cadb52945070771Max Krasnyansky			return STRING;
846728b0dbbfba17d6d41c46aa4cadb52945070771Max Krasnyansky		}
856728b0dbbfba17d6d41c46aa4cadb52945070771Max Krasnyansky
866728b0dbbfba17d6d41c46aa4cadb52945070771Max Krasnyansky{bdaddr}	{
876728b0dbbfba17d6d41c46aa4cadb52945070771Max Krasnyansky			bdaddr_t *ba = malloc(sizeof(bdaddr_t));
886728b0dbbfba17d6d41c46aa4cadb52945070771Max Krasnyansky			str2ba(yytext, ba);
896728b0dbbfba17d6d41c46aa4cadb52945070771Max Krasnyansky			yylval.bdaddr = ba;
906728b0dbbfba17d6d41c46aa4cadb52945070771Max Krasnyansky			return BDADDR;
916728b0dbbfba17d6d41c46aa4cadb52945070771Max Krasnyansky		}
926728b0dbbfba17d6d41c46aa4cadb52945070771Max Krasnyansky
936728b0dbbfba17d6d41c46aa4cadb52945070771Max Krasnyansky{keyword}	{
946728b0dbbfba17d6d41c46aa4cadb52945070771Max Krasnyansky			int keyword = rfcomm_find_keyword(rfcomm_keyword, yytext);
956728b0dbbfba17d6d41c46aa4cadb52945070771Max Krasnyansky			if (keyword != -1)
966728b0dbbfba17d6d41c46aa4cadb52945070771Max Krasnyansky				return keyword;
976728b0dbbfba17d6d41c46aa4cadb52945070771Max Krasnyansky
986728b0dbbfba17d6d41c46aa4cadb52945070771Max Krasnyansky			if (strncmp(yytext, "rfcomm", 6) == 0) {
996728b0dbbfba17d6d41c46aa4cadb52945070771Max Krasnyansky				yylval.number = atoi(yytext + 6);
1006728b0dbbfba17d6d41c46aa4cadb52945070771Max Krasnyansky				return RFCOMM;
1016728b0dbbfba17d6d41c46aa4cadb52945070771Max Krasnyansky			}
1026728b0dbbfba17d6d41c46aa4cadb52945070771Max Krasnyansky
1036728b0dbbfba17d6d41c46aa4cadb52945070771Max Krasnyansky			yylval.string = yytext;
1046728b0dbbfba17d6d41c46aa4cadb52945070771Max Krasnyansky			return WORD;
1056728b0dbbfba17d6d41c46aa4cadb52945070771Max Krasnyansky		}
1066728b0dbbfba17d6d41c46aa4cadb52945070771Max Krasnyansky
1076728b0dbbfba17d6d41c46aa4cadb52945070771Max Krasnyansky{linebreak}	{
1086728b0dbbfba17d6d41c46aa4cadb52945070771Max Krasnyansky			lineno++;
1096728b0dbbfba17d6d41c46aa4cadb52945070771Max Krasnyansky		}
1106728b0dbbfba17d6d41c46aa4cadb52945070771Max Krasnyansky
1116728b0dbbfba17d6d41c46aa4cadb52945070771Max Krasnyansky.		{
1126728b0dbbfba17d6d41c46aa4cadb52945070771Max Krasnyansky			return *yytext;
1136728b0dbbfba17d6d41c46aa4cadb52945070771Max Krasnyansky		}
1146728b0dbbfba17d6d41c46aa4cadb52945070771Max Krasnyansky
1156728b0dbbfba17d6d41c46aa4cadb52945070771Max Krasnyansky%%
1166728b0dbbfba17d6d41c46aa4cadb52945070771Max Krasnyansky
1176728b0dbbfba17d6d41c46aa4cadb52945070771Max Krasnyanskyint yywrap(void)
1186728b0dbbfba17d6d41c46aa4cadb52945070771Max Krasnyansky{
1196728b0dbbfba17d6d41c46aa4cadb52945070771Max Krasnyansky	return 1;
1206728b0dbbfba17d6d41c46aa4cadb52945070771Max Krasnyansky}
121