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 # include <openssl/ssl.h>
45 #define FAR do_not_use_this_in_wine
48 #ifdef HAVE_SYS_SOCKET_H
49 # include <sys/socket.h>
52 #if defined(__MINGW32__) || defined (_MSC_VER)
58 #define closesocket close
59 #endif /* __MINGW32__ */
61 /* used for netconnection.c stuff */
66 #ifdef HAVE_OPENSSL_SSL_H
72 } WININET_NETCONNECTION
;
74 static inline LPWSTR
WININET_strdupW( LPCWSTR str
)
76 LPWSTR ret
= HeapAlloc( GetProcessHeap(), 0, (strlenW(str
) + 1)*sizeof(WCHAR
) );
77 if (ret
) strcpyW( ret
, str
);
81 static inline LPWSTR
WININET_strdup_AtoW( LPCSTR str
)
83 int len
= MultiByteToWideChar( CP_ACP
, 0, str
, -1, NULL
, 0);
84 LPWSTR ret
= HeapAlloc( GetProcessHeap(), 0, len
* sizeof(WCHAR
) );
86 MultiByteToWideChar( CP_ACP
, 0, str
, -1, ret
, len
);
90 static inline LPSTR
WININET_strdup_WtoA( LPCWSTR str
)
92 int len
= WideCharToMultiByte( CP_ACP
, 0, str
, -1, NULL
, 0, NULL
, NULL
);
93 LPSTR ret
= HeapAlloc( GetProcessHeap(), 0, len
);
95 WideCharToMultiByte( CP_ACP
, 0, str
, -1, ret
, len
, NULL
, NULL
);
99 static inline void WININET_find_data_WtoA(LPWIN32_FIND_DATAW dataW
, LPWIN32_FIND_DATAA dataA
)
101 dataA
->dwFileAttributes
= dataW
->dwFileAttributes
;
102 dataA
->ftCreationTime
= dataW
->ftCreationTime
;
103 dataA
->ftLastAccessTime
= dataW
->ftLastAccessTime
;
104 dataA
->ftLastWriteTime
= dataW
->ftLastWriteTime
;
105 dataA
->nFileSizeHigh
= dataW
->nFileSizeHigh
;
106 dataA
->nFileSizeLow
= dataW
->nFileSizeLow
;
107 dataA
->dwReserved0
= dataW
->dwReserved0
;
108 dataA
->dwReserved1
= dataW
->dwReserved1
;
109 WideCharToMultiByte(CP_ACP
, 0, dataW
->cFileName
, -1,
110 dataA
->cFileName
, sizeof(dataA
->cFileName
),
112 WideCharToMultiByte(CP_ACP
, 0, dataW
->cAlternateFileName
, -1,
113 dataA
->cAlternateFileName
, sizeof(dataA
->cAlternateFileName
),
119 WH_HINIT
= INTERNET_HANDLE_TYPE_INTERNET
,
120 WH_HFTPSESSION
= INTERNET_HANDLE_TYPE_CONNECT_FTP
,
121 WH_HGOPHERSESSION
= INTERNET_HANDLE_TYPE_CONNECT_GOPHER
,
122 WH_HHTTPSESSION
= INTERNET_HANDLE_TYPE_CONNECT_HTTP
,
123 WH_HFILE
= INTERNET_HANDLE_TYPE_FTP_FILE
,
124 WH_HFTPFINDNEXT
= INTERNET_HANDLE_TYPE_FTP_FIND
,
125 WH_HHTTPREQ
= INTERNET_HANDLE_TYPE_HTTP_REQUEST
,
128 #define INET_OPENURL 0x0001
129 #define INET_CALLBACKW 0x0002
131 struct _WININETHANDLEHEADER
;
132 typedef struct _WININETHANDLEHEADER WININETHANDLEHEADER
, *LPWININETHANDLEHEADER
;
134 typedef void (*WININET_object_destructor
)( LPWININETHANDLEHEADER
);
136 struct _WININETHANDLEHEADER
143 DWORD dwInternalFlags
;
145 WININET_object_destructor destroy
;
146 INTERNET_STATUS_CALLBACK lpfnStatusCB
;
152 WININETHANDLEHEADER hdr
;
155 LPWSTR lpszProxyBypass
;
156 LPWSTR lpszProxyUsername
;
157 LPWSTR lpszProxyPassword
;
159 } WININETAPPINFOW
, *LPWININETAPPINFOW
;
164 WININETHANDLEHEADER hdr
;
165 WININETAPPINFOW
*lpAppInfo
;
166 LPWSTR lpszHostName
; /* the final destination of the request */
167 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
;
189 WININETHANDLEHEADER hdr
;
190 WININETHTTPSESSIONW
*lpHttpSession
;
193 LPWSTR lpszRawHeaders
;
194 WININET_NETCONNECTION netConnection
;
196 LPWSTR lpszStatusText
;
197 DWORD dwContentLength
; /* total number of bytes to be read */
198 DWORD dwContentRead
; /* bytes of the content read so far */
199 HTTPHEADERW
*pCustHeaders
;
201 } WININETHTTPREQW
, *LPWININETHTTPREQW
;
204 struct _WININETFTPSESSIONW
;
208 WININETHANDLEHEADER hdr
;
209 struct _WININETFTPSESSIONW
*lpFtpSession
;
210 BOOL session_deleted
;
212 } WININETFTPFILE
, *LPWININETFTPFILE
;
215 typedef struct _WININETFTPSESSIONW
217 WININETHANDLEHEADER hdr
;
218 WININETAPPINFOW
*lpAppInfo
;
221 int pasvSocket
; /* data socket connected by us in case of passive FTP */
222 LPWININETFTPFILE download_in_progress
;
223 struct sockaddr_in socketAddress
;
224 struct sockaddr_in lstnSocketAddress
;
227 } WININETFTPSESSIONW
, *LPWININETFTPSESSIONW
;
235 struct tm tmLastModified
;
236 unsigned short permissions
;
237 } FILEPROPERTIESW
, *LPFILEPROPERTIESW
;
242 WININETHANDLEHEADER hdr
;
243 WININETFTPSESSIONW
*lpFtpSession
;
246 LPFILEPROPERTIESW lpafp
;
247 } WININETFTPFINDNEXTW
, *LPWININETFTPFINDNEXTW
;
249 struct WORKREQ_FTPPUTFILEW
251 LPWSTR lpszLocalFile
;
252 LPWSTR lpszNewRemoteFile
;
257 struct WORKREQ_FTPSETCURRENTDIRECTORYW
259 LPWSTR lpszDirectory
;
262 struct WORKREQ_FTPCREATEDIRECTORYW
264 LPWSTR lpszDirectory
;
267 struct WORKREQ_FTPFINDFIRSTFILEW
269 LPWSTR lpszSearchFile
;
270 LPWIN32_FIND_DATAW lpFindFileData
;
275 struct WORKREQ_FTPGETCURRENTDIRECTORYW
277 LPWSTR lpszDirectory
;
278 DWORD
*lpdwDirectory
;
281 struct WORKREQ_FTPOPENFILEW
289 struct WORKREQ_FTPGETFILEW
291 LPWSTR lpszRemoteFile
;
294 DWORD dwLocalFlagsAttribute
;
299 struct WORKREQ_FTPDELETEFILEW
304 struct WORKREQ_FTPREMOVEDIRECTORYW
306 LPWSTR lpszDirectory
;
309 struct WORKREQ_FTPRENAMEFILEW
315 struct WORKREQ_FTPFINDNEXTW
317 LPWIN32_FIND_DATAW lpFindFileData
;
320 struct WORKREQ_HTTPSENDREQUESTW
323 DWORD dwHeaderLength
;
325 DWORD dwOptionalLength
;
326 DWORD dwContentLength
;
330 struct WORKREQ_SENDCALLBACK
333 DWORD dwInternetStatus
;
334 LPVOID lpvStatusInfo
;
335 DWORD dwStatusInfoLength
;
338 struct WORKREQ_INTERNETOPENURLW
343 DWORD dwHeadersLength
;
348 struct WORKREQ_INTERNETREADFILEEXA
350 LPINTERNET_BUFFERSA lpBuffersOut
;
353 typedef struct WORKREQ
355 void (*asyncproc
)(struct WORKREQ
*);
356 WININETHANDLEHEADER
*hdr
;
359 struct WORKREQ_FTPPUTFILEW FtpPutFileW
;
360 struct WORKREQ_FTPSETCURRENTDIRECTORYW FtpSetCurrentDirectoryW
;
361 struct WORKREQ_FTPCREATEDIRECTORYW FtpCreateDirectoryW
;
362 struct WORKREQ_FTPFINDFIRSTFILEW FtpFindFirstFileW
;
363 struct WORKREQ_FTPGETCURRENTDIRECTORYW FtpGetCurrentDirectoryW
;
364 struct WORKREQ_FTPOPENFILEW FtpOpenFileW
;
365 struct WORKREQ_FTPGETFILEW FtpGetFileW
;
366 struct WORKREQ_FTPDELETEFILEW FtpDeleteFileW
;
367 struct WORKREQ_FTPREMOVEDIRECTORYW FtpRemoveDirectoryW
;
368 struct WORKREQ_FTPRENAMEFILEW FtpRenameFileW
;
369 struct WORKREQ_FTPFINDNEXTW FtpFindNextW
;
370 struct WORKREQ_HTTPSENDREQUESTW HttpSendRequestW
;
371 struct WORKREQ_SENDCALLBACK SendCallback
;
372 struct WORKREQ_INTERNETOPENURLW InternetOpenUrlW
;
373 struct WORKREQ_INTERNETREADFILEEXA InternetReadFileExA
;
376 } WORKREQUEST
, *LPWORKREQUEST
;
378 HINTERNET
WININET_AllocHandle( LPWININETHANDLEHEADER info
);
379 LPWININETHANDLEHEADER
WININET_GetObject( HINTERNET hinternet
);
380 LPWININETHANDLEHEADER
WININET_AddRef( LPWININETHANDLEHEADER info
);
381 BOOL
WININET_Release( LPWININETHANDLEHEADER info
);
382 BOOL
WININET_FreeHandle( HINTERNET hinternet
);
384 time_t ConvertTimeString(LPCWSTR asctime
);
386 HINTERNET
FTP_Connect(LPWININETAPPINFOW hIC
, LPCWSTR lpszServerName
,
387 INTERNET_PORT nServerPort
, LPCWSTR lpszUserName
,
388 LPCWSTR lpszPassword
, DWORD dwFlags
, DWORD dwContext
,
389 DWORD dwInternalFlags
);
391 HINTERNET
HTTP_Connect(LPWININETAPPINFOW hIC
, LPCWSTR lpszServerName
,
392 INTERNET_PORT nServerPort
, LPCWSTR lpszUserName
,
393 LPCWSTR lpszPassword
, DWORD dwFlags
, DWORD dwContext
,
394 DWORD dwInternalFlags
);
396 BOOL
GetAddress(LPCWSTR lpszServerName
, INTERNET_PORT nServerPort
,
397 struct sockaddr_in
*psa
);
399 void INTERNET_SetLastError(DWORD dwError
);
400 DWORD
INTERNET_GetLastError(void);
401 BOOL
INTERNET_AsyncCall(LPWORKREQUEST lpWorkRequest
);
402 LPSTR
INTERNET_GetResponseBuffer(void);
403 LPSTR
INTERNET_GetNextLine(INT nSocket
, LPDWORD dwLen
);
404 BOOL
INTERNET_ReadFile(LPWININETHANDLEHEADER lpwh
, LPVOID lpBuffer
,
405 DWORD dwNumOfBytesToRead
, LPDWORD pdwNumOfBytesRead
,
406 BOOL bWait
, BOOL bSendCompletionStatus
);
408 BOOLAPI
FTP_FtpPutFileW(LPWININETFTPSESSIONW lpwfs
, LPCWSTR lpszLocalFile
,
409 LPCWSTR lpszNewRemoteFile
, DWORD dwFlags
, DWORD dwContext
);
410 BOOLAPI
FTP_FtpSetCurrentDirectoryW(LPWININETFTPSESSIONW lpwfs
, LPCWSTR lpszDirectory
);
411 BOOLAPI
FTP_FtpCreateDirectoryW(LPWININETFTPSESSIONW lpwfs
, LPCWSTR lpszDirectory
);
412 INTERNETAPI HINTERNET WINAPI
FTP_FtpFindFirstFileW(LPWININETFTPSESSIONW lpwfs
,
413 LPCWSTR lpszSearchFile
, LPWIN32_FIND_DATAW lpFindFileData
, DWORD dwFlags
, DWORD dwContext
);
414 BOOL WINAPI
FTP_FindNextFileW(LPWININETFTPFINDNEXTW lpwh
, LPVOID lpvFindData
);
415 BOOLAPI
FTP_FtpGetCurrentDirectoryW(LPWININETFTPSESSIONW lpwfs
, LPWSTR lpszCurrentDirectory
,
416 LPDWORD lpdwCurrentDirectory
);
417 BOOL
FTP_ConvertFileProp(LPFILEPROPERTIESW lpafp
, LPWIN32_FIND_DATAW lpFindFileData
);
418 BOOL
FTP_FtpRenameFileW(LPWININETFTPSESSIONW lpwfs
, LPCWSTR lpszSrc
, LPCWSTR lpszDest
);
419 BOOL
FTP_FtpRemoveDirectoryW(LPWININETFTPSESSIONW lpwfs
, LPCWSTR lpszDirectory
);
420 BOOL
FTP_FtpDeleteFileW(LPWININETFTPSESSIONW lpwfs
, LPCWSTR lpszFileName
);
421 HINTERNET
FTP_FtpOpenFileW(LPWININETFTPSESSIONW lpwfs
, LPCWSTR lpszFileName
,
422 DWORD fdwAccess
, DWORD dwFlags
, DWORD dwContext
);
423 BOOLAPI
FTP_FtpGetFileW(LPWININETFTPSESSIONW lpwfs
, LPCWSTR lpszRemoteFile
, LPCWSTR lpszNewFile
,
424 BOOL fFailIfExists
, DWORD dwLocalFlagsAttribute
, DWORD dwInternetFlags
,
427 BOOLAPI
HTTP_HttpSendRequestW(LPWININETHTTPREQW lpwhr
, LPCWSTR lpszHeaders
,
428 DWORD dwHeaderLength
, LPVOID lpOptional
, DWORD dwOptionalLength
,
429 DWORD dwContentLength
, BOOL bEndRequest
);
430 INTERNETAPI HINTERNET WINAPI
HTTP_HttpOpenRequestW(LPWININETHTTPSESSIONW lpwhs
,
431 LPCWSTR lpszVerb
, LPCWSTR lpszObjectName
, LPCWSTR lpszVersion
,
432 LPCWSTR lpszReferrer
, LPCWSTR
*lpszAcceptTypes
,
433 DWORD dwFlags
, DWORD dwContext
);
434 BOOL
HTTP_FinishedReading(LPWININETHTTPREQW lpwhr
);
436 VOID
SendAsyncCallback(LPWININETHANDLEHEADER hdr
, DWORD dwContext
,
437 DWORD dwInternetStatus
, LPVOID lpvStatusInfo
,
438 DWORD dwStatusInfoLength
);
440 VOID
INTERNET_SendCallback(LPWININETHANDLEHEADER hdr
, DWORD dwContext
,
441 DWORD dwInternetStatus
, LPVOID lpvStatusInfo
,
442 DWORD dwStatusInfoLength
);
444 LPHTTPHEADERW
HTTP_GetHeader(LPWININETHTTPREQW lpwhr
, LPCWSTR header
);
446 BOOL
NETCON_connected(WININET_NETCONNECTION
*connection
);
447 BOOL
NETCON_init(WININET_NETCONNECTION
*connnection
, BOOL useSSL
);
448 BOOL
NETCON_create(WININET_NETCONNECTION
*connection
, int domain
,
449 int type
, int protocol
);
450 BOOL
NETCON_close(WININET_NETCONNECTION
*connection
);
451 BOOL
NETCON_connect(WININET_NETCONNECTION
*connection
, const struct sockaddr
*serv_addr
,
452 unsigned int addrlen
);
453 BOOL
NETCON_secure_connect(WININET_NETCONNECTION
*connection
, LPCWSTR hostname
);
454 BOOL
NETCON_send(WININET_NETCONNECTION
*connection
, const void *msg
, size_t len
, int flags
,
455 int *sent
/* out */);
456 BOOL
NETCON_recv(WININET_NETCONNECTION
*connection
, void *buf
, size_t len
, int flags
,
457 int *recvd
/* out */);
458 BOOL
NETCON_getNextLine(WININET_NETCONNECTION
*connection
, LPSTR lpszBuffer
, LPDWORD dwBuffer
);
459 LPCVOID
NETCON_GetCert(WININET_NETCONNECTION
*connection
);
460 BOOL
NETCON_set_timeout(WININET_NETCONNECTION
*connection
, BOOL send
, int value
);
462 extern void URLCacheContainers_CreateDefaults(void);
463 extern void URLCacheContainers_DeleteAll(void);
465 #define MAX_REPLY_LEN 0x5B4
467 /* Used for debugging - maybe need to be shared in the Wine debugging code ? */
474 #endif /* _WINE_INTERNET_H_ */