xref: /aoo41x/main/rsc/source/prj/gui.cxx (revision 477794c1)
1*477794c1SAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
3*477794c1SAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
4*477794c1SAndrew Rist  * or more contributor license agreements.  See the NOTICE file
5*477794c1SAndrew Rist  * distributed with this work for additional information
6*477794c1SAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
7*477794c1SAndrew Rist  * to you under the Apache License, Version 2.0 (the
8*477794c1SAndrew Rist  * "License"); you may not use this file except in compliance
9*477794c1SAndrew Rist  * with the License.  You may obtain a copy of the License at
10*477794c1SAndrew Rist  *
11*477794c1SAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12*477794c1SAndrew Rist  *
13*477794c1SAndrew Rist  * Unless required by applicable law or agreed to in writing,
14*477794c1SAndrew Rist  * software distributed under the License is distributed on an
15*477794c1SAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*477794c1SAndrew Rist  * KIND, either express or implied.  See the License for the
17*477794c1SAndrew Rist  * specific language governing permissions and limitations
18*477794c1SAndrew Rist  * under the License.
19*477794c1SAndrew Rist  *
20*477794c1SAndrew Rist  *************************************************************/
21*477794c1SAndrew Rist 
22*477794c1SAndrew Rist 
23cdf0e10cSrcweir 
24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
25cdf0e10cSrcweir #include "precompiled_rsc.hxx"
26cdf0e10cSrcweir 
27cdf0e10cSrcweir #include <stdlib.h>
28cdf0e10cSrcweir #include <stdio.h>
29cdf0e10cSrcweir #include <sal/main.h>
30cdf0e10cSrcweir #include <rscrsc.hxx>
31cdf0e10cSrcweir #include <rscdb.hxx>
32cdf0e10cSrcweir 
33cdf0e10cSrcweir /*************** G l o b a l e	 V a r i a b l e n **********************/
34cdf0e10cSrcweir static RscCompiler * pRscCompiler = NULL;
35cdf0e10cSrcweir /****************************************************************/
36cdf0e10cSrcweir /*																*/
37cdf0e10cSrcweir /*	Function	:	ExitProgram()								*/
38cdf0e10cSrcweir /*																*/
39cdf0e10cSrcweir /*	Description :	Gibt die Temporaeren Dateien frei.			*/
40cdf0e10cSrcweir /****************************************************************/
41cdf0e10cSrcweir #if defined( UNX ) || ( defined( OS2 ) && ( defined( TCPP ) || defined ( GCC )) ) ||  defined (WTC) || defined (MTW) || defined(__MINGW32__)
ExitProgram(void)42cdf0e10cSrcweir 		void ExitProgram( void ){
43cdf0e10cSrcweir #else
44cdf0e10cSrcweir #if defined( CSET )
45cdf0e10cSrcweir 	void _Optlink ExitProgram( void ){
46cdf0e10cSrcweir #else
47cdf0e10cSrcweir 	void cdecl ExitProgram( void ){
48cdf0e10cSrcweir #endif
49cdf0e10cSrcweir #endif
50cdf0e10cSrcweir 	if( pRscCompiler )
51cdf0e10cSrcweir 		delete pRscCompiler;
52cdf0e10cSrcweir }
53cdf0e10cSrcweir 
54cdf0e10cSrcweir RscVerbosity lcl_determineVerbosity( int argc, char ** argv )
55cdf0e10cSrcweir {
56cdf0e10cSrcweir     for ( int i = 0; i < argc; ++i )
57cdf0e10cSrcweir     {
58cdf0e10cSrcweir         if ( argv[i] == NULL )
59cdf0e10cSrcweir             continue;
60cdf0e10cSrcweir         if ( rsc_stricmp( argv[i], "-verbose" ) == 0 )
61cdf0e10cSrcweir             return RscVerbosityVerbose;
62cdf0e10cSrcweir         if ( rsc_stricmp( argv[i], "-quiet" ) == 0 )
63cdf0e10cSrcweir             return RscVerbositySilent;
64cdf0e10cSrcweir     }
65cdf0e10cSrcweir     return RscVerbosityNormal;
66cdf0e10cSrcweir }
67cdf0e10cSrcweir 
68cdf0e10cSrcweir SAL_IMPLEMENT_MAIN_WITH_ARGS(argc, argv) {
69cdf0e10cSrcweir #ifndef UNX
70cdf0e10cSrcweir #ifdef CSET
71cdf0e10cSrcweir 	atexit( ExitProgram );
72cdf0e10cSrcweir #else
73cdf0e10cSrcweir 	atexit( ExitProgram );
74cdf0e10cSrcweir #endif
75cdf0e10cSrcweir #endif
76cdf0e10cSrcweir #if OSL_DEBUG_LEVEL > 1
77cdf0e10cSrcweir     fprintf( stderr, "debugging %s\n", argv[0] );
78cdf0e10cSrcweir #endif
79cdf0e10cSrcweir 
80cdf0e10cSrcweir 	ERRTYPE 	aError;
81cdf0e10cSrcweir 
82cdf0e10cSrcweir 	InitRscCompiler();
83cdf0e10cSrcweir 	RscError*	pErrHdl    = new RscError( lcl_determineVerbosity( argc, argv ) );
84cdf0e10cSrcweir #ifdef MTW
85cdf0e10cSrcweir 	RscCmdLine* pCmdLine   = new RscCmdLine( argc, (char **)argv, pErrHdl );
86cdf0e10cSrcweir #else
87cdf0e10cSrcweir 	RscCmdLine* pCmdLine   = new RscCmdLine( argc, argv, pErrHdl );
88cdf0e10cSrcweir #endif
89cdf0e10cSrcweir 	RscTypCont* pTypCont   = new RscTypCont( pErrHdl,
90cdf0e10cSrcweir 											 pCmdLine->nByteOrder,
91cdf0e10cSrcweir 											 pCmdLine->aPath,
92cdf0e10cSrcweir 											 pCmdLine->nCommands );
93cdf0e10cSrcweir 
94cdf0e10cSrcweir 	if( pErrHdl->nErrors )
95cdf0e10cSrcweir 		aError = ERR_ERROR;
96cdf0e10cSrcweir 	else{
97cdf0e10cSrcweir 		RscCompiler* pCompiler = new RscCompiler( pCmdLine, pTypCont );
98cdf0e10cSrcweir 
99cdf0e10cSrcweir 		pRscCompiler = pCompiler;
100cdf0e10cSrcweir 		aError = pCompiler->Start();
101cdf0e10cSrcweir 		pRscCompiler = NULL;
102cdf0e10cSrcweir 
103cdf0e10cSrcweir 		delete pCompiler;
104cdf0e10cSrcweir 	}
105cdf0e10cSrcweir 
106cdf0e10cSrcweir 	delete pTypCont;
107cdf0e10cSrcweir 	delete pCmdLine;
108cdf0e10cSrcweir 	delete pErrHdl;
109cdf0e10cSrcweir 	delete pHS; // wird durch InitRscCompiler erzeugt
110cdf0e10cSrcweir 
111cdf0e10cSrcweir 	if( aError.IsOk() )
112cdf0e10cSrcweir 		return( 0 );
113cdf0e10cSrcweir 	else
114cdf0e10cSrcweir 		return( 1 );
115cdf0e10cSrcweir }
116cdf0e10cSrcweir 
117cdf0e10cSrcweir void RscExit( sal_uInt32 nExit )
118cdf0e10cSrcweir {
119cdf0e10cSrcweir 	if( nExit )
120cdf0e10cSrcweir 		printf( "Program exit is %ud\n", (unsigned int)nExit );
121cdf0e10cSrcweir 	exit( nExit );
122cdf0e10cSrcweir }
123