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 /* 24f329b923SSean Wilcox * Copyright (c) 2004, 2010, Oracle and/or its affiliates. All rights reserved. 257c478bd9Sstevel@tonic-gate */ 267c478bd9Sstevel@tonic-gate 277c478bd9Sstevel@tonic-gate 287c478bd9Sstevel@tonic-gate #include <libintl.h> 297c478bd9Sstevel@tonic-gate 307c478bd9Sstevel@tonic-gate #include "svccfg.h" 317c478bd9Sstevel@tonic-gate 327c478bd9Sstevel@tonic-gate uu_list_pool_t *string_pool; 337c478bd9Sstevel@tonic-gate 347c478bd9Sstevel@tonic-gate %} 357c478bd9Sstevel@tonic-gate 367c478bd9Sstevel@tonic-gate %union { 377c478bd9Sstevel@tonic-gate int tok; 387c478bd9Sstevel@tonic-gate char *str; 397c478bd9Sstevel@tonic-gate uu_list_t *uul; 407c478bd9Sstevel@tonic-gate } 417c478bd9Sstevel@tonic-gate 427c478bd9Sstevel@tonic-gate %start commands 437c478bd9Sstevel@tonic-gate 447c478bd9Sstevel@tonic-gate %token SCC_VALIDATE SCC_IMPORT SCC_EXPORT SCC_ARCHIVE SCC_APPLY SCC_EXTRACT 459444c26fSTom Whitten %token SCC_CLEANUP 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 501f6eb021SLiane 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 55*f6e214c7SGavin Maltby %token SCC_DELNOTIFY SCC_SETNOTIFY SCC_LISTNOTIFY 567c478bd9Sstevel@tonic-gate 577c478bd9Sstevel@tonic-gate %type <tok> command_token 587c478bd9Sstevel@tonic-gate %type <str> SCV_WORD SCV_STRING 597c478bd9Sstevel@tonic-gate %type <str> string opt_word 607c478bd9Sstevel@tonic-gate %type <uul> string_list multiline_string_list 617c478bd9Sstevel@tonic-gate 627c478bd9Sstevel@tonic-gate %% 637c478bd9Sstevel@tonic-gate 647c478bd9Sstevel@tonic-gate /* 657c478bd9Sstevel@tonic-gate * We could hoist the command terminator for all the rules up here, but then 667c478bd9Sstevel@tonic-gate * the parser would reduce before shifting the terminator, which would require 677c478bd9Sstevel@tonic-gate * an additional error rule (per command) to catch extra arguments. 687c478bd9Sstevel@tonic-gate * This way requires all input to be terminated, which is done by input() in 697c478bd9Sstevel@tonic-gate * svccfg.l. 707c478bd9Sstevel@tonic-gate */ 717c478bd9Sstevel@tonic-gate 727c478bd9Sstevel@tonic-gate commands : command 737c478bd9Sstevel@tonic-gate | commands command 747c478bd9Sstevel@tonic-gate 757c478bd9Sstevel@tonic-gate command : terminator 767c478bd9Sstevel@tonic-gate | validate_cmd 777c478bd9Sstevel@tonic-gate | import_cmd 789444c26fSTom Whitten | cleanup_cmd 797c478bd9Sstevel@tonic-gate | export_cmd 807c478bd9Sstevel@tonic-gate | archive_cmd 813eae19d9Swesolows | restore_cmd 827c478bd9Sstevel@tonic-gate | apply_cmd 837c478bd9Sstevel@tonic-gate | extract_cmd 847c478bd9Sstevel@tonic-gate | repository_cmd 857c478bd9Sstevel@tonic-gate | inventory_cmd 867c478bd9Sstevel@tonic-gate | set_cmd 877c478bd9Sstevel@tonic-gate | end_cmd 887c478bd9Sstevel@tonic-gate | help_cmd 897c478bd9Sstevel@tonic-gate | list_cmd 907c478bd9Sstevel@tonic-gate | add_cmd 917c478bd9Sstevel@tonic-gate | delete_cmd 927c478bd9Sstevel@tonic-gate | select_cmd 937c478bd9Sstevel@tonic-gate | unselect_cmd 947c478bd9Sstevel@tonic-gate | listpg_cmd 957c478bd9Sstevel@tonic-gate | addpg_cmd 967c478bd9Sstevel@tonic-gate | delpg_cmd 9770cbfe41SPhilippe Jung | delhash_cmd 987c478bd9Sstevel@tonic-gate | listprop_cmd 997c478bd9Sstevel@tonic-gate | setprop_cmd 1007c478bd9Sstevel@tonic-gate | delprop_cmd 1017c478bd9Sstevel@tonic-gate | editprop_cmd 1021f6eb021SLiane Praza | describe_cmd 1037c478bd9Sstevel@tonic-gate | addpropvalue_cmd 1047c478bd9Sstevel@tonic-gate | delpropvalue_cmd 1057c478bd9Sstevel@tonic-gate | setenv_cmd 1067c478bd9Sstevel@tonic-gate | unsetenv_cmd 1077c478bd9Sstevel@tonic-gate | listsnap_cmd 1087c478bd9Sstevel@tonic-gate | selectsnap_cmd 1097c478bd9Sstevel@tonic-gate | revert_cmd 110347a77f2Samaguire | refresh_cmd 1117c478bd9Sstevel@tonic-gate | unknown_cmd 112*f6e214c7SGavin Maltby | delnotify_cmd 113*f6e214c7SGavin Maltby | listnotify_cmd 114*f6e214c7SGavin Maltby | setnotify_cmd 1157c478bd9Sstevel@tonic-gate | error terminator { semerr(gettext("Syntax error.\n")); } 1167c478bd9Sstevel@tonic-gate 1177c478bd9Sstevel@tonic-gate unknown_cmd : SCV_WORD terminator 1187c478bd9Sstevel@tonic-gate { 1197c478bd9Sstevel@tonic-gate semerr(gettext("Unknown command \"%s\".\n"), $1); 1207c478bd9Sstevel@tonic-gate free($1); 1217c478bd9Sstevel@tonic-gate } 1227c478bd9Sstevel@tonic-gate | SCV_WORD string_list terminator 1237c478bd9Sstevel@tonic-gate { 1247c478bd9Sstevel@tonic-gate string_list_t *slp; 1257c478bd9Sstevel@tonic-gate void *cookie = NULL; 1267c478bd9Sstevel@tonic-gate 1277c478bd9Sstevel@tonic-gate semerr(gettext("Unknown command \"%s\".\n"), $1); 1287c478bd9Sstevel@tonic-gate 1297c478bd9Sstevel@tonic-gate while ((slp = uu_list_teardown($2, &cookie)) != NULL) { 1307c478bd9Sstevel@tonic-gate free(slp->str); 1317c478bd9Sstevel@tonic-gate free(slp); 1327c478bd9Sstevel@tonic-gate } 1337c478bd9Sstevel@tonic-gate 1347c478bd9Sstevel@tonic-gate uu_list_destroy($2); 1357c478bd9Sstevel@tonic-gate free($1); 1367c478bd9Sstevel@tonic-gate } 1377c478bd9Sstevel@tonic-gate 1387c478bd9Sstevel@tonic-gate validate_cmd : SCC_VALIDATE SCV_WORD terminator 1397c478bd9Sstevel@tonic-gate { 1401f6eb021SLiane Praza lscf_validate($2); 1417c478bd9Sstevel@tonic-gate free($2); 1427c478bd9Sstevel@tonic-gate } 1431f6eb021SLiane Praza | SCC_VALIDATE terminator { lscf_validate_fmri(NULL); } 144d3186a0eSjeanm | SCC_VALIDATE error terminator { synerr(SCC_VALIDATE); return(0); } 1457c478bd9Sstevel@tonic-gate 1467c478bd9Sstevel@tonic-gate import_cmd : SCC_IMPORT string_list terminator 1477c478bd9Sstevel@tonic-gate { 1487c478bd9Sstevel@tonic-gate string_list_t *slp; 1497c478bd9Sstevel@tonic-gate void *cookie = NULL; 1507c478bd9Sstevel@tonic-gate 151d3186a0eSjeanm if (engine_import($2) == -2) { 1527c478bd9Sstevel@tonic-gate synerr(SCC_IMPORT); 153d3186a0eSjeanm return(0); 154d3186a0eSjeanm } 1557c478bd9Sstevel@tonic-gate 1567c478bd9Sstevel@tonic-gate while ((slp = uu_list_teardown($2, &cookie)) != NULL) { 1577c478bd9Sstevel@tonic-gate free(slp->str); 1587c478bd9Sstevel@tonic-gate free(slp); 1597c478bd9Sstevel@tonic-gate } 1607c478bd9Sstevel@tonic-gate 1617c478bd9Sstevel@tonic-gate uu_list_destroy($2); 1627c478bd9Sstevel@tonic-gate } 163d3186a0eSjeanm | SCC_IMPORT error terminator { synerr(SCC_IMPORT); return(0); } 1647c478bd9Sstevel@tonic-gate 1659444c26fSTom Whitten cleanup_cmd : SCC_CLEANUP terminator 1669444c26fSTom Whitten { 1679444c26fSTom Whitten engine_cleanup(0); 1689444c26fSTom Whitten } 1699444c26fSTom Whitten | SCC_CLEANUP SCV_WORD terminator 1709444c26fSTom Whitten { 1719444c26fSTom Whitten if (strcmp($2, "-a") == 0) { 1729444c26fSTom Whitten engine_cleanup(1); 1739444c26fSTom Whitten free($2); 1749444c26fSTom Whitten } else { 1759444c26fSTom Whitten synerr(SCC_CLEANUP); 1769444c26fSTom Whitten free($2); 1779444c26fSTom Whitten return (0); 1789444c26fSTom Whitten } 1799444c26fSTom Whitten } 1809444c26fSTom Whitten | SCC_CLEANUP error terminator { synerr(SCC_CLEANUP); return(0); } 1819444c26fSTom Whitten 1829444c26fSTom Whitten 1837c478bd9Sstevel@tonic-gate export_cmd : SCC_EXPORT SCV_WORD terminator 1847c478bd9Sstevel@tonic-gate { 1853eae19d9Swesolows lscf_service_export($2, NULL, 0); 1867c478bd9Sstevel@tonic-gate free($2); 1877c478bd9Sstevel@tonic-gate } 1887c478bd9Sstevel@tonic-gate | SCC_EXPORT SCV_WORD SCS_REDIRECT SCV_WORD terminator 1897c478bd9Sstevel@tonic-gate { 1903eae19d9Swesolows lscf_service_export($2, $4, 0); 1917c478bd9Sstevel@tonic-gate free($2); 1927c478bd9Sstevel@tonic-gate free($4); 1937c478bd9Sstevel@tonic-gate } 1943eae19d9Swesolows | SCC_EXPORT SCV_WORD SCV_WORD terminator 1953eae19d9Swesolows { 1963eae19d9Swesolows if (strcmp($2, "-a") == 0) { 1973eae19d9Swesolows lscf_service_export($3, NULL, SCE_ALL_VALUES); 1983eae19d9Swesolows free($2); 1993eae19d9Swesolows free($3); 2003eae19d9Swesolows } else { 2013eae19d9Swesolows synerr(SCC_EXPORT); 2023eae19d9Swesolows free($2); 2033eae19d9Swesolows free($3); 2043eae19d9Swesolows return (0); 2053eae19d9Swesolows } 2063eae19d9Swesolows } 2073eae19d9Swesolows | SCC_EXPORT SCV_WORD SCV_WORD SCS_REDIRECT SCV_WORD terminator 2083eae19d9Swesolows { 2093eae19d9Swesolows if (strcmp($2, "-a") == 0) { 2103eae19d9Swesolows lscf_service_export($3, $5, SCE_ALL_VALUES); 2113eae19d9Swesolows free($2); 2123eae19d9Swesolows free($3); 2133eae19d9Swesolows free($5); 2143eae19d9Swesolows } else { 2153eae19d9Swesolows synerr(SCC_EXPORT); 2163eae19d9Swesolows free($2); 2173eae19d9Swesolows free($3); 2183eae19d9Swesolows free($5); 2193eae19d9Swesolows return (0); 2203eae19d9Swesolows } 2213eae19d9Swesolows } 222d3186a0eSjeanm | SCC_EXPORT error terminator { synerr(SCC_EXPORT); return(0); } 2237c478bd9Sstevel@tonic-gate 2247c478bd9Sstevel@tonic-gate archive_cmd : SCC_ARCHIVE terminator 2257c478bd9Sstevel@tonic-gate { 2263eae19d9Swesolows lscf_archive(NULL, 0); 2273eae19d9Swesolows } 2283eae19d9Swesolows | SCC_ARCHIVE SCV_WORD terminator 2293eae19d9Swesolows { 2303eae19d9Swesolows if (strcmp($2, "-a") == 0) { 2313eae19d9Swesolows lscf_archive(NULL, SCE_ALL_VALUES); 2323eae19d9Swesolows free($2); 2333eae19d9Swesolows } else { 2343eae19d9Swesolows synerr(SCC_ARCHIVE); 2353eae19d9Swesolows free($2); 2363eae19d9Swesolows return (0); 2373eae19d9Swesolows } 2387c478bd9Sstevel@tonic-gate } 2397c478bd9Sstevel@tonic-gate | SCC_ARCHIVE SCS_REDIRECT SCV_WORD terminator 2407c478bd9Sstevel@tonic-gate { 2413eae19d9Swesolows lscf_archive($3, 0); 2427c478bd9Sstevel@tonic-gate free($3); 2437c478bd9Sstevel@tonic-gate } 2443eae19d9Swesolows | SCC_ARCHIVE SCV_WORD SCS_REDIRECT SCV_WORD terminator 2453eae19d9Swesolows { 2463eae19d9Swesolows if (strcmp($2, "-a") == 0) { 2473eae19d9Swesolows lscf_archive($4, SCE_ALL_VALUES); 2483eae19d9Swesolows free($2); 2493eae19d9Swesolows free($4); 2503eae19d9Swesolows } else { 2513eae19d9Swesolows synerr(SCC_ARCHIVE); 2523eae19d9Swesolows free($2); 2533eae19d9Swesolows free($4); 2543eae19d9Swesolows return (0); 2553eae19d9Swesolows } 2563eae19d9Swesolows } 257d3186a0eSjeanm | SCC_ARCHIVE error terminator { synerr(SCC_ARCHIVE); return(0); } 2587c478bd9Sstevel@tonic-gate 2593eae19d9Swesolows restore_cmd : SCC_RESTORE SCV_WORD terminator 2603eae19d9Swesolows { 2613eae19d9Swesolows (void) engine_restore($2); 2623eae19d9Swesolows free($2); 2633eae19d9Swesolows } 2643eae19d9Swesolows | SCC_RESTORE error terminator { synerr(SCC_RESTORE); return(0); } 2653eae19d9Swesolows 2667c478bd9Sstevel@tonic-gate apply_cmd : SCC_APPLY SCV_WORD terminator 267687293e1SAntonello Cruz { 268f329b923SSean Wilcox if (engine_apply($2, 1) == -1) { 269f329b923SSean Wilcox if ((est->sc_cmd_flags & (SC_CMD_IACTIVE|SC_CMD_DONT_EXIT)) == 0) 270f329b923SSean Wilcox exit(1); 271f329b923SSean Wilcox 272f329b923SSean Wilcox free($2); 273f329b923SSean Wilcox return (0); 274f329b923SSean Wilcox } 275f329b923SSean Wilcox 276687293e1SAntonello Cruz free($2); 277687293e1SAntonello Cruz } 278687293e1SAntonello Cruz | SCC_APPLY SCV_WORD SCV_WORD terminator 279687293e1SAntonello Cruz { 280687293e1SAntonello Cruz if (strcmp($2, "-n") == 0) { 281687293e1SAntonello Cruz (void) engine_apply($3, 0); 282687293e1SAntonello Cruz free($2); 283687293e1SAntonello Cruz free($3); 284687293e1SAntonello Cruz } else { 285687293e1SAntonello Cruz synerr(SCC_APPLY); 286687293e1SAntonello Cruz free($2); 287687293e1SAntonello Cruz free($3); 288687293e1SAntonello Cruz return (0); 289687293e1SAntonello Cruz } 290687293e1SAntonello Cruz } 291d3186a0eSjeanm | SCC_APPLY error terminator { synerr(SCC_APPLY); return(0); } 2927c478bd9Sstevel@tonic-gate 2937c478bd9Sstevel@tonic-gate extract_cmd: SCC_EXTRACT terminator { lscf_profile_extract(NULL); } 2947c478bd9Sstevel@tonic-gate | SCC_EXTRACT SCS_REDIRECT SCV_WORD terminator 2957c478bd9Sstevel@tonic-gate { 2967c478bd9Sstevel@tonic-gate lscf_profile_extract($3); 2977c478bd9Sstevel@tonic-gate free($3); 2987c478bd9Sstevel@tonic-gate } 299d3186a0eSjeanm | SCC_EXTRACT error terminator { synerr(SCC_EXTRACT); return(0); } 3007c478bd9Sstevel@tonic-gate 3017c478bd9Sstevel@tonic-gate repository_cmd: SCC_REPOSITORY SCV_WORD terminator 3027c478bd9Sstevel@tonic-gate { 303db11989eSpjung if (strcmp($2, "-f") == 0) { 304db11989eSpjung synerr(SCC_REPOSITORY); 305db11989eSpjung return(0); 306db11989eSpjung } 307db11989eSpjung lscf_set_repository($2, 0); 3087c478bd9Sstevel@tonic-gate free($2); 3097c478bd9Sstevel@tonic-gate } 310db11989eSpjung | SCC_REPOSITORY SCV_WORD SCV_WORD terminator 311db11989eSpjung { 312db11989eSpjung if (strcmp($2, "-f") == 0) { 313db11989eSpjung lscf_set_repository($3, 1); 314db11989eSpjung free($2); 315db11989eSpjung free($3); 316db11989eSpjung } else { 317db11989eSpjung synerr(SCC_REPOSITORY); 318db11989eSpjung return(0); 319db11989eSpjung } 320db11989eSpjung } 321d3186a0eSjeanm | SCC_REPOSITORY error terminator { synerr(SCC_REPOSITORY); return(0); } 3227c478bd9Sstevel@tonic-gate 3237c478bd9Sstevel@tonic-gate inventory_cmd : SCC_INVENTORY SCV_WORD terminator 3247c478bd9Sstevel@tonic-gate { lxml_inventory($2); free($2); } 325d3186a0eSjeanm | SCC_INVENTORY error terminator { synerr(SCC_INVENTORY); return(0); } 3267c478bd9Sstevel@tonic-gate 3277c478bd9Sstevel@tonic-gate set_cmd : SCC_SET string_list terminator 3287c478bd9Sstevel@tonic-gate { 3297c478bd9Sstevel@tonic-gate string_list_t *slp; 3307c478bd9Sstevel@tonic-gate void *cookie = NULL; 3317c478bd9Sstevel@tonic-gate 3327c478bd9Sstevel@tonic-gate (void) engine_set($2); 3337c478bd9Sstevel@tonic-gate 3347c478bd9Sstevel@tonic-gate while ((slp = uu_list_teardown($2, &cookie)) != NULL) { 3357c478bd9Sstevel@tonic-gate free(slp->str); 3367c478bd9Sstevel@tonic-gate free(slp); 3377c478bd9Sstevel@tonic-gate } 3387c478bd9Sstevel@tonic-gate 3397c478bd9Sstevel@tonic-gate uu_list_destroy($2); 3407c478bd9Sstevel@tonic-gate } 341d3186a0eSjeanm | SCC_SET error terminator { synerr(SCC_SET); return(0); } 3427c478bd9Sstevel@tonic-gate 3437c478bd9Sstevel@tonic-gate end_cmd : SCC_END terminator { exit(0); } 344d3186a0eSjeanm | SCC_END error terminator { synerr (SCC_END); return(0); } 3457c478bd9Sstevel@tonic-gate 3467c478bd9Sstevel@tonic-gate help_cmd : SCC_HELP terminator { help(0); } 3477c478bd9Sstevel@tonic-gate | SCC_HELP command_token terminator { help($2); } 348d3186a0eSjeanm | SCC_HELP error terminator { synerr(SCC_HELP); return(0); } 3497c478bd9Sstevel@tonic-gate 3507c478bd9Sstevel@tonic-gate list_cmd : SCC_LIST opt_word terminator { lscf_list($2); free($2); } 351d3186a0eSjeanm | SCC_LIST error terminator { synerr(SCC_LIST); return(0); } 3527c478bd9Sstevel@tonic-gate 3537c478bd9Sstevel@tonic-gate add_cmd : SCC_ADD SCV_WORD terminator { lscf_add($2); free($2); } 354d3186a0eSjeanm | SCC_ADD error terminator { synerr(SCC_ADD); return(0); } 3557c478bd9Sstevel@tonic-gate 3567c478bd9Sstevel@tonic-gate delete_cmd : SCC_DELETE SCV_WORD terminator 3577c478bd9Sstevel@tonic-gate { lscf_delete($2, 0); free($2); } 3587c478bd9Sstevel@tonic-gate | SCC_DELETE SCV_WORD SCV_WORD terminator 3597c478bd9Sstevel@tonic-gate { 3607c478bd9Sstevel@tonic-gate if (strcmp($2, "-f") == 0) { 3617c478bd9Sstevel@tonic-gate lscf_delete($3, 1); 3627c478bd9Sstevel@tonic-gate free($2); 3637c478bd9Sstevel@tonic-gate free($3); 3647c478bd9Sstevel@tonic-gate } else { 3657c478bd9Sstevel@tonic-gate synerr(SCC_DELETE); 3663eae19d9Swesolows free($2); 3673eae19d9Swesolows free($3); 368d3186a0eSjeanm return(0); 3697c478bd9Sstevel@tonic-gate } 3707c478bd9Sstevel@tonic-gate } 371d3186a0eSjeanm | SCC_DELETE error terminator { synerr(SCC_DELETE); return(0); } 3727c478bd9Sstevel@tonic-gate 3737c478bd9Sstevel@tonic-gate select_cmd : SCC_SELECT SCV_WORD terminator { lscf_select($2); free($2); } 374d3186a0eSjeanm | SCC_SELECT error terminator { synerr(SCC_SELECT); return(0) ;} 3757c478bd9Sstevel@tonic-gate 3767c478bd9Sstevel@tonic-gate unselect_cmd : SCC_UNSELECT terminator { lscf_unselect(); } 377d3186a0eSjeanm | SCC_UNSELECT error terminator { synerr(SCC_UNSELECT); return(0); } 3787c478bd9Sstevel@tonic-gate 3797c478bd9Sstevel@tonic-gate listpg_cmd : SCC_LISTPG opt_word terminator 3807c478bd9Sstevel@tonic-gate { lscf_listpg($2); free($2); } 381d3186a0eSjeanm | SCC_LISTPG error terminator { synerr(SCC_LISTPG); return(0); } 3827c478bd9Sstevel@tonic-gate 3837c478bd9Sstevel@tonic-gate addpg_cmd : SCC_ADDPG SCV_WORD SCV_WORD opt_word terminator 3847c478bd9Sstevel@tonic-gate { 3857c478bd9Sstevel@tonic-gate (void) lscf_addpg($2, $3, $4); 3867c478bd9Sstevel@tonic-gate free($2); 3877c478bd9Sstevel@tonic-gate free($3); 3887c478bd9Sstevel@tonic-gate free($4); 3897c478bd9Sstevel@tonic-gate } 390d3186a0eSjeanm | SCC_ADDPG error terminator { synerr(SCC_ADDPG); return(0); } 3917c478bd9Sstevel@tonic-gate 3927c478bd9Sstevel@tonic-gate delpg_cmd : SCC_DELPG SCV_WORD terminator 3937c478bd9Sstevel@tonic-gate { lscf_delpg($2); free($2); } 394d3186a0eSjeanm | SCC_DELPG error terminator { synerr(SCC_DELPG); return(0); } 3957c478bd9Sstevel@tonic-gate 39670cbfe41SPhilippe Jung delhash_cmd : SCC_DELHASH SCV_WORD terminator 39770cbfe41SPhilippe Jung { 39870cbfe41SPhilippe Jung lscf_delhash($2, 0); free($2); 39970cbfe41SPhilippe Jung } 40070cbfe41SPhilippe Jung | SCC_DELHASH SCV_WORD SCV_WORD terminator 40170cbfe41SPhilippe Jung { 40270cbfe41SPhilippe Jung if (strcmp($2, "-d") == 0) { 40370cbfe41SPhilippe Jung lscf_delhash($3, 1); 40470cbfe41SPhilippe Jung free($2); 40570cbfe41SPhilippe Jung free($3); 40670cbfe41SPhilippe Jung } else { 40770cbfe41SPhilippe Jung synerr(SCC_DELHASH); 40870cbfe41SPhilippe Jung free($2); 40970cbfe41SPhilippe Jung free($3); 41070cbfe41SPhilippe Jung return(0); 41170cbfe41SPhilippe Jung } 41270cbfe41SPhilippe Jung } 41370cbfe41SPhilippe Jung | SCC_DELHASH error terminator { synerr(SCC_DELHASH); return(0); } 41470cbfe41SPhilippe Jung 4157c478bd9Sstevel@tonic-gate listprop_cmd : SCC_LISTPROP opt_word terminator 4167c478bd9Sstevel@tonic-gate { lscf_listprop($2); free($2); } 417d3186a0eSjeanm | SCC_LISTPROP error terminator { synerr(SCC_LISTPROP); return(0); } 4187c478bd9Sstevel@tonic-gate 4197c478bd9Sstevel@tonic-gate setprop_cmd : SCC_SETPROP SCV_WORD SCS_EQUALS string terminator 4207c478bd9Sstevel@tonic-gate { 4217c478bd9Sstevel@tonic-gate lscf_setprop($2, NULL, $4, NULL); 4227c478bd9Sstevel@tonic-gate free($2); 4237c478bd9Sstevel@tonic-gate free($4); 4247c478bd9Sstevel@tonic-gate } 4257c478bd9Sstevel@tonic-gate | SCC_SETPROP SCV_WORD SCS_EQUALS SCV_WORD string terminator 4267c478bd9Sstevel@tonic-gate { 4277c478bd9Sstevel@tonic-gate (void) lscf_setprop($2, $4, $5, NULL); 4287c478bd9Sstevel@tonic-gate free($2); 4297c478bd9Sstevel@tonic-gate free($4); 4307c478bd9Sstevel@tonic-gate free($5); 4317c478bd9Sstevel@tonic-gate } 4327c478bd9Sstevel@tonic-gate | SCC_SETPROP SCV_WORD SCS_EQUALS opt_word SCS_LPAREN 4337c478bd9Sstevel@tonic-gate multiline_string_list SCS_RPAREN terminator 4347c478bd9Sstevel@tonic-gate { 4357c478bd9Sstevel@tonic-gate string_list_t *slp; 4367c478bd9Sstevel@tonic-gate void *cookie = NULL; 4377c478bd9Sstevel@tonic-gate 4387c478bd9Sstevel@tonic-gate (void) lscf_setprop($2, $4, NULL, $6); 4397c478bd9Sstevel@tonic-gate 4407c478bd9Sstevel@tonic-gate free($2); 4417c478bd9Sstevel@tonic-gate free($4); 4427c478bd9Sstevel@tonic-gate 4437c478bd9Sstevel@tonic-gate while ((slp = uu_list_teardown($6, &cookie)) != NULL) { 4447c478bd9Sstevel@tonic-gate free(slp->str); 4457c478bd9Sstevel@tonic-gate free(slp); 4467c478bd9Sstevel@tonic-gate } 4477c478bd9Sstevel@tonic-gate 4487c478bd9Sstevel@tonic-gate uu_list_destroy($6); 4497c478bd9Sstevel@tonic-gate } 450d3186a0eSjeanm | SCC_SETPROP error terminator { synerr(SCC_SETPROP); return(0); } 451d3186a0eSjeanm | SCC_SETPROP error { synerr(SCC_SETPROP); return(0); } 4527c478bd9Sstevel@tonic-gate 4537c478bd9Sstevel@tonic-gate delprop_cmd : SCC_DELPROP SCV_WORD terminator 4547c478bd9Sstevel@tonic-gate { lscf_delprop($2); free($2); } 455d3186a0eSjeanm | SCC_DELPROP error terminator { synerr(SCC_DELPROP); return(0); } 4567c478bd9Sstevel@tonic-gate 4577c478bd9Sstevel@tonic-gate editprop_cmd : SCC_EDITPROP terminator { lscf_editprop(); } 458d3186a0eSjeanm | SCC_EDITPROP error terminator { synerr(SCC_EDITPROP); return(0); } 4597c478bd9Sstevel@tonic-gate 4601f6eb021SLiane Praza describe_cmd : SCC_DESCRIBE string_list terminator 4611f6eb021SLiane Praza { 4621f6eb021SLiane Praza string_list_t *slp; 4631f6eb021SLiane Praza void *cookie = NULL; 4641f6eb021SLiane Praza 4651f6eb021SLiane Praza if (lscf_describe($2, 1) == -2) { 4661f6eb021SLiane Praza synerr(SCC_DESCRIBE); 4671f6eb021SLiane Praza return(0); 4681f6eb021SLiane Praza } 4691f6eb021SLiane Praza 4701f6eb021SLiane Praza while ((slp = uu_list_teardown($2, &cookie)) != NULL) { 4711f6eb021SLiane Praza free(slp->str); 4721f6eb021SLiane Praza free(slp); 4731f6eb021SLiane Praza } 4741f6eb021SLiane Praza 4751f6eb021SLiane Praza uu_list_destroy($2); 4761f6eb021SLiane Praza } 4771f6eb021SLiane Praza | SCC_DESCRIBE terminator { lscf_describe(NULL, 0); } 4781f6eb021SLiane Praza | SCC_DESCRIBE error terminator { synerr(SCC_DESCRIBE); return(0); } 4791f6eb021SLiane Praza 4807c478bd9Sstevel@tonic-gate addpropvalue_cmd : SCC_ADDPROPVALUE SCV_WORD string terminator 4817c478bd9Sstevel@tonic-gate { 4827c478bd9Sstevel@tonic-gate lscf_addpropvalue($2, NULL, $3); 4837c478bd9Sstevel@tonic-gate free($2); 4847c478bd9Sstevel@tonic-gate free($3); 4857c478bd9Sstevel@tonic-gate } 4867c478bd9Sstevel@tonic-gate | SCC_ADDPROPVALUE SCV_WORD string string terminator 4877c478bd9Sstevel@tonic-gate { 4887c478bd9Sstevel@tonic-gate (void) lscf_addpropvalue($2, $3, $4); 4897c478bd9Sstevel@tonic-gate free($2); 4907c478bd9Sstevel@tonic-gate free($3); 4917c478bd9Sstevel@tonic-gate free($4); 4927c478bd9Sstevel@tonic-gate } 493d3186a0eSjeanm | SCC_ADDPROPVALUE error terminator { synerr(SCC_ADDPROPVALUE); return(0); } 4947c478bd9Sstevel@tonic-gate 4957c478bd9Sstevel@tonic-gate delpropvalue_cmd : SCC_DELPROPVALUE SCV_WORD string terminator 4967c478bd9Sstevel@tonic-gate { 4977c478bd9Sstevel@tonic-gate lscf_delpropvalue($2, $3, 0); 4987c478bd9Sstevel@tonic-gate free($2); 4997c478bd9Sstevel@tonic-gate free($3); 5007c478bd9Sstevel@tonic-gate } 501d3186a0eSjeanm | SCC_DELPROPVALUE error terminator { synerr(SCC_DELPROPVALUE); return(0); } 5027c478bd9Sstevel@tonic-gate 5037c478bd9Sstevel@tonic-gate setenv_cmd : SCC_SETENV string_list terminator 5047c478bd9Sstevel@tonic-gate { 5057c478bd9Sstevel@tonic-gate string_list_t *slp; 5067c478bd9Sstevel@tonic-gate void *cookie = NULL; 5077c478bd9Sstevel@tonic-gate 508d3186a0eSjeanm if (lscf_setenv($2, 0) == -2) { 5097c478bd9Sstevel@tonic-gate synerr(SCC_SETENV); 510d3186a0eSjeanm return(0); 511d3186a0eSjeanm } 5127c478bd9Sstevel@tonic-gate 5137c478bd9Sstevel@tonic-gate while ((slp = uu_list_teardown($2, &cookie)) != NULL) { 5147c478bd9Sstevel@tonic-gate free(slp->str); 5157c478bd9Sstevel@tonic-gate free(slp); 5167c478bd9Sstevel@tonic-gate } 5177c478bd9Sstevel@tonic-gate 5187c478bd9Sstevel@tonic-gate uu_list_destroy($2); 5197c478bd9Sstevel@tonic-gate } 520d3186a0eSjeanm | SCC_SETENV error terminator { synerr(SCC_SETENV); return(0); } 5217c478bd9Sstevel@tonic-gate 5227c478bd9Sstevel@tonic-gate unsetenv_cmd : SCC_UNSETENV string_list terminator 5237c478bd9Sstevel@tonic-gate { 5247c478bd9Sstevel@tonic-gate string_list_t *slp; 5257c478bd9Sstevel@tonic-gate void *cookie = NULL; 5267c478bd9Sstevel@tonic-gate 527d3186a0eSjeanm if (lscf_setenv($2, 1) == -2) { 5287c478bd9Sstevel@tonic-gate synerr(SCC_UNSETENV); 529d3186a0eSjeanm return(0); 530d3186a0eSjeanm } 5317c478bd9Sstevel@tonic-gate 5327c478bd9Sstevel@tonic-gate while ((slp = uu_list_teardown($2, &cookie)) != NULL) { 5337c478bd9Sstevel@tonic-gate free(slp->str); 5347c478bd9Sstevel@tonic-gate free(slp); 5357c478bd9Sstevel@tonic-gate } 5367c478bd9Sstevel@tonic-gate 5377c478bd9Sstevel@tonic-gate uu_list_destroy($2); 5387c478bd9Sstevel@tonic-gate } 539d3186a0eSjeanm | SCC_UNSETENV error terminator { synerr(SCC_UNSETENV); return(0); } 5407c478bd9Sstevel@tonic-gate 5417c478bd9Sstevel@tonic-gate listsnap_cmd : SCC_LISTSNAP terminator { lscf_listsnap(); } 542d3186a0eSjeanm | SCC_LISTSNAP error terminator { synerr(SCC_LISTSNAP); return(0); } 5437c478bd9Sstevel@tonic-gate 5447c478bd9Sstevel@tonic-gate selectsnap_cmd : SCC_SELECTSNAP opt_word terminator 5457c478bd9Sstevel@tonic-gate { lscf_selectsnap($2); free($2); } 5467c478bd9Sstevel@tonic-gate | SCC_SELECTSNAP error terminator 547d3186a0eSjeanm { synerr(SCC_SELECTSNAP); return(0); } 5487c478bd9Sstevel@tonic-gate 5497c478bd9Sstevel@tonic-gate revert_cmd: SCC_REVERT opt_word terminator { lscf_revert($2); free ($2); } 550d3186a0eSjeanm | SCC_REVERT error terminator { synerr(SCC_REVERT); return(0); } 5517c478bd9Sstevel@tonic-gate 552347a77f2Samaguire refresh_cmd: SCC_REFRESH terminator { lscf_refresh(); } 553347a77f2Samaguire | SCC_REFRESH error terminator { synerr(SCC_REFRESH); return(0); } 5547c478bd9Sstevel@tonic-gate 555*f6e214c7SGavin Maltby delnotify_cmd : SCC_DELNOTIFY SCV_WORD terminator 556*f6e214c7SGavin Maltby { 557*f6e214c7SGavin Maltby lscf_delnotify($2, 0); 558*f6e214c7SGavin Maltby free($2); 559*f6e214c7SGavin Maltby } 560*f6e214c7SGavin Maltby | SCC_DELNOTIFY SCV_WORD SCV_WORD terminator 561*f6e214c7SGavin Maltby { 562*f6e214c7SGavin Maltby if (strcmp($2, "-g") == 0) { 563*f6e214c7SGavin Maltby lscf_delnotify($3, 1); 564*f6e214c7SGavin Maltby free($2); 565*f6e214c7SGavin Maltby free($3); 566*f6e214c7SGavin Maltby } else { 567*f6e214c7SGavin Maltby synerr(SCC_DELNOTIFY); 568*f6e214c7SGavin Maltby free($2); 569*f6e214c7SGavin Maltby free($3); 570*f6e214c7SGavin Maltby return(0); 571*f6e214c7SGavin Maltby } 572*f6e214c7SGavin Maltby } 573*f6e214c7SGavin Maltby | SCC_DELNOTIFY error terminator { synerr(SCC_DELNOTIFY); return(0); } 574*f6e214c7SGavin Maltby 575*f6e214c7SGavin Maltby listnotify_cmd : SCC_LISTNOTIFY terminator 576*f6e214c7SGavin Maltby { 577*f6e214c7SGavin Maltby lscf_listnotify("all", 0); 578*f6e214c7SGavin Maltby } 579*f6e214c7SGavin Maltby | SCC_LISTNOTIFY SCV_WORD terminator 580*f6e214c7SGavin Maltby { 581*f6e214c7SGavin Maltby if (strcmp($2, "-g") == 0) { 582*f6e214c7SGavin Maltby lscf_listnotify("all", 1); 583*f6e214c7SGavin Maltby } else { 584*f6e214c7SGavin Maltby lscf_listnotify($2, 0); 585*f6e214c7SGavin Maltby } 586*f6e214c7SGavin Maltby free($2); 587*f6e214c7SGavin Maltby } 588*f6e214c7SGavin Maltby | SCC_LISTNOTIFY SCV_WORD SCV_WORD terminator 589*f6e214c7SGavin Maltby { 590*f6e214c7SGavin Maltby if (strcmp($2, "-g") == 0) { 591*f6e214c7SGavin Maltby lscf_listnotify($3, 1); 592*f6e214c7SGavin Maltby free($2); 593*f6e214c7SGavin Maltby free($3); 594*f6e214c7SGavin Maltby } else { 595*f6e214c7SGavin Maltby synerr(SCC_LISTNOTIFY); 596*f6e214c7SGavin Maltby free($2); 597*f6e214c7SGavin Maltby free($3); 598*f6e214c7SGavin Maltby return(0); 599*f6e214c7SGavin Maltby } 600*f6e214c7SGavin Maltby } 601*f6e214c7SGavin Maltby | SCC_LISTNOTIFY error terminator { synerr(SCC_LISTNOTIFY); return(0); } 602*f6e214c7SGavin Maltby 603*f6e214c7SGavin Maltby setnotify_cmd : SCC_SETNOTIFY string_list terminator 604*f6e214c7SGavin Maltby { 605*f6e214c7SGavin Maltby string_list_t *slp; 606*f6e214c7SGavin Maltby void *cookie = NULL; 607*f6e214c7SGavin Maltby 608*f6e214c7SGavin Maltby if (lscf_setnotify($2) == -2) 609*f6e214c7SGavin Maltby synerr(SCC_SETNOTIFY); 610*f6e214c7SGavin Maltby 611*f6e214c7SGavin Maltby while ((slp = uu_list_teardown($2, &cookie)) != NULL) { 612*f6e214c7SGavin Maltby free(slp->str); 613*f6e214c7SGavin Maltby free(slp); 614*f6e214c7SGavin Maltby } 615*f6e214c7SGavin Maltby 616*f6e214c7SGavin Maltby uu_list_destroy($2); 617*f6e214c7SGavin Maltby } 618*f6e214c7SGavin Maltby | SCC_SETNOTIFY error terminator { synerr(SCC_SETNOTIFY); return(0); } 619*f6e214c7SGavin Maltby 6207c478bd9Sstevel@tonic-gate terminator : SCS_NEWLINE 6217c478bd9Sstevel@tonic-gate 6227c478bd9Sstevel@tonic-gate string_list : 6237c478bd9Sstevel@tonic-gate { 6247c478bd9Sstevel@tonic-gate $$ = uu_list_create(string_pool, NULL, 0); 6257c478bd9Sstevel@tonic-gate if ($$ == NULL) 6267c478bd9Sstevel@tonic-gate uu_die(gettext("Out of memory\n")); 6277c478bd9Sstevel@tonic-gate } 6287c478bd9Sstevel@tonic-gate | string_list string 6297c478bd9Sstevel@tonic-gate { 6307c478bd9Sstevel@tonic-gate string_list_t *slp; 6317c478bd9Sstevel@tonic-gate 6327c478bd9Sstevel@tonic-gate slp = safe_malloc(sizeof (*slp)); 6337c478bd9Sstevel@tonic-gate 6347c478bd9Sstevel@tonic-gate slp->str = $2; 6357c478bd9Sstevel@tonic-gate uu_list_node_init(slp, &slp->node, string_pool); 6367c478bd9Sstevel@tonic-gate uu_list_append($1, slp); 6377c478bd9Sstevel@tonic-gate $$ = $1; 6387c478bd9Sstevel@tonic-gate } 6397c478bd9Sstevel@tonic-gate 6407c478bd9Sstevel@tonic-gate multiline_string_list : string_list 6417c478bd9Sstevel@tonic-gate { 6427c478bd9Sstevel@tonic-gate $$ = $1; 6437c478bd9Sstevel@tonic-gate } 6447c478bd9Sstevel@tonic-gate | multiline_string_list SCS_NEWLINE string_list 6457c478bd9Sstevel@tonic-gate { 6467c478bd9Sstevel@tonic-gate void *cookie = NULL; 6477c478bd9Sstevel@tonic-gate string_list_t *slp; 6487c478bd9Sstevel@tonic-gate 6497c478bd9Sstevel@tonic-gate /* Append $3 to $1. */ 6507c478bd9Sstevel@tonic-gate while ((slp = uu_list_teardown($3, &cookie)) != NULL) 6517c478bd9Sstevel@tonic-gate uu_list_append($1, slp); 6527c478bd9Sstevel@tonic-gate 6537c478bd9Sstevel@tonic-gate uu_list_destroy($3); 6547c478bd9Sstevel@tonic-gate } 6557c478bd9Sstevel@tonic-gate 6567c478bd9Sstevel@tonic-gate string : SCV_WORD { $$ = $1; } 6577c478bd9Sstevel@tonic-gate | SCV_STRING { $$ = $1; } 6587c478bd9Sstevel@tonic-gate 6597c478bd9Sstevel@tonic-gate opt_word : { $$ = NULL; } 6607c478bd9Sstevel@tonic-gate | SCV_WORD { $$ = $1; } 6617c478bd9Sstevel@tonic-gate 6627c478bd9Sstevel@tonic-gate command_token : SCC_VALIDATE { $$ = SCC_VALIDATE; } 6637c478bd9Sstevel@tonic-gate | SCC_IMPORT { $$ = SCC_IMPORT; } 6649444c26fSTom Whitten | SCC_CLEANUP { $$ = SCC_CLEANUP; } 6657c478bd9Sstevel@tonic-gate | SCC_EXPORT { $$ = SCC_EXPORT; } 6667c478bd9Sstevel@tonic-gate | SCC_APPLY { $$ = SCC_APPLY; } 6677c478bd9Sstevel@tonic-gate | SCC_EXTRACT { $$ = SCC_EXTRACT; } 6687c478bd9Sstevel@tonic-gate | SCC_REPOSITORY { $$ = SCC_REPOSITORY; } 6697c478bd9Sstevel@tonic-gate | SCC_ARCHIVE { $$ = SCC_ARCHIVE; } 6707c478bd9Sstevel@tonic-gate | SCC_INVENTORY { $$ = SCC_INVENTORY; } 6717c478bd9Sstevel@tonic-gate | SCC_SET { $$ = SCC_SET; } 6727c478bd9Sstevel@tonic-gate | SCC_END { $$ = SCC_END; } 6737c478bd9Sstevel@tonic-gate | SCC_HELP { $$ = SCC_HELP; } 6747c478bd9Sstevel@tonic-gate | SCC_LIST { $$ = SCC_LIST; } 6757c478bd9Sstevel@tonic-gate | SCC_ADD { $$ = SCC_ADD; } 6767c478bd9Sstevel@tonic-gate | SCC_DELETE { $$ = SCC_DELETE; } 6777c478bd9Sstevel@tonic-gate | SCC_SELECT { $$ = SCC_SELECT; } 6787c478bd9Sstevel@tonic-gate | SCC_UNSELECT { $$ = SCC_UNSELECT; } 6797c478bd9Sstevel@tonic-gate | SCC_LISTPG { $$ = SCC_LISTPG; } 6807c478bd9Sstevel@tonic-gate | SCC_ADDPG { $$ = SCC_ADDPG; } 6817c478bd9Sstevel@tonic-gate | SCC_DELPG { $$ = SCC_DELPG; } 68270cbfe41SPhilippe Jung | SCC_DELHASH { $$ = SCC_DELHASH; } 6837c478bd9Sstevel@tonic-gate | SCC_LISTPROP { $$ = SCC_LISTPROP; } 6847c478bd9Sstevel@tonic-gate | SCC_SETPROP { $$ = SCC_SETPROP; } 6857c478bd9Sstevel@tonic-gate | SCC_DELPROP { $$ = SCC_DELPROP; } 6867c478bd9Sstevel@tonic-gate | SCC_EDITPROP { $$ = SCC_EDITPROP; } 6877c478bd9Sstevel@tonic-gate | SCC_ADDPROPVALUE { $$ = SCC_ADDPROPVALUE; } 6887c478bd9Sstevel@tonic-gate | SCC_DELPROPVALUE { $$ = SCC_DELPROPVALUE; } 6897c478bd9Sstevel@tonic-gate | SCC_SETENV { $$ = SCC_SETENV; } 6907c478bd9Sstevel@tonic-gate | SCC_UNSETENV { $$ = SCC_UNSETENV; } 6917c478bd9Sstevel@tonic-gate | SCC_LISTSNAP { $$ = SCC_LISTSNAP; } 6927c478bd9Sstevel@tonic-gate | SCC_SELECTSNAP { $$ = SCC_SELECTSNAP; } 6937c478bd9Sstevel@tonic-gate | SCC_REVERT { $$ = SCC_REVERT; } 694347a77f2Samaguire | SCC_REFRESH { $$ = SCC_REFRESH; } 6951f6eb021SLiane Praza | SCC_DESCRIBE { $$ = SCC_DESCRIBE; } 696*f6e214c7SGavin Maltby | SCC_DELNOTIFY { $$ = SCC_DELNOTIFY; } 697*f6e214c7SGavin Maltby | SCC_LISTNOTIFY { $$ = SCC_LISTNOTIFY; } 698*f6e214c7SGavin Maltby | SCC_SETNOTIFY { $$ = SCC_SETNOTIFY; } 699