fdo#74697 Add Bluez 5 support for impress remote.
[LibreOffice.git] / rsc / inc / rsctools.hxx
blobe26efcd6080734456a984d57d5283401771231fd
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 _RSCTOOLS_HXX
23 #define _RSCTOOLS_HXX
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>
33 /******************* T y p e s *******************************************/
34 // Zeichensatz
35 enum COMPARE { LESS = -1, EQUAL = 0, GREATER = 1 };
37 enum RSCBYTEORDER_TYPE { RSC_BIGENDIAN, RSC_LITTLEENDIAN, RSC_SYSTEMENDIAN };
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 OString GetTmpFileName();
44 sal_Bool Append(const OString &rDestFile, const OString &rSourceFile);
45 sal_Bool Append(FILE * fDest, OString &raSourceFile);
46 OString OutputFile(const OString &rInput, const char * ext);
47 char * ResponseFile( RscPtrPtr * ppCmd, char ** ppArgv,
48 sal_uInt32 nArgc );
49 void RscExit( sal_uInt32 nExit );
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* );
56 /****************** C L A S S E S ****************************************/
58 typedef ::std::vector< OString* > RscStrList;
60 /*********** R s c C h a r ***********************************************/
61 class RscChar
63 public:
64 static char * MakeUTF8( char * pStr, sal_uInt16 nTextEncoding );
67 /****************** R s c P t r P t r ************************************/
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 ){
78 return( Append( (void *)pStr ) );
80 sal_uInt32 GetCount(){ return( nCount ); };
81 void * GetEntry( sal_uInt32 nEle );
82 void ** GetBlock(){ return( pMem ); };
85 /****************** R s c W r i t e R c **********************************/
86 class RscWriteRc
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 void * GetBuffer()
99 return GetPointer( 0 );
101 sal_uInt16 GetShort( sal_uInt32 nPos )
103 sal_uInt16 nVal = 0;
104 char* pFrom = GetPointer(nPos);
105 char* pTo = (char*)&nVal;
106 *pTo++ = *pFrom++;
107 *pTo++ = *pFrom++;
108 return bSwap ? OSL_SWAPWORD( nVal ) : nVal;
110 sal_uInt32 GetLong( sal_uInt32 nPos )
112 sal_uInt32 nVal = 0;
113 char* pFrom = GetPointer(nPos);
114 char* pTo = (char*)&nVal;
115 *pTo++ = *pFrom++;
116 *pTo++ = *pFrom++;
117 *pTo++ = *pFrom++;
118 *pTo++ = *pFrom++;
119 return bSwap ? OSL_SWAPDWORD( nVal ) : nVal;
121 char * GetUTF8( sal_uInt32 nPos )
123 return GetPointer( nPos );
127 RSCBYTEORDER_TYPE GetByteOrder() const { return nByteOrder; }
128 sal_uInt32 Size(){ return( nLen ); };
129 void Put( sal_uInt64 lVal )
131 union
133 sal_uInt64 lVal64;
134 sal_uInt32 aVal32[2];
136 lVal64 = lVal;
137 if( bSwap )
139 Put( aVal32[1] );
140 Put( aVal32[0] );
142 else
144 Put( aVal32[0] );
145 Put( aVal32[1] );
148 void Put( sal_Int32 lVal )
150 union
152 sal_uInt32 lVal32;
153 sal_uInt16 aVal16[2];
155 lVal32 = lVal;
157 if( bSwap )
159 Put( aVal16[1] );
160 Put( aVal16[0] );
162 else
164 Put( aVal16[0] );
165 Put( aVal16[1] );
168 void Put( sal_uInt32 nValue )
169 { Put( (sal_Int32)nValue ); }
170 void Put( sal_uInt16 nValue );
171 void Put( sal_Int16 nValue )
172 { Put( (sal_uInt16)nValue ); }
173 void PutUTF8( char * pData );
175 void PutAt( sal_uInt32 nPos, sal_Int32 lVal )
177 union
179 sal_uInt32 lVal32;
180 sal_uInt16 aVal16[2];
182 lVal32 = lVal;
184 if( bSwap )
186 PutAt( nPos, aVal16[1] );
187 PutAt( nPos + 2, aVal16[0] );
189 else
191 PutAt( nPos, aVal16[0] );
192 PutAt( nPos + 2, aVal16[1] );
195 void PutAt( sal_uInt32 nPos, sal_uInt32 lVal )
197 PutAt( nPos, (sal_Int32)lVal);
199 void PutAt( sal_uInt32 nPos, short nVal )
201 PutAt( nPos, (sal_uInt16)nVal );
203 void PutAt( sal_uInt32 nPos, sal_uInt16 nVal )
205 if( bSwap )
206 nVal = OSL_SWAPWORD( nVal );
207 char* pTo = GetPointer( nPos );
208 char* pFrom = (char*)&nVal;
209 *pTo++ = *pFrom++;
210 *pTo++ = *pFrom++;
214 #endif // _RSCTOOLS_HXX
216 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */