File indexing completed on 2024-04-21 14:56:19

0001 /*
0002     This file is part of the KDE project
0003     SPDX-FileCopyrightText: 2015-2016 Ralf Habacker <ralf.habacker@freenet.de>
0004 
0005     SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL
0006 */
0007 
0008 #include "loggingcategory.h"
0009 
0010 #include <QCoreApplication>
0011 #include <QProcess>
0012 #include <QStandardPaths>
0013 
0014 #include <stdio.h>
0015 
0016 int main(int argc, char **argv)
0017 {
0018     QCoreApplication app(argc, argv);
0019 
0020     const QStringList arguments = app.arguments();
0021     if (arguments.count() != 2) {
0022         qCCritical(KDocToolsLog) << "wrong argument count";
0023         return (1);
0024     }
0025 
0026     const QString exec = QStandardPaths::findExecutable(QStringLiteral("meinproc5"));
0027     if (exec.isEmpty()) {
0028         qCCritical(KDocToolsLog) << "Could not find meinproc5 executable in PATH";
0029         return 1;
0030     }
0031 
0032     QProcess meinproc;
0033     meinproc.start(exec, QStringList{QStringLiteral("--check"), QStringLiteral("--stdout"), arguments[1]});
0034     if (!meinproc.waitForStarted()) {
0035         return -2;
0036     }
0037     if (!meinproc.waitForFinished()) {
0038         return -1;
0039     }
0040     fprintf(stderr, "%s", meinproc.readAllStandardError().constData());
0041     return meinproc.exitCode();
0042 }