Deleted Added
full compact
parse.y (204076) parse.y (207371)
1%{
2/*-
3 * Copyright (c) 2009-2010 The FreeBSD Foundation
4 * All rights reserved.
5 *
6 * This software was developed by Pawel Jakub Dawidek under sponsorship from
7 * the FreeBSD Foundation.
8 *

--- 13 unchanged lines hidden (view full) ---

22 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
23 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
24 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
25 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
26 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
27 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
28 * SUCH DAMAGE.
29 *
1%{
2/*-
3 * Copyright (c) 2009-2010 The FreeBSD Foundation
4 * All rights reserved.
5 *
6 * This software was developed by Pawel Jakub Dawidek under sponsorship from
7 * the FreeBSD Foundation.
8 *

--- 13 unchanged lines hidden (view full) ---

22 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
23 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
24 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
25 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
26 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
27 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
28 * SUCH DAMAGE.
29 *
30 * $FreeBSD: head/sbin/hastd/parse.y 204076 2010-02-18 23:16:19Z pjd $
30 * $FreeBSD: head/sbin/hastd/parse.y 207371 2010-04-29 15:36:32Z pjd $
31 */
32
33#include <sys/param.h> /* MAXHOSTNAMELEN */
34#include <sys/queue.h>
35#include <sys/sysctl.h>
36
37#include <arpa/inet.h>
38

--- 14 unchanged lines hidden (view full) ---

53
54static struct hastd_config lconfig;
55static struct hast_resource *curres;
56static bool mynode;
57
58static char depth0_control[HAST_ADDRSIZE];
59static char depth0_listen[HAST_ADDRSIZE];
60static int depth0_replication;
31 */
32
33#include <sys/param.h> /* MAXHOSTNAMELEN */
34#include <sys/queue.h>
35#include <sys/sysctl.h>
36
37#include <arpa/inet.h>
38

--- 14 unchanged lines hidden (view full) ---

53
54static struct hastd_config lconfig;
55static struct hast_resource *curres;
56static bool mynode;
57
58static char depth0_control[HAST_ADDRSIZE];
59static char depth0_listen[HAST_ADDRSIZE];
60static int depth0_replication;
61static int depth0_timeout;
61
62static char depth1_provname[PATH_MAX];
63static char depth1_localpath[PATH_MAX];
64
65static bool
66isitme(const char *name)
67{
68 char buf[MAXHOSTNAMELEN];

--- 41 unchanged lines hidden (view full) ---

110struct hastd_config *
111yy_config_parse(const char *config)
112{
113 int ret;
114
115 curres = NULL;
116 mynode = false;
117
62
63static char depth1_provname[PATH_MAX];
64static char depth1_localpath[PATH_MAX];
65
66static bool
67isitme(const char *name)
68{
69 char buf[MAXHOSTNAMELEN];

--- 41 unchanged lines hidden (view full) ---

111struct hastd_config *
112yy_config_parse(const char *config)
113{
114 int ret;
115
116 curres = NULL;
117 mynode = false;
118
119 depth0_timeout = HAST_TIMEOUT;
118 depth0_replication = HAST_REPLICATION_MEMSYNC;
119 strlcpy(depth0_control, HAST_CONTROL, sizeof(depth0_control));
120 strlcpy(depth0_listen, HASTD_LISTEN, sizeof(depth0_listen));
121
122 TAILQ_INIT(&lconfig.hc_resources);
123
124 yyin = fopen(config, "r");
125 if (yyin == NULL)

--- 23 unchanged lines hidden (view full) ---

149
150 if (curres->hr_replication == -1) {
151 /*
152 * Replication is not set at resource-level.
153 * Use global or default setting.
154 */
155 curres->hr_replication = depth0_replication;
156 }
120 depth0_replication = HAST_REPLICATION_MEMSYNC;
121 strlcpy(depth0_control, HAST_CONTROL, sizeof(depth0_control));
122 strlcpy(depth0_listen, HASTD_LISTEN, sizeof(depth0_listen));
123
124 TAILQ_INIT(&lconfig.hc_resources);
125
126 yyin = fopen(config, "r");
127 if (yyin == NULL)

--- 23 unchanged lines hidden (view full) ---

151
152 if (curres->hr_replication == -1) {
153 /*
154 * Replication is not set at resource-level.
155 * Use global or default setting.
156 */
157 curres->hr_replication = depth0_replication;
158 }
159 if (curres->hr_timeout == -1) {
160 /*
161 * Timeout is not set at resource-level.
162 * Use global or default setting.
163 */
164 curres->hr_timeout = depth0_timeout;
165 }
157 }
158
159 return (&lconfig);
160}
161
162void
163yy_config_free(struct hastd_config *config)
164{
165 struct hast_resource *res;
166
167 while ((res = TAILQ_FIRST(&config->hc_resources)) != NULL) {
168 TAILQ_REMOVE(&config->hc_resources, res, hr_next);
169 free(res);
170 }
171}
172%}
173
166 }
167
168 return (&lconfig);
169}
170
171void
172yy_config_free(struct hastd_config *config)
173{
174 struct hast_resource *res;
175
176 while ((res = TAILQ_FIRST(&config->hc_resources)) != NULL) {
177 TAILQ_REMOVE(&config->hc_resources, res, hr_next);
178 free(res);
179 }
180}
181%}
182
174%token CONTROL LISTEN PORT REPLICATION EXTENTSIZE RESOURCE NAME LOCAL REMOTE ON
183%token CONTROL LISTEN PORT REPLICATION TIMEOUT EXTENTSIZE RESOURCE NAME LOCAL REMOTE ON
175%token FULLSYNC MEMSYNC ASYNC
176%token NUM STR OB CB
177
178%type <num> replication_type
179
180%union
181{
182 int num;

--- 12 unchanged lines hidden (view full) ---

195
196statement:
197 control_statement
198 |
199 listen_statement
200 |
201 replication_statement
202 |
184%token FULLSYNC MEMSYNC ASYNC
185%token NUM STR OB CB
186
187%type <num> replication_type
188
189%union
190{
191 int num;

--- 12 unchanged lines hidden (view full) ---

204
205statement:
206 control_statement
207 |
208 listen_statement
209 |
210 replication_statement
211 |
212 timeout_statement
213 |
203 node_statement
204 |
205 resource_statement
206 ;
207
208control_statement: CONTROL STR
209 {
210 switch (depth) {

--- 65 unchanged lines hidden (view full) ---

276replication_type:
277 FULLSYNC { $$ = HAST_REPLICATION_FULLSYNC; }
278 |
279 MEMSYNC { $$ = HAST_REPLICATION_MEMSYNC; }
280 |
281 ASYNC { $$ = HAST_REPLICATION_ASYNC; }
282 ;
283
214 node_statement
215 |
216 resource_statement
217 ;
218
219control_statement: CONTROL STR
220 {
221 switch (depth) {

--- 65 unchanged lines hidden (view full) ---

287replication_type:
288 FULLSYNC { $$ = HAST_REPLICATION_FULLSYNC; }
289 |
290 MEMSYNC { $$ = HAST_REPLICATION_MEMSYNC; }
291 |
292 ASYNC { $$ = HAST_REPLICATION_ASYNC; }
293 ;
294
295timeout_statement: TIMEOUT NUM
296 {
297 switch (depth) {
298 case 0:
299 depth0_timeout = $2;
300 break;
301 case 1:
302 if (curres != NULL)
303 curres->hr_timeout = $2;
304 break;
305 default:
306 assert(!"timeout at wrong depth level");
307 }
308 }
309 ;
310
284node_statement: ON node_start OB node_entries CB
285 {
286 mynode = false;
287 }
288 ;
289
290node_start: STR
291 {

--- 92 unchanged lines hidden (view full) ---

384 sizeof(curres->hr_name)) >=
385 sizeof(curres->hr_name)) {
386 errx(EX_CONFIG,
387 "resource name (%s) too long", $1);
388 }
389 curres->hr_role = HAST_ROLE_INIT;
390 curres->hr_previous_role = HAST_ROLE_INIT;
391 curres->hr_replication = -1;
311node_statement: ON node_start OB node_entries CB
312 {
313 mynode = false;
314 }
315 ;
316
317node_start: STR
318 {

--- 92 unchanged lines hidden (view full) ---

411 sizeof(curres->hr_name)) >=
412 sizeof(curres->hr_name)) {
413 errx(EX_CONFIG,
414 "resource name (%s) too long", $1);
415 }
416 curres->hr_role = HAST_ROLE_INIT;
417 curres->hr_previous_role = HAST_ROLE_INIT;
418 curres->hr_replication = -1;
419 curres->hr_timeout = -1;
392 curres->hr_provname[0] = '\0';
393 curres->hr_localpath[0] = '\0';
394 curres->hr_localfd = -1;
395 curres->hr_remoteaddr[0] = '\0';
396 curres->hr_ggateunit = -1;
397 }
398 ;
399
400resource_entries:
401 |
402 resource_entries resource_entry
403 ;
404
405resource_entry:
406 replication_statement
407 |
420 curres->hr_provname[0] = '\0';
421 curres->hr_localpath[0] = '\0';
422 curres->hr_localfd = -1;
423 curres->hr_remoteaddr[0] = '\0';
424 curres->hr_ggateunit = -1;
425 }
426 ;
427
428resource_entries:
429 |
430 resource_entries resource_entry
431 ;
432
433resource_entry:
434 replication_statement
435 |
436 timeout_statement
437 |
408 name_statement
409 |
410 local_statement
411 |
412 resource_node_statement
413 ;
414
415name_statement: NAME STR

--- 92 unchanged lines hidden ---
438 name_statement
439 |
440 local_statement
441 |
442 resource_node_statement
443 ;
444
445name_statement: NAME STR

--- 92 unchanged lines hidden ---