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 6*d3186a0eSjeanm * Common Development and Distribution License (the "License"). 7*d3186a0eSjeanm * 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 217c478bd9Sstevel@tonic-gate * 22*d3186a0eSjeanm * Copyright 2006 Sun Microsystems, Inc. All rights reserved. 237c478bd9Sstevel@tonic-gate * Use is subject to license terms. 247c478bd9Sstevel@tonic-gate */ 257c478bd9Sstevel@tonic-gate 267c478bd9Sstevel@tonic-gate #pragma ident "%Z%%M% %I% %E% SMI" 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 457c478bd9Sstevel@tonic-gate %token SCC_REPOSITORY SCC_INVENTORY SCC_SET SCC_END SCC_HELP 467c478bd9Sstevel@tonic-gate %token SCC_LIST SCC_ADD SCC_DELETE SCC_SELECT SCC_UNSELECT 477c478bd9Sstevel@tonic-gate %token SCC_LISTPG SCC_ADDPG SCC_DELPG 487c478bd9Sstevel@tonic-gate %token SCC_LISTPROP SCC_SETPROP SCC_DELPROP SCC_EDITPROP 497c478bd9Sstevel@tonic-gate %token SCC_ADDPROPVALUE SCC_DELPROPVALUE SCC_SETENV SCC_UNSETENV 507c478bd9Sstevel@tonic-gate %token SCC_LISTSNAP SCC_SELECTSNAP SCC_REVERT 517c478bd9Sstevel@tonic-gate %token SCS_REDIRECT SCS_NEWLINE SCS_EQUALS SCS_LPAREN SCS_RPAREN 527c478bd9Sstevel@tonic-gate %token SCV_WORD SCV_STRING 537c478bd9Sstevel@tonic-gate 547c478bd9Sstevel@tonic-gate %type <tok> command_token 557c478bd9Sstevel@tonic-gate %type <str> SCV_WORD SCV_STRING 567c478bd9Sstevel@tonic-gate %type <str> string opt_word 577c478bd9Sstevel@tonic-gate %type <uul> string_list multiline_string_list 587c478bd9Sstevel@tonic-gate 597c478bd9Sstevel@tonic-gate %% 607c478bd9Sstevel@tonic-gate 617c478bd9Sstevel@tonic-gate /* 627c478bd9Sstevel@tonic-gate * We could hoist the command terminator for all the rules up here, but then 637c478bd9Sstevel@tonic-gate * the parser would reduce before shifting the terminator, which would require 647c478bd9Sstevel@tonic-gate * an additional error rule (per command) to catch extra arguments. 657c478bd9Sstevel@tonic-gate * This way requires all input to be terminated, which is done by input() in 667c478bd9Sstevel@tonic-gate * svccfg.l. 677c478bd9Sstevel@tonic-gate */ 687c478bd9Sstevel@tonic-gate 697c478bd9Sstevel@tonic-gate commands : command 707c478bd9Sstevel@tonic-gate | commands command 717c478bd9Sstevel@tonic-gate 727c478bd9Sstevel@tonic-gate command : terminator 737c478bd9Sstevel@tonic-gate | validate_cmd 747c478bd9Sstevel@tonic-gate | import_cmd 757c478bd9Sstevel@tonic-gate | export_cmd 767c478bd9Sstevel@tonic-gate | archive_cmd 777c478bd9Sstevel@tonic-gate | apply_cmd 787c478bd9Sstevel@tonic-gate | extract_cmd 797c478bd9Sstevel@tonic-gate | repository_cmd 807c478bd9Sstevel@tonic-gate | inventory_cmd 817c478bd9Sstevel@tonic-gate | set_cmd 827c478bd9Sstevel@tonic-gate | end_cmd 837c478bd9Sstevel@tonic-gate | help_cmd 847c478bd9Sstevel@tonic-gate | list_cmd 857c478bd9Sstevel@tonic-gate | add_cmd 867c478bd9Sstevel@tonic-gate | delete_cmd 877c478bd9Sstevel@tonic-gate | select_cmd 887c478bd9Sstevel@tonic-gate | unselect_cmd 897c478bd9Sstevel@tonic-gate | listpg_cmd 907c478bd9Sstevel@tonic-gate | addpg_cmd 917c478bd9Sstevel@tonic-gate | delpg_cmd 927c478bd9Sstevel@tonic-gate | listprop_cmd 937c478bd9Sstevel@tonic-gate | setprop_cmd 947c478bd9Sstevel@tonic-gate | delprop_cmd 957c478bd9Sstevel@tonic-gate | editprop_cmd 967c478bd9Sstevel@tonic-gate | addpropvalue_cmd 977c478bd9Sstevel@tonic-gate | delpropvalue_cmd 987c478bd9Sstevel@tonic-gate | setenv_cmd 997c478bd9Sstevel@tonic-gate | unsetenv_cmd 1007c478bd9Sstevel@tonic-gate | listsnap_cmd 1017c478bd9Sstevel@tonic-gate | selectsnap_cmd 1027c478bd9Sstevel@tonic-gate | revert_cmd 1037c478bd9Sstevel@tonic-gate | unknown_cmd 1047c478bd9Sstevel@tonic-gate | error terminator { semerr(gettext("Syntax error.\n")); } 1057c478bd9Sstevel@tonic-gate 1067c478bd9Sstevel@tonic-gate unknown_cmd : SCV_WORD terminator 1077c478bd9Sstevel@tonic-gate { 1087c478bd9Sstevel@tonic-gate semerr(gettext("Unknown command \"%s\".\n"), $1); 1097c478bd9Sstevel@tonic-gate free($1); 1107c478bd9Sstevel@tonic-gate } 1117c478bd9Sstevel@tonic-gate | SCV_WORD string_list terminator 1127c478bd9Sstevel@tonic-gate { 1137c478bd9Sstevel@tonic-gate string_list_t *slp; 1147c478bd9Sstevel@tonic-gate void *cookie = NULL; 1157c478bd9Sstevel@tonic-gate 1167c478bd9Sstevel@tonic-gate semerr(gettext("Unknown command \"%s\".\n"), $1); 1177c478bd9Sstevel@tonic-gate 1187c478bd9Sstevel@tonic-gate while ((slp = uu_list_teardown($2, &cookie)) != NULL) { 1197c478bd9Sstevel@tonic-gate free(slp->str); 1207c478bd9Sstevel@tonic-gate free(slp); 1217c478bd9Sstevel@tonic-gate } 1227c478bd9Sstevel@tonic-gate 1237c478bd9Sstevel@tonic-gate uu_list_destroy($2); 1247c478bd9Sstevel@tonic-gate free($1); 1257c478bd9Sstevel@tonic-gate } 1267c478bd9Sstevel@tonic-gate 1277c478bd9Sstevel@tonic-gate validate_cmd : SCC_VALIDATE SCV_WORD terminator 1287c478bd9Sstevel@tonic-gate { 1297c478bd9Sstevel@tonic-gate bundle_t *b = internal_bundle_new(); 1307c478bd9Sstevel@tonic-gate lxml_get_bundle_file(b, $2, 0); 1317c478bd9Sstevel@tonic-gate (void) internal_bundle_free(b); 1327c478bd9Sstevel@tonic-gate free($2); 1337c478bd9Sstevel@tonic-gate } 134*d3186a0eSjeanm | SCC_VALIDATE error terminator { synerr(SCC_VALIDATE); return(0); } 1357c478bd9Sstevel@tonic-gate 1367c478bd9Sstevel@tonic-gate import_cmd : SCC_IMPORT string_list terminator 1377c478bd9Sstevel@tonic-gate { 1387c478bd9Sstevel@tonic-gate string_list_t *slp; 1397c478bd9Sstevel@tonic-gate void *cookie = NULL; 1407c478bd9Sstevel@tonic-gate 141*d3186a0eSjeanm if (engine_import($2) == -2) { 1427c478bd9Sstevel@tonic-gate synerr(SCC_IMPORT); 143*d3186a0eSjeanm return(0); 144*d3186a0eSjeanm } 1457c478bd9Sstevel@tonic-gate 1467c478bd9Sstevel@tonic-gate while ((slp = uu_list_teardown($2, &cookie)) != NULL) { 1477c478bd9Sstevel@tonic-gate free(slp->str); 1487c478bd9Sstevel@tonic-gate free(slp); 1497c478bd9Sstevel@tonic-gate } 1507c478bd9Sstevel@tonic-gate 1517c478bd9Sstevel@tonic-gate uu_list_destroy($2); 1527c478bd9Sstevel@tonic-gate } 153*d3186a0eSjeanm | SCC_IMPORT error terminator { synerr(SCC_IMPORT); return(0); } 1547c478bd9Sstevel@tonic-gate 1557c478bd9Sstevel@tonic-gate export_cmd : SCC_EXPORT SCV_WORD terminator 1567c478bd9Sstevel@tonic-gate { 1577c478bd9Sstevel@tonic-gate lscf_service_export($2, NULL); 1587c478bd9Sstevel@tonic-gate free($2); 1597c478bd9Sstevel@tonic-gate } 1607c478bd9Sstevel@tonic-gate | SCC_EXPORT SCV_WORD SCS_REDIRECT SCV_WORD terminator 1617c478bd9Sstevel@tonic-gate { 1627c478bd9Sstevel@tonic-gate lscf_service_export($2, $4); 1637c478bd9Sstevel@tonic-gate free($2); 1647c478bd9Sstevel@tonic-gate free($4); 1657c478bd9Sstevel@tonic-gate } 166*d3186a0eSjeanm | SCC_EXPORT error terminator { synerr(SCC_EXPORT); return(0); } 1677c478bd9Sstevel@tonic-gate 1687c478bd9Sstevel@tonic-gate archive_cmd : SCC_ARCHIVE terminator 1697c478bd9Sstevel@tonic-gate { 1707c478bd9Sstevel@tonic-gate lscf_archive(NULL); 1717c478bd9Sstevel@tonic-gate } 1727c478bd9Sstevel@tonic-gate | SCC_ARCHIVE SCS_REDIRECT SCV_WORD terminator 1737c478bd9Sstevel@tonic-gate { 1747c478bd9Sstevel@tonic-gate lscf_archive($3); 1757c478bd9Sstevel@tonic-gate free($3); 1767c478bd9Sstevel@tonic-gate } 177*d3186a0eSjeanm | SCC_ARCHIVE error terminator { synerr(SCC_ARCHIVE); return(0); } 1787c478bd9Sstevel@tonic-gate 1797c478bd9Sstevel@tonic-gate apply_cmd : SCC_APPLY SCV_WORD terminator 1807c478bd9Sstevel@tonic-gate { (void) engine_apply($2); free($2); } 181*d3186a0eSjeanm | SCC_APPLY error terminator { synerr(SCC_APPLY); return(0); } 1827c478bd9Sstevel@tonic-gate 1837c478bd9Sstevel@tonic-gate extract_cmd: SCC_EXTRACT terminator { lscf_profile_extract(NULL); } 1847c478bd9Sstevel@tonic-gate | SCC_EXTRACT SCS_REDIRECT SCV_WORD terminator 1857c478bd9Sstevel@tonic-gate { 1867c478bd9Sstevel@tonic-gate lscf_profile_extract($3); 1877c478bd9Sstevel@tonic-gate free($3); 1887c478bd9Sstevel@tonic-gate } 189*d3186a0eSjeanm | SCC_EXTRACT error terminator { synerr(SCC_EXTRACT); return(0); } 1907c478bd9Sstevel@tonic-gate 1917c478bd9Sstevel@tonic-gate repository_cmd : SCC_REPOSITORY SCV_WORD terminator 1927c478bd9Sstevel@tonic-gate { 1937c478bd9Sstevel@tonic-gate lscf_set_repository($2); 1947c478bd9Sstevel@tonic-gate free($2); 1957c478bd9Sstevel@tonic-gate } 196*d3186a0eSjeanm | SCC_REPOSITORY error terminator { synerr(SCC_REPOSITORY); return(0); } 1977c478bd9Sstevel@tonic-gate 1987c478bd9Sstevel@tonic-gate inventory_cmd : SCC_INVENTORY SCV_WORD terminator 1997c478bd9Sstevel@tonic-gate { lxml_inventory($2); free($2); } 200*d3186a0eSjeanm | SCC_INVENTORY error terminator { synerr(SCC_INVENTORY); return(0); } 2017c478bd9Sstevel@tonic-gate 2027c478bd9Sstevel@tonic-gate set_cmd : SCC_SET string_list terminator 2037c478bd9Sstevel@tonic-gate { 2047c478bd9Sstevel@tonic-gate string_list_t *slp; 2057c478bd9Sstevel@tonic-gate void *cookie = NULL; 2067c478bd9Sstevel@tonic-gate 2077c478bd9Sstevel@tonic-gate (void) engine_set($2); 2087c478bd9Sstevel@tonic-gate 2097c478bd9Sstevel@tonic-gate while ((slp = uu_list_teardown($2, &cookie)) != NULL) { 2107c478bd9Sstevel@tonic-gate free(slp->str); 2117c478bd9Sstevel@tonic-gate free(slp); 2127c478bd9Sstevel@tonic-gate } 2137c478bd9Sstevel@tonic-gate 2147c478bd9Sstevel@tonic-gate uu_list_destroy($2); 2157c478bd9Sstevel@tonic-gate } 216*d3186a0eSjeanm | SCC_SET error terminator { synerr(SCC_SET); return(0); } 2177c478bd9Sstevel@tonic-gate 2187c478bd9Sstevel@tonic-gate end_cmd : SCC_END terminator { exit(0); } 219*d3186a0eSjeanm | SCC_END error terminator { synerr (SCC_END); return(0); } 2207c478bd9Sstevel@tonic-gate 2217c478bd9Sstevel@tonic-gate help_cmd : SCC_HELP terminator { help(0); } 2227c478bd9Sstevel@tonic-gate | SCC_HELP command_token terminator { help($2); } 223*d3186a0eSjeanm | SCC_HELP error terminator { synerr(SCC_HELP); return(0); } 2247c478bd9Sstevel@tonic-gate 2257c478bd9Sstevel@tonic-gate list_cmd : SCC_LIST opt_word terminator { lscf_list($2); free($2); } 226*d3186a0eSjeanm | SCC_LIST error terminator { synerr(SCC_LIST); return(0); } 2277c478bd9Sstevel@tonic-gate 2287c478bd9Sstevel@tonic-gate add_cmd : SCC_ADD SCV_WORD terminator { lscf_add($2); free($2); } 229*d3186a0eSjeanm | SCC_ADD error terminator { synerr(SCC_ADD); return(0); } 2307c478bd9Sstevel@tonic-gate 2317c478bd9Sstevel@tonic-gate delete_cmd : SCC_DELETE SCV_WORD terminator 2327c478bd9Sstevel@tonic-gate { lscf_delete($2, 0); free($2); } 2337c478bd9Sstevel@tonic-gate | SCC_DELETE SCV_WORD SCV_WORD terminator 2347c478bd9Sstevel@tonic-gate { 2357c478bd9Sstevel@tonic-gate if (strcmp($2, "-f") == 0) { 2367c478bd9Sstevel@tonic-gate lscf_delete($3, 1); 2377c478bd9Sstevel@tonic-gate free($2); 2387c478bd9Sstevel@tonic-gate free($3); 2397c478bd9Sstevel@tonic-gate } else { 2407c478bd9Sstevel@tonic-gate synerr(SCC_DELETE); 241*d3186a0eSjeanm return(0); 2427c478bd9Sstevel@tonic-gate } 2437c478bd9Sstevel@tonic-gate } 244*d3186a0eSjeanm | SCC_DELETE error terminator { synerr(SCC_DELETE); return(0); } 2457c478bd9Sstevel@tonic-gate 2467c478bd9Sstevel@tonic-gate select_cmd : SCC_SELECT SCV_WORD terminator { lscf_select($2); free($2); } 247*d3186a0eSjeanm | SCC_SELECT error terminator { synerr(SCC_SELECT); return(0) ;} 2487c478bd9Sstevel@tonic-gate 2497c478bd9Sstevel@tonic-gate unselect_cmd : SCC_UNSELECT terminator { lscf_unselect(); } 250*d3186a0eSjeanm | SCC_UNSELECT error terminator { synerr(SCC_UNSELECT); return(0); } 2517c478bd9Sstevel@tonic-gate 2527c478bd9Sstevel@tonic-gate listpg_cmd : SCC_LISTPG opt_word terminator 2537c478bd9Sstevel@tonic-gate { lscf_listpg($2); free($2); } 254*d3186a0eSjeanm | SCC_LISTPG error terminator { synerr(SCC_LISTPG); return(0); } 2557c478bd9Sstevel@tonic-gate 2567c478bd9Sstevel@tonic-gate addpg_cmd : SCC_ADDPG SCV_WORD SCV_WORD opt_word terminator 2577c478bd9Sstevel@tonic-gate { 2587c478bd9Sstevel@tonic-gate (void) lscf_addpg($2, $3, $4); 2597c478bd9Sstevel@tonic-gate free($2); 2607c478bd9Sstevel@tonic-gate free($3); 2617c478bd9Sstevel@tonic-gate free($4); 2627c478bd9Sstevel@tonic-gate } 263*d3186a0eSjeanm | SCC_ADDPG error terminator { synerr(SCC_ADDPG); return(0); } 2647c478bd9Sstevel@tonic-gate 2657c478bd9Sstevel@tonic-gate delpg_cmd : SCC_DELPG SCV_WORD terminator 2667c478bd9Sstevel@tonic-gate { lscf_delpg($2); free($2); } 267*d3186a0eSjeanm | SCC_DELPG error terminator { synerr(SCC_DELPG); return(0); } 2687c478bd9Sstevel@tonic-gate 2697c478bd9Sstevel@tonic-gate listprop_cmd : SCC_LISTPROP opt_word terminator 2707c478bd9Sstevel@tonic-gate { lscf_listprop($2); free($2); } 271*d3186a0eSjeanm | SCC_LISTPROP error terminator { synerr(SCC_LISTPROP); return(0); } 2727c478bd9Sstevel@tonic-gate 2737c478bd9Sstevel@tonic-gate setprop_cmd : SCC_SETPROP SCV_WORD SCS_EQUALS string terminator 2747c478bd9Sstevel@tonic-gate { 2757c478bd9Sstevel@tonic-gate lscf_setprop($2, NULL, $4, NULL); 2767c478bd9Sstevel@tonic-gate free($2); 2777c478bd9Sstevel@tonic-gate free($4); 2787c478bd9Sstevel@tonic-gate } 2797c478bd9Sstevel@tonic-gate | SCC_SETPROP SCV_WORD SCS_EQUALS SCV_WORD string terminator 2807c478bd9Sstevel@tonic-gate { 2817c478bd9Sstevel@tonic-gate (void) lscf_setprop($2, $4, $5, NULL); 2827c478bd9Sstevel@tonic-gate free($2); 2837c478bd9Sstevel@tonic-gate free($4); 2847c478bd9Sstevel@tonic-gate free($5); 2857c478bd9Sstevel@tonic-gate } 2867c478bd9Sstevel@tonic-gate | SCC_SETPROP SCV_WORD SCS_EQUALS opt_word SCS_LPAREN 2877c478bd9Sstevel@tonic-gate multiline_string_list SCS_RPAREN terminator 2887c478bd9Sstevel@tonic-gate { 2897c478bd9Sstevel@tonic-gate string_list_t *slp; 2907c478bd9Sstevel@tonic-gate void *cookie = NULL; 2917c478bd9Sstevel@tonic-gate 2927c478bd9Sstevel@tonic-gate (void) lscf_setprop($2, $4, NULL, $6); 2937c478bd9Sstevel@tonic-gate 2947c478bd9Sstevel@tonic-gate free($2); 2957c478bd9Sstevel@tonic-gate free($4); 2967c478bd9Sstevel@tonic-gate 2977c478bd9Sstevel@tonic-gate while ((slp = uu_list_teardown($6, &cookie)) != NULL) { 2987c478bd9Sstevel@tonic-gate free(slp->str); 2997c478bd9Sstevel@tonic-gate free(slp); 3007c478bd9Sstevel@tonic-gate } 3017c478bd9Sstevel@tonic-gate 3027c478bd9Sstevel@tonic-gate uu_list_destroy($6); 3037c478bd9Sstevel@tonic-gate } 304*d3186a0eSjeanm | SCC_SETPROP error terminator { synerr(SCC_SETPROP); return(0); } 305*d3186a0eSjeanm | SCC_SETPROP error { synerr(SCC_SETPROP); return(0); } 3067c478bd9Sstevel@tonic-gate 3077c478bd9Sstevel@tonic-gate delprop_cmd : SCC_DELPROP SCV_WORD terminator 3087c478bd9Sstevel@tonic-gate { lscf_delprop($2); free($2); } 309*d3186a0eSjeanm | SCC_DELPROP error terminator { synerr(SCC_DELPROP); return(0); } 3107c478bd9Sstevel@tonic-gate 3117c478bd9Sstevel@tonic-gate editprop_cmd : SCC_EDITPROP terminator { lscf_editprop(); } 312*d3186a0eSjeanm | SCC_EDITPROP error terminator { synerr(SCC_EDITPROP); return(0); } 3137c478bd9Sstevel@tonic-gate 3147c478bd9Sstevel@tonic-gate addpropvalue_cmd : SCC_ADDPROPVALUE SCV_WORD string terminator 3157c478bd9Sstevel@tonic-gate { 3167c478bd9Sstevel@tonic-gate lscf_addpropvalue($2, NULL, $3); 3177c478bd9Sstevel@tonic-gate free($2); 3187c478bd9Sstevel@tonic-gate free($3); 3197c478bd9Sstevel@tonic-gate } 3207c478bd9Sstevel@tonic-gate | SCC_ADDPROPVALUE SCV_WORD string string terminator 3217c478bd9Sstevel@tonic-gate { 3227c478bd9Sstevel@tonic-gate (void) lscf_addpropvalue($2, $3, $4); 3237c478bd9Sstevel@tonic-gate free($2); 3247c478bd9Sstevel@tonic-gate free($3); 3257c478bd9Sstevel@tonic-gate free($4); 3267c478bd9Sstevel@tonic-gate } 327*d3186a0eSjeanm | SCC_ADDPROPVALUE error terminator { synerr(SCC_ADDPROPVALUE); return(0); } 3287c478bd9Sstevel@tonic-gate 3297c478bd9Sstevel@tonic-gate delpropvalue_cmd : SCC_DELPROPVALUE SCV_WORD string terminator 3307c478bd9Sstevel@tonic-gate { 3317c478bd9Sstevel@tonic-gate lscf_delpropvalue($2, $3, 0); 3327c478bd9Sstevel@tonic-gate free($2); 3337c478bd9Sstevel@tonic-gate free($3); 3347c478bd9Sstevel@tonic-gate } 335*d3186a0eSjeanm | SCC_DELPROPVALUE error terminator { synerr(SCC_DELPROPVALUE); return(0); } 3367c478bd9Sstevel@tonic-gate 3377c478bd9Sstevel@tonic-gate setenv_cmd : SCC_SETENV string_list terminator 3387c478bd9Sstevel@tonic-gate { 3397c478bd9Sstevel@tonic-gate string_list_t *slp; 3407c478bd9Sstevel@tonic-gate void *cookie = NULL; 3417c478bd9Sstevel@tonic-gate 342*d3186a0eSjeanm if (lscf_setenv($2, 0) == -2) { 3437c478bd9Sstevel@tonic-gate synerr(SCC_SETENV); 344*d3186a0eSjeanm return(0); 345*d3186a0eSjeanm } 3467c478bd9Sstevel@tonic-gate 3477c478bd9Sstevel@tonic-gate while ((slp = uu_list_teardown($2, &cookie)) != NULL) { 3487c478bd9Sstevel@tonic-gate free(slp->str); 3497c478bd9Sstevel@tonic-gate free(slp); 3507c478bd9Sstevel@tonic-gate } 3517c478bd9Sstevel@tonic-gate 3527c478bd9Sstevel@tonic-gate uu_list_destroy($2); 3537c478bd9Sstevel@tonic-gate } 354*d3186a0eSjeanm | SCC_SETENV error terminator { synerr(SCC_SETENV); return(0); } 3557c478bd9Sstevel@tonic-gate 3567c478bd9Sstevel@tonic-gate unsetenv_cmd : SCC_UNSETENV string_list terminator 3577c478bd9Sstevel@tonic-gate { 3587c478bd9Sstevel@tonic-gate string_list_t *slp; 3597c478bd9Sstevel@tonic-gate void *cookie = NULL; 3607c478bd9Sstevel@tonic-gate 361*d3186a0eSjeanm if (lscf_setenv($2, 1) == -2) { 3627c478bd9Sstevel@tonic-gate synerr(SCC_UNSETENV); 363*d3186a0eSjeanm return(0); 364*d3186a0eSjeanm } 3657c478bd9Sstevel@tonic-gate 3667c478bd9Sstevel@tonic-gate while ((slp = uu_list_teardown($2, &cookie)) != NULL) { 3677c478bd9Sstevel@tonic-gate free(slp->str); 3687c478bd9Sstevel@tonic-gate free(slp); 3697c478bd9Sstevel@tonic-gate } 3707c478bd9Sstevel@tonic-gate 3717c478bd9Sstevel@tonic-gate uu_list_destroy($2); 3727c478bd9Sstevel@tonic-gate } 373*d3186a0eSjeanm | SCC_UNSETENV error terminator { synerr(SCC_UNSETENV); return(0); } 3747c478bd9Sstevel@tonic-gate 3757c478bd9Sstevel@tonic-gate listsnap_cmd : SCC_LISTSNAP terminator { lscf_listsnap(); } 376*d3186a0eSjeanm | SCC_LISTSNAP error terminator { synerr(SCC_LISTSNAP); return(0); } 3777c478bd9Sstevel@tonic-gate 3787c478bd9Sstevel@tonic-gate selectsnap_cmd : SCC_SELECTSNAP opt_word terminator 3797c478bd9Sstevel@tonic-gate { lscf_selectsnap($2); free($2); } 3807c478bd9Sstevel@tonic-gate | SCC_SELECTSNAP error terminator 381*d3186a0eSjeanm { synerr(SCC_SELECTSNAP); return(0); } 3827c478bd9Sstevel@tonic-gate 3837c478bd9Sstevel@tonic-gate revert_cmd: SCC_REVERT opt_word terminator { lscf_revert($2); free ($2); } 384*d3186a0eSjeanm | SCC_REVERT error terminator { synerr(SCC_REVERT); return(0); } 3857c478bd9Sstevel@tonic-gate 3867c478bd9Sstevel@tonic-gate 3877c478bd9Sstevel@tonic-gate terminator : SCS_NEWLINE 3887c478bd9Sstevel@tonic-gate 3897c478bd9Sstevel@tonic-gate string_list : 3907c478bd9Sstevel@tonic-gate { 3917c478bd9Sstevel@tonic-gate $$ = uu_list_create(string_pool, NULL, 0); 3927c478bd9Sstevel@tonic-gate if ($$ == NULL) 3937c478bd9Sstevel@tonic-gate uu_die(gettext("Out of memory\n")); 3947c478bd9Sstevel@tonic-gate } 3957c478bd9Sstevel@tonic-gate | string_list string 3967c478bd9Sstevel@tonic-gate { 3977c478bd9Sstevel@tonic-gate string_list_t *slp; 3987c478bd9Sstevel@tonic-gate 3997c478bd9Sstevel@tonic-gate slp = safe_malloc(sizeof (*slp)); 4007c478bd9Sstevel@tonic-gate 4017c478bd9Sstevel@tonic-gate slp->str = $2; 4027c478bd9Sstevel@tonic-gate uu_list_node_init(slp, &slp->node, string_pool); 4037c478bd9Sstevel@tonic-gate uu_list_append($1, slp); 4047c478bd9Sstevel@tonic-gate $$ = $1; 4057c478bd9Sstevel@tonic-gate } 4067c478bd9Sstevel@tonic-gate 4077c478bd9Sstevel@tonic-gate multiline_string_list : string_list 4087c478bd9Sstevel@tonic-gate { 4097c478bd9Sstevel@tonic-gate $$ = $1; 4107c478bd9Sstevel@tonic-gate } 4117c478bd9Sstevel@tonic-gate | multiline_string_list SCS_NEWLINE string_list 4127c478bd9Sstevel@tonic-gate { 4137c478bd9Sstevel@tonic-gate void *cookie = NULL; 4147c478bd9Sstevel@tonic-gate string_list_t *slp; 4157c478bd9Sstevel@tonic-gate 4167c478bd9Sstevel@tonic-gate /* Append $3 to $1. */ 4177c478bd9Sstevel@tonic-gate while ((slp = uu_list_teardown($3, &cookie)) != NULL) 4187c478bd9Sstevel@tonic-gate uu_list_append($1, slp); 4197c478bd9Sstevel@tonic-gate 4207c478bd9Sstevel@tonic-gate uu_list_destroy($3); 4217c478bd9Sstevel@tonic-gate } 4227c478bd9Sstevel@tonic-gate 4237c478bd9Sstevel@tonic-gate string : SCV_WORD { $$ = $1; } 4247c478bd9Sstevel@tonic-gate | SCV_STRING { $$ = $1; } 4257c478bd9Sstevel@tonic-gate 4267c478bd9Sstevel@tonic-gate opt_word : { $$ = NULL; } 4277c478bd9Sstevel@tonic-gate | SCV_WORD { $$ = $1; } 4287c478bd9Sstevel@tonic-gate 4297c478bd9Sstevel@tonic-gate command_token : SCC_VALIDATE { $$ = SCC_VALIDATE; } 4307c478bd9Sstevel@tonic-gate | SCC_IMPORT { $$ = SCC_IMPORT; } 4317c478bd9Sstevel@tonic-gate | SCC_EXPORT { $$ = SCC_EXPORT; } 4327c478bd9Sstevel@tonic-gate | SCC_APPLY { $$ = SCC_APPLY; } 4337c478bd9Sstevel@tonic-gate | SCC_EXTRACT { $$ = SCC_EXTRACT; } 4347c478bd9Sstevel@tonic-gate | SCC_REPOSITORY { $$ = SCC_REPOSITORY; } 4357c478bd9Sstevel@tonic-gate | SCC_ARCHIVE { $$ = SCC_ARCHIVE; } 4367c478bd9Sstevel@tonic-gate | SCC_INVENTORY { $$ = SCC_INVENTORY; } 4377c478bd9Sstevel@tonic-gate | SCC_SET { $$ = SCC_SET; } 4387c478bd9Sstevel@tonic-gate | SCC_END { $$ = SCC_END; } 4397c478bd9Sstevel@tonic-gate | SCC_HELP { $$ = SCC_HELP; } 4407c478bd9Sstevel@tonic-gate | SCC_LIST { $$ = SCC_LIST; } 4417c478bd9Sstevel@tonic-gate | SCC_ADD { $$ = SCC_ADD; } 4427c478bd9Sstevel@tonic-gate | SCC_DELETE { $$ = SCC_DELETE; } 4437c478bd9Sstevel@tonic-gate | SCC_SELECT { $$ = SCC_SELECT; } 4447c478bd9Sstevel@tonic-gate | SCC_UNSELECT { $$ = SCC_UNSELECT; } 4457c478bd9Sstevel@tonic-gate | SCC_LISTPG { $$ = SCC_LISTPG; } 4467c478bd9Sstevel@tonic-gate | SCC_ADDPG { $$ = SCC_ADDPG; } 4477c478bd9Sstevel@tonic-gate | SCC_DELPG { $$ = SCC_DELPG; } 4487c478bd9Sstevel@tonic-gate | SCC_LISTPROP { $$ = SCC_LISTPROP; } 4497c478bd9Sstevel@tonic-gate | SCC_SETPROP { $$ = SCC_SETPROP; } 4507c478bd9Sstevel@tonic-gate | SCC_DELPROP { $$ = SCC_DELPROP; } 4517c478bd9Sstevel@tonic-gate | SCC_EDITPROP { $$ = SCC_EDITPROP; } 4527c478bd9Sstevel@tonic-gate | SCC_ADDPROPVALUE { $$ = SCC_ADDPROPVALUE; } 4537c478bd9Sstevel@tonic-gate | SCC_DELPROPVALUE { $$ = SCC_DELPROPVALUE; } 4547c478bd9Sstevel@tonic-gate | SCC_SETENV { $$ = SCC_SETENV; } 4557c478bd9Sstevel@tonic-gate | SCC_UNSETENV { $$ = SCC_UNSETENV; } 4567c478bd9Sstevel@tonic-gate | SCC_LISTSNAP { $$ = SCC_LISTSNAP; } 4577c478bd9Sstevel@tonic-gate | SCC_SELECTSNAP { $$ = SCC_SELECTSNAP; } 4587c478bd9Sstevel@tonic-gate | SCC_REVERT { $$ = SCC_REVERT; } 459