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

timestamp.c File Reference

#include "jam.h"
#include "hash.h"
#include "filesys.h"
#include "pathsys.h"
#include "timestamp.h"
#include "newstr.h"
#include "strings.h"

Include dependency graph for timestamp.c:

Include dependency graph

Go to the source code of this file.

Classes

struct  _binding

Defines

#define BIND_FOUND   4
#define BIND_INIT   0
#define BIND_MISSING   3
#define BIND_NOENTRY   1
#define BIND_SCANNED   0x01
#define BIND_SPOTTED   2

Typedefs

typedef _binding BINDING

Functions

void donestamps ()
void time_enter (void *, char *, int, time_t)
void timestamp (char *target, time_t *time)

Variables

hashbindhash = 0
char * time_progress []


Define Documentation

#define BIND_FOUND   4
 

Definition at line 47 of file timestamp.c.

Referenced by time_enter(), and timestamp().

#define BIND_INIT   0
 

Definition at line 43 of file timestamp.c.

#define BIND_MISSING   3
 

Definition at line 46 of file timestamp.c.

#define BIND_NOENTRY   1
 

Definition at line 44 of file timestamp.c.

#define BIND_SCANNED   0x01
 

Definition at line 39 of file timestamp.c.

#define BIND_SPOTTED   2
 

Definition at line 45 of file timestamp.c.


Typedef Documentation

typedef struct _binding BINDING
 

Definition at line 33 of file timestamp.c.


Function Documentation

void donestamps  ) 
 

Definition at line 226 of file timestamp.c.

References bindhash, and hashdone().

Referenced by main().

00227 {
00228         hashdone( bindhash );
00229 }

Here is the call graph for this function:

void time_enter void *  ,
char *  ,
int  ,
time_t 
[static]
 

Definition at line 189 of file timestamp.c.

References BIND_FOUND, bindhash, BINDING, _binding::flags, HASHDATA, hashenter, _binding::name, newstr(), p, and time_progress.

Referenced by timestamp().

00194 {
00195         BINDING binding, *b = &binding;
00196         struct hash *bindhash = (struct hash *)closure;
00197 
00198 # ifdef DOWNSHIFT_PATHS
00199         char path[ MAXJPATH ];
00200         char *p = path;
00201 
00202         do *p++ = tolower( *target );
00203         while( *target++ );
00204 
00205         target = path;
00206 # endif
00207 
00208         b->name = target;
00209         b->flags = 0;
00210 
00211         if( hashenter( bindhash, (HASHDATA **)&b ) )
00212             b->name = newstr( target );         /* never freed */
00213 
00214         b->time = time;
00215         b->progress = found ? BIND_FOUND : BIND_SPOTTED;
00216 
00217         if( DEBUG_BINDSCAN )
00218             printf( "time ( %s ) : %s\n", target, time_progress[b->progress] );
00219 }

Here is the call graph for this function:

void timestamp char *  target,
time_t *  time
 

Definition at line 70 of file timestamp.c.

References BIND_FOUND, bindhash, BINDING, file_archscan(), file_dirscan(), file_time(), _binding::flags, HASHDATA, hashenter, hashinit(), _binding::name, newstr(), p, path_build(), path_parent(), path_parse(), PATHNAME, _binding::progress, string_copy(), string_free(), string_new(), string_truncate(), _binding::time, time_enter(), and string::value.

Referenced by search(), and search_for_target().

00073 {
00074         PATHNAME f1, f2;
00075         BINDING binding, *b = &binding;
00076         string buf[1];
00077 
00078 # ifdef DOWNSHIFT_PATHS
00079         string path; 
00080         char *p;
00081 
00082         string_copy( &path, target );
00083         p = path.value;
00084 
00085         do
00086     {
00087         *p = tolower( *p );
00088 #  ifdef NT
00089         /* On NT, we must use backslashes or the file won't be found. */
00090         if (*p == '/')
00091             *p = PATH_DELIM;
00092 #  endif 
00093     }
00094         while( *p++ );
00095 
00096         target = path.value;
00097 # endif
00098         string_new( buf );
00099 
00100         if( !bindhash )
00101             bindhash = hashinit( sizeof( BINDING ), "bindings" );
00102 
00103         /* Quick path - is it there? */
00104 
00105         b->name = target;
00106         b->time = b->flags = 0;
00107         b->progress = BIND_INIT;
00108 
00109         if( hashenter( bindhash, (HASHDATA **)&b ) )
00110             b->name = newstr( target );         /* never freed */
00111 
00112         if( b->progress != BIND_INIT )
00113             goto afterscanning;
00114 
00115         b->progress = BIND_NOENTRY;
00116 
00117         /* Not found - have to scan for it */
00118 
00119         path_parse( target, &f1 );
00120 
00121         /* Scan directory if not already done so */
00122 
00123         {
00124             BINDING binding, *b = &binding;
00125 
00126             f2 = f1;
00127             f2.f_grist.len = 0;
00128             path_parent( &f2 );
00129             path_build( &f2, buf, 0 );
00130 
00131             b->name = buf->value;
00132             b->time = b->flags = 0;
00133             b->progress = BIND_INIT;
00134 
00135             if( hashenter( bindhash, (HASHDATA **)&b ) )
00136                 b->name = newstr( buf->value ); /* never freed */
00137 
00138             if( !( b->flags & BIND_SCANNED ) )
00139             {
00140                 file_dirscan( buf->value, time_enter, bindhash );
00141                 b->flags |= BIND_SCANNED;
00142             }
00143         }
00144 
00145         /* Scan archive if not already done so */
00146 
00147         if( f1.f_member.len )
00148         {
00149             BINDING binding, *b = &binding;
00150 
00151             f2 = f1;
00152             f2.f_grist.len = 0;
00153             f2.f_member.len = 0;
00154             string_truncate( buf, 0 );
00155             path_build( &f2, buf, 0 );
00156 
00157             b->name = buf->value;
00158             b->time = b->flags = 0;
00159             b->progress = BIND_INIT;
00160 
00161             if( hashenter( bindhash, (HASHDATA **)&b ) )
00162                 b->name = newstr( buf->value ); /* never freed */
00163 
00164             if( !( b->flags & BIND_SCANNED ) )
00165             {
00166                 file_archscan( buf->value, time_enter, bindhash );
00167                 b->flags |= BIND_SCANNED;
00168             }
00169         }
00170 
00171     afterscanning:
00172 
00173         if( b->progress == BIND_SPOTTED )
00174         {
00175             if( file_time( b->name, &b->time ) < 0 )
00176                 b->progress = BIND_MISSING;
00177             else
00178                 b->progress = BIND_FOUND;
00179         }
00180 
00181         *time = b->progress == BIND_FOUND ? b->time : 0;
00182         string_free( buf );
00183 # ifdef DOWNSHIFT_PATHS
00184         string_free( &path );
00185 #endif
00186 }

Here is the call graph for this function:


Variable Documentation

struct hash* bindhash = 0 [static]
 

Definition at line 52 of file timestamp.c.

Referenced by donestamps(), time_enter(), and timestamp().

char* time_progress[] [static]
 

Initial value:

{
        "INIT",
        "NOENTRY",
        "SPOTTED",
        "MISSING",
        "FOUND"
}

Definition at line 55 of file timestamp.c.

Referenced by time_enter().


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