2 /* $NetBSD: nsparser.y,v 1.3 1999/01/25 00:16:18 lukem Exp $ */
5 * SPDX-License-Identifier: BSD-2-Clause-NetBSD
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 <sys/cdefs.h>
36 __FBSDID("$FreeBSD$");
38 #include "namespace.h"
45 #include "un-namespace.h"
47 static void _nsaddsrctomap(const char *);
59 %token SUCCESS UNAVAIL NOTFOUND TRYAGAIN
60 %token RETURN CONTINUE
64 %type <mapval> Status Action
82 free((char*)curdbt.name);
84 | Database ':' Srclist NL
97 curdbt.name = yylval.str;
98 curdbt.srclist = NULL;
99 curdbt.srclistsize = 0;
111 cursrc.flags = NS_TERMINATE;
114 | STRING '[' { cursrc.flags = NS_SUCCESS; } Criteria ']'
128 if ($3) /* if action == RETURN set RETURN bit */
130 else /* else unset it */
136 : SUCCESS { $$ = NS_SUCCESS; }
137 | UNAVAIL { $$ = NS_UNAVAIL; }
138 | NOTFOUND { $$ = NS_NOTFOUND; }
139 | TRYAGAIN { $$ = NS_TRYAGAIN; }
143 : RETURN { $$ = NS_ACTION_RETURN; }
144 | CONTINUE { $$ = NS_ACTION_CONTINUE; }
150 _nsaddsrctomap(const char *elem)
153 extern int _nsyylineno;
154 extern char * _nsyytext;
156 lineno = _nsyylineno - (*_nsyytext == '\n' ? 1 : 0);
157 if (curdbt.srclistsize > 0) {
158 if (((strcasecmp(elem, NSSRC_COMPAT) == 0) &&
159 (strcasecmp(curdbt.srclist[0].name, NSSRC_CACHE) != 0)) ||
160 (strcasecmp(curdbt.srclist[0].name, NSSRC_COMPAT) == 0)) {
162 "NSSWITCH(nsparser): %s line %d: 'compat' used with sources, other than 'cache'",
163 _PATH_NS_CONF, lineno);
168 for (i = 0; i < curdbt.srclistsize; i++) {
169 if (strcasecmp(curdbt.srclist[i].name, elem) == 0) {
171 "NSSWITCH(nsparser): %s line %d: duplicate source '%s'",
172 _PATH_NS_CONF, lineno, elem);
178 _nsdbtaddsrc(&curdbt, &cursrc);