1 | |
2 | #include "meinproc_common.h" |
3 | |
4 | #include "xslt.h" |
5 | |
6 | #include <QCoreApplication> |
7 | #include <QtCore/QString> |
8 | #include <QtCore/QFile> |
9 | #include <QtCore/QDir> |
10 | #include <QtCore/QTextCodec> |
11 | #include <QtCore/QFileInfo> |
12 | #include <QtCore/QList> |
13 | |
14 | #include <libxml/xmlversion.h> |
15 | #include <libxml/xmlmemory.h> |
16 | #include <libxml/debugXML.h> |
17 | #include <libxml/HTMLtree.h> |
18 | #include <libxml/xmlIO.h> |
19 | #include <libxml/catalog.h> |
20 | #include <libxml/parserInternals.h> |
21 | #include <libxslt/xsltconfig.h> |
22 | #include <libxslt/xsltInternals.h> |
23 | #include <libxslt/transform.h> |
24 | #include <libxslt/xsltutils.h> |
25 | #include <libexslt/exslt.h> |
26 | |
27 | #include <stdlib.h> |
28 | #include <string.h> |
29 | #include <sys/time.h> |
30 | #include <unistd.h> |
31 | |
32 | #ifndef _WIN32 |
33 | extern "C" int xmlLoadExtDtdDefaultValue; |
34 | #endif |
35 | |
36 | int main(int argc, char **argv) { |
37 | |
38 | // xsltSetGenericDebugFunc(stderr, NULL); |
39 | |
40 | QCoreApplication app( argc, argv ); |
41 | |
42 | const QStringList arguments = app.arguments(); |
43 | if ( arguments.count() != 4 ) { |
44 | qCritical() << "wrong argument count" ; |
45 | return ( 1 ); |
46 | } |
47 | |
48 | const QString srcDir = arguments[1]; |
49 | const QString xmllintPath = arguments[2]; |
50 | const QString checkFilename = arguments[3]; |
51 | const QString customizationCatalog = srcDir + "/customization/catalog.xml" ; |
52 | |
53 | if ( checkFile( checkFilename ) != CheckFileSuccess ) |
54 | { |
55 | qCritical() << "checkFile failed in " << checkFilename; |
56 | return ( 2 ); |
57 | } |
58 | if ( checkFile( customizationCatalog ) != CheckFileSuccess ) |
59 | { |
60 | qCritical() << "checkFile failed in " << customizationCatalog; |
61 | return ( 2 ); |
62 | } |
63 | |
64 | exsltRegisterAll(); |
65 | |
66 | QByteArray catalogs; |
67 | catalogs += customizationCatalog.toUtf8(); |
68 | |
69 | setenv( "XML_CATALOG_FILES" , catalogs.constData(), 1 ); |
70 | xmlInitializeCatalog(); |
71 | |
72 | LIBXML_TEST_VERSION |
73 | |
74 | if ( check( checkFilename, xmllintPath, catalogs ) != CheckSuccess ) |
75 | { |
76 | qWarning() << "Check failed" ; |
77 | return 3; |
78 | } |
79 | |
80 | xmlSubstituteEntitiesDefault(1); |
81 | xmlLoadExtDtdDefaultValue = 1; |
82 | |
83 | QVector<const char *> params; |
84 | params.append( NULL ); |
85 | |
86 | const QString tss = srcDir + "/customization/kde-chunk.xsl" ; |
87 | QString output = transform(checkFilename , tss, params); |
88 | if (output.isEmpty()) { |
89 | fprintf(stderr, "unable to parse %s\n" , checkFilename.toLocal8Bit().data()); |
90 | return(4); |
91 | } |
92 | |
93 | doOutput(output, true, false, QString(), false /* replaceCharset */); |
94 | |
95 | xmlCleanupParser(); |
96 | xmlMemoryDump(); |
97 | return(0); |
98 | } |
99 | |
100 | |