2 /* $NetBSD: nsparser.y,v 1.3 1999/01/25 00:16:18 lukem Exp $ */
5 * SPDX-License-Identifier: BSD-2-Clause
7 * Copyright (c) 1997, 1998, 1999 The NetBSD Foundation, Inc.
10 * This code is derived from software contributed to The NetBSD Foundation
13 * Redistribution and use in source and binary forms, with or without
14 * modification, are permitted provided that the following conditions
16 * 1. Redistributions of source code must retain the above copyright
17 * notice, this list of conditions and the following disclaimer.
18 * 2. Redistributions in binary form must reproduce the above copyright
19 * notice, this list of conditions and the following disclaimer in the
20 * documentation and/or other materials provided with the distribution.
22 * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
23 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
24 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
25 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
26 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
27 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
28 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
29 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
30 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
31 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
32 * POSSIBILITY OF SUCH DAMAGE.
35 #include "namespace.h"
42 #include "un-namespace.h"
44 static void _nsaddsrctomap(const char *);
56 %token SUCCESS UNAVAIL NOTFOUND TRYAGAIN
57 %token RETURN CONTINUE
61 %type <mapval> Status Action
79 free((char*)curdbt.name);
81 | Database ':' Srclist NL
94 curdbt.name = yylval.str;
95 curdbt.srclist = NULL;
96 curdbt.srclistsize = 0;
108 cursrc.flags = NS_TERMINATE;
111 | STRING '[' { cursrc.flags = NS_SUCCESS; } Criteria ']'
125 if ($3) /* if action == RETURN set RETURN bit */
127 else /* else unset it */
133 : SUCCESS { $$ = NS_SUCCESS; }
134 | UNAVAIL { $$ = NS_UNAVAIL; }
135 | NOTFOUND { $$ = NS_NOTFOUND; }
136 | TRYAGAIN { $$ = NS_TRYAGAIN; }
140 : RETURN { $$ = NS_ACTION_RETURN; }
141 | CONTINUE { $$ = NS_ACTION_CONTINUE; }
147 _nsaddsrctomap(const char *elem)
150 extern int _nsyylineno;
151 extern char * _nsyytext;
153 lineno = _nsyylineno - (*_nsyytext == '\n' ? 1 : 0);
154 if (curdbt.srclistsize > 0) {
155 if (((strcasecmp(elem, NSSRC_COMPAT) == 0) &&
156 (strcasecmp(curdbt.srclist[0].name, NSSRC_CACHE) != 0)) ||
157 (strcasecmp(curdbt.srclist[0].name, NSSRC_COMPAT) == 0)) {
159 "NSSWITCH(nsparser): %s line %d: 'compat' used with sources, other than 'cache'",
160 _PATH_NS_CONF, lineno);
165 for (i = 0; i < curdbt.srclistsize; i++) {
166 if (strcasecmp(curdbt.srclist[i].name, elem) == 0) {
168 "NSSWITCH(nsparser): %s line %d: duplicate source '%s'",
169 _PATH_NS_CONF, lineno, elem);
175 _nsdbtaddsrc(&curdbt, &cursrc);