summaryrefslogtreecommitdiff
path: root/src/postprocess/dumpindex2.c
diff options
context:
space:
mode:
authorDirk Engling <erdgeist@erdgeist.org>2014-02-20 02:46:41 +0100
committerDirk Engling <erdgeist@erdgeist.org>2014-02-20 02:46:41 +0100
commit64c85dfc1d3b546dd4b5f84168e9256817f3a741 (patch)
treee3de2e7a99362bfa1dfcde3d4bad3e76af179c61 /src/postprocess/dumpindex2.c
parent632c350fcf2021620afd032994e6e32c34c6dbfb (diff)
clean up source directory
Diffstat (limited to 'src/postprocess/dumpindex2.c')
-rw-r--r--src/postprocess/dumpindex2.c33
1 files changed, 33 insertions, 0 deletions
diff --git a/src/postprocess/dumpindex2.c b/src/postprocess/dumpindex2.c
new file mode 100644
index 0000000..f49a329
--- /dev/null
+++ b/src/postprocess/dumpindex2.c
@@ -0,0 +1,33 @@
1#include "mystdlib.h"
2#include <sys/mman.h>
3#include <fcntl.h>
4
5static int indexed = -1;
6
7int main( int argc, char **argv ) {
8 MAP index = NULL;
9 int i,j;
10 char out[50];
11
12 if( argc != 3 )
13 { fputs( "Syntax: sortindex <indexedfile> <indexfile>", stderr); exit( 1 ); }
14
15 if( ( indexed = open( argv[1], O_RDONLY ) ) == -1 )
16 { fprintf( stderr, "Could not open file: %s\n", argv[1] ); exit( 1 ); }
17
18 if( !(index = map_file( argv[2], 0 ) ) ) exit( 1 );
19
20 for( i = 0; i < index->size; i+= 16 ) {
21 unsigned char *x = i + (unsigned char*)index->addr;
22 unsigned long p = *(unsigned long*)x;
23
24 pread( indexed, out, 40, (off_t)p );
25 for( j=0;j<40;++j) if( out[j] == '\t' || out[j] == '\n' ) out[j] = 0; out[j] = 0;
26 puts( out );
27 }
28
29 unmap_file( &index );
30 close( indexed );
31
32 return 0;
33}