LCOV - code coverage report
Current view: top level - rsc/inc - rsctools.hxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 58 64 90.6 %
Date: 2012-08-25 Functions: 15 15 100.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 15 40 37.5 %

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

Generated by: LCOV version 1.10