1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: rsctools.hxx,v $
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 ************************************************************************/
40 #include <tools/string.hxx>
41 #include <tools/list.hxx>
43 /******************* T y p e s *******************************************/
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
,
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 ***********************************************/
73 static char * MakeUTF8( char * pStr
, UINT16 nTextEncoding
);
74 static char * MakeUTF8FromL( char * pStr
);
77 /****************** R s c P t r P t r ************************************/
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 **********************************/
100 RSCBYTEORDER_TYPE nByteOrder
;
102 char * GetPointer( sal_uInt32 nSize
);
104 RscWriteRc( RSCBYTEORDER_TYPE nOrder
= RSC_SYSTEMENDIAN
);
106 sal_uInt32
IncSize( sal_uInt32 nSize
);// gibt die vorherige Groesse
109 return GetPointer( 0 );
111 sal_uInt16
GetShort( sal_uInt32 nPos
)
114 char* pFrom
= GetPointer(nPos
);
115 char* pTo
= (char*)&nVal
;
118 return bSwap
? SWAPSHORT( nVal
) : nVal
;
120 sal_uInt32
GetLong( sal_uInt32 nPos
)
123 char* pFrom
= GetPointer(nPos
);
124 char* pTo
= (char*)&nVal
;
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
)
143 Put( *(((sal_uInt32
*)&lVal
)+1) );
144 Put( *(sal_uInt32
*)&lVal
);
148 Put( *(sal_uInt32
*)&lVal
);
149 Put( *(((sal_uInt32
*)&lVal
)+1) );
152 void Put( sal_Int32 lVal
)
156 Put( *(((sal_uInt16
*)&lVal
) +1) );
157 Put( *(sal_uInt16
*)&lVal
);
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
)
176 PutAt( nPos
, *(((sal_uInt16
*)&lVal
) +1) );
177 PutAt( nPos
+ 2, *(sal_uInt16
*)&lVal
);
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
)
196 nVal
= SWAPSHORT( nVal
);
197 char* pTo
= GetPointer( nPos
);
198 char* pFrom
= (char*)&nVal
;
204 #endif // _RSCTOOLS_HXX