4 * BlueZ - Bluetooth protocol stack for Linux
6 * Copyright (C) 2002-2010 Marcel Holtmann <marcel@holtmann.org>
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2 of the License, or
12 * (at your option) any later version.
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, write to the Free Software
21 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
34 #include <sys/param.h>
35 #include <sys/socket.h>
37 #include <bluetooth/bluetooth.h>
38 #include <bluetooth/rfcomm.h>
45 struct rfcomm_opts *opts;
55 %token K_BIND K_DEVICE K_CHANNEL K_COMMENT
58 %token <number> NUMBER RFCOMM
59 %token <string> STRING WORD
60 %token <bdaddr> BDADDR
71 statement : section '{' rfcomm_options '}'
72 | rfcomm '{' rfcomm_options '}'
91 if (($1 >= 0) && ($1 < RFCOMM_MAX_DEV))
92 opts = &rfcomm_opts[$1];
98 rfcomm_options : rfcomm_option ';'
100 | rfcomm_options rfcomm_option ';'
103 rfcomm_option : K_BIND bool
111 bacpy(&opts->bdaddr, $2);
121 snprintf(opts->comment, MAXCOMMENTLEN, "%s", $2);
129 bool : K_YES { $$ = 1; }
137 fprintf(stderr, "%s line %d\n", s, lineno);
141 int rfcomm_read_config(char *filename)
144 char file[MAXPATHLEN + 1];
147 for (i = 0; i < RFCOMM_MAX_DEV; i++) {
148 rfcomm_opts[i].bind = 0;
149 bacpy(&rfcomm_opts[i].bdaddr, BDADDR_ANY);
150 rfcomm_opts[i].channel = 1;
154 snprintf(file, MAXPATHLEN, "%s", filename);
156 snprintf(file, MAXPATHLEN, "%s/.bluetooth/rfcomm.conf", getenv("HOME"));
158 if ((getuid() == 0) || (access(file, R_OK) < 0))
159 snprintf(file, MAXPATHLEN, "%s/rfcomm.conf", CONFIGDIR);
162 if (!(yyin = fopen(file, "r")))