LCOV - code coverage report
Current view: top level - idl/source/prj - command.cxx (source / functions) Hit Total Coverage
Test: commit e02a6cb2c3e2b23b203b422e4e0680877f232636 Lines: 0 134 0.0 %
Date: 2014-04-14 Functions: 0 6 0.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2             : /*
       3             :  * This file is part of the LibreOffice project.
       4             :  *
       5             :  * This Source Code Form is subject to the terms of the Mozilla Public
       6             :  * License, v. 2.0. If a copy of the MPL was not distributed with this
       7             :  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
       8             :  *
       9             :  * This file incorporates work covered by the following license notice:
      10             :  *
      11             :  *   Licensed to the Apache Software Foundation (ASF) under one or more
      12             :  *   contributor license agreements. See the NOTICE file distributed
      13             :  *   with this work for additional information regarding copyright
      14             :  *   ownership. The ASF licenses this file to you under the Apache
      15             :  *   License, Version 2.0 (the "License"); you may not use this file
      16             :  *   except in compliance with the License. You may obtain a copy of
      17             :  *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
      18             :  */
      19             : 
      20             : 
      21             : #include <stdlib.h>
      22             : #include <stdio.h>
      23             : #include <string.h>
      24             : #include <ctype.h>
      25             : 
      26             : #include <command.hxx>
      27             : #include <globals.hxx>
      28             : #include <database.hxx>
      29             : #include "sal/config.h"
      30             : 
      31             : char const * SyntaxStrings[] = {
      32             : "basic-type:",
      33             : "\tvoid|        char|       int|        float|      double|",
      34             : "\tUINT16|      INT16|      UINT32|     INT32|      BOOL|",
      35             : "\tBYTE|        String|     SbxObject",
      36             : "",
      37             : "{ import \"filename\" }\n",
      38             : "module definition:",
      39             : "module",
      40             : "\tunique id range (ask MM)",
      41             : "modul-name",
      42             : "'['",
      43             : "\tSlotIdFile( \"filename\" )",
      44             : "']'",
      45             : "'{'",
      46             : "\t{ include \"filename\" }\n",
      47             : 
      48             : "\titem definition:",
      49             : "\titem type item-name;\n",
      50             : 
      51             : "\ttype definition:",
      52             : "\tstruct | union identifier",
      53             : "\t'{'",
      54             : "\t\t{ type idetifier }",
      55             : "\t'}'",
      56             : "\t|",
      57             : "\tenum identifier",
      58             : "\t'{'",
      59             : "\t\t{ identifier, }",
      60             : "\t'}'",
      61             : "\t|",
      62             : "\ttypedef type identifier\n",
      63             : 
      64             : "\titem-method:",
      65             : "\titem identifier item-method-args\n",
      66             : 
      67             : "\titem-method-args:",
      68             : "\t( { item parameter-name SLOT_ID } )\n",
      69             : 
      70             : "\tslot definition:",
      71             : "\titem identifier SLOT_ID [ item-method-args ]",
      72             : "\t'['\n",
      73             : 
      74             : "\t\titem-method-args",
      75             : "\t\tAccelConfig, MenuConfig, StatusBarConfig, ToolbarConfig",
      76             : "\t\tAutomation*",
      77             : "\t\tAutoUpdate",
      78             : "\t\tContainer",
      79             : "\t\tDefault        = Identifier",
      80             : "\t\tExecMethod     = Identifier",
      81             : "\t\tExport*",
      82             : "\t\tFastCall",
      83             : "\t\tGet, Set",
      84             : "\t\tGroupId        = Identifier",
      85             : "\t\tHasCoreId",
      86             : "\t\tHasDialog",
      87             : "\t\tIsCollection",
      88             : "\t\tImageRotation",
      89             : "\t\tImageReflection",
      90             : "\t\tPseudoPrefix   = Identifier",
      91             : "\t\tPseudoSlots",
      92             : "\t\tReadOnly",
      93             : "\t\tReadOnlyDoc*",
      94             : "\t\tRecordPerSet*, RecordPerItem, RecordManual, NoRecord",
      95             : "\t\tRecordAbsolute",
      96             : "\t\tStateMethod    = Identifier",
      97             : "\t\tSynchron*, Asynchron",
      98             : "\t\tToggle",
      99             : "\t']'\n",
     100             : 
     101             : "\tinterface definition:",
     102             : "\tshell | interface identifier ':' interface",
     103             : "\t'{'",
     104             : "\t\t{ slot }",
     105             : "\t'}'\n",
     106             : "---syntax example is sfx.idl---\n",
     107             : NULL };
     108             : 
     109             : char CommandLineSyntax[] =
     110             : "-fs<slotmap file>          -fl<listing file>\n"
     111             : "-fo<odl file>              -fd<data base file>\n"
     112             : "-fi<item implementation>   -ft<type library file> (not OLE)\n"
     113             : "-fr<resource file>         -fm<makefile target file>\n"
     114             : "-fC<c++ source file>       -fH<c++ header file>\n"
     115             : "-fc<c source file>         -fh<c header file>\n"
     116             : "-rsc <*.srs header line>\n"
     117             : "-help, ?                   @<file> response file\n"
     118             : " <filenames>\n";
     119             : 
     120           0 : void Init()
     121             : {
     122           0 :     if( !IDLAPP->pHashTable )
     123           0 :         IDLAPP->pHashTable      = new SvStringHashTable( 2801 );
     124           0 :     if( !IDLAPP->pGlobalNames )
     125           0 :         IDLAPP->pGlobalNames    = new SvGlobalHashNames();
     126           0 : }
     127             : 
     128           0 : void DeInit()
     129             : {
     130           0 :     delete IDLAPP;
     131           0 : }
     132             : 
     133           0 : sal_Bool ReadIdl( SvIdlWorkingBase * pDataBase, const SvCommand & rCommand )
     134             : {
     135           0 :     for( size_t n = 0; n < rCommand.aInFileList.size(); ++n )
     136             :     {
     137           0 :         OUString aFileName ( rCommand.aInFileList[ n ] );
     138           0 :         pDataBase->AddDepFile(aFileName);
     139           0 :         SvFileStream aStm( aFileName, STREAM_STD_READ | STREAM_NOCREATE );
     140           0 :         if( aStm.GetError() == SVSTREAM_OK )
     141             :         {
     142           0 :             if( pDataBase->IsBinaryFormat( aStm ) )
     143             :             {
     144           0 :                 pDataBase->Load( aStm );
     145           0 :                 if( aStm.GetError() != SVSTREAM_OK )
     146             :                 {
     147           0 :                     OStringBuffer aStr;
     148           0 :                     if( aStm.GetError() == SVSTREAM_FILEFORMAT_ERROR )
     149           0 :                         aStr.append("error: incompatible format, file ");
     150           0 :                     else if( aStm.GetError() == SVSTREAM_WRONGVERSION )
     151           0 :                         aStr.append("error: wrong version, file ");
     152             :                     else
     153           0 :                         aStr.append("error during load, file ");
     154             :                     aStr.append(OUStringToOString(aFileName,
     155           0 :                         RTL_TEXTENCODING_UTF8));
     156           0 :                     fprintf( stderr, "%s\n", aStr.getStr() );
     157           0 :                     return sal_False;
     158             :                 }
     159             :             }
     160             :             else
     161             :             {
     162           0 :                 SvTokenStream aTokStm( aStm, aFileName );
     163           0 :                 if( !pDataBase->ReadSvIdl( aTokStm, sal_False, rCommand.aPath ) )
     164           0 :                     return sal_False;
     165             :             }
     166             :         }
     167             :         else
     168             :         {
     169             :             const OString aStr(OUStringToOString(aFileName,
     170           0 :                 RTL_TEXTENCODING_UTF8));
     171           0 :             fprintf( stderr, "unable to read input file: %s\n", aStr.getStr() );
     172           0 :             return sal_False;
     173             :         }
     174           0 :     }
     175           0 :     return sal_True;
     176             : }
     177             : 
     178           0 : static sal_Bool ResponseFile( StringList * pList, int argc, char ** argv )
     179             : {
     180             :     // program name
     181           0 :     pList->push_back( OUString::createFromAscii(*argv) );
     182           0 :     for( int i = 1; i < argc; i++ )
     183             :     {
     184           0 :         if( '@' == **(argv +i) )
     185             :         { // when @, then response file
     186           0 :             SvFileStream aStm( OUString::createFromAscii((*(argv +i)) +1), STREAM_STD_READ | STREAM_NOCREATE );
     187           0 :             if( aStm.GetError() != SVSTREAM_OK )
     188           0 :                 return sal_False;
     189             : 
     190           0 :             OString aStr;
     191           0 :             while( aStm.ReadLine( aStr ) )
     192             :             {
     193           0 :                 sal_uInt16 n = 0;
     194           0 :                 sal_uInt16 nPos = 1;
     195           0 :                 while( n != nPos )
     196             :                 {
     197           0 :                     while( aStr[n] && isspace( aStr[n] ) )
     198           0 :                         n++;
     199           0 :                     nPos = n;
     200           0 :                     while( aStr[n] && !isspace( aStr[n] ) )
     201           0 :                         n++;
     202           0 :                     if( n != nPos )
     203           0 :                         pList->push_back( OStringToOUString(aStr.copy(nPos, n - nPos), RTL_TEXTENCODING_ASCII_US) );
     204             :                 }
     205           0 :             }
     206             :         }
     207           0 :         else if( argv[ i ] )
     208           0 :             pList->push_back( OUString::createFromAscii( argv[ i ] ) );
     209             :     }
     210           0 :     return sal_True;
     211             : }
     212             : 
     213           0 : SvCommand::SvCommand( int argc, char ** argv )
     214           0 :     : nVerbosity(1), nFlags( 0 )
     215             : {
     216           0 :     StringList aList;
     217             : 
     218           0 :     if( ResponseFile( &aList, argc, argv ) )
     219             :     {
     220           0 :         for( size_t i = 1; i < aList.size(); i++ )
     221             :         {
     222           0 :             OUString aParam( aList[ i ] );
     223           0 :             sal_Unicode aFirstChar( aParam[0] );
     224           0 :             if( '-' == aFirstChar )
     225             :             {
     226           0 :                 aParam = aParam.copy( 1 );
     227           0 :                 aFirstChar = aParam[0];
     228           0 :                 if( aFirstChar == 'F' || aFirstChar == 'f' )
     229             :                 {
     230           0 :                     aParam = aParam.copy( 1 );
     231           0 :                     aFirstChar = aParam[0];
     232           0 :                     OUString aName( aParam.copy( 1 ) );
     233           0 :                     if( 's' == aFirstChar )
     234             :                     { // name of slot output
     235           0 :                         aSlotMapFile = aName;
     236             :                     }
     237           0 :                     else if( 'l' == aFirstChar )
     238             :                     { // name of listing
     239           0 :                         aListFile = aName;
     240             :                     }
     241           0 :                     else if( 'i' == aFirstChar )
     242             :                     {
     243             :                     }
     244           0 :                     else if( 'o' == aFirstChar )
     245             :                     {
     246             :                     }
     247           0 :                     else if( 'd' == aFirstChar )
     248             :                     { // name of data set file
     249           0 :                         aDataBaseFile = aName;
     250             :                     }
     251           0 :                     else if( 'D' == aFirstChar )
     252             :                     {
     253             :                     }
     254           0 :                     else if( 'C' == aFirstChar )
     255             :                     {
     256             :                     }
     257           0 :                     else if( 'H' == aFirstChar )
     258             :                     {
     259             :                     }
     260           0 :                     else if( 'c' == aFirstChar )
     261             :                     {
     262             :                     }
     263           0 :                     else if( 'h' == aFirstChar )
     264             :                     {
     265             :                     }
     266           0 :                     else if( 't' == aFirstChar )
     267             :                     {
     268             :                     }
     269           0 :                     else if( 'm' == aFirstChar )
     270             :                     { // name of info file
     271           0 :                         aTargetFile = aName;
     272             :                     }
     273           0 :                     else if( 'r' == aFirstChar )
     274             :                     {
     275             :                     }
     276           0 :                     else if( 'z' == aFirstChar )
     277             :                     { // name of HelpId file
     278           0 :                         aHelpIdFile = aName;
     279             :                     }
     280           0 :                     else if( 'y' == aFirstChar )
     281             :                     { // name of CSV file
     282           0 :                         aCSVFile = aName;
     283             :                     }
     284           0 :                     else if( 'x' == aFirstChar )
     285             :                     { // name of IDL file for the CSV file
     286           0 :                         aExportFile = aName;
     287             :                     }
     288           0 :                     else if( 'M' == aFirstChar )
     289             :                     {
     290           0 :                         m_DepFile = aName;
     291             :                     }
     292             :                     else
     293             :                     {
     294             :                         printf(
     295             :                             "unknown switch: %s\n",
     296             :                             OUStringToOString(
     297           0 :                                 aParam, RTL_TEXTENCODING_UTF8).getStr());
     298           0 :                         exit( -1 );
     299           0 :                     }
     300             :                 }
     301           0 :                 else if( aParam.equalsIgnoreAsciiCase( "help" ) || aParam.equalsIgnoreAsciiCase( "?" ) )
     302             :                 { // help
     303           0 :                     printf( "%s", CommandLineSyntax );
     304             :                 }
     305           0 :                 else if( aParam.equalsIgnoreAsciiCase( "quiet" ) )
     306             :                 {
     307           0 :                     nVerbosity = 0;
     308             :                 }
     309           0 :                 else if( aParam.equalsIgnoreAsciiCase( "verbose" ) )
     310             :                 {
     311           0 :                     nVerbosity = 2;
     312             :                 }
     313           0 :                 else if( aParam.equalsIgnoreAsciiCase( "syntax" ) )
     314             :                 { // help
     315           0 :                     int j = 0;
     316           0 :                     while(SyntaxStrings[j])
     317           0 :                         printf("%s\n",SyntaxStrings[j++]);
     318             :                 }
     319           0 :                 else if( aParam.startsWithIgnoreAsciiCase( "i" ) )
     320             :                 { // define include paths
     321           0 :                     OUString aName( aParam.copy( 1 ) );
     322           0 :                     if( !aPath.isEmpty() )
     323           0 :                         aPath += OUString( SAL_PATHSEPARATOR );
     324           0 :                     aPath += aName;
     325             :                 }
     326           0 :                 else if( aParam.startsWithIgnoreAsciiCase( "rsc" ) )
     327             :                 { // first line in *.srs file
     328             :                     OSL_ENSURE(false, "does anything use this option, doesn't look like it belong here");
     329           0 :                     if( !aList[ i + 1 ].isEmpty() )
     330             :                     {
     331           0 :                         i++;
     332             :                     }
     333             :                 }
     334             :                 else
     335             :                 {
     336             :                     // temporary compatibility hack
     337             :                     printf(
     338             :                         "unknown switch: %s\n",
     339             :                         OUStringToOString(
     340           0 :                             aParam, RTL_TEXTENCODING_UTF8).getStr());
     341           0 :                     exit( -1 );
     342             :                 }
     343             :             }
     344             :             else
     345             :             {
     346           0 :                 aInFileList.push_back( aParam );
     347             :             }
     348           0 :         }
     349             :     }
     350             :     else
     351             :     {
     352           0 :         printf( "%s", CommandLineSyntax );
     353             :     }
     354             : 
     355           0 :     aList.clear();
     356             : 
     357           0 :     OString aInc(getenv("INCLUDE"));
     358             :     // append include environment variable
     359           0 :     if( aInc.getLength() )
     360             :     {
     361           0 :         if( !aPath.isEmpty() )
     362           0 :             aPath += OUString( SAL_PATHSEPARATOR );
     363           0 :         aPath += OStringToOUString(aInc, RTL_TEXTENCODING_ASCII_US);
     364           0 :     }
     365           0 : }
     366             : 
     367           0 : SvCommand::~SvCommand()
     368             : {
     369             :     // release String list
     370           0 :     aInFileList.clear();
     371           0 : }
     372             : 
     373             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10