add idx2ldif (dump data as ldif)
This commit is contained in:
6
Makefile
6
Makefile
@@ -1,6 +1,6 @@
|
||||
#DEBUG=1
|
||||
DEBUG=1
|
||||
|
||||
all: t1 t2 parse dumpidx addindex bindrequest tinyldap tinyldap_standalone tinyldap_debug ldapclient ldapclient_str # t
|
||||
all: t1 t2 parse dumpidx idx2ldif addindex bindrequest tinyldap tinyldap_standalone tinyldap_debug ldapclient ldapclient_str # t
|
||||
|
||||
asn1.a: fmt_asn1intpayload.o fmt_asn1length.o fmt_asn1tag.o \
|
||||
fmt_asn1int.o fmt_asn1string.o fmt_asn1transparent.o scan_asn1tag.o \
|
||||
@@ -56,7 +56,7 @@ tinyldap_debug: tinyldap.c
|
||||
clean:
|
||||
rm -f t t[1-9] *.[ao] bindrequest tinyldap ldapclient data \
|
||||
parse tinyldap_standalone tinyldap_debug ldapclient_str addindex \
|
||||
dumpidx *.da *.bbg *.bb *.gcov gmon.out
|
||||
dumpidx idx2ldif *.da *.bbg *.bb *.gcov gmon.out
|
||||
|
||||
tar: clean
|
||||
cd ..; tar cvvf tinyldap.tar.bz2 tinyldap --use=bzip2 --exclude capture --exclude CVS --exclude exp.ldif --exclude polyp* --exclude rfc*
|
||||
|
||||
48
idx2ldif.c
Normal file
48
idx2ldif.c
Normal file
@@ -0,0 +1,48 @@
|
||||
#include "buffer.h"
|
||||
#include "mmap.h"
|
||||
#include "uint32.h"
|
||||
|
||||
int main() {
|
||||
int verbose=1;
|
||||
long filelen;
|
||||
char* map=mmap_read("data",&filelen);
|
||||
uint32 magic,attribute_count,record_count,indices_offset,size_of_string_table;
|
||||
uint32_unpack(map,&magic);
|
||||
uint32_unpack(map+4,&attribute_count);
|
||||
uint32_unpack(map+2*4,&record_count);
|
||||
uint32_unpack(map+3*4,&indices_offset);
|
||||
uint32_unpack(map+4*4,&size_of_string_table);
|
||||
|
||||
if (verbose) {
|
||||
unsigned long i;
|
||||
char* x=map+5*4+size_of_string_table+attribute_count*8;
|
||||
for (i=0; i<record_count; ++i) {
|
||||
uint32 j,k;
|
||||
uint32_unpack(x,&j);
|
||||
|
||||
x+=8;
|
||||
buffer_puts(buffer_1,"dn: ");
|
||||
uint32_unpack(x,&k);
|
||||
buffer_puts(buffer_1,map+k);
|
||||
buffer_puts(buffer_1,"\nobjectClass: ");
|
||||
x+=4;
|
||||
uint32_unpack(x,&k);
|
||||
buffer_puts(buffer_1,map+k);
|
||||
buffer_puts(buffer_1,"\n");
|
||||
x+=4;
|
||||
for (; j>2; --j) {
|
||||
uint32_unpack(x,&k);
|
||||
buffer_puts(buffer_1,map+k);
|
||||
buffer_puts(buffer_1,": ");
|
||||
uint32_unpack(x+4,&k);
|
||||
buffer_puts(buffer_1,map+k);
|
||||
buffer_puts(buffer_1,"\n");
|
||||
x+=8;
|
||||
}
|
||||
buffer_puts(buffer_1,"\n");
|
||||
}
|
||||
}
|
||||
buffer_flush(buffer_1);
|
||||
|
||||
return 0;
|
||||
}
|
||||
Reference in New Issue
Block a user