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