Deleted Added
sdiff udiff text old ( 204076 ) new ( 207371 )
full compact
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 $
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;
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
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 }
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
174%token CONTROL LISTEN PORT REPLICATION 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 |
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
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;
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 |
408 name_statement
409 |
410 local_statement
411 |
412 resource_node_statement
413 ;
414
415name_statement: NAME STR

--- 92 unchanged lines hidden ---