| # kio Library API Documentation
Overview | Class Hierarchy | Classes | Classes (annotated) | Members | Source Files

# kmimemagic.h

    00001 /* This file is part of the KDE project
    00002    Copyright (C) 1998, 1999 Torben Weis <weis@kde.org>
    00003
    00004    This library is free software; you can redistribute it and/or
    00005    modify it under the terms of the GNU Library General Public
    00006    License as published by the Free Software Foundation; either
    00007    version 2 of the License, or (at your option) any later version.
    00008
    00009    This library is distributed in the hope that it will be useful,
    00010    but WITHOUT ANY WARRANTY; without even the implied warranty of
    00011    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
    00012    Library General Public License for more details.
    00013
    00014    You should have received a copy of the GNU Library General Public License
    00015    along with this library; see the file COPYING.LIB.  If not, write to
    00016    the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
    00017    Boston, MA 02111-1307, USA.
    00018 */
    00019
    00020 /*
    00021  * KMimeMagic is inspired by the code of the
    00022  * Apache Web Server.
    00023  *
    00024  * Rewritten for KDE by Fritz Elfert
    00025  * fritz@kde.org
    00026  * Adaptations by Torben Weis <weis@kde.org>
    00027  * Fixes and documentation by David Faure <faure@kde.org>
    00028  */
    00029
    00030 #ifndef KMIMEMAGIC_H
    00031 #define KMIMEMAGIC_H
    00032
    00033 #include <qstring.h>
    00034
    00035 class KMimeMagic; // see below (read this one first)
    00036
    00045 class KMimeMagicResult
    00046 {
    00047 public:
    00048   KMimeMagicResult() { m_iAccuracy = 100; }
    00049   ~KMimeMagicResult() { }
    00050
    00054   QString mimeType() const { return m_strMimeType; }
    00058   int accuracy() const { return m_iAccuracy; }
    00062   bool isValid() const { return !m_strMimeType.isEmpty(); }
    00063
    00065   // Internal functions only
    00067   void setMimeType( const QString& _mime ) { m_strMimeType = _mime; }
    00068   void setAccuracy( int _accuracy ) { m_iAccuracy = _accuracy; }
    00069   void setInvalid() { m_strMimeType = QString::null; }
    00070
    00071 protected:
    00072   QString m_strMimeType;
    00073   int m_iAccuracy;
    00074 };
    00075
    00100 class KMimeMagic
    00101 {
    00102 public:
    00108   KMimeMagic();
    00109
    00113   KMimeMagic( const QString & configFile );
    00114
    00118   ~KMimeMagic();
    00119
    00126   bool mergeConfig( const QString & configFile );
    00127
    00134   bool mergeBufConfig(char *);
    00135
    00141   void setFollowLinks( bool _enable );
    00142
    00155   KMimeMagicResult* findFileType( const QString & _filename );
    00156
    00169   KMimeMagicResult* findBufferType( const QByteArray &p );
    00170
    00185   KMimeMagicResult * findBufferFileType( const QByteArray &, const QString & filename );
    00186
    00190   static KMimeMagic* self();
    00191
    00192 protected:
    00196   KMimeMagicResult * magicResult;
    00197
    00198   static void initStatic();
    00199   static KMimeMagic* s_pSelf;
    00200
    00201 private:
    00202   void init( const QString& configFile );
    00203
    00207   bool followLinks;
    00208
    00212   QString resultBuf;
    00213
    00214   int finishResult();
    00215   void process(const QString &);
    00216   void tryit(unsigned char *, int);
    00217   int fsmagic(const char *, struct stat *);
    00218   int match(unsigned char *, int);
    00219   int parse_line(char *line, int *rule, int lineno);
    00220   int parse(char *, int);
    00221   int buff_apprentice(char*buff);
    00222   int apprentice(const QString &configFile);
    00223   int ascmagic(unsigned char *, int);
    00224   int textmagic(unsigned char *, int);
    00225
    00226   struct config_rec *conf; // this is also our "d pointer"
    00227   int accuracy;
    00228 };
    00229
    00230 #endif
    00231

This file is part of the documentation for kdelibs Version 3.1.5.
Documentation copyright © 1996-2002 the KDE developers.
Generated on Wed Jan 28 13:13:41 2004 by doxygen 1.3.4 written by Dimitri van Heesch, © 1997-2001