#include "mystdlib.h" #include #include static int indexed = -1; int main( int argc, char **argv ) { MAP index = NULL; int i,j; char out[50]; if( argc != 3 ) { fputs( "Syntax: sortindex ", stderr); exit( 1 ); } if( ( indexed = open( argv[1], O_RDONLY ) ) == -1 ) { fprintf( stderr, "Could not open file: %s\n", argv[1] ); exit( 1 ); } if( !(index = map_file( argv[2], 0 ) ) ) exit( 1 ); for( i = 0; i < index->size; i+= 16 ) { unsigned char *x = i + (unsigned char*)index->addr; unsigned long p = *(unsigned long*)x; pread( indexed, out, 40, (off_t)p ); for( j=0;j<40;++j) if( out[j] == '\t' || out[j] == '\n' ) out[j] = 0; out[j] = 0; puts( out ); } unmap_file( &index ); close( indexed ); return 0; }