Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
branch: jb
Fetching contributors…

Cannot retrieve contributors at this time

596 lines (553 sloc) 16.216 kb
#ifndef lint
static const char yysccsid[] = "@(#)yaccpar 1.9 (Berkeley) 02/21/93";
#endif
#include <stdlib.h>
#define YYBYACC 1
#define YYMAJOR 1
#define YYMINOR 9
#define YYPATCH 20050813
#define YYEMPTY (-1)
#define yyclearin (yychar = YYEMPTY)
#define yyerrok (yyerrflag = 0)
#define YYRECOVERING (yyerrflag != 0)
extern int yyparse(void);
static int yygrowstack(void);
#define YYPREFIX "yy"
#line 2 "parser.y"
/*
*
* BlueZ - Bluetooth protocol stack for Linux
*
* Copyright (C) 2002-2008 Marcel Holtmann <marcel@holtmann.org>
*
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*
*/
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
#include <stdio.h>
#include <errno.h>
#include <unistd.h>
#include <stdlib.h>
#include <string.h>
#include <sys/param.h>
#include <sys/socket.h>
#include <bluetooth/bluetooth.h>
#include <bluetooth/rfcomm.h>
#include "kword.h"
int yylex(void);
int yyerror(char *s);
struct rfcomm_opts *opts;
#line 49 "parser.y"
typedef union {
int number;
char *string;
bdaddr_t *bdaddr;
} YYSTYPE;
#line 74 "y.tab.c"
#define K_BIND 257
#define K_DEVICE 258
#define K_CHANNEL 259
#define K_COMMENT 260
#define K_YES 261
#define K_NO 262
#define NUMBER 263
#define RFCOMM 264
#define STRING 265
#define WORD 266
#define BDADDR 267
#define YYERRCODE 256
short yylhs[] = { -1,
0, 0, 0, 2, 2, 2, 2, 3, 5, 4,
4, 4, 6, 6, 6, 6, 6, 1, 1,
};
short yylen[] = { 2,
0, 1, 2, 4, 4, 1, 1, 1, 1, 2,
2, 3, 2, 2, 2, 2, 1, 1, 1,
};
short yydefred[] = { 0,
7, 9, 0, 0, 2, 0, 0, 3, 0, 0,
0, 0, 0, 0, 0, 17, 0, 0, 0, 11,
18, 19, 13, 14, 15, 16, 4, 0, 10, 5,
12,
};
short yydgoto[] = { 4,
23, 5, 6, 17, 7, 18,
};
short yysindex[] = { -254,
0, 0, 0, -254, 0, -120, -109, 0, -251, -251,
-41, -245, -248, -243, -244, 0, -125, -37, -121, 0,
0, 0, 0, 0, 0, 0, 0, -36, 0, 0,
0,
};
short yyrindex[] = { 24,
0, 0, 1, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0,
};
short yygindex[] = { 0,
0, 21, 0, 16, 0, -6,
};
#define YYTABLESIZE 267
short yytable[] = { 27,
6, 1, 9, 30, 11, 12, 13, 14, 15, 2,
28, 3, 28, 10, 16, 21, 22, 20, 24, 25,
26, 29, 31, 1, 8, 19, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 8, 0, 0, 0, 0, 0, 0,
0, 12, 13, 14, 15, 12, 13, 14, 15, 0,
16, 0, 0, 0, 16, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 6, 0, 0, 0,
0, 0, 0, 0, 6, 0, 6,
};
short yycheck[] = { 125,
0, 256, 123, 125, 256, 257, 258, 259, 260, 264,
17, 266, 19, 123, 266, 261, 262, 59, 267, 263,
265, 59, 59, 0, 4, 10, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, 123, -1, -1, -1, -1, -1, -1,
-1, 257, 258, 259, 260, 257, 258, 259, 260, -1,
266, -1, -1, -1, 266, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, 256, -1, -1, -1,
-1, -1, -1, -1, 264, -1, 266,
};
#define YYFINAL 4
#ifndef YYDEBUG
#define YYDEBUG 0
#endif
#define YYMAXTOKEN 267
#if YYDEBUG
char *yyname[] = {
"end-of-file",0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,"';'",0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,"'{'",0,"'}'",0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,"K_BIND","K_DEVICE",
"K_CHANNEL","K_COMMENT","K_YES","K_NO","NUMBER","RFCOMM","STRING","WORD",
"BDADDR",
};
char *yyrule[] = {
"$accept : config",
"config :",
"config : statement",
"config : config statement",
"statement : section '{' rfcomm_options '}'",
"statement : rfcomm '{' rfcomm_options '}'",
"statement : WORD",
"statement : error",
"section : WORD",
"rfcomm : RFCOMM",
"rfcomm_options : rfcomm_option ';'",
"rfcomm_options : error ';'",
"rfcomm_options : rfcomm_options rfcomm_option ';'",
"rfcomm_option : K_BIND bool",
"rfcomm_option : K_DEVICE BDADDR",
"rfcomm_option : K_CHANNEL NUMBER",
"rfcomm_option : K_COMMENT STRING",
"rfcomm_option : WORD",
"bool : K_YES",
"bool : K_NO",
};
#endif
#if YYDEBUG
#include <stdio.h>
#endif
/* define the initial stack-sizes */
#ifdef YYSTACKSIZE
#undef YYMAXDEPTH
#define YYMAXDEPTH YYSTACKSIZE
#else
#ifdef YYMAXDEPTH
#define YYSTACKSIZE YYMAXDEPTH
#else
#define YYSTACKSIZE 500
#define YYMAXDEPTH 500
#endif
#endif
#define YYINITSTACKSIZE 500
int yydebug;
int yynerrs;
int yyerrflag;
int yychar;
short *yyssp;
YYSTYPE *yyvsp;
YYSTYPE yyval;
YYSTYPE yylval;
/* variables for the parser stack */
static short *yyss;
static short *yysslim;
static YYSTYPE *yyvs;
static int yystacksize;
#line 134 "parser.y"
int yyerror(char *s)
{
fprintf(stderr, "%s line %d\n", s, lineno);
return 0;
}
int rfcomm_read_config(char *filename)
{
extern FILE *yyin;
char file[MAXPATHLEN + 1];
int i;
for (i = 0; i < RFCOMM_MAX_DEV; i++) {
rfcomm_opts[i].bind = 0;
bacpy(&rfcomm_opts[i].bdaddr, BDADDR_ANY);
rfcomm_opts[i].channel = 1;
}
if (filename) {
snprintf(file, MAXPATHLEN, "%s", filename);
} else {
snprintf(file, MAXPATHLEN, "%s/.bluetooth/rfcomm.conf", getenv("HOME"));
if ((getuid() == 0) || (access(file, R_OK) < 0))
snprintf(file, MAXPATHLEN, "%s/rfcomm.conf", CONFIGDIR);
}
if (!(yyin = fopen(file, "r")))
return -1;
lineno = 1;
yyparse();
fclose(yyin);
return 0;
}
#line 290 "y.tab.c"
/* allocate initial stack or double stack size, up to YYMAXDEPTH */
static int yygrowstack(void)
{
int newsize, i;
short *newss;
YYSTYPE *newvs;
if ((newsize = yystacksize) == 0)
newsize = YYINITSTACKSIZE;
else if (newsize >= YYMAXDEPTH)
return -1;
else if ((newsize *= 2) > YYMAXDEPTH)
newsize = YYMAXDEPTH;
i = yyssp - yyss;
newss = (yyss != 0)
? (short *)realloc(yyss, newsize * sizeof(*newss))
: (short *)malloc(newsize * sizeof(*newss));
if (newss == 0)
return -1;
yyss = newss;
yyssp = newss + i;
newvs = (yyvs != 0)
? (YYSTYPE *)realloc(yyvs, newsize * sizeof(*newvs))
: (YYSTYPE *)malloc(newsize * sizeof(*newvs));
if (newvs == 0)
return -1;
yyvs = newvs;
yyvsp = newvs + i;
yystacksize = newsize;
yysslim = yyss + newsize - 1;
return 0;
}
#define YYABORT goto yyabort
#define YYREJECT goto yyabort
#define YYACCEPT goto yyaccept
#define YYERROR goto yyerrlab
int
yyparse(void)
{
register int yym, yyn, yystate;
#if YYDEBUG
register const char *yys;
if ((yys = getenv("YYDEBUG")) != 0)
{
yyn = *yys;
if (yyn >= '0' && yyn <= '9')
yydebug = yyn - '0';
}
#endif
yynerrs = 0;
yyerrflag = 0;
yychar = YYEMPTY;
if (yyss == NULL && yygrowstack()) goto yyoverflow;
yyssp = yyss;
yyvsp = yyvs;
*yyssp = yystate = 0;
yyloop:
if ((yyn = yydefred[yystate]) != 0) goto yyreduce;
if (yychar < 0)
{
if ((yychar = yylex()) < 0) yychar = 0;
#if YYDEBUG
if (yydebug)
{
yys = 0;
if (yychar <= YYMAXTOKEN) yys = yyname[yychar];
if (!yys) yys = "illegal-symbol";
printf("%sdebug: state %d, reading %d (%s)\n",
YYPREFIX, yystate, yychar, yys);
}
#endif
}
if ((yyn = yysindex[yystate]) && (yyn += yychar) >= 0 &&
yyn <= YYTABLESIZE && yycheck[yyn] == yychar)
{
#if YYDEBUG
if (yydebug)
printf("%sdebug: state %d, shifting to state %d\n",
YYPREFIX, yystate, yytable[yyn]);
#endif
if (yyssp >= yysslim && yygrowstack())
{
goto yyoverflow;
}
*++yyssp = yystate = yytable[yyn];
*++yyvsp = yylval;
yychar = YYEMPTY;
if (yyerrflag > 0) --yyerrflag;
goto yyloop;
}
if ((yyn = yyrindex[yystate]) && (yyn += yychar) >= 0 &&
yyn <= YYTABLESIZE && yycheck[yyn] == yychar)
{
yyn = yytable[yyn];
goto yyreduce;
}
if (yyerrflag) goto yyinrecovery;
yyerror("syntax error");
#ifdef lint
goto yyerrlab;
#endif
yyerrlab:
++yynerrs;
yyinrecovery:
if (yyerrflag < 3)
{
yyerrflag = 3;
for (;;)
{
if ((yyn = yysindex[*yyssp]) && (yyn += YYERRCODE) >= 0 &&
yyn <= YYTABLESIZE && yycheck[yyn] == YYERRCODE)
{
#if YYDEBUG
if (yydebug)
printf("%sdebug: state %d, error recovery shifting\
to state %d\n", YYPREFIX, *yyssp, yytable[yyn]);
#endif
if (yyssp >= yysslim && yygrowstack())
{
goto yyoverflow;
}
*++yyssp = yystate = yytable[yyn];
*++yyvsp = yylval;
goto yyloop;
}
else
{
#if YYDEBUG
if (yydebug)
printf("%sdebug: error recovery discarding state %d\n",
YYPREFIX, *yyssp);
#endif
if (yyssp <= yyss) goto yyabort;
--yyssp;
--yyvsp;
}
}
}
else
{
if (yychar == 0) goto yyabort;
#if YYDEBUG
if (yydebug)
{
yys = 0;
if (yychar <= YYMAXTOKEN) yys = yyname[yychar];
if (!yys) yys = "illegal-symbol";
printf("%sdebug: state %d, error recovery discards token %d (%s)\n",
YYPREFIX, yystate, yychar, yys);
}
#endif
yychar = YYEMPTY;
goto yyloop;
}
yyreduce:
#if YYDEBUG
if (yydebug)
printf("%sdebug: state %d, reducing by rule %d (%s)\n",
YYPREFIX, yystate, yyn, yyrule[yyn]);
#endif
yym = yylen[yyn];
yyval = yyvsp[1-yym];
switch (yyn)
{
case 6:
#line 74 "parser.y"
{
}
break;
case 7:
#line 77 "parser.y"
{
yyclearin;
yyerrok;
}
break;
case 8:
#line 84 "parser.y"
{
opts = NULL;
}
break;
case 9:
#line 90 "parser.y"
{
if ((yyvsp[0].number >= 0) && (yyvsp[0].number < RFCOMM_MAX_DEV))
opts = &rfcomm_opts[yyvsp[0].number];
else
opts = NULL;
}
break;
case 13:
#line 104 "parser.y"
{
if (opts)
opts->bind = yyvsp[0].number;
}
break;
case 14:
#line 109 "parser.y"
{
if (opts)
bacpy(&opts->bdaddr, yyvsp[0].bdaddr);
}
break;
case 15:
#line 114 "parser.y"
{
if (opts)
opts->channel = yyvsp[0].number;
}
break;
case 16:
#line 119 "parser.y"
{
if (opts)
snprintf(opts->comment, MAXCOMMENTLEN, "%s", yyvsp[0].string);
}
break;
case 17:
#line 124 "parser.y"
{
/* Unknown option*/
}
break;
case 18:
#line 129 "parser.y"
{ yyval.number = 1; }
break;
case 19:
#line 130 "parser.y"
{ yyval.number = 0; }
break;
#line 537 "y.tab.c"
}
yyssp -= yym;
yystate = *yyssp;
yyvsp -= yym;
yym = yylhs[yyn];
if (yystate == 0 && yym == 0)
{
#if YYDEBUG
if (yydebug)
printf("%sdebug: after reduction, shifting from state 0 to\
state %d\n", YYPREFIX, YYFINAL);
#endif
yystate = YYFINAL;
*++yyssp = YYFINAL;
*++yyvsp = yyval;
if (yychar < 0)
{
if ((yychar = yylex()) < 0) yychar = 0;
#if YYDEBUG
if (yydebug)
{
yys = 0;
if (yychar <= YYMAXTOKEN) yys = yyname[yychar];
if (!yys) yys = "illegal-symbol";
printf("%sdebug: state %d, reading %d (%s)\n",
YYPREFIX, YYFINAL, yychar, yys);
}
#endif
}
if (yychar == 0) goto yyaccept;
goto yyloop;
}
if ((yyn = yygindex[yym]) && (yyn += yystate) >= 0 &&
yyn <= YYTABLESIZE && yycheck[yyn] == yystate)
yystate = yytable[yyn];
else
yystate = yydgoto[yym];
#if YYDEBUG
if (yydebug)
printf("%sdebug: after reduction, shifting from state %d \
to state %d\n", YYPREFIX, *yyssp, yystate);
#endif
if (yyssp >= yysslim && yygrowstack())
{
goto yyoverflow;
}
*++yyssp = yystate;
*++yyvsp = yyval;
goto yyloop;
yyoverflow:
yyerror("yacc stack overflow");
yyabort:
return (1);
yyaccept:
return (0);
}
Jump to Line
Something went wrong with that request. Please try again.