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 */ 22*3eae19d9Swesolows 23db11989eSpjung /* 24db11989eSpjung * Copyright 2007 Sun Microsystems, Inc. All rights reserved. 257c478bd9Sstevel@tonic-gate * Use is subject to license terms. 267c478bd9Sstevel@tonic-gate */ 277c478bd9Sstevel@tonic-gate 287c478bd9Sstevel@tonic-gate #pragma ident "%Z%%M% %I% %E% SMI" 297c478bd9Sstevel@tonic-gate 307c478bd9Sstevel@tonic-gate #include <libintl.h> 317c478bd9Sstevel@tonic-gate 327c478bd9Sstevel@tonic-gate #include "svccfg.h" 337c478bd9Sstevel@tonic-gate 347c478bd9Sstevel@tonic-gate uu_list_pool_t *string_pool; 357c478bd9Sstevel@tonic-gate 367c478bd9Sstevel@tonic-gate %} 377c478bd9Sstevel@tonic-gate 387c478bd9Sstevel@tonic-gate %union { 397c478bd9Sstevel@tonic-gate int tok; 407c478bd9Sstevel@tonic-gate char *str; 417c478bd9Sstevel@tonic-gate uu_list_t *uul; 427c478bd9Sstevel@tonic-gate } 437c478bd9Sstevel@tonic-gate 447c478bd9Sstevel@tonic-gate %start commands 457c478bd9Sstevel@tonic-gate 467c478bd9Sstevel@tonic-gate %token SCC_VALIDATE SCC_IMPORT SCC_EXPORT SCC_ARCHIVE SCC_APPLY SCC_EXTRACT 47*3eae19d9Swesolows %token SCC_REPOSITORY SCC_INVENTORY SCC_SET SCC_END SCC_HELP SCC_RESTORE 487c478bd9Sstevel@tonic-gate %token SCC_LIST SCC_ADD SCC_DELETE SCC_SELECT SCC_UNSELECT 497c478bd9Sstevel@tonic-gate %token SCC_LISTPG SCC_ADDPG SCC_DELPG 507c478bd9Sstevel@tonic-gate %token SCC_LISTPROP SCC_SETPROP SCC_DELPROP SCC_EDITPROP 517c478bd9Sstevel@tonic-gate %token SCC_ADDPROPVALUE SCC_DELPROPVALUE SCC_SETENV SCC_UNSETENV 527c478bd9Sstevel@tonic-gate %token SCC_LISTSNAP SCC_SELECTSNAP SCC_REVERT 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 79*3eae19d9Swesolows | 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 957c478bd9Sstevel@tonic-gate | listprop_cmd 967c478bd9Sstevel@tonic-gate | setprop_cmd 977c478bd9Sstevel@tonic-gate | delprop_cmd 987c478bd9Sstevel@tonic-gate | editprop_cmd 997c478bd9Sstevel@tonic-gate | addpropvalue_cmd 1007c478bd9Sstevel@tonic-gate | delpropvalue_cmd 1017c478bd9Sstevel@tonic-gate | setenv_cmd 1027c478bd9Sstevel@tonic-gate | unsetenv_cmd 1037c478bd9Sstevel@tonic-gate | listsnap_cmd 1047c478bd9Sstevel@tonic-gate | selectsnap_cmd 1057c478bd9Sstevel@tonic-gate | revert_cmd 1067c478bd9Sstevel@tonic-gate | unknown_cmd 1077c478bd9Sstevel@tonic-gate | error terminator { semerr(gettext("Syntax error.\n")); } 1087c478bd9Sstevel@tonic-gate 1097c478bd9Sstevel@tonic-gate unknown_cmd : SCV_WORD terminator 1107c478bd9Sstevel@tonic-gate { 1117c478bd9Sstevel@tonic-gate semerr(gettext("Unknown command \"%s\".\n"), $1); 1127c478bd9Sstevel@tonic-gate free($1); 1137c478bd9Sstevel@tonic-gate } 1147c478bd9Sstevel@tonic-gate | SCV_WORD string_list terminator 1157c478bd9Sstevel@tonic-gate { 1167c478bd9Sstevel@tonic-gate string_list_t *slp; 1177c478bd9Sstevel@tonic-gate void *cookie = NULL; 1187c478bd9Sstevel@tonic-gate 1197c478bd9Sstevel@tonic-gate semerr(gettext("Unknown command \"%s\".\n"), $1); 1207c478bd9Sstevel@tonic-gate 1217c478bd9Sstevel@tonic-gate while ((slp = uu_list_teardown($2, &cookie)) != NULL) { 1227c478bd9Sstevel@tonic-gate free(slp->str); 1237c478bd9Sstevel@tonic-gate free(slp); 1247c478bd9Sstevel@tonic-gate } 1257c478bd9Sstevel@tonic-gate 1267c478bd9Sstevel@tonic-gate uu_list_destroy($2); 1277c478bd9Sstevel@tonic-gate free($1); 1287c478bd9Sstevel@tonic-gate } 1297c478bd9Sstevel@tonic-gate 1307c478bd9Sstevel@tonic-gate validate_cmd : SCC_VALIDATE SCV_WORD terminator 1317c478bd9Sstevel@tonic-gate { 1327c478bd9Sstevel@tonic-gate bundle_t *b = internal_bundle_new(); 133*3eae19d9Swesolows lxml_get_bundle_file(b, $2, SVCCFG_OP_IMPORT); 1347c478bd9Sstevel@tonic-gate (void) internal_bundle_free(b); 1357c478bd9Sstevel@tonic-gate free($2); 1367c478bd9Sstevel@tonic-gate } 137d3186a0eSjeanm | SCC_VALIDATE error terminator { synerr(SCC_VALIDATE); return(0); } 1387c478bd9Sstevel@tonic-gate 1397c478bd9Sstevel@tonic-gate import_cmd : SCC_IMPORT string_list terminator 1407c478bd9Sstevel@tonic-gate { 1417c478bd9Sstevel@tonic-gate string_list_t *slp; 1427c478bd9Sstevel@tonic-gate void *cookie = NULL; 1437c478bd9Sstevel@tonic-gate 144d3186a0eSjeanm if (engine_import($2) == -2) { 1457c478bd9Sstevel@tonic-gate synerr(SCC_IMPORT); 146d3186a0eSjeanm return(0); 147d3186a0eSjeanm } 1487c478bd9Sstevel@tonic-gate 1497c478bd9Sstevel@tonic-gate while ((slp = uu_list_teardown($2, &cookie)) != NULL) { 1507c478bd9Sstevel@tonic-gate free(slp->str); 1517c478bd9Sstevel@tonic-gate free(slp); 1527c478bd9Sstevel@tonic-gate } 1537c478bd9Sstevel@tonic-gate 1547c478bd9Sstevel@tonic-gate uu_list_destroy($2); 1557c478bd9Sstevel@tonic-gate } 156d3186a0eSjeanm | SCC_IMPORT error terminator { synerr(SCC_IMPORT); return(0); } 1577c478bd9Sstevel@tonic-gate 1587c478bd9Sstevel@tonic-gate export_cmd : SCC_EXPORT SCV_WORD terminator 1597c478bd9Sstevel@tonic-gate { 160*3eae19d9Swesolows lscf_service_export($2, NULL, 0); 1617c478bd9Sstevel@tonic-gate free($2); 1627c478bd9Sstevel@tonic-gate } 1637c478bd9Sstevel@tonic-gate | SCC_EXPORT SCV_WORD SCS_REDIRECT SCV_WORD terminator 1647c478bd9Sstevel@tonic-gate { 165*3eae19d9Swesolows lscf_service_export($2, $4, 0); 1667c478bd9Sstevel@tonic-gate free($2); 1677c478bd9Sstevel@tonic-gate free($4); 1687c478bd9Sstevel@tonic-gate } 169*3eae19d9Swesolows | SCC_EXPORT SCV_WORD SCV_WORD terminator 170*3eae19d9Swesolows { 171*3eae19d9Swesolows if (strcmp($2, "-a") == 0) { 172*3eae19d9Swesolows lscf_service_export($3, NULL, SCE_ALL_VALUES); 173*3eae19d9Swesolows free($2); 174*3eae19d9Swesolows free($3); 175*3eae19d9Swesolows } else { 176*3eae19d9Swesolows synerr(SCC_EXPORT); 177*3eae19d9Swesolows free($2); 178*3eae19d9Swesolows free($3); 179*3eae19d9Swesolows return (0); 180*3eae19d9Swesolows } 181*3eae19d9Swesolows } 182*3eae19d9Swesolows | SCC_EXPORT SCV_WORD SCV_WORD SCS_REDIRECT SCV_WORD terminator 183*3eae19d9Swesolows { 184*3eae19d9Swesolows if (strcmp($2, "-a") == 0) { 185*3eae19d9Swesolows lscf_service_export($3, $5, SCE_ALL_VALUES); 186*3eae19d9Swesolows free($2); 187*3eae19d9Swesolows free($3); 188*3eae19d9Swesolows free($5); 189*3eae19d9Swesolows } else { 190*3eae19d9Swesolows synerr(SCC_EXPORT); 191*3eae19d9Swesolows free($2); 192*3eae19d9Swesolows free($3); 193*3eae19d9Swesolows free($5); 194*3eae19d9Swesolows return (0); 195*3eae19d9Swesolows } 196*3eae19d9Swesolows } 197d3186a0eSjeanm | SCC_EXPORT error terminator { synerr(SCC_EXPORT); return(0); } 1987c478bd9Sstevel@tonic-gate 1997c478bd9Sstevel@tonic-gate archive_cmd : SCC_ARCHIVE terminator 2007c478bd9Sstevel@tonic-gate { 201*3eae19d9Swesolows lscf_archive(NULL, 0); 202*3eae19d9Swesolows } 203*3eae19d9Swesolows | SCC_ARCHIVE SCV_WORD terminator 204*3eae19d9Swesolows { 205*3eae19d9Swesolows if (strcmp($2, "-a") == 0) { 206*3eae19d9Swesolows lscf_archive(NULL, SCE_ALL_VALUES); 207*3eae19d9Swesolows free($2); 208*3eae19d9Swesolows } else { 209*3eae19d9Swesolows synerr(SCC_ARCHIVE); 210*3eae19d9Swesolows free($2); 211*3eae19d9Swesolows return (0); 212*3eae19d9Swesolows } 2137c478bd9Sstevel@tonic-gate } 2147c478bd9Sstevel@tonic-gate | SCC_ARCHIVE SCS_REDIRECT SCV_WORD terminator 2157c478bd9Sstevel@tonic-gate { 216*3eae19d9Swesolows lscf_archive($3, 0); 2177c478bd9Sstevel@tonic-gate free($3); 2187c478bd9Sstevel@tonic-gate } 219*3eae19d9Swesolows | SCC_ARCHIVE SCV_WORD SCS_REDIRECT SCV_WORD terminator 220*3eae19d9Swesolows { 221*3eae19d9Swesolows if (strcmp($2, "-a") == 0) { 222*3eae19d9Swesolows lscf_archive($4, SCE_ALL_VALUES); 223*3eae19d9Swesolows free($2); 224*3eae19d9Swesolows free($4); 225*3eae19d9Swesolows } else { 226*3eae19d9Swesolows synerr(SCC_ARCHIVE); 227*3eae19d9Swesolows free($2); 228*3eae19d9Swesolows free($4); 229*3eae19d9Swesolows return (0); 230*3eae19d9Swesolows } 231*3eae19d9Swesolows } 232d3186a0eSjeanm | SCC_ARCHIVE error terminator { synerr(SCC_ARCHIVE); return(0); } 2337c478bd9Sstevel@tonic-gate 234*3eae19d9Swesolows restore_cmd : SCC_RESTORE SCV_WORD terminator 235*3eae19d9Swesolows { 236*3eae19d9Swesolows (void) engine_restore($2); 237*3eae19d9Swesolows free($2); 238*3eae19d9Swesolows } 239*3eae19d9Swesolows | SCC_RESTORE error terminator { synerr(SCC_RESTORE); return(0); } 240*3eae19d9Swesolows 2417c478bd9Sstevel@tonic-gate apply_cmd : SCC_APPLY SCV_WORD terminator 2427c478bd9Sstevel@tonic-gate { (void) engine_apply($2); free($2); } 243d3186a0eSjeanm | SCC_APPLY error terminator { synerr(SCC_APPLY); return(0); } 2447c478bd9Sstevel@tonic-gate 2457c478bd9Sstevel@tonic-gate extract_cmd: SCC_EXTRACT terminator { lscf_profile_extract(NULL); } 2467c478bd9Sstevel@tonic-gate | SCC_EXTRACT SCS_REDIRECT SCV_WORD terminator 2477c478bd9Sstevel@tonic-gate { 2487c478bd9Sstevel@tonic-gate lscf_profile_extract($3); 2497c478bd9Sstevel@tonic-gate free($3); 2507c478bd9Sstevel@tonic-gate } 251d3186a0eSjeanm | SCC_EXTRACT error terminator { synerr(SCC_EXTRACT); return(0); } 2527c478bd9Sstevel@tonic-gate 2537c478bd9Sstevel@tonic-gate repository_cmd: SCC_REPOSITORY SCV_WORD terminator 2547c478bd9Sstevel@tonic-gate { 255db11989eSpjung if (strcmp($2, "-f") == 0) { 256db11989eSpjung synerr(SCC_REPOSITORY); 257db11989eSpjung return(0); 258db11989eSpjung } 259db11989eSpjung lscf_set_repository($2, 0); 2607c478bd9Sstevel@tonic-gate free($2); 2617c478bd9Sstevel@tonic-gate } 262db11989eSpjung | SCC_REPOSITORY SCV_WORD SCV_WORD terminator 263db11989eSpjung { 264db11989eSpjung if (strcmp($2, "-f") == 0) { 265db11989eSpjung lscf_set_repository($3, 1); 266db11989eSpjung free($2); 267db11989eSpjung free($3); 268db11989eSpjung } else { 269db11989eSpjung synerr(SCC_REPOSITORY); 270db11989eSpjung return(0); 271db11989eSpjung } 272db11989eSpjung } 273d3186a0eSjeanm | SCC_REPOSITORY error terminator { synerr(SCC_REPOSITORY); return(0); } 2747c478bd9Sstevel@tonic-gate 2757c478bd9Sstevel@tonic-gate inventory_cmd : SCC_INVENTORY SCV_WORD terminator 2767c478bd9Sstevel@tonic-gate { lxml_inventory($2); free($2); } 277d3186a0eSjeanm | SCC_INVENTORY error terminator { synerr(SCC_INVENTORY); return(0); } 2787c478bd9Sstevel@tonic-gate 2797c478bd9Sstevel@tonic-gate set_cmd : SCC_SET string_list terminator 2807c478bd9Sstevel@tonic-gate { 2817c478bd9Sstevel@tonic-gate string_list_t *slp; 2827c478bd9Sstevel@tonic-gate void *cookie = NULL; 2837c478bd9Sstevel@tonic-gate 2847c478bd9Sstevel@tonic-gate (void) engine_set($2); 2857c478bd9Sstevel@tonic-gate 2867c478bd9Sstevel@tonic-gate while ((slp = uu_list_teardown($2, &cookie)) != NULL) { 2877c478bd9Sstevel@tonic-gate free(slp->str); 2887c478bd9Sstevel@tonic-gate free(slp); 2897c478bd9Sstevel@tonic-gate } 2907c478bd9Sstevel@tonic-gate 2917c478bd9Sstevel@tonic-gate uu_list_destroy($2); 2927c478bd9Sstevel@tonic-gate } 293d3186a0eSjeanm | SCC_SET error terminator { synerr(SCC_SET); return(0); } 2947c478bd9Sstevel@tonic-gate 2957c478bd9Sstevel@tonic-gate end_cmd : SCC_END terminator { exit(0); } 296d3186a0eSjeanm | SCC_END error terminator { synerr (SCC_END); return(0); } 2977c478bd9Sstevel@tonic-gate 2987c478bd9Sstevel@tonic-gate help_cmd : SCC_HELP terminator { help(0); } 2997c478bd9Sstevel@tonic-gate | SCC_HELP command_token terminator { help($2); } 300d3186a0eSjeanm | SCC_HELP error terminator { synerr(SCC_HELP); return(0); } 3017c478bd9Sstevel@tonic-gate 3027c478bd9Sstevel@tonic-gate list_cmd : SCC_LIST opt_word terminator { lscf_list($2); free($2); } 303d3186a0eSjeanm | SCC_LIST error terminator { synerr(SCC_LIST); return(0); } 3047c478bd9Sstevel@tonic-gate 3057c478bd9Sstevel@tonic-gate add_cmd : SCC_ADD SCV_WORD terminator { lscf_add($2); free($2); } 306d3186a0eSjeanm | SCC_ADD error terminator { synerr(SCC_ADD); return(0); } 3077c478bd9Sstevel@tonic-gate 3087c478bd9Sstevel@tonic-gate delete_cmd : SCC_DELETE SCV_WORD terminator 3097c478bd9Sstevel@tonic-gate { lscf_delete($2, 0); free($2); } 3107c478bd9Sstevel@tonic-gate | SCC_DELETE SCV_WORD SCV_WORD terminator 3117c478bd9Sstevel@tonic-gate { 3127c478bd9Sstevel@tonic-gate if (strcmp($2, "-f") == 0) { 3137c478bd9Sstevel@tonic-gate lscf_delete($3, 1); 3147c478bd9Sstevel@tonic-gate free($2); 3157c478bd9Sstevel@tonic-gate free($3); 3167c478bd9Sstevel@tonic-gate } else { 3177c478bd9Sstevel@tonic-gate synerr(SCC_DELETE); 318*3eae19d9Swesolows free($2); 319*3eae19d9Swesolows free($3); 320d3186a0eSjeanm return(0); 3217c478bd9Sstevel@tonic-gate } 3227c478bd9Sstevel@tonic-gate } 323d3186a0eSjeanm | SCC_DELETE error terminator { synerr(SCC_DELETE); return(0); } 3247c478bd9Sstevel@tonic-gate 3257c478bd9Sstevel@tonic-gate select_cmd : SCC_SELECT SCV_WORD terminator { lscf_select($2); free($2); } 326d3186a0eSjeanm | SCC_SELECT error terminator { synerr(SCC_SELECT); return(0) ;} 3277c478bd9Sstevel@tonic-gate 3287c478bd9Sstevel@tonic-gate unselect_cmd : SCC_UNSELECT terminator { lscf_unselect(); } 329d3186a0eSjeanm | SCC_UNSELECT error terminator { synerr(SCC_UNSELECT); return(0); } 3307c478bd9Sstevel@tonic-gate 3317c478bd9Sstevel@tonic-gate listpg_cmd : SCC_LISTPG opt_word terminator 3327c478bd9Sstevel@tonic-gate { lscf_listpg($2); free($2); } 333d3186a0eSjeanm | SCC_LISTPG error terminator { synerr(SCC_LISTPG); return(0); } 3347c478bd9Sstevel@tonic-gate 3357c478bd9Sstevel@tonic-gate addpg_cmd : SCC_ADDPG SCV_WORD SCV_WORD opt_word terminator 3367c478bd9Sstevel@tonic-gate { 3377c478bd9Sstevel@tonic-gate (void) lscf_addpg($2, $3, $4); 3387c478bd9Sstevel@tonic-gate free($2); 3397c478bd9Sstevel@tonic-gate free($3); 3407c478bd9Sstevel@tonic-gate free($4); 3417c478bd9Sstevel@tonic-gate } 342d3186a0eSjeanm | SCC_ADDPG error terminator { synerr(SCC_ADDPG); return(0); } 3437c478bd9Sstevel@tonic-gate 3447c478bd9Sstevel@tonic-gate delpg_cmd : SCC_DELPG SCV_WORD terminator 3457c478bd9Sstevel@tonic-gate { lscf_delpg($2); free($2); } 346d3186a0eSjeanm | SCC_DELPG error terminator { synerr(SCC_DELPG); return(0); } 3477c478bd9Sstevel@tonic-gate 3487c478bd9Sstevel@tonic-gate listprop_cmd : SCC_LISTPROP opt_word terminator 3497c478bd9Sstevel@tonic-gate { lscf_listprop($2); free($2); } 350d3186a0eSjeanm | SCC_LISTPROP error terminator { synerr(SCC_LISTPROP); return(0); } 3517c478bd9Sstevel@tonic-gate 3527c478bd9Sstevel@tonic-gate setprop_cmd : SCC_SETPROP SCV_WORD SCS_EQUALS string terminator 3537c478bd9Sstevel@tonic-gate { 3547c478bd9Sstevel@tonic-gate lscf_setprop($2, NULL, $4, NULL); 3557c478bd9Sstevel@tonic-gate free($2); 3567c478bd9Sstevel@tonic-gate free($4); 3577c478bd9Sstevel@tonic-gate } 3587c478bd9Sstevel@tonic-gate | SCC_SETPROP SCV_WORD SCS_EQUALS SCV_WORD string terminator 3597c478bd9Sstevel@tonic-gate { 3607c478bd9Sstevel@tonic-gate (void) lscf_setprop($2, $4, $5, NULL); 3617c478bd9Sstevel@tonic-gate free($2); 3627c478bd9Sstevel@tonic-gate free($4); 3637c478bd9Sstevel@tonic-gate free($5); 3647c478bd9Sstevel@tonic-gate } 3657c478bd9Sstevel@tonic-gate | SCC_SETPROP SCV_WORD SCS_EQUALS opt_word SCS_LPAREN 3667c478bd9Sstevel@tonic-gate multiline_string_list SCS_RPAREN terminator 3677c478bd9Sstevel@tonic-gate { 3687c478bd9Sstevel@tonic-gate string_list_t *slp; 3697c478bd9Sstevel@tonic-gate void *cookie = NULL; 3707c478bd9Sstevel@tonic-gate 3717c478bd9Sstevel@tonic-gate (void) lscf_setprop($2, $4, NULL, $6); 3727c478bd9Sstevel@tonic-gate 3737c478bd9Sstevel@tonic-gate free($2); 3747c478bd9Sstevel@tonic-gate free($4); 3757c478bd9Sstevel@tonic-gate 3767c478bd9Sstevel@tonic-gate while ((slp = uu_list_teardown($6, &cookie)) != NULL) { 3777c478bd9Sstevel@tonic-gate free(slp->str); 3787c478bd9Sstevel@tonic-gate free(slp); 3797c478bd9Sstevel@tonic-gate } 3807c478bd9Sstevel@tonic-gate 3817c478bd9Sstevel@tonic-gate uu_list_destroy($6); 3827c478bd9Sstevel@tonic-gate } 383d3186a0eSjeanm | SCC_SETPROP error terminator { synerr(SCC_SETPROP); return(0); } 384d3186a0eSjeanm | SCC_SETPROP error { synerr(SCC_SETPROP); return(0); } 3857c478bd9Sstevel@tonic-gate 3867c478bd9Sstevel@tonic-gate delprop_cmd : SCC_DELPROP SCV_WORD terminator 3877c478bd9Sstevel@tonic-gate { lscf_delprop($2); free($2); } 388d3186a0eSjeanm | SCC_DELPROP error terminator { synerr(SCC_DELPROP); return(0); } 3897c478bd9Sstevel@tonic-gate 3907c478bd9Sstevel@tonic-gate editprop_cmd : SCC_EDITPROP terminator { lscf_editprop(); } 391d3186a0eSjeanm | SCC_EDITPROP error terminator { synerr(SCC_EDITPROP); return(0); } 3927c478bd9Sstevel@tonic-gate 3937c478bd9Sstevel@tonic-gate addpropvalue_cmd : SCC_ADDPROPVALUE SCV_WORD string terminator 3947c478bd9Sstevel@tonic-gate { 3957c478bd9Sstevel@tonic-gate lscf_addpropvalue($2, NULL, $3); 3967c478bd9Sstevel@tonic-gate free($2); 3977c478bd9Sstevel@tonic-gate free($3); 3987c478bd9Sstevel@tonic-gate } 3997c478bd9Sstevel@tonic-gate | SCC_ADDPROPVALUE SCV_WORD string string terminator 4007c478bd9Sstevel@tonic-gate { 4017c478bd9Sstevel@tonic-gate (void) lscf_addpropvalue($2, $3, $4); 4027c478bd9Sstevel@tonic-gate free($2); 4037c478bd9Sstevel@tonic-gate free($3); 4047c478bd9Sstevel@tonic-gate free($4); 4057c478bd9Sstevel@tonic-gate } 406d3186a0eSjeanm | SCC_ADDPROPVALUE error terminator { synerr(SCC_ADDPROPVALUE); return(0); } 4077c478bd9Sstevel@tonic-gate 4087c478bd9Sstevel@tonic-gate delpropvalue_cmd : SCC_DELPROPVALUE SCV_WORD string terminator 4097c478bd9Sstevel@tonic-gate { 4107c478bd9Sstevel@tonic-gate lscf_delpropvalue($2, $3, 0); 4117c478bd9Sstevel@tonic-gate free($2); 4127c478bd9Sstevel@tonic-gate free($3); 4137c478bd9Sstevel@tonic-gate } 414d3186a0eSjeanm | SCC_DELPROPVALUE error terminator { synerr(SCC_DELPROPVALUE); return(0); } 4157c478bd9Sstevel@tonic-gate 4167c478bd9Sstevel@tonic-gate setenv_cmd : SCC_SETENV string_list terminator 4177c478bd9Sstevel@tonic-gate { 4187c478bd9Sstevel@tonic-gate string_list_t *slp; 4197c478bd9Sstevel@tonic-gate void *cookie = NULL; 4207c478bd9Sstevel@tonic-gate 421d3186a0eSjeanm if (lscf_setenv($2, 0) == -2) { 4227c478bd9Sstevel@tonic-gate synerr(SCC_SETENV); 423d3186a0eSjeanm return(0); 424d3186a0eSjeanm } 4257c478bd9Sstevel@tonic-gate 4267c478bd9Sstevel@tonic-gate while ((slp = uu_list_teardown($2, &cookie)) != NULL) { 4277c478bd9Sstevel@tonic-gate free(slp->str); 4287c478bd9Sstevel@tonic-gate free(slp); 4297c478bd9Sstevel@tonic-gate } 4307c478bd9Sstevel@tonic-gate 4317c478bd9Sstevel@tonic-gate uu_list_destroy($2); 4327c478bd9Sstevel@tonic-gate } 433d3186a0eSjeanm | SCC_SETENV error terminator { synerr(SCC_SETENV); return(0); } 4347c478bd9Sstevel@tonic-gate 4357c478bd9Sstevel@tonic-gate unsetenv_cmd : SCC_UNSETENV string_list terminator 4367c478bd9Sstevel@tonic-gate { 4377c478bd9Sstevel@tonic-gate string_list_t *slp; 4387c478bd9Sstevel@tonic-gate void *cookie = NULL; 4397c478bd9Sstevel@tonic-gate 440d3186a0eSjeanm if (lscf_setenv($2, 1) == -2) { 4417c478bd9Sstevel@tonic-gate synerr(SCC_UNSETENV); 442d3186a0eSjeanm return(0); 443d3186a0eSjeanm } 4447c478bd9Sstevel@tonic-gate 4457c478bd9Sstevel@tonic-gate while ((slp = uu_list_teardown($2, &cookie)) != NULL) { 4467c478bd9Sstevel@tonic-gate free(slp->str); 4477c478bd9Sstevel@tonic-gate free(slp); 4487c478bd9Sstevel@tonic-gate } 4497c478bd9Sstevel@tonic-gate 4507c478bd9Sstevel@tonic-gate uu_list_destroy($2); 4517c478bd9Sstevel@tonic-gate } 452d3186a0eSjeanm | SCC_UNSETENV error terminator { synerr(SCC_UNSETENV); return(0); } 4537c478bd9Sstevel@tonic-gate 4547c478bd9Sstevel@tonic-gate listsnap_cmd : SCC_LISTSNAP terminator { lscf_listsnap(); } 455d3186a0eSjeanm | SCC_LISTSNAP error terminator { synerr(SCC_LISTSNAP); return(0); } 4567c478bd9Sstevel@tonic-gate 4577c478bd9Sstevel@tonic-gate selectsnap_cmd : SCC_SELECTSNAP opt_word terminator 4587c478bd9Sstevel@tonic-gate { lscf_selectsnap($2); free($2); } 4597c478bd9Sstevel@tonic-gate | SCC_SELECTSNAP error terminator 460d3186a0eSjeanm { synerr(SCC_SELECTSNAP); return(0); } 4617c478bd9Sstevel@tonic-gate 4627c478bd9Sstevel@tonic-gate revert_cmd: SCC_REVERT opt_word terminator { lscf_revert($2); free ($2); } 463d3186a0eSjeanm | SCC_REVERT error terminator { synerr(SCC_REVERT); return(0); } 4647c478bd9Sstevel@tonic-gate 4657c478bd9Sstevel@tonic-gate 4667c478bd9Sstevel@tonic-gate terminator : SCS_NEWLINE 4677c478bd9Sstevel@tonic-gate 4687c478bd9Sstevel@tonic-gate string_list : 4697c478bd9Sstevel@tonic-gate { 4707c478bd9Sstevel@tonic-gate $$ = uu_list_create(string_pool, NULL, 0); 4717c478bd9Sstevel@tonic-gate if ($$ == NULL) 4727c478bd9Sstevel@tonic-gate uu_die(gettext("Out of memory\n")); 4737c478bd9Sstevel@tonic-gate } 4747c478bd9Sstevel@tonic-gate | string_list string 4757c478bd9Sstevel@tonic-gate { 4767c478bd9Sstevel@tonic-gate string_list_t *slp; 4777c478bd9Sstevel@tonic-gate 4787c478bd9Sstevel@tonic-gate slp = safe_malloc(sizeof (*slp)); 4797c478bd9Sstevel@tonic-gate 4807c478bd9Sstevel@tonic-gate slp->str = $2; 4817c478bd9Sstevel@tonic-gate uu_list_node_init(slp, &slp->node, string_pool); 4827c478bd9Sstevel@tonic-gate uu_list_append($1, slp); 4837c478bd9Sstevel@tonic-gate $$ = $1; 4847c478bd9Sstevel@tonic-gate } 4857c478bd9Sstevel@tonic-gate 4867c478bd9Sstevel@tonic-gate multiline_string_list : string_list 4877c478bd9Sstevel@tonic-gate { 4887c478bd9Sstevel@tonic-gate $$ = $1; 4897c478bd9Sstevel@tonic-gate } 4907c478bd9Sstevel@tonic-gate | multiline_string_list SCS_NEWLINE string_list 4917c478bd9Sstevel@tonic-gate { 4927c478bd9Sstevel@tonic-gate void *cookie = NULL; 4937c478bd9Sstevel@tonic-gate string_list_t *slp; 4947c478bd9Sstevel@tonic-gate 4957c478bd9Sstevel@tonic-gate /* Append $3 to $1. */ 4967c478bd9Sstevel@tonic-gate while ((slp = uu_list_teardown($3, &cookie)) != NULL) 4977c478bd9Sstevel@tonic-gate uu_list_append($1, slp); 4987c478bd9Sstevel@tonic-gate 4997c478bd9Sstevel@tonic-gate uu_list_destroy($3); 5007c478bd9Sstevel@tonic-gate } 5017c478bd9Sstevel@tonic-gate 5027c478bd9Sstevel@tonic-gate string : SCV_WORD { $$ = $1; } 5037c478bd9Sstevel@tonic-gate | SCV_STRING { $$ = $1; } 5047c478bd9Sstevel@tonic-gate 5057c478bd9Sstevel@tonic-gate opt_word : { $$ = NULL; } 5067c478bd9Sstevel@tonic-gate | SCV_WORD { $$ = $1; } 5077c478bd9Sstevel@tonic-gate 5087c478bd9Sstevel@tonic-gate command_token : SCC_VALIDATE { $$ = SCC_VALIDATE; } 5097c478bd9Sstevel@tonic-gate | SCC_IMPORT { $$ = SCC_IMPORT; } 5107c478bd9Sstevel@tonic-gate | SCC_EXPORT { $$ = SCC_EXPORT; } 5117c478bd9Sstevel@tonic-gate | SCC_APPLY { $$ = SCC_APPLY; } 5127c478bd9Sstevel@tonic-gate | SCC_EXTRACT { $$ = SCC_EXTRACT; } 5137c478bd9Sstevel@tonic-gate | SCC_REPOSITORY { $$ = SCC_REPOSITORY; } 5147c478bd9Sstevel@tonic-gate | SCC_ARCHIVE { $$ = SCC_ARCHIVE; } 5157c478bd9Sstevel@tonic-gate | SCC_INVENTORY { $$ = SCC_INVENTORY; } 5167c478bd9Sstevel@tonic-gate | SCC_SET { $$ = SCC_SET; } 5177c478bd9Sstevel@tonic-gate | SCC_END { $$ = SCC_END; } 5187c478bd9Sstevel@tonic-gate | SCC_HELP { $$ = SCC_HELP; } 5197c478bd9Sstevel@tonic-gate | SCC_LIST { $$ = SCC_LIST; } 5207c478bd9Sstevel@tonic-gate | SCC_ADD { $$ = SCC_ADD; } 5217c478bd9Sstevel@tonic-gate | SCC_DELETE { $$ = SCC_DELETE; } 5227c478bd9Sstevel@tonic-gate | SCC_SELECT { $$ = SCC_SELECT; } 5237c478bd9Sstevel@tonic-gate | SCC_UNSELECT { $$ = SCC_UNSELECT; } 5247c478bd9Sstevel@tonic-gate | SCC_LISTPG { $$ = SCC_LISTPG; } 5257c478bd9Sstevel@tonic-gate | SCC_ADDPG { $$ = SCC_ADDPG; } 5267c478bd9Sstevel@tonic-gate | SCC_DELPG { $$ = SCC_DELPG; } 5277c478bd9Sstevel@tonic-gate | SCC_LISTPROP { $$ = SCC_LISTPROP; } 5287c478bd9Sstevel@tonic-gate | SCC_SETPROP { $$ = SCC_SETPROP; } 5297c478bd9Sstevel@tonic-gate | SCC_DELPROP { $$ = SCC_DELPROP; } 5307c478bd9Sstevel@tonic-gate | SCC_EDITPROP { $$ = SCC_EDITPROP; } 5317c478bd9Sstevel@tonic-gate | SCC_ADDPROPVALUE { $$ = SCC_ADDPROPVALUE; } 5327c478bd9Sstevel@tonic-gate | SCC_DELPROPVALUE { $$ = SCC_DELPROPVALUE; } 5337c478bd9Sstevel@tonic-gate | SCC_SETENV { $$ = SCC_SETENV; } 5347c478bd9Sstevel@tonic-gate | SCC_UNSETENV { $$ = SCC_UNSETENV; } 5357c478bd9Sstevel@tonic-gate | SCC_LISTSNAP { $$ = SCC_LISTSNAP; } 5367c478bd9Sstevel@tonic-gate | SCC_SELECTSNAP { $$ = SCC_SELECTSNAP; } 5377c478bd9Sstevel@tonic-gate | SCC_REVERT { $$ = SCC_REVERT; } 538