xref: /aoo41x/main/sal/osl/os2/file_url.h (revision 9eab2a37)
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   * Internal header file, declares all functions
26   * that are not part of the offical API and are
27   * not defined in the osl header files
28   **************************************************/
29 
30  #ifndef _FILE_URL_H_
31  #define _FILE_URL_H_
32 
33  #ifndef _FILE_H_
34  #include <osl/file.h>
35  #endif
36 
37 
38 /***************************************************
39  * constants
40  **************************************************/
41 
42 #define _tcslen(a)		wcslen((const wchar_t *) a)
43 #define _tcsspn(a,b)	wcsspn((const wchar_t *) a, (const wchar_t *) b)
44 #define _istalpha(a)	iswalpha((wint_t) a)
45 
46 const sal_Unicode UNICHAR_SLASH = ((sal_Unicode)'/');
47 const sal_Unicode UNICHAR_COLON = ((sal_Unicode)':');
48 const sal_Unicode UNICHAR_DOT   = ((sal_Unicode)'.');
49 
50 #define ELEMENTS_OF_ARRAY(arr) (sizeof(arr)/(sizeof((arr)[0])))
51 
52 #if OSL_DEBUG_LEVEL > 0
53 #define OSL_ENSURE_FILE( cond, msg, file ) ( (cond) ?  (void)0 : _osl_warnFile( msg, file ) )
54 #else
55 #define OSL_ENSURE_FILE( cond, msg, file ) ((void)0)
56 #endif
57 
58 typedef sal_Unicode            				TCHAR;
59 typedef sal_Unicode           				*LPTSTR;
60 typedef const sal_Unicode     				*LPCTSTR;
61 typedef wchar_t           				*LPWSTR;
62 typedef const wchar_t     				*LPCWSTR;
63 typedef sal_Unicode							DWORD;
64 #define WINAPI
65 
66 #define	CHARSET_SEPARATOR					L"\\/"
67 #define WSTR_SYSTEM_ROOT_PATH				L"\\\\.\\"
68 
69 
70 /******************************************************************************
71  *
72  *                  Data Type Definition
73  *
74  ******************************************************************************/
75 
76 #define PATHTYPE_ERROR						0
77 #define PATHTYPE_RELATIVE					1
78 #define PATHTYPE_ABSOLUTE_UNC				2
79 #define PATHTYPE_ABSOLUTE_LOCAL				3
80 #define PATHTYPE_MASK_TYPE					0xFF
81 #define PATHTYPE_IS_VOLUME					0x0100
82 #define PATHTYPE_IS_SERVER					0x0200
83 
84 #define VALIDATEPATH_NORMAL					0x0000
85 #define VALIDATEPATH_ALLOW_WILDCARDS		0x0001
86 #define VALIDATEPATH_ALLOW_ELLIPSE			0x0002
87 #define VALIDATEPATH_ALLOW_RELATIVE			0x0004
88 #define VALIDATEPATH_ALLOW_UNC				0x0008
89 
90 typedef struct {
91 	UINT			uType;
92     rtl_uString* 	ustrDrive;
93     rtl_uString* 	ustrFilePath;	/* holds native directory path */
94 	int				d_attr;			/* OS/2 file attributes */
95 	int				nRefCount;
96 }DirectoryItem_Impl;
97 
98 #define	DIRECTORYTYPE_LOCALROOT	    0
99 #define	DIRECTORYTYPE_NETROOT		1
100 #define	DIRECTORYTYPE_NETRESORCE	2
101 #define	DIRECTORYTYPE_FILESYSTEM	3
102 
103 #define DIRECTORYITEM_DRIVE		0
104 #define DIRECTORYITEM_FILE		1
105 #define DIRECTORYITEM_SERVER	2
106 
107 typedef struct
108 {
109 	UINT		 uType;
110     rtl_uString* ustrPath;           /* holds native directory path */
111     DIR*         pDirStruct;
112 	ULONG		 ulDriveMap;
113 	ULONG		 ulNextDrive;
114 	ULONG		 ulNextDriveMask;
115 } DirectoryImpl;
116 
117 /* Different types of paths */
118 typedef enum _PATHTYPE
119 {
120 	PATHTYPE_SYNTAXERROR = 0,
121 	PATHTYPE_NETROOT,
122 	PATHTYPE_NETSERVER,
123 	PATHTYPE_VOLUME,
124 	PATHTYPE_FILE
125 } PATHTYPE;
126 
127 DWORD WINAPI IsValidFilePath(LPCTSTR, LPCTSTR*, DWORD);
128 
129 
130 typedef struct _oslVolumeDeviceHandleImpl
131 {
132     sal_Char pszMountPoint[PATH_MAX];
133     sal_Char pszFilePath[PATH_MAX];
134     sal_Char pszDevice[PATH_MAX];
135     sal_Char ident[4];
136     sal_uInt32   RefCount;
137 } oslVolumeDeviceHandleImpl;
138 
139 /* OS error to errno values mapping table */
140 struct errentry {
141 	unsigned long oscode;	/* OS return value */
142 	int errnocode;			/* System V error code */
143 };
144 
145 #ifdef __cplusplus
146 extern "C"
147 {
148 #endif
149 
150 /**************************************************
151 * _osl_getSystemPathFromFileURL
152 *************************************************/
153 
154 #define FURL_ALLOW_RELATIVE sal_True
155 #define FURL_DENY_RELATIVE  sal_False
156 
157 oslFileError osl_getSystemPathFromFileURL_Ex(rtl_uString *ustrFileURL, rtl_uString **pustrSystemPath, sal_Bool bAllowRelative);
158 
159 /**************************************************
160 * FileURLToPath
161 *************************************************/
162 
163 oslFileError FileURLToPath(char * buffer, size_t bufLen, rtl_uString* ustrFileURL);
164 
165 
166 #ifdef __cplusplus
167 }
168 #endif
169 
170 
171 #endif /* #define _FILE_URL_H_ */
172 
173