5 * The contents of this file are subject to the terms of the
6 * Common Development and Distribution License (the "License").
7 * You may not use this file except in compliance with the License.
9 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10 * or http://www.opensolaris.org/os/licensing.
11 * See the License for the specific language governing permissions
12 * and limitations under the License.
14 * When distributing Covered Code, include this CDDL HEADER in each
15 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16 * If applicable, add the following below this CDDL HEADER, with the
17 * fields enclosed by brackets "[]" replaced with your own identifying
18 * information: Portions Copyright [yyyy] [name of copyright owner]
24 * Copyright (c) 2004, 2010, Oracle and/or its affiliates. All rights reserved.
32 uu_list_pool_t
*string_pool
;
44 %token SCC_VALIDATE SCC_IMPORT SCC_EXPORT SCC_ARCHIVE SCC_APPLY SCC_EXTRACT
46 %token SCC_REPOSITORY SCC_INVENTORY SCC_SET SCC_END SCC_HELP SCC_RESTORE
47 %token SCC_LIST SCC_ADD SCC_DELETE SCC_SELECT SCC_UNSELECT
48 %token SCC_LISTPG SCC_ADDPG SCC_DELPG SCC_DELHASH
49 %token SCC_LISTPROP SCC_SETPROP SCC_DELPROP SCC_EDITPROP
51 %token SCC_ADDPROPVALUE SCC_DELPROPVALUE SCC_SETENV SCC_UNSETENV
52 %token SCC_LISTSNAP SCC_SELECTSNAP SCC_REVERT SCC_REFRESH
53 %token SCS_REDIRECT SCS_NEWLINE SCS_EQUALS SCS_LPAREN SCS_RPAREN
54 %token SCV_WORD SCV_STRING
55 %token SCC_DELNOTIFY SCC_SETNOTIFY SCC_LISTNOTIFY
57 %type
<tok
> command_token
58 %type
<str
> SCV_WORD SCV_STRING
59 %type
<str
> string opt_word
60 %type
<uul
> string_list multiline_string_list
65 * We could hoist the command terminator for all the rules up here, but then
66 * the parser would reduce before shifting the terminator, which would require
67 * an additional error rule (per command) to catch extra arguments.
68 * This way requires all input to be terminated, which is done by input() in
115 |
error terminator
{ semerr
(gettext
("Syntax error.\n")); }
117 unknown_cmd
: SCV_WORD terminator
119 semerr
(gettext
("Unknown command \"%s\".\n"), $1);
122 | SCV_WORD string_list terminator
127 semerr
(gettext
("Unknown command \"%s\".\n"), $1);
129 while
((slp
= uu_list_teardown
($2, &cookie
)) != NULL
) {
138 validate_cmd
: SCC_VALIDATE SCV_WORD terminator
143 | SCC_VALIDATE terminator
{ lscf_validate_fmri
(NULL
); }
144 | SCC_VALIDATE
error terminator
{ synerr
(SCC_VALIDATE
); return
(0); }
146 import_cmd
: SCC_IMPORT string_list terminator
151 if
(engine_import
($2) == -2) {
156 while
((slp
= uu_list_teardown
($2, &cookie
)) != NULL
) {
163 | SCC_IMPORT
error terminator
{ synerr
(SCC_IMPORT
); return
(0); }
165 cleanup_cmd
: SCC_CLEANUP terminator
169 | SCC_CLEANUP SCV_WORD terminator
171 if
(strcmp
($2, "-a") == 0) {
180 | SCC_CLEANUP
error terminator
{ synerr
(SCC_CLEANUP
); return
(0); }
183 export_cmd
: SCC_EXPORT SCV_WORD terminator
185 lscf_service_export
($2, NULL
, 0);
188 | SCC_EXPORT SCV_WORD SCS_REDIRECT SCV_WORD terminator
190 lscf_service_export
($2, $4, 0);
194 | SCC_EXPORT SCV_WORD SCV_WORD terminator
196 if
(strcmp
($2, "-a") == 0) {
197 lscf_service_export
($3, NULL
, SCE_ALL_VALUES
);
207 | SCC_EXPORT SCV_WORD SCV_WORD SCS_REDIRECT SCV_WORD terminator
209 if
(strcmp
($2, "-a") == 0) {
210 lscf_service_export
($3, $5, SCE_ALL_VALUES
);
222 | SCC_EXPORT
error terminator
{ synerr
(SCC_EXPORT
); return
(0); }
224 archive_cmd
: SCC_ARCHIVE terminator
226 lscf_archive
(NULL
, 0);
228 | SCC_ARCHIVE SCV_WORD terminator
230 if
(strcmp
($2, "-a") == 0) {
231 lscf_archive
(NULL
, SCE_ALL_VALUES
);
239 | SCC_ARCHIVE SCS_REDIRECT SCV_WORD terminator
244 | SCC_ARCHIVE SCV_WORD SCS_REDIRECT SCV_WORD terminator
246 if
(strcmp
($2, "-a") == 0) {
247 lscf_archive
($4, SCE_ALL_VALUES
);
257 | SCC_ARCHIVE
error terminator
{ synerr
(SCC_ARCHIVE
); return
(0); }
259 restore_cmd
: SCC_RESTORE SCV_WORD terminator
261 (void) engine_restore
($2);
264 | SCC_RESTORE
error terminator
{ synerr
(SCC_RESTORE
); return
(0); }
266 apply_cmd
: SCC_APPLY SCV_WORD terminator
268 if
(engine_apply
($2, 1) == -1) {
269 if
((est
->sc_cmd_flags
& (SC_CMD_IACTIVE|SC_CMD_DONT_EXIT
)) == 0)
278 | SCC_APPLY SCV_WORD SCV_WORD terminator
280 if
(strcmp
($2, "-n") == 0) {
281 (void) engine_apply
($3, 0);
291 | SCC_APPLY
error terminator
{ synerr
(SCC_APPLY
); return
(0); }
293 extract_cmd: SCC_EXTRACT terminator
{ lscf_profile_extract
(NULL
); }
294 | SCC_EXTRACT SCS_REDIRECT SCV_WORD terminator
296 lscf_profile_extract
($3);
299 | SCC_EXTRACT
error terminator
{ synerr
(SCC_EXTRACT
); return
(0); }
301 repository_cmd: SCC_REPOSITORY SCV_WORD terminator
303 if
(strcmp
($2, "-f") == 0) {
304 synerr
(SCC_REPOSITORY
);
307 lscf_set_repository
($2, 0);
310 | SCC_REPOSITORY SCV_WORD SCV_WORD terminator
312 if
(strcmp
($2, "-f") == 0) {
313 lscf_set_repository
($3, 1);
317 synerr
(SCC_REPOSITORY
);
321 | SCC_REPOSITORY
error terminator
{ synerr
(SCC_REPOSITORY
); return
(0); }
323 inventory_cmd
: SCC_INVENTORY SCV_WORD terminator
324 { lxml_inventory
($2); free
($2); }
325 | SCC_INVENTORY
error terminator
{ synerr
(SCC_INVENTORY
); return
(0); }
327 set_cmd
: SCC_SET string_list terminator
332 (void) engine_set
($2);
334 while
((slp
= uu_list_teardown
($2, &cookie
)) != NULL
) {
341 | SCC_SET
error terminator
{ synerr
(SCC_SET
); return
(0); }
343 end_cmd
: SCC_END terminator
{ exit
(0); }
344 | SCC_END
error terminator
{ synerr
(SCC_END
); return
(0); }
346 help_cmd
: SCC_HELP terminator
{ help
(0); }
347 | SCC_HELP command_token terminator
{ help
($2); }
348 | SCC_HELP
error terminator
{ synerr
(SCC_HELP
); return
(0); }
350 list_cmd
: SCC_LIST opt_word terminator
{ lscf_list
($2); free
($2); }
351 | SCC_LIST
error terminator
{ synerr
(SCC_LIST
); return
(0); }
353 add_cmd
: SCC_ADD SCV_WORD terminator
{ lscf_add
($2); free
($2); }
354 | SCC_ADD
error terminator
{ synerr
(SCC_ADD
); return
(0); }
356 delete_cmd
: SCC_DELETE SCV_WORD terminator
357 { lscf_delete
($2, 0); free
($2); }
358 | SCC_DELETE SCV_WORD SCV_WORD terminator
360 if
(strcmp
($2, "-f") == 0) {
371 | SCC_DELETE
error terminator
{ synerr
(SCC_DELETE
); return
(0); }
373 select_cmd
: SCC_SELECT SCV_WORD terminator
{ lscf_select
($2); free
($2); }
374 | SCC_SELECT
error terminator
{ synerr
(SCC_SELECT
); return
(0) ;}
376 unselect_cmd
: SCC_UNSELECT terminator
{ lscf_unselect
(); }
377 | SCC_UNSELECT
error terminator
{ synerr
(SCC_UNSELECT
); return
(0); }
379 listpg_cmd
: SCC_LISTPG opt_word terminator
380 { lscf_listpg
($2); free
($2); }
381 | SCC_LISTPG
error terminator
{ synerr
(SCC_LISTPG
); return
(0); }
383 addpg_cmd
: SCC_ADDPG SCV_WORD SCV_WORD opt_word terminator
385 (void) lscf_addpg
($2, $3, $4);
390 | SCC_ADDPG
error terminator
{ synerr
(SCC_ADDPG
); return
(0); }
392 delpg_cmd
: SCC_DELPG SCV_WORD terminator
393 { lscf_delpg
($2); free
($2); }
394 | SCC_DELPG
error terminator
{ synerr
(SCC_DELPG
); return
(0); }
396 delhash_cmd
: SCC_DELHASH SCV_WORD terminator
398 lscf_delhash
($2, 0); free
($2);
400 | SCC_DELHASH SCV_WORD SCV_WORD terminator
402 if
(strcmp
($2, "-d") == 0) {
413 | SCC_DELHASH
error terminator
{ synerr
(SCC_DELHASH
); return
(0); }
415 listprop_cmd
: SCC_LISTPROP opt_word terminator
416 { lscf_listprop
($2); free
($2); }
417 | SCC_LISTPROP
error terminator
{ synerr
(SCC_LISTPROP
); return
(0); }
419 setprop_cmd
: SCC_SETPROP SCV_WORD SCS_EQUALS
string terminator
421 lscf_setprop
($2, NULL
, $4, NULL
);
425 | SCC_SETPROP SCV_WORD SCS_EQUALS SCV_WORD
string terminator
427 (void) lscf_setprop
($2, $4, $5, NULL
);
432 | SCC_SETPROP SCV_WORD SCS_EQUALS opt_word SCS_LPAREN
433 multiline_string_list SCS_RPAREN terminator
438 (void) lscf_setprop
($2, $4, NULL
, $6);
443 while
((slp
= uu_list_teardown
($6, &cookie
)) != NULL
) {
450 | SCC_SETPROP
error terminator
{ synerr
(SCC_SETPROP
); return
(0); }
451 | SCC_SETPROP
error { synerr
(SCC_SETPROP
); return
(0); }
453 delprop_cmd
: SCC_DELPROP SCV_WORD terminator
454 { lscf_delprop
($2); free
($2); }
455 | SCC_DELPROP
error terminator
{ synerr
(SCC_DELPROP
); return
(0); }
457 editprop_cmd
: SCC_EDITPROP terminator
{ lscf_editprop
(); }
458 | SCC_EDITPROP
error terminator
{ synerr
(SCC_EDITPROP
); return
(0); }
460 describe_cmd
: SCC_DESCRIBE string_list terminator
465 if
(lscf_describe
($2, 1) == -2) {
466 synerr
(SCC_DESCRIBE
);
470 while
((slp
= uu_list_teardown
($2, &cookie
)) != NULL
) {
477 | SCC_DESCRIBE terminator
{ lscf_describe
(NULL
, 0); }
478 | SCC_DESCRIBE
error terminator
{ synerr
(SCC_DESCRIBE
); return
(0); }
480 addpropvalue_cmd
: SCC_ADDPROPVALUE SCV_WORD
string terminator
482 lscf_addpropvalue
($2, NULL
, $3);
486 | SCC_ADDPROPVALUE SCV_WORD
string string terminator
488 (void) lscf_addpropvalue
($2, $3, $4);
493 | SCC_ADDPROPVALUE
error terminator
{ synerr
(SCC_ADDPROPVALUE
); return
(0); }
495 delpropvalue_cmd
: SCC_DELPROPVALUE SCV_WORD
string terminator
497 lscf_delpropvalue
($2, $3, 0);
501 | SCC_DELPROPVALUE
error terminator
{ synerr
(SCC_DELPROPVALUE
); return
(0); }
503 setenv_cmd
: SCC_SETENV string_list terminator
508 if
(lscf_setenv
($2, 0) == -2) {
513 while
((slp
= uu_list_teardown
($2, &cookie
)) != NULL
) {
520 | SCC_SETENV
error terminator
{ synerr
(SCC_SETENV
); return
(0); }
522 unsetenv_cmd
: SCC_UNSETENV string_list terminator
527 if
(lscf_setenv
($2, 1) == -2) {
528 synerr
(SCC_UNSETENV
);
532 while
((slp
= uu_list_teardown
($2, &cookie
)) != NULL
) {
539 | SCC_UNSETENV
error terminator
{ synerr
(SCC_UNSETENV
); return
(0); }
541 listsnap_cmd
: SCC_LISTSNAP terminator
{ lscf_listsnap
(); }
542 | SCC_LISTSNAP
error terminator
{ synerr
(SCC_LISTSNAP
); return
(0); }
544 selectsnap_cmd
: SCC_SELECTSNAP opt_word terminator
545 { lscf_selectsnap
($2); free
($2); }
546 | SCC_SELECTSNAP
error terminator
547 { synerr
(SCC_SELECTSNAP
); return
(0); }
549 revert_cmd: SCC_REVERT opt_word terminator
{ lscf_revert
($2); free
($2); }
550 | SCC_REVERT
error terminator
{ synerr
(SCC_REVERT
); return
(0); }
552 refresh_cmd: SCC_REFRESH terminator
{ lscf_refresh
(); }
553 | SCC_REFRESH
error terminator
{ synerr
(SCC_REFRESH
); return
(0); }
555 delnotify_cmd
: SCC_DELNOTIFY SCV_WORD terminator
557 lscf_delnotify
($2, 0);
560 | SCC_DELNOTIFY SCV_WORD SCV_WORD terminator
562 if
(strcmp
($2, "-g") == 0) {
563 lscf_delnotify
($3, 1);
567 synerr
(SCC_DELNOTIFY
);
573 | SCC_DELNOTIFY
error terminator
{ synerr
(SCC_DELNOTIFY
); return
(0); }
575 listnotify_cmd
: SCC_LISTNOTIFY terminator
577 lscf_listnotify
("all", 0);
579 | SCC_LISTNOTIFY SCV_WORD terminator
581 if
(strcmp
($2, "-g") == 0) {
582 lscf_listnotify
("all", 1);
584 lscf_listnotify
($2, 0);
588 | SCC_LISTNOTIFY SCV_WORD SCV_WORD terminator
590 if
(strcmp
($2, "-g") == 0) {
591 lscf_listnotify
($3, 1);
595 synerr
(SCC_LISTNOTIFY
);
601 | SCC_LISTNOTIFY
error terminator
{ synerr
(SCC_LISTNOTIFY
); return
(0); }
603 setnotify_cmd
: SCC_SETNOTIFY string_list terminator
608 if
(lscf_setnotify
($2) == -2)
609 synerr
(SCC_SETNOTIFY
);
611 while
((slp
= uu_list_teardown
($2, &cookie
)) != NULL
) {
618 | SCC_SETNOTIFY
error terminator
{ synerr
(SCC_SETNOTIFY
); return
(0); }
620 terminator
: SCS_NEWLINE
624 $$
= uu_list_create
(string_pool
, NULL
, 0);
626 uu_die
(gettext
("Out of memory\n"));
632 slp
= safe_malloc
(sizeof
(*slp
));
635 uu_list_node_init
(slp
, &slp
->node
, string_pool
);
636 uu_list_append
($1, slp
);
640 multiline_string_list
: string_list
644 | multiline_string_list SCS_NEWLINE string_list
649 /* Append $3 to $1. */
650 while
((slp
= uu_list_teardown
($3, &cookie
)) != NULL
)
651 uu_list_append
($1, slp
);
656 string : SCV_WORD
{ $$
= $1; }
657 | SCV_STRING
{ $$
= $1; }
659 opt_word
: { $$
= NULL
; }
660 | SCV_WORD
{ $$
= $1; }
662 command_token
: SCC_VALIDATE
{ $$
= SCC_VALIDATE
; }
663 | SCC_IMPORT
{ $$
= SCC_IMPORT
; }
664 | SCC_CLEANUP
{ $$
= SCC_CLEANUP
; }
665 | SCC_EXPORT
{ $$
= SCC_EXPORT
; }
666 | SCC_APPLY
{ $$
= SCC_APPLY
; }
667 | SCC_EXTRACT
{ $$
= SCC_EXTRACT
; }
668 | SCC_REPOSITORY
{ $$
= SCC_REPOSITORY
; }
669 | SCC_ARCHIVE
{ $$
= SCC_ARCHIVE
; }
670 | SCC_INVENTORY
{ $$
= SCC_INVENTORY
; }
671 | SCC_SET
{ $$
= SCC_SET
; }
672 | SCC_END
{ $$
= SCC_END
; }
673 | SCC_HELP
{ $$
= SCC_HELP
; }
674 | SCC_LIST
{ $$
= SCC_LIST
; }
675 | SCC_ADD
{ $$
= SCC_ADD
; }
676 | SCC_DELETE
{ $$
= SCC_DELETE
; }
677 | SCC_SELECT
{ $$
= SCC_SELECT
; }
678 | SCC_UNSELECT
{ $$
= SCC_UNSELECT
; }
679 | SCC_LISTPG
{ $$
= SCC_LISTPG
; }
680 | SCC_ADDPG
{ $$
= SCC_ADDPG
; }
681 | SCC_DELPG
{ $$
= SCC_DELPG
; }
682 | SCC_DELHASH
{ $$
= SCC_DELHASH
; }
683 | SCC_LISTPROP
{ $$
= SCC_LISTPROP
; }
684 | SCC_SETPROP
{ $$
= SCC_SETPROP
; }
685 | SCC_DELPROP
{ $$
= SCC_DELPROP
; }
686 | SCC_EDITPROP
{ $$
= SCC_EDITPROP
; }
687 | SCC_ADDPROPVALUE
{ $$
= SCC_ADDPROPVALUE
; }
688 | SCC_DELPROPVALUE
{ $$
= SCC_DELPROPVALUE
; }
689 | SCC_SETENV
{ $$
= SCC_SETENV
; }
690 | SCC_UNSETENV
{ $$
= SCC_UNSETENV
; }
691 | SCC_LISTSNAP
{ $$
= SCC_LISTSNAP
; }
692 | SCC_SELECTSNAP
{ $$
= SCC_SELECTSNAP
; }
693 | SCC_REVERT
{ $$
= SCC_REVERT
; }
694 | SCC_REFRESH
{ $$
= SCC_REFRESH
; }
695 | SCC_DESCRIBE
{ $$
= SCC_DESCRIBE
; }
696 | SCC_DELNOTIFY
{ $$
= SCC_DELNOTIFY
; }
697 | SCC_LISTNOTIFY
{ $$
= SCC_LISTNOTIFY
; }
698 | SCC_SETNOTIFY
{ $$
= SCC_SETNOTIFY
; }