1
#include "api.h"
2
#include "pole.h"
3
#include <QtCore/QDebug>
4
5
using namespace std;
6
7
void
8
testFile(const char* path) {
9
    POLE::Storage storage(path);
10
    if (!storage.open()) return;
11
    string prefix;
12
    if (storage.isDirectory("PP97_DUALSTORAGE")) {
13
        prefix = "PP97_DUALSTORAGE/";
14
    } else {
15
        prefix = "/";
16
    }
17
    list<string> entries = storage.entries(prefix);
18
    for (list<string>::const_iterator i=entries.begin(); i!=entries.end(); ++i) {
19
        // if encrypted, do not report failure.
20
        if (*i == "EncryptedSummary") return;
21
    }
22
    POLE::Stream stream(&storage, prefix + "PowerPoint Document");
23
24
    QByteArray array;
25
    array.resize(stream.size());
26
    unsigned long read = stream.read((unsigned char*)array.data(), stream.size());
27
    if (read != stream.size()) {
28
        qDebug() << "Error reading stream ";
29
        return;
30
    }
31
    MSO::PowerPointStructs s(array.data(), array.size());
32
    qDebug() << "Parsed " << s.getSize() << " of " << array.size() << ": "
33
        << ((s.getSize() == array.size())?"OK":"FAIL");
34
    if (s.getSize() != array.size()) {
35
        qDebug() << path;
36
    }
37
}
38
39
static const char* const fixedstring = "ABC";
40
41
void testiterator() {
42
    MSO::TODOS t(fixedstring, 3);
43
    int total = 0;
44
    foreach (const MSO::Byte& b, t.anon()) {
45
        qDebug() << b.b();
46
        total += b.b();
47
    }
48
    for (int i = 0; i < t.anon().getCount(); ++i) {
49
        qDebug() << t.anon()[i].b();
50
        total += t.anon()[i].b();
51
    }
52
    qDebug() << total;
53
}
54
55
int
56
main(int argc, char** argv) {
57
    //testiterator();
58
    for (int i=1; i<argc; ++i) {
59
        testFile(argv[i]);
60
    }
61
    return 0;
62
}