LCOV - code coverage report
Current view: top level - rsc/inc - rsctools.hxx (source / functions) Hit Total Coverage
Test: commit 10e77ab3ff6f4314137acd6e2702a6e5c1ce1fae Lines: 58 64 90.6 %
Date: 2014-11-03 Functions: 15 15 100.0 %
Legend: Lines: hit not hit

          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             : struct RSHEADER_TYPE;
      20             : class  RscPtrPtr;
      21             : 
      22             : #ifndef INCLUDED_RSC_INC_RSCTOOLS_HXX
      23             : #define INCLUDED_RSC_INC_RSCTOOLS_HXX
      24             : 
      25             : #ifdef UNX
      26             : #include <stdlib.h>
      27             : #endif
      28             : #include <stdio.h>
      29             : #include <vector>
      30             : #include <rtl/ustring.hxx>
      31             : #include <osl/endian.h>
      32             : 
      33             : // Zeichensatz
      34             : enum COMPARE { LESS = -1, EQUAL = 0, GREATER = 1 };
      35             : 
      36             : enum RSCBYTEORDER_TYPE { RSC_BIGENDIAN, RSC_LITTLEENDIAN, RSC_SYSTEMENDIAN };
      37             : 
      38             : #define ALIGNED_SIZE( nSize )                               \
      39             :             (nSize + sizeof( void * ) -1) / sizeof( void * ) * sizeof( void * )
      40             : 
      41             : // Function Forwards
      42             : OString GetTmpFileName();
      43             : 
      44             : bool Append(const OString &rDestFile, const OString &rSourceFile);
      45             : 
      46             : bool Append(FILE * fDest, OString &raSourceFile);
      47             : 
      48             : OString OutputFile(const OString &rInput, const char * ext);
      49             : 
      50             : char * ResponseFile( RscPtrPtr * ppCmd, char ** ppArgv,
      51             :                      sal_uInt32 nArgc );
      52             : 
      53             : void RscExit( sal_uInt32 nExit );
      54             : 
      55             : // Ansi-Function Forwards
      56             : int rsc_strnicmp( const char *string1, const char *string2, size_t count );
      57             : int rsc_stricmp( const char *string1, const char *string2 );
      58             : char* rsc_strdup( const char* );
      59             : 
      60             : typedef ::std::vector< OString* > RscStrList;
      61             : 
      62             : class RscChar
      63             : {
      64             : public:
      65             :     static char * MakeUTF8( char * pStr, sal_uInt16 nTextEncoding );
      66             : };
      67             : 
      68             : class RscPtrPtr
      69             : {
      70             :     sal_uInt32  nCount;
      71             :     void **         pMem;
      72             : public:
      73             :                     RscPtrPtr();
      74             :                     ~RscPtrPtr();
      75             :     void            Reset();
      76             :     sal_uInt32  Append( void * );
      77       42295 :     sal_uInt32  Append( char * pStr ){
      78       42295 :                         return( Append( (void *)pStr ) );
      79             :                     };
      80       53209 :     sal_uInt32  GetCount(){ return( nCount ); };
      81             :     void *          GetEntry( sal_uInt32 nEle );
      82        1620 :     void **         GetBlock(){ return( pMem ); };
      83             : };
      84             : 
      85             : class RscWriteRc
      86             : {
      87             :     sal_uInt32          nLen;
      88             :     bool                bSwap;
      89             :     RSCBYTEORDER_TYPE   nByteOrder;
      90             :     char *              pMem;
      91             :     char *              GetPointer( sal_uInt32 nSize );
      92             : public:
      93             :                 RscWriteRc( RSCBYTEORDER_TYPE nOrder = RSC_SYSTEMENDIAN );
      94             :                 ~RscWriteRc();
      95             :     sal_uInt32      IncSize( sal_uInt32 nSize );// gibt die vorherige Groesse
      96        9589 :     void *      GetBuffer()
      97             :                 {
      98        9589 :                     return GetPointer( 0 );
      99             :                 }
     100        1270 :     sal_uInt16  GetShort( sal_uInt32 nPos )
     101             :                 {
     102        1270 :                     sal_uInt16 nVal = 0;
     103        1270 :                     char* pFrom = GetPointer(nPos);
     104        1270 :                     char* pTo = (char*)&nVal;
     105        1270 :                     *pTo++ = *pFrom++;
     106        1270 :                     *pTo++ = *pFrom++;
     107        1270 :                     return bSwap ? OSL_SWAPWORD( nVal ) : nVal;
     108             :                 }
     109       33916 :     sal_uInt32  GetLong( sal_uInt32 nPos )
     110             :                 {
     111       33916 :                     sal_uInt32 nVal = 0;
     112       33916 :                     char* pFrom = GetPointer(nPos);
     113       33916 :                     char* pTo = (char*)&nVal;
     114       33916 :                     *pTo++ = *pFrom++;
     115       33916 :                     *pTo++ = *pFrom++;
     116       33916 :                     *pTo++ = *pFrom++;
     117       33916 :                     *pTo++ = *pFrom++;
     118       33916 :                     return bSwap ? OSL_SWAPDWORD( nVal ) : nVal;
     119             :                 }
     120        2014 :     char *      GetUTF8( sal_uInt32 nPos )
     121             :                 {
     122        2014 :                     return GetPointer( nPos );
     123             :                 }
     124             : 
     125             : 
     126             :     RSCBYTEORDER_TYPE GetByteOrder() const { return nByteOrder; }
     127       69467 :     sal_uInt32      Size(){ return( nLen ); };
     128        9589 :     void        Put( sal_uInt64 lVal )
     129             :                 {
     130             :                     union
     131             :                     {
     132             :                         sal_uInt64 lVal64;
     133             :                         sal_uInt32 aVal32[2];
     134             :                     };
     135        9589 :                     lVal64 = lVal;
     136        9589 :                     if( bSwap )
     137             :                     {
     138        9589 :                         Put( aVal32[1] );
     139        9589 :                         Put( aVal32[0] );
     140             :                     }
     141             :                     else
     142             :                     {
     143           0 :                         Put( aVal32[0] );
     144           0 :                         Put( aVal32[1] );
     145             :                     }
     146        9589 :                 }
     147       45914 :     void        Put( sal_Int32 lVal )
     148             :                 {
     149             :                     union
     150             :                     {
     151             :                         sal_uInt32 lVal32;
     152             :                         sal_uInt16 aVal16[2];
     153             :                     };
     154       45914 :                     lVal32 = lVal;
     155             : 
     156       45914 :                     if( bSwap )
     157             :                     {
     158       45914 :                         Put( aVal16[1] );
     159       45914 :                         Put( aVal16[0] );
     160             :                     }
     161             :                     else
     162             :                     {
     163           0 :                         Put( aVal16[0] );
     164           0 :                         Put( aVal16[1] );
     165             :                     }
     166       45914 :                 }
     167       27463 :     void        Put( sal_uInt32 nValue )
     168       27463 :                 { Put( (sal_Int32)nValue ); }
     169             :     void        Put( sal_uInt16 nValue );
     170        7313 :     void        Put( sal_Int16 nValue )
     171        7313 :                 { Put( (sal_uInt16)nValue ); }
     172             :     void        PutUTF8( char * pData );
     173             : 
     174      102322 :     void        PutAt( sal_uInt32 nPos, sal_Int32 lVal )
     175             :                 {
     176             :                     union
     177             :                     {
     178             :                         sal_uInt32 lVal32;
     179             :                         sal_uInt16 aVal16[2];
     180             :                     };
     181      102322 :                     lVal32 = lVal;
     182             : 
     183      102322 :                     if( bSwap )
     184             :                     {
     185      102322 :                         PutAt( nPos, aVal16[1] );
     186      102322 :                         PutAt( nPos + 2, aVal16[0] );
     187             :                     }
     188             :                     else
     189             :                     {
     190           0 :                         PutAt( nPos, aVal16[0] );
     191           0 :                         PutAt( nPos + 2, aVal16[1] );
     192             :                     }
     193      102322 :                 }
     194      102322 :     void        PutAt( sal_uInt32 nPos, sal_uInt32 lVal )
     195             :                 {
     196      102322 :                     PutAt( nPos, (sal_Int32)lVal);
     197      102322 :                 }
     198             :     void        PutAt( sal_uInt32 nPos, short nVal )
     199             :                 {
     200             :                     PutAt( nPos, (sal_uInt16)nVal );
     201             :                 }
     202      305531 :     void        PutAt( sal_uInt32 nPos, sal_uInt16 nVal )
     203             :                 {
     204      305531 :                     if( bSwap )
     205      300451 :                         nVal = OSL_SWAPWORD( nVal );
     206      305531 :                     char* pTo = GetPointer( nPos );
     207      305531 :                     char* pFrom = (char*)&nVal;
     208      305531 :                     *pTo++ = *pFrom++;
     209      305531 :                     *pTo++ = *pFrom++;
     210      305531 :                 }
     211             : };
     212             : 
     213             : #endif // INCLUDED_RSC_INC_RSCTOOLS_HXX
     214             : 
     215             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10