update dev300-m58
[ooovba.git] / rsc / inc / rsctools.hxx
blob355fd61f8c409750253a7f2d27a9b8e2c6632ff5
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: rsctools.hxx,v $
10 * $Revision: 1.7 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
30 struct RSHEADER_TYPE;
31 class RscPtrPtr;
33 #ifndef _RSCTOOLS_HXX
34 #define _RSCTOOLS_HXX
36 #ifdef UNX
37 #include <stdlib.h>
38 #endif
39 #include <stdio.h>
40 #include <tools/string.hxx>
41 #include <tools/list.hxx>
43 /******************* T y p e s *******************************************/
44 // Zeichensatz
45 enum COMPARE { LESS = -1, EQUAL = 0, GREATER = 1 };
47 enum RSCBYTEORDER_TYPE { RSC_BIGENDIAN, RSC_LITTLEENDIAN, RSC_SYSTEMENDIAN };
49 /******************* M A K R O S *****************************************/
50 #define ALIGNED_SIZE( nSize ) \
51 (nSize + sizeof( void * ) -1) / sizeof( void * ) * sizeof( void * )
52 /******************* F u n c t i o n F o r w a r d s *******************/
53 ByteString GetTmpFileName();
54 BOOL Append( ByteString aDestFile, ByteString aSourceFile );
55 BOOL Append( FILE * fDest, ByteString aSourceFile );
56 ByteString InputFile ( const char * pInput, const char * pExt );
57 ByteString OutputFile( ByteString aInput, const char * ext );
58 char * ResponseFile( RscPtrPtr * ppCmd, char ** ppArgv,
59 sal_uInt32 nArgc );
60 void RscExit( sal_uInt32 nExit );
62 /********* A n s i - F u n c t i o n F o r w a r d s *******************/
63 int rsc_strnicmp( const char *string1, const char *string2, size_t count );
64 int rsc_stricmp( const char *string1, const char *string2 );
65 char* rsc_strdup( const char* );
67 /****************** C L A S S E S ****************************************/
68 DECLARE_LIST( RscStrList, ByteString * )
69 /*********** R s c C h a r ***********************************************/
70 class RscChar
72 public:
73 static char * MakeUTF8( char * pStr, UINT16 nTextEncoding );
74 static char * MakeUTF8FromL( char * pStr );
77 /****************** R s c P t r P t r ************************************/
78 class RscPtrPtr
80 sal_uInt32 nCount;
81 void ** pMem;
82 public:
83 RscPtrPtr();
84 ~RscPtrPtr();
85 void Reset();
86 sal_uInt32 Append( void * );
87 sal_uInt32 Append( char * pStr ){
88 return( Append( (void *)pStr ) );
90 sal_uInt32 GetCount(){ return( nCount ); };
91 void * GetEntry( sal_uInt32 nEle );
92 void ** GetBlock(){ return( pMem ); };
95 /****************** R s c W r i t e R c **********************************/
96 class RscWriteRc
98 sal_uInt32 nLen;
99 BOOL bSwap;
100 RSCBYTEORDER_TYPE nByteOrder;
101 char * pMem;
102 char * GetPointer( sal_uInt32 nSize );
103 public:
104 RscWriteRc( RSCBYTEORDER_TYPE nOrder = RSC_SYSTEMENDIAN );
105 ~RscWriteRc();
106 sal_uInt32 IncSize( sal_uInt32 nSize );// gibt die vorherige Groesse
107 void * GetBuffer()
109 return GetPointer( 0 );
111 sal_uInt16 GetShort( sal_uInt32 nPos )
113 sal_uInt16 nVal = 0;
114 char* pFrom = GetPointer(nPos);
115 char* pTo = (char*)&nVal;
116 *pTo++ = *pFrom++;
117 *pTo++ = *pFrom++;
118 return bSwap ? SWAPSHORT( nVal ) : nVal;
120 sal_uInt32 GetLong( sal_uInt32 nPos )
122 sal_uInt32 nVal = 0;
123 char* pFrom = GetPointer(nPos);
124 char* pTo = (char*)&nVal;
125 *pTo++ = *pFrom++;
126 *pTo++ = *pFrom++;
127 *pTo++ = *pFrom++;
128 *pTo++ = *pFrom++;
129 return bSwap ? SWAPLONG( nVal ) : nVal;
131 char * GetUTF8( sal_uInt32 nPos )
133 return GetPointer( nPos );
137 RSCBYTEORDER_TYPE GetByteOrder() const { return nByteOrder; }
138 sal_uInt32 Size(){ return( nLen ); };
139 void Put( sal_uInt64 lVal )
141 if( bSwap )
143 Put( *(((sal_uInt32*)&lVal)+1) );
144 Put( *(sal_uInt32*)&lVal );
146 else
148 Put( *(sal_uInt32*)&lVal );
149 Put( *(((sal_uInt32*)&lVal)+1) );
152 void Put( sal_Int32 lVal )
154 if( bSwap )
156 Put( *(((sal_uInt16*)&lVal) +1) );
157 Put( *(sal_uInt16*)&lVal );
159 else
161 Put( *(sal_uInt16*)&lVal );
162 Put( *(((sal_uInt16*)&lVal) +1) );
165 void Put( sal_uInt32 nValue )
166 { Put( (sal_Int32)nValue ); }
167 void Put( sal_uInt16 nValue );
168 void Put( sal_Int16 nValue )
169 { Put( (sal_uInt16)nValue ); }
170 void PutUTF8( char * pData );
172 void PutAt( sal_uInt32 nPos, INT32 lVal )
174 if( bSwap )
176 PutAt( nPos, *(((sal_uInt16*)&lVal) +1) );
177 PutAt( nPos + 2, *(sal_uInt16*)&lVal );
179 else
181 PutAt( nPos, *(sal_uInt16*)&lVal );
182 PutAt( nPos + 2, *(((sal_uInt16*)&lVal) +1) );
185 void PutAt( sal_uInt32 nPos, sal_uInt32 lVal )
187 PutAt( nPos, (INT32)lVal);
189 void PutAt( sal_uInt32 nPos, short nVal )
191 PutAt( nPos, (sal_uInt16)nVal );
193 void PutAt( sal_uInt32 nPos, sal_uInt16 nVal )
195 if( bSwap )
196 nVal = SWAPSHORT( nVal );
197 char* pTo = GetPointer( nPos );
198 char* pFrom = (char*)&nVal;
199 *pTo++ = *pFrom++;
200 *pTo++ = *pFrom++;
204 #endif // _RSCTOOLS_HXX