xref: /onnv-gate/usr/src/cmd/svc/svccfg/svccfg.y (revision 12967:ab9ae749152f)
10Sstevel@tonic-gate %{
20Sstevel@tonic-gate /*
30Sstevel@tonic-gate  * CDDL HEADER START
40Sstevel@tonic-gate  *
50Sstevel@tonic-gate  * The contents of this file are subject to the terms of the
63179Sjeanm  * Common Development and Distribution License (the "License").
73179Sjeanm  * You may not use this file except in compliance with the License.
80Sstevel@tonic-gate  *
90Sstevel@tonic-gate  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
100Sstevel@tonic-gate  * or http://www.opensolaris.org/os/licensing.
110Sstevel@tonic-gate  * See the License for the specific language governing permissions
120Sstevel@tonic-gate  * and limitations under the License.
130Sstevel@tonic-gate  *
140Sstevel@tonic-gate  * When distributing Covered Code, include this CDDL HEADER in each
150Sstevel@tonic-gate  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
160Sstevel@tonic-gate  * If applicable, add the following below this CDDL HEADER, with the
170Sstevel@tonic-gate  * fields enclosed by brackets "[]" replaced with your own identifying
180Sstevel@tonic-gate  * information: Portions Copyright [yyyy] [name of copyright owner]
190Sstevel@tonic-gate  *
200Sstevel@tonic-gate  * CDDL HEADER END
214931Spjung  */
225040Swesolows 
234931Spjung /*
2412667SSean.Wilcox@Sun.COM  * Copyright (c) 2004, 2010, Oracle and/or its affiliates. All rights reserved.
250Sstevel@tonic-gate  */
260Sstevel@tonic-gate 
270Sstevel@tonic-gate 
280Sstevel@tonic-gate #include <libintl.h>
290Sstevel@tonic-gate 
300Sstevel@tonic-gate #include "svccfg.h"
310Sstevel@tonic-gate 
320Sstevel@tonic-gate uu_list_pool_t *string_pool;
330Sstevel@tonic-gate 
340Sstevel@tonic-gate %}
350Sstevel@tonic-gate 
360Sstevel@tonic-gate %union {
370Sstevel@tonic-gate 	int tok;
380Sstevel@tonic-gate 	char *str;
390Sstevel@tonic-gate 	uu_list_t *uul;
400Sstevel@tonic-gate }
410Sstevel@tonic-gate 
420Sstevel@tonic-gate %start commands
430Sstevel@tonic-gate 
440Sstevel@tonic-gate %token SCC_VALIDATE SCC_IMPORT SCC_EXPORT SCC_ARCHIVE SCC_APPLY SCC_EXTRACT
4511996SThomas.Whitten@Sun.COM %token SCC_CLEANUP
465040Swesolows %token SCC_REPOSITORY SCC_INVENTORY SCC_SET SCC_END SCC_HELP SCC_RESTORE
470Sstevel@tonic-gate %token SCC_LIST SCC_ADD SCC_DELETE SCC_SELECT SCC_UNSELECT
487475SPhilippe.Jung@Sun.COM %token SCC_LISTPG SCC_ADDPG SCC_DELPG SCC_DELHASH
490Sstevel@tonic-gate %token SCC_LISTPROP SCC_SETPROP SCC_DELPROP SCC_EDITPROP
507887SLiane.Praza@Sun.COM %token SCC_DESCRIBE
510Sstevel@tonic-gate %token SCC_ADDPROPVALUE SCC_DELPROPVALUE SCC_SETENV SCC_UNSETENV
525841Samaguire %token SCC_LISTSNAP SCC_SELECTSNAP SCC_REVERT SCC_REFRESH
530Sstevel@tonic-gate %token SCS_REDIRECT SCS_NEWLINE SCS_EQUALS SCS_LPAREN SCS_RPAREN
540Sstevel@tonic-gate %token SCV_WORD SCV_STRING
55*12967Sgavin.maltby@oracle.com %token SCC_DELNOTIFY SCC_SETNOTIFY SCC_LISTNOTIFY
560Sstevel@tonic-gate 
570Sstevel@tonic-gate %type <tok> command_token
580Sstevel@tonic-gate %type <str> SCV_WORD SCV_STRING
590Sstevel@tonic-gate %type <str> string opt_word
600Sstevel@tonic-gate %type <uul> string_list multiline_string_list
610Sstevel@tonic-gate 
620Sstevel@tonic-gate %%
630Sstevel@tonic-gate 
640Sstevel@tonic-gate /*
650Sstevel@tonic-gate  * We could hoist the command terminator for all the rules up here, but then
660Sstevel@tonic-gate  * the parser would reduce before shifting the terminator, which would require
670Sstevel@tonic-gate  * an additional error rule (per command) to catch extra arguments.
680Sstevel@tonic-gate  * This way requires all input to be terminated, which is done by input() in
690Sstevel@tonic-gate  * svccfg.l.
700Sstevel@tonic-gate  */
710Sstevel@tonic-gate 
720Sstevel@tonic-gate commands : command
730Sstevel@tonic-gate 	| commands command
740Sstevel@tonic-gate 
750Sstevel@tonic-gate command : terminator
760Sstevel@tonic-gate 	| validate_cmd
770Sstevel@tonic-gate 	| import_cmd
7811996SThomas.Whitten@Sun.COM 	| cleanup_cmd
790Sstevel@tonic-gate 	| export_cmd
800Sstevel@tonic-gate 	| archive_cmd
815040Swesolows 	| restore_cmd
820Sstevel@tonic-gate 	| apply_cmd
830Sstevel@tonic-gate 	| extract_cmd
840Sstevel@tonic-gate 	| repository_cmd
850Sstevel@tonic-gate 	| inventory_cmd
860Sstevel@tonic-gate 	| set_cmd
870Sstevel@tonic-gate 	| end_cmd
880Sstevel@tonic-gate 	| help_cmd
890Sstevel@tonic-gate 	| list_cmd
900Sstevel@tonic-gate 	| add_cmd
910Sstevel@tonic-gate 	| delete_cmd
920Sstevel@tonic-gate 	| select_cmd
930Sstevel@tonic-gate 	| unselect_cmd
940Sstevel@tonic-gate 	| listpg_cmd
950Sstevel@tonic-gate 	| addpg_cmd
960Sstevel@tonic-gate 	| delpg_cmd
977475SPhilippe.Jung@Sun.COM 	| delhash_cmd
980Sstevel@tonic-gate 	| listprop_cmd
990Sstevel@tonic-gate 	| setprop_cmd
1000Sstevel@tonic-gate 	| delprop_cmd
1010Sstevel@tonic-gate 	| editprop_cmd
1027887SLiane.Praza@Sun.COM 	| describe_cmd
1030Sstevel@tonic-gate 	| addpropvalue_cmd
1040Sstevel@tonic-gate 	| delpropvalue_cmd
1050Sstevel@tonic-gate 	| setenv_cmd
1060Sstevel@tonic-gate 	| unsetenv_cmd
1070Sstevel@tonic-gate 	| listsnap_cmd
1080Sstevel@tonic-gate 	| selectsnap_cmd
1090Sstevel@tonic-gate 	| revert_cmd
1105841Samaguire 	| refresh_cmd
1110Sstevel@tonic-gate 	| unknown_cmd
112*12967Sgavin.maltby@oracle.com 	| delnotify_cmd
113*12967Sgavin.maltby@oracle.com 	| listnotify_cmd
114*12967Sgavin.maltby@oracle.com 	| setnotify_cmd
1150Sstevel@tonic-gate 	| error terminator	{ semerr(gettext("Syntax error.\n")); }
1160Sstevel@tonic-gate 
1170Sstevel@tonic-gate unknown_cmd : SCV_WORD terminator
1180Sstevel@tonic-gate 	{
1190Sstevel@tonic-gate 		semerr(gettext("Unknown command \"%s\".\n"), $1);
1200Sstevel@tonic-gate 		free($1);
1210Sstevel@tonic-gate 	}
1220Sstevel@tonic-gate 	| SCV_WORD string_list terminator
1230Sstevel@tonic-gate 	{
1240Sstevel@tonic-gate 		string_list_t *slp;
1250Sstevel@tonic-gate 		void *cookie = NULL;
1260Sstevel@tonic-gate 
1270Sstevel@tonic-gate 		semerr(gettext("Unknown command \"%s\".\n"), $1);
1280Sstevel@tonic-gate 
1290Sstevel@tonic-gate 		while ((slp = uu_list_teardown($2, &cookie)) != NULL) {
1300Sstevel@tonic-gate 			free(slp->str);
1310Sstevel@tonic-gate 			free(slp);
1320Sstevel@tonic-gate 		}
1330Sstevel@tonic-gate 
1340Sstevel@tonic-gate 		uu_list_destroy($2);
1350Sstevel@tonic-gate 		free($1);
1360Sstevel@tonic-gate 	}
1370Sstevel@tonic-gate 
1380Sstevel@tonic-gate validate_cmd : SCC_VALIDATE SCV_WORD terminator
1390Sstevel@tonic-gate 	{
1407887SLiane.Praza@Sun.COM 		lscf_validate($2);
1410Sstevel@tonic-gate 		free($2);
1420Sstevel@tonic-gate 	}
1437887SLiane.Praza@Sun.COM 	| SCC_VALIDATE terminator { lscf_validate_fmri(NULL); }
1443179Sjeanm 	| SCC_VALIDATE error terminator	{ synerr(SCC_VALIDATE); return(0); }
1450Sstevel@tonic-gate 
1460Sstevel@tonic-gate import_cmd : SCC_IMPORT string_list terminator
1470Sstevel@tonic-gate 	{
1480Sstevel@tonic-gate 		string_list_t *slp;
1490Sstevel@tonic-gate 		void *cookie = NULL;
1500Sstevel@tonic-gate 
1513179Sjeanm 		if (engine_import($2) == -2) {
1520Sstevel@tonic-gate 			synerr(SCC_IMPORT);
1533179Sjeanm 			return(0);
1543179Sjeanm 		}
1550Sstevel@tonic-gate 
1560Sstevel@tonic-gate 		while ((slp = uu_list_teardown($2, &cookie)) != NULL) {
1570Sstevel@tonic-gate 			free(slp->str);
1580Sstevel@tonic-gate 			free(slp);
1590Sstevel@tonic-gate 		}
1600Sstevel@tonic-gate 
1610Sstevel@tonic-gate 		uu_list_destroy($2);
1620Sstevel@tonic-gate 	}
1633179Sjeanm 	| SCC_IMPORT error terminator	{ synerr(SCC_IMPORT); return(0); }
1640Sstevel@tonic-gate 
16511996SThomas.Whitten@Sun.COM cleanup_cmd : SCC_CLEANUP terminator
16611996SThomas.Whitten@Sun.COM 	{
16711996SThomas.Whitten@Sun.COM 		engine_cleanup(0);
16811996SThomas.Whitten@Sun.COM 	}
16911996SThomas.Whitten@Sun.COM 	| SCC_CLEANUP SCV_WORD terminator
17011996SThomas.Whitten@Sun.COM 	{
17111996SThomas.Whitten@Sun.COM 		if (strcmp($2, "-a") == 0) {
17211996SThomas.Whitten@Sun.COM 			engine_cleanup(1);
17311996SThomas.Whitten@Sun.COM 			free($2);
17411996SThomas.Whitten@Sun.COM 		} else {
17511996SThomas.Whitten@Sun.COM 			synerr(SCC_CLEANUP);
17611996SThomas.Whitten@Sun.COM 			free($2);
17711996SThomas.Whitten@Sun.COM 			return (0);
17811996SThomas.Whitten@Sun.COM 		}
17911996SThomas.Whitten@Sun.COM 	}
18011996SThomas.Whitten@Sun.COM 	| SCC_CLEANUP error terminator { synerr(SCC_CLEANUP); return(0); }
18111996SThomas.Whitten@Sun.COM 
18211996SThomas.Whitten@Sun.COM 
1830Sstevel@tonic-gate export_cmd : SCC_EXPORT SCV_WORD terminator
1840Sstevel@tonic-gate 	{
1855040Swesolows 		lscf_service_export($2, NULL, 0);
1860Sstevel@tonic-gate 		free($2);
1870Sstevel@tonic-gate 	}
1880Sstevel@tonic-gate 	| SCC_EXPORT SCV_WORD SCS_REDIRECT SCV_WORD terminator
1890Sstevel@tonic-gate 	{
1905040Swesolows 		lscf_service_export($2, $4, 0);
1910Sstevel@tonic-gate 		free($2);
1920Sstevel@tonic-gate 		free($4);
1930Sstevel@tonic-gate 	}
1945040Swesolows 	| SCC_EXPORT SCV_WORD SCV_WORD terminator
1955040Swesolows 	{
1965040Swesolows 		if (strcmp($2, "-a") == 0) {
1975040Swesolows 			lscf_service_export($3, NULL, SCE_ALL_VALUES);
1985040Swesolows 			free($2);
1995040Swesolows 			free($3);
2005040Swesolows 		} else {
2015040Swesolows 			synerr(SCC_EXPORT);
2025040Swesolows 			free($2);
2035040Swesolows 			free($3);
2045040Swesolows 			return (0);
2055040Swesolows 		}
2065040Swesolows 	}
2075040Swesolows 	| SCC_EXPORT SCV_WORD SCV_WORD SCS_REDIRECT SCV_WORD terminator
2085040Swesolows 	{
2095040Swesolows 		if (strcmp($2, "-a") == 0) {
2105040Swesolows 			lscf_service_export($3, $5, SCE_ALL_VALUES);
2115040Swesolows 			free($2);
2125040Swesolows 			free($3);
2135040Swesolows 			free($5);
2145040Swesolows 		} else {
2155040Swesolows 			synerr(SCC_EXPORT);
2165040Swesolows 			free($2);
2175040Swesolows 			free($3);
2185040Swesolows 			free($5);
2195040Swesolows 			return (0);
2205040Swesolows 		}
2215040Swesolows 	}
2223179Sjeanm 	| SCC_EXPORT error terminator	{ synerr(SCC_EXPORT); return(0); }
2230Sstevel@tonic-gate 
2240Sstevel@tonic-gate archive_cmd : SCC_ARCHIVE terminator
2250Sstevel@tonic-gate 	{
2265040Swesolows 		lscf_archive(NULL, 0);
2275040Swesolows 	}
2285040Swesolows 	| SCC_ARCHIVE SCV_WORD terminator
2295040Swesolows 	{
2305040Swesolows 		if (strcmp($2, "-a") == 0) {
2315040Swesolows 			lscf_archive(NULL, SCE_ALL_VALUES);
2325040Swesolows 			free($2);
2335040Swesolows 		} else {
2345040Swesolows 			synerr(SCC_ARCHIVE);
2355040Swesolows 			free($2);
2365040Swesolows 			return (0);
2375040Swesolows 		}
2380Sstevel@tonic-gate 	}
2390Sstevel@tonic-gate 	| SCC_ARCHIVE SCS_REDIRECT SCV_WORD terminator
2400Sstevel@tonic-gate 	{
2415040Swesolows 		lscf_archive($3, 0);
2420Sstevel@tonic-gate 		free($3);
2430Sstevel@tonic-gate 	}
2445040Swesolows 	| SCC_ARCHIVE SCV_WORD SCS_REDIRECT SCV_WORD terminator
2455040Swesolows 	{
2465040Swesolows 		if (strcmp($2, "-a") == 0) {
2475040Swesolows 			lscf_archive($4, SCE_ALL_VALUES);
2485040Swesolows 			free($2);
2495040Swesolows 			free($4);
2505040Swesolows 		} else {
2515040Swesolows 			synerr(SCC_ARCHIVE);
2525040Swesolows 			free($2);
2535040Swesolows 			free($4);
2545040Swesolows 			return (0);
2555040Swesolows 		}
2565040Swesolows 	}
2573179Sjeanm 	| SCC_ARCHIVE error terminator	{ synerr(SCC_ARCHIVE); return(0); }
2580Sstevel@tonic-gate 
2595040Swesolows restore_cmd : SCC_RESTORE SCV_WORD terminator
2605040Swesolows 	{
2615040Swesolows 		(void) engine_restore($2);
2625040Swesolows 		free($2);
2635040Swesolows 	}
2645040Swesolows 	| SCC_RESTORE error terminator	{ synerr(SCC_RESTORE); return(0); }
2655040Swesolows 
2660Sstevel@tonic-gate apply_cmd : SCC_APPLY SCV_WORD terminator
26710029SAntonello.Cruz@Sun.COM 	{
26812667SSean.Wilcox@Sun.COM 		if (engine_apply($2, 1) == -1) {
26912667SSean.Wilcox@Sun.COM 			if ((est->sc_cmd_flags & (SC_CMD_IACTIVE|SC_CMD_DONT_EXIT)) == 0)
27012667SSean.Wilcox@Sun.COM 				exit(1);
27112667SSean.Wilcox@Sun.COM 
27212667SSean.Wilcox@Sun.COM 			free($2);
27312667SSean.Wilcox@Sun.COM 			return (0);
27412667SSean.Wilcox@Sun.COM 		}
27512667SSean.Wilcox@Sun.COM 
27610029SAntonello.Cruz@Sun.COM 		free($2);
27710029SAntonello.Cruz@Sun.COM 	}
27810029SAntonello.Cruz@Sun.COM 	| SCC_APPLY SCV_WORD SCV_WORD terminator
27910029SAntonello.Cruz@Sun.COM 	{
28010029SAntonello.Cruz@Sun.COM 		if (strcmp($2, "-n") == 0) {
28110029SAntonello.Cruz@Sun.COM 			(void) engine_apply($3, 0);
28210029SAntonello.Cruz@Sun.COM 			free($2);
28310029SAntonello.Cruz@Sun.COM 			free($3);
28410029SAntonello.Cruz@Sun.COM 		} else {
28510029SAntonello.Cruz@Sun.COM 			synerr(SCC_APPLY);
28610029SAntonello.Cruz@Sun.COM 			free($2);
28710029SAntonello.Cruz@Sun.COM 			free($3);
28810029SAntonello.Cruz@Sun.COM 			return (0);
28910029SAntonello.Cruz@Sun.COM 		}
29010029SAntonello.Cruz@Sun.COM 	}
2913179Sjeanm 	| SCC_APPLY error terminator	{ synerr(SCC_APPLY); return(0); }
2920Sstevel@tonic-gate 
2930Sstevel@tonic-gate extract_cmd: SCC_EXTRACT terminator	{ lscf_profile_extract(NULL); }
2940Sstevel@tonic-gate 	| SCC_EXTRACT SCS_REDIRECT SCV_WORD terminator
2950Sstevel@tonic-gate 	{
2960Sstevel@tonic-gate 		lscf_profile_extract($3);
2970Sstevel@tonic-gate 		free($3);
2980Sstevel@tonic-gate 	}
2993179Sjeanm 	| SCC_EXTRACT error terminator	{ synerr(SCC_EXTRACT); return(0); }
3000Sstevel@tonic-gate 
3014931Spjung repository_cmd: SCC_REPOSITORY SCV_WORD terminator
3020Sstevel@tonic-gate 	{
3034931Spjung 		if (strcmp($2, "-f") == 0) {
3044931Spjung 			synerr(SCC_REPOSITORY);
3054931Spjung 			return(0);
3064931Spjung 		}
3074931Spjung 		lscf_set_repository($2, 0);
3080Sstevel@tonic-gate 		free($2);
3090Sstevel@tonic-gate 	}
3104931Spjung 	| SCC_REPOSITORY SCV_WORD SCV_WORD terminator
3114931Spjung 	{
3124931Spjung 		if (strcmp($2, "-f") == 0) {
3134931Spjung 			lscf_set_repository($3, 1);
3144931Spjung 			free($2);
3154931Spjung 			free($3);
3164931Spjung 		} else {
3174931Spjung 			synerr(SCC_REPOSITORY);
3184931Spjung 			return(0);
3194931Spjung 		}
3204931Spjung 	}
3213179Sjeanm 	| SCC_REPOSITORY error terminator   { synerr(SCC_REPOSITORY); return(0); }
3220Sstevel@tonic-gate 
3230Sstevel@tonic-gate inventory_cmd : SCC_INVENTORY SCV_WORD terminator
3240Sstevel@tonic-gate 					{ lxml_inventory($2); free($2); }
3253179Sjeanm 	| SCC_INVENTORY error terminator	{ synerr(SCC_INVENTORY); return(0); }
3260Sstevel@tonic-gate 
3270Sstevel@tonic-gate set_cmd : SCC_SET string_list terminator
3280Sstevel@tonic-gate 	{
3290Sstevel@tonic-gate 		string_list_t *slp;
3300Sstevel@tonic-gate 		void *cookie = NULL;
3310Sstevel@tonic-gate 
3320Sstevel@tonic-gate 		(void) engine_set($2);
3330Sstevel@tonic-gate 
3340Sstevel@tonic-gate 		while ((slp = uu_list_teardown($2, &cookie)) != NULL) {
3350Sstevel@tonic-gate 			free(slp->str);
3360Sstevel@tonic-gate 			free(slp);
3370Sstevel@tonic-gate 		}
3380Sstevel@tonic-gate 
3390Sstevel@tonic-gate 		uu_list_destroy($2);
3400Sstevel@tonic-gate 	}
3413179Sjeanm 	| SCC_SET error terminator		{ synerr(SCC_SET); return(0); }
3420Sstevel@tonic-gate 
3430Sstevel@tonic-gate end_cmd : SCC_END terminator			{ exit(0); }
3443179Sjeanm 	| SCC_END error terminator		{ synerr (SCC_END); return(0); }
3450Sstevel@tonic-gate 
3460Sstevel@tonic-gate help_cmd : SCC_HELP terminator			{ help(0); }
3470Sstevel@tonic-gate 	| SCC_HELP command_token terminator	{ help($2); }
3483179Sjeanm 	| SCC_HELP error terminator		{ synerr(SCC_HELP); return(0); }
3490Sstevel@tonic-gate 
3500Sstevel@tonic-gate list_cmd : SCC_LIST opt_word terminator	{ lscf_list($2); free($2); }
3513179Sjeanm 	| SCC_LIST error terminator	{ synerr(SCC_LIST); return(0); }
3520Sstevel@tonic-gate 
3530Sstevel@tonic-gate add_cmd : SCC_ADD SCV_WORD terminator	{ lscf_add($2); free($2); }
3543179Sjeanm 	| SCC_ADD error terminator	{ synerr(SCC_ADD); return(0); }
3550Sstevel@tonic-gate 
3560Sstevel@tonic-gate delete_cmd : SCC_DELETE SCV_WORD terminator
3570Sstevel@tonic-gate 					{ lscf_delete($2, 0); free($2); }
3580Sstevel@tonic-gate 	| SCC_DELETE SCV_WORD SCV_WORD terminator
3590Sstevel@tonic-gate 	{
3600Sstevel@tonic-gate 		if (strcmp($2, "-f") == 0) {
3610Sstevel@tonic-gate 			lscf_delete($3, 1);
3620Sstevel@tonic-gate 			free($2);
3630Sstevel@tonic-gate 			free($3);
3640Sstevel@tonic-gate 		} else {
3650Sstevel@tonic-gate 			synerr(SCC_DELETE);
3665040Swesolows 			free($2);
3675040Swesolows 			free($3);
3683179Sjeanm 			return(0);
3690Sstevel@tonic-gate 		}
3700Sstevel@tonic-gate 	}
3713179Sjeanm 	| SCC_DELETE error terminator	{ synerr(SCC_DELETE); return(0); }
3720Sstevel@tonic-gate 
3730Sstevel@tonic-gate select_cmd : SCC_SELECT SCV_WORD terminator	{ lscf_select($2); free($2); }
3743179Sjeanm 	| SCC_SELECT error terminator	{ synerr(SCC_SELECT); return(0) ;}
3750Sstevel@tonic-gate 
3760Sstevel@tonic-gate unselect_cmd : SCC_UNSELECT terminator	{ lscf_unselect(); }
3773179Sjeanm 	| SCC_UNSELECT error terminator	{ synerr(SCC_UNSELECT); return(0); }
3780Sstevel@tonic-gate 
3790Sstevel@tonic-gate listpg_cmd : SCC_LISTPG opt_word terminator
3800Sstevel@tonic-gate 					{ lscf_listpg($2); free($2); }
3813179Sjeanm 	| SCC_LISTPG error terminator	{ synerr(SCC_LISTPG); return(0); }
3820Sstevel@tonic-gate 
3830Sstevel@tonic-gate addpg_cmd : SCC_ADDPG SCV_WORD SCV_WORD opt_word terminator
3840Sstevel@tonic-gate 	{
3850Sstevel@tonic-gate 		(void) lscf_addpg($2, $3, $4);
3860Sstevel@tonic-gate 		free($2);
3870Sstevel@tonic-gate 		free($3);
3880Sstevel@tonic-gate 		free($4);
3890Sstevel@tonic-gate 	}
3903179Sjeanm 	| SCC_ADDPG error terminator	{ synerr(SCC_ADDPG); return(0); }
3910Sstevel@tonic-gate 
3920Sstevel@tonic-gate delpg_cmd : SCC_DELPG SCV_WORD terminator
3930Sstevel@tonic-gate 					{ lscf_delpg($2); free($2); }
3943179Sjeanm 	| SCC_DELPG error terminator	{ synerr(SCC_DELPG); return(0); }
3950Sstevel@tonic-gate 
3967475SPhilippe.Jung@Sun.COM delhash_cmd : SCC_DELHASH SCV_WORD terminator
3977475SPhilippe.Jung@Sun.COM 	{
3987475SPhilippe.Jung@Sun.COM 		lscf_delhash($2, 0); free($2);
3997475SPhilippe.Jung@Sun.COM 	}
4007475SPhilippe.Jung@Sun.COM 	| SCC_DELHASH SCV_WORD SCV_WORD terminator
4017475SPhilippe.Jung@Sun.COM 	{
4027475SPhilippe.Jung@Sun.COM 		if (strcmp($2, "-d") == 0) {
4037475SPhilippe.Jung@Sun.COM 			lscf_delhash($3, 1);
4047475SPhilippe.Jung@Sun.COM 			free($2);
4057475SPhilippe.Jung@Sun.COM 			free($3);
4067475SPhilippe.Jung@Sun.COM 		} else {
4077475SPhilippe.Jung@Sun.COM 			synerr(SCC_DELHASH);
4087475SPhilippe.Jung@Sun.COM 			free($2);
4097475SPhilippe.Jung@Sun.COM 			free($3);
4107475SPhilippe.Jung@Sun.COM 			return(0);
4117475SPhilippe.Jung@Sun.COM 		}
4127475SPhilippe.Jung@Sun.COM 	}
4137475SPhilippe.Jung@Sun.COM 	| SCC_DELHASH error terminator	{ synerr(SCC_DELHASH); return(0); }
4147475SPhilippe.Jung@Sun.COM 
4150Sstevel@tonic-gate listprop_cmd : SCC_LISTPROP opt_word terminator
4160Sstevel@tonic-gate 					{ lscf_listprop($2); free($2); }
4173179Sjeanm 	| SCC_LISTPROP error terminator	{ synerr(SCC_LISTPROP); return(0); }
4180Sstevel@tonic-gate 
4190Sstevel@tonic-gate setprop_cmd : SCC_SETPROP SCV_WORD SCS_EQUALS string terminator
4200Sstevel@tonic-gate 	{
4210Sstevel@tonic-gate 		lscf_setprop($2, NULL, $4, NULL);
4220Sstevel@tonic-gate 		free($2);
4230Sstevel@tonic-gate 		free($4);
4240Sstevel@tonic-gate 	}
4250Sstevel@tonic-gate 	| SCC_SETPROP SCV_WORD SCS_EQUALS SCV_WORD string terminator
4260Sstevel@tonic-gate 	{
4270Sstevel@tonic-gate 		(void) lscf_setprop($2, $4, $5, NULL);
4280Sstevel@tonic-gate 		free($2);
4290Sstevel@tonic-gate 		free($4);
4300Sstevel@tonic-gate 		free($5);
4310Sstevel@tonic-gate 	}
4320Sstevel@tonic-gate 	| SCC_SETPROP SCV_WORD SCS_EQUALS opt_word SCS_LPAREN
4330Sstevel@tonic-gate 	      multiline_string_list SCS_RPAREN terminator
4340Sstevel@tonic-gate 	{
4350Sstevel@tonic-gate 		string_list_t *slp;
4360Sstevel@tonic-gate 		void *cookie = NULL;
4370Sstevel@tonic-gate 
4380Sstevel@tonic-gate 		(void) lscf_setprop($2, $4, NULL, $6);
4390Sstevel@tonic-gate 
4400Sstevel@tonic-gate 		free($2);
4410Sstevel@tonic-gate 		free($4);
4420Sstevel@tonic-gate 
4430Sstevel@tonic-gate 		while ((slp = uu_list_teardown($6, &cookie)) != NULL) {
4440Sstevel@tonic-gate 			free(slp->str);
4450Sstevel@tonic-gate 			free(slp);
4460Sstevel@tonic-gate 		}
4470Sstevel@tonic-gate 
4480Sstevel@tonic-gate 		uu_list_destroy($6);
4490Sstevel@tonic-gate 	}
4503179Sjeanm 	| SCC_SETPROP error terminator	{ synerr(SCC_SETPROP); return(0); }
4513179Sjeanm 	| SCC_SETPROP error		{ synerr(SCC_SETPROP); return(0); }
4520Sstevel@tonic-gate 
4530Sstevel@tonic-gate delprop_cmd : SCC_DELPROP SCV_WORD terminator
4540Sstevel@tonic-gate 					{ lscf_delprop($2); free($2); }
4553179Sjeanm 	| SCC_DELPROP error terminator	{ synerr(SCC_DELPROP); return(0); }
4560Sstevel@tonic-gate 
4570Sstevel@tonic-gate editprop_cmd : SCC_EDITPROP terminator	{ lscf_editprop(); }
4583179Sjeanm 	| SCC_EDITPROP error terminator	{ synerr(SCC_EDITPROP); return(0); }
4590Sstevel@tonic-gate 
4607887SLiane.Praza@Sun.COM describe_cmd : SCC_DESCRIBE string_list terminator
4617887SLiane.Praza@Sun.COM 	{
4627887SLiane.Praza@Sun.COM 		string_list_t *slp;
4637887SLiane.Praza@Sun.COM 		void *cookie = NULL;
4647887SLiane.Praza@Sun.COM 
4657887SLiane.Praza@Sun.COM 		if (lscf_describe($2, 1) == -2) {
4667887SLiane.Praza@Sun.COM 			synerr(SCC_DESCRIBE);
4677887SLiane.Praza@Sun.COM 			return(0);
4687887SLiane.Praza@Sun.COM 		}
4697887SLiane.Praza@Sun.COM 
4707887SLiane.Praza@Sun.COM 		while ((slp = uu_list_teardown($2, &cookie)) != NULL) {
4717887SLiane.Praza@Sun.COM 			free(slp->str);
4727887SLiane.Praza@Sun.COM 			free(slp);
4737887SLiane.Praza@Sun.COM 		}
4747887SLiane.Praza@Sun.COM 
4757887SLiane.Praza@Sun.COM 		uu_list_destroy($2);
4767887SLiane.Praza@Sun.COM 	}
4777887SLiane.Praza@Sun.COM 	| SCC_DESCRIBE terminator { lscf_describe(NULL, 0); }
4787887SLiane.Praza@Sun.COM 	| SCC_DESCRIBE error terminator	 { synerr(SCC_DESCRIBE); return(0); }
4797887SLiane.Praza@Sun.COM 
4800Sstevel@tonic-gate addpropvalue_cmd : SCC_ADDPROPVALUE SCV_WORD string terminator
4810Sstevel@tonic-gate 	{
4820Sstevel@tonic-gate 		lscf_addpropvalue($2, NULL, $3);
4830Sstevel@tonic-gate 		free($2);
4840Sstevel@tonic-gate 		free($3);
4850Sstevel@tonic-gate 	}
4860Sstevel@tonic-gate 	| SCC_ADDPROPVALUE SCV_WORD string string terminator
4870Sstevel@tonic-gate 	{
4880Sstevel@tonic-gate 		(void) lscf_addpropvalue($2, $3, $4);
4890Sstevel@tonic-gate 		free($2);
4900Sstevel@tonic-gate 		free($3);
4910Sstevel@tonic-gate 		free($4);
4920Sstevel@tonic-gate 	}
4933179Sjeanm 	| SCC_ADDPROPVALUE error terminator { synerr(SCC_ADDPROPVALUE); return(0); }
4940Sstevel@tonic-gate 
4950Sstevel@tonic-gate delpropvalue_cmd : SCC_DELPROPVALUE SCV_WORD string terminator
4960Sstevel@tonic-gate 	{
4970Sstevel@tonic-gate 		lscf_delpropvalue($2, $3, 0);
4980Sstevel@tonic-gate 		free($2);
4990Sstevel@tonic-gate 		free($3);
5000Sstevel@tonic-gate 	}
5013179Sjeanm 	| SCC_DELPROPVALUE error terminator { synerr(SCC_DELPROPVALUE); return(0); }
5020Sstevel@tonic-gate 
5030Sstevel@tonic-gate setenv_cmd : SCC_SETENV string_list terminator
5040Sstevel@tonic-gate 	{
5050Sstevel@tonic-gate 		string_list_t *slp;
5060Sstevel@tonic-gate 		void *cookie = NULL;
5070Sstevel@tonic-gate 
5083179Sjeanm 		if (lscf_setenv($2, 0) == -2) {
5090Sstevel@tonic-gate 			synerr(SCC_SETENV);
5103179Sjeanm 			return(0);
5113179Sjeanm 		}
5120Sstevel@tonic-gate 
5130Sstevel@tonic-gate 		while ((slp = uu_list_teardown($2, &cookie)) != NULL) {
5140Sstevel@tonic-gate 			free(slp->str);
5150Sstevel@tonic-gate 			free(slp);
5160Sstevel@tonic-gate 		}
5170Sstevel@tonic-gate 
5180Sstevel@tonic-gate 		uu_list_destroy($2);
5190Sstevel@tonic-gate 	}
5203179Sjeanm 	| SCC_SETENV error terminator		{ synerr(SCC_SETENV); return(0); }
5210Sstevel@tonic-gate 
5220Sstevel@tonic-gate unsetenv_cmd : SCC_UNSETENV string_list terminator
5230Sstevel@tonic-gate 	{
5240Sstevel@tonic-gate 		string_list_t *slp;
5250Sstevel@tonic-gate 		void *cookie = NULL;
5260Sstevel@tonic-gate 
5273179Sjeanm 		if (lscf_setenv($2, 1) == -2) {
5280Sstevel@tonic-gate 			synerr(SCC_UNSETENV);
5293179Sjeanm 			return(0);
5303179Sjeanm 		}
5310Sstevel@tonic-gate 
5320Sstevel@tonic-gate 		while ((slp = uu_list_teardown($2, &cookie)) != NULL) {
5330Sstevel@tonic-gate 			free(slp->str);
5340Sstevel@tonic-gate 			free(slp);
5350Sstevel@tonic-gate 		}
5360Sstevel@tonic-gate 
5370Sstevel@tonic-gate 		uu_list_destroy($2);
5380Sstevel@tonic-gate 	}
5393179Sjeanm 	| SCC_UNSETENV error terminator	{ synerr(SCC_UNSETENV); return(0); }
5400Sstevel@tonic-gate 
5410Sstevel@tonic-gate listsnap_cmd : SCC_LISTSNAP terminator	{ lscf_listsnap(); }
5423179Sjeanm 	| SCC_LISTSNAP error terminator	{ synerr(SCC_LISTSNAP); return(0); }
5430Sstevel@tonic-gate 
5440Sstevel@tonic-gate selectsnap_cmd : SCC_SELECTSNAP opt_word terminator
5450Sstevel@tonic-gate 					{ lscf_selectsnap($2); free($2); }
5460Sstevel@tonic-gate 	| SCC_SELECTSNAP error terminator
5473179Sjeanm 					{ synerr(SCC_SELECTSNAP); return(0); }
5480Sstevel@tonic-gate 
5490Sstevel@tonic-gate revert_cmd: SCC_REVERT opt_word terminator	{ lscf_revert($2); free ($2); }
5503179Sjeanm 	| SCC_REVERT error terminator		{ synerr(SCC_REVERT); return(0); }
5510Sstevel@tonic-gate 
5525841Samaguire refresh_cmd: SCC_REFRESH terminator	{ lscf_refresh(); }
5535841Samaguire 	| SCC_REFRESH error terminator	{ synerr(SCC_REFRESH); return(0); }
5540Sstevel@tonic-gate 
555*12967Sgavin.maltby@oracle.com delnotify_cmd : SCC_DELNOTIFY SCV_WORD terminator
556*12967Sgavin.maltby@oracle.com 	{
557*12967Sgavin.maltby@oracle.com 		lscf_delnotify($2, 0);
558*12967Sgavin.maltby@oracle.com 		free($2);
559*12967Sgavin.maltby@oracle.com 	}
560*12967Sgavin.maltby@oracle.com 	| SCC_DELNOTIFY SCV_WORD SCV_WORD terminator
561*12967Sgavin.maltby@oracle.com 	{
562*12967Sgavin.maltby@oracle.com 		if (strcmp($2, "-g") == 0) {
563*12967Sgavin.maltby@oracle.com 			lscf_delnotify($3, 1);
564*12967Sgavin.maltby@oracle.com 			free($2);
565*12967Sgavin.maltby@oracle.com 			free($3);
566*12967Sgavin.maltby@oracle.com 		} else {
567*12967Sgavin.maltby@oracle.com 			synerr(SCC_DELNOTIFY);
568*12967Sgavin.maltby@oracle.com 			free($2);
569*12967Sgavin.maltby@oracle.com 			free($3);
570*12967Sgavin.maltby@oracle.com 			return(0);
571*12967Sgavin.maltby@oracle.com 		}
572*12967Sgavin.maltby@oracle.com 	}
573*12967Sgavin.maltby@oracle.com 	| SCC_DELNOTIFY error terminator { synerr(SCC_DELNOTIFY); return(0); }
574*12967Sgavin.maltby@oracle.com 
575*12967Sgavin.maltby@oracle.com listnotify_cmd : SCC_LISTNOTIFY terminator
576*12967Sgavin.maltby@oracle.com 	{
577*12967Sgavin.maltby@oracle.com 		lscf_listnotify("all", 0);
578*12967Sgavin.maltby@oracle.com 	}
579*12967Sgavin.maltby@oracle.com 	| SCC_LISTNOTIFY SCV_WORD terminator
580*12967Sgavin.maltby@oracle.com 	{
581*12967Sgavin.maltby@oracle.com 		if (strcmp($2, "-g") == 0) {
582*12967Sgavin.maltby@oracle.com 			lscf_listnotify("all", 1);
583*12967Sgavin.maltby@oracle.com 		} else {
584*12967Sgavin.maltby@oracle.com 			lscf_listnotify($2, 0);
585*12967Sgavin.maltby@oracle.com 		}
586*12967Sgavin.maltby@oracle.com 		free($2);
587*12967Sgavin.maltby@oracle.com 	}
588*12967Sgavin.maltby@oracle.com 	| SCC_LISTNOTIFY SCV_WORD SCV_WORD terminator
589*12967Sgavin.maltby@oracle.com 	{
590*12967Sgavin.maltby@oracle.com 		if (strcmp($2, "-g") == 0) {
591*12967Sgavin.maltby@oracle.com 			lscf_listnotify($3, 1);
592*12967Sgavin.maltby@oracle.com 			free($2);
593*12967Sgavin.maltby@oracle.com 			free($3);
594*12967Sgavin.maltby@oracle.com 		} else {
595*12967Sgavin.maltby@oracle.com 			synerr(SCC_LISTNOTIFY);
596*12967Sgavin.maltby@oracle.com 			free($2);
597*12967Sgavin.maltby@oracle.com 			free($3);
598*12967Sgavin.maltby@oracle.com 			return(0);
599*12967Sgavin.maltby@oracle.com 		}
600*12967Sgavin.maltby@oracle.com 	}
601*12967Sgavin.maltby@oracle.com 	| SCC_LISTNOTIFY error terminator { synerr(SCC_LISTNOTIFY); return(0); }
602*12967Sgavin.maltby@oracle.com 
603*12967Sgavin.maltby@oracle.com setnotify_cmd : SCC_SETNOTIFY string_list terminator
604*12967Sgavin.maltby@oracle.com 	{
605*12967Sgavin.maltby@oracle.com 		string_list_t *slp;
606*12967Sgavin.maltby@oracle.com 		void *cookie = NULL;
607*12967Sgavin.maltby@oracle.com 
608*12967Sgavin.maltby@oracle.com 		if (lscf_setnotify($2) == -2)
609*12967Sgavin.maltby@oracle.com 			synerr(SCC_SETNOTIFY);
610*12967Sgavin.maltby@oracle.com 
611*12967Sgavin.maltby@oracle.com 		while ((slp = uu_list_teardown($2, &cookie)) != NULL) {
612*12967Sgavin.maltby@oracle.com 			free(slp->str);
613*12967Sgavin.maltby@oracle.com 			free(slp);
614*12967Sgavin.maltby@oracle.com 		}
615*12967Sgavin.maltby@oracle.com 
616*12967Sgavin.maltby@oracle.com 		uu_list_destroy($2);
617*12967Sgavin.maltby@oracle.com 	}
618*12967Sgavin.maltby@oracle.com 	| SCC_SETNOTIFY error terminator { synerr(SCC_SETNOTIFY); return(0); }
619*12967Sgavin.maltby@oracle.com 
6200Sstevel@tonic-gate terminator : SCS_NEWLINE
6210Sstevel@tonic-gate 
6220Sstevel@tonic-gate string_list :
6230Sstevel@tonic-gate 	{
6240Sstevel@tonic-gate 		$$ = uu_list_create(string_pool, NULL, 0);
6250Sstevel@tonic-gate 		if ($$ == NULL)
6260Sstevel@tonic-gate 			uu_die(gettext("Out of memory\n"));
6270Sstevel@tonic-gate 	}
6280Sstevel@tonic-gate 	| string_list string
6290Sstevel@tonic-gate 	{
6300Sstevel@tonic-gate 		string_list_t *slp;
6310Sstevel@tonic-gate 
6320Sstevel@tonic-gate 		slp = safe_malloc(sizeof (*slp));
6330Sstevel@tonic-gate 
6340Sstevel@tonic-gate 		slp->str = $2;
6350Sstevel@tonic-gate 		uu_list_node_init(slp, &slp->node, string_pool);
6360Sstevel@tonic-gate 		uu_list_append($1, slp);
6370Sstevel@tonic-gate 		$$ = $1;
6380Sstevel@tonic-gate 	}
6390Sstevel@tonic-gate 
6400Sstevel@tonic-gate multiline_string_list : string_list
6410Sstevel@tonic-gate 	{
6420Sstevel@tonic-gate 		$$ = $1;
6430Sstevel@tonic-gate 	}
6440Sstevel@tonic-gate 	| multiline_string_list SCS_NEWLINE string_list
6450Sstevel@tonic-gate 	{
6460Sstevel@tonic-gate 		void *cookie = NULL;
6470Sstevel@tonic-gate 		string_list_t *slp;
6480Sstevel@tonic-gate 
6490Sstevel@tonic-gate 		/* Append $3 to $1. */
6500Sstevel@tonic-gate 		while ((slp = uu_list_teardown($3, &cookie)) != NULL)
6510Sstevel@tonic-gate 			uu_list_append($1, slp);
6520Sstevel@tonic-gate 
6530Sstevel@tonic-gate 		uu_list_destroy($3);
6540Sstevel@tonic-gate 	}
6550Sstevel@tonic-gate 
6560Sstevel@tonic-gate string : SCV_WORD	{ $$ = $1; }
6570Sstevel@tonic-gate 	| SCV_STRING	{ $$ = $1; }
6580Sstevel@tonic-gate 
6590Sstevel@tonic-gate opt_word :		{ $$ = NULL; }
6600Sstevel@tonic-gate 	| SCV_WORD	{ $$ = $1; }
6610Sstevel@tonic-gate 
6620Sstevel@tonic-gate command_token : SCC_VALIDATE	{ $$ = SCC_VALIDATE; }
6630Sstevel@tonic-gate 	| SCC_IMPORT		{ $$ = SCC_IMPORT; }
66411996SThomas.Whitten@Sun.COM 	| SCC_CLEANUP		{ $$ = SCC_CLEANUP; }
6650Sstevel@tonic-gate 	| SCC_EXPORT		{ $$ = SCC_EXPORT; }
6660Sstevel@tonic-gate 	| SCC_APPLY		{ $$ = SCC_APPLY; }
6670Sstevel@tonic-gate 	| SCC_EXTRACT		{ $$ = SCC_EXTRACT; }
6680Sstevel@tonic-gate 	| SCC_REPOSITORY	{ $$ = SCC_REPOSITORY; }
6690Sstevel@tonic-gate 	| SCC_ARCHIVE		{ $$ = SCC_ARCHIVE; }
6700Sstevel@tonic-gate 	| SCC_INVENTORY		{ $$ = SCC_INVENTORY; }
6710Sstevel@tonic-gate 	| SCC_SET		{ $$ = SCC_SET; }
6720Sstevel@tonic-gate 	| SCC_END		{ $$ = SCC_END; }
6730Sstevel@tonic-gate 	| SCC_HELP		{ $$ = SCC_HELP; }
6740Sstevel@tonic-gate 	| SCC_LIST		{ $$ = SCC_LIST; }
6750Sstevel@tonic-gate 	| SCC_ADD		{ $$ = SCC_ADD; }
6760Sstevel@tonic-gate 	| SCC_DELETE		{ $$ = SCC_DELETE; }
6770Sstevel@tonic-gate 	| SCC_SELECT		{ $$ = SCC_SELECT; }
6780Sstevel@tonic-gate 	| SCC_UNSELECT		{ $$ = SCC_UNSELECT; }
6790Sstevel@tonic-gate 	| SCC_LISTPG		{ $$ = SCC_LISTPG; }
6800Sstevel@tonic-gate 	| SCC_ADDPG		{ $$ = SCC_ADDPG; }
6810Sstevel@tonic-gate 	| SCC_DELPG		{ $$ = SCC_DELPG; }
6827475SPhilippe.Jung@Sun.COM 	| SCC_DELHASH		{ $$ = SCC_DELHASH; }
6830Sstevel@tonic-gate 	| SCC_LISTPROP		{ $$ = SCC_LISTPROP; }
6840Sstevel@tonic-gate 	| SCC_SETPROP		{ $$ = SCC_SETPROP; }
6850Sstevel@tonic-gate 	| SCC_DELPROP		{ $$ = SCC_DELPROP; }
6860Sstevel@tonic-gate 	| SCC_EDITPROP		{ $$ = SCC_EDITPROP; }
6870Sstevel@tonic-gate 	| SCC_ADDPROPVALUE	{ $$ = SCC_ADDPROPVALUE; }
6880Sstevel@tonic-gate 	| SCC_DELPROPVALUE	{ $$ = SCC_DELPROPVALUE; }
6890Sstevel@tonic-gate 	| SCC_SETENV		{ $$ = SCC_SETENV; }
6900Sstevel@tonic-gate 	| SCC_UNSETENV		{ $$ = SCC_UNSETENV; }
6910Sstevel@tonic-gate 	| SCC_LISTSNAP		{ $$ = SCC_LISTSNAP; }
6920Sstevel@tonic-gate 	| SCC_SELECTSNAP	{ $$ = SCC_SELECTSNAP; }
6930Sstevel@tonic-gate 	| SCC_REVERT		{ $$ = SCC_REVERT; }
6945841Samaguire 	| SCC_REFRESH		{ $$ = SCC_REFRESH; }
6957887SLiane.Praza@Sun.COM 	| SCC_DESCRIBE		{ $$ = SCC_DESCRIBE; }
696*12967Sgavin.maltby@oracle.com 	| SCC_DELNOTIFY		{ $$ = SCC_DELNOTIFY; }
697*12967Sgavin.maltby@oracle.com 	| SCC_LISTNOTIFY	{ $$ = SCC_LISTNOTIFY; }
698*12967Sgavin.maltby@oracle.com 	| SCC_SETNOTIFY		{ $$ = SCC_SETNOTIFY; }
699