4 * Copyright 1999 Corel Corporation
8 * This library is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Lesser General Public
10 * License as published by the Free Software Foundation; either
11 * version 2.1 of the License, or (at your option) any later version.
13 * This library is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * Lesser General Public License for more details.
18 * You should have received a copy of the GNU Lesser General Public
19 * License along with this library; if not, write to the Free Software
20 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
23 #ifndef _WINE_INTERNET_H_
24 #define _WINE_INTERNET_H_
26 #ifndef __WINE_CONFIG_H
27 # error You must include config.h to use this header
30 #include "wine/unicode.h"
31 #include "wine/list.h"
37 #ifdef HAVE_NETINET_IN_H
38 # include <sys/types.h>
39 # include <netinet/in.h>
41 #ifdef HAVE_SYS_SOCKET_H
42 # include <sys/socket.h>
45 #if !defined(__MINGW32__) && !defined(_MSC_VER)
46 #define closesocket close
47 #define ioctlsocket ioctl
48 #endif /* __MINGW32__ */
50 /* used for netconnection.c stuff */
59 } WININET_NETCONNECTION
;
61 static inline LPWSTR
WININET_strdupW( LPCWSTR str
)
63 LPWSTR ret
= HeapAlloc( GetProcessHeap(), 0, (strlenW(str
) + 1)*sizeof(WCHAR
) );
64 if (ret
) strcpyW( ret
, str
);
68 static inline LPWSTR
WININET_strdup_AtoW( LPCSTR str
)
70 int len
= MultiByteToWideChar( CP_ACP
, 0, str
, -1, NULL
, 0);
71 LPWSTR ret
= HeapAlloc( GetProcessHeap(), 0, len
* sizeof(WCHAR
) );
73 MultiByteToWideChar( CP_ACP
, 0, str
, -1, ret
, len
);
77 static inline LPSTR
WININET_strdup_WtoA( LPCWSTR str
)
79 int len
= WideCharToMultiByte( CP_ACP
, 0, str
, -1, NULL
, 0, NULL
, NULL
);
80 LPSTR ret
= HeapAlloc( GetProcessHeap(), 0, len
);
82 WideCharToMultiByte( CP_ACP
, 0, str
, -1, ret
, len
, NULL
, NULL
);
86 static inline void WININET_find_data_WtoA(LPWIN32_FIND_DATAW dataW
, LPWIN32_FIND_DATAA dataA
)
88 dataA
->dwFileAttributes
= dataW
->dwFileAttributes
;
89 dataA
->ftCreationTime
= dataW
->ftCreationTime
;
90 dataA
->ftLastAccessTime
= dataW
->ftLastAccessTime
;
91 dataA
->ftLastWriteTime
= dataW
->ftLastWriteTime
;
92 dataA
->nFileSizeHigh
= dataW
->nFileSizeHigh
;
93 dataA
->nFileSizeLow
= dataW
->nFileSizeLow
;
94 dataA
->dwReserved0
= dataW
->dwReserved0
;
95 dataA
->dwReserved1
= dataW
->dwReserved1
;
96 WideCharToMultiByte(CP_ACP
, 0, dataW
->cFileName
, -1,
97 dataA
->cFileName
, sizeof(dataA
->cFileName
),
99 WideCharToMultiByte(CP_ACP
, 0, dataW
->cAlternateFileName
, -1,
100 dataA
->cAlternateFileName
, sizeof(dataA
->cAlternateFileName
),
106 WH_HINIT
= INTERNET_HANDLE_TYPE_INTERNET
,
107 WH_HFTPSESSION
= INTERNET_HANDLE_TYPE_CONNECT_FTP
,
108 WH_HGOPHERSESSION
= INTERNET_HANDLE_TYPE_CONNECT_GOPHER
,
109 WH_HHTTPSESSION
= INTERNET_HANDLE_TYPE_CONNECT_HTTP
,
110 WH_HFILE
= INTERNET_HANDLE_TYPE_FTP_FILE
,
111 WH_HFTPFINDNEXT
= INTERNET_HANDLE_TYPE_FTP_FIND
,
112 WH_HHTTPREQ
= INTERNET_HANDLE_TYPE_HTTP_REQUEST
,
115 #define INET_OPENURL 0x0001
116 #define INET_CALLBACKW 0x0002
118 typedef struct _WININETHANDLEHEADER WININETHANDLEHEADER
, *LPWININETHANDLEHEADER
;
121 void (*Destroy
)(WININETHANDLEHEADER
*);
122 void (*CloseConnection
)(WININETHANDLEHEADER
*);
123 DWORD (*QueryOption
)(WININETHANDLEHEADER
*,DWORD
,void*,DWORD
*,BOOL
);
124 DWORD (*SetOption
)(WININETHANDLEHEADER
*,DWORD
,void*,DWORD
);
125 DWORD (*ReadFile
)(WININETHANDLEHEADER
*,void*,DWORD
,DWORD
*);
126 DWORD (*ReadFileExA
)(WININETHANDLEHEADER
*,INTERNET_BUFFERSA
*,DWORD
,DWORD_PTR
);
127 DWORD (*ReadFileExW
)(WININETHANDLEHEADER
*,INTERNET_BUFFERSW
*,DWORD
,DWORD_PTR
);
128 BOOL (*WriteFile
)(WININETHANDLEHEADER
*,const void*,DWORD
,DWORD
*);
129 DWORD (*QueryDataAvailable
)(WININETHANDLEHEADER
*,DWORD
*,DWORD
,DWORD_PTR
);
130 DWORD (*FindNextFileW
)(WININETHANDLEHEADER
*,void*);
133 struct _WININETHANDLEHEADER
136 const HANDLEHEADERVtbl
*vtbl
;
141 DWORD dwInternalFlags
;
143 INTERNET_STATUS_CALLBACK lpfnStatusCB
;
145 struct list children
;
151 WININETHANDLEHEADER hdr
;
154 LPWSTR lpszProxyBypass
;
155 LPWSTR lpszProxyUsername
;
156 LPWSTR lpszProxyPassword
;
158 } WININETAPPINFOW
, *LPWININETAPPINFOW
;
163 WININETHANDLEHEADER hdr
;
164 WININETAPPINFOW
*lpAppInfo
;
165 LPWSTR lpszHostName
; /* the final destination of the request */
166 LPWSTR lpszServerName
; /* the name of the server we directly connect to */
169 INTERNET_PORT nHostPort
; /* the final destination port of the request */
170 INTERNET_PORT nServerPort
; /* the port of the server we directly connect to */
171 struct sockaddr_in socketAddress
;
172 } WININETHTTPSESSIONW
, *LPWININETHTTPSESSIONW
;
174 #define HDR_ISREQUEST 0x0001
175 #define HDR_COMMADELIMITED 0x0002
176 #define HDR_SEMIDELIMITED 0x0004
184 } HTTPHEADERW
, *LPHTTPHEADERW
;
191 WININETHANDLEHEADER hdr
;
192 WININETHTTPSESSIONW
*lpHttpSession
;
195 LPWSTR lpszRawHeaders
;
196 WININET_NETCONNECTION netConnection
;
198 LPWSTR lpszStatusText
;
199 DWORD dwContentLength
; /* total number of bytes to be read */
200 DWORD dwContentRead
; /* bytes of the content read so far */
201 HTTPHEADERW
*pCustHeaders
;
204 LPWSTR lpszCacheFile
;
205 struct HttpAuthInfo
*pAuthInfo
;
206 struct HttpAuthInfo
*pProxyAuthInfo
;
207 } WININETHTTPREQW
, *LPWININETHTTPREQW
;
211 struct WORKREQ_FTPPUTFILEW
213 LPWSTR lpszLocalFile
;
214 LPWSTR lpszNewRemoteFile
;
219 struct WORKREQ_FTPSETCURRENTDIRECTORYW
221 LPWSTR lpszDirectory
;
224 struct WORKREQ_FTPCREATEDIRECTORYW
226 LPWSTR lpszDirectory
;
229 struct WORKREQ_FTPFINDFIRSTFILEW
231 LPWSTR lpszSearchFile
;
232 LPWIN32_FIND_DATAW lpFindFileData
;
237 struct WORKREQ_FTPGETCURRENTDIRECTORYW
239 LPWSTR lpszDirectory
;
240 DWORD
*lpdwDirectory
;
243 struct WORKREQ_FTPOPENFILEW
251 struct WORKREQ_FTPGETFILEW
253 LPWSTR lpszRemoteFile
;
256 DWORD dwLocalFlagsAttribute
;
261 struct WORKREQ_FTPDELETEFILEW
266 struct WORKREQ_FTPREMOVEDIRECTORYW
268 LPWSTR lpszDirectory
;
271 struct WORKREQ_FTPRENAMEFILEW
277 struct WORKREQ_FTPFINDNEXTW
279 LPWIN32_FIND_DATAW lpFindFileData
;
282 struct WORKREQ_HTTPSENDREQUESTW
285 DWORD dwHeaderLength
;
287 DWORD dwOptionalLength
;
288 DWORD dwContentLength
;
292 struct WORKREQ_SENDCALLBACK
295 DWORD dwInternetStatus
;
296 LPVOID lpvStatusInfo
;
297 DWORD dwStatusInfoLength
;
300 struct WORKREQ_INTERNETOPENURLW
305 DWORD dwHeadersLength
;
310 struct WORKREQ_INTERNETREADFILEEXA
312 LPINTERNET_BUFFERSA lpBuffersOut
;
315 struct WORKREQ_INTERNETREADFILEEXW
317 LPINTERNET_BUFFERSW lpBuffersOut
;
320 typedef struct WORKREQ
322 void (*asyncproc
)(struct WORKREQ
*);
323 WININETHANDLEHEADER
*hdr
;
326 struct WORKREQ_FTPPUTFILEW FtpPutFileW
;
327 struct WORKREQ_FTPSETCURRENTDIRECTORYW FtpSetCurrentDirectoryW
;
328 struct WORKREQ_FTPCREATEDIRECTORYW FtpCreateDirectoryW
;
329 struct WORKREQ_FTPFINDFIRSTFILEW FtpFindFirstFileW
;
330 struct WORKREQ_FTPGETCURRENTDIRECTORYW FtpGetCurrentDirectoryW
;
331 struct WORKREQ_FTPOPENFILEW FtpOpenFileW
;
332 struct WORKREQ_FTPGETFILEW FtpGetFileW
;
333 struct WORKREQ_FTPDELETEFILEW FtpDeleteFileW
;
334 struct WORKREQ_FTPREMOVEDIRECTORYW FtpRemoveDirectoryW
;
335 struct WORKREQ_FTPRENAMEFILEW FtpRenameFileW
;
336 struct WORKREQ_FTPFINDNEXTW FtpFindNextW
;
337 struct WORKREQ_HTTPSENDREQUESTW HttpSendRequestW
;
338 struct WORKREQ_SENDCALLBACK SendCallback
;
339 struct WORKREQ_INTERNETOPENURLW InternetOpenUrlW
;
340 struct WORKREQ_INTERNETREADFILEEXA InternetReadFileExA
;
341 struct WORKREQ_INTERNETREADFILEEXW InternetReadFileExW
;
344 } WORKREQUEST
, *LPWORKREQUEST
;
346 HINTERNET
WININET_AllocHandle( LPWININETHANDLEHEADER info
);
347 LPWININETHANDLEHEADER
WININET_GetObject( HINTERNET hinternet
);
348 LPWININETHANDLEHEADER
WININET_AddRef( LPWININETHANDLEHEADER info
);
349 BOOL
WININET_Release( LPWININETHANDLEHEADER info
);
350 BOOL
WININET_FreeHandle( HINTERNET hinternet
);
352 DWORD
INET_QueryOption(DWORD
,void*,DWORD
*,BOOL
);
354 time_t ConvertTimeString(LPCWSTR asctime
);
356 HINTERNET
FTP_Connect(LPWININETAPPINFOW hIC
, LPCWSTR lpszServerName
,
357 INTERNET_PORT nServerPort
, LPCWSTR lpszUserName
,
358 LPCWSTR lpszPassword
, DWORD dwFlags
, DWORD_PTR dwContext
,
359 DWORD dwInternalFlags
);
361 HINTERNET
HTTP_Connect(LPWININETAPPINFOW hIC
, LPCWSTR lpszServerName
,
362 INTERNET_PORT nServerPort
, LPCWSTR lpszUserName
,
363 LPCWSTR lpszPassword
, DWORD dwFlags
, DWORD_PTR dwContext
,
364 DWORD dwInternalFlags
);
366 BOOL
GetAddress(LPCWSTR lpszServerName
, INTERNET_PORT nServerPort
,
367 struct sockaddr_in
*psa
);
369 void INTERNET_SetLastError(DWORD dwError
);
370 DWORD
INTERNET_GetLastError(void);
371 BOOL
INTERNET_AsyncCall(LPWORKREQUEST lpWorkRequest
);
372 LPSTR
INTERNET_GetResponseBuffer(void);
373 LPSTR
INTERNET_GetNextLine(INT nSocket
, LPDWORD dwLen
);
375 BOOLAPI
HTTP_HttpSendRequestW(LPWININETHTTPREQW lpwhr
, LPCWSTR lpszHeaders
,
376 DWORD dwHeaderLength
, LPVOID lpOptional
, DWORD dwOptionalLength
,
377 DWORD dwContentLength
, BOOL bEndRequest
);
378 INTERNETAPI HINTERNET WINAPI
HTTP_HttpOpenRequestW(LPWININETHTTPSESSIONW lpwhs
,
379 LPCWSTR lpszVerb
, LPCWSTR lpszObjectName
, LPCWSTR lpszVersion
,
380 LPCWSTR lpszReferrer
, LPCWSTR
*lpszAcceptTypes
,
381 DWORD dwFlags
, DWORD_PTR dwContext
);
383 VOID
SendAsyncCallback(LPWININETHANDLEHEADER hdr
, DWORD_PTR dwContext
,
384 DWORD dwInternetStatus
, LPVOID lpvStatusInfo
,
385 DWORD dwStatusInfoLength
);
387 VOID
INTERNET_SendCallback(LPWININETHANDLEHEADER hdr
, DWORD_PTR dwContext
,
388 DWORD dwInternetStatus
, LPVOID lpvStatusInfo
,
389 DWORD dwStatusInfoLength
);
391 BOOL
NETCON_connected(WININET_NETCONNECTION
*connection
);
392 BOOL
NETCON_init(WININET_NETCONNECTION
*connnection
, BOOL useSSL
);
393 BOOL
NETCON_create(WININET_NETCONNECTION
*connection
, int domain
,
394 int type
, int protocol
);
395 BOOL
NETCON_close(WININET_NETCONNECTION
*connection
);
396 BOOL
NETCON_connect(WININET_NETCONNECTION
*connection
, const struct sockaddr
*serv_addr
,
397 unsigned int addrlen
);
398 BOOL
NETCON_secure_connect(WININET_NETCONNECTION
*connection
, LPCWSTR hostname
);
399 BOOL
NETCON_send(WININET_NETCONNECTION
*connection
, const void *msg
, size_t len
, int flags
,
400 int *sent
/* out */);
401 BOOL
NETCON_recv(WININET_NETCONNECTION
*connection
, void *buf
, size_t len
, int flags
,
402 int *recvd
/* out */);
403 BOOL
NETCON_query_data_available(WININET_NETCONNECTION
*connection
, DWORD
*available
);
404 BOOL
NETCON_getNextLine(WININET_NETCONNECTION
*connection
, LPSTR lpszBuffer
, LPDWORD dwBuffer
);
405 LPCVOID
NETCON_GetCert(WININET_NETCONNECTION
*connection
);
406 DWORD
NETCON_set_timeout(WININET_NETCONNECTION
*connection
, BOOL send
, int value
);
408 extern void URLCacheContainers_CreateDefaults(void);
409 extern void URLCacheContainers_DeleteAll(void);
411 #define MAX_REPLY_LEN 0x5B4
413 /* Used for debugging - maybe need to be shared in the Wine debugging code ? */
420 #endif /* _WINE_INTERNET_H_ */