xref: /aoo42x/main/sal/qa/osl/file/osl_File_Const.h (revision e6348c9c)
1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 
24 //------------------------------------------------------------------------
25 //------------------------------------------------------------------------
26 
27 #ifndef _OSL_FILE_CONST_H_
28 #define _OSL_FILE_CONST_H_
29 
30 //------------------------------------------------------------------------
31 //------------------------------------------------------------------------
32 #include <stdlib.h>
33 #include <stdio.h>
34 #include <string.h>
35 #include <sal/types.h>
36 #include <rtl/textenc.h>
37 
38 #include <rtl/ustring.hxx>
39 #include <rtl/uri.hxx>
40 
41 
42 
43 //------------------------------------------------------------------------
44 //------------------------------------------------------------------------
45 
46 
47 #ifdef __cplusplus
48 extern "C"
49 {
50 #endif
51 
52 
53 
54 //------------------------------------------------------------------------
55 // common used string resource
56 // these common used string will be used as assist resource in test
57 // they are mostly OS independent, some of the resource can be reused
58 // so, acommon test data repository will be better since it can be
59 // shared among all test code
60 //------------------------------------------------------------------------
61 
62 const sal_Char pBuffer_Char[]   = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
63 const sal_Char pBuffer_Number[] = "1234567890";
64 const sal_Char pBuffer_Blank[]  = "";
65 
66 #define TRUNC_LEN               10;
67 #define ENLARG_LEN              100;
68 
69 
70 
71 //------------------------------------------------------------------------
72 // OS dependent/independent definitions/includes
73 // we use FILE_PREFIX for URL prefix,
74 //        TEST_PLATFORM for test platform initial,
75 //        TEST_PLATFORM_ROOT for root dir in comrresponding platform,
76 //        TEST_PLATFORM_TEMP for temp dir in comrresponding platform,
77 //        PATH_LIST_DELIMITER for seperator of path list in comrresponding platform,
78 //        PATH_SEPERATOR for seperator in URL or system path in comrresponding platform,
79 //        PATH_MAX/MAX_PATH for max path length in comrresponding platform,
80 //------------------------------------------------------------------------
81 
82 //------------------------------------------------------------------------
83 // OS independent const definition
84 //------------------------------------------------------------------------
85 #	define FILE_PREFIX          "file:///"
86 #	define TEST_FILE_SIZE       1024
87 
88 //------------------------------------------------------------------------
89 // OS dependent declaration and includes
90 //------------------------------------------------------------------------
91 #if ( defined UNX ) || ( defined OS2 )  //Unix
92 #	include <unistd.h>
93 #	include <limits.h>
94 #	include <math.h>
95 #	include <errno.h>
96 #	include <fcntl.h>
97 #	include <sys/stat.h>
98 #   ifndef __FreeBSD__
99 #       include <sys/statfs.h>
100 #   endif
101 #	include <sys/statvfs.h>
102 #	include <sys/types.h>
103 #	define TEST_PLATFORM        ""
104 #	define TEST_PLATFORM_ROOT   "/"
105 #	define TEST_PLATFORM_TEMP   "tmp"
106 #	define PATH_LIST_DELIMITER  ":"
107 #	define PATH_SEPERATOR       "/"
108 #endif
109 #if (defined WNT )                      // Windows
110 #   include <tchar.h>
111 #	include <io.h>
112 #	include <stdio.h>
113 #	include <stdlib.h>
114 #	define PATH_MAX             MAX_PATH
115 #	define TEST_PLATFORM        "c:/"
116 #	define TEST_PLATFORM_ROOT   "c:/"
117 #	define TEST_PLATFORM_TEMP   "temp"
118 #	define PATH_LIST_DELIMITER  ";"
119 #	define PATH_SEPERATOR		"/"
120 #endif
121 
122 
123 //------------------------------------------------------------------------
124 // macro definition for the ASCII array/OUString declarations,
125 // we use p### for the ASCII array,
126 //        a### for the OUString,
127 //        n###Len for its length
128 //------------------------------------------------------------------------
129 
130 #define OSLTEST_DECLARE( str_name, str_value ) \
131 	::rtl::OUString a##str_name = rtl::OUString::createFromAscii( ( str_value ) )
132 
133 #define OSLTEST_DECLARE_UTF8(str_name, str_value ) \
134 	::rtl::OUString a##str_name = ::rtl::Uri::decode( ::rtl::OUString::createFromAscii( ( str_value ) ), rtl_UriDecodeToIuri, RTL_TEXTENCODING_UTF8)
135 
136 //------------------------------------------------------------------------
137 // OS independent file definition
138 //------------------------------------------------------------------------
139 OSLTEST_DECLARE( NullURL,  "" );
140 OSLTEST_DECLARE( SlashURL, PATH_SEPERATOR );
141 OSLTEST_DECLARE( PreURL, FILE_PREFIX );
142 OSLTEST_DECLARE( RootURL,  FILE_PREFIX TEST_PLATFORM );
143 
144 OSLTEST_DECLARE( TempDirectoryURL,  FILE_PREFIX TEST_PLATFORM TEST_PLATFORM_TEMP );
145 OSLTEST_DECLARE( TempDirectorySys,  TEST_PLATFORM_ROOT TEST_PLATFORM_TEMP );
146 OSLTEST_DECLARE( UserDirectoryURL,  FILE_PREFIX TEST_PLATFORM TEST_PLATFORM_TEMP "" );
147 OSLTEST_DECLARE( UserDirectorySys,  TEST_PLATFORM_ROOT TEST_PLATFORM_TEMP "" );
148 
149 //------------------------------------------------------------------------
150 // common used URL:temp, canonical, root, relative, link,etc
151 //------------------------------------------------------------------------
152 OSLTEST_DECLARE( CanURL1,  FILE_PREFIX TEST_PLATFORM TEST_PLATFORM_TEMP "/canonical.name" );
153 OSLTEST_DECLARE( CanURL2,  "ca@#;+.,$///78no\0ni..name" );
154 OSLTEST_DECLARE( CanURL3,  "ca@#;+.,$//tmp/678nonical//name" );
155 OSLTEST_DECLARE( CanURL4,  "canonical.name" );
156 OSLTEST_DECLARE( TmpName1, "tmpdir" );
157 OSLTEST_DECLARE( TmpName2, "tmpname" );
158 OSLTEST_DECLARE( TmpName3, FILE_PREFIX TEST_PLATFORM TEST_PLATFORM_TEMP "/tmpdir" );
159 OSLTEST_DECLARE( TmpName4, FILE_PREFIX TEST_PLATFORM TEST_PLATFORM_TEMP "/tmpdir/tmpname" );
160 OSLTEST_DECLARE( TmpName5, FILE_PREFIX TEST_PLATFORM TEST_PLATFORM_TEMP "/tmpdir/../tmpdir/./tmpname" );
161 OSLTEST_DECLARE( TmpName6, FILE_PREFIX TEST_PLATFORM TEST_PLATFORM_TEMP "/tmpname" );
162 OSLTEST_DECLARE( TmpName7, FILE_PREFIX TEST_PLATFORM "tmpname" );
163 OSLTEST_DECLARE( TmpName8, FILE_PREFIX TEST_PLATFORM TEST_PLATFORM_TEMP "/tmpname/tmpdir" );
164 OSLTEST_DECLARE( TmpName9, FILE_PREFIX TEST_PLATFORM TEST_PLATFORM_TEMP "/tmpdir/../tmpdir/./" );
165 OSLTEST_DECLARE_UTF8( TmpName10, FILE_PREFIX TEST_PLATFORM TEST_PLATFORM_TEMP "/%E6%9C%AA%E5%91%BD%E5%90%8Dzhgb18030" );
166 
167 OSLTEST_DECLARE( RelURL1,  "relative/file1" );
168 OSLTEST_DECLARE( RelURL2,  "relative/./file2" );
169 OSLTEST_DECLARE( RelURL3,  "relative/../file3" );
170 OSLTEST_DECLARE( RelURL4,  "././relative/../file4" );
171 OSLTEST_DECLARE( RelURL5,  TEST_PLATFORM_TEMP "/./../" TEST_PLATFORM_TEMP );
172 OSLTEST_DECLARE( LnkURL1,  FILE_PREFIX TEST_PLATFORM TEST_PLATFORM_TEMP "/link.file" );
173 OSLTEST_DECLARE( HidURL1,  ".hiddenfile" );
174 
175 //------------------------------------------------------------------------
176 // common used System Path:temp, root,etc
177 //------------------------------------------------------------------------
178 OSLTEST_DECLARE( RootSys,  TEST_PLATFORM_ROOT );
179 OSLTEST_DECLARE( SysPath1, TEST_PLATFORM_ROOT TEST_PLATFORM_TEMP "/system.path" );
180 OSLTEST_DECLARE( SysPath2, TEST_PLATFORM_ROOT TEST_PLATFORM_TEMP "/system/path" );
181 OSLTEST_DECLARE( SysPath3, TEST_PLATFORM_ROOT TEST_PLATFORM_TEMP "/tmpdir" );
182 OSLTEST_DECLARE( SysPath4, TEST_PLATFORM_ROOT TEST_PLATFORM_TEMP "/tmpname" );
183 OSLTEST_DECLARE_UTF8( SysPath5, TEST_PLATFORM_ROOT TEST_PLATFORM_TEMP "/%E6%9C%AA%E5%91%BD%E5%90%8Dzhgb18030" );
184 OSLTEST_DECLARE( FifoSys,  TEST_PLATFORM_ROOT TEST_PLATFORM_TEMP "/tmpdir/fifo" );
185 
186 //------------------------------------------------------------------------
187 // FileType URL, we pick some canonical file in corresponding system for test:
188 // socket, link, etc.
189 // Note that this may be changed in the different platform, so be careful to use.
190 //------------------------------------------------------------------------
191 #if ( defined UNX ) || ( defined OS2 )                                 //          Unix
192 OSLTEST_DECLARE( TypeURL1,  FILE_PREFIX "dev/ccv");                    //socket    Solaris/Linux
193 OSLTEST_DECLARE( TypeURL2,  FILE_PREFIX "devices/pseudo/tcp@0:tcp");   //special   Solaris/Linux
194 OSLTEST_DECLARE( TypeURL3,  FILE_PREFIX "lib" );                       //link      Solaris
195 #else                                                                  //          Windows
196 OSLTEST_DECLARE( TypeURL1,  FILE_PREFIX "" );
197 OSLTEST_DECLARE( TypeURL2,  FILE_PREFIX "" );
198 OSLTEST_DECLARE( TypeURL3,  FILE_PREFIX "" );
199 #endif
200 
201 //------------------------------------------------------------------------
202 // Volume device URL, we pick some canonical volume device for test:
203 // UNIX file system, Floppy Disk, Proc file system, Temp file system, Compact Disk.
204 //------------------------------------------------------------------------
205 #if ( defined UNX ) || ( defined OS2 )					//			Unix
206 OSLTEST_DECLARE( VolURL1,  FILE_PREFIX  "");			//ufs		Solaris/Linux
207 #ifdef SOLARIS
208 OSLTEST_DECLARE( VolURL2,  FILE_PREFIX  "dev/fd" );		//fd		Solaris
209 #else
210 OSLTEST_DECLARE( VolURL2,  FILE_PREFIX  "dev/floppy/0u1440" );	//fd0		Linux
211 #endif
212 OSLTEST_DECLARE( VolURL3,  FILE_PREFIX  "proc" );		//proc		Solaris/Linux
213 OSLTEST_DECLARE( VolURL4,  FILE_PREFIX  "staroffice" );	//nfs		Solaris/Linux
214 OSLTEST_DECLARE( VolURL5,  FILE_PREFIX  "tmp" );		//tmpfs		Solaris
215 OSLTEST_DECLARE( VolURL6,  FILE_PREFIX  "cdrom" );		//cd		Solaris
216 #else													//			Windows
217 OSLTEST_DECLARE( VolURL1,  FILE_PREFIX  "c:/" );
218 OSLTEST_DECLARE( VolURL2,  FILE_PREFIX  "a:/" );
219 OSLTEST_DECLARE( VolURL3,  FILE_PREFIX  "" );
220 OSLTEST_DECLARE( VolURL4,  FILE_PREFIX  "" );
221 OSLTEST_DECLARE( VolURL5,  FILE_PREFIX  "c:/temp" );
222 OSLTEST_DECLARE( VolURL6,  FILE_PREFIX  "e:/" );
223 #endif
224 
225 
226 //------------------------------------------------------------------------
227 //------------------------------------------------------------------------
228 
229 #ifdef __cplusplus
230 }
231 #endif
232 
233 //------------------------------------------------------------------------
234 //------------------------------------------------------------------------
235 
236 
237 #endif /* _OSL_FILE_CONST_H_ */
238