1*477794c1SAndrew Rist /**************************************************************
2cdf0e10cSrcweir *
3*477794c1SAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one
4*477794c1SAndrew Rist * or more contributor license agreements. See the NOTICE file
5*477794c1SAndrew Rist * distributed with this work for additional information
6*477794c1SAndrew Rist * regarding copyright ownership. The ASF licenses this file
7*477794c1SAndrew Rist * to you under the Apache License, Version 2.0 (the
8*477794c1SAndrew Rist * "License"); you may not use this file except in compliance
9*477794c1SAndrew Rist * with the License. You may obtain a copy of the License at
10cdf0e10cSrcweir *
11*477794c1SAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0
12cdf0e10cSrcweir *
13*477794c1SAndrew Rist * Unless required by applicable law or agreed to in writing,
14*477794c1SAndrew Rist * software distributed under the License is distributed on an
15*477794c1SAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*477794c1SAndrew Rist * KIND, either express or implied. See the License for the
17*477794c1SAndrew Rist * specific language governing permissions and limitations
18*477794c1SAndrew Rist * under the License.
19cdf0e10cSrcweir *
20*477794c1SAndrew Rist *************************************************************/
21*477794c1SAndrew Rist
22*477794c1SAndrew Rist
23cdf0e10cSrcweir
24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
25cdf0e10cSrcweir #include "precompiled_rsc.hxx"
26cdf0e10cSrcweir /****************** I N C L U D E S **************************************/
27cdf0e10cSrcweir
28cdf0e10cSrcweir // C and C++ Includes.
29cdf0e10cSrcweir #include <stdlib.h>
30cdf0e10cSrcweir #include <stdio.h>
31cdf0e10cSrcweir #if defined (WNT )
32cdf0e10cSrcweir #include <direct.h>
33cdf0e10cSrcweir #endif
34cdf0e10cSrcweir #if defined ( OS2 ) && !defined ( GCC )
35cdf0e10cSrcweir #include <direct.h>
36cdf0e10cSrcweir #endif
37cdf0e10cSrcweir #include <string.h>
38cdf0e10cSrcweir #include <ctype.h>
39cdf0e10cSrcweir
40cdf0e10cSrcweir #include <tools/fsys.hxx>
41cdf0e10cSrcweir
42cdf0e10cSrcweir // Include
43cdf0e10cSrcweir #include <rscdef.hxx>
44cdf0e10cSrcweir #include <rsctools.hxx>
45cdf0e10cSrcweir
46cdf0e10cSrcweir #include <osl/file.h>
47cdf0e10cSrcweir #include <rtl/alloc.h>
48cdf0e10cSrcweir #include <rtl/memory.h>
49cdf0e10cSrcweir
50cdf0e10cSrcweir using namespace rtl;
51cdf0e10cSrcweir
52cdf0e10cSrcweir /****************** C o d e **********************************************/
53cdf0e10cSrcweir /*************************************************************************
54cdf0e10cSrcweir |*
55cdf0e10cSrcweir |* rsc_strnicmp()
56cdf0e10cSrcweir |*
57cdf0e10cSrcweir |* Beschreibung Vergleicht zwei Strings Case-Unabhaengig bis zu
58cdf0e10cSrcweir |* einer bestimmten Laenge
59cdf0e10cSrcweir |* Ersterstellung MM 13.02.91
60cdf0e10cSrcweir |* Letzte Aenderung MM 13.02.91
61cdf0e10cSrcweir |*
62cdf0e10cSrcweir *************************************************************************/
rsc_strnicmp(const char * string1,const char * string2,size_t count)63cdf0e10cSrcweir int rsc_strnicmp( const char *string1, const char *string2, size_t count )
64cdf0e10cSrcweir {
65cdf0e10cSrcweir size_t i;
66cdf0e10cSrcweir
67cdf0e10cSrcweir for( i = 0; ( i < count ) && string1[ i ] && string2[ i ] ; i++ )
68cdf0e10cSrcweir {
69cdf0e10cSrcweir if( tolower( string1[ i ] ) < tolower( string2[ i ] ) )
70cdf0e10cSrcweir return( -1 );
71cdf0e10cSrcweir else if( tolower( string1[ i ] ) > tolower( string2[ i ] ) )
72cdf0e10cSrcweir return( 1 );
73cdf0e10cSrcweir }
74cdf0e10cSrcweir if( i == count )
75cdf0e10cSrcweir return( 0 );
76cdf0e10cSrcweir else if( tolower( string1[ i ] ) < tolower( string2[ i ] ) )
77cdf0e10cSrcweir return( -1 );
78cdf0e10cSrcweir else if( tolower( string1[ i ] ) > tolower( string2[ i ] ) )
79cdf0e10cSrcweir return( 1 );
80cdf0e10cSrcweir return( 0 );
81cdf0e10cSrcweir }
82cdf0e10cSrcweir
83cdf0e10cSrcweir /*************************************************************************
84cdf0e10cSrcweir |*
85cdf0e10cSrcweir |* rsc_strnicmp()
86cdf0e10cSrcweir |*
87cdf0e10cSrcweir |* Beschreibung Vergleicht zwei Strings Case-Unabhaengig
88cdf0e10cSrcweir |* Ersterstellung MM 13.02.91
89cdf0e10cSrcweir |* Letzte Aenderung MM 13.02.91
90cdf0e10cSrcweir |*
91cdf0e10cSrcweir *************************************************************************/
rsc_stricmp(const char * string1,const char * string2)92cdf0e10cSrcweir int rsc_stricmp( const char *string1, const char *string2 ){
93cdf0e10cSrcweir int i;
94cdf0e10cSrcweir
95cdf0e10cSrcweir for( i = 0; string1[ i ] && string2[ i ]; i++ ){
96cdf0e10cSrcweir if( tolower( string1[ i ] ) < tolower( string2[ i ] ) )
97cdf0e10cSrcweir return( -1 );
98cdf0e10cSrcweir else if( tolower( string1[ i ] ) > tolower( string2[ i ] ) )
99cdf0e10cSrcweir return( 1 );
100cdf0e10cSrcweir }
101cdf0e10cSrcweir if( tolower( string1[ i ] ) < tolower( string2[ i ] ) )
102cdf0e10cSrcweir return( -1 );
103cdf0e10cSrcweir else if( tolower( string1[ i ] ) > tolower( string2[ i ] ) )
104cdf0e10cSrcweir return( 1 );
105cdf0e10cSrcweir return( 0 );
106cdf0e10cSrcweir }
107cdf0e10cSrcweir
rsc_strdup(const char * pStr)108cdf0e10cSrcweir char* rsc_strdup( const char* pStr )
109cdf0e10cSrcweir {
110cdf0e10cSrcweir int nLen = strlen( pStr );
111cdf0e10cSrcweir char* pBuffer = (char*)rtl_allocateMemory( nLen+1 );
112cdf0e10cSrcweir rtl_copyMemory( pBuffer, pStr, nLen+1 );
113cdf0e10cSrcweir return pBuffer;
114cdf0e10cSrcweir }
115cdf0e10cSrcweir
116cdf0e10cSrcweir /*************************************************************************
117cdf0e10cSrcweir |*
118cdf0e10cSrcweir |* GetTmpFileName()
119cdf0e10cSrcweir |*
120cdf0e10cSrcweir |* Beschreibung Gibt einen String eines eindeutigen Dateinamens
121cdf0e10cSrcweir |* zurueck. Der Speicher fuer den String wird mit
122cdf0e10cSrcweir |* malloc allokiert
123cdf0e10cSrcweir |* Ersterstellung MM 13.02.91
124cdf0e10cSrcweir |* Letzte Aenderung MH 13.10.97
125cdf0e10cSrcweir |*
126cdf0e10cSrcweir *************************************************************************/
GetTmpFileName()127cdf0e10cSrcweir ByteString GetTmpFileName()
128cdf0e10cSrcweir {
129cdf0e10cSrcweir OUString aTmpURL, aTmpFile;
130cdf0e10cSrcweir osl_createTempFile( NULL, NULL, &aTmpURL.pData );
131cdf0e10cSrcweir osl_getSystemPathFromFileURL( aTmpURL.pData, &aTmpFile.pData );
132cdf0e10cSrcweir return OUStringToOString( aTmpFile, RTL_TEXTENCODING_MS_1252 );
133cdf0e10cSrcweir }
134cdf0e10cSrcweir
135cdf0e10cSrcweir /********************************************************************/
136cdf0e10cSrcweir /* */
137cdf0e10cSrcweir /* Function : Append( ) */
138cdf0e10cSrcweir /* */
139cdf0e10cSrcweir /* Parameters : psw - pointer to a preprocessor switch */
140cdf0e10cSrcweir /* */
141cdf0e10cSrcweir /* Description : appends text files */
142cdf0e10cSrcweir /********************************************************************/
Append(FILE * fDest,ByteString aTmpFile)143cdf0e10cSrcweir sal_Bool Append( FILE * fDest, ByteString aTmpFile )
144cdf0e10cSrcweir {
145cdf0e10cSrcweir #define MAX_BUF 4096
146cdf0e10cSrcweir char szBuf[ MAX_BUF ];
147cdf0e10cSrcweir int nItems;
148cdf0e10cSrcweir FILE *fSource;
149cdf0e10cSrcweir
150cdf0e10cSrcweir fSource = fopen( aTmpFile.GetBuffer(), "rb" );
151cdf0e10cSrcweir if( !fDest || !fSource ){
152cdf0e10cSrcweir if( fSource )
153cdf0e10cSrcweir fclose( fSource );
154cdf0e10cSrcweir return sal_False;
155cdf0e10cSrcweir }
156cdf0e10cSrcweir else{
157cdf0e10cSrcweir do{ // append
158cdf0e10cSrcweir nItems = fread( szBuf, sizeof( char ), MAX_BUF, fSource );
159cdf0e10cSrcweir fwrite( szBuf, sizeof( char ), nItems, fDest );
160cdf0e10cSrcweir } while( MAX_BUF == nItems );
161cdf0e10cSrcweir
162cdf0e10cSrcweir fclose( fSource );
163cdf0e10cSrcweir };
164cdf0e10cSrcweir return sal_True;
165cdf0e10cSrcweir }
166cdf0e10cSrcweir
Append(ByteString aOutputSrs,ByteString aTmpFile)167cdf0e10cSrcweir sal_Bool Append( ByteString aOutputSrs, ByteString aTmpFile )
168cdf0e10cSrcweir {
169cdf0e10cSrcweir FILE * fDest = fopen( aOutputSrs.GetBuffer(), "ab" );
170cdf0e10cSrcweir
171cdf0e10cSrcweir sal_Bool bRet = Append( fDest, aTmpFile );
172cdf0e10cSrcweir
173cdf0e10cSrcweir if( fDest )
174cdf0e10cSrcweir fclose( fDest );
175cdf0e10cSrcweir
176cdf0e10cSrcweir return bRet;
177cdf0e10cSrcweir }
178cdf0e10cSrcweir
179cdf0e10cSrcweir /*************************************************************************
180cdf0e10cSrcweir |*
181cdf0e10cSrcweir |* InputFile
182cdf0e10cSrcweir |*
183cdf0e10cSrcweir |* Beschreibung Haengt Extension an, wenn keine da ist
184cdf0e10cSrcweir |* Parameter: pInput, der Input-Dateiname.
185cdf0e10cSrcweir |* pExt, die Extension des Ausgabenamens
186cdf0e10cSrcweir |* Ersterstellung MM 13.02.91
187cdf0e10cSrcweir |* Letzte Aenderung MM 28.06.91
188cdf0e10cSrcweir |*
189cdf0e10cSrcweir *************************************************************************/
InputFile(const char * pInput,const char * pExt)190cdf0e10cSrcweir ByteString InputFile ( const char * pInput, const char * pExt )
191cdf0e10cSrcweir {
192cdf0e10cSrcweir UniString aUniInput( pInput, RTL_TEXTENCODING_ASCII_US );
193cdf0e10cSrcweir DirEntry aFileName( aUniInput );
194cdf0e10cSrcweir
195cdf0e10cSrcweir if ( 0 == aFileName.GetExtension().Len() )
196cdf0e10cSrcweir {
197cdf0e10cSrcweir UniString aExt( pExt, RTL_TEXTENCODING_ASCII_US );
198cdf0e10cSrcweir aFileName.SetExtension( aExt );
199cdf0e10cSrcweir }
200cdf0e10cSrcweir
201cdf0e10cSrcweir return ByteString( aFileName.GetFull(), RTL_TEXTENCODING_ASCII_US );
202cdf0e10cSrcweir }
203cdf0e10cSrcweir
204cdf0e10cSrcweir /*************************************************************************
205cdf0e10cSrcweir |*
206cdf0e10cSrcweir |* OutputFile
207cdf0e10cSrcweir |*
208cdf0e10cSrcweir |* Beschreibung Ersetzt Extension durch eine andere
209cdf0e10cSrcweir |* Parameter: input, der Input-Dateiname.
210cdf0e10cSrcweir |* pExt, die Extension des Ausgabenamens
211cdf0e10cSrcweir |* Ersterstellung MM 13.02.91
212cdf0e10cSrcweir |* Letzte Aenderung MM 28.06.91
213cdf0e10cSrcweir |*
214cdf0e10cSrcweir *************************************************************************/
OutputFile(ByteString aInput,const char * pExt)215cdf0e10cSrcweir ByteString OutputFile ( ByteString aInput, const char * pExt )
216cdf0e10cSrcweir {
217cdf0e10cSrcweir UniString aUniInput( aInput, RTL_TEXTENCODING_ASCII_US );
218cdf0e10cSrcweir DirEntry aFileName( aUniInput );
219cdf0e10cSrcweir
220cdf0e10cSrcweir UniString aExt( pExt, RTL_TEXTENCODING_ASCII_US );
221cdf0e10cSrcweir aFileName.SetExtension( aExt );
222cdf0e10cSrcweir
223cdf0e10cSrcweir return ByteString( aFileName.GetFull(), RTL_TEXTENCODING_ASCII_US );
224cdf0e10cSrcweir }
225cdf0e10cSrcweir
226cdf0e10cSrcweir /*************************************************************************
227cdf0e10cSrcweir |*
228cdf0e10cSrcweir |* ::ResonseFile()
229cdf0e10cSrcweir |*
230cdf0e10cSrcweir |* Beschreibung Kommandozeile aufbereiten
231cdf0e10cSrcweir |* Ersterstellung MM 05.09.91
232cdf0e10cSrcweir |* Letzte Aenderung MM 05.09.91
233cdf0e10cSrcweir |*
234cdf0e10cSrcweir *************************************************************************/
ResponseFile(RscPtrPtr * ppCmd,char ** ppArgv,sal_uInt32 nArgc)235cdf0e10cSrcweir char * ResponseFile( RscPtrPtr * ppCmd, char ** ppArgv, sal_uInt32 nArgc )
236cdf0e10cSrcweir {
237cdf0e10cSrcweir FILE *fFile;
238cdf0e10cSrcweir int nItems;
239cdf0e10cSrcweir char szBuffer[4096]; // file buffer
240cdf0e10cSrcweir sal_uInt32 i;
241cdf0e10cSrcweir bool bInQuotes = false;
242cdf0e10cSrcweir
243cdf0e10cSrcweir // Programmname
244cdf0e10cSrcweir ppCmd->Append( rsc_strdup( *ppArgv ) );
245cdf0e10cSrcweir for( i = 1; i < nArgc; i++ )
246cdf0e10cSrcweir {
247cdf0e10cSrcweir if( '@' == **(ppArgv +i) ){ // wenn @, dann Response-Datei
248cdf0e10cSrcweir if( NULL == (fFile = fopen( (*(ppArgv +i)) +1, "r" )) )
249cdf0e10cSrcweir return( (*(ppArgv +i)) );
250cdf0e10cSrcweir nItems = fread( &szBuffer[ 0 ], 1, sizeof( char ), fFile );
251cdf0e10cSrcweir while( nItems )
252cdf0e10cSrcweir {
253cdf0e10cSrcweir if( !isspace( szBuffer[ 0 ] ) )
254cdf0e10cSrcweir {
255cdf0e10cSrcweir /*
256cdf0e10cSrcweir * #i27914# double ticks '"' now have a duplicate function:
257cdf0e10cSrcweir * 1. they define a string ( e.g. -DFOO="baz" )
258cdf0e10cSrcweir * 2. a string can contain spaces, so -DFOO="baz zum" defines one
259cdf0e10cSrcweir * argument no two !
260cdf0e10cSrcweir */
261cdf0e10cSrcweir unsigned int n = 0;
262cdf0e10cSrcweir while( nItems && (!isspace( szBuffer[ n ] ) || bInQuotes) &&
263cdf0e10cSrcweir n +1 < sizeof( szBuffer ) )
264cdf0e10cSrcweir {
265cdf0e10cSrcweir n++;
266cdf0e10cSrcweir nItems = fread( &szBuffer[ n ], 1,
267cdf0e10cSrcweir sizeof( char ), fFile );
268cdf0e10cSrcweir if( szBuffer[n] == '"' )
269cdf0e10cSrcweir bInQuotes = !bInQuotes;
270cdf0e10cSrcweir }
271cdf0e10cSrcweir szBuffer[ n ] = '\0';
272cdf0e10cSrcweir ppCmd->Append( rsc_strdup( szBuffer ) );
273cdf0e10cSrcweir }
274cdf0e10cSrcweir nItems = fread( &szBuffer[ 0 ], 1, sizeof( char ), fFile );
275cdf0e10cSrcweir };
276cdf0e10cSrcweir
277cdf0e10cSrcweir fclose( fFile );
278cdf0e10cSrcweir }
279cdf0e10cSrcweir else
280cdf0e10cSrcweir ppCmd->Append( rsc_strdup( *(ppArgv +i) ) );
281cdf0e10cSrcweir };
282cdf0e10cSrcweir ppCmd->Append( (void *)0 );
283cdf0e10cSrcweir return( NULL );
284cdf0e10cSrcweir }
285cdf0e10cSrcweir
286cdf0e10cSrcweir
287cdf0e10cSrcweir /*************** R s c P t r P t r **************************************/
288cdf0e10cSrcweir /*************************************************************************
289cdf0e10cSrcweir |*
290cdf0e10cSrcweir |* RscPtrPtr :: RscPtrPtr()
291cdf0e10cSrcweir |*
292cdf0e10cSrcweir |* Beschreibung Eine Tabelle mit Zeigern
293cdf0e10cSrcweir |* Ersterstellung MM 13.02.91
294cdf0e10cSrcweir |* Letzte Aenderung MM 13.02.91
295cdf0e10cSrcweir |*
296cdf0e10cSrcweir *************************************************************************/
RscPtrPtr()297cdf0e10cSrcweir RscPtrPtr :: RscPtrPtr(){
298cdf0e10cSrcweir nCount = 0;
299cdf0e10cSrcweir pMem = NULL;
300cdf0e10cSrcweir }
301cdf0e10cSrcweir
302cdf0e10cSrcweir /*************************************************************************
303cdf0e10cSrcweir |*
304cdf0e10cSrcweir |* RscPtrPtr :: ~RscPtrPtr()
305cdf0e10cSrcweir |*
306cdf0e10cSrcweir |* Beschreibung Zerst�rt eine Tabelle mit Zeigern, die Zeiger werde
307cdf0e10cSrcweir |* ebenfalls freigegebn
308cdf0e10cSrcweir |* Ersterstellung MM 13.02.91
309cdf0e10cSrcweir |* Letzte Aenderung MM 13.02.91
310cdf0e10cSrcweir |*
311cdf0e10cSrcweir *************************************************************************/
~RscPtrPtr()312cdf0e10cSrcweir RscPtrPtr :: ~RscPtrPtr(){
313cdf0e10cSrcweir Reset();
314cdf0e10cSrcweir }
315cdf0e10cSrcweir
316cdf0e10cSrcweir /*************************************************************************
317cdf0e10cSrcweir |*
318cdf0e10cSrcweir |* RscPtrPtr :: Reset()
319cdf0e10cSrcweir |*
320cdf0e10cSrcweir |* Beschreibung
321cdf0e10cSrcweir |* Ersterstellung MM 03.05.91
322cdf0e10cSrcweir |* Letzte Aenderung MM 03.05.91
323cdf0e10cSrcweir |*
324cdf0e10cSrcweir *************************************************************************/
Reset()325cdf0e10cSrcweir void RscPtrPtr :: Reset(){
326cdf0e10cSrcweir sal_uInt32 i;
327cdf0e10cSrcweir
328cdf0e10cSrcweir if( pMem ){
329cdf0e10cSrcweir for( i = 0; i < nCount; i++ ){
330cdf0e10cSrcweir if( pMem[ i ] )
331cdf0e10cSrcweir rtl_freeMemory( pMem[ i ] );
332cdf0e10cSrcweir }
333cdf0e10cSrcweir rtl_freeMemory( (void *)pMem );
334cdf0e10cSrcweir };
335cdf0e10cSrcweir nCount = 0;
336cdf0e10cSrcweir pMem = NULL;
337cdf0e10cSrcweir }
338cdf0e10cSrcweir
339cdf0e10cSrcweir /*************************************************************************
340cdf0e10cSrcweir |*
341cdf0e10cSrcweir |* RscPtrPtr :: Append()
342cdf0e10cSrcweir |*
343cdf0e10cSrcweir |* Beschreibung Haengt einen Eintrag an.
344cdf0e10cSrcweir |* Ersterstellung MM 13.02.91
345cdf0e10cSrcweir |* Letzte Aenderung MM 13.02.91
346cdf0e10cSrcweir |*
347cdf0e10cSrcweir *************************************************************************/
Append(void * pBuffer)348cdf0e10cSrcweir sal_uInt32 RscPtrPtr :: Append( void * pBuffer ){
349cdf0e10cSrcweir if( !pMem )
350cdf0e10cSrcweir pMem = (void **)rtl_allocateMemory( (nCount +1) * sizeof( void * ) );
351cdf0e10cSrcweir else
352cdf0e10cSrcweir pMem = (void **)rtl_reallocateMemory( (void *)pMem,
353cdf0e10cSrcweir ((nCount +1) * sizeof( void * )
354cdf0e10cSrcweir ) );
355cdf0e10cSrcweir pMem[ nCount ] = pBuffer;
356cdf0e10cSrcweir return( nCount++ );
357cdf0e10cSrcweir }
358cdf0e10cSrcweir
359cdf0e10cSrcweir /*************************************************************************
360cdf0e10cSrcweir |*
361cdf0e10cSrcweir |* RscPtrPtr :: GetEntry()
362cdf0e10cSrcweir |*
363cdf0e10cSrcweir |* Beschreibung Liefert einen Eintrag, NULL wenn nicht vorhanden.
364cdf0e10cSrcweir |* Ersterstellung MM 13.02.91
365cdf0e10cSrcweir |* Letzte Aenderung MM 13.02.91
366cdf0e10cSrcweir |*
367cdf0e10cSrcweir *************************************************************************/
GetEntry(sal_uInt32 nEntry)368cdf0e10cSrcweir void * RscPtrPtr :: GetEntry( sal_uInt32 nEntry ){
369cdf0e10cSrcweir if( nEntry < nCount )
370cdf0e10cSrcweir return( pMem[ nEntry ] );
371cdf0e10cSrcweir return( NULL );
372cdf0e10cSrcweir }
373cdf0e10cSrcweir
374cdf0e10cSrcweir /****************** R S C W R I T E R C **********************************/
375cdf0e10cSrcweir /*************************************************************************
376cdf0e10cSrcweir |*
377cdf0e10cSrcweir |* RscWriteRc :: RscWriteRc()
378cdf0e10cSrcweir |*
379cdf0e10cSrcweir |* Beschreibung
380cdf0e10cSrcweir |* Ersterstellung MM 15.04.91
381cdf0e10cSrcweir |* Letzte Aenderung MM 15.04.91
382cdf0e10cSrcweir |*
383cdf0e10cSrcweir *************************************************************************/
RscWriteRc(RSCBYTEORDER_TYPE nOrder)384cdf0e10cSrcweir RscWriteRc::RscWriteRc( RSCBYTEORDER_TYPE nOrder )
385cdf0e10cSrcweir {
386cdf0e10cSrcweir short nSwapTest = 1;
387cdf0e10cSrcweir RSCBYTEORDER_TYPE nMachineOrder;
388cdf0e10cSrcweir
389cdf0e10cSrcweir bSwap = sal_False;
390cdf0e10cSrcweir if( nOrder != RSC_SYSTEMENDIAN )
391cdf0e10cSrcweir {
392cdf0e10cSrcweir if( (sal_uInt8)*(sal_uInt8 *)&nSwapTest )
393cdf0e10cSrcweir nMachineOrder = RSC_LITTLEENDIAN;
394cdf0e10cSrcweir else
395cdf0e10cSrcweir nMachineOrder = RSC_BIGENDIAN;
396cdf0e10cSrcweir bSwap = nOrder != nMachineOrder;
397cdf0e10cSrcweir }
398cdf0e10cSrcweir nByteOrder = nOrder;
399cdf0e10cSrcweir nLen = 0;
400cdf0e10cSrcweir pMem = NULL;
401cdf0e10cSrcweir }
402cdf0e10cSrcweir
403cdf0e10cSrcweir /*************************************************************************
404cdf0e10cSrcweir |*
405cdf0e10cSrcweir |* RscWriteRc :: ~RscWriteRc()
406cdf0e10cSrcweir |*
407cdf0e10cSrcweir |* Beschreibung
408cdf0e10cSrcweir |* Ersterstellung MM 15.04.91
409cdf0e10cSrcweir |* Letzte Aenderung MM 15.04.91
410cdf0e10cSrcweir |*
411cdf0e10cSrcweir *************************************************************************/
~RscWriteRc()412cdf0e10cSrcweir RscWriteRc :: ~RscWriteRc()
413cdf0e10cSrcweir {
414cdf0e10cSrcweir if( pMem )
415cdf0e10cSrcweir rtl_freeMemory( pMem );
416cdf0e10cSrcweir }
417cdf0e10cSrcweir
418cdf0e10cSrcweir /*************************************************************************
419cdf0e10cSrcweir |*
420cdf0e10cSrcweir |* RscWriteRc :: IncSize()
421cdf0e10cSrcweir |*
422cdf0e10cSrcweir |* Beschreibung
423cdf0e10cSrcweir |* Ersterstellung MM 15.04.91
424cdf0e10cSrcweir |* Letzte Aenderung MM 15.04.91
425cdf0e10cSrcweir |*
426cdf0e10cSrcweir *************************************************************************/
IncSize(sal_uInt32 nSize)427cdf0e10cSrcweir sal_uInt32 RscWriteRc :: IncSize( sal_uInt32 nSize )
428cdf0e10cSrcweir {
429cdf0e10cSrcweir nLen += nSize;
430cdf0e10cSrcweir if( pMem )
431cdf0e10cSrcweir pMem = (char*)rtl_reallocateMemory( pMem, nLen );
432cdf0e10cSrcweir return( nLen - nSize );
433cdf0e10cSrcweir }
434cdf0e10cSrcweir
435cdf0e10cSrcweir /*************************************************************************
436cdf0e10cSrcweir |*
437cdf0e10cSrcweir |* RscWriteRc :: GetPointer()
438cdf0e10cSrcweir |*
439cdf0e10cSrcweir |* Beschreibung
440cdf0e10cSrcweir |* Ersterstellung MM 15.04.91
441cdf0e10cSrcweir |* Letzte Aenderung MM 15.04.91
442cdf0e10cSrcweir |*
443cdf0e10cSrcweir *************************************************************************/
GetPointer(sal_uInt32 nSize)444cdf0e10cSrcweir char * RscWriteRc :: GetPointer( sal_uInt32 nSize )
445cdf0e10cSrcweir {
446cdf0e10cSrcweir if( !pMem )
447cdf0e10cSrcweir pMem = (char *)rtl_allocateMemory( nLen );
448cdf0e10cSrcweir return( pMem + nSize );
449cdf0e10cSrcweir }
450cdf0e10cSrcweir
451cdf0e10cSrcweir
452cdf0e10cSrcweir /*************************************************************************
453cdf0e10cSrcweir |*
454cdf0e10cSrcweir |* RscWriteRc :: Put()
455cdf0e10cSrcweir |*
456cdf0e10cSrcweir |* Beschreibung
457cdf0e10cSrcweir |* Ersterstellung MM 15.04.91
458cdf0e10cSrcweir |* Letzte Aenderung MM 15.04.91
459cdf0e10cSrcweir |*
460cdf0e10cSrcweir *************************************************************************/
Put(sal_uInt16 nVal)461cdf0e10cSrcweir void RscWriteRc :: Put( sal_uInt16 nVal )
462cdf0e10cSrcweir {
463cdf0e10cSrcweir sal_uInt32 nOldLen;
464cdf0e10cSrcweir
465cdf0e10cSrcweir nOldLen = IncSize( sizeof( nVal ) );
466cdf0e10cSrcweir PutAt( nOldLen, nVal );
467cdf0e10cSrcweir }
468cdf0e10cSrcweir
PutUTF8(char * pStr)469cdf0e10cSrcweir void RscWriteRc :: PutUTF8( char * pStr )
470cdf0e10cSrcweir {
471cdf0e10cSrcweir sal_uInt32 nStrLen = 0;
472cdf0e10cSrcweir if( pStr )
473cdf0e10cSrcweir nStrLen = strlen( pStr );
474cdf0e10cSrcweir
475cdf0e10cSrcweir sal_uInt32 n = nStrLen +1;
476cdf0e10cSrcweir if( n % 2 )
477cdf0e10cSrcweir // align to 2
478cdf0e10cSrcweir n++;
479cdf0e10cSrcweir
480cdf0e10cSrcweir sal_uInt32 nOldLen = IncSize( n );
481cdf0e10cSrcweir rtl_copyMemory( GetPointer( nOldLen ), pStr, nStrLen );
482cdf0e10cSrcweir // 0 terminated
483cdf0e10cSrcweir pMem[ nOldLen + nStrLen ] = '\0';
484cdf0e10cSrcweir }
485