1 /* This file is part of the KDE libraries
2 Copyright (c) 2000 Matthias Hoelzer-Kluepfel <mhk@caldera.de>
5 This library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Library General Public
7 License as published by the Free Software Foundation; either
8 version 2 of the License, or (at your option) any later version.
10 This library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Library General Public License for more details.
15 You should have received a copy of the GNU Library General Public License
16 along with this library; see the file COPYING.LIB. If not, write to
17 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
18 Boston, MA 02110-1301, USA.
26 #include <QTextStream>
28 #include <kio/global.h>
29 #include <kio/slavebase.h>
31 class MANProtocol
: public QObject
, public KIO::SlaveBase
37 MANProtocol(const QByteArray
&pool_socket
, const QByteArray
&app_socket
);
38 virtual ~MANProtocol();
40 virtual void get(const KUrl
& url
);
41 virtual void stat(const KUrl
& url
);
43 virtual void mimetype(const KUrl
&url
);
44 virtual void listDir(const KUrl
&url
);
46 void outputError(const QString
& errmsg
);
47 void outputMatchingPages(const QStringList
&matchingPages
);
50 void showIndex(const QString
& section
);
52 // the following two functions are the interface to man2html
53 void output(const char *insert
);
54 char *readManPage(const char *filename
);
56 static MANProtocol
*self();
60 QStringList
manDirectories();
61 QMap
<QString
, QString
> buildIndexMap(const QString
& section
);
62 bool addWhatIs(QMap
<QString
, QString
>& i
, const QString
& f
, const QString
& mark
);
63 void parseWhatIs( QMap
<QString
, QString
> &i
, QTextStream
&t
, const QString
&mark
);
64 QStringList
findPages(const QString
& section
,
66 bool full_path
= true);
68 void addToBuffer(const char *buffer
, int buflen
);
69 QString
pageName(const QString
& page
) const;
70 QStringList
buildSectionList(const QStringList
& dirs
) const;
71 void constructPath(QStringList
& constr_path
, QStringList constr_catmanpath
);
73 static MANProtocol
*_self
;
76 void findManPagesInSection(const QString
&dir
, const QString
&title
, bool full_path
, QStringList
&list
);
77 QStringList m_manpath
; ///< Path of man directories
78 QStringList m_mandbpath
; ///< Path of catman directories
79 QStringList section_names
;
81 QString mySgml2RoffPath
;
82 void getProgramPath();
84 QByteArray m_cssPath
; ///< Path to KDE resources, encoded for CSS
85 QBuffer m_outputBuffer
; ///< Buffer for the output
86 QByteArray m_manCSSFile
; ///< Path to kio_man.css