lib Library API Documentation

main.cc

00001 /* This file is part of the KDE project 00002 Copyright (C) 1998, 1999, 2000 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 #include "koscript.h" 00021 00022 #include <kapplication.h> 00023 #include <klocale.h> 00024 #include <kcmdlineargs.h> 00025 #include <dcopclient.h> 00026 #include <qstring.h> 00027 #include <stdio.h> /* for printf */ 00028 #include <stdlib.h> 00029 #include <qdir.h> 00030 #include <iostream> 00031 00032 static KCmdLineOptions options[] = 00033 { 00034 { "+script", I18N_NOOP("Script to run"), 0 }, 00035 { "+-- [options]", I18N_NOOP("Options to pass to the script"), 0 }, 00036 KCmdLineLastOption 00037 }; 00038 00039 int main( int argc, char** argv ) 00040 { 00041 const char *appName = (argc > 1) ? argv[1] : "koscript"; 00042 KCmdLineArgs::init(argc, argv, appName, 00043 I18N_NOOP("KOffice script interpreter."), 00044 "2.0.0"); 00045 00046 KCmdLineArgs::addCmdLineOptions(options); 00047 00048 KApplication app; 00049 00050 KCmdLineArgs *args = KCmdLineArgs::parsedArgs(); 00051 00052 if (args->count() < 1) 00053 { 00054 fprintf(stderr, i18n("You must specify a script.\n").local8Bit()); 00055 ::exit(1); 00056 } 00057 00058 qDebug("..... KScript started"); 00059 { 00060 QStringList argList; 00061 for( int i = 1; i < args->count(); ++i ) 00062 argList.append( args->arg(i) ); 00063 00064 KSInterpreter script; 00065 script.addSearchPath( QDir::currentDirPath() ); 00066 QString ex = script.runScript( args->arg(0), argList ); 00067 if ( !ex.isEmpty() ) 00068 printf("%s\n",ex.local8Bit().data()); 00069 } 00070 std::cout << std::endl; // till I can come up with a working "flush" :} 00071 return 0; 00072 }
KDE Logo
This file is part of the documentation for lib Library Version 1.3.5.
Documentation copyright © 1996-2004 the KDE developers.
Generated on Wed Nov 17 06:54:20 2004 by doxygen 1.3.7 written by Dimitri van Heesch, © 1997-2003