1*cdf0e10cSrcweir /************************************************************************* 2*cdf0e10cSrcweir * 3*cdf0e10cSrcweir * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4*cdf0e10cSrcweir * 5*cdf0e10cSrcweir * Copyright 2000, 2010 Oracle and/or its affiliates. 6*cdf0e10cSrcweir * 7*cdf0e10cSrcweir * OpenOffice.org - a multi-platform office productivity suite 8*cdf0e10cSrcweir * 9*cdf0e10cSrcweir * This file is part of OpenOffice.org. 10*cdf0e10cSrcweir * 11*cdf0e10cSrcweir * OpenOffice.org is free software: you can redistribute it and/or modify 12*cdf0e10cSrcweir * it under the terms of the GNU Lesser General Public License version 3 13*cdf0e10cSrcweir * only, as published by the Free Software Foundation. 14*cdf0e10cSrcweir * 15*cdf0e10cSrcweir * OpenOffice.org is distributed in the hope that it will be useful, 16*cdf0e10cSrcweir * but WITHOUT ANY WARRANTY; without even the implied warranty of 17*cdf0e10cSrcweir * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18*cdf0e10cSrcweir * GNU Lesser General Public License version 3 for more details 19*cdf0e10cSrcweir * (a copy is included in the LICENSE file that accompanied this code). 20*cdf0e10cSrcweir * 21*cdf0e10cSrcweir * You should have received a copy of the GNU Lesser General Public License 22*cdf0e10cSrcweir * version 3 along with OpenOffice.org. If not, see 23*cdf0e10cSrcweir * <http://www.openoffice.org/license.html> 24*cdf0e10cSrcweir * for a copy of the LGPLv3 License. 25*cdf0e10cSrcweir * 26*cdf0e10cSrcweir ************************************************************************/ 27*cdf0e10cSrcweir 28*cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove 29*cdf0e10cSrcweir #include "precompiled_rsc.hxx" 30*cdf0e10cSrcweir 31*cdf0e10cSrcweir #include <stdlib.h> 32*cdf0e10cSrcweir #include <stdio.h> 33*cdf0e10cSrcweir #include <fcntl.h> 34*cdf0e10cSrcweir #include <string.h> 35*cdf0e10cSrcweir #if defined (WNT) && defined (tcpp) 36*cdf0e10cSrcweir #define _spawnvp spawnvp 37*cdf0e10cSrcweir #define _P_WAIT P_WAIT 38*cdf0e10cSrcweir #endif 39*cdf0e10cSrcweir 40*cdf0e10cSrcweir #ifdef UNX 41*cdf0e10cSrcweir #include <unistd.h> 42*cdf0e10cSrcweir #include <sys/wait.h> 43*cdf0e10cSrcweir #else // UNX 44*cdf0e10cSrcweir 45*cdf0e10cSrcweir #include <io.h> 46*cdf0e10cSrcweir #include <process.h> 47*cdf0e10cSrcweir #if defined ( OS2 ) && !defined ( GCC ) 48*cdf0e10cSrcweir #include <direct.h> 49*cdf0e10cSrcweir #endif 50*cdf0e10cSrcweir #if !defined ( CSET ) && !defined ( OS2 ) 51*cdf0e10cSrcweir #include <dos.h> 52*cdf0e10cSrcweir #endif 53*cdf0e10cSrcweir 54*cdf0e10cSrcweir #endif // UNX 55*cdf0e10cSrcweir #include <rsctools.hxx> 56*cdf0e10cSrcweir #include <rscerror.h> 57*cdf0e10cSrcweir #include <sal/main.h> 58*cdf0e10cSrcweir #include <tools/fsys.hxx> 59*cdf0e10cSrcweir 60*cdf0e10cSrcweir /*************** C O D E ************************************************/ 61*cdf0e10cSrcweir /****************************************************************/ 62*cdf0e10cSrcweir /* */ 63*cdf0e10cSrcweir /* Function : fuer Ansi kompatibilitaet */ 64*cdf0e10cSrcweir /* */ 65*cdf0e10cSrcweir /****************************************************************/ 66*cdf0e10cSrcweir #ifdef UNX 67*cdf0e10cSrcweir #define P_WAIT 0 68*cdf0e10cSrcweir int spawnvp( int, const char * cmdname, char *const* argv ){ 69*cdf0e10cSrcweir int rc(0); 70*cdf0e10cSrcweir 71*cdf0e10cSrcweir switch( fork() ){ 72*cdf0e10cSrcweir case -1: 73*cdf0e10cSrcweir return( -1 ); 74*cdf0e10cSrcweir case 0: 75*cdf0e10cSrcweir if( execvp( cmdname, argv ) == -1 ) 76*cdf0e10cSrcweir // an error occurs 77*cdf0e10cSrcweir return( -1 ); 78*cdf0e10cSrcweir break; 79*cdf0e10cSrcweir default: 80*cdf0e10cSrcweir if( -1 == wait( &rc ) ) 81*cdf0e10cSrcweir return( -1 ); 82*cdf0e10cSrcweir } 83*cdf0e10cSrcweir return( WEXITSTATUS( rc ) ); 84*cdf0e10cSrcweir } 85*cdf0e10cSrcweir #endif 86*cdf0e10cSrcweir 87*cdf0e10cSrcweir /************************************************************************* 88*cdf0e10cSrcweir |* CallPrePro() 89*cdf0e10cSrcweir |* 90*cdf0e10cSrcweir |* Beschreibung 91*cdf0e10cSrcweir *************************************************************************/ 92*cdf0e10cSrcweir static sal_Bool CallPrePro( const ByteString& rPrePro, 93*cdf0e10cSrcweir const ByteString& rInput, 94*cdf0e10cSrcweir const ByteString& rOutput, 95*cdf0e10cSrcweir RscPtrPtr * pCmdLine, 96*cdf0e10cSrcweir sal_Bool bResponse ) 97*cdf0e10cSrcweir { 98*cdf0e10cSrcweir RscPtrPtr aNewCmdL; // Kommandozeile 99*cdf0e10cSrcweir RscPtrPtr aRespCmdL; // Kommandozeile 100*cdf0e10cSrcweir RscPtrPtr * pCmdL = &aNewCmdL; 101*cdf0e10cSrcweir int i, nExit; 102*cdf0e10cSrcweir FILE* fRspFile = NULL; 103*cdf0e10cSrcweir ByteString aRspFileName; 104*cdf0e10cSrcweir 105*cdf0e10cSrcweir if( bResponse ) 106*cdf0e10cSrcweir { 107*cdf0e10cSrcweir aRspFileName = ::GetTmpFileName(); 108*cdf0e10cSrcweir fRspFile = fopen( aRspFileName.GetBuffer(), "w" ); 109*cdf0e10cSrcweir } 110*cdf0e10cSrcweir 111*cdf0e10cSrcweir if( !fRspFile ) 112*cdf0e10cSrcweir aNewCmdL.Append( rsc_strdup( rPrePro.GetBuffer() ) ); 113*cdf0e10cSrcweir 114*cdf0e10cSrcweir bool bVerbose = false; 115*cdf0e10cSrcweir for( i = 1; i < int(pCmdLine->GetCount() -1); i++ ) 116*cdf0e10cSrcweir { 117*cdf0e10cSrcweir if ( 0 == rsc_stricmp( (char *)pCmdLine->GetEntry( i ), "-verbose" ) ) 118*cdf0e10cSrcweir { 119*cdf0e10cSrcweir bVerbose = true; 120*cdf0e10cSrcweir continue; 121*cdf0e10cSrcweir } 122*cdf0e10cSrcweir if ( !rsc_strnicmp( (char *)pCmdLine->GetEntry( i ), "-u", 2 ) 123*cdf0e10cSrcweir || !rsc_strnicmp( (char *)pCmdLine->GetEntry( i ), "-i", 2 ) 124*cdf0e10cSrcweir || !rsc_strnicmp( (char *)pCmdLine->GetEntry( i ), "-d", 2 ) 125*cdf0e10cSrcweir ) 126*cdf0e10cSrcweir { 127*cdf0e10cSrcweir aNewCmdL.Append( rsc_strdup( (char *)pCmdLine->GetEntry( i ) ) ); 128*cdf0e10cSrcweir } 129*cdf0e10cSrcweir } 130*cdf0e10cSrcweir 131*cdf0e10cSrcweir aNewCmdL.Append( rsc_strdup( rInput.GetBuffer() ) ); 132*cdf0e10cSrcweir aNewCmdL.Append( rsc_strdup( rOutput.GetBuffer() ) ); 133*cdf0e10cSrcweir aNewCmdL.Append( (void *)0 ); 134*cdf0e10cSrcweir 135*cdf0e10cSrcweir if ( bVerbose ) 136*cdf0e10cSrcweir { 137*cdf0e10cSrcweir printf( "Preprocessor commandline: " ); 138*cdf0e10cSrcweir for( i = 0; i < (int)(pCmdL->GetCount() -1); i++ ) 139*cdf0e10cSrcweir { 140*cdf0e10cSrcweir printf( " " ); 141*cdf0e10cSrcweir printf( "%s", (const char *)pCmdL->GetEntry( i ) ); 142*cdf0e10cSrcweir } 143*cdf0e10cSrcweir printf( "\n" ); 144*cdf0e10cSrcweir } 145*cdf0e10cSrcweir 146*cdf0e10cSrcweir if( fRspFile ) 147*cdf0e10cSrcweir { 148*cdf0e10cSrcweir aRespCmdL.Append( rsc_strdup( rPrePro.GetBuffer() ) ); 149*cdf0e10cSrcweir ByteString aTmpStr( '@' ); 150*cdf0e10cSrcweir aTmpStr += aRspFileName; 151*cdf0e10cSrcweir aRespCmdL.Append( rsc_strdup( aTmpStr.GetBuffer() ) ); 152*cdf0e10cSrcweir aRespCmdL.Append( (void *)0 ); 153*cdf0e10cSrcweir 154*cdf0e10cSrcweir pCmdL = &aRespCmdL; 155*cdf0e10cSrcweir for( i = 0; i < (int)(aNewCmdL.GetCount() -1); i++ ) 156*cdf0e10cSrcweir { 157*cdf0e10cSrcweir #ifdef OS2 158*cdf0e10cSrcweir fprintf( fRspFile, "%s\n", (const char *)aNewCmdL.GetEntry( i ) ); 159*cdf0e10cSrcweir #else 160*cdf0e10cSrcweir fprintf( fRspFile, "%s ", (const char *)aNewCmdL.GetEntry( i ) ); 161*cdf0e10cSrcweir #endif 162*cdf0e10cSrcweir } 163*cdf0e10cSrcweir fclose( fRspFile ); 164*cdf0e10cSrcweir 165*cdf0e10cSrcweir if ( bVerbose ) 166*cdf0e10cSrcweir { 167*cdf0e10cSrcweir printf( "Preprocessor startline: " ); 168*cdf0e10cSrcweir for( i = 0; i < (int)(pCmdL->GetCount() -1); i++ ) 169*cdf0e10cSrcweir { 170*cdf0e10cSrcweir printf( " " ); 171*cdf0e10cSrcweir printf( "%s", (const char *)pCmdL->GetEntry( i ) ); 172*cdf0e10cSrcweir } 173*cdf0e10cSrcweir printf( "\n" ); 174*cdf0e10cSrcweir } 175*cdf0e10cSrcweir } 176*cdf0e10cSrcweir 177*cdf0e10cSrcweir #if ((defined OS2 || defined WNT) && (defined TCPP || defined tcpp)) || defined UNX || defined OS2 178*cdf0e10cSrcweir nExit = spawnvp( P_WAIT, rPrePro.GetBuffer(), (char* const*)pCmdL->GetBlock() ); 179*cdf0e10cSrcweir #elif defined CSET 180*cdf0e10cSrcweir nExit = spawnvp( P_WAIT, (char*)rPrePro.GetBuffer(), (const char**)pCmdL->GetBlock() ); 181*cdf0e10cSrcweir #elif defined WTC 182*cdf0e10cSrcweir nExit = spawnvp( P_WAIT, (char*)rPrePro.GetBuffer(), (const char* const*)pCmdL->GetBlock() ); 183*cdf0e10cSrcweir #elif defined MTW 184*cdf0e10cSrcweir nExit = spawnvp( P_WAIT, (char*)rPrePro.GetBuffer(), (char**)pCmdL->GetBlock() ); 185*cdf0e10cSrcweir #else 186*cdf0e10cSrcweir nExit = spawnvp( P_WAIT, (char*)rPrePro.GetBuffer(), (const char**)pCmdL->GetBlock() ); 187*cdf0e10cSrcweir #endif 188*cdf0e10cSrcweir 189*cdf0e10cSrcweir if ( fRspFile ) 190*cdf0e10cSrcweir #if OSL_DEBUG_LEVEL > 5 191*cdf0e10cSrcweir fprintf( stderr, "leaving response file %s\n", aRspFileName.GetBuffer() ); 192*cdf0e10cSrcweir #else 193*cdf0e10cSrcweir unlink( aRspFileName.GetBuffer() ); 194*cdf0e10cSrcweir #endif 195*cdf0e10cSrcweir if ( nExit ) 196*cdf0e10cSrcweir return sal_False; 197*cdf0e10cSrcweir 198*cdf0e10cSrcweir return sal_True; 199*cdf0e10cSrcweir } 200*cdf0e10cSrcweir 201*cdf0e10cSrcweir 202*cdf0e10cSrcweir /************************************************************************* 203*cdf0e10cSrcweir |* CallRsc2 204*cdf0e10cSrcweir |* 205*cdf0e10cSrcweir |* Beschreibung 206*cdf0e10cSrcweir *************************************************************************/ 207*cdf0e10cSrcweir static sal_Bool CallRsc2( ByteString aRsc2Name, 208*cdf0e10cSrcweir RscStrList * pInputList, 209*cdf0e10cSrcweir ByteString aSrsName, 210*cdf0e10cSrcweir RscPtrPtr * pCmdLine ) 211*cdf0e10cSrcweir { 212*cdf0e10cSrcweir int i, nExit; 213*cdf0e10cSrcweir ByteString* pString; 214*cdf0e10cSrcweir ByteString aRspFileName; // Response-Datei 215*cdf0e10cSrcweir FILE * fRspFile; // Response-Datei 216*cdf0e10cSrcweir 217*cdf0e10cSrcweir aRspFileName = ::GetTmpFileName(); 218*cdf0e10cSrcweir fRspFile = fopen( aRspFileName.GetBuffer(), "w" ); 219*cdf0e10cSrcweir 220*cdf0e10cSrcweir RscVerbosity eVerbosity = RscVerbosityNormal; 221*cdf0e10cSrcweir if( fRspFile ) 222*cdf0e10cSrcweir { 223*cdf0e10cSrcweir for( i = 1; i < (int)(pCmdLine->GetCount() -1); i++ ) 224*cdf0e10cSrcweir { 225*cdf0e10cSrcweir if ( !rsc_stricmp( (char *)pCmdLine->GetEntry( i ), "-verbose" ) ) 226*cdf0e10cSrcweir { 227*cdf0e10cSrcweir eVerbosity = RscVerbosityVerbose; 228*cdf0e10cSrcweir continue; 229*cdf0e10cSrcweir } 230*cdf0e10cSrcweir if ( !rsc_stricmp( (char *)pCmdLine->GetEntry( i ), "-quiet" ) ) 231*cdf0e10cSrcweir { 232*cdf0e10cSrcweir eVerbosity = RscVerbositySilent; 233*cdf0e10cSrcweir continue; 234*cdf0e10cSrcweir } 235*cdf0e10cSrcweir if( !rsc_strnicmp( (char *)pCmdLine->GetEntry( i ), "-fp=", 4 ) 236*cdf0e10cSrcweir || !rsc_strnicmp( (char *)pCmdLine->GetEntry( i ), "-fo=", 4 ) 237*cdf0e10cSrcweir || !rsc_strnicmp( (char *)pCmdLine->GetEntry( i ), "-pp=", 4 ) 238*cdf0e10cSrcweir || !rsc_strnicmp( (char *)pCmdLine->GetEntry( i ), "-rsc2=", 6 ) 239*cdf0e10cSrcweir || !rsc_strnicmp( (char *)pCmdLine->GetEntry( i ), "-presponse", 9 ) 240*cdf0e10cSrcweir || !rsc_strnicmp( (char *)pCmdLine->GetEntry( i ), "-rc", 3 ) 241*cdf0e10cSrcweir || !rsc_stricmp( (char *)pCmdLine->GetEntry( i ), "-+" ) 242*cdf0e10cSrcweir || !rsc_stricmp( (char *)pCmdLine->GetEntry( i ), "-br" ) 243*cdf0e10cSrcweir || !rsc_stricmp( (char *)pCmdLine->GetEntry( i ), "-bz" ) 244*cdf0e10cSrcweir || !rsc_stricmp( (char *)pCmdLine->GetEntry( i ), "-r" ) 245*cdf0e10cSrcweir // Am I the only one that thinks the following line inludes all the tests before? 246*cdf0e10cSrcweir || ( '-' != *(char *)pCmdLine->GetEntry( i ) ) ) 247*cdf0e10cSrcweir { 248*cdf0e10cSrcweir } 249*cdf0e10cSrcweir else 250*cdf0e10cSrcweir #ifdef OS2 251*cdf0e10cSrcweir fprintf( fRspFile, "%s\n", 252*cdf0e10cSrcweir #else 253*cdf0e10cSrcweir fprintf( fRspFile, "%s ", 254*cdf0e10cSrcweir #endif 255*cdf0e10cSrcweir (const char *)pCmdLine->GetEntry( i ) ); 256*cdf0e10cSrcweir }; 257*cdf0e10cSrcweir 258*cdf0e10cSrcweir #ifdef OS2 259*cdf0e10cSrcweir fprintf( fRspFile, "%s\n", aSrsName.GetBuffer() ); 260*cdf0e10cSrcweir #else 261*cdf0e10cSrcweir fprintf( fRspFile, aSrsName.GetBuffer() ); 262*cdf0e10cSrcweir #endif 263*cdf0e10cSrcweir 264*cdf0e10cSrcweir pString = pInputList->First(); 265*cdf0e10cSrcweir while( pString ) 266*cdf0e10cSrcweir { 267*cdf0e10cSrcweir #ifdef OS2 268*cdf0e10cSrcweir fprintf( fRspFile, "%s\n", pString->GetBuffer() ); 269*cdf0e10cSrcweir #else 270*cdf0e10cSrcweir fprintf( fRspFile, " %s", pString->GetBuffer() ); 271*cdf0e10cSrcweir #endif 272*cdf0e10cSrcweir pString = pInputList->Next(); 273*cdf0e10cSrcweir }; 274*cdf0e10cSrcweir 275*cdf0e10cSrcweir fclose( fRspFile ); 276*cdf0e10cSrcweir }; 277*cdf0e10cSrcweir 278*cdf0e10cSrcweir RscPtrPtr aNewCmdL; // Kommandozeile 279*cdf0e10cSrcweir aNewCmdL.Append( rsc_strdup( aRsc2Name.GetBuffer() ) ); 280*cdf0e10cSrcweir ByteString aTmpStr( '@' ); 281*cdf0e10cSrcweir aTmpStr += aRspFileName; 282*cdf0e10cSrcweir aNewCmdL.Append( rsc_strdup( aTmpStr.GetBuffer() ) ); 283*cdf0e10cSrcweir aNewCmdL.Append( (void *)0 ); 284*cdf0e10cSrcweir 285*cdf0e10cSrcweir if ( eVerbosity >= RscVerbosityVerbose ) 286*cdf0e10cSrcweir { 287*cdf0e10cSrcweir printf( "Rsc2 commandline: " ); 288*cdf0e10cSrcweir printf( "%s", (const char *)aNewCmdL.GetEntry( 0 ) ); 289*cdf0e10cSrcweir printf( " " ); 290*cdf0e10cSrcweir printf( "%s", (const char *)aNewCmdL.GetEntry( 1 ) ); 291*cdf0e10cSrcweir printf( "\n" ); 292*cdf0e10cSrcweir } 293*cdf0e10cSrcweir 294*cdf0e10cSrcweir #if ((defined OS2 || defined WNT) && (defined TCPP || defined tcpp)) || defined UNX || defined OS2 295*cdf0e10cSrcweir nExit = spawnvp( P_WAIT, aRsc2Name.GetBuffer(), (char* const*)aNewCmdL.GetBlock() ); 296*cdf0e10cSrcweir #elif defined CSET 297*cdf0e10cSrcweir nExit = spawnvp( P_WAIT, (char*)aRsc2Name.GetBuffer(), (char **)(const char**)aNewCmdL.GetBlock() ); 298*cdf0e10cSrcweir #elif defined WTC 299*cdf0e10cSrcweir nExit = spawnvp( P_WAIT, (char*)aRsc2Name.GetBuffer(), (const char* const*)aNewCmdL.GetBlock() ); 300*cdf0e10cSrcweir #elif defined MTW 301*cdf0e10cSrcweir nExit = spawnvp( P_WAIT, (char*)aRsc2Name.GetBuffer(), (char**)aNewCmdL.GetBlock() ); 302*cdf0e10cSrcweir #else 303*cdf0e10cSrcweir nExit = spawnvp( P_WAIT, (char*)aRsc2Name.GetBuffer(), (const char**)aNewCmdL.GetBlock() ); 304*cdf0e10cSrcweir #endif 305*cdf0e10cSrcweir 306*cdf0e10cSrcweir if( fRspFile ) 307*cdf0e10cSrcweir #if OSL_DEBUG_LEVEL > 5 308*cdf0e10cSrcweir fprintf( stderr, "leaving response file %s\n", aRspFileName.GetBuffer() ); 309*cdf0e10cSrcweir #else 310*cdf0e10cSrcweir unlink( aRspFileName.GetBuffer() ); 311*cdf0e10cSrcweir #endif 312*cdf0e10cSrcweir if( nExit ) 313*cdf0e10cSrcweir return( sal_False ); 314*cdf0e10cSrcweir return( sal_True ); 315*cdf0e10cSrcweir } 316*cdf0e10cSrcweir 317*cdf0e10cSrcweir /************************************************************************* 318*cdf0e10cSrcweir |* 319*cdf0e10cSrcweir |* main() 320*cdf0e10cSrcweir |* 321*cdf0e10cSrcweir |* Beschreibung 322*cdf0e10cSrcweir |* Ersterstellung MM 05.09.91 323*cdf0e10cSrcweir |* Letzte Aenderung MM 05.09.91 324*cdf0e10cSrcweir |* 325*cdf0e10cSrcweir *************************************************************************/ 326*cdf0e10cSrcweir SAL_IMPLEMENT_MAIN_WITH_ARGS(argc, argv) 327*cdf0e10cSrcweir { 328*cdf0e10cSrcweir sal_Bool bPrePro = sal_True; 329*cdf0e10cSrcweir sal_Bool bResFile = sal_True; 330*cdf0e10cSrcweir sal_Bool bHelp = sal_False; 331*cdf0e10cSrcweir sal_Bool bError = sal_False; 332*cdf0e10cSrcweir sal_Bool bResponse = sal_False; 333*cdf0e10cSrcweir ByteString aSolarbin(getenv("SOLARBINDIR")); 334*cdf0e10cSrcweir ByteString aDelim("/"); 335*cdf0e10cSrcweir ByteString aPrePro; //( aSolarbin + aDelim + ByteString("rscpp")); 336*cdf0e10cSrcweir ByteString aRsc2Name; //( aSolarbin + aDelim + ByteString("rsc2")); 337*cdf0e10cSrcweir ByteString aSrsName; 338*cdf0e10cSrcweir ByteString aResName; 339*cdf0e10cSrcweir RscStrList aInputList; 340*cdf0e10cSrcweir RscStrList aTmpList; 341*cdf0e10cSrcweir char * pStr; 342*cdf0e10cSrcweir char ** ppStr; 343*cdf0e10cSrcweir RscPtrPtr aCmdLine; // Kommandozeile 344*cdf0e10cSrcweir sal_uInt32 i; 345*cdf0e10cSrcweir ByteString* pString; 346*cdf0e10cSrcweir 347*cdf0e10cSrcweir aPrePro = aSolarbin; 348*cdf0e10cSrcweir aPrePro += aDelim; 349*cdf0e10cSrcweir aPrePro += ByteString("rscpp"); 350*cdf0e10cSrcweir 351*cdf0e10cSrcweir aRsc2Name = aSolarbin; 352*cdf0e10cSrcweir aRsc2Name += aDelim; 353*cdf0e10cSrcweir aRsc2Name += ByteString("rsc2"); 354*cdf0e10cSrcweir 355*cdf0e10cSrcweir pStr = ::ResponseFile( &aCmdLine, argv, argc ); 356*cdf0e10cSrcweir if( pStr ) 357*cdf0e10cSrcweir { 358*cdf0e10cSrcweir printf( "Cannot open response file <%s>\n", pStr ); 359*cdf0e10cSrcweir return( 1 ); 360*cdf0e10cSrcweir }; 361*cdf0e10cSrcweir 362*cdf0e10cSrcweir ppStr = (char **)aCmdLine.GetBlock(); 363*cdf0e10cSrcweir ppStr++; 364*cdf0e10cSrcweir i = 1; 365*cdf0e10cSrcweir sal_Bool bSetSrs = sal_False; 366*cdf0e10cSrcweir while( ppStr && i < (aCmdLine.GetCount() -1) ) 367*cdf0e10cSrcweir { 368*cdf0e10cSrcweir if( '-' == **ppStr ) 369*cdf0e10cSrcweir { 370*cdf0e10cSrcweir if( !rsc_stricmp( (*ppStr) + 1, "p" ) 371*cdf0e10cSrcweir || !rsc_stricmp( (*ppStr) + 1, "l" ) ) 372*cdf0e10cSrcweir { // kein Preprozessor 373*cdf0e10cSrcweir bPrePro = sal_False; 374*cdf0e10cSrcweir } 375*cdf0e10cSrcweir else if( !rsc_stricmp( (*ppStr) + 1, "r" ) 376*cdf0e10cSrcweir || !rsc_stricmp( (*ppStr) + 1, "s" ) ) 377*cdf0e10cSrcweir { // erzeugt kein .res-file 378*cdf0e10cSrcweir bResFile = sal_False; 379*cdf0e10cSrcweir } 380*cdf0e10cSrcweir else if( !rsc_stricmp( (*ppStr) + 1, "h" ) ) 381*cdf0e10cSrcweir { // Hilfe anzeigen 382*cdf0e10cSrcweir bHelp = sal_True; 383*cdf0e10cSrcweir } 384*cdf0e10cSrcweir else if( !rsc_strnicmp( (*ppStr) + 1, "presponse", 9 ) ) 385*cdf0e10cSrcweir { // anderer Name fuer den Preprozessor 386*cdf0e10cSrcweir bResponse = sal_True; 387*cdf0e10cSrcweir } 388*cdf0e10cSrcweir else if( !rsc_strnicmp( (*ppStr) + 1, "pp=", 3 ) ) 389*cdf0e10cSrcweir { // anderer Name fuer den Preprozessor 390*cdf0e10cSrcweir aPrePro = (*ppStr) + 4; 391*cdf0e10cSrcweir } 392*cdf0e10cSrcweir else if( !rsc_strnicmp( (*ppStr) + 1, "rsc2=", 5 ) ) 393*cdf0e10cSrcweir { // Accept alternate name for the rsc2 compiler 394*cdf0e10cSrcweir aRsc2Name = (*ppStr) + 6; 395*cdf0e10cSrcweir } 396*cdf0e10cSrcweir else if( !rsc_strnicmp( (*ppStr) + 1, "fo=", 3 ) ) 397*cdf0e10cSrcweir { // anderer Name fuer .res-file 398*cdf0e10cSrcweir aResName = (*ppStr) + 4; 399*cdf0e10cSrcweir } 400*cdf0e10cSrcweir else if( !rsc_strnicmp( (*ppStr) + 1, "fp=", 3 ) ) 401*cdf0e10cSrcweir { // anderer Name fuer .srs-file 402*cdf0e10cSrcweir bSetSrs = sal_True; 403*cdf0e10cSrcweir aSrsName = (*ppStr); 404*cdf0e10cSrcweir } 405*cdf0e10cSrcweir } 406*cdf0e10cSrcweir else 407*cdf0e10cSrcweir { 408*cdf0e10cSrcweir // Eingabedatei 409*cdf0e10cSrcweir aInputList.Insert( new ByteString( *ppStr ), CONTAINER_APPEND ); 410*cdf0e10cSrcweir } 411*cdf0e10cSrcweir ppStr++; 412*cdf0e10cSrcweir i++; 413*cdf0e10cSrcweir } 414*cdf0e10cSrcweir 415*cdf0e10cSrcweir if( aInputList.Count() ) 416*cdf0e10cSrcweir { 417*cdf0e10cSrcweir /* build the output file names */ 418*cdf0e10cSrcweir if( ! aResName.Len() ) 419*cdf0e10cSrcweir aResName = OutputFile( *aInputList.First(), "res" ); 420*cdf0e10cSrcweir if( ! bSetSrs ) 421*cdf0e10cSrcweir { 422*cdf0e10cSrcweir aSrsName = "-fp="; 423*cdf0e10cSrcweir aSrsName += OutputFile( *aInputList.First(), "srs" ); 424*cdf0e10cSrcweir } 425*cdf0e10cSrcweir }; 426*cdf0e10cSrcweir 427*cdf0e10cSrcweir if( bHelp ) 428*cdf0e10cSrcweir { 429*cdf0e10cSrcweir bPrePro = sal_False; 430*cdf0e10cSrcweir bResFile = sal_False; 431*cdf0e10cSrcweir }; 432*cdf0e10cSrcweir if( bPrePro && aInputList.Count() ) 433*cdf0e10cSrcweir { 434*cdf0e10cSrcweir ByteString aTmpName; 435*cdf0e10cSrcweir 436*cdf0e10cSrcweir pString = aInputList.First(); 437*cdf0e10cSrcweir while( pString ) 438*cdf0e10cSrcweir { 439*cdf0e10cSrcweir aTmpName = ::GetTmpFileName(); 440*cdf0e10cSrcweir if( !CallPrePro( aPrePro, *pString, aTmpName, &aCmdLine, bResponse ) ) 441*cdf0e10cSrcweir { 442*cdf0e10cSrcweir printf( "Error starting preprocessor\n" ); 443*cdf0e10cSrcweir bError = sal_True; 444*cdf0e10cSrcweir break; 445*cdf0e10cSrcweir } 446*cdf0e10cSrcweir aTmpList.Insert( new ByteString( aTmpName ), CONTAINER_APPEND ); 447*cdf0e10cSrcweir pString = aInputList.Next(); 448*cdf0e10cSrcweir }; 449*cdf0e10cSrcweir }; 450*cdf0e10cSrcweir 451*cdf0e10cSrcweir if( !bError ) 452*cdf0e10cSrcweir { 453*cdf0e10cSrcweir if( !CallRsc2( aRsc2Name, bPrePro ? &aTmpList : &aInputList, 454*cdf0e10cSrcweir aSrsName, &aCmdLine ) ) 455*cdf0e10cSrcweir { 456*cdf0e10cSrcweir if( !bHelp ) 457*cdf0e10cSrcweir { 458*cdf0e10cSrcweir printf( "Error starting rsc2 compiler\n" ); 459*cdf0e10cSrcweir bError = sal_True; 460*cdf0e10cSrcweir } 461*cdf0e10cSrcweir }; 462*cdf0e10cSrcweir }; 463*cdf0e10cSrcweir 464*cdf0e10cSrcweir pString = aTmpList.First(); 465*cdf0e10cSrcweir while( pString ) 466*cdf0e10cSrcweir { 467*cdf0e10cSrcweir #if OSL_DEBUG_LEVEL > 5 468*cdf0e10cSrcweir fprintf( stderr, "leaving temp file %s\n", pString->GetBuffer() ); 469*cdf0e10cSrcweir #else 470*cdf0e10cSrcweir unlink( pString->GetBuffer() ); 471*cdf0e10cSrcweir #endif 472*cdf0e10cSrcweir pString = aTmpList.Next(); 473*cdf0e10cSrcweir }; 474*cdf0e10cSrcweir 475*cdf0e10cSrcweir return( bError ); 476*cdf0e10cSrcweir } 477*cdf0e10cSrcweir 478*cdf0e10cSrcweir void RscExit( sal_uInt32 nExit ) 479*cdf0e10cSrcweir { 480*cdf0e10cSrcweir if( nExit ) 481*cdf0e10cSrcweir printf( "Program exit is %d\n", (int)nExit ); 482*cdf0e10cSrcweir exit( nExit ); 483*cdf0e10cSrcweir } 484