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"
36 #ifdef HAVE_NETINET_IN_H
37 # include <sys/types.h>
38 # include <netinet/in.h>
40 #ifdef HAVE_OPENSSL_SSL_H
41 #define DSA __ssl_DSA /* avoid conflict with commctrl.h */
43 /* avoid conflict with wincrypt.h */
44 #undef PKCS7_SIGNER_INFO
47 # include <openssl/ssl.h>
49 #define FAR do_not_use_this_in_wine
52 #ifdef HAVE_SYS_SOCKET_H
53 # include <sys/socket.h>
56 #if defined(__MINGW32__) || defined (_MSC_VER)
62 #define closesocket close
63 #endif /* __MINGW32__ */
65 /* used for netconnection.c stuff */
70 #ifdef HAVE_OPENSSL_SSL_H
76 } WININET_NETCONNECTION
;
78 static inline LPWSTR
WININET_strdupW( LPCWSTR str
)
80 LPWSTR ret
= HeapAlloc( GetProcessHeap(), 0, (strlenW(str
) + 1)*sizeof(WCHAR
) );
81 if (ret
) strcpyW( ret
, str
);
85 static inline LPWSTR
WININET_strdup_AtoW( LPCSTR str
)
87 int len
= MultiByteToWideChar( CP_ACP
, 0, str
, -1, NULL
, 0);
88 LPWSTR ret
= HeapAlloc( GetProcessHeap(), 0, len
* sizeof(WCHAR
) );
90 MultiByteToWideChar( CP_ACP
, 0, str
, -1, ret
, len
);
94 static inline LPSTR
WININET_strdup_WtoA( LPCWSTR str
)
96 int len
= WideCharToMultiByte( CP_ACP
, 0, str
, -1, NULL
, 0, NULL
, NULL
);
97 LPSTR ret
= HeapAlloc( GetProcessHeap(), 0, len
);
99 WideCharToMultiByte( CP_ACP
, 0, str
, -1, ret
, len
, NULL
, NULL
);
103 static inline void WININET_find_data_WtoA(LPWIN32_FIND_DATAW dataW
, LPWIN32_FIND_DATAA dataA
)
105 dataA
->dwFileAttributes
= dataW
->dwFileAttributes
;
106 dataA
->ftCreationTime
= dataW
->ftCreationTime
;
107 dataA
->ftLastAccessTime
= dataW
->ftLastAccessTime
;
108 dataA
->ftLastWriteTime
= dataW
->ftLastWriteTime
;
109 dataA
->nFileSizeHigh
= dataW
->nFileSizeHigh
;
110 dataA
->nFileSizeLow
= dataW
->nFileSizeLow
;
111 dataA
->dwReserved0
= dataW
->dwReserved0
;
112 dataA
->dwReserved1
= dataW
->dwReserved1
;
113 WideCharToMultiByte(CP_ACP
, 0, dataW
->cFileName
, -1,
114 dataA
->cFileName
, sizeof(dataA
->cFileName
),
116 WideCharToMultiByte(CP_ACP
, 0, dataW
->cAlternateFileName
, -1,
117 dataA
->cAlternateFileName
, sizeof(dataA
->cAlternateFileName
),
123 WH_HINIT
= INTERNET_HANDLE_TYPE_INTERNET
,
124 WH_HFTPSESSION
= INTERNET_HANDLE_TYPE_CONNECT_FTP
,
125 WH_HGOPHERSESSION
= INTERNET_HANDLE_TYPE_CONNECT_GOPHER
,
126 WH_HHTTPSESSION
= INTERNET_HANDLE_TYPE_CONNECT_HTTP
,
127 WH_HFILE
= INTERNET_HANDLE_TYPE_FTP_FILE
,
128 WH_HFTPFINDNEXT
= INTERNET_HANDLE_TYPE_FTP_FIND
,
129 WH_HHTTPREQ
= INTERNET_HANDLE_TYPE_HTTP_REQUEST
,
132 #define INET_OPENURL 0x0001
133 #define INET_CALLBACKW 0x0002
135 struct _WININETHANDLEHEADER
;
136 typedef struct _WININETHANDLEHEADER WININETHANDLEHEADER
, *LPWININETHANDLEHEADER
;
138 typedef void (*WININET_object_function
)( LPWININETHANDLEHEADER
);
140 struct _WININETHANDLEHEADER
147 DWORD dwInternalFlags
;
149 WININET_object_function close_connection
;
150 WININET_object_function destroy
;
151 INTERNET_STATUS_CALLBACK lpfnStatusCB
;
157 WININETHANDLEHEADER hdr
;
160 LPWSTR lpszProxyBypass
;
161 LPWSTR lpszProxyUsername
;
162 LPWSTR lpszProxyPassword
;
164 } WININETAPPINFOW
, *LPWININETAPPINFOW
;
169 WININETHANDLEHEADER hdr
;
170 WININETAPPINFOW
*lpAppInfo
;
171 LPWSTR lpszHostName
; /* the final destination of the request */
172 LPWSTR lpszServerName
; /* the name of the server we directly connect to */
175 INTERNET_PORT nHostPort
; /* the final destination port of the request */
176 INTERNET_PORT nServerPort
; /* the port of the server we directly connect to */
177 struct sockaddr_in socketAddress
;
178 } WININETHTTPSESSIONW
, *LPWININETHTTPSESSIONW
;
180 #define HDR_ISREQUEST 0x0001
181 #define HDR_COMMADELIMITED 0x0002
182 #define HDR_SEMIDELIMITED 0x0004
190 } HTTPHEADERW
, *LPHTTPHEADERW
;
197 WININETHANDLEHEADER hdr
;
198 WININETHTTPSESSIONW
*lpHttpSession
;
201 LPWSTR lpszRawHeaders
;
202 WININET_NETCONNECTION netConnection
;
204 LPWSTR lpszStatusText
;
205 DWORD dwContentLength
; /* total number of bytes to be read */
206 DWORD dwContentRead
; /* bytes of the content read so far */
207 HTTPHEADERW
*pCustHeaders
;
209 struct HttpAuthInfo
*pAuthInfo
;
210 struct HttpAuthInfo
*pProxyAuthInfo
;
211 } WININETHTTPREQW
, *LPWININETHTTPREQW
;
214 struct _WININETFTPSESSIONW
;
218 WININETHANDLEHEADER hdr
;
219 struct _WININETFTPSESSIONW
*lpFtpSession
;
220 BOOL session_deleted
;
222 } WININETFTPFILE
, *LPWININETFTPFILE
;
225 typedef struct _WININETFTPSESSIONW
227 WININETHANDLEHEADER hdr
;
228 WININETAPPINFOW
*lpAppInfo
;
231 int pasvSocket
; /* data socket connected by us in case of passive FTP */
232 LPWININETFTPFILE download_in_progress
;
233 struct sockaddr_in socketAddress
;
234 struct sockaddr_in lstnSocketAddress
;
237 } WININETFTPSESSIONW
, *LPWININETFTPSESSIONW
;
245 struct tm tmLastModified
;
246 unsigned short permissions
;
247 } FILEPROPERTIESW
, *LPFILEPROPERTIESW
;
252 WININETHANDLEHEADER hdr
;
253 WININETFTPSESSIONW
*lpFtpSession
;
256 LPFILEPROPERTIESW lpafp
;
257 } WININETFTPFINDNEXTW
, *LPWININETFTPFINDNEXTW
;
259 struct WORKREQ_FTPPUTFILEW
261 LPWSTR lpszLocalFile
;
262 LPWSTR lpszNewRemoteFile
;
267 struct WORKREQ_FTPSETCURRENTDIRECTORYW
269 LPWSTR lpszDirectory
;
272 struct WORKREQ_FTPCREATEDIRECTORYW
274 LPWSTR lpszDirectory
;
277 struct WORKREQ_FTPFINDFIRSTFILEW
279 LPWSTR lpszSearchFile
;
280 LPWIN32_FIND_DATAW lpFindFileData
;
285 struct WORKREQ_FTPGETCURRENTDIRECTORYW
287 LPWSTR lpszDirectory
;
288 DWORD
*lpdwDirectory
;
291 struct WORKREQ_FTPOPENFILEW
299 struct WORKREQ_FTPGETFILEW
301 LPWSTR lpszRemoteFile
;
304 DWORD dwLocalFlagsAttribute
;
309 struct WORKREQ_FTPDELETEFILEW
314 struct WORKREQ_FTPREMOVEDIRECTORYW
316 LPWSTR lpszDirectory
;
319 struct WORKREQ_FTPRENAMEFILEW
325 struct WORKREQ_FTPFINDNEXTW
327 LPWIN32_FIND_DATAW lpFindFileData
;
330 struct WORKREQ_HTTPSENDREQUESTW
333 DWORD dwHeaderLength
;
335 DWORD dwOptionalLength
;
336 DWORD dwContentLength
;
340 struct WORKREQ_SENDCALLBACK
343 DWORD dwInternetStatus
;
344 LPVOID lpvStatusInfo
;
345 DWORD dwStatusInfoLength
;
348 struct WORKREQ_INTERNETOPENURLW
353 DWORD dwHeadersLength
;
358 struct WORKREQ_INTERNETREADFILEEXA
360 LPINTERNET_BUFFERSA lpBuffersOut
;
363 typedef struct WORKREQ
365 void (*asyncproc
)(struct WORKREQ
*);
366 WININETHANDLEHEADER
*hdr
;
369 struct WORKREQ_FTPPUTFILEW FtpPutFileW
;
370 struct WORKREQ_FTPSETCURRENTDIRECTORYW FtpSetCurrentDirectoryW
;
371 struct WORKREQ_FTPCREATEDIRECTORYW FtpCreateDirectoryW
;
372 struct WORKREQ_FTPFINDFIRSTFILEW FtpFindFirstFileW
;
373 struct WORKREQ_FTPGETCURRENTDIRECTORYW FtpGetCurrentDirectoryW
;
374 struct WORKREQ_FTPOPENFILEW FtpOpenFileW
;
375 struct WORKREQ_FTPGETFILEW FtpGetFileW
;
376 struct WORKREQ_FTPDELETEFILEW FtpDeleteFileW
;
377 struct WORKREQ_FTPREMOVEDIRECTORYW FtpRemoveDirectoryW
;
378 struct WORKREQ_FTPRENAMEFILEW FtpRenameFileW
;
379 struct WORKREQ_FTPFINDNEXTW FtpFindNextW
;
380 struct WORKREQ_HTTPSENDREQUESTW HttpSendRequestW
;
381 struct WORKREQ_SENDCALLBACK SendCallback
;
382 struct WORKREQ_INTERNETOPENURLW InternetOpenUrlW
;
383 struct WORKREQ_INTERNETREADFILEEXA InternetReadFileExA
;
386 } WORKREQUEST
, *LPWORKREQUEST
;
388 HINTERNET
WININET_AllocHandle( LPWININETHANDLEHEADER info
);
389 LPWININETHANDLEHEADER
WININET_GetObject( HINTERNET hinternet
);
390 LPWININETHANDLEHEADER
WININET_AddRef( LPWININETHANDLEHEADER info
);
391 BOOL
WININET_Release( LPWININETHANDLEHEADER info
);
392 BOOL
WININET_FreeHandle( HINTERNET hinternet
);
394 time_t ConvertTimeString(LPCWSTR asctime
);
396 HINTERNET
FTP_Connect(LPWININETAPPINFOW hIC
, LPCWSTR lpszServerName
,
397 INTERNET_PORT nServerPort
, LPCWSTR lpszUserName
,
398 LPCWSTR lpszPassword
, DWORD dwFlags
, DWORD dwContext
,
399 DWORD dwInternalFlags
);
401 HINTERNET
HTTP_Connect(LPWININETAPPINFOW hIC
, LPCWSTR lpszServerName
,
402 INTERNET_PORT nServerPort
, LPCWSTR lpszUserName
,
403 LPCWSTR lpszPassword
, DWORD dwFlags
, DWORD dwContext
,
404 DWORD dwInternalFlags
);
406 BOOL
GetAddress(LPCWSTR lpszServerName
, INTERNET_PORT nServerPort
,
407 struct sockaddr_in
*psa
);
409 void INTERNET_SetLastError(DWORD dwError
);
410 DWORD
INTERNET_GetLastError(void);
411 BOOL
INTERNET_AsyncCall(LPWORKREQUEST lpWorkRequest
);
412 LPSTR
INTERNET_GetResponseBuffer(void);
413 LPSTR
INTERNET_GetNextLine(INT nSocket
, LPDWORD dwLen
);
414 BOOL
INTERNET_ReadFile(LPWININETHANDLEHEADER lpwh
, LPVOID lpBuffer
,
415 DWORD dwNumOfBytesToRead
, LPDWORD pdwNumOfBytesRead
,
416 BOOL bWait
, BOOL bSendCompletionStatus
);
418 BOOLAPI
FTP_FtpPutFileW(LPWININETFTPSESSIONW lpwfs
, LPCWSTR lpszLocalFile
,
419 LPCWSTR lpszNewRemoteFile
, DWORD dwFlags
, DWORD dwContext
);
420 BOOLAPI
FTP_FtpSetCurrentDirectoryW(LPWININETFTPSESSIONW lpwfs
, LPCWSTR lpszDirectory
);
421 BOOLAPI
FTP_FtpCreateDirectoryW(LPWININETFTPSESSIONW lpwfs
, LPCWSTR lpszDirectory
);
422 INTERNETAPI HINTERNET WINAPI
FTP_FtpFindFirstFileW(LPWININETFTPSESSIONW lpwfs
,
423 LPCWSTR lpszSearchFile
, LPWIN32_FIND_DATAW lpFindFileData
, DWORD dwFlags
, DWORD dwContext
);
424 BOOL WINAPI
FTP_FindNextFileW(LPWININETFTPFINDNEXTW lpwh
, LPVOID lpvFindData
);
425 BOOLAPI
FTP_FtpGetCurrentDirectoryW(LPWININETFTPSESSIONW lpwfs
, LPWSTR lpszCurrentDirectory
,
426 LPDWORD lpdwCurrentDirectory
);
427 BOOL
FTP_ConvertFileProp(LPFILEPROPERTIESW lpafp
, LPWIN32_FIND_DATAW lpFindFileData
);
428 BOOL
FTP_FtpRenameFileW(LPWININETFTPSESSIONW lpwfs
, LPCWSTR lpszSrc
, LPCWSTR lpszDest
);
429 BOOL
FTP_FtpRemoveDirectoryW(LPWININETFTPSESSIONW lpwfs
, LPCWSTR lpszDirectory
);
430 BOOL
FTP_FtpDeleteFileW(LPWININETFTPSESSIONW lpwfs
, LPCWSTR lpszFileName
);
431 HINTERNET
FTP_FtpOpenFileW(LPWININETFTPSESSIONW lpwfs
, LPCWSTR lpszFileName
,
432 DWORD fdwAccess
, DWORD dwFlags
, DWORD dwContext
);
433 BOOLAPI
FTP_FtpGetFileW(LPWININETFTPSESSIONW lpwfs
, LPCWSTR lpszRemoteFile
, LPCWSTR lpszNewFile
,
434 BOOL fFailIfExists
, DWORD dwLocalFlagsAttribute
, DWORD dwInternetFlags
,
437 BOOLAPI
HTTP_HttpSendRequestW(LPWININETHTTPREQW lpwhr
, LPCWSTR lpszHeaders
,
438 DWORD dwHeaderLength
, LPVOID lpOptional
, DWORD dwOptionalLength
,
439 DWORD dwContentLength
, BOOL bEndRequest
);
440 INTERNETAPI HINTERNET WINAPI
HTTP_HttpOpenRequestW(LPWININETHTTPSESSIONW lpwhs
,
441 LPCWSTR lpszVerb
, LPCWSTR lpszObjectName
, LPCWSTR lpszVersion
,
442 LPCWSTR lpszReferrer
, LPCWSTR
*lpszAcceptTypes
,
443 DWORD dwFlags
, DWORD dwContext
);
444 BOOL
HTTP_FinishedReading(LPWININETHTTPREQW lpwhr
);
446 VOID
SendAsyncCallback(LPWININETHANDLEHEADER hdr
, DWORD dwContext
,
447 DWORD dwInternetStatus
, LPVOID lpvStatusInfo
,
448 DWORD dwStatusInfoLength
);
450 VOID
INTERNET_SendCallback(LPWININETHANDLEHEADER hdr
, DWORD dwContext
,
451 DWORD dwInternetStatus
, LPVOID lpvStatusInfo
,
452 DWORD dwStatusInfoLength
);
454 LPHTTPHEADERW
HTTP_GetHeader(LPWININETHTTPREQW lpwhr
, LPCWSTR header
);
456 BOOL
NETCON_connected(WININET_NETCONNECTION
*connection
);
457 BOOL
NETCON_init(WININET_NETCONNECTION
*connnection
, BOOL useSSL
);
458 BOOL
NETCON_create(WININET_NETCONNECTION
*connection
, int domain
,
459 int type
, int protocol
);
460 BOOL
NETCON_close(WININET_NETCONNECTION
*connection
);
461 BOOL
NETCON_connect(WININET_NETCONNECTION
*connection
, const struct sockaddr
*serv_addr
,
462 unsigned int addrlen
);
463 BOOL
NETCON_secure_connect(WININET_NETCONNECTION
*connection
, LPCWSTR hostname
);
464 BOOL
NETCON_send(WININET_NETCONNECTION
*connection
, const void *msg
, size_t len
, int flags
,
465 int *sent
/* out */);
466 BOOL
NETCON_recv(WININET_NETCONNECTION
*connection
, void *buf
, size_t len
, int flags
,
467 int *recvd
/* out */);
468 BOOL
NETCON_query_data_available(WININET_NETCONNECTION
*connection
, DWORD
*available
);
469 BOOL
NETCON_getNextLine(WININET_NETCONNECTION
*connection
, LPSTR lpszBuffer
, LPDWORD dwBuffer
);
470 LPCVOID
NETCON_GetCert(WININET_NETCONNECTION
*connection
);
471 BOOL
NETCON_set_timeout(WININET_NETCONNECTION
*connection
, BOOL send
, int value
);
473 extern void URLCacheContainers_CreateDefaults(void);
474 extern void URLCacheContainers_DeleteAll(void);
476 #define MAX_REPLY_LEN 0x5B4
478 /* Used for debugging - maybe need to be shared in the Wine debugging code ? */
485 #endif /* _WINE_INTERNET_H_ */