Commit | Line | Data |
---|---|---|
920dae64 AT |
1 | \ ========== Copyright Header Begin ========================================== |
2 | \ | |
3 | \ Hypervisor Software File: confact.fth | |
4 | \ | |
5 | \ Copyright (c) 2006 Sun Microsystems, Inc. All Rights Reserved. | |
6 | \ | |
7 | \ - Do no alter or remove copyright notices | |
8 | \ | |
9 | \ - Redistribution and use of this software in source and binary forms, with | |
10 | \ or without modification, are permitted provided that the following | |
11 | \ conditions are met: | |
12 | \ | |
13 | \ - Redistribution of source code must retain the above copyright notice, | |
14 | \ this list of conditions and the following disclaimer. | |
15 | \ | |
16 | \ - Redistribution in binary form must reproduce the above copyright notice, | |
17 | \ this list of conditions and the following disclaimer in the | |
18 | \ documentation and/or other materials provided with the distribution. | |
19 | \ | |
20 | \ Neither the name of Sun Microsystems, Inc. or the names of contributors | |
21 | \ may be used to endorse or promote products derived from this software | |
22 | \ without specific prior written permission. | |
23 | \ | |
24 | \ This software is provided "AS IS," without a warranty of any kind. | |
25 | \ ALL EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES, | |
26 | \ INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A | |
27 | \ PARTICULAR PURPOSE OR NON-INFRINGEMENT, ARE HEREBY EXCLUDED. SUN | |
28 | \ MICROSYSTEMS, INC. ("SUN") AND ITS LICENSORS SHALL NOT BE LIABLE FOR | |
29 | \ ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR | |
30 | \ DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES. IN NO EVENT WILL SUN | |
31 | \ OR ITS LICENSORS BE LIABLE FOR ANY LOST REVENUE, PROFIT OR DATA, OR | |
32 | \ FOR DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL, INCIDENTAL OR PUNITIVE | |
33 | \ DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE THEORY OF LIABILITY, | |
34 | \ ARISING OUT OF THE USE OF OR INABILITY TO USE THIS SOFTWARE, EVEN IF | |
35 | \ SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. | |
36 | \ | |
37 | \ You acknowledge that this software is not designed, licensed or | |
38 | \ intended for use in the design, construction, operation or maintenance of | |
39 | \ any nuclear facility. | |
40 | \ | |
41 | \ ========== Copyright Header End ============================================ | |
42 | id: @(#)confact.fth 1.9 01/11/30 | |
43 | purpose: Action names for configuration option data types | |
44 | copyright: Copyright 1990-2001 Sun Microsystems, Inc. All Rights Reserved | |
45 | ||
46 | \ Action names for configuration objects | |
47 | \ 0 action = value on stack ( apf -- value ) | |
48 | \ call with: fieldname | |
49 | \ 1 action = store value ( value apf -- ) | |
50 | \ call with: value to fieldname | |
51 | \ 2 action = adr on stack ( apf -- adr ) | |
52 | \ call with: addr fieldname | |
53 | \ 3 action = decode for display ( apf -- adr len ) | |
54 | \ 4 action = encode for storage ( adr len apf -- ) | |
55 | \ 5 action = has-default? ( apf -- flag ) | |
56 | \ 6 action = default value ( apf -- value ) | |
57 | \ "value" is either int, char, or ( adr len) for strings | |
58 | \ action 6 is only required to be present for values that have defaults. | |
59 | ||
60 | \ Decoding byte values | |
61 | : c->n ( byte -- n ) d# 24 << l->n d# 24 >>a ; | |
62 | : n->c ( apf value -- byte apf ) h# ff and ; | |
63 | ||
64 | \ Two useful boolean strings. | |
65 | : true$ ( - str,len ) " true" ; | |
66 | : false$ ( -- str,len ) " false" ; | |
67 | ||
68 | \ Encoding/Decoding boolean flags | |
69 | : decode-flag ( n apf -- str,len ) drop if true$ else false$ then ; | |
70 | \ : encode-flag ( str,len apf -- n ) drop true$ $= ; | |
71 | ||
72 | \ encode-number is defined elsewhere | |
73 | ||
74 | exported-headerless | |
75 | ||
76 | : nodefault? ( acf -- flag ) 5 perform-action ; | |
77 | : get-default ( acf -- ??value?? ) 6 perform-action ; | |
78 | ||
79 | : do-get-default ( acf -- str,len ) | |
80 | dup nodefault? if ( acf ) | |
81 | drop " No default" ( adr,len ) | |
82 | else ( -- ) | |
83 | >r r@ get-default ( ??value?? ) | |
84 | r> decode ( adr,len ) | |
85 | then ( adr,len ) | |
86 | ; | |
87 | ||
88 | : do-set-default ( acf -- ) | |
89 | dup nodefault? if ( acf ) | |
90 | drop ( -- ) | |
91 | else ( acf ) | |
92 | >r r@ get-default ( ??value?? ) | |
93 | r> set ( -- ) | |
94 | then ( -- ) | |
95 | ; | |
96 | ||
97 | unexported-words |