xref: /titanic_51/usr/src/cmd/svc/svccfg/svccfg.y (revision db11989eba94cf47ce5bf1b5d90354fa5855a69f)
17c478bd9Sstevel@tonic-gate %{
27c478bd9Sstevel@tonic-gate /*
37c478bd9Sstevel@tonic-gate  * CDDL HEADER START
47c478bd9Sstevel@tonic-gate  *
57c478bd9Sstevel@tonic-gate  * The contents of this file are subject to the terms of the
6d3186a0eSjeanm  * Common Development and Distribution License (the "License").
7d3186a0eSjeanm  * You may not use this file except in compliance with the License.
87c478bd9Sstevel@tonic-gate  *
97c478bd9Sstevel@tonic-gate  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
107c478bd9Sstevel@tonic-gate  * or http://www.opensolaris.org/os/licensing.
117c478bd9Sstevel@tonic-gate  * See the License for the specific language governing permissions
127c478bd9Sstevel@tonic-gate  * and limitations under the License.
137c478bd9Sstevel@tonic-gate  *
147c478bd9Sstevel@tonic-gate  * When distributing Covered Code, include this CDDL HEADER in each
157c478bd9Sstevel@tonic-gate  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
167c478bd9Sstevel@tonic-gate  * If applicable, add the following below this CDDL HEADER, with the
177c478bd9Sstevel@tonic-gate  * fields enclosed by brackets "[]" replaced with your own identifying
187c478bd9Sstevel@tonic-gate  * information: Portions Copyright [yyyy] [name of copyright owner]
197c478bd9Sstevel@tonic-gate  *
207c478bd9Sstevel@tonic-gate  * CDDL HEADER END
21*db11989eSpjung  */
22*db11989eSpjung /*
23*db11989eSpjung  * Copyright 2007 Sun Microsystems, Inc.  All rights reserved.
247c478bd9Sstevel@tonic-gate  * Use is subject to license terms.
257c478bd9Sstevel@tonic-gate  */
267c478bd9Sstevel@tonic-gate 
277c478bd9Sstevel@tonic-gate #pragma ident	"%Z%%M%	%I%	%E% SMI"
287c478bd9Sstevel@tonic-gate 
297c478bd9Sstevel@tonic-gate #include <libintl.h>
307c478bd9Sstevel@tonic-gate 
317c478bd9Sstevel@tonic-gate #include "svccfg.h"
327c478bd9Sstevel@tonic-gate 
337c478bd9Sstevel@tonic-gate uu_list_pool_t *string_pool;
347c478bd9Sstevel@tonic-gate 
357c478bd9Sstevel@tonic-gate %}
367c478bd9Sstevel@tonic-gate 
377c478bd9Sstevel@tonic-gate %union {
387c478bd9Sstevel@tonic-gate 	int tok;
397c478bd9Sstevel@tonic-gate 	char *str;
407c478bd9Sstevel@tonic-gate 	uu_list_t *uul;
417c478bd9Sstevel@tonic-gate }
427c478bd9Sstevel@tonic-gate 
437c478bd9Sstevel@tonic-gate %start commands
447c478bd9Sstevel@tonic-gate 
457c478bd9Sstevel@tonic-gate %token SCC_VALIDATE SCC_IMPORT SCC_EXPORT SCC_ARCHIVE SCC_APPLY SCC_EXTRACT
467c478bd9Sstevel@tonic-gate %token SCC_REPOSITORY SCC_INVENTORY SCC_SET SCC_END SCC_HELP
477c478bd9Sstevel@tonic-gate %token SCC_LIST SCC_ADD SCC_DELETE SCC_SELECT SCC_UNSELECT
487c478bd9Sstevel@tonic-gate %token SCC_LISTPG SCC_ADDPG SCC_DELPG
497c478bd9Sstevel@tonic-gate %token SCC_LISTPROP SCC_SETPROP SCC_DELPROP SCC_EDITPROP
507c478bd9Sstevel@tonic-gate %token SCC_ADDPROPVALUE SCC_DELPROPVALUE SCC_SETENV SCC_UNSETENV
517c478bd9Sstevel@tonic-gate %token SCC_LISTSNAP SCC_SELECTSNAP SCC_REVERT
527c478bd9Sstevel@tonic-gate %token SCS_REDIRECT SCS_NEWLINE SCS_EQUALS SCS_LPAREN SCS_RPAREN
537c478bd9Sstevel@tonic-gate %token SCV_WORD SCV_STRING
547c478bd9Sstevel@tonic-gate 
557c478bd9Sstevel@tonic-gate %type <tok> command_token
567c478bd9Sstevel@tonic-gate %type <str> SCV_WORD SCV_STRING
577c478bd9Sstevel@tonic-gate %type <str> string opt_word
587c478bd9Sstevel@tonic-gate %type <uul> string_list multiline_string_list
597c478bd9Sstevel@tonic-gate 
607c478bd9Sstevel@tonic-gate %%
617c478bd9Sstevel@tonic-gate 
627c478bd9Sstevel@tonic-gate /*
637c478bd9Sstevel@tonic-gate  * We could hoist the command terminator for all the rules up here, but then
647c478bd9Sstevel@tonic-gate  * the parser would reduce before shifting the terminator, which would require
657c478bd9Sstevel@tonic-gate  * an additional error rule (per command) to catch extra arguments.
667c478bd9Sstevel@tonic-gate  * This way requires all input to be terminated, which is done by input() in
677c478bd9Sstevel@tonic-gate  * svccfg.l.
687c478bd9Sstevel@tonic-gate  */
697c478bd9Sstevel@tonic-gate 
707c478bd9Sstevel@tonic-gate commands : command
717c478bd9Sstevel@tonic-gate 	| commands command
727c478bd9Sstevel@tonic-gate 
737c478bd9Sstevel@tonic-gate command : terminator
747c478bd9Sstevel@tonic-gate 	| validate_cmd
757c478bd9Sstevel@tonic-gate 	| import_cmd
767c478bd9Sstevel@tonic-gate 	| export_cmd
777c478bd9Sstevel@tonic-gate 	| archive_cmd
787c478bd9Sstevel@tonic-gate 	| apply_cmd
797c478bd9Sstevel@tonic-gate 	| extract_cmd
807c478bd9Sstevel@tonic-gate 	| repository_cmd
817c478bd9Sstevel@tonic-gate 	| inventory_cmd
827c478bd9Sstevel@tonic-gate 	| set_cmd
837c478bd9Sstevel@tonic-gate 	| end_cmd
847c478bd9Sstevel@tonic-gate 	| help_cmd
857c478bd9Sstevel@tonic-gate 	| list_cmd
867c478bd9Sstevel@tonic-gate 	| add_cmd
877c478bd9Sstevel@tonic-gate 	| delete_cmd
887c478bd9Sstevel@tonic-gate 	| select_cmd
897c478bd9Sstevel@tonic-gate 	| unselect_cmd
907c478bd9Sstevel@tonic-gate 	| listpg_cmd
917c478bd9Sstevel@tonic-gate 	| addpg_cmd
927c478bd9Sstevel@tonic-gate 	| delpg_cmd
937c478bd9Sstevel@tonic-gate 	| listprop_cmd
947c478bd9Sstevel@tonic-gate 	| setprop_cmd
957c478bd9Sstevel@tonic-gate 	| delprop_cmd
967c478bd9Sstevel@tonic-gate 	| editprop_cmd
977c478bd9Sstevel@tonic-gate 	| addpropvalue_cmd
987c478bd9Sstevel@tonic-gate 	| delpropvalue_cmd
997c478bd9Sstevel@tonic-gate 	| setenv_cmd
1007c478bd9Sstevel@tonic-gate 	| unsetenv_cmd
1017c478bd9Sstevel@tonic-gate 	| listsnap_cmd
1027c478bd9Sstevel@tonic-gate 	| selectsnap_cmd
1037c478bd9Sstevel@tonic-gate 	| revert_cmd
1047c478bd9Sstevel@tonic-gate 	| unknown_cmd
1057c478bd9Sstevel@tonic-gate 	| error terminator	{ semerr(gettext("Syntax error.\n")); }
1067c478bd9Sstevel@tonic-gate 
1077c478bd9Sstevel@tonic-gate unknown_cmd : SCV_WORD terminator
1087c478bd9Sstevel@tonic-gate 	{
1097c478bd9Sstevel@tonic-gate 		semerr(gettext("Unknown command \"%s\".\n"), $1);
1107c478bd9Sstevel@tonic-gate 		free($1);
1117c478bd9Sstevel@tonic-gate 	}
1127c478bd9Sstevel@tonic-gate 	| SCV_WORD string_list terminator
1137c478bd9Sstevel@tonic-gate 	{
1147c478bd9Sstevel@tonic-gate 		string_list_t *slp;
1157c478bd9Sstevel@tonic-gate 		void *cookie = NULL;
1167c478bd9Sstevel@tonic-gate 
1177c478bd9Sstevel@tonic-gate 		semerr(gettext("Unknown command \"%s\".\n"), $1);
1187c478bd9Sstevel@tonic-gate 
1197c478bd9Sstevel@tonic-gate 		while ((slp = uu_list_teardown($2, &cookie)) != NULL) {
1207c478bd9Sstevel@tonic-gate 			free(slp->str);
1217c478bd9Sstevel@tonic-gate 			free(slp);
1227c478bd9Sstevel@tonic-gate 		}
1237c478bd9Sstevel@tonic-gate 
1247c478bd9Sstevel@tonic-gate 		uu_list_destroy($2);
1257c478bd9Sstevel@tonic-gate 		free($1);
1267c478bd9Sstevel@tonic-gate 	}
1277c478bd9Sstevel@tonic-gate 
1287c478bd9Sstevel@tonic-gate validate_cmd : SCC_VALIDATE SCV_WORD terminator
1297c478bd9Sstevel@tonic-gate 	{
1307c478bd9Sstevel@tonic-gate 		bundle_t *b = internal_bundle_new();
1317c478bd9Sstevel@tonic-gate 		lxml_get_bundle_file(b, $2, 0);
1327c478bd9Sstevel@tonic-gate 		(void) internal_bundle_free(b);
1337c478bd9Sstevel@tonic-gate 		free($2);
1347c478bd9Sstevel@tonic-gate 	}
135d3186a0eSjeanm 	| SCC_VALIDATE error terminator	{ synerr(SCC_VALIDATE); return(0); }
1367c478bd9Sstevel@tonic-gate 
1377c478bd9Sstevel@tonic-gate import_cmd : SCC_IMPORT string_list terminator
1387c478bd9Sstevel@tonic-gate 	{
1397c478bd9Sstevel@tonic-gate 		string_list_t *slp;
1407c478bd9Sstevel@tonic-gate 		void *cookie = NULL;
1417c478bd9Sstevel@tonic-gate 
142d3186a0eSjeanm 		if (engine_import($2) == -2) {
1437c478bd9Sstevel@tonic-gate 			synerr(SCC_IMPORT);
144d3186a0eSjeanm 			return(0);
145d3186a0eSjeanm 		}
1467c478bd9Sstevel@tonic-gate 
1477c478bd9Sstevel@tonic-gate 		while ((slp = uu_list_teardown($2, &cookie)) != NULL) {
1487c478bd9Sstevel@tonic-gate 			free(slp->str);
1497c478bd9Sstevel@tonic-gate 			free(slp);
1507c478bd9Sstevel@tonic-gate 		}
1517c478bd9Sstevel@tonic-gate 
1527c478bd9Sstevel@tonic-gate 		uu_list_destroy($2);
1537c478bd9Sstevel@tonic-gate 	}
154d3186a0eSjeanm 	| SCC_IMPORT error terminator	{ synerr(SCC_IMPORT); return(0); }
1557c478bd9Sstevel@tonic-gate 
1567c478bd9Sstevel@tonic-gate export_cmd : SCC_EXPORT SCV_WORD terminator
1577c478bd9Sstevel@tonic-gate 	{
1587c478bd9Sstevel@tonic-gate 		lscf_service_export($2, NULL);
1597c478bd9Sstevel@tonic-gate 		free($2);
1607c478bd9Sstevel@tonic-gate 	}
1617c478bd9Sstevel@tonic-gate 	| SCC_EXPORT SCV_WORD SCS_REDIRECT SCV_WORD terminator
1627c478bd9Sstevel@tonic-gate 	{
1637c478bd9Sstevel@tonic-gate 		lscf_service_export($2, $4);
1647c478bd9Sstevel@tonic-gate 		free($2);
1657c478bd9Sstevel@tonic-gate 		free($4);
1667c478bd9Sstevel@tonic-gate 	}
167d3186a0eSjeanm 	| SCC_EXPORT error terminator	{ synerr(SCC_EXPORT); return(0); }
1687c478bd9Sstevel@tonic-gate 
1697c478bd9Sstevel@tonic-gate archive_cmd : SCC_ARCHIVE terminator
1707c478bd9Sstevel@tonic-gate 	{
1717c478bd9Sstevel@tonic-gate 		lscf_archive(NULL);
1727c478bd9Sstevel@tonic-gate 	}
1737c478bd9Sstevel@tonic-gate 	| SCC_ARCHIVE SCS_REDIRECT SCV_WORD terminator
1747c478bd9Sstevel@tonic-gate 	{
1757c478bd9Sstevel@tonic-gate 		lscf_archive($3);
1767c478bd9Sstevel@tonic-gate 		free($3);
1777c478bd9Sstevel@tonic-gate 	}
178d3186a0eSjeanm 	| SCC_ARCHIVE error terminator	{ synerr(SCC_ARCHIVE); return(0); }
1797c478bd9Sstevel@tonic-gate 
1807c478bd9Sstevel@tonic-gate apply_cmd : SCC_APPLY SCV_WORD terminator
1817c478bd9Sstevel@tonic-gate 					{ (void) engine_apply($2); free($2); }
182d3186a0eSjeanm 	| SCC_APPLY error terminator	{ synerr(SCC_APPLY); return(0); }
1837c478bd9Sstevel@tonic-gate 
1847c478bd9Sstevel@tonic-gate extract_cmd: SCC_EXTRACT terminator	{ lscf_profile_extract(NULL); }
1857c478bd9Sstevel@tonic-gate 	| SCC_EXTRACT SCS_REDIRECT SCV_WORD terminator
1867c478bd9Sstevel@tonic-gate 	{
1877c478bd9Sstevel@tonic-gate 		lscf_profile_extract($3);
1887c478bd9Sstevel@tonic-gate 		free($3);
1897c478bd9Sstevel@tonic-gate 	}
190d3186a0eSjeanm 	| SCC_EXTRACT error terminator	{ synerr(SCC_EXTRACT); return(0); }
1917c478bd9Sstevel@tonic-gate 
1927c478bd9Sstevel@tonic-gate repository_cmd: SCC_REPOSITORY SCV_WORD terminator
1937c478bd9Sstevel@tonic-gate 	{
194*db11989eSpjung 		if (strcmp($2, "-f") == 0) {
195*db11989eSpjung 			synerr(SCC_REPOSITORY);
196*db11989eSpjung 			return(0);
197*db11989eSpjung 		}
198*db11989eSpjung 		lscf_set_repository($2, 0);
1997c478bd9Sstevel@tonic-gate 		free($2);
2007c478bd9Sstevel@tonic-gate 	}
201*db11989eSpjung 	| SCC_REPOSITORY SCV_WORD SCV_WORD terminator
202*db11989eSpjung 	{
203*db11989eSpjung 		if (strcmp($2, "-f") == 0) {
204*db11989eSpjung 			lscf_set_repository($3, 1);
205*db11989eSpjung 			free($2);
206*db11989eSpjung 			free($3);
207*db11989eSpjung 		} else {
208*db11989eSpjung 			synerr(SCC_REPOSITORY);
209*db11989eSpjung 			return(0);
210*db11989eSpjung 		}
211*db11989eSpjung 	}
212d3186a0eSjeanm 	| SCC_REPOSITORY error terminator   { synerr(SCC_REPOSITORY); return(0); }
2137c478bd9Sstevel@tonic-gate 
2147c478bd9Sstevel@tonic-gate inventory_cmd : SCC_INVENTORY SCV_WORD terminator
2157c478bd9Sstevel@tonic-gate 					{ lxml_inventory($2); free($2); }
216d3186a0eSjeanm 	| SCC_INVENTORY error terminator	{ synerr(SCC_INVENTORY); return(0); }
2177c478bd9Sstevel@tonic-gate 
2187c478bd9Sstevel@tonic-gate set_cmd : SCC_SET string_list terminator
2197c478bd9Sstevel@tonic-gate 	{
2207c478bd9Sstevel@tonic-gate 		string_list_t *slp;
2217c478bd9Sstevel@tonic-gate 		void *cookie = NULL;
2227c478bd9Sstevel@tonic-gate 
2237c478bd9Sstevel@tonic-gate 		(void) engine_set($2);
2247c478bd9Sstevel@tonic-gate 
2257c478bd9Sstevel@tonic-gate 		while ((slp = uu_list_teardown($2, &cookie)) != NULL) {
2267c478bd9Sstevel@tonic-gate 			free(slp->str);
2277c478bd9Sstevel@tonic-gate 			free(slp);
2287c478bd9Sstevel@tonic-gate 		}
2297c478bd9Sstevel@tonic-gate 
2307c478bd9Sstevel@tonic-gate 		uu_list_destroy($2);
2317c478bd9Sstevel@tonic-gate 	}
232d3186a0eSjeanm 	| SCC_SET error terminator		{ synerr(SCC_SET); return(0); }
2337c478bd9Sstevel@tonic-gate 
2347c478bd9Sstevel@tonic-gate end_cmd : SCC_END terminator			{ exit(0); }
235d3186a0eSjeanm 	| SCC_END error terminator		{ synerr (SCC_END); return(0); }
2367c478bd9Sstevel@tonic-gate 
2377c478bd9Sstevel@tonic-gate help_cmd : SCC_HELP terminator			{ help(0); }
2387c478bd9Sstevel@tonic-gate 	| SCC_HELP command_token terminator	{ help($2); }
239d3186a0eSjeanm 	| SCC_HELP error terminator		{ synerr(SCC_HELP); return(0); }
2407c478bd9Sstevel@tonic-gate 
2417c478bd9Sstevel@tonic-gate list_cmd : SCC_LIST opt_word terminator	{ lscf_list($2); free($2); }
242d3186a0eSjeanm 	| SCC_LIST error terminator	{ synerr(SCC_LIST); return(0); }
2437c478bd9Sstevel@tonic-gate 
2447c478bd9Sstevel@tonic-gate add_cmd : SCC_ADD SCV_WORD terminator	{ lscf_add($2); free($2); }
245d3186a0eSjeanm 	| SCC_ADD error terminator	{ synerr(SCC_ADD); return(0); }
2467c478bd9Sstevel@tonic-gate 
2477c478bd9Sstevel@tonic-gate delete_cmd : SCC_DELETE SCV_WORD terminator
2487c478bd9Sstevel@tonic-gate 					{ lscf_delete($2, 0); free($2); }
2497c478bd9Sstevel@tonic-gate 	| SCC_DELETE SCV_WORD SCV_WORD terminator
2507c478bd9Sstevel@tonic-gate 	{
2517c478bd9Sstevel@tonic-gate 		if (strcmp($2, "-f") == 0) {
2527c478bd9Sstevel@tonic-gate 			lscf_delete($3, 1);
2537c478bd9Sstevel@tonic-gate 			free($2);
2547c478bd9Sstevel@tonic-gate 			free($3);
2557c478bd9Sstevel@tonic-gate 		} else {
2567c478bd9Sstevel@tonic-gate 			synerr(SCC_DELETE);
257d3186a0eSjeanm 			return(0);
2587c478bd9Sstevel@tonic-gate 		}
2597c478bd9Sstevel@tonic-gate 	}
260d3186a0eSjeanm 	| SCC_DELETE error terminator	{ synerr(SCC_DELETE); return(0); }
2617c478bd9Sstevel@tonic-gate 
2627c478bd9Sstevel@tonic-gate select_cmd : SCC_SELECT SCV_WORD terminator	{ lscf_select($2); free($2); }
263d3186a0eSjeanm 	| SCC_SELECT error terminator	{ synerr(SCC_SELECT); return(0) ;}
2647c478bd9Sstevel@tonic-gate 
2657c478bd9Sstevel@tonic-gate unselect_cmd : SCC_UNSELECT terminator	{ lscf_unselect(); }
266d3186a0eSjeanm 	| SCC_UNSELECT error terminator	{ synerr(SCC_UNSELECT); return(0); }
2677c478bd9Sstevel@tonic-gate 
2687c478bd9Sstevel@tonic-gate listpg_cmd : SCC_LISTPG opt_word terminator
2697c478bd9Sstevel@tonic-gate 					{ lscf_listpg($2); free($2); }
270d3186a0eSjeanm 	| SCC_LISTPG error terminator	{ synerr(SCC_LISTPG); return(0); }
2717c478bd9Sstevel@tonic-gate 
2727c478bd9Sstevel@tonic-gate addpg_cmd : SCC_ADDPG SCV_WORD SCV_WORD opt_word terminator
2737c478bd9Sstevel@tonic-gate 	{
2747c478bd9Sstevel@tonic-gate 		(void) lscf_addpg($2, $3, $4);
2757c478bd9Sstevel@tonic-gate 		free($2);
2767c478bd9Sstevel@tonic-gate 		free($3);
2777c478bd9Sstevel@tonic-gate 		free($4);
2787c478bd9Sstevel@tonic-gate 	}
279d3186a0eSjeanm 	| SCC_ADDPG error terminator	{ synerr(SCC_ADDPG); return(0); }
2807c478bd9Sstevel@tonic-gate 
2817c478bd9Sstevel@tonic-gate delpg_cmd : SCC_DELPG SCV_WORD terminator
2827c478bd9Sstevel@tonic-gate 					{ lscf_delpg($2); free($2); }
283d3186a0eSjeanm 	| SCC_DELPG error terminator	{ synerr(SCC_DELPG); return(0); }
2847c478bd9Sstevel@tonic-gate 
2857c478bd9Sstevel@tonic-gate listprop_cmd : SCC_LISTPROP opt_word terminator
2867c478bd9Sstevel@tonic-gate 					{ lscf_listprop($2); free($2); }
287d3186a0eSjeanm 	| SCC_LISTPROP error terminator	{ synerr(SCC_LISTPROP); return(0); }
2887c478bd9Sstevel@tonic-gate 
2897c478bd9Sstevel@tonic-gate setprop_cmd : SCC_SETPROP SCV_WORD SCS_EQUALS string terminator
2907c478bd9Sstevel@tonic-gate 	{
2917c478bd9Sstevel@tonic-gate 		lscf_setprop($2, NULL, $4, NULL);
2927c478bd9Sstevel@tonic-gate 		free($2);
2937c478bd9Sstevel@tonic-gate 		free($4);
2947c478bd9Sstevel@tonic-gate 	}
2957c478bd9Sstevel@tonic-gate 	| SCC_SETPROP SCV_WORD SCS_EQUALS SCV_WORD string terminator
2967c478bd9Sstevel@tonic-gate 	{
2977c478bd9Sstevel@tonic-gate 		(void) lscf_setprop($2, $4, $5, NULL);
2987c478bd9Sstevel@tonic-gate 		free($2);
2997c478bd9Sstevel@tonic-gate 		free($4);
3007c478bd9Sstevel@tonic-gate 		free($5);
3017c478bd9Sstevel@tonic-gate 	}
3027c478bd9Sstevel@tonic-gate 	| SCC_SETPROP SCV_WORD SCS_EQUALS opt_word SCS_LPAREN
3037c478bd9Sstevel@tonic-gate 	      multiline_string_list SCS_RPAREN terminator
3047c478bd9Sstevel@tonic-gate 	{
3057c478bd9Sstevel@tonic-gate 		string_list_t *slp;
3067c478bd9Sstevel@tonic-gate 		void *cookie = NULL;
3077c478bd9Sstevel@tonic-gate 
3087c478bd9Sstevel@tonic-gate 		(void) lscf_setprop($2, $4, NULL, $6);
3097c478bd9Sstevel@tonic-gate 
3107c478bd9Sstevel@tonic-gate 		free($2);
3117c478bd9Sstevel@tonic-gate 		free($4);
3127c478bd9Sstevel@tonic-gate 
3137c478bd9Sstevel@tonic-gate 		while ((slp = uu_list_teardown($6, &cookie)) != NULL) {
3147c478bd9Sstevel@tonic-gate 			free(slp->str);
3157c478bd9Sstevel@tonic-gate 			free(slp);
3167c478bd9Sstevel@tonic-gate 		}
3177c478bd9Sstevel@tonic-gate 
3187c478bd9Sstevel@tonic-gate 		uu_list_destroy($6);
3197c478bd9Sstevel@tonic-gate 	}
320d3186a0eSjeanm 	| SCC_SETPROP error terminator	{ synerr(SCC_SETPROP); return(0); }
321d3186a0eSjeanm 	| SCC_SETPROP error		{ synerr(SCC_SETPROP); return(0); }
3227c478bd9Sstevel@tonic-gate 
3237c478bd9Sstevel@tonic-gate delprop_cmd : SCC_DELPROP SCV_WORD terminator
3247c478bd9Sstevel@tonic-gate 					{ lscf_delprop($2); free($2); }
325d3186a0eSjeanm 	| SCC_DELPROP error terminator	{ synerr(SCC_DELPROP); return(0); }
3267c478bd9Sstevel@tonic-gate 
3277c478bd9Sstevel@tonic-gate editprop_cmd : SCC_EDITPROP terminator	{ lscf_editprop(); }
328d3186a0eSjeanm 	| SCC_EDITPROP error terminator	{ synerr(SCC_EDITPROP); return(0); }
3297c478bd9Sstevel@tonic-gate 
3307c478bd9Sstevel@tonic-gate addpropvalue_cmd : SCC_ADDPROPVALUE SCV_WORD string terminator
3317c478bd9Sstevel@tonic-gate 	{
3327c478bd9Sstevel@tonic-gate 		lscf_addpropvalue($2, NULL, $3);
3337c478bd9Sstevel@tonic-gate 		free($2);
3347c478bd9Sstevel@tonic-gate 		free($3);
3357c478bd9Sstevel@tonic-gate 	}
3367c478bd9Sstevel@tonic-gate 	| SCC_ADDPROPVALUE SCV_WORD string string terminator
3377c478bd9Sstevel@tonic-gate 	{
3387c478bd9Sstevel@tonic-gate 		(void) lscf_addpropvalue($2, $3, $4);
3397c478bd9Sstevel@tonic-gate 		free($2);
3407c478bd9Sstevel@tonic-gate 		free($3);
3417c478bd9Sstevel@tonic-gate 		free($4);
3427c478bd9Sstevel@tonic-gate 	}
343d3186a0eSjeanm 	| SCC_ADDPROPVALUE error terminator { synerr(SCC_ADDPROPVALUE); return(0); }
3447c478bd9Sstevel@tonic-gate 
3457c478bd9Sstevel@tonic-gate delpropvalue_cmd : SCC_DELPROPVALUE SCV_WORD string terminator
3467c478bd9Sstevel@tonic-gate 	{
3477c478bd9Sstevel@tonic-gate 		lscf_delpropvalue($2, $3, 0);
3487c478bd9Sstevel@tonic-gate 		free($2);
3497c478bd9Sstevel@tonic-gate 		free($3);
3507c478bd9Sstevel@tonic-gate 	}
351d3186a0eSjeanm 	| SCC_DELPROPVALUE error terminator { synerr(SCC_DELPROPVALUE); return(0); }
3527c478bd9Sstevel@tonic-gate 
3537c478bd9Sstevel@tonic-gate setenv_cmd : SCC_SETENV string_list terminator
3547c478bd9Sstevel@tonic-gate 	{
3557c478bd9Sstevel@tonic-gate 		string_list_t *slp;
3567c478bd9Sstevel@tonic-gate 		void *cookie = NULL;
3577c478bd9Sstevel@tonic-gate 
358d3186a0eSjeanm 		if (lscf_setenv($2, 0) == -2) {
3597c478bd9Sstevel@tonic-gate 			synerr(SCC_SETENV);
360d3186a0eSjeanm 			return(0);
361d3186a0eSjeanm 		}
3627c478bd9Sstevel@tonic-gate 
3637c478bd9Sstevel@tonic-gate 		while ((slp = uu_list_teardown($2, &cookie)) != NULL) {
3647c478bd9Sstevel@tonic-gate 			free(slp->str);
3657c478bd9Sstevel@tonic-gate 			free(slp);
3667c478bd9Sstevel@tonic-gate 		}
3677c478bd9Sstevel@tonic-gate 
3687c478bd9Sstevel@tonic-gate 		uu_list_destroy($2);
3697c478bd9Sstevel@tonic-gate 	}
370d3186a0eSjeanm 	| SCC_SETENV error terminator		{ synerr(SCC_SETENV); return(0); }
3717c478bd9Sstevel@tonic-gate 
3727c478bd9Sstevel@tonic-gate unsetenv_cmd : SCC_UNSETENV string_list terminator
3737c478bd9Sstevel@tonic-gate 	{
3747c478bd9Sstevel@tonic-gate 		string_list_t *slp;
3757c478bd9Sstevel@tonic-gate 		void *cookie = NULL;
3767c478bd9Sstevel@tonic-gate 
377d3186a0eSjeanm 		if (lscf_setenv($2, 1) == -2) {
3787c478bd9Sstevel@tonic-gate 			synerr(SCC_UNSETENV);
379d3186a0eSjeanm 			return(0);
380d3186a0eSjeanm 		}
3817c478bd9Sstevel@tonic-gate 
3827c478bd9Sstevel@tonic-gate 		while ((slp = uu_list_teardown($2, &cookie)) != NULL) {
3837c478bd9Sstevel@tonic-gate 			free(slp->str);
3847c478bd9Sstevel@tonic-gate 			free(slp);
3857c478bd9Sstevel@tonic-gate 		}
3867c478bd9Sstevel@tonic-gate 
3877c478bd9Sstevel@tonic-gate 		uu_list_destroy($2);
3887c478bd9Sstevel@tonic-gate 	}
389d3186a0eSjeanm 	| SCC_UNSETENV error terminator	{ synerr(SCC_UNSETENV); return(0); }
3907c478bd9Sstevel@tonic-gate 
3917c478bd9Sstevel@tonic-gate listsnap_cmd : SCC_LISTSNAP terminator	{ lscf_listsnap(); }
392d3186a0eSjeanm 	| SCC_LISTSNAP error terminator	{ synerr(SCC_LISTSNAP); return(0); }
3937c478bd9Sstevel@tonic-gate 
3947c478bd9Sstevel@tonic-gate selectsnap_cmd : SCC_SELECTSNAP opt_word terminator
3957c478bd9Sstevel@tonic-gate 					{ lscf_selectsnap($2); free($2); }
3967c478bd9Sstevel@tonic-gate 	| SCC_SELECTSNAP error terminator
397d3186a0eSjeanm 					{ synerr(SCC_SELECTSNAP); return(0); }
3987c478bd9Sstevel@tonic-gate 
3997c478bd9Sstevel@tonic-gate revert_cmd: SCC_REVERT opt_word terminator	{ lscf_revert($2); free ($2); }
400d3186a0eSjeanm 	| SCC_REVERT error terminator		{ synerr(SCC_REVERT); return(0); }
4017c478bd9Sstevel@tonic-gate 
4027c478bd9Sstevel@tonic-gate 
4037c478bd9Sstevel@tonic-gate terminator : SCS_NEWLINE
4047c478bd9Sstevel@tonic-gate 
4057c478bd9Sstevel@tonic-gate string_list :
4067c478bd9Sstevel@tonic-gate 	{
4077c478bd9Sstevel@tonic-gate 		$$ = uu_list_create(string_pool, NULL, 0);
4087c478bd9Sstevel@tonic-gate 		if ($$ == NULL)
4097c478bd9Sstevel@tonic-gate 			uu_die(gettext("Out of memory\n"));
4107c478bd9Sstevel@tonic-gate 	}
4117c478bd9Sstevel@tonic-gate 	| string_list string
4127c478bd9Sstevel@tonic-gate 	{
4137c478bd9Sstevel@tonic-gate 		string_list_t *slp;
4147c478bd9Sstevel@tonic-gate 
4157c478bd9Sstevel@tonic-gate 		slp = safe_malloc(sizeof (*slp));
4167c478bd9Sstevel@tonic-gate 
4177c478bd9Sstevel@tonic-gate 		slp->str = $2;
4187c478bd9Sstevel@tonic-gate 		uu_list_node_init(slp, &slp->node, string_pool);
4197c478bd9Sstevel@tonic-gate 		uu_list_append($1, slp);
4207c478bd9Sstevel@tonic-gate 		$$ = $1;
4217c478bd9Sstevel@tonic-gate 	}
4227c478bd9Sstevel@tonic-gate 
4237c478bd9Sstevel@tonic-gate multiline_string_list : string_list
4247c478bd9Sstevel@tonic-gate 	{
4257c478bd9Sstevel@tonic-gate 		$$ = $1;
4267c478bd9Sstevel@tonic-gate 	}
4277c478bd9Sstevel@tonic-gate 	| multiline_string_list SCS_NEWLINE string_list
4287c478bd9Sstevel@tonic-gate 	{
4297c478bd9Sstevel@tonic-gate 		void *cookie = NULL;
4307c478bd9Sstevel@tonic-gate 		string_list_t *slp;
4317c478bd9Sstevel@tonic-gate 
4327c478bd9Sstevel@tonic-gate 		/* Append $3 to $1. */
4337c478bd9Sstevel@tonic-gate 		while ((slp = uu_list_teardown($3, &cookie)) != NULL)
4347c478bd9Sstevel@tonic-gate 			uu_list_append($1, slp);
4357c478bd9Sstevel@tonic-gate 
4367c478bd9Sstevel@tonic-gate 		uu_list_destroy($3);
4377c478bd9Sstevel@tonic-gate 	}
4387c478bd9Sstevel@tonic-gate 
4397c478bd9Sstevel@tonic-gate string : SCV_WORD	{ $$ = $1; }
4407c478bd9Sstevel@tonic-gate 	| SCV_STRING	{ $$ = $1; }
4417c478bd9Sstevel@tonic-gate 
4427c478bd9Sstevel@tonic-gate opt_word :		{ $$ = NULL; }
4437c478bd9Sstevel@tonic-gate 	| SCV_WORD	{ $$ = $1; }
4447c478bd9Sstevel@tonic-gate 
4457c478bd9Sstevel@tonic-gate command_token : SCC_VALIDATE	{ $$ = SCC_VALIDATE; }
4467c478bd9Sstevel@tonic-gate 	| SCC_IMPORT		{ $$ = SCC_IMPORT; }
4477c478bd9Sstevel@tonic-gate 	| SCC_EXPORT		{ $$ = SCC_EXPORT; }
4487c478bd9Sstevel@tonic-gate 	| SCC_APPLY		{ $$ = SCC_APPLY; }
4497c478bd9Sstevel@tonic-gate 	| SCC_EXTRACT		{ $$ = SCC_EXTRACT; }
4507c478bd9Sstevel@tonic-gate 	| SCC_REPOSITORY	{ $$ = SCC_REPOSITORY; }
4517c478bd9Sstevel@tonic-gate 	| SCC_ARCHIVE		{ $$ = SCC_ARCHIVE; }
4527c478bd9Sstevel@tonic-gate 	| SCC_INVENTORY		{ $$ = SCC_INVENTORY; }
4537c478bd9Sstevel@tonic-gate 	| SCC_SET		{ $$ = SCC_SET; }
4547c478bd9Sstevel@tonic-gate 	| SCC_END		{ $$ = SCC_END; }
4557c478bd9Sstevel@tonic-gate 	| SCC_HELP		{ $$ = SCC_HELP; }
4567c478bd9Sstevel@tonic-gate 	| SCC_LIST		{ $$ = SCC_LIST; }
4577c478bd9Sstevel@tonic-gate 	| SCC_ADD		{ $$ = SCC_ADD; }
4587c478bd9Sstevel@tonic-gate 	| SCC_DELETE		{ $$ = SCC_DELETE; }
4597c478bd9Sstevel@tonic-gate 	| SCC_SELECT		{ $$ = SCC_SELECT; }
4607c478bd9Sstevel@tonic-gate 	| SCC_UNSELECT		{ $$ = SCC_UNSELECT; }
4617c478bd9Sstevel@tonic-gate 	| SCC_LISTPG		{ $$ = SCC_LISTPG; }
4627c478bd9Sstevel@tonic-gate 	| SCC_ADDPG		{ $$ = SCC_ADDPG; }
4637c478bd9Sstevel@tonic-gate 	| SCC_DELPG		{ $$ = SCC_DELPG; }
4647c478bd9Sstevel@tonic-gate 	| SCC_LISTPROP		{ $$ = SCC_LISTPROP; }
4657c478bd9Sstevel@tonic-gate 	| SCC_SETPROP		{ $$ = SCC_SETPROP; }
4667c478bd9Sstevel@tonic-gate 	| SCC_DELPROP		{ $$ = SCC_DELPROP; }
4677c478bd9Sstevel@tonic-gate 	| SCC_EDITPROP		{ $$ = SCC_EDITPROP; }
4687c478bd9Sstevel@tonic-gate 	| SCC_ADDPROPVALUE	{ $$ = SCC_ADDPROPVALUE; }
4697c478bd9Sstevel@tonic-gate 	| SCC_DELPROPVALUE	{ $$ = SCC_DELPROPVALUE; }
4707c478bd9Sstevel@tonic-gate 	| SCC_SETENV		{ $$ = SCC_SETENV; }
4717c478bd9Sstevel@tonic-gate 	| SCC_UNSETENV		{ $$ = SCC_UNSETENV; }
4727c478bd9Sstevel@tonic-gate 	| SCC_LISTSNAP		{ $$ = SCC_LISTSNAP; }
4737c478bd9Sstevel@tonic-gate 	| SCC_SELECTSNAP	{ $$ = SCC_SELECTSNAP; }
4747c478bd9Sstevel@tonic-gate 	| SCC_REVERT		{ $$ = SCC_REVERT; }
475