xref: /aoo42x/main/sal/osl/os2/file_url.h (revision cdf0e10c)
1 /*************************************************************************
2  *
3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4  *
5  * Copyright 2000, 2010 Oracle and/or its affiliates.
6  *
7  * OpenOffice.org - a multi-platform office productivity suite
8  *
9  * This file is part of OpenOffice.org.
10  *
11  * OpenOffice.org is free software: you can redistribute it and/or modify
12  * it under the terms of the GNU Lesser General Public License version 3
13  * only, as published by the Free Software Foundation.
14  *
15  * OpenOffice.org is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  * GNU Lesser General Public License version 3 for more details
19  * (a copy is included in the LICENSE file that accompanied this code).
20  *
21  * You should have received a copy of the GNU Lesser General Public License
22  * version 3 along with OpenOffice.org.  If not, see
23  * <http://www.openoffice.org/license.html>
24  * for a copy of the LGPLv3 License.
25  *
26  ************************************************************************/
27 
28  /***************************************************
29   * Internal header file, declares all functions
30   * that are not part of the offical API and are
31   * not defined in the osl header files
32   **************************************************/
33 
34  #ifndef _FILE_URL_H_
35  #define _FILE_URL_H_
36 
37  #ifndef _FILE_H_
38  #include <osl/file.h>
39  #endif
40 
41 
42 /***************************************************
43  * constants
44  **************************************************/
45 
46 #define _tcslen(a)		wcslen((const wchar_t *) a)
47 #define _tcsspn(a,b)	wcsspn((const wchar_t *) a, (const wchar_t *) b)
48 #define _istalpha(a)	iswalpha((wint_t) a)
49 
50 const sal_Unicode UNICHAR_SLASH = ((sal_Unicode)'/');
51 const sal_Unicode UNICHAR_COLON = ((sal_Unicode)':');
52 const sal_Unicode UNICHAR_DOT   = ((sal_Unicode)'.');
53 
54 #define ELEMENTS_OF_ARRAY(arr) (sizeof(arr)/(sizeof((arr)[0])))
55 
56 #if OSL_DEBUG_LEVEL > 0
57 #define OSL_ENSURE_FILE( cond, msg, file ) ( (cond) ?  (void)0 : _osl_warnFile( msg, file ) )
58 #else
59 #define OSL_ENSURE_FILE( cond, msg, file ) ((void)0)
60 #endif
61 
62 typedef sal_Unicode            				TCHAR;
63 typedef sal_Unicode           				*LPTSTR;
64 typedef const sal_Unicode     				*LPCTSTR;
65 typedef wchar_t           				*LPWSTR;
66 typedef const wchar_t     				*LPCWSTR;
67 typedef sal_Unicode							DWORD;
68 #define WINAPI
69 
70 #define	CHARSET_SEPARATOR					L"\\/"
71 #define WSTR_SYSTEM_ROOT_PATH				L"\\\\.\\"
72 
73 
74 /******************************************************************************
75  *
76  *                  Data Type Definition
77  *
78  ******************************************************************************/
79 
80 #define PATHTYPE_ERROR						0
81 #define PATHTYPE_RELATIVE					1
82 #define PATHTYPE_ABSOLUTE_UNC				2
83 #define PATHTYPE_ABSOLUTE_LOCAL				3
84 #define PATHTYPE_MASK_TYPE					0xFF
85 #define PATHTYPE_IS_VOLUME					0x0100
86 #define PATHTYPE_IS_SERVER					0x0200
87 
88 #define VALIDATEPATH_NORMAL					0x0000
89 #define VALIDATEPATH_ALLOW_WILDCARDS		0x0001
90 #define VALIDATEPATH_ALLOW_ELLIPSE			0x0002
91 #define VALIDATEPATH_ALLOW_RELATIVE			0x0004
92 #define VALIDATEPATH_ALLOW_UNC				0x0008
93 
94 typedef struct {
95 	UINT			uType;
96     rtl_uString* 	ustrDrive;
97     rtl_uString* 	ustrFilePath;	/* holds native directory path */
98 	int				d_attr;			/* OS/2 file attributes */
99 	int				nRefCount;
100 }DirectoryItem_Impl;
101 
102 #define	DIRECTORYTYPE_LOCALROOT	    0
103 #define	DIRECTORYTYPE_NETROOT		1
104 #define	DIRECTORYTYPE_NETRESORCE	2
105 #define	DIRECTORYTYPE_FILESYSTEM	3
106 
107 #define DIRECTORYITEM_DRIVE		0
108 #define DIRECTORYITEM_FILE		1
109 #define DIRECTORYITEM_SERVER	2
110 
111 typedef struct
112 {
113 	UINT		 uType;
114     rtl_uString* ustrPath;           /* holds native directory path */
115     DIR*         pDirStruct;
116 	ULONG		 ulDriveMap;
117 	ULONG		 ulNextDrive;
118 	ULONG		 ulNextDriveMask;
119 } DirectoryImpl;
120 
121 /* Different types of paths */
122 typedef enum _PATHTYPE
123 {
124 	PATHTYPE_SYNTAXERROR = 0,
125 	PATHTYPE_NETROOT,
126 	PATHTYPE_NETSERVER,
127 	PATHTYPE_VOLUME,
128 	PATHTYPE_FILE
129 } PATHTYPE;
130 
131 DWORD WINAPI IsValidFilePath(LPCTSTR, LPCTSTR*, DWORD);
132 
133 typedef struct
134 {
135     rtl_uString* ustrFilePath;      /* holds native file path */
136     int fd;
137     sal_Bool bLocked;
138 } oslFileHandleImpl;
139 
140 
141 typedef struct _oslVolumeDeviceHandleImpl
142 {
143     sal_Char pszMountPoint[PATH_MAX];
144     sal_Char pszFilePath[PATH_MAX];
145     sal_Char pszDevice[PATH_MAX];
146     sal_Char ident[4];
147     sal_uInt32   RefCount;
148 } oslVolumeDeviceHandleImpl;
149 
150 /* OS error to errno values mapping table */
151 struct errentry {
152 	unsigned long oscode;	/* OS return value */
153 	int errnocode;			/* System V error code */
154 };
155 
156 #ifdef __cplusplus
157 extern "C"
158 {
159 #endif
160 
161 /**************************************************
162 * _osl_getSystemPathFromFileURL
163 *************************************************/
164 
165 #define FURL_ALLOW_RELATIVE sal_True
166 #define FURL_DENY_RELATIVE  sal_False
167 
168 oslFileError osl_getSystemPathFromFileURL_Ex(rtl_uString *ustrFileURL, rtl_uString **pustrSystemPath, sal_Bool bAllowRelative);
169 
170 /**************************************************
171 * FileURLToPath
172 *************************************************/
173 
174 oslFileError FileURLToPath(char * buffer, size_t bufLen, rtl_uString* ustrFileURL);
175 
176 
177 #ifdef __cplusplus
178 }
179 #endif
180 
181 
182 #endif /* #define _FILE_URL_H_ */
183 
184