Deleted Added
full compact
parse.y (219351) parse.y (219354)
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 *
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 219351 2011-03-06 22:56:14Z pjd $
31 * $FreeBSD: head/sbin/hastd/parse.y 219354 2011-03-06 23:09:33Z pjd $
32 */
33
34#include <sys/param.h> /* MAXHOSTNAMELEN */
35#include <sys/queue.h>
36#include <sys/sysctl.h>
37
38#include <arpa/inet.h>
39

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

57static struct hastd_config *lconfig;
58static struct hast_resource *curres;
59static bool mynode, hadmynode;
60
61static char depth0_control[HAST_ADDRSIZE];
62static char depth0_listen[HAST_ADDRSIZE];
63static int depth0_replication;
64static int depth0_checksum;
32 */
33
34#include <sys/param.h> /* MAXHOSTNAMELEN */
35#include <sys/queue.h>
36#include <sys/sysctl.h>
37
38#include <arpa/inet.h>
39

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

57static struct hastd_config *lconfig;
58static struct hast_resource *curres;
59static bool mynode, hadmynode;
60
61static char depth0_control[HAST_ADDRSIZE];
62static char depth0_listen[HAST_ADDRSIZE];
63static int depth0_replication;
64static int depth0_checksum;
65static int depth0_compression;
65static int depth0_timeout;
66static char depth0_exec[PATH_MAX];
67
68static char depth1_provname[PATH_MAX];
69static char depth1_localpath[PATH_MAX];
70
71extern void yyrestart(FILE *);
72

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

165 curres = NULL;
166 mynode = false;
167 depth = 0;
168 lineno = 0;
169
170 depth0_timeout = HAST_TIMEOUT;
171 depth0_replication = HAST_REPLICATION_MEMSYNC;
172 depth0_checksum = HAST_CHECKSUM_NONE;
66static int depth0_timeout;
67static char depth0_exec[PATH_MAX];
68
69static char depth1_provname[PATH_MAX];
70static char depth1_localpath[PATH_MAX];
71
72extern void yyrestart(FILE *);
73

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

166 curres = NULL;
167 mynode = false;
168 depth = 0;
169 lineno = 0;
170
171 depth0_timeout = HAST_TIMEOUT;
172 depth0_replication = HAST_REPLICATION_MEMSYNC;
173 depth0_checksum = HAST_CHECKSUM_NONE;
174 depth0_compression = HAST_COMPRESSION_HOLE;
173 strlcpy(depth0_control, HAST_CONTROL, sizeof(depth0_control));
174 strlcpy(depth0_listen, HASTD_LISTEN, sizeof(depth0_listen));
175 depth0_exec[0] = '\0';
176
177 lconfig = calloc(1, sizeof(*lconfig));
178 if (lconfig == NULL) {
179 pjdlog_error("Unable to allocate memory for configuration.");
180 if (exitonerror)

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

228 }
229 if (curres->hr_checksum == -1) {
230 /*
231 * Checksum is not set at resource-level.
232 * Use global or default setting.
233 */
234 curres->hr_checksum = depth0_checksum;
235 }
175 strlcpy(depth0_control, HAST_CONTROL, sizeof(depth0_control));
176 strlcpy(depth0_listen, HASTD_LISTEN, sizeof(depth0_listen));
177 depth0_exec[0] = '\0';
178
179 lconfig = calloc(1, sizeof(*lconfig));
180 if (lconfig == NULL) {
181 pjdlog_error("Unable to allocate memory for configuration.");
182 if (exitonerror)

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

230 }
231 if (curres->hr_checksum == -1) {
232 /*
233 * Checksum is not set at resource-level.
234 * Use global or default setting.
235 */
236 curres->hr_checksum = depth0_checksum;
237 }
238 if (curres->hr_compression == -1) {
239 /*
240 * Compression is not set at resource-level.
241 * Use global or default setting.
242 */
243 curres->hr_compression = depth0_compression;
244 }
236 if (curres->hr_timeout == -1) {
237 /*
238 * Timeout is not set at resource-level.
239 * Use global or default setting.
240 */
241 curres->hr_timeout = depth0_timeout;
242 }
243 if (curres->hr_exec[0] == '\0') {

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

261 while ((res = TAILQ_FIRST(&config->hc_resources)) != NULL) {
262 TAILQ_REMOVE(&config->hc_resources, res, hr_next);
263 free(res);
264 }
265 free(config);
266}
267%}
268
245 if (curres->hr_timeout == -1) {
246 /*
247 * Timeout is not set at resource-level.
248 * Use global or default setting.
249 */
250 curres->hr_timeout = depth0_timeout;
251 }
252 if (curres->hr_exec[0] == '\0') {

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

270 while ((res = TAILQ_FIRST(&config->hc_resources)) != NULL) {
271 TAILQ_REMOVE(&config->hc_resources, res, hr_next);
272 free(res);
273 }
274 free(config);
275}
276%}
277
269%token CONTROL LISTEN PORT REPLICATION CHECKSUM
278%token CONTROL LISTEN PORT REPLICATION CHECKSUM COMPRESSION
270%token TIMEOUT EXEC EXTENTSIZE RESOURCE NAME LOCAL REMOTE ON
279%token TIMEOUT EXEC EXTENTSIZE RESOURCE NAME LOCAL REMOTE ON
271%token FULLSYNC MEMSYNC ASYNC NONE CRC32 SHA256
280%token FULLSYNC MEMSYNC ASYNC NONE CRC32 SHA256 HOLE LZF
272%token NUM STR OB CB
273
274%type <num> replication_type
275%type <num> checksum_type
281%token NUM STR OB CB
282
283%type <num> replication_type
284%type <num> checksum_type
285%type <num> compression_type
276
277%union
278{
279 int num;
280 char *str;
281}
282
283%token <num> NUM

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

294 control_statement
295 |
296 listen_statement
297 |
298 replication_statement
299 |
300 checksum_statement
301 |
286
287%union
288{
289 int num;
290 char *str;
291}
292
293%token <num> NUM

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

304 control_statement
305 |
306 listen_statement
307 |
308 replication_statement
309 |
310 checksum_statement
311 |
312 compression_statement
313 |
302 timeout_statement
303 |
304 exec_statement
305 |
306 node_statement
307 |
308 resource_statement
309 ;

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

411checksum_type:
412 NONE { $$ = HAST_CHECKSUM_NONE; }
413 |
414 CRC32 { $$ = HAST_CHECKSUM_CRC32; }
415 |
416 SHA256 { $$ = HAST_CHECKSUM_SHA256; }
417 ;
418
314 timeout_statement
315 |
316 exec_statement
317 |
318 node_statement
319 |
320 resource_statement
321 ;

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

423checksum_type:
424 NONE { $$ = HAST_CHECKSUM_NONE; }
425 |
426 CRC32 { $$ = HAST_CHECKSUM_CRC32; }
427 |
428 SHA256 { $$ = HAST_CHECKSUM_SHA256; }
429 ;
430
431compression_statement: COMPRESSION compression_type
432 {
433 switch (depth) {
434 case 0:
435 depth0_compression = $2;
436 break;
437 case 1:
438 if (curres != NULL)
439 curres->hr_compression = $2;
440 break;
441 default:
442 assert(!"compression at wrong depth level");
443 }
444 }
445 ;
446
447compression_type:
448 NONE { $$ = HAST_COMPRESSION_NONE; }
449 |
450 HOLE { $$ = HAST_COMPRESSION_HOLE; }
451 |
452 LZF { $$ = HAST_COMPRESSION_LZF; }
453 ;
454
419timeout_statement: TIMEOUT NUM
420 {
421 switch (depth) {
422 case 0:
423 depth0_timeout = $2;
424 break;
425 case 1:
426 if (curres != NULL)

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

604 free($1);
605 return (1);
606 }
607 free($1);
608 curres->hr_role = HAST_ROLE_INIT;
609 curres->hr_previous_role = HAST_ROLE_INIT;
610 curres->hr_replication = -1;
611 curres->hr_checksum = -1;
455timeout_statement: TIMEOUT NUM
456 {
457 switch (depth) {
458 case 0:
459 depth0_timeout = $2;
460 break;
461 case 1:
462 if (curres != NULL)

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

640 free($1);
641 return (1);
642 }
643 free($1);
644 curres->hr_role = HAST_ROLE_INIT;
645 curres->hr_previous_role = HAST_ROLE_INIT;
646 curres->hr_replication = -1;
647 curres->hr_checksum = -1;
648 curres->hr_compression = -1;
612 curres->hr_timeout = -1;
613 curres->hr_exec[0] = '\0';
614 curres->hr_provname[0] = '\0';
615 curres->hr_localpath[0] = '\0';
616 curres->hr_localfd = -1;
617 curres->hr_remoteaddr[0] = '\0';
618 curres->hr_ggateunit = -1;
619 }

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

624 resource_entries resource_entry
625 ;
626
627resource_entry:
628 replication_statement
629 |
630 checksum_statement
631 |
649 curres->hr_timeout = -1;
650 curres->hr_exec[0] = '\0';
651 curres->hr_provname[0] = '\0';
652 curres->hr_localpath[0] = '\0';
653 curres->hr_localfd = -1;
654 curres->hr_remoteaddr[0] = '\0';
655 curres->hr_ggateunit = -1;
656 }

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

661 resource_entries resource_entry
662 ;
663
664resource_entry:
665 replication_statement
666 |
667 checksum_statement
668 |
669 compression_statement
670 |
632 timeout_statement
633 |
634 exec_statement
635 |
636 name_statement
637 |
638 local_statement
639 |

--- 120 unchanged lines hidden ---
671 timeout_statement
672 |
673 exec_statement
674 |
675 name_statement
676 |
677 local_statement
678 |

--- 120 unchanged lines hidden ---