dcop Library API Documentation

main.cpp

00001 /***************************************************************** 00002 Copyright (c) 1999 Torben Weis <weis@kde.org> 00003 Copyright (c) 2000 Matthias Ettrich <ettrich@kde.org> 00004 00005 Permission is hereby granted, free of charge, to any person obtaining a copy 00006 of this software and associated documentation files (the "Software"), to deal 00007 in the Software without restriction, including without limitation the rights 00008 to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 00009 copies of the Software, and to permit persons to whom the Software is 00010 furnished to do so, subject to the following conditions: 00011 00012 The above copyright notice and this permission notice shall be included in 00013 all copies or substantial portions of the Software. 00014 00015 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 00016 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 00017 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 00018 AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN 00019 AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 00020 CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 00021 00022 ******************************************************************/ 00023 #include <qdom.h> 00024 #include <qfile.h> 00025 #include <qtextstream.h> 00026 #include <qstring.h> 00027 00028 #include <string.h> 00029 #include <stdlib.h> 00030 #include <stdio.h> 00031 #include <unistd.h> 00032 #include "main.h" 00033 00034 00035 00036 void usage() 00037 { 00038 fprintf( stderr, "Usage: dcopidl2cpp [ --no-skel | --no-stub ] [--c++-suffix <suffix>] file\n" ); 00039 } 00040 00041 int main( int argc, char** argv ) 00042 { 00043 00044 if ( *qVersion() == '1' ) { 00045 fprintf( stderr, "dcopidl2cpp appears to be linked to Qt 1 instead of Qt >= 2 ! Aborting.\n" ); 00046 exit(1); 00047 } 00048 int argpos = 1; 00049 bool generate_skel = true; 00050 bool generate_stub = true; 00051 00052 QString suffix = "cpp"; 00053 00054 while (argc > 2) { 00055 00056 if ( strcmp( argv[argpos], "--no-skel" ) == 0 ) 00057 { 00058 generate_skel = false; 00059 for (int i = argpos; i < argc - 1; i++) argv[i] = argv[i+1]; 00060 argc--; 00061 } 00062 else if ( strcmp( argv[argpos], "--no-stub" ) == 0 ) 00063 { 00064 generate_stub = false; 00065 for (int i = argpos; i < argc - 1; i++) argv[i] = argv[i+1]; 00066 argc--; 00067 } 00068 else if ( strcmp( argv[argpos], "--no-signals" ) == 0 ) 00069 { 00070 // Obsolete: Signal stubs are now always generated. 00071 // Leave this command line argument intact, so old Makefiles won't break. 00072 for (int i = argpos; i < argc - 1; i++) argv[i] = argv[i+1]; 00073 argc--; 00074 } 00075 else if ( strcmp( argv[argpos], "--c++-suffix" ) == 0) 00076 { 00077 if (argc - 1 < argpos) { 00078 usage(); 00079 exit(1); 00080 } 00081 suffix = argv[argpos+1]; 00082 for (int i = argpos; i < argc - 2; i++) argv[i] = argv[i+2]; 00083 argc -= 2; 00084 } else { 00085 usage(); 00086 exit(1); 00087 00088 } 00089 } 00090 00091 QFile in( QFile::decodeName(argv[argpos]) ); 00092 if ( !in.open( IO_ReadOnly ) ) 00093 qFatal("Could not read %s", argv[argpos] ); 00094 00095 QDomDocument doc; 00096 doc.setContent( &in ); 00097 00098 QDomElement de = doc.documentElement(); 00099 Q_ASSERT( de.tagName() == "DCOP-IDL" ); 00100 00101 QString base( argv[argpos] ); 00102 QString idl = base; 00103 00104 int pos = base.findRev( '.' ); 00105 if ( pos != -1 ) 00106 base = base.left( pos ); 00107 00108 pos = idl.findRev('/'); 00109 if ( pos != -1 ) 00110 idl = idl.mid( pos+1 ); 00111 00112 if ( generate_skel ) 00113 generateSkel( idl, base + "_skel." + suffix, de ); 00114 00115 if ( generate_stub ) { 00116 QString header = base; 00117 generateStub( idl, header + "_stub.h", de ); 00118 pos = header.findRev('/'); 00119 if ( pos != -1 ) 00120 header = header.mid( pos+1 ); 00121 generateStubImpl( idl, header + "_stub.h", base+".h", base + "_stub." + suffix, de); 00122 } 00123 00124 return 0; 00125 }
KDE Logo
This file is part of the documentation for dcop Library Version 3.2.3.
Documentation copyright © 1996-2004 the KDE developers.
Generated on Fri Aug 20 09:48:10 2004 by doxygen 1.3.7 written by Dimitri van Heesch, © 1997-2003