| 135 | */ |
| 136 | |
| 137 | OBJECT * search( OBJECT * target, timestamp * const time, |
| 138 | OBJECT * * another_target, int const file ) |
| 139 | { |
| 140 | PATHNAME f[ 1 ]; |
| 141 | LIST * varlist; |
| 142 | string buf[ 1 ]; |
| 143 | int found = 0; |
| 144 | OBJECT * boundname = 0; |
| 145 | |
| 146 | if ( another_target ) |
| 147 | *another_target = 0; |
| 148 | |
| 149 | if ( !explicit_bindings ) |
| 150 | explicit_bindings = hashinit( sizeof( BINDING ), "explicitly specified " |
| 151 | "locations" ); |
| 152 | |
| 153 | string_new( buf ); |
| 154 | |
| 155 | /* Parse the filename. */ |
| 156 | path_parse( object_str( target ), f ); |
| 157 | |
| 158 | f->f_grist.ptr = 0; |
| 159 | f->f_grist.len = 0; |
| 160 | |
| 161 | varlist = var_get( root_module(), constant_LOCATE ); |
| 162 | if ( !list_empty( varlist ) ) |
| 163 | { |
| 164 | OBJECT * key; |
| 165 | f->f_root.ptr = object_str( list_front( varlist ) ); |
| 166 | f->f_root.len = strlen( object_str( list_front( varlist ) ) ); |
| 167 | |
| 168 | path_build( f, buf ); |
| 169 | |
| 170 | if ( DEBUG_SEARCH ) |
| 171 | printf( "locate %s: %s\n", object_str( target ), buf->value ); |
| 172 | |
| 173 | key = object_new( buf->value ); |
| 174 | timestamp_from_path( time, key ); |
| 175 | object_free( key ); |
| 176 | found = 1; |
| 177 | } |
| 178 | else if ( varlist = var_get( root_module(), constant_SEARCH ), |
| 179 | !list_empty( varlist ) ) |
| 180 | { |
| 181 | LISTITER iter = list_begin( varlist ); |
| 182 | LISTITER const end = list_end( varlist ); |
| 183 | for ( ; iter != end; iter = list_next( iter ) ) |
| 184 | { |
| 185 | BINDING * ba; |
| 186 | file_info_t * ff; |
| 187 | OBJECT * key; |
| 188 | OBJECT * test_path; |
| 189 | |
| 190 | f->f_root.ptr = object_str( list_item( iter ) ); |
| 191 | f->f_root.len = strlen( object_str( list_item( iter ) ) ); |
| 192 | |
| 193 | string_truncate( buf, 0 ); |
| 194 | path_build( f, buf ); |
no test coverage detected