Deleted Added
full compact
parse.y (211886) parse.y (214274)
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 211886 2010-08-27 15:16:52Z pjd $
30 * $FreeBSD: head/sbin/hastd/parse.y 214274 2010-10-24 15:41:23Z 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

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

259control_statement: CONTROL STR
260 {
261 switch (depth) {
262 case 0:
263 if (strlcpy(depth0_control, $2,
264 sizeof(depth0_control)) >=
265 sizeof(depth0_control)) {
266 pjdlog_error("control argument is too long.");
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

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

259control_statement: CONTROL STR
260 {
261 switch (depth) {
262 case 0:
263 if (strlcpy(depth0_control, $2,
264 sizeof(depth0_control)) >=
265 sizeof(depth0_control)) {
266 pjdlog_error("control argument is too long.");
267 free($2);
267 return (1);
268 }
269 break;
270 case 1:
271 if (!mynode)
272 break;
273 if (strlcpy(lconfig->hc_controladdr, $2,
274 sizeof(lconfig->hc_controladdr)) >=
275 sizeof(lconfig->hc_controladdr)) {
276 pjdlog_error("control argument is too long.");
268 return (1);
269 }
270 break;
271 case 1:
272 if (!mynode)
273 break;
274 if (strlcpy(lconfig->hc_controladdr, $2,
275 sizeof(lconfig->hc_controladdr)) >=
276 sizeof(lconfig->hc_controladdr)) {
277 pjdlog_error("control argument is too long.");
278 free($2);
277 return (1);
278 }
279 break;
280 default:
281 assert(!"control at wrong depth level");
282 }
279 return (1);
280 }
281 break;
282 default:
283 assert(!"control at wrong depth level");
284 }
285 free($2);
283 }
284 ;
285
286listen_statement: LISTEN STR
287 {
288 switch (depth) {
289 case 0:
290 if (strlcpy(depth0_listen, $2,
291 sizeof(depth0_listen)) >=
292 sizeof(depth0_listen)) {
293 pjdlog_error("listen argument is too long.");
286 }
287 ;
288
289listen_statement: LISTEN STR
290 {
291 switch (depth) {
292 case 0:
293 if (strlcpy(depth0_listen, $2,
294 sizeof(depth0_listen)) >=
295 sizeof(depth0_listen)) {
296 pjdlog_error("listen argument is too long.");
297 free($2);
294 return (1);
295 }
296 break;
297 case 1:
298 if (!mynode)
299 break;
300 if (strlcpy(lconfig->hc_listenaddr, $2,
301 sizeof(lconfig->hc_listenaddr)) >=
302 sizeof(lconfig->hc_listenaddr)) {
303 pjdlog_error("listen argument is too long.");
298 return (1);
299 }
300 break;
301 case 1:
302 if (!mynode)
303 break;
304 if (strlcpy(lconfig->hc_listenaddr, $2,
305 sizeof(lconfig->hc_listenaddr)) >=
306 sizeof(lconfig->hc_listenaddr)) {
307 pjdlog_error("listen argument is too long.");
308 free($2);
304 return (1);
305 }
306 break;
307 default:
308 assert(!"listen at wrong depth level");
309 }
309 return (1);
310 }
311 break;
312 default:
313 assert(!"listen at wrong depth level");
314 }
315 free($2);
310 }
311 ;
312
313replication_statement: REPLICATION replication_type
314 {
315 switch (depth) {
316 case 0:
317 depth0_replication = $2;

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

352
353exec_statement: EXEC STR
354 {
355 switch (depth) {
356 case 0:
357 if (strlcpy(depth0_exec, $2, sizeof(depth0_exec)) >=
358 sizeof(depth0_exec)) {
359 pjdlog_error("Exec path is too long.");
316 }
317 ;
318
319replication_statement: REPLICATION replication_type
320 {
321 switch (depth) {
322 case 0:
323 depth0_replication = $2;

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

358
359exec_statement: EXEC STR
360 {
361 switch (depth) {
362 case 0:
363 if (strlcpy(depth0_exec, $2, sizeof(depth0_exec)) >=
364 sizeof(depth0_exec)) {
365 pjdlog_error("Exec path is too long.");
366 free($2);
360 return (1);
361 }
362 break;
363 case 1:
364 if (curres == NULL)
365 break;
366 if (strlcpy(curres->hr_exec, $2,
367 sizeof(curres->hr_exec)) >=
368 sizeof(curres->hr_exec)) {
369 pjdlog_error("Exec path is too long.");
367 return (1);
368 }
369 break;
370 case 1:
371 if (curres == NULL)
372 break;
373 if (strlcpy(curres->hr_exec, $2,
374 sizeof(curres->hr_exec)) >=
375 sizeof(curres->hr_exec)) {
376 pjdlog_error("Exec path is too long.");
377 free($2);
370 return (1);
371 }
372 break;
373 default:
374 assert(!"exec at wrong depth level");
375 }
378 return (1);
379 }
380 break;
381 default:
382 assert(!"exec at wrong depth level");
383 }
384 free($2);
376 }
377 ;
378
379node_statement: ON node_start OB node_entries CB
380 {
381 mynode = false;
382 }
383 ;
384
385node_start: STR
386 {
387 switch (isitme($1)) {
388 case -1:
385 }
386 ;
387
388node_statement: ON node_start OB node_entries CB
389 {
390 mynode = false;
391 }
392 ;
393
394node_start: STR
395 {
396 switch (isitme($1)) {
397 case -1:
398 free($1);
389 return (1);
390 case 0:
391 break;
392 case 1:
393 mynode = true;
394 break;
395 default:
396 assert(!"invalid isitme() return value");
397 }
399 return (1);
400 case 0:
401 break;
402 case 1:
403 mynode = true;
404 break;
405 default:
406 assert(!"invalid isitme() return value");
407 }
408 free($1);
398 }
399 ;
400
401node_entries:
402 |
403 node_entries node_entry
404 ;
405

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

477 * resource-level or not.
478 */
479 depth1_provname[0] = '\0';
480 depth1_localpath[0] = '\0';
481
482 curres = calloc(1, sizeof(*curres));
483 if (curres == NULL) {
484 pjdlog_error("Unable to allocate memory for resource.");
409 }
410 ;
411
412node_entries:
413 |
414 node_entries node_entry
415 ;
416

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

488 * resource-level or not.
489 */
490 depth1_provname[0] = '\0';
491 depth1_localpath[0] = '\0';
492
493 curres = calloc(1, sizeof(*curres));
494 if (curres == NULL) {
495 pjdlog_error("Unable to allocate memory for resource.");
496 free($1);
485 return (1);
486 }
487 if (strlcpy(curres->hr_name, $1,
488 sizeof(curres->hr_name)) >=
489 sizeof(curres->hr_name)) {
490 pjdlog_error("Resource name is too long.");
497 return (1);
498 }
499 if (strlcpy(curres->hr_name, $1,
500 sizeof(curres->hr_name)) >=
501 sizeof(curres->hr_name)) {
502 pjdlog_error("Resource name is too long.");
503 free($1);
491 return (1);
492 }
504 return (1);
505 }
506 free($1);
493 curres->hr_role = HAST_ROLE_INIT;
494 curres->hr_previous_role = HAST_ROLE_INIT;
495 curres->hr_replication = -1;
496 curres->hr_timeout = -1;
497 curres->hr_exec[0] = '\0';
498 curres->hr_provname[0] = '\0';
499 curres->hr_localpath[0] = '\0';
500 curres->hr_localfd = -1;

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

525name_statement: NAME STR
526 {
527 switch (depth) {
528 case 1:
529 if (strlcpy(depth1_provname, $2,
530 sizeof(depth1_provname)) >=
531 sizeof(depth1_provname)) {
532 pjdlog_error("name argument is too long.");
507 curres->hr_role = HAST_ROLE_INIT;
508 curres->hr_previous_role = HAST_ROLE_INIT;
509 curres->hr_replication = -1;
510 curres->hr_timeout = -1;
511 curres->hr_exec[0] = '\0';
512 curres->hr_provname[0] = '\0';
513 curres->hr_localpath[0] = '\0';
514 curres->hr_localfd = -1;

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

539name_statement: NAME STR
540 {
541 switch (depth) {
542 case 1:
543 if (strlcpy(depth1_provname, $2,
544 sizeof(depth1_provname)) >=
545 sizeof(depth1_provname)) {
546 pjdlog_error("name argument is too long.");
547 free($2);
533 return (1);
534 }
535 break;
536 case 2:
537 if (!mynode)
538 break;
539 assert(curres != NULL);
540 if (strlcpy(curres->hr_provname, $2,
541 sizeof(curres->hr_provname)) >=
542 sizeof(curres->hr_provname)) {
543 pjdlog_error("name argument is too long.");
548 return (1);
549 }
550 break;
551 case 2:
552 if (!mynode)
553 break;
554 assert(curres != NULL);
555 if (strlcpy(curres->hr_provname, $2,
556 sizeof(curres->hr_provname)) >=
557 sizeof(curres->hr_provname)) {
558 pjdlog_error("name argument is too long.");
559 free($2);
544 return (1);
545 }
546 break;
547 default:
548 assert(!"name at wrong depth level");
549 }
560 return (1);
561 }
562 break;
563 default:
564 assert(!"name at wrong depth level");
565 }
566 free($2);
550 }
551 ;
552
553local_statement: LOCAL STR
554 {
555 switch (depth) {
556 case 1:
557 if (strlcpy(depth1_localpath, $2,
558 sizeof(depth1_localpath)) >=
559 sizeof(depth1_localpath)) {
560 pjdlog_error("local argument is too long.");
567 }
568 ;
569
570local_statement: LOCAL STR
571 {
572 switch (depth) {
573 case 1:
574 if (strlcpy(depth1_localpath, $2,
575 sizeof(depth1_localpath)) >=
576 sizeof(depth1_localpath)) {
577 pjdlog_error("local argument is too long.");
578 free($2);
561 return (1);
562 }
563 break;
564 case 2:
565 if (!mynode)
566 break;
567 assert(curres != NULL);
568 if (strlcpy(curres->hr_localpath, $2,
569 sizeof(curres->hr_localpath)) >=
570 sizeof(curres->hr_localpath)) {
571 pjdlog_error("local argument is too long.");
579 return (1);
580 }
581 break;
582 case 2:
583 if (!mynode)
584 break;
585 assert(curres != NULL);
586 if (strlcpy(curres->hr_localpath, $2,
587 sizeof(curres->hr_localpath)) >=
588 sizeof(curres->hr_localpath)) {
589 pjdlog_error("local argument is too long.");
590 free($2);
572 return (1);
573 }
574 break;
575 default:
576 assert(!"local at wrong depth level");
577 }
591 return (1);
592 }
593 break;
594 default:
595 assert(!"local at wrong depth level");
596 }
597 free($2);
578 }
579 ;
580
581resource_node_statement:ON resource_node_start OB resource_node_entries CB
582 {
583 mynode = false;
584 }
585 ;
586
587resource_node_start: STR
588 {
589 if (curres != NULL) {
590 switch (isitme($1)) {
591 case -1:
598 }
599 ;
600
601resource_node_statement:ON resource_node_start OB resource_node_entries CB
602 {
603 mynode = false;
604 }
605 ;
606
607resource_node_start: STR
608 {
609 if (curres != NULL) {
610 switch (isitme($1)) {
611 case -1:
612 free($1);
592 return (1);
593 case 0:
594 break;
595 case 1:
596 mynode = true;
597 break;
598 default:
599 assert(!"invalid isitme() return value");
600 }
601 }
613 return (1);
614 case 0:
615 break;
616 case 1:
617 mynode = true;
618 break;
619 default:
620 assert(!"invalid isitme() return value");
621 }
622 }
623 free($1);
602 }
603 ;
604
605resource_node_entries:
606 |
607 resource_node_entries resource_node_entry
608 ;
609

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

619 {
620 assert(depth == 2);
621 if (mynode) {
622 assert(curres != NULL);
623 if (strlcpy(curres->hr_remoteaddr, $2,
624 sizeof(curres->hr_remoteaddr)) >=
625 sizeof(curres->hr_remoteaddr)) {
626 pjdlog_error("remote argument is too long.");
624 }
625 ;
626
627resource_node_entries:
628 |
629 resource_node_entries resource_node_entry
630 ;
631

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

641 {
642 assert(depth == 2);
643 if (mynode) {
644 assert(curres != NULL);
645 if (strlcpy(curres->hr_remoteaddr, $2,
646 sizeof(curres->hr_remoteaddr)) >=
647 sizeof(curres->hr_remoteaddr)) {
648 pjdlog_error("remote argument is too long.");
649 free($2);
627 return (1);
628 }
629 }
650 return (1);
651 }
652 }
653 free($2);
630 }
631 ;
654 }
655 ;