5 * The contents of this file are subject to the terms of the
6 * Common Development and Distribution License (the "License").
7 * You may not use this file except in compliance with the License.
9 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10 * or http://www.opensolaris.org/os/licensing.
11 * See the License for the specific language governing permissions
12 * and limitations under the License.
14 * When distributing Covered Code, include this CDDL HEADER in each
15 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16 * If applicable, add the following below this CDDL HEADER, with the
17 * fields enclosed by brackets "[]" replaced with your own identifying
18 * information: Portions Copyright [yyyy] [name of copyright owner]
24 * Copyright (c) 2004, 2010, Oracle and/or its affiliates. All rights reserved.
28 #pragma error_messages(off, E_BLOCK_DECL_UNUSED)
29 #pragma error_messages(off, E_EQUALITY_NOT_ASSIGNMENT)
30 #pragma error_messages(off, E_FUNC_RET_MAYBE_IGNORED2)
31 #pragma error_messages(off, E_STMT_NOT_REACHED)
37 #include "svccfg_grammar.h"
40 * We need to undefine lex's input, unput, and output macros so that references
41 * to these call the functions we provide at the end of this source file,
42 * instead of the default versions based on libc's stdio.
56 static int input(void);
57 static void unput(int);
58 static void output(int);
62 extern int yyerror(const char *);
67 * Since command tokens are only valid at the beginning of the command (or
68 * after help), we'll only return them in the INITIAL state, and report them
69 * as SCV_WORDs afterwards.
74 * The default value of lex for transitions is 2000 and it seems we reached it.
75 * So we are bumping it up!
83 <INITIAL>validate { BEGIN WORD; return (SCC_VALIDATE); }
84 <INITIAL>import { BEGIN WORD; return (SCC_IMPORT); }
85 <INITIAL>cleanup { BEGIN WORD; return (SCC_CLEANUP); }
86 <INITIAL>export { BEGIN WORD; return (SCC_EXPORT); }
87 <INITIAL>archive { BEGIN WORD; return (SCC_ARCHIVE); }
88 <INITIAL>restore { BEGIN WORD; return (SCC_RESTORE); }
89 <INITIAL>apply { BEGIN WORD; return (SCC_APPLY); }
90 <INITIAL>extract { BEGIN WORD; return (SCC_EXTRACT); }
91 <INITIAL>repository { BEGIN WORD; return (SCC_REPOSITORY); }
92 <INITIAL>inventory { BEGIN WORD; return (SCC_INVENTORY); }
93 <INITIAL>set { BEGIN WORD; return (SCC_SET); }
94 <INITIAL>end { BEGIN WORD; return (SCC_END); }
95 <INITIAL>exit { BEGIN WORD; return (SCC_END); }
96 <INITIAL>quit { BEGIN WORD; return (SCC_END); }
97 <INITIAL>help { return (SCC_HELP); }
99 <INITIAL>list { BEGIN WORD; return (SCC_LIST); }
100 <INITIAL>add { BEGIN WORD; return (SCC_ADD); }
101 <INITIAL>delete { BEGIN WORD; return (SCC_DELETE); }
102 <INITIAL>select { BEGIN WORD; return (SCC_SELECT); }
103 <INITIAL>unselect { BEGIN WORD; return (SCC_UNSELECT); }
105 <INITIAL>listpg { BEGIN WORD; return (SCC_LISTPG); }
106 <INITIAL>addpg { BEGIN WORD; return (SCC_ADDPG); }
107 <INITIAL>delpg { BEGIN WORD; return (SCC_DELPG); }
108 <INITIAL>delhash { BEGIN WORD; return (SCC_DELHASH); }
109 <INITIAL>listprop { BEGIN WORD; return (SCC_LISTPROP); }
110 <INITIAL>setprop { BEGIN WORD; return (SCC_SETPROP); }
111 <INITIAL>delprop { BEGIN WORD; return (SCC_DELPROP); }
112 <INITIAL>editprop { BEGIN WORD; return (SCC_EDITPROP); }
113 <INITIAL>describe { BEGIN WORD; return (SCC_DESCRIBE); }
114 <INITIAL>addpropvalue { BEGIN WORD; return (SCC_ADDPROPVALUE); }
115 <INITIAL>delpropvalue { BEGIN WORD; return (SCC_DELPROPVALUE); }
116 <INITIAL>setenv { BEGIN WORD; return (SCC_SETENV); }
117 <INITIAL>unsetenv { BEGIN WORD; return (SCC_UNSETENV); }
119 <INITIAL>listsnap { BEGIN WORD; return (SCC_LISTSNAP); }
120 <INITIAL>selectsnap { BEGIN WORD; return (SCC_SELECTSNAP); }
121 <INITIAL>revert { BEGIN WORD; return (SCC_REVERT); }
122 <INITIAL>refresh { BEGIN WORD; return (SCC_REFRESH); }
124 <INITIAL>delnotify { BEGIN WORD; return (SCC_DELNOTIFY); }
125 <INITIAL>listnotify { BEGIN WORD; return (SCC_LISTNOTIFY); }
126 <INITIAL>setnotify { BEGIN WORD; return (SCC_SETNOTIFY); }
129 if ((yylval.str = strdup(yytext)) == NULL) {
130 yyerror(gettext("Out of memory"));
139 * double-quoted strings start at a
140 * double-quote, include characters other than
141 * double-quote and backslash, and
142 * backslashed-characters, and end with a
149 if ((str = strdup(yytext)) == NULL) {
150 yyerror(gettext("Out of memory"));
154 /* Strip out the backslashes. */
155 for (cp = str, shift = 0; *cp != '\0'; ++cp) {
160 * This can't be null because
161 * the string always ends with
167 } else if (shift != 0)
171 /* Nullify everything after trailing quote */
172 *(cp - shift) = '\0';
179 est->sc_cmd_lineno++;
181 return (SCS_NEWLINE);
186 ">" { return SCS_REDIRECT; }
187 "=" { return SCS_EQUALS; }
188 "(" { ++parens; return SCS_LPAREN; }
189 ")" { --parens; return SCS_RPAREN; }
192 uu_die(gettext("unrecognized character %s\n"),
199 yyerror(const char *s)
207 static int saw_eof = 0;
209 int c = engine_cmd_getc(est);
212 * To ensure input is terminated, slip in a newline on EOF.
235 (void) engine_cmd_ungetc(est, c == 0 ? EOF : c);
242 engine_cmd_nputs(est, &ch, sizeof (ch));