• Skip to content
  • Skip to link menu
KDE 4.0 API Reference
  • KDE API Reference
  • kdelibs
  • Sitemap
  • Contact Us
 

KInit

kioslave.cpp

Go to the documentation of this file.
00001 /*
00002  * This file is part of the KDE libraries
00003  * Copyright (c) 1999-2000 Waldo Bastian <bastian@kde.org>
00004  *           (c) 1999 Mario Weilguni <mweilguni@sime.com>
00005  *           (c) 2001 Lubos Lunak <l.lunak@kde.org>
00006  *
00007  * This library is free software; you can redistribute it and/or
00008  * modify it under the terms of the GNU Library General Public
00009  * License version 2 as published by the Free Software Foundation.
00010  *
00011  * This library is distributed in the hope that it will be useful,
00012  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00013  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00014  * Library General Public License for more details.
00015  *
00016  * You should have received a copy of the GNU Library General Public License
00017  * along with this library; see the file COPYING.LIB.  If not, write to
00018  * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
00019  * Boston, MA 02110-1301, USA.
00020  */
00021 
00022 #include <config.h>
00023 
00024 #include <stdlib.h>
00025 #include <stdio.h>
00026 #include <errno.h>
00027 
00028 #include <QtCore/QString>
00029 #include <QtCore/QLibrary>
00030 #include <QtCore/QFile>
00031 #ifdef Q_WS_WIN
00032 #include <QtCore/QDir>
00033 #include <QtCore/QProcess>
00034 #include <QtCore/QStringList>
00035 #include <windows.h>
00036 #include "kstandarddirs.h"
00037 #endif
00038 
00039 #ifndef Q_WS_WIN
00040 /* These are to link libkio even if 'smart' linker is used */
00041 #include <kio/authinfo.h>
00042 extern "C" KIO::AuthInfo* _kioslave_init_kio() { return new KIO::AuthInfo(); }
00043 #endif 
00044 
00045 int main(int argc, char **argv)
00046 {
00047      if (argc < 5)
00048      {
00049         fprintf(stderr, "Usage: kioslave <slave-lib> <protocol> <klauncher-socket> <app-socket>\n\nThis program is part of KDE.\n");
00050         exit(1);
00051      }
00052      QString libpath = QFile::decodeName(argv[1]);
00053 
00054      if (libpath.isEmpty())
00055      {
00056         fprintf(stderr, "library path is empty.\n");
00057         exit(1); 
00058      }
00059 
00060      QLibrary lib(libpath);
00061 #ifdef Q_WS_WIN
00062      qDebug("trying to load '%s'", qPrintable(libpath));
00063 #endif
00064      if ( !lib.load() || !lib.isLoaded() )
00065      {
00066 #ifdef Q_WS_WIN
00067         libpath = KStandardDirs::installPath("module") + QFileInfo(libpath).fileName();
00068         lib.setFileName( libpath );
00069         if(!lib.load() || !lib.isLoaded())
00070         {
00071             QByteArray kdedirs = qgetenv("KDEDIRS");
00072             if (!kdedirs.size()) {
00073               qDebug("not able to find '%s' because KDEDIRS environment variable is not set.\n"
00074                      "Set KDEDIRS to the KDE installation root dir and restart klauncher to fix this problem.",
00075                      qPrintable(libpath));
00076               exit(1);
00077             }
00078             QString paths = QString::fromLocal8Bit(kdedirs);
00079             QStringList pathlist = paths.split(';');
00080             Q_FOREACH(QString path, pathlist) {
00081               QString slave_path = path + QLatin1String("/lib/kde4/") + libpath;
00082               qDebug("trying to load '%s'",slave_path.toAscii().data());
00083               lib.setFileName(slave_path);
00084               if (lib.load() && lib.isLoaded() )
00085                 break;
00086             }
00087             if (!lib.isLoaded())
00088             {
00089               fprintf(stderr, "could not open %s: %s", libpath.data(),
00090                       qPrintable (lib.errorString()) );
00091               exit(1);
00092             }
00093         }
00094 #else
00095         fprintf(stderr, "could not open %s: %s", qPrintable(libpath),
00096                 qPrintable (lib.errorString()) );
00097         exit(1);
00098 #endif
00099      }  
00100 
00101      void* sym = lib.resolve("kdemain");
00102      if (!sym )
00103      {
00104         sym = lib.resolve("main");
00105         if (!sym )
00106         {
00107            fprintf(stderr, "Could not find main: %s\n", qPrintable(lib.errorString() ));
00108            exit(1);
00109         }
00110      }
00111 
00112 #ifdef Q_WS_WIN
00113      // enter debugger in case debugging is actived 
00114      QString mSlaveDebug = getenv("KDE_SLAVE_DEBUG_WAIT");
00115 
00116      if (mSlaveDebug == argv[2]) 
00117 #ifdef Q_CC_GNU
00118      {
00119         // gdb does not support win32 jit debug support, so implement it by ourself
00120         QByteArray buf(1024,0);
00121         GetModuleFileName(NULL,buf.data(),buf.size());
00122         QStringList params;
00123         params << buf;
00124         params << QString::number(GetCurrentProcessId());
00125         QProcess::startDetached("gdb",params);
00126         Sleep(1000);
00127      }
00128 #else
00129         // msvc: windbg supports jit debugging, require install windbg jit with windbg -i
00130         DebugBreak();
00131 #endif
00132 #endif
00133 
00134      int (*func)(int, char *[]) = (int (*)(int, char *[])) sym;
00135 
00136      exit( func(argc-1, argv+1)); /* Launch! */
00137 }

KInit

Skip menu "KInit"
  • Main Page
  • Namespace List
  • Class Hierarchy
  • Alphabetical List
  • Class List
  • File List
  • Class Members
  • Related Pages

kdelibs

Skip menu "kdelibs"
  • DNSSD
  • Interfaces
  •   KHexEdit
  •   KMediaPlayer
  •   KSpeech
  •   KTextEditor
  • Kate
  • kconf_update
  • KDE3Support
  •   KUnitTest
  • KDECore
  • KDED
  • KDEsu
  • KDEUI
  • KDocTools
  • KFile
  • KHTML
  • KImgIO
  • KInit
  • KIO
  • KIOSlave
  • KJS
  •   WTF
  • KJSEmbed
  • KNewStuff
  • KParts
  • Kross
  • KUtils
  • Nepomuk
  •   core
  • Phonon
  •   Backend
  • Solid
  • Sonnet
  • ThreadWeaver
Generated for kdelibs by doxygen 1.5.4
This website is maintained by Adriaan de Groot and Allen Winter.
KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal