| 164 | */ |
| 165 | |
| 166 | LIST * var_get( struct module_t * module, OBJECT * symbol ) |
| 167 | { |
| 168 | LIST * result = L0; |
| 169 | #ifdef OPT_AT_FILES |
| 170 | /* Some "fixed" variables... */ |
| 171 | if ( object_equal( symbol, constant_TMPDIR ) ) |
| 172 | { |
| 173 | list_free( saved_var ); |
| 174 | result = saved_var = list_new( object_new( path_tmpdir()->value ) ); |
| 175 | } |
| 176 | else if ( object_equal( symbol, constant_TMPNAME ) ) |
| 177 | { |
| 178 | list_free( saved_var ); |
| 179 | result = saved_var = list_new( path_tmpnam() ); |
| 180 | } |
| 181 | else if ( object_equal( symbol, constant_TMPFILE ) ) |
| 182 | { |
| 183 | list_free( saved_var ); |
| 184 | result = saved_var = list_new( path_tmpfile() ); |
| 185 | } |
| 186 | else if ( object_equal( symbol, constant_STDOUT ) ) |
| 187 | { |
| 188 | list_free( saved_var ); |
| 189 | result = saved_var = list_new( object_copy( constant_STDOUT ) ); |
| 190 | } |
| 191 | else if ( object_equal( symbol, constant_STDERR ) ) |
| 192 | { |
| 193 | list_free( saved_var ); |
| 194 | result = saved_var = list_new( object_copy( constant_STDERR ) ); |
| 195 | } |
| 196 | else |
| 197 | #endif |
| 198 | { |
| 199 | VARIABLE * v; |
| 200 | int n; |
| 201 | |
| 202 | if ( ( n = module_get_fixed_var( module, symbol ) ) != -1 ) |
| 203 | { |
| 204 | if ( DEBUG_VARGET ) |
| 205 | var_dump( symbol, module->fixed_variables[ n ], "get" ); |
| 206 | result = module->fixed_variables[ n ]; |
| 207 | } |
| 208 | else if ( module->variables && ( v = (VARIABLE *)hash_find( |
| 209 | module->variables, symbol ) ) ) |
| 210 | { |
| 211 | if ( DEBUG_VARGET ) |
| 212 | var_dump( v->symbol, v->value, "get" ); |
| 213 | result = v->value; |
| 214 | } |
| 215 | |
| 216 | #ifdef OS_VMS |
| 217 | else if ( ( module->name && object_equal( module->name, constant_ENVIRON ) ) |
| 218 | || root_module() == module ) |
| 219 | { |
| 220 | /* On VMS, when a variable from root or ENVIRON module is not found, |
| 221 | * explicitly request it from the process. |
| 222 | * By design, process variables (and logicals) are not made available |
| 223 | * to C main(), and thus will not get loaded in bulk to root/ENVRON. |
no test coverage detected