LCOV - code coverage report
Current view: top level - rsc/inc - rsctools.hxx (source / functions) Hit Total Coverage
Test: commit c8344322a7af75b84dd3ca8f78b05543a976dfd5 Lines: 57 63 90.5 %
Date: 2015-06-13 12:38:46 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       40793 :     sal_uInt32      Append( char * pStr ) { return Append( static_cast<void *>(pStr) ); }
      78       51326 :     sal_uInt32      GetCount() { return nCount; }
      79             :     void *          GetEntry( sal_uInt32 nEle );
      80        1612 :     void **         GetBlock() { return pMem; }
      81             : };
      82             : 
      83             : class RscWriteRc
      84             : {
      85             :     sal_uInt32          nLen;
      86             :     bool                bSwap;
      87             :     RSCBYTEORDER_TYPE   nByteOrder;
      88             :     char *              pMem;
      89             :     char *              GetPointer( sal_uInt32 nSize );
      90             : public:
      91             :                 RscWriteRc( RSCBYTEORDER_TYPE nOrder = RSC_SYSTEMENDIAN );
      92             :                 ~RscWriteRc();
      93             :     sal_uInt32      IncSize( sal_uInt32 nSize );// gibt die vorherige Groesse
      94        9552 :     void *      GetBuffer()
      95             :                 {
      96        9552 :                     return GetPointer( 0 );
      97             :                 }
      98         518 :     sal_uInt16  GetShort( sal_uInt32 nPos )
      99             :                 {
     100         518 :                     sal_uInt16 nVal = 0;
     101         518 :                     char* pFrom = GetPointer(nPos);
     102         518 :                     char* pTo = reinterpret_cast<char*>(&nVal);
     103         518 :                     *pTo++ = *pFrom++;
     104         518 :                     *pTo++ = *pFrom++;
     105         518 :                     return bSwap ? OSL_SWAPWORD( nVal ) : nVal;
     106             :                 }
     107       31301 :     sal_uInt32  GetLong( sal_uInt32 nPos )
     108             :                 {
     109       31301 :                     sal_uInt32 nVal = 0;
     110       31301 :                     char* pFrom = GetPointer(nPos);
     111       31301 :                     char* pTo = reinterpret_cast<char*>(&nVal);
     112       31301 :                     *pTo++ = *pFrom++;
     113       31301 :                     *pTo++ = *pFrom++;
     114       31301 :                     *pTo++ = *pFrom++;
     115       31301 :                     *pTo++ = *pFrom++;
     116       31301 :                     return bSwap ? OSL_SWAPDWORD( nVal ) : nVal;
     117             :                 }
     118        1882 :     char *      GetUTF8( sal_uInt32 nPos )
     119             :                 {
     120        1882 :                     return GetPointer( nPos );
     121             :                 }
     122             : 
     123             : 
     124             :     RSCBYTEORDER_TYPE GetByteOrder() const { return nByteOrder; }
     125       67301 :     sal_uInt32  Size(){ return nLen; }
     126        9552 :     void        Put( sal_uInt64 lVal )
     127             :                 {
     128             :                     union
     129             :                     {
     130             :                         sal_uInt64 lVal64;
     131             :                         sal_uInt32 aVal32[2];
     132             :                     };
     133        9552 :                     lVal64 = lVal;
     134        9552 :                     if( bSwap )
     135             :                     {
     136        9552 :                         Put( aVal32[1] );
     137        9552 :                         Put( aVal32[0] );
     138             :                     }
     139             :                     else
     140             :                     {
     141           0 :                         Put( aVal32[0] );
     142           0 :                         Put( aVal32[1] );
     143             :                     }
     144        9552 :                 }
     145       42808 :     void        Put( sal_Int32 lVal )
     146             :                 {
     147             :                     union
     148             :                     {
     149             :                         sal_uInt32 lVal32;
     150             :                         sal_uInt16 aVal16[2];
     151             :                     };
     152       42808 :                     lVal32 = lVal;
     153             : 
     154       42808 :                     if( bSwap )
     155             :                     {
     156       42808 :                         Put( aVal16[1] );
     157       42808 :                         Put( aVal16[0] );
     158             :                     }
     159             :                     else
     160             :                     {
     161           0 :                         Put( aVal16[0] );
     162           0 :                         Put( aVal16[1] );
     163             :                     }
     164       42808 :                 }
     165       26495 :     void        Put( sal_uInt32 nValue )
     166       26495 :                 { Put( (sal_Int32)nValue ); }
     167             :     void        Put( sal_uInt16 nValue );
     168        4336 :     void        Put( sal_Int16 nValue )
     169        4336 :                 { Put( (sal_uInt16)nValue ); }
     170             :     void        PutUTF8( char * pData );
     171             : 
     172       97157 :     void        PutAt( sal_uInt32 nPos, sal_Int32 lVal )
     173             :                 {
     174             :                     union
     175             :                     {
     176             :                         sal_uInt32 lVal32;
     177             :                         sal_uInt16 aVal16[2];
     178             :                     };
     179       97157 :                     lVal32 = lVal;
     180             : 
     181       97157 :                     if( bSwap )
     182             :                     {
     183       97157 :                         PutAt( nPos, aVal16[1] );
     184       97157 :                         PutAt( nPos + 2, aVal16[0] );
     185             :                     }
     186             :                     else
     187             :                     {
     188           0 :                         PutAt( nPos, aVal16[0] );
     189           0 :                         PutAt( nPos + 2, aVal16[1] );
     190             :                     }
     191       97157 :                 }
     192       97157 :     void        PutAt( sal_uInt32 nPos, sal_uInt32 lVal )
     193             :                 {
     194       97157 :                     PutAt( nPos, (sal_Int32)lVal);
     195       97157 :                 }
     196             :     void        PutAt( sal_uInt32 nPos, short nVal )
     197             :                 {
     198             :                     PutAt( nPos, (sal_uInt16)nVal );
     199             :                 }
     200      285696 :     void        PutAt( sal_uInt32 nPos, sal_uInt16 nVal )
     201             :                 {
     202      285696 :                     if( bSwap )
     203      283624 :                         nVal = OSL_SWAPWORD( nVal );
     204      285696 :                     char* pTo = GetPointer( nPos );
     205      285696 :                     char* pFrom = reinterpret_cast<char*>(&nVal);
     206      285696 :                     *pTo++ = *pFrom++;
     207      285696 :                     *pTo++ = *pFrom++;
     208      285696 :                 }
     209             : };
     210             : 
     211             : #endif // INCLUDED_RSC_INC_RSCTOOLS_HXX
     212             : 
     213             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.11