merge the formfield patch from ooo-build
[ooovba.git] / sal / qa / osl / file / osl_File_Const.h
blob41067d2c48c990fe40bf219e62adc12b74327be7
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: osl_File_Const.h,v $
10 * $Revision: 1.10 $
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 ************************************************************************/
31 //------------------------------------------------------------------------
32 //------------------------------------------------------------------------
34 #ifndef _OSL_FILE_CONST_H_
35 #define _OSL_FILE_CONST_H_
37 //------------------------------------------------------------------------
38 //------------------------------------------------------------------------
39 #include <stdlib.h>
40 #include <stdio.h>
41 #include <string.h>
42 #include <sal/types.h>
43 #include <rtl/textenc.h>
45 #include <rtl/ustring.hxx>
46 #include <rtl/uri.hxx>
50 //------------------------------------------------------------------------
51 //------------------------------------------------------------------------
54 #ifdef __cplusplus
55 extern "C"
57 #endif
61 //------------------------------------------------------------------------
62 // common used string resource
63 // these common used string will be used as assist resource in test
64 // they are mostly OS independent, some of the resource can be reused
65 // so, acommon test data repository will be better since it can be
66 // shared among all test code
67 //------------------------------------------------------------------------
69 const sal_Char pBuffer_Char[] = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
70 const sal_Char pBuffer_Number[] = "1234567890";
71 const sal_Char pBuffer_Blank[] = "";
73 #define TRUNC_LEN 10;
74 #define ENLARG_LEN 100;
78 //------------------------------------------------------------------------
79 // OS dependent/independent definitions/includes
80 // we use FILE_PREFIX for URL prefix,
81 // TEST_PLATFORM for test platform initial,
82 // TEST_PLATFORM_ROOT for root dir in comrresponding platform,
83 // TEST_PLATFORM_TEMP for temp dir in comrresponding platform,
84 // PATH_LIST_DELIMITER for seperator of path list in comrresponding platform,
85 // PATH_SEPERATOR for seperator in URL or system path in comrresponding platform,
86 // PATH_MAX/MAX_PATH for max path length in comrresponding platform,
87 //------------------------------------------------------------------------
89 //------------------------------------------------------------------------
90 // OS independent const definition
91 //------------------------------------------------------------------------
92 # define FILE_PREFIX "file:///"
93 # define TEST_FILE_SIZE 1024
95 //------------------------------------------------------------------------
96 // OS dependent declaration and includes
97 //------------------------------------------------------------------------
98 #if ( defined UNX ) || ( defined OS2 ) //Unix
99 # include <unistd.h>
100 # include <limits.h>
101 # include <math.h>
102 # include <errno.h>
103 # include <fcntl.h>
104 # include <sys/stat.h>
105 # include <sys/statfs.h>
106 # include <sys/statvfs.h>
107 # include <sys/types.h>
108 # define TEST_PLATFORM ""
109 # define TEST_PLATFORM_ROOT "/"
110 # define TEST_PLATFORM_TEMP "tmp"
111 # define PATH_LIST_DELIMITER ":"
112 # define PATH_SEPERATOR "/"
113 #endif
114 #if (defined WNT ) // Windows
115 #include <tools/prewin.h>
116 // # include <windows.h>
117 # include <tchar.h>
118 # include <io.h>
119 # include <stdio.h>
120 # include <stdlib.h>
121 #include <tools/postwin.h>
122 # define PATH_MAX MAX_PATH
123 # define TEST_PLATFORM "c:/"
124 # define TEST_PLATFORM_ROOT "c:/"
125 # define TEST_PLATFORM_TEMP "temp"
126 # define PATH_LIST_DELIMITER ";"
127 # define PATH_SEPERATOR "/"
128 #endif
131 //------------------------------------------------------------------------
132 // macro definition for the ASCII array/OUString declarations,
133 // we use p### for the ASCII array,
134 // a### for the OUString,
135 // n###Len for its length
136 //------------------------------------------------------------------------
138 #define OSLTEST_DECLARE( str_name, str_value ) \
139 ::rtl::OUString a##str_name = rtl::OUString::createFromAscii( ( str_value ) )
141 #define OSLTEST_DECLARE_UTF8(str_name, str_value ) \
142 ::rtl::OUString a##str_name = ::rtl::Uri::decode( ::rtl::OUString::createFromAscii( ( str_value ) ), rtl_UriDecodeToIuri, RTL_TEXTENCODING_UTF8)
144 //------------------------------------------------------------------------
145 // OS independent file definition
146 //------------------------------------------------------------------------
147 OSLTEST_DECLARE( NullURL, "" );
148 OSLTEST_DECLARE( SlashURL, PATH_SEPERATOR );
149 OSLTEST_DECLARE( PreURL, FILE_PREFIX );
150 OSLTEST_DECLARE( RootURL, FILE_PREFIX TEST_PLATFORM );
152 OSLTEST_DECLARE( TempDirectoryURL, FILE_PREFIX TEST_PLATFORM TEST_PLATFORM_TEMP );
153 OSLTEST_DECLARE( TempDirectorySys, TEST_PLATFORM_ROOT TEST_PLATFORM_TEMP );
154 OSLTEST_DECLARE( UserDirectoryURL, FILE_PREFIX TEST_PLATFORM TEST_PLATFORM_TEMP "" );
155 OSLTEST_DECLARE( UserDirectorySys, TEST_PLATFORM_ROOT TEST_PLATFORM_TEMP "" );
157 //------------------------------------------------------------------------
158 // common used URL:temp, canonical, root, relative, link,etc
159 //------------------------------------------------------------------------
160 OSLTEST_DECLARE( CanURL1, FILE_PREFIX TEST_PLATFORM TEST_PLATFORM_TEMP "/canonical.name" );
161 OSLTEST_DECLARE( CanURL2, "ca@#;+.,$///78no\0ni..name" );
162 OSLTEST_DECLARE( CanURL3, "ca@#;+.,$//tmp/678nonical//name" );
163 OSLTEST_DECLARE( CanURL4, "canonical.name" );
164 OSLTEST_DECLARE( TmpName1, "tmpdir" );
165 OSLTEST_DECLARE( TmpName2, "tmpname" );
166 OSLTEST_DECLARE( TmpName3, FILE_PREFIX TEST_PLATFORM TEST_PLATFORM_TEMP "/tmpdir" );
167 OSLTEST_DECLARE( TmpName4, FILE_PREFIX TEST_PLATFORM TEST_PLATFORM_TEMP "/tmpdir/tmpname" );
168 OSLTEST_DECLARE( TmpName5, FILE_PREFIX TEST_PLATFORM TEST_PLATFORM_TEMP "/tmpdir/../tmpdir/./tmpname" );
169 OSLTEST_DECLARE( TmpName6, FILE_PREFIX TEST_PLATFORM TEST_PLATFORM_TEMP "/tmpname" );
170 OSLTEST_DECLARE( TmpName7, FILE_PREFIX TEST_PLATFORM "tmpname" );
171 OSLTEST_DECLARE( TmpName8, FILE_PREFIX TEST_PLATFORM TEST_PLATFORM_TEMP "/tmpname/tmpdir" );
172 OSLTEST_DECLARE( TmpName9, FILE_PREFIX TEST_PLATFORM TEST_PLATFORM_TEMP "/tmpdir/../tmpdir/./" );
173 OSLTEST_DECLARE_UTF8( TmpName10, FILE_PREFIX TEST_PLATFORM TEST_PLATFORM_TEMP "/%E6%9C%AA%E5%91%BD%E5%90%8Dzhgb18030" );
175 OSLTEST_DECLARE( RelURL1, "relative/file1" );
176 OSLTEST_DECLARE( RelURL2, "relative/./file2" );
177 OSLTEST_DECLARE( RelURL3, "relative/../file3" );
178 OSLTEST_DECLARE( RelURL4, "././relative/../file4" );
179 OSLTEST_DECLARE( RelURL5, TEST_PLATFORM_TEMP "/./../" TEST_PLATFORM_TEMP );
180 OSLTEST_DECLARE( LnkURL1, FILE_PREFIX TEST_PLATFORM TEST_PLATFORM_TEMP "/link.file" );
181 OSLTEST_DECLARE( HidURL1, ".hiddenfile" );
183 //------------------------------------------------------------------------
184 // common used System Path:temp, root,etc
185 //------------------------------------------------------------------------
186 OSLTEST_DECLARE( RootSys, TEST_PLATFORM_ROOT );
187 OSLTEST_DECLARE( SysPath1, TEST_PLATFORM_ROOT TEST_PLATFORM_TEMP "/system.path" );
188 OSLTEST_DECLARE( SysPath2, TEST_PLATFORM_ROOT TEST_PLATFORM_TEMP "/system/path" );
189 OSLTEST_DECLARE( SysPath3, TEST_PLATFORM_ROOT TEST_PLATFORM_TEMP "/tmpdir" );
190 OSLTEST_DECLARE( SysPath4, TEST_PLATFORM_ROOT TEST_PLATFORM_TEMP "/tmpname" );
191 OSLTEST_DECLARE_UTF8( SysPath5, TEST_PLATFORM_ROOT TEST_PLATFORM_TEMP "/%E6%9C%AA%E5%91%BD%E5%90%8Dzhgb18030" );
192 OSLTEST_DECLARE( FifoSys, TEST_PLATFORM_ROOT TEST_PLATFORM_TEMP "/tmpdir/fifo" );
194 //------------------------------------------------------------------------
195 // FileType URL, we pick some canonical file in corresponding system for test:
196 // socket, link, etc.
197 // Note that this may be changed in the different platform, so be careful to use.
198 //------------------------------------------------------------------------
199 #if ( defined UNX ) || ( defined OS2 ) // Unix
200 OSLTEST_DECLARE( TypeURL1, FILE_PREFIX "dev/ccv"); //socket Solaris/Linux
201 OSLTEST_DECLARE( TypeURL2, FILE_PREFIX "devices/pseudo/tcp@0:tcp"); //special Solaris/Linux
202 OSLTEST_DECLARE( TypeURL3, FILE_PREFIX "lib" ); //link Solaris
203 #else // Windows
204 OSLTEST_DECLARE( TypeURL1, FILE_PREFIX "" );
205 OSLTEST_DECLARE( TypeURL2, FILE_PREFIX "" );
206 OSLTEST_DECLARE( TypeURL3, FILE_PREFIX "" );
207 #endif
209 //------------------------------------------------------------------------
210 // Volume device URL, we pick some canonical volume device for test:
211 // UNIX file system, Floppy Disk, Proc file system, Temp file system, Compact Disk.
212 //------------------------------------------------------------------------
213 #if ( defined UNX ) || ( defined OS2 ) // Unix
214 OSLTEST_DECLARE( VolURL1, FILE_PREFIX ""); //ufs Solaris/Linux
215 #ifdef SOLARIS
216 OSLTEST_DECLARE( VolURL2, FILE_PREFIX "dev/fd" ); //fd Solaris
217 #else
218 OSLTEST_DECLARE( VolURL2, FILE_PREFIX "dev/floppy/0u1440" ); //fd0 Linux
219 #endif
220 OSLTEST_DECLARE( VolURL3, FILE_PREFIX "proc" ); //proc Solaris/Linux
221 OSLTEST_DECLARE( VolURL4, FILE_PREFIX "staroffice" ); //nfs Solaris/Linux
222 OSLTEST_DECLARE( VolURL5, FILE_PREFIX "tmp" ); //tmpfs Solaris
223 OSLTEST_DECLARE( VolURL6, FILE_PREFIX "cdrom" ); //cd Solaris
224 #else // Windows
225 OSLTEST_DECLARE( VolURL1, FILE_PREFIX "c:/" );
226 OSLTEST_DECLARE( VolURL2, FILE_PREFIX "a:/" );
227 OSLTEST_DECLARE( VolURL3, FILE_PREFIX "" );
228 OSLTEST_DECLARE( VolURL4, FILE_PREFIX "" );
229 OSLTEST_DECLARE( VolURL5, FILE_PREFIX "c:/temp" );
230 OSLTEST_DECLARE( VolURL6, FILE_PREFIX "e:/" );
231 #endif
234 //------------------------------------------------------------------------
235 //------------------------------------------------------------------------
237 #ifdef __cplusplus
239 #endif
241 //------------------------------------------------------------------------
242 //------------------------------------------------------------------------
245 #endif /* _OSL_FILE_CONST_H_ */