#include #include #include #include int main(int argc, char *argv[]) { QCoreApplication app(argc, argv); QFile inf(argv[1]); QFile outf(argv[2]); inf.open(QIODevice::ReadOnly); outf.open(QIODevice::WriteOnly); QTextStream in(&inf); QTextStream out(&outf); do { // Find poster name for (;;) { QString nameLine = in.readLine(); int namePos = nameLine.indexOf("has just replied") - 1; if (namePos > 0) { static int count = 0; qDebug("Post No %d\n", count++); out << "[QUOTE=" << nameLine.left(namePos) << "]" << endl; break; } } // Find start of post for (;;) { QString postStart = in.readLine(); if (postStart == "***************") { break; } } // Post itself for (;;) { QString line = in.readLine(); // Check for quote begin if (line.contains("---Quote (Originally by ")) { int nameBegin = line.lastIndexOf(" ") + 1; int nameEnd = line.lastIndexOf(")"); out << "[QUOTE=" << line.mid(nameBegin, nameEnd - nameBegin) << "]" << endl; continue; } // Check for quote without name if (line == "---Quote---") { out << "[QUOTE]" << endl; continue; } // Check for quote end if (line == "---End Quote---") { out << "[\\QUOTE]" << endl; continue; } // Check for post end if (line == "***************") { out << "[\\QUOTE]" << endl; // Go to outer loop, start searching for next poster break; } // Check for stuff GMail adds if (line == "- Peida osundatud tekst -") { continue; } // Print everything else as-is out << line << endl; } } while (in.status() == QTextStream::Ok); return 0; }