xref: /titanic_54/usr/src/cmd/svc/svccfg/svccfg.y (revision 1f6eb0216cb17ca5fdff9563329f1dda47c8b801)
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
21db11989eSpjung  */
223eae19d9Swesolows 
23db11989eSpjung /*
24347a77f2Samaguire  * Copyright 2008 Sun Microsystems, Inc.  All rights reserved.
257c478bd9Sstevel@tonic-gate  * Use is subject to license terms.
267c478bd9Sstevel@tonic-gate  */
277c478bd9Sstevel@tonic-gate 
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
463eae19d9Swesolows %token SCC_REPOSITORY SCC_INVENTORY SCC_SET SCC_END SCC_HELP SCC_RESTORE
477c478bd9Sstevel@tonic-gate %token SCC_LIST SCC_ADD SCC_DELETE SCC_SELECT SCC_UNSELECT
4870cbfe41SPhilippe Jung %token SCC_LISTPG SCC_ADDPG SCC_DELPG SCC_DELHASH
497c478bd9Sstevel@tonic-gate %token SCC_LISTPROP SCC_SETPROP SCC_DELPROP SCC_EDITPROP
50*1f6eb021SLiane Praza %token SCC_DESCRIBE
517c478bd9Sstevel@tonic-gate %token SCC_ADDPROPVALUE SCC_DELPROPVALUE SCC_SETENV SCC_UNSETENV
52347a77f2Samaguire %token SCC_LISTSNAP SCC_SELECTSNAP SCC_REVERT SCC_REFRESH
537c478bd9Sstevel@tonic-gate %token SCS_REDIRECT SCS_NEWLINE SCS_EQUALS SCS_LPAREN SCS_RPAREN
547c478bd9Sstevel@tonic-gate %token SCV_WORD SCV_STRING
557c478bd9Sstevel@tonic-gate 
567c478bd9Sstevel@tonic-gate %type <tok> command_token
577c478bd9Sstevel@tonic-gate %type <str> SCV_WORD SCV_STRING
587c478bd9Sstevel@tonic-gate %type <str> string opt_word
597c478bd9Sstevel@tonic-gate %type <uul> string_list multiline_string_list
607c478bd9Sstevel@tonic-gate 
617c478bd9Sstevel@tonic-gate %%
627c478bd9Sstevel@tonic-gate 
637c478bd9Sstevel@tonic-gate /*
647c478bd9Sstevel@tonic-gate  * We could hoist the command terminator for all the rules up here, but then
657c478bd9Sstevel@tonic-gate  * the parser would reduce before shifting the terminator, which would require
667c478bd9Sstevel@tonic-gate  * an additional error rule (per command) to catch extra arguments.
677c478bd9Sstevel@tonic-gate  * This way requires all input to be terminated, which is done by input() in
687c478bd9Sstevel@tonic-gate  * svccfg.l.
697c478bd9Sstevel@tonic-gate  */
707c478bd9Sstevel@tonic-gate 
717c478bd9Sstevel@tonic-gate commands : command
727c478bd9Sstevel@tonic-gate 	| commands command
737c478bd9Sstevel@tonic-gate 
747c478bd9Sstevel@tonic-gate command : terminator
757c478bd9Sstevel@tonic-gate 	| validate_cmd
767c478bd9Sstevel@tonic-gate 	| import_cmd
777c478bd9Sstevel@tonic-gate 	| export_cmd
787c478bd9Sstevel@tonic-gate 	| archive_cmd
793eae19d9Swesolows 	| restore_cmd
807c478bd9Sstevel@tonic-gate 	| apply_cmd
817c478bd9Sstevel@tonic-gate 	| extract_cmd
827c478bd9Sstevel@tonic-gate 	| repository_cmd
837c478bd9Sstevel@tonic-gate 	| inventory_cmd
847c478bd9Sstevel@tonic-gate 	| set_cmd
857c478bd9Sstevel@tonic-gate 	| end_cmd
867c478bd9Sstevel@tonic-gate 	| help_cmd
877c478bd9Sstevel@tonic-gate 	| list_cmd
887c478bd9Sstevel@tonic-gate 	| add_cmd
897c478bd9Sstevel@tonic-gate 	| delete_cmd
907c478bd9Sstevel@tonic-gate 	| select_cmd
917c478bd9Sstevel@tonic-gate 	| unselect_cmd
927c478bd9Sstevel@tonic-gate 	| listpg_cmd
937c478bd9Sstevel@tonic-gate 	| addpg_cmd
947c478bd9Sstevel@tonic-gate 	| delpg_cmd
9570cbfe41SPhilippe Jung 	| delhash_cmd
967c478bd9Sstevel@tonic-gate 	| listprop_cmd
977c478bd9Sstevel@tonic-gate 	| setprop_cmd
987c478bd9Sstevel@tonic-gate 	| delprop_cmd
997c478bd9Sstevel@tonic-gate 	| editprop_cmd
100*1f6eb021SLiane Praza 	| describe_cmd
1017c478bd9Sstevel@tonic-gate 	| addpropvalue_cmd
1027c478bd9Sstevel@tonic-gate 	| delpropvalue_cmd
1037c478bd9Sstevel@tonic-gate 	| setenv_cmd
1047c478bd9Sstevel@tonic-gate 	| unsetenv_cmd
1057c478bd9Sstevel@tonic-gate 	| listsnap_cmd
1067c478bd9Sstevel@tonic-gate 	| selectsnap_cmd
1077c478bd9Sstevel@tonic-gate 	| revert_cmd
108347a77f2Samaguire 	| refresh_cmd
1097c478bd9Sstevel@tonic-gate 	| unknown_cmd
1107c478bd9Sstevel@tonic-gate 	| error terminator	{ semerr(gettext("Syntax error.\n")); }
1117c478bd9Sstevel@tonic-gate 
1127c478bd9Sstevel@tonic-gate unknown_cmd : SCV_WORD terminator
1137c478bd9Sstevel@tonic-gate 	{
1147c478bd9Sstevel@tonic-gate 		semerr(gettext("Unknown command \"%s\".\n"), $1);
1157c478bd9Sstevel@tonic-gate 		free($1);
1167c478bd9Sstevel@tonic-gate 	}
1177c478bd9Sstevel@tonic-gate 	| SCV_WORD string_list terminator
1187c478bd9Sstevel@tonic-gate 	{
1197c478bd9Sstevel@tonic-gate 		string_list_t *slp;
1207c478bd9Sstevel@tonic-gate 		void *cookie = NULL;
1217c478bd9Sstevel@tonic-gate 
1227c478bd9Sstevel@tonic-gate 		semerr(gettext("Unknown command \"%s\".\n"), $1);
1237c478bd9Sstevel@tonic-gate 
1247c478bd9Sstevel@tonic-gate 		while ((slp = uu_list_teardown($2, &cookie)) != NULL) {
1257c478bd9Sstevel@tonic-gate 			free(slp->str);
1267c478bd9Sstevel@tonic-gate 			free(slp);
1277c478bd9Sstevel@tonic-gate 		}
1287c478bd9Sstevel@tonic-gate 
1297c478bd9Sstevel@tonic-gate 		uu_list_destroy($2);
1307c478bd9Sstevel@tonic-gate 		free($1);
1317c478bd9Sstevel@tonic-gate 	}
1327c478bd9Sstevel@tonic-gate 
1337c478bd9Sstevel@tonic-gate validate_cmd : SCC_VALIDATE SCV_WORD terminator
1347c478bd9Sstevel@tonic-gate 	{
135*1f6eb021SLiane Praza 		lscf_validate($2);
1367c478bd9Sstevel@tonic-gate 		free($2);
1377c478bd9Sstevel@tonic-gate 	}
138*1f6eb021SLiane Praza 	| SCC_VALIDATE terminator { lscf_validate_fmri(NULL); }
139d3186a0eSjeanm 	| SCC_VALIDATE error terminator	{ synerr(SCC_VALIDATE); return(0); }
1407c478bd9Sstevel@tonic-gate 
1417c478bd9Sstevel@tonic-gate import_cmd : SCC_IMPORT string_list terminator
1427c478bd9Sstevel@tonic-gate 	{
1437c478bd9Sstevel@tonic-gate 		string_list_t *slp;
1447c478bd9Sstevel@tonic-gate 		void *cookie = NULL;
1457c478bd9Sstevel@tonic-gate 
146d3186a0eSjeanm 		if (engine_import($2) == -2) {
1477c478bd9Sstevel@tonic-gate 			synerr(SCC_IMPORT);
148d3186a0eSjeanm 			return(0);
149d3186a0eSjeanm 		}
1507c478bd9Sstevel@tonic-gate 
1517c478bd9Sstevel@tonic-gate 		while ((slp = uu_list_teardown($2, &cookie)) != NULL) {
1527c478bd9Sstevel@tonic-gate 			free(slp->str);
1537c478bd9Sstevel@tonic-gate 			free(slp);
1547c478bd9Sstevel@tonic-gate 		}
1557c478bd9Sstevel@tonic-gate 
1567c478bd9Sstevel@tonic-gate 		uu_list_destroy($2);
1577c478bd9Sstevel@tonic-gate 	}
158d3186a0eSjeanm 	| SCC_IMPORT error terminator	{ synerr(SCC_IMPORT); return(0); }
1597c478bd9Sstevel@tonic-gate 
1607c478bd9Sstevel@tonic-gate export_cmd : SCC_EXPORT SCV_WORD terminator
1617c478bd9Sstevel@tonic-gate 	{
1623eae19d9Swesolows 		lscf_service_export($2, NULL, 0);
1637c478bd9Sstevel@tonic-gate 		free($2);
1647c478bd9Sstevel@tonic-gate 	}
1657c478bd9Sstevel@tonic-gate 	| SCC_EXPORT SCV_WORD SCS_REDIRECT SCV_WORD terminator
1667c478bd9Sstevel@tonic-gate 	{
1673eae19d9Swesolows 		lscf_service_export($2, $4, 0);
1687c478bd9Sstevel@tonic-gate 		free($2);
1697c478bd9Sstevel@tonic-gate 		free($4);
1707c478bd9Sstevel@tonic-gate 	}
1713eae19d9Swesolows 	| SCC_EXPORT SCV_WORD SCV_WORD terminator
1723eae19d9Swesolows 	{
1733eae19d9Swesolows 		if (strcmp($2, "-a") == 0) {
1743eae19d9Swesolows 			lscf_service_export($3, NULL, SCE_ALL_VALUES);
1753eae19d9Swesolows 			free($2);
1763eae19d9Swesolows 			free($3);
1773eae19d9Swesolows 		} else {
1783eae19d9Swesolows 			synerr(SCC_EXPORT);
1793eae19d9Swesolows 			free($2);
1803eae19d9Swesolows 			free($3);
1813eae19d9Swesolows 			return (0);
1823eae19d9Swesolows 		}
1833eae19d9Swesolows 	}
1843eae19d9Swesolows 	| SCC_EXPORT SCV_WORD SCV_WORD SCS_REDIRECT SCV_WORD terminator
1853eae19d9Swesolows 	{
1863eae19d9Swesolows 		if (strcmp($2, "-a") == 0) {
1873eae19d9Swesolows 			lscf_service_export($3, $5, SCE_ALL_VALUES);
1883eae19d9Swesolows 			free($2);
1893eae19d9Swesolows 			free($3);
1903eae19d9Swesolows 			free($5);
1913eae19d9Swesolows 		} else {
1923eae19d9Swesolows 			synerr(SCC_EXPORT);
1933eae19d9Swesolows 			free($2);
1943eae19d9Swesolows 			free($3);
1953eae19d9Swesolows 			free($5);
1963eae19d9Swesolows 			return (0);
1973eae19d9Swesolows 		}
1983eae19d9Swesolows 	}
199d3186a0eSjeanm 	| SCC_EXPORT error terminator	{ synerr(SCC_EXPORT); return(0); }
2007c478bd9Sstevel@tonic-gate 
2017c478bd9Sstevel@tonic-gate archive_cmd : SCC_ARCHIVE terminator
2027c478bd9Sstevel@tonic-gate 	{
2033eae19d9Swesolows 		lscf_archive(NULL, 0);
2043eae19d9Swesolows 	}
2053eae19d9Swesolows 	| SCC_ARCHIVE SCV_WORD terminator
2063eae19d9Swesolows 	{
2073eae19d9Swesolows 		if (strcmp($2, "-a") == 0) {
2083eae19d9Swesolows 			lscf_archive(NULL, SCE_ALL_VALUES);
2093eae19d9Swesolows 			free($2);
2103eae19d9Swesolows 		} else {
2113eae19d9Swesolows 			synerr(SCC_ARCHIVE);
2123eae19d9Swesolows 			free($2);
2133eae19d9Swesolows 			return (0);
2143eae19d9Swesolows 		}
2157c478bd9Sstevel@tonic-gate 	}
2167c478bd9Sstevel@tonic-gate 	| SCC_ARCHIVE SCS_REDIRECT SCV_WORD terminator
2177c478bd9Sstevel@tonic-gate 	{
2183eae19d9Swesolows 		lscf_archive($3, 0);
2197c478bd9Sstevel@tonic-gate 		free($3);
2207c478bd9Sstevel@tonic-gate 	}
2213eae19d9Swesolows 	| SCC_ARCHIVE SCV_WORD SCS_REDIRECT SCV_WORD terminator
2223eae19d9Swesolows 	{
2233eae19d9Swesolows 		if (strcmp($2, "-a") == 0) {
2243eae19d9Swesolows 			lscf_archive($4, SCE_ALL_VALUES);
2253eae19d9Swesolows 			free($2);
2263eae19d9Swesolows 			free($4);
2273eae19d9Swesolows 		} else {
2283eae19d9Swesolows 			synerr(SCC_ARCHIVE);
2293eae19d9Swesolows 			free($2);
2303eae19d9Swesolows 			free($4);
2313eae19d9Swesolows 			return (0);
2323eae19d9Swesolows 		}
2333eae19d9Swesolows 	}
234d3186a0eSjeanm 	| SCC_ARCHIVE error terminator	{ synerr(SCC_ARCHIVE); return(0); }
2357c478bd9Sstevel@tonic-gate 
2363eae19d9Swesolows restore_cmd : SCC_RESTORE SCV_WORD terminator
2373eae19d9Swesolows 	{
2383eae19d9Swesolows 		(void) engine_restore($2);
2393eae19d9Swesolows 		free($2);
2403eae19d9Swesolows 	}
2413eae19d9Swesolows 	| SCC_RESTORE error terminator	{ synerr(SCC_RESTORE); return(0); }
2423eae19d9Swesolows 
2437c478bd9Sstevel@tonic-gate apply_cmd : SCC_APPLY SCV_WORD terminator
2447c478bd9Sstevel@tonic-gate 					{ (void) engine_apply($2); free($2); }
245d3186a0eSjeanm 	| SCC_APPLY error terminator	{ synerr(SCC_APPLY); return(0); }
2467c478bd9Sstevel@tonic-gate 
2477c478bd9Sstevel@tonic-gate extract_cmd: SCC_EXTRACT terminator	{ lscf_profile_extract(NULL); }
2487c478bd9Sstevel@tonic-gate 	| SCC_EXTRACT SCS_REDIRECT SCV_WORD terminator
2497c478bd9Sstevel@tonic-gate 	{
2507c478bd9Sstevel@tonic-gate 		lscf_profile_extract($3);
2517c478bd9Sstevel@tonic-gate 		free($3);
2527c478bd9Sstevel@tonic-gate 	}
253d3186a0eSjeanm 	| SCC_EXTRACT error terminator	{ synerr(SCC_EXTRACT); return(0); }
2547c478bd9Sstevel@tonic-gate 
2557c478bd9Sstevel@tonic-gate repository_cmd: SCC_REPOSITORY SCV_WORD terminator
2567c478bd9Sstevel@tonic-gate 	{
257db11989eSpjung 		if (strcmp($2, "-f") == 0) {
258db11989eSpjung 			synerr(SCC_REPOSITORY);
259db11989eSpjung 			return(0);
260db11989eSpjung 		}
261db11989eSpjung 		lscf_set_repository($2, 0);
2627c478bd9Sstevel@tonic-gate 		free($2);
2637c478bd9Sstevel@tonic-gate 	}
264db11989eSpjung 	| SCC_REPOSITORY SCV_WORD SCV_WORD terminator
265db11989eSpjung 	{
266db11989eSpjung 		if (strcmp($2, "-f") == 0) {
267db11989eSpjung 			lscf_set_repository($3, 1);
268db11989eSpjung 			free($2);
269db11989eSpjung 			free($3);
270db11989eSpjung 		} else {
271db11989eSpjung 			synerr(SCC_REPOSITORY);
272db11989eSpjung 			return(0);
273db11989eSpjung 		}
274db11989eSpjung 	}
275d3186a0eSjeanm 	| SCC_REPOSITORY error terminator   { synerr(SCC_REPOSITORY); return(0); }
2767c478bd9Sstevel@tonic-gate 
2777c478bd9Sstevel@tonic-gate inventory_cmd : SCC_INVENTORY SCV_WORD terminator
2787c478bd9Sstevel@tonic-gate 					{ lxml_inventory($2); free($2); }
279d3186a0eSjeanm 	| SCC_INVENTORY error terminator	{ synerr(SCC_INVENTORY); return(0); }
2807c478bd9Sstevel@tonic-gate 
2817c478bd9Sstevel@tonic-gate set_cmd : SCC_SET string_list terminator
2827c478bd9Sstevel@tonic-gate 	{
2837c478bd9Sstevel@tonic-gate 		string_list_t *slp;
2847c478bd9Sstevel@tonic-gate 		void *cookie = NULL;
2857c478bd9Sstevel@tonic-gate 
2867c478bd9Sstevel@tonic-gate 		(void) engine_set($2);
2877c478bd9Sstevel@tonic-gate 
2887c478bd9Sstevel@tonic-gate 		while ((slp = uu_list_teardown($2, &cookie)) != NULL) {
2897c478bd9Sstevel@tonic-gate 			free(slp->str);
2907c478bd9Sstevel@tonic-gate 			free(slp);
2917c478bd9Sstevel@tonic-gate 		}
2927c478bd9Sstevel@tonic-gate 
2937c478bd9Sstevel@tonic-gate 		uu_list_destroy($2);
2947c478bd9Sstevel@tonic-gate 	}
295d3186a0eSjeanm 	| SCC_SET error terminator		{ synerr(SCC_SET); return(0); }
2967c478bd9Sstevel@tonic-gate 
2977c478bd9Sstevel@tonic-gate end_cmd : SCC_END terminator			{ exit(0); }
298d3186a0eSjeanm 	| SCC_END error terminator		{ synerr (SCC_END); return(0); }
2997c478bd9Sstevel@tonic-gate 
3007c478bd9Sstevel@tonic-gate help_cmd : SCC_HELP terminator			{ help(0); }
3017c478bd9Sstevel@tonic-gate 	| SCC_HELP command_token terminator	{ help($2); }
302d3186a0eSjeanm 	| SCC_HELP error terminator		{ synerr(SCC_HELP); return(0); }
3037c478bd9Sstevel@tonic-gate 
3047c478bd9Sstevel@tonic-gate list_cmd : SCC_LIST opt_word terminator	{ lscf_list($2); free($2); }
305d3186a0eSjeanm 	| SCC_LIST error terminator	{ synerr(SCC_LIST); return(0); }
3067c478bd9Sstevel@tonic-gate 
3077c478bd9Sstevel@tonic-gate add_cmd : SCC_ADD SCV_WORD terminator	{ lscf_add($2); free($2); }
308d3186a0eSjeanm 	| SCC_ADD error terminator	{ synerr(SCC_ADD); return(0); }
3097c478bd9Sstevel@tonic-gate 
3107c478bd9Sstevel@tonic-gate delete_cmd : SCC_DELETE SCV_WORD terminator
3117c478bd9Sstevel@tonic-gate 					{ lscf_delete($2, 0); free($2); }
3127c478bd9Sstevel@tonic-gate 	| SCC_DELETE SCV_WORD SCV_WORD terminator
3137c478bd9Sstevel@tonic-gate 	{
3147c478bd9Sstevel@tonic-gate 		if (strcmp($2, "-f") == 0) {
3157c478bd9Sstevel@tonic-gate 			lscf_delete($3, 1);
3167c478bd9Sstevel@tonic-gate 			free($2);
3177c478bd9Sstevel@tonic-gate 			free($3);
3187c478bd9Sstevel@tonic-gate 		} else {
3197c478bd9Sstevel@tonic-gate 			synerr(SCC_DELETE);
3203eae19d9Swesolows 			free($2);
3213eae19d9Swesolows 			free($3);
322d3186a0eSjeanm 			return(0);
3237c478bd9Sstevel@tonic-gate 		}
3247c478bd9Sstevel@tonic-gate 	}
325d3186a0eSjeanm 	| SCC_DELETE error terminator	{ synerr(SCC_DELETE); return(0); }
3267c478bd9Sstevel@tonic-gate 
3277c478bd9Sstevel@tonic-gate select_cmd : SCC_SELECT SCV_WORD terminator	{ lscf_select($2); free($2); }
328d3186a0eSjeanm 	| SCC_SELECT error terminator	{ synerr(SCC_SELECT); return(0) ;}
3297c478bd9Sstevel@tonic-gate 
3307c478bd9Sstevel@tonic-gate unselect_cmd : SCC_UNSELECT terminator	{ lscf_unselect(); }
331d3186a0eSjeanm 	| SCC_UNSELECT error terminator	{ synerr(SCC_UNSELECT); return(0); }
3327c478bd9Sstevel@tonic-gate 
3337c478bd9Sstevel@tonic-gate listpg_cmd : SCC_LISTPG opt_word terminator
3347c478bd9Sstevel@tonic-gate 					{ lscf_listpg($2); free($2); }
335d3186a0eSjeanm 	| SCC_LISTPG error terminator	{ synerr(SCC_LISTPG); return(0); }
3367c478bd9Sstevel@tonic-gate 
3377c478bd9Sstevel@tonic-gate addpg_cmd : SCC_ADDPG SCV_WORD SCV_WORD opt_word terminator
3387c478bd9Sstevel@tonic-gate 	{
3397c478bd9Sstevel@tonic-gate 		(void) lscf_addpg($2, $3, $4);
3407c478bd9Sstevel@tonic-gate 		free($2);
3417c478bd9Sstevel@tonic-gate 		free($3);
3427c478bd9Sstevel@tonic-gate 		free($4);
3437c478bd9Sstevel@tonic-gate 	}
344d3186a0eSjeanm 	| SCC_ADDPG error terminator	{ synerr(SCC_ADDPG); return(0); }
3457c478bd9Sstevel@tonic-gate 
3467c478bd9Sstevel@tonic-gate delpg_cmd : SCC_DELPG SCV_WORD terminator
3477c478bd9Sstevel@tonic-gate 					{ lscf_delpg($2); free($2); }
348d3186a0eSjeanm 	| SCC_DELPG error terminator	{ synerr(SCC_DELPG); return(0); }
3497c478bd9Sstevel@tonic-gate 
35070cbfe41SPhilippe Jung delhash_cmd : SCC_DELHASH SCV_WORD terminator
35170cbfe41SPhilippe Jung 	{
35270cbfe41SPhilippe Jung 		lscf_delhash($2, 0); free($2);
35370cbfe41SPhilippe Jung 	}
35470cbfe41SPhilippe Jung 	| SCC_DELHASH SCV_WORD SCV_WORD terminator
35570cbfe41SPhilippe Jung 	{
35670cbfe41SPhilippe Jung 		if (strcmp($2, "-d") == 0) {
35770cbfe41SPhilippe Jung 			lscf_delhash($3, 1);
35870cbfe41SPhilippe Jung 			free($2);
35970cbfe41SPhilippe Jung 			free($3);
36070cbfe41SPhilippe Jung 		} else {
36170cbfe41SPhilippe Jung 			synerr(SCC_DELHASH);
36270cbfe41SPhilippe Jung 			free($2);
36370cbfe41SPhilippe Jung 			free($3);
36470cbfe41SPhilippe Jung 			return(0);
36570cbfe41SPhilippe Jung 		}
36670cbfe41SPhilippe Jung 	}
36770cbfe41SPhilippe Jung 	| SCC_DELHASH error terminator	{ synerr(SCC_DELHASH); return(0); }
36870cbfe41SPhilippe Jung 
3697c478bd9Sstevel@tonic-gate listprop_cmd : SCC_LISTPROP opt_word terminator
3707c478bd9Sstevel@tonic-gate 					{ lscf_listprop($2); free($2); }
371d3186a0eSjeanm 	| SCC_LISTPROP error terminator	{ synerr(SCC_LISTPROP); return(0); }
3727c478bd9Sstevel@tonic-gate 
3737c478bd9Sstevel@tonic-gate setprop_cmd : SCC_SETPROP SCV_WORD SCS_EQUALS string terminator
3747c478bd9Sstevel@tonic-gate 	{
3757c478bd9Sstevel@tonic-gate 		lscf_setprop($2, NULL, $4, NULL);
3767c478bd9Sstevel@tonic-gate 		free($2);
3777c478bd9Sstevel@tonic-gate 		free($4);
3787c478bd9Sstevel@tonic-gate 	}
3797c478bd9Sstevel@tonic-gate 	| SCC_SETPROP SCV_WORD SCS_EQUALS SCV_WORD string terminator
3807c478bd9Sstevel@tonic-gate 	{
3817c478bd9Sstevel@tonic-gate 		(void) lscf_setprop($2, $4, $5, NULL);
3827c478bd9Sstevel@tonic-gate 		free($2);
3837c478bd9Sstevel@tonic-gate 		free($4);
3847c478bd9Sstevel@tonic-gate 		free($5);
3857c478bd9Sstevel@tonic-gate 	}
3867c478bd9Sstevel@tonic-gate 	| SCC_SETPROP SCV_WORD SCS_EQUALS opt_word SCS_LPAREN
3877c478bd9Sstevel@tonic-gate 	      multiline_string_list SCS_RPAREN terminator
3887c478bd9Sstevel@tonic-gate 	{
3897c478bd9Sstevel@tonic-gate 		string_list_t *slp;
3907c478bd9Sstevel@tonic-gate 		void *cookie = NULL;
3917c478bd9Sstevel@tonic-gate 
3927c478bd9Sstevel@tonic-gate 		(void) lscf_setprop($2, $4, NULL, $6);
3937c478bd9Sstevel@tonic-gate 
3947c478bd9Sstevel@tonic-gate 		free($2);
3957c478bd9Sstevel@tonic-gate 		free($4);
3967c478bd9Sstevel@tonic-gate 
3977c478bd9Sstevel@tonic-gate 		while ((slp = uu_list_teardown($6, &cookie)) != NULL) {
3987c478bd9Sstevel@tonic-gate 			free(slp->str);
3997c478bd9Sstevel@tonic-gate 			free(slp);
4007c478bd9Sstevel@tonic-gate 		}
4017c478bd9Sstevel@tonic-gate 
4027c478bd9Sstevel@tonic-gate 		uu_list_destroy($6);
4037c478bd9Sstevel@tonic-gate 	}
404d3186a0eSjeanm 	| SCC_SETPROP error terminator	{ synerr(SCC_SETPROP); return(0); }
405d3186a0eSjeanm 	| SCC_SETPROP error		{ synerr(SCC_SETPROP); return(0); }
4067c478bd9Sstevel@tonic-gate 
4077c478bd9Sstevel@tonic-gate delprop_cmd : SCC_DELPROP SCV_WORD terminator
4087c478bd9Sstevel@tonic-gate 					{ lscf_delprop($2); free($2); }
409d3186a0eSjeanm 	| SCC_DELPROP error terminator	{ synerr(SCC_DELPROP); return(0); }
4107c478bd9Sstevel@tonic-gate 
4117c478bd9Sstevel@tonic-gate editprop_cmd : SCC_EDITPROP terminator	{ lscf_editprop(); }
412d3186a0eSjeanm 	| SCC_EDITPROP error terminator	{ synerr(SCC_EDITPROP); return(0); }
4137c478bd9Sstevel@tonic-gate 
414*1f6eb021SLiane Praza describe_cmd : SCC_DESCRIBE string_list terminator
415*1f6eb021SLiane Praza 	{
416*1f6eb021SLiane Praza 		string_list_t *slp;
417*1f6eb021SLiane Praza 		void *cookie = NULL;
418*1f6eb021SLiane Praza 
419*1f6eb021SLiane Praza 		if (lscf_describe($2, 1) == -2) {
420*1f6eb021SLiane Praza 			synerr(SCC_DESCRIBE);
421*1f6eb021SLiane Praza 			return(0);
422*1f6eb021SLiane Praza 		}
423*1f6eb021SLiane Praza 
424*1f6eb021SLiane Praza 		while ((slp = uu_list_teardown($2, &cookie)) != NULL) {
425*1f6eb021SLiane Praza 			free(slp->str);
426*1f6eb021SLiane Praza 			free(slp);
427*1f6eb021SLiane Praza 		}
428*1f6eb021SLiane Praza 
429*1f6eb021SLiane Praza 		uu_list_destroy($2);
430*1f6eb021SLiane Praza 	}
431*1f6eb021SLiane Praza 	| SCC_DESCRIBE terminator { lscf_describe(NULL, 0); }
432*1f6eb021SLiane Praza 	| SCC_DESCRIBE error terminator	 { synerr(SCC_DESCRIBE); return(0); }
433*1f6eb021SLiane Praza 
4347c478bd9Sstevel@tonic-gate addpropvalue_cmd : SCC_ADDPROPVALUE SCV_WORD string terminator
4357c478bd9Sstevel@tonic-gate 	{
4367c478bd9Sstevel@tonic-gate 		lscf_addpropvalue($2, NULL, $3);
4377c478bd9Sstevel@tonic-gate 		free($2);
4387c478bd9Sstevel@tonic-gate 		free($3);
4397c478bd9Sstevel@tonic-gate 	}
4407c478bd9Sstevel@tonic-gate 	| SCC_ADDPROPVALUE SCV_WORD string string terminator
4417c478bd9Sstevel@tonic-gate 	{
4427c478bd9Sstevel@tonic-gate 		(void) lscf_addpropvalue($2, $3, $4);
4437c478bd9Sstevel@tonic-gate 		free($2);
4447c478bd9Sstevel@tonic-gate 		free($3);
4457c478bd9Sstevel@tonic-gate 		free($4);
4467c478bd9Sstevel@tonic-gate 	}
447d3186a0eSjeanm 	| SCC_ADDPROPVALUE error terminator { synerr(SCC_ADDPROPVALUE); return(0); }
4487c478bd9Sstevel@tonic-gate 
4497c478bd9Sstevel@tonic-gate delpropvalue_cmd : SCC_DELPROPVALUE SCV_WORD string terminator
4507c478bd9Sstevel@tonic-gate 	{
4517c478bd9Sstevel@tonic-gate 		lscf_delpropvalue($2, $3, 0);
4527c478bd9Sstevel@tonic-gate 		free($2);
4537c478bd9Sstevel@tonic-gate 		free($3);
4547c478bd9Sstevel@tonic-gate 	}
455d3186a0eSjeanm 	| SCC_DELPROPVALUE error terminator { synerr(SCC_DELPROPVALUE); return(0); }
4567c478bd9Sstevel@tonic-gate 
4577c478bd9Sstevel@tonic-gate setenv_cmd : SCC_SETENV string_list terminator
4587c478bd9Sstevel@tonic-gate 	{
4597c478bd9Sstevel@tonic-gate 		string_list_t *slp;
4607c478bd9Sstevel@tonic-gate 		void *cookie = NULL;
4617c478bd9Sstevel@tonic-gate 
462d3186a0eSjeanm 		if (lscf_setenv($2, 0) == -2) {
4637c478bd9Sstevel@tonic-gate 			synerr(SCC_SETENV);
464d3186a0eSjeanm 			return(0);
465d3186a0eSjeanm 		}
4667c478bd9Sstevel@tonic-gate 
4677c478bd9Sstevel@tonic-gate 		while ((slp = uu_list_teardown($2, &cookie)) != NULL) {
4687c478bd9Sstevel@tonic-gate 			free(slp->str);
4697c478bd9Sstevel@tonic-gate 			free(slp);
4707c478bd9Sstevel@tonic-gate 		}
4717c478bd9Sstevel@tonic-gate 
4727c478bd9Sstevel@tonic-gate 		uu_list_destroy($2);
4737c478bd9Sstevel@tonic-gate 	}
474d3186a0eSjeanm 	| SCC_SETENV error terminator		{ synerr(SCC_SETENV); return(0); }
4757c478bd9Sstevel@tonic-gate 
4767c478bd9Sstevel@tonic-gate unsetenv_cmd : SCC_UNSETENV string_list terminator
4777c478bd9Sstevel@tonic-gate 	{
4787c478bd9Sstevel@tonic-gate 		string_list_t *slp;
4797c478bd9Sstevel@tonic-gate 		void *cookie = NULL;
4807c478bd9Sstevel@tonic-gate 
481d3186a0eSjeanm 		if (lscf_setenv($2, 1) == -2) {
4827c478bd9Sstevel@tonic-gate 			synerr(SCC_UNSETENV);
483d3186a0eSjeanm 			return(0);
484d3186a0eSjeanm 		}
4857c478bd9Sstevel@tonic-gate 
4867c478bd9Sstevel@tonic-gate 		while ((slp = uu_list_teardown($2, &cookie)) != NULL) {
4877c478bd9Sstevel@tonic-gate 			free(slp->str);
4887c478bd9Sstevel@tonic-gate 			free(slp);
4897c478bd9Sstevel@tonic-gate 		}
4907c478bd9Sstevel@tonic-gate 
4917c478bd9Sstevel@tonic-gate 		uu_list_destroy($2);
4927c478bd9Sstevel@tonic-gate 	}
493d3186a0eSjeanm 	| SCC_UNSETENV error terminator	{ synerr(SCC_UNSETENV); return(0); }
4947c478bd9Sstevel@tonic-gate 
4957c478bd9Sstevel@tonic-gate listsnap_cmd : SCC_LISTSNAP terminator	{ lscf_listsnap(); }
496d3186a0eSjeanm 	| SCC_LISTSNAP error terminator	{ synerr(SCC_LISTSNAP); return(0); }
4977c478bd9Sstevel@tonic-gate 
4987c478bd9Sstevel@tonic-gate selectsnap_cmd : SCC_SELECTSNAP opt_word terminator
4997c478bd9Sstevel@tonic-gate 					{ lscf_selectsnap($2); free($2); }
5007c478bd9Sstevel@tonic-gate 	| SCC_SELECTSNAP error terminator
501d3186a0eSjeanm 					{ synerr(SCC_SELECTSNAP); return(0); }
5027c478bd9Sstevel@tonic-gate 
5037c478bd9Sstevel@tonic-gate revert_cmd: SCC_REVERT opt_word terminator	{ lscf_revert($2); free ($2); }
504d3186a0eSjeanm 	| SCC_REVERT error terminator		{ synerr(SCC_REVERT); return(0); }
5057c478bd9Sstevel@tonic-gate 
506347a77f2Samaguire refresh_cmd: SCC_REFRESH terminator	{ lscf_refresh(); }
507347a77f2Samaguire 	| SCC_REFRESH error terminator	{ synerr(SCC_REFRESH); return(0); }
5087c478bd9Sstevel@tonic-gate 
5097c478bd9Sstevel@tonic-gate terminator : SCS_NEWLINE
5107c478bd9Sstevel@tonic-gate 
5117c478bd9Sstevel@tonic-gate string_list :
5127c478bd9Sstevel@tonic-gate 	{
5137c478bd9Sstevel@tonic-gate 		$$ = uu_list_create(string_pool, NULL, 0);
5147c478bd9Sstevel@tonic-gate 		if ($$ == NULL)
5157c478bd9Sstevel@tonic-gate 			uu_die(gettext("Out of memory\n"));
5167c478bd9Sstevel@tonic-gate 	}
5177c478bd9Sstevel@tonic-gate 	| string_list string
5187c478bd9Sstevel@tonic-gate 	{
5197c478bd9Sstevel@tonic-gate 		string_list_t *slp;
5207c478bd9Sstevel@tonic-gate 
5217c478bd9Sstevel@tonic-gate 		slp = safe_malloc(sizeof (*slp));
5227c478bd9Sstevel@tonic-gate 
5237c478bd9Sstevel@tonic-gate 		slp->str = $2;
5247c478bd9Sstevel@tonic-gate 		uu_list_node_init(slp, &slp->node, string_pool);
5257c478bd9Sstevel@tonic-gate 		uu_list_append($1, slp);
5267c478bd9Sstevel@tonic-gate 		$$ = $1;
5277c478bd9Sstevel@tonic-gate 	}
5287c478bd9Sstevel@tonic-gate 
5297c478bd9Sstevel@tonic-gate multiline_string_list : string_list
5307c478bd9Sstevel@tonic-gate 	{
5317c478bd9Sstevel@tonic-gate 		$$ = $1;
5327c478bd9Sstevel@tonic-gate 	}
5337c478bd9Sstevel@tonic-gate 	| multiline_string_list SCS_NEWLINE string_list
5347c478bd9Sstevel@tonic-gate 	{
5357c478bd9Sstevel@tonic-gate 		void *cookie = NULL;
5367c478bd9Sstevel@tonic-gate 		string_list_t *slp;
5377c478bd9Sstevel@tonic-gate 
5387c478bd9Sstevel@tonic-gate 		/* Append $3 to $1. */
5397c478bd9Sstevel@tonic-gate 		while ((slp = uu_list_teardown($3, &cookie)) != NULL)
5407c478bd9Sstevel@tonic-gate 			uu_list_append($1, slp);
5417c478bd9Sstevel@tonic-gate 
5427c478bd9Sstevel@tonic-gate 		uu_list_destroy($3);
5437c478bd9Sstevel@tonic-gate 	}
5447c478bd9Sstevel@tonic-gate 
5457c478bd9Sstevel@tonic-gate string : SCV_WORD	{ $$ = $1; }
5467c478bd9Sstevel@tonic-gate 	| SCV_STRING	{ $$ = $1; }
5477c478bd9Sstevel@tonic-gate 
5487c478bd9Sstevel@tonic-gate opt_word :		{ $$ = NULL; }
5497c478bd9Sstevel@tonic-gate 	| SCV_WORD	{ $$ = $1; }
5507c478bd9Sstevel@tonic-gate 
5517c478bd9Sstevel@tonic-gate command_token : SCC_VALIDATE	{ $$ = SCC_VALIDATE; }
5527c478bd9Sstevel@tonic-gate 	| SCC_IMPORT		{ $$ = SCC_IMPORT; }
5537c478bd9Sstevel@tonic-gate 	| SCC_EXPORT		{ $$ = SCC_EXPORT; }
5547c478bd9Sstevel@tonic-gate 	| SCC_APPLY		{ $$ = SCC_APPLY; }
5557c478bd9Sstevel@tonic-gate 	| SCC_EXTRACT		{ $$ = SCC_EXTRACT; }
5567c478bd9Sstevel@tonic-gate 	| SCC_REPOSITORY	{ $$ = SCC_REPOSITORY; }
5577c478bd9Sstevel@tonic-gate 	| SCC_ARCHIVE		{ $$ = SCC_ARCHIVE; }
5587c478bd9Sstevel@tonic-gate 	| SCC_INVENTORY		{ $$ = SCC_INVENTORY; }
5597c478bd9Sstevel@tonic-gate 	| SCC_SET		{ $$ = SCC_SET; }
5607c478bd9Sstevel@tonic-gate 	| SCC_END		{ $$ = SCC_END; }
5617c478bd9Sstevel@tonic-gate 	| SCC_HELP		{ $$ = SCC_HELP; }
5627c478bd9Sstevel@tonic-gate 	| SCC_LIST		{ $$ = SCC_LIST; }
5637c478bd9Sstevel@tonic-gate 	| SCC_ADD		{ $$ = SCC_ADD; }
5647c478bd9Sstevel@tonic-gate 	| SCC_DELETE		{ $$ = SCC_DELETE; }
5657c478bd9Sstevel@tonic-gate 	| SCC_SELECT		{ $$ = SCC_SELECT; }
5667c478bd9Sstevel@tonic-gate 	| SCC_UNSELECT		{ $$ = SCC_UNSELECT; }
5677c478bd9Sstevel@tonic-gate 	| SCC_LISTPG		{ $$ = SCC_LISTPG; }
5687c478bd9Sstevel@tonic-gate 	| SCC_ADDPG		{ $$ = SCC_ADDPG; }
5697c478bd9Sstevel@tonic-gate 	| SCC_DELPG		{ $$ = SCC_DELPG; }
57070cbfe41SPhilippe Jung 	| SCC_DELHASH		{ $$ = SCC_DELHASH; }
5717c478bd9Sstevel@tonic-gate 	| SCC_LISTPROP		{ $$ = SCC_LISTPROP; }
5727c478bd9Sstevel@tonic-gate 	| SCC_SETPROP		{ $$ = SCC_SETPROP; }
5737c478bd9Sstevel@tonic-gate 	| SCC_DELPROP		{ $$ = SCC_DELPROP; }
5747c478bd9Sstevel@tonic-gate 	| SCC_EDITPROP		{ $$ = SCC_EDITPROP; }
5757c478bd9Sstevel@tonic-gate 	| SCC_ADDPROPVALUE	{ $$ = SCC_ADDPROPVALUE; }
5767c478bd9Sstevel@tonic-gate 	| SCC_DELPROPVALUE	{ $$ = SCC_DELPROPVALUE; }
5777c478bd9Sstevel@tonic-gate 	| SCC_SETENV		{ $$ = SCC_SETENV; }
5787c478bd9Sstevel@tonic-gate 	| SCC_UNSETENV		{ $$ = SCC_UNSETENV; }
5797c478bd9Sstevel@tonic-gate 	| SCC_LISTSNAP		{ $$ = SCC_LISTSNAP; }
5807c478bd9Sstevel@tonic-gate 	| SCC_SELECTSNAP	{ $$ = SCC_SELECTSNAP; }
5817c478bd9Sstevel@tonic-gate 	| SCC_REVERT		{ $$ = SCC_REVERT; }
582347a77f2Samaguire 	| SCC_REFRESH		{ $$ = SCC_REFRESH; }
583*1f6eb021SLiane Praza 	| SCC_DESCRIBE		{ $$ = SCC_DESCRIBE; }
584