File indexing completed on 2024-04-28 04:40:00

0001 #include "api.h"
0002 #include "pole.h"
0003 #include <QtCore/QDebug>
0004 
0005 using namespace std;
0006 
0007 void
0008 testFile(const char* path) {
0009     POLE::Storage storage(path);
0010     if (!storage.open()) return;
0011     string prefix;
0012     if (storage.isDirectory("PP97_DUALSTORAGE")) {
0013         prefix = "PP97_DUALSTORAGE/";
0014     } else {
0015         prefix = "/";
0016     }
0017     list<string> entries = storage.entries(prefix);
0018     for (list<string>::const_iterator i=entries.begin(); i!=entries.end(); ++i) {
0019         // if encrypted, do not report failure.
0020         if (*i == "EncryptedSummary") return;
0021     }
0022     POLE::Stream stream(&storage, prefix + "PowerPoint Document");
0023 
0024     QByteArray array;
0025     array.resize(stream.size());
0026     unsigned long read = stream.read((unsigned char*)array.data(), stream.size());
0027     if (read != stream.size()) {
0028         qDebug() << "Error reading stream ";
0029         return;
0030     }
0031     MSO::PowerPointStructs s(array.data(), array.size());
0032     qDebug() << "Parsed " << s.getSize() << " of " << array.size() << ": "
0033         << ((s.getSize() == array.size())?"OK":"FAIL");
0034     if (s.getSize() != array.size()) {
0035         qDebug() << path;
0036     }
0037 }
0038 
0039 static const char* const fixedstring = "ABC";
0040 
0041 void testiterator() {
0042     MSO::TODOS t(fixedstring, 3);
0043     int total = 0;
0044     foreach (const MSO::Byte& b, t.anon()) {
0045         qDebug() << b.b();
0046         total += b.b();
0047     }
0048     for (int i = 0; i < t.anon().getCount(); ++i) {
0049         qDebug() << t.anon()[i].b();
0050         total += t.anon()[i].b();
0051     }
0052     qDebug() << total;
0053 }
0054 
0055 int
0056 main(int argc, char** argv) {
0057     //testiterator();
0058     for (int i=1; i<argc; ++i) {
0059         testFile(argv[i]);
0060     }
0061     return 0;
0062 }