/xmlbench/trunk

To get this branch, use:
bzr branch http://darksoft.org/webbzr/xmlbench/trunk

« back to all changes in this revision

Viewing changes to parse/vtdxml.c

  • Committer: Suren A. Chilingaryan
  • Date: 2009-09-28 21:25:28 UTC
  • Revision ID: csa@dside.dyndns.org-20090928212528-e6oby5he4yrueskz
Parsing tests for mono, vtd-xml, lisp, scripting languages

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#include <stdio.h>
 
2
#include <sys/time.h>
 
3
 
 
4
#include <vtdGen.h>
 
5
#include <vtdNav.h>
 
6
#include <autoPilot.h>
 
7
 
 
8
 
 
9
#define PREPARE_XML
 
10
#include "tools.h"
 
11
 
 
12
struct exception_context the_exception_context[1];
 
13
 
 
14
int pre_mode = 0;
 
15
VTDGen *vg = NULL;
 
16
char *idxbuf;
 
17
int idxlen;
 
18
 
 
19
void initXML(struct TestData *td) {
 
20
//    if (getenv("allow_deferring")) deferring_mode = 1;
 
21
    if (getenv("allow_preprocessing")) pre_mode = 1;
 
22
 
 
23
    vg = createVTDGen();
 
24
}
 
25
 
 
26
void releaseXML(struct TestData *td) {
 
27
    freeVTDGen(vg);
 
28
}
 
29
 
 
30
void preparseXML(struct TestData *td, unsigned long iter) {
 
31
    FILE *f;
 
32
    if (pre_mode) {
 
33
        setDoc(vg,td->xml,td->xmllen);
 
34
        parse(vg,1);
 
35
        
 
36
        f = fopen("/tmp/vtdxml.test", "w");
 
37
        if (!f) {
 
38
            printf("Can't write temporary file\n");
 
39
            exit(1);
 
40
        }
 
41
        writeIndex(vg, f);
 
42
        fclose(f);
 
43
        idxbuf = ReadFile("/tmp/vtdxml.test");
 
44
        clear(vg);
 
45
    }
 
46
}
 
47
 
 
48
void postparseXML(struct TestData *td, unsigned long iter) {
 
49
    if (pre_mode) {
 
50
        free(idxbuf);
 
51
    }
 
52
}
 
53
 
 
54
 
 
55
void parseXML(struct TestData *td, unsigned long iter) {
 
56
    VTDNav *vn;
 
57
 
 
58
    if (pre_mode) {
 
59
        vn = loadIndex2(vg, idxbuf + sizeof(unsigned long), (*(unsigned long*)idxbuf));
 
60
    } else {
 
61
        // This destructs original string
 
62
        setDoc(vg,td->xml,td->xmllen);
 
63
        parse(vg,1);
 
64
        vn = getNav(vg);
 
65
    }
 
66
    
 
67
    freeVTDNav(vn);
 
68
    //clear(vg);        // done by getNav
 
69
 
 
70
}
 
71
 
 
72
 
 
73
int main(int argc, char *argv[]) {
 
74
    return Test(argc,argv);
 
75
}