xref: /aoo42x/main/sal/osl/os2/file_url.h (revision 9eab2a37)
1*9eab2a37SAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
3*9eab2a37SAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
4*9eab2a37SAndrew Rist  * or more contributor license agreements.  See the NOTICE file
5*9eab2a37SAndrew Rist  * distributed with this work for additional information
6*9eab2a37SAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
7*9eab2a37SAndrew Rist  * to you under the Apache License, Version 2.0 (the
8*9eab2a37SAndrew Rist  * "License"); you may not use this file except in compliance
9*9eab2a37SAndrew Rist  * with the License.  You may obtain a copy of the License at
10*9eab2a37SAndrew Rist  *
11*9eab2a37SAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12*9eab2a37SAndrew Rist  *
13*9eab2a37SAndrew Rist  * Unless required by applicable law or agreed to in writing,
14*9eab2a37SAndrew Rist  * software distributed under the License is distributed on an
15*9eab2a37SAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*9eab2a37SAndrew Rist  * KIND, either express or implied.  See the License for the
17*9eab2a37SAndrew Rist  * specific language governing permissions and limitations
18*9eab2a37SAndrew Rist  * under the License.
19*9eab2a37SAndrew Rist  *
20*9eab2a37SAndrew Rist  *************************************************************/
21*9eab2a37SAndrew Rist 
22*9eab2a37SAndrew Rist 
23cdf0e10cSrcweir 
24cdf0e10cSrcweir  /***************************************************
25cdf0e10cSrcweir   * Internal header file, declares all functions
26cdf0e10cSrcweir   * that are not part of the offical API and are
27cdf0e10cSrcweir   * not defined in the osl header files
28cdf0e10cSrcweir   **************************************************/
29cdf0e10cSrcweir 
30cdf0e10cSrcweir  #ifndef _FILE_URL_H_
31cdf0e10cSrcweir  #define _FILE_URL_H_
32cdf0e10cSrcweir 
33cdf0e10cSrcweir  #ifndef _FILE_H_
34cdf0e10cSrcweir  #include <osl/file.h>
35cdf0e10cSrcweir  #endif
36cdf0e10cSrcweir 
37cdf0e10cSrcweir 
38cdf0e10cSrcweir /***************************************************
39cdf0e10cSrcweir  * constants
40cdf0e10cSrcweir  **************************************************/
41cdf0e10cSrcweir 
42cdf0e10cSrcweir #define _tcslen(a)		wcslen((const wchar_t *) a)
43cdf0e10cSrcweir #define _tcsspn(a,b)	wcsspn((const wchar_t *) a, (const wchar_t *) b)
44cdf0e10cSrcweir #define _istalpha(a)	iswalpha((wint_t) a)
45cdf0e10cSrcweir 
46cdf0e10cSrcweir const sal_Unicode UNICHAR_SLASH = ((sal_Unicode)'/');
47cdf0e10cSrcweir const sal_Unicode UNICHAR_COLON = ((sal_Unicode)':');
48cdf0e10cSrcweir const sal_Unicode UNICHAR_DOT   = ((sal_Unicode)'.');
49cdf0e10cSrcweir 
50cdf0e10cSrcweir #define ELEMENTS_OF_ARRAY(arr) (sizeof(arr)/(sizeof((arr)[0])))
51cdf0e10cSrcweir 
52cdf0e10cSrcweir #if OSL_DEBUG_LEVEL > 0
53cdf0e10cSrcweir #define OSL_ENSURE_FILE( cond, msg, file ) ( (cond) ?  (void)0 : _osl_warnFile( msg, file ) )
54cdf0e10cSrcweir #else
55cdf0e10cSrcweir #define OSL_ENSURE_FILE( cond, msg, file ) ((void)0)
56cdf0e10cSrcweir #endif
57cdf0e10cSrcweir 
58cdf0e10cSrcweir typedef sal_Unicode            				TCHAR;
59cdf0e10cSrcweir typedef sal_Unicode           				*LPTSTR;
60cdf0e10cSrcweir typedef const sal_Unicode     				*LPCTSTR;
61cdf0e10cSrcweir typedef wchar_t           				*LPWSTR;
62cdf0e10cSrcweir typedef const wchar_t     				*LPCWSTR;
63cdf0e10cSrcweir typedef sal_Unicode							DWORD;
64cdf0e10cSrcweir #define WINAPI
65cdf0e10cSrcweir 
66cdf0e10cSrcweir #define	CHARSET_SEPARATOR					L"\\/"
67cdf0e10cSrcweir #define WSTR_SYSTEM_ROOT_PATH				L"\\\\.\\"
68cdf0e10cSrcweir 
69cdf0e10cSrcweir 
70cdf0e10cSrcweir /******************************************************************************
71cdf0e10cSrcweir  *
72cdf0e10cSrcweir  *                  Data Type Definition
73cdf0e10cSrcweir  *
74cdf0e10cSrcweir  ******************************************************************************/
75cdf0e10cSrcweir 
76cdf0e10cSrcweir #define PATHTYPE_ERROR						0
77cdf0e10cSrcweir #define PATHTYPE_RELATIVE					1
78cdf0e10cSrcweir #define PATHTYPE_ABSOLUTE_UNC				2
79cdf0e10cSrcweir #define PATHTYPE_ABSOLUTE_LOCAL				3
80cdf0e10cSrcweir #define PATHTYPE_MASK_TYPE					0xFF
81cdf0e10cSrcweir #define PATHTYPE_IS_VOLUME					0x0100
82cdf0e10cSrcweir #define PATHTYPE_IS_SERVER					0x0200
83cdf0e10cSrcweir 
84cdf0e10cSrcweir #define VALIDATEPATH_NORMAL					0x0000
85cdf0e10cSrcweir #define VALIDATEPATH_ALLOW_WILDCARDS		0x0001
86cdf0e10cSrcweir #define VALIDATEPATH_ALLOW_ELLIPSE			0x0002
87cdf0e10cSrcweir #define VALIDATEPATH_ALLOW_RELATIVE			0x0004
88cdf0e10cSrcweir #define VALIDATEPATH_ALLOW_UNC				0x0008
89cdf0e10cSrcweir 
90cdf0e10cSrcweir typedef struct {
91cdf0e10cSrcweir 	UINT			uType;
92cdf0e10cSrcweir     rtl_uString* 	ustrDrive;
93cdf0e10cSrcweir     rtl_uString* 	ustrFilePath;	/* holds native directory path */
94cdf0e10cSrcweir 	int				d_attr;			/* OS/2 file attributes */
95cdf0e10cSrcweir 	int				nRefCount;
96cdf0e10cSrcweir }DirectoryItem_Impl;
97cdf0e10cSrcweir 
98cdf0e10cSrcweir #define	DIRECTORYTYPE_LOCALROOT	    0
99cdf0e10cSrcweir #define	DIRECTORYTYPE_NETROOT		1
100cdf0e10cSrcweir #define	DIRECTORYTYPE_NETRESORCE	2
101cdf0e10cSrcweir #define	DIRECTORYTYPE_FILESYSTEM	3
102cdf0e10cSrcweir 
103cdf0e10cSrcweir #define DIRECTORYITEM_DRIVE		0
104cdf0e10cSrcweir #define DIRECTORYITEM_FILE		1
105cdf0e10cSrcweir #define DIRECTORYITEM_SERVER	2
106cdf0e10cSrcweir 
107cdf0e10cSrcweir typedef struct
108cdf0e10cSrcweir {
109cdf0e10cSrcweir 	UINT		 uType;
110cdf0e10cSrcweir     rtl_uString* ustrPath;           /* holds native directory path */
111cdf0e10cSrcweir     DIR*         pDirStruct;
112cdf0e10cSrcweir 	ULONG		 ulDriveMap;
113cdf0e10cSrcweir 	ULONG		 ulNextDrive;
114cdf0e10cSrcweir 	ULONG		 ulNextDriveMask;
115cdf0e10cSrcweir } DirectoryImpl;
116cdf0e10cSrcweir 
117cdf0e10cSrcweir /* Different types of paths */
118cdf0e10cSrcweir typedef enum _PATHTYPE
119cdf0e10cSrcweir {
120cdf0e10cSrcweir 	PATHTYPE_SYNTAXERROR = 0,
121cdf0e10cSrcweir 	PATHTYPE_NETROOT,
122cdf0e10cSrcweir 	PATHTYPE_NETSERVER,
123cdf0e10cSrcweir 	PATHTYPE_VOLUME,
124cdf0e10cSrcweir 	PATHTYPE_FILE
125cdf0e10cSrcweir } PATHTYPE;
126cdf0e10cSrcweir 
127cdf0e10cSrcweir DWORD WINAPI IsValidFilePath(LPCTSTR, LPCTSTR*, DWORD);
128cdf0e10cSrcweir 
129cdf0e10cSrcweir 
130cdf0e10cSrcweir typedef struct _oslVolumeDeviceHandleImpl
131cdf0e10cSrcweir {
132cdf0e10cSrcweir     sal_Char pszMountPoint[PATH_MAX];
133cdf0e10cSrcweir     sal_Char pszFilePath[PATH_MAX];
134cdf0e10cSrcweir     sal_Char pszDevice[PATH_MAX];
135cdf0e10cSrcweir     sal_Char ident[4];
136cdf0e10cSrcweir     sal_uInt32   RefCount;
137cdf0e10cSrcweir } oslVolumeDeviceHandleImpl;
138cdf0e10cSrcweir 
139cdf0e10cSrcweir /* OS error to errno values mapping table */
140cdf0e10cSrcweir struct errentry {
141cdf0e10cSrcweir 	unsigned long oscode;	/* OS return value */
142cdf0e10cSrcweir 	int errnocode;			/* System V error code */
143cdf0e10cSrcweir };
144cdf0e10cSrcweir 
145cdf0e10cSrcweir #ifdef __cplusplus
146cdf0e10cSrcweir extern "C"
147cdf0e10cSrcweir {
148cdf0e10cSrcweir #endif
149cdf0e10cSrcweir 
150cdf0e10cSrcweir /**************************************************
151cdf0e10cSrcweir * _osl_getSystemPathFromFileURL
152cdf0e10cSrcweir *************************************************/
153cdf0e10cSrcweir 
154cdf0e10cSrcweir #define FURL_ALLOW_RELATIVE sal_True
155cdf0e10cSrcweir #define FURL_DENY_RELATIVE  sal_False
156cdf0e10cSrcweir 
157cdf0e10cSrcweir oslFileError osl_getSystemPathFromFileURL_Ex(rtl_uString *ustrFileURL, rtl_uString **pustrSystemPath, sal_Bool bAllowRelative);
158cdf0e10cSrcweir 
159cdf0e10cSrcweir /**************************************************
160cdf0e10cSrcweir * FileURLToPath
161cdf0e10cSrcweir *************************************************/
162cdf0e10cSrcweir 
163cdf0e10cSrcweir oslFileError FileURLToPath(char * buffer, size_t bufLen, rtl_uString* ustrFileURL);
164cdf0e10cSrcweir 
165cdf0e10cSrcweir 
166cdf0e10cSrcweir #ifdef __cplusplus
167cdf0e10cSrcweir }
168cdf0e10cSrcweir #endif
169cdf0e10cSrcweir 
170cdf0e10cSrcweir 
171cdf0e10cSrcweir #endif /* #define _FILE_URL_H_ */
172cdf0e10cSrcweir 
173