xref: /aoo41x/main/rsc/source/prj/gui.cxx (revision cdf0e10c)
1 /*************************************************************************
2  *
3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4  *
5  * Copyright 2000, 2010 Oracle and/or its affiliates.
6  *
7  * OpenOffice.org - a multi-platform office productivity suite
8  *
9  * This file is part of OpenOffice.org.
10  *
11  * OpenOffice.org is free software: you can redistribute it and/or modify
12  * it under the terms of the GNU Lesser General Public License version 3
13  * only, as published by the Free Software Foundation.
14  *
15  * OpenOffice.org is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  * GNU Lesser General Public License version 3 for more details
19  * (a copy is included in the LICENSE file that accompanied this code).
20  *
21  * You should have received a copy of the GNU Lesser General Public License
22  * version 3 along with OpenOffice.org.  If not, see
23  * <http://www.openoffice.org/license.html>
24  * for a copy of the LGPLv3 License.
25  *
26  ************************************************************************/
27 
28 // MARKER(update_precomp.py): autogen include statement, do not remove
29 #include "precompiled_rsc.hxx"
30 
31 #include <stdlib.h>
32 #include <stdio.h>
33 #include <sal/main.h>
34 #include <rscrsc.hxx>
35 #include <rscdb.hxx>
36 
37 /*************** G l o b a l e	 V a r i a b l e n **********************/
38 static RscCompiler * pRscCompiler = NULL;
39 /****************************************************************/
40 /*																*/
41 /*	Function	:	ExitProgram()								*/
42 /*																*/
43 /*	Description :	Gibt die Temporaeren Dateien frei.			*/
44 /****************************************************************/
45 #if defined( UNX ) || ( defined( OS2 ) && ( defined( TCPP ) || defined ( GCC )) ) ||  defined (WTC) || defined (MTW) || defined(__MINGW32__)
46 		void ExitProgram( void ){
47 #else
48 #if defined( CSET )
49 	void _Optlink ExitProgram( void ){
50 #else
51 	void cdecl ExitProgram( void ){
52 #endif
53 #endif
54 	if( pRscCompiler )
55 		delete pRscCompiler;
56 }
57 
58 RscVerbosity lcl_determineVerbosity( int argc, char ** argv )
59 {
60     for ( int i = 0; i < argc; ++i )
61     {
62         if ( argv[i] == NULL )
63             continue;
64         if ( rsc_stricmp( argv[i], "-verbose" ) == 0 )
65             return RscVerbosityVerbose;
66         if ( rsc_stricmp( argv[i], "-quiet" ) == 0 )
67             return RscVerbositySilent;
68     }
69     return RscVerbosityNormal;
70 }
71 
72 SAL_IMPLEMENT_MAIN_WITH_ARGS(argc, argv) {
73 #ifndef UNX
74 #ifdef CSET
75 	atexit( ExitProgram );
76 #else
77 	atexit( ExitProgram );
78 #endif
79 #endif
80 #if OSL_DEBUG_LEVEL > 1
81     fprintf( stderr, "debugging %s\n", argv[0] );
82 #endif
83 
84 	ERRTYPE 	aError;
85 
86 	InitRscCompiler();
87 	RscError*	pErrHdl    = new RscError( lcl_determineVerbosity( argc, argv ) );
88 #ifdef MTW
89 	RscCmdLine* pCmdLine   = new RscCmdLine( argc, (char **)argv, pErrHdl );
90 #else
91 	RscCmdLine* pCmdLine   = new RscCmdLine( argc, argv, pErrHdl );
92 #endif
93 	RscTypCont* pTypCont   = new RscTypCont( pErrHdl,
94 											 pCmdLine->nByteOrder,
95 											 pCmdLine->aPath,
96 											 pCmdLine->nCommands );
97 
98 	if( pErrHdl->nErrors )
99 		aError = ERR_ERROR;
100 	else{
101 		RscCompiler* pCompiler = new RscCompiler( pCmdLine, pTypCont );
102 
103 		pRscCompiler = pCompiler;
104 		aError = pCompiler->Start();
105 		pRscCompiler = NULL;
106 
107 		delete pCompiler;
108 	}
109 
110 	delete pTypCont;
111 	delete pCmdLine;
112 	delete pErrHdl;
113 	delete pHS; // wird durch InitRscCompiler erzeugt
114 
115 	if( aError.IsOk() )
116 		return( 0 );
117 	else
118 		return( 1 );
119 }
120 
121 void RscExit( sal_uInt32 nExit )
122 {
123 	if( nExit )
124 		printf( "Program exit is %ud\n", (unsigned int)nExit );
125 	exit( nExit );
126 }
127