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

filent.c File Reference

#include "jam.h"
#include "filesys.h"
#include "pathsys.h"
#include "strings.h"

Include dependency graph for filent.c:

Include dependency graph

Go to the source code of this file.

Classes

struct  ar_hdr

Defines

#define ARFMAG   "`\n"
#define ARMAG   "!<arch>\n"
#define SARFMAG   2
#define SARHDR   sizeof( struct ar_hdr )
#define SARMAG   8

Functions

 _findclose (handle)
void file_archscan (char *archive, scanback func, void *closure)
int file_time (char *filename, time_t *time)
 if (ret=(handle< 0L))
 string_free (filespec)
 string_free (filename)
 string_new (filename)
 while (!ret)

Variables

 handle = _findfirst( filespec->value, finfo )


Define Documentation

#define ARFMAG   "`\n"
 

Definition at line 178 of file filent.c.

Referenced by file_archscan().

#define ARMAG   "!<arch>\n"
 

Definition at line 175 of file filent.c.

Referenced by file_archscan().

#define SARFMAG   2
 

Definition at line 190 of file filent.c.

Referenced by file_archscan().

#define SARHDR   sizeof( struct ar_hdr )
 

Definition at line 191 of file filent.c.

Referenced by file_archscan().

#define SARMAG   8
 

Definition at line 176 of file filent.c.

Referenced by file_archscan().


Function Documentation

_findclose handle   ) 
 

void file_archscan char *  archive,
scanback  func,
void *  closure
 

Definition at line 194 of file filent.c.

00198 {
00199         struct ar_hdr ar_hdr;
00200         char *string_table = 0;
00201         char buf[ MAXJPATH ];
00202         long offset;
00203         int fd;
00204 
00205         if( ( fd = open( archive, O_RDONLY | O_BINARY, 0 ) ) < 0 )
00206             return;
00207 
00208         if( read( fd, buf, SARMAG ) != SARMAG ||
00209             strncmp( ARMAG, buf, SARMAG ) )
00210         {
00211             close( fd );
00212             return;
00213         }
00214 
00215         offset = SARMAG;
00216 
00217         if( DEBUG_BINDSCAN )
00218             printf( "scan archive %s\n", archive );
00219 
00220         while( read( fd, &ar_hdr, SARHDR ) == SARHDR &&
00221                !memcmp( ar_hdr.ar_fmag, ARFMAG, SARFMAG ) )
00222         {
00223             long    lar_date;
00224             long    lar_size;
00225             char    *name = 0;
00226             char    *endname;
00227             char    *c;
00228 
00229             sscanf( ar_hdr.ar_date, "%ld", &lar_date );
00230             sscanf( ar_hdr.ar_size, "%ld", &lar_size );
00231 
00232             lar_size = ( lar_size + 1 ) & ~1;
00233 
00234             if (ar_hdr.ar_name[0] == '/' && ar_hdr.ar_name[1] == '/' )
00235             {
00236                 /* this is the "string table" entry of the symbol table,
00237                 ** which holds strings of filenames that are longer than
00238                 ** 15 characters (ie. don't fit into a ar_name
00239                 */
00240 
00241                 string_table = malloc(lar_size);
00242                 if (read(fd, string_table, lar_size) != lar_size)
00243                     printf("error reading string table\n");
00244                 offset += SARHDR + lar_size;
00245                 continue;
00246             }
00247             else if (ar_hdr.ar_name[0] == '/' && ar_hdr.ar_name[1] != ' ')
00248             {
00249                 /* Long filenames are recognized by "/nnnn" where nnnn is
00250                 ** the offset of the string in the string table represented
00251                 ** in ASCII decimals.
00252                 */
00253 
00254                 name = string_table + atoi( ar_hdr.ar_name + 1 );
00255                 endname = name + strlen( name );
00256             }
00257             else
00258             {
00259                 /* normal name */
00260                 name = ar_hdr.ar_name;
00261                 endname = name + sizeof( ar_hdr.ar_name );
00262             }
00263 
00264             /* strip trailing space, slashes, and backslashes */
00265 
00266             while( endname-- > name )
00267                 if( *endname != ' ' && *endname != '\\' && *endname != '/' )
00268                     break;
00269             *++endname = 0;
00270 
00271             /* strip leading directory names, an NT specialty */
00272 
00273             if( c = strrchr( name, '/' ) )
00274                 name = c + 1;
00275             if( c = strrchr( name, '\\' ) )
00276                 name = c + 1;
00277 
00278             sprintf( buf, "%s(%.*s)", archive, endname - name, name );
00279             (*func)( closure, buf, 1 /* time valid */, (time_t)lar_date );
00280 
00281             offset += SARHDR + lar_size;
00282             lseek( fd, offset, 0 );
00283         }
00284 
00285         close( fd );
00286 }

int file_time char *  filename,
time_t *  time
 

Definition at line 153 of file filent.c.

00156 {
00157         /* On NT this is called only for C:/ */
00158 
00159         struct stat statbuf;
00160 
00161         if( stat( filename, &statbuf ) < 0 )
00162             return -1;
00163 
00164         *time = statbuf.st_mtime;
00165 
00166         return 0;
00167 }

if ret  = handle < 0L )  ) 
 

Definition at line 122 of file filent.c.

References handle, and string_free().

00123     {
00124         string_free( filespec );
00125         return;
00126     }

Here is the call graph for this function:

string_free filespec   ) 
 

string_free filename   ) 
 

string_new filename   ) 
 

while ret  ) 
 

Definition at line 129 of file filent.c.

References f(), handle, path_build(), string_truncate(), and string::value.

00130     {
00131         f.f_base.ptr = finfo->name;
00132         f.f_base.len = strlen( finfo->name );
00133 
00134         string_truncate( filename, 0 );
00135         path_build( &f, filename, 0 );
00136 
00137         (*func)( closure, filename->value, 1 /* stat()'ed */, finfo->time_write );
00138  
00139         ret = _findnext( handle, finfo );
00140     }

Here is the call graph for this function:


Variable Documentation

handle = _findfirst( filespec->value, finfo )
 

Definition at line 120 of file filent.c.

Referenced by if(), and while().


Generated on Mon Nov 8 17:07:59 2004 for MPT by  doxygen 1.3.9.1