The Machine Perception Toolbox

[Introduction]- [News]- [Download]- [Screenshots]- [Manual (pdf)]- [Forums]- [API Reference]- [Repository ]

 

Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages

search.h File Reference

This graph shows which files directly or indirectly include this file:

Included by dependency graph

Go to the source code of this file.

Functions

char * search (char *target, time_t *time, char **another_target)


Function Documentation

char* search char *  target,
time_t *  time,
char **  another_target
 

Definition at line 91 of file search.c.

References _binding::binding, BINDING, call_bind_rule(), explicit_bindings, f(), hashcheck, HASHDATA, hashenter, hashinit(), LIST, list_next, newstr(), path_build(), path_parse(), PATHNAME, _list::string, string_free(), string_new(), string_truncate(), _binding::target, timestamp(), string::value, and var_get().

Referenced by bind_explicitly_located_target(), compile_include(), make0(), and make1bind().

00096 {
00097         PATHNAME f[1];
00098     LIST    *varlist;
00099     string    buf[1];
00100     int     found = 0;
00101     /* Will be set to 1 if target location is specified via LOCATE. */
00102     int     explicitly_located = 0;
00103     char    *boundname = 0;
00104 
00105     if( another_target )
00106         *another_target = 0;
00107 
00108     if (! explicit_bindings )
00109         explicit_bindings = hashinit( sizeof(BINDING), 
00110                                      "explicitly specified locations");
00111 
00112     string_new( buf );
00113     /* Parse the filename */
00114 
00115         path_parse( target, f );
00116 
00117     f->f_grist.ptr = 0;
00118     f->f_grist.len = 0;
00119 
00120     if( varlist = var_get( "LOCATE" ) )
00121       {
00122         f->f_root.ptr = varlist->string;
00123         f->f_root.len = strlen( varlist->string );
00124 
00125             path_build( f, buf, 1 );
00126 
00127         if( DEBUG_SEARCH )
00128             printf( "locate %s: %s\n", target, buf->value );
00129 
00130         explicitly_located = 1;
00131 
00132         timestamp( buf->value, time );
00133         found = 1;
00134     }
00135     else if( varlist = var_get( "SEARCH" ) )
00136     {
00137         while( varlist )
00138         {
00139             BINDING b, *ba = &b;
00140 
00141             f->f_root.ptr = varlist->string;
00142             f->f_root.len = strlen( varlist->string );
00143 
00144             string_truncate( buf, 0 );
00145             path_build( f, buf, 1 );
00146 
00147             if( DEBUG_SEARCH )
00148                 printf( "search %s: %s\n", target, buf->value );
00149 
00150             timestamp( buf->value, time );
00151 
00152             b.binding = buf->value;
00153             
00154             if( hashcheck( explicit_bindings, (HASHDATA**)&ba ) )
00155             {
00156                 if( DEBUG_SEARCH )
00157                     printf(" search %s: found explicitly located target %s\n", 
00158                            target, ba->target);
00159                 if( another_target )
00160                     *another_target = ba->target;
00161                 found = 1;
00162                 break;                
00163             }
00164             else if( *time )
00165             {
00166                 found = 1;
00167                 break;
00168             }
00169 
00170             varlist = list_next( varlist );
00171         }
00172     }
00173 
00174     if (!found)
00175     {
00176         /* Look for the obvious */
00177         /* This is a questionable move.  Should we look in the */
00178         /* obvious place if SEARCH is set? */
00179 
00180         f->f_root.ptr = 0;
00181         f->f_root.len = 0;
00182 
00183         string_truncate( buf, 0 );
00184         path_build( f, buf, 1 );
00185 
00186         if( DEBUG_SEARCH )
00187             printf( "search %s: %s\n", target, buf->value );
00188 
00189         timestamp( buf->value, time );
00190     }
00191 
00192     boundname = newstr( buf->value );
00193     string_free( buf );
00194 
00195     if (explicitly_located)
00196     {
00197         BINDING b, *ba = &b;
00198         b.binding = boundname;
00199         b.target = target;
00200         /* CONSIDER: we probably should issue a warning is another file
00201            is explicitly bound to the same location. This might break
00202            compatibility, though. */
00203         hashenter(explicit_bindings, (HASHDATA**)&ba);
00204     }
00205         
00206     /* prepare a call to BINDRULE if the variable is set */
00207     call_bind_rule( target, boundname );
00208 
00209     return boundname;
00210 }

Here is the call graph for this function:


Generated on Mon Nov 8 17:08:24 2004 for MPT by  doxygen 1.3.9.1