Deleted Added
sdiff udiff text old ( 225784 ) new ( 225830 )
full compact
1%{
2/*-
3 * Copyright (c) 2009-2010 The FreeBSD Foundation
4 * Copyright (c) 2011 Pawel Jakub Dawidek <pawel@dawidek.net>
5 * All rights reserved.
6 *
7 * This software was developed by Pawel Jakub Dawidek under sponsorship from
8 * the FreeBSD Foundation.

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

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

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

63static char depth0_listen_tcp4[HAST_ADDRSIZE];
64static char depth0_listen_tcp6[HAST_ADDRSIZE];
65static TAILQ_HEAD(, hastd_listen) depth0_listen;
66static int depth0_replication;
67static int depth0_checksum;
68static int depth0_compression;
69static int depth0_timeout;
70static char depth0_exec[PATH_MAX];
71
72static char depth1_provname[PATH_MAX];
73static char depth1_localpath[PATH_MAX];
74
75extern void yyrestart(FILE *);
76
77static int
78isitme(const char *name)
79{
80 char buf[MAXHOSTNAMELEN];
81 char *pos;

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

192 depth0_compression = HAST_COMPRESSION_HOLE;
193 strlcpy(depth0_control, HAST_CONTROL, sizeof(depth0_control));
194 TAILQ_INIT(&depth0_listen);
195 strlcpy(depth0_listen_tcp4, HASTD_LISTEN_TCP4,
196 sizeof(depth0_listen_tcp4));
197 strlcpy(depth0_listen_tcp6, HASTD_LISTEN_TCP6,
198 sizeof(depth0_listen_tcp6));
199 depth0_exec[0] = '\0';
200
201 lconfig = calloc(1, sizeof(*lconfig));
202 if (lconfig == NULL) {
203 pjdlog_error("Unable to allocate memory for configuration.");
204 if (exitonerror)
205 exit(EX_TEMPFAIL);
206 return (NULL);
207 }

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

323 if (curres->hr_exec[0] == '\0') {
324 /*
325 * Exec is not set at resource-level.
326 * Use global or default setting.
327 */
328 strlcpy(curres->hr_exec, depth0_exec,
329 sizeof(curres->hr_exec));
330 }
331 }
332
333 return (lconfig);
334}
335
336void
337yy_config_free(struct hastd_config *config)
338{

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

350 while ((res = TAILQ_FIRST(&config->hc_resources)) != NULL) {
351 TAILQ_REMOVE(&config->hc_resources, res, hr_next);
352 free(res);
353 }
354 free(config);
355}
356%}
357
358%token CONTROL LISTEN PORT REPLICATION CHECKSUM COMPRESSION
359%token TIMEOUT EXEC EXTENTSIZE RESOURCE NAME LOCAL REMOTE SOURCE ON
360%token FULLSYNC MEMSYNC ASYNC NONE CRC32 SHA256 HOLE LZF
361%token NUM STR OB CB
362
363%type <str> remote_str
364%type <num> replication_type
365%type <num> checksum_type
366%type <num> compression_type
367
368%union
369{
370 int num;
371 char *str;
372}
373
374%token <num> NUM

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

391 checksum_statement
392 |
393 compression_statement
394 |
395 timeout_statement
396 |
397 exec_statement
398 |
399 node_statement
400 |
401 resource_statement
402 ;
403
404control_statement: CONTROL STR
405 {
406 switch (depth) {

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

580 break;
581 default:
582 PJDLOG_ABORT("exec at wrong depth level");
583 }
584 free($2);
585 }
586 ;
587
588node_statement: ON node_start OB node_entries CB
589 {
590 mynode = false;
591 }
592 ;
593
594node_start: STR
595 {

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

655 /*
656 * Path to local provider is not set at
657 * node-level, but is set at resource-level,
658 * use it.
659 */
660 strlcpy(curres->hr_localpath, depth1_localpath,
661 sizeof(curres->hr_localpath));
662 }
663
664 /*
665 * If provider name is not given, use resource name
666 * as provider name.
667 */
668 if (curres->hr_provname[0] == '\0') {
669 strlcpy(curres->hr_provname, curres->hr_name,
670 sizeof(curres->hr_provname));

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

708 }
709
710 /*
711 * Clear those, so we can tell if they were set at
712 * resource-level or not.
713 */
714 depth1_provname[0] = '\0';
715 depth1_localpath[0] = '\0';
716 hadmynode = false;
717
718 curres = calloc(1, sizeof(*curres));
719 if (curres == NULL) {
720 pjdlog_error("Unable to allocate memory for resource.");
721 free($1);
722 return (1);
723 }

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

734 curres->hr_replication = -1;
735 curres->hr_checksum = -1;
736 curres->hr_compression = -1;
737 curres->hr_timeout = -1;
738 curres->hr_exec[0] = '\0';
739 curres->hr_provname[0] = '\0';
740 curres->hr_localpath[0] = '\0';
741 curres->hr_localfd = -1;
742 curres->hr_remoteaddr[0] = '\0';
743 curres->hr_sourceaddr[0] = '\0';
744 curres->hr_ggateunit = -1;
745 }
746 ;
747
748resource_entries:
749 |

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

756 checksum_statement
757 |
758 compression_statement
759 |
760 timeout_statement
761 |
762 exec_statement
763 |
764 name_statement
765 |
766 local_statement
767 |
768 resource_node_statement
769 ;
770
771name_statement: NAME STR

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

864resource_node_entry:
865 name_statement
866 |
867 local_statement
868 |
869 remote_statement
870 |
871 source_statement
872 ;
873
874remote_statement: REMOTE remote_str
875 {
876 PJDLOG_ASSERT(depth == 2);
877 if (mynode) {
878 PJDLOG_ASSERT(curres != NULL);
879 if (strlcpy(curres->hr_remoteaddr, $2,

--- 33 unchanged lines hidden ---