Branch data 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 <rscrsc.hxx>
24 : : #include <rscdb.hxx>
25 : :
26 : : /*************** G l o b a l e V a r i a b l e n **********************/
27 : : static RscCompiler * pRscCompiler = NULL;
28 : : /****************************************************************/
29 : : /* */
30 : : /* Function : ExitProgram() */
31 : : /* */
32 : : /* Description : Gibt die Temporaeren Dateien frei. */
33 : : /****************************************************************/
34 : : #if defined( UNX ) || defined ( GCC ) || defined(__MINGW32__)
35 : 0 : void ExitProgram( void ){
36 : : #else
37 : : void cdecl ExitProgram( void ){
38 : : #endif
39 [ # # ]: 0 : if( pRscCompiler )
40 [ # # ]: 0 : delete pRscCompiler;
41 : 0 : }
42 : :
43 : 1440 : RscVerbosity lcl_determineVerbosity( int argc, char ** argv )
44 : : {
45 [ + + ]: 53842 : for ( int i = 0; i < argc; ++i )
46 : : {
47 [ - + ]: 52402 : if ( argv[i] == NULL )
48 : 0 : continue;
49 [ - + ]: 52402 : if ( rsc_stricmp( argv[i], "-verbose" ) == 0 )
50 : 0 : return RscVerbosityVerbose;
51 [ - + ]: 52402 : if ( rsc_stricmp( argv[i], "-quiet" ) == 0 )
52 : 0 : return RscVerbositySilent;
53 : : }
54 : 1440 : return RscVerbosityNormal;
55 : : }
56 : :
57 : 1440 : int rsc2_main( int argc, char **argv )
58 : : {
59 : : #ifndef UNX
60 : : atexit( ExitProgram );
61 : : #endif
62 : : #if OSL_DEBUG_LEVEL > 1
63 : : fprintf( stderr, "debugging %s\n", argv[0] );
64 : : #endif
65 : :
66 : 1440 : ERRTYPE aError;
67 : :
68 [ + - ]: 1440 : InitRscCompiler();
69 [ + - ][ + - ]: 1440 : RscError* pErrHdl = new RscError( lcl_determineVerbosity( argc, argv ) );
70 [ + - ][ + - ]: 1440 : RscCmdLine* pCmdLine = new RscCmdLine( argc, argv, pErrHdl );
71 : : RscTypCont* pTypCont = new RscTypCont( pErrHdl,
72 : : pCmdLine->nByteOrder,
73 : : pCmdLine->aPath,
74 [ + - ][ + - ]: 1440 : pCmdLine->nCommands );
75 : :
76 [ - + ]: 1440 : if( pErrHdl->nErrors )
77 [ # # ]: 0 : aError = ERR_ERROR;
78 : : else{
79 [ + - ][ + - ]: 1440 : RscCompiler* pCompiler = new RscCompiler( pCmdLine, pTypCont );
80 : :
81 : 1440 : pRscCompiler = pCompiler;
82 [ + - ][ + - ]: 1440 : aError = pCompiler->Start();
83 : 1440 : pRscCompiler = NULL;
84 : :
85 [ + - ][ + - ]: 1440 : delete pCompiler;
86 : : }
87 : :
88 [ + - ][ + - ]: 1440 : delete pTypCont;
89 [ + - ][ + - ]: 1440 : delete pCmdLine;
90 [ + - ][ + - ]: 1440 : delete pErrHdl;
91 [ + - ][ + - ]: 1440 : delete pHS; // wird durch InitRscCompiler erzeugt
92 : :
93 [ + - ]: 1440 : if( aError.IsOk() )
94 : 1440 : return( 0 );
95 : : else
96 : 1440 : return( 1 );
97 : : }
98 : :
99 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|