bump product version to 5.0.4.1
[LibreOffice.git] / rsc / inc / rsctools.hxx
blobf8d50c02e0773f4aeaec2e9e4960a291cae3af18
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
19 struct RSHEADER_TYPE;
20 class RscPtrPtr;
22 #ifndef INCLUDED_RSC_INC_RSCTOOLS_HXX
23 #define INCLUDED_RSC_INC_RSCTOOLS_HXX
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>
33 // Zeichensatz
34 enum COMPARE { LESS = -1, EQUAL = 0, GREATER = 1 };
36 enum RSCBYTEORDER_TYPE { RSC_BIGENDIAN, RSC_LITTLEENDIAN, RSC_SYSTEMENDIAN };
38 #define ALIGNED_SIZE( nSize ) \
39 (nSize + sizeof( void * ) -1) / sizeof( void * ) * sizeof( void * )
41 // Function Forwards
42 OString GetTmpFileName();
44 bool Append(const OString &rDestFile, const OString &rSourceFile);
46 bool Append(FILE * fDest, OString &raSourceFile);
48 OString OutputFile(const OString &rInput, const char * ext);
50 char * ResponseFile( RscPtrPtr * ppCmd, char ** ppArgv,
51 sal_uInt32 nArgc );
53 void RscExit( sal_uInt32 nExit );
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* );
60 typedef ::std::vector< OString* > RscStrList;
62 class RscChar
64 public:
65 static char * MakeUTF8( char * pStr, sal_uInt16 nTextEncoding );
68 class RscPtrPtr
70 sal_uInt32 nCount;
71 void ** pMem;
72 public:
73 RscPtrPtr();
74 ~RscPtrPtr();
75 void Reset();
76 sal_uInt32 Append( void * );
77 sal_uInt32 Append( char * pStr ) { return Append( (void *)pStr ); }
78 sal_uInt32 GetCount() { return nCount; }
79 void * GetEntry( sal_uInt32 nEle );
80 void ** GetBlock() { return pMem; }
83 class RscWriteRc
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 void * GetBuffer()
96 return GetPointer( 0 );
98 sal_uInt16 GetShort( sal_uInt32 nPos )
100 sal_uInt16 nVal = 0;
101 char* pFrom = GetPointer(nPos);
102 char* pTo = reinterpret_cast<char*>(&nVal);
103 *pTo++ = *pFrom++;
104 *pTo++ = *pFrom++;
105 return bSwap ? OSL_SWAPWORD( nVal ) : nVal;
107 sal_uInt32 GetLong( sal_uInt32 nPos )
109 sal_uInt32 nVal = 0;
110 char* pFrom = GetPointer(nPos);
111 char* pTo = reinterpret_cast<char*>(&nVal);
112 *pTo++ = *pFrom++;
113 *pTo++ = *pFrom++;
114 *pTo++ = *pFrom++;
115 *pTo++ = *pFrom++;
116 return bSwap ? OSL_SWAPDWORD( nVal ) : nVal;
118 char * GetUTF8( sal_uInt32 nPos )
120 return GetPointer( nPos );
124 RSCBYTEORDER_TYPE GetByteOrder() const { return nByteOrder; }
125 sal_uInt32 Size(){ return nLen; }
126 void Put( sal_uInt64 lVal )
128 union
130 sal_uInt64 lVal64;
131 sal_uInt32 aVal32[2];
133 lVal64 = lVal;
134 if( bSwap )
136 Put( aVal32[1] );
137 Put( aVal32[0] );
139 else
141 Put( aVal32[0] );
142 Put( aVal32[1] );
145 void Put( sal_Int32 lVal )
147 union
149 sal_uInt32 lVal32;
150 sal_uInt16 aVal16[2];
152 lVal32 = lVal;
154 if( bSwap )
156 Put( aVal16[1] );
157 Put( aVal16[0] );
159 else
161 Put( aVal16[0] );
162 Put( aVal16[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, sal_Int32 lVal )
174 union
176 sal_uInt32 lVal32;
177 sal_uInt16 aVal16[2];
179 lVal32 = lVal;
181 if( bSwap )
183 PutAt( nPos, aVal16[1] );
184 PutAt( nPos + 2, aVal16[0] );
186 else
188 PutAt( nPos, aVal16[0] );
189 PutAt( nPos + 2, aVal16[1] );
192 void PutAt( sal_uInt32 nPos, sal_uInt32 lVal )
194 PutAt( nPos, (sal_Int32)lVal);
196 void PutAt( sal_uInt32 nPos, short nVal )
198 PutAt( nPos, (sal_uInt16)nVal );
200 void PutAt( sal_uInt32 nPos, sal_uInt16 nVal )
202 if( bSwap )
203 nVal = OSL_SWAPWORD( nVal );
204 char* pTo = GetPointer( nPos );
205 char* pFrom = reinterpret_cast<char*>(&nVal);
206 *pTo++ = *pFrom++;
207 *pTo++ = *pFrom++;
211 #endif // INCLUDED_RSC_INC_RSCTOOLS_HXX
213 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */