# dcop Library API Documentation

Overview | Class Hierarchy | Classes | Classes (annotated) | Members | Namespaces | Source Files

# 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 <qstring.h>
    00024 #include <qfile.h>
    00025 #include <qcstring.h>
    00026 #include <stdlib.h>
    00027
    00028 void dcopidlParse( const char *_code );
    00029
    00030 int idl_line_no;
    00031
    00032 #if YYDEBUG
    00033 extern int yydebug;
    00034 #endif
    00035
    00036 int main( int argc, char** argv )
    00037 {
    00038     if (argc != 2)
    00039     {
    00040         fprintf(stderr, "Usage : dcopidl input_file\n");
    00041         return -1;
    00042     }
    00043     QFile file( argv[1] );
    00044     if ( !file.open( IO_ReadOnly ) )
    00045     {
    00046         fprintf(stderr, "Can't open input file\n");
    00047         return -1;
    00048     }
    00049
    00050     QByteArray arr = file.readAll();
    00051     uint len = arr.size();
    00052     uint j = 1;
    00053     for (uint i = 1; i<len; i++, j++) {
    00054         if (arr[ i-1 ] == '\r' && ((i+1)==len || arr[ i ] != '\n')) {
    00055             // change single \r's (Mac OS line endings) to \n
    00056             arr[ j-1 ] = '\n';
    00057             if ((i+1)==len) //special case: cut last character
    00058                 j--;
    00059         }
    00060         else if (arr[ i-1 ] == '\r' && arr[ i ] == '\n') {
    00061             // change \r\n's (win32 line endings) to \n
    00062             arr[ j-1 ] = '\n';
    00063             i++; //skip \n
    00064         }
    00065         else if (i!=j) {
    00066             arr[ j-1 ] = arr[ i-1 ];
    00067         }
    00068     }
    00069     len = j;
    00070     arr.resize( len + 1 );
    00071     arr[ len ] = 0;
    00072
    00073 #if YYDEBUG
    00074     char *debug = getenv("DEBUG");
    00075     if (debug)
    00076     yydebug = 1;
    00077 #endif
    00078     idl_line_no = 1;
    00079
    00080     printf("<!DOCTYPE DCOP-IDL><DCOP-IDL>\n");
    00081     printf("<SOURCE>%s</SOURCE>\n", argv[1] );
    00082     dcopidlParse( arr.data() );
    00083     printf("</DCOP-IDL>\n");
    00084
    00085     file.close();
    00086     return 0;
    00087 }

This file is part of the documentation for dcop Library Version 3.4.1.
Documentation copyright © 1996-2004 the KDE developers.
Generated on Sat Jun 11 20:16:55 2005 by doxygen 1.4.1 written by Dimitri van Heesch, © 1997-2003