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_OPENSSL_SSL_H
42 #define DSA __ssl_DSA /* avoid conflict with commctrl.h */
44 /* avoid conflict with wincrypt.h */
45 #undef PKCS7_SIGNER_INFO
48 # include <openssl/ssl.h>
50 #define FAR do_not_use_this_in_wine
53 #ifdef HAVE_SYS_SOCKET_H
54 # include <sys/socket.h>
57 #if defined(__MINGW32__) || defined (_MSC_VER)
63 #define closesocket close
64 #endif /* __MINGW32__ */
66 /* used for netconnection.c stuff */
71 #ifdef HAVE_OPENSSL_SSL_H
77 } WININET_NETCONNECTION;
79 static inline LPWSTR WININET_strdupW( LPCWSTR str )
81 LPWSTR ret = HeapAlloc( GetProcessHeap(), 0, (strlenW(str) + 1)*sizeof(WCHAR) );
82 if (ret) strcpyW( ret, str );
86 static inline LPWSTR WININET_strdup_AtoW( LPCSTR str )
88 int len = MultiByteToWideChar( CP_ACP, 0, str, -1, NULL, 0);
89 LPWSTR ret = HeapAlloc( GetProcessHeap(), 0, len * sizeof(WCHAR) );
91 MultiByteToWideChar( CP_ACP, 0, str, -1, ret, len);
95 static inline LPSTR WININET_strdup_WtoA( LPCWSTR str )
97 int len = WideCharToMultiByte( CP_ACP, 0, str, -1, NULL, 0, NULL, NULL);
98 LPSTR ret = HeapAlloc( GetProcessHeap(), 0, len );
100 WideCharToMultiByte( CP_ACP, 0, str, -1, ret, len, NULL, NULL);
104 static inline void WININET_find_data_WtoA(LPWIN32_FIND_DATAW dataW, LPWIN32_FIND_DATAA dataA)
106 dataA->dwFileAttributes = dataW->dwFileAttributes;
107 dataA->ftCreationTime = dataW->ftCreationTime;
108 dataA->ftLastAccessTime = dataW->ftLastAccessTime;
109 dataA->ftLastWriteTime = dataW->ftLastWriteTime;
110 dataA->nFileSizeHigh = dataW->nFileSizeHigh;
111 dataA->nFileSizeLow = dataW->nFileSizeLow;
112 dataA->dwReserved0 = dataW->dwReserved0;
113 dataA->dwReserved1 = dataW->dwReserved1;
114 WideCharToMultiByte(CP_ACP, 0, dataW->cFileName, -1,
115 dataA->cFileName, sizeof(dataA->cFileName),
117 WideCharToMultiByte(CP_ACP, 0, dataW->cAlternateFileName, -1,
118 dataA->cAlternateFileName, sizeof(dataA->cAlternateFileName),
124 WH_HINIT = INTERNET_HANDLE_TYPE_INTERNET,
125 WH_HFTPSESSION = INTERNET_HANDLE_TYPE_CONNECT_FTP,
126 WH_HGOPHERSESSION = INTERNET_HANDLE_TYPE_CONNECT_GOPHER,
127 WH_HHTTPSESSION = INTERNET_HANDLE_TYPE_CONNECT_HTTP,
128 WH_HFILE = INTERNET_HANDLE_TYPE_FTP_FILE,
129 WH_HFTPFINDNEXT = INTERNET_HANDLE_TYPE_FTP_FIND,
130 WH_HHTTPREQ = INTERNET_HANDLE_TYPE_HTTP_REQUEST,
133 #define INET_OPENURL 0x0001
134 #define INET_CALLBACKW 0x0002
136 struct _WININETHANDLEHEADER;
137 typedef struct _WININETHANDLEHEADER WININETHANDLEHEADER, *LPWININETHANDLEHEADER;
139 typedef void (*WININET_object_function)( LPWININETHANDLEHEADER );
141 struct _WININETHANDLEHEADER
148 DWORD dwInternalFlags;
150 WININET_object_function close_connection;
151 WININET_object_function destroy;
152 INTERNET_STATUS_CALLBACK lpfnStatusCB;
154 struct list children;
160 WININETHANDLEHEADER hdr;
163 LPWSTR lpszProxyBypass;
164 LPWSTR lpszProxyUsername;
165 LPWSTR lpszProxyPassword;
167 } WININETAPPINFOW, *LPWININETAPPINFOW;
172 WININETHANDLEHEADER hdr;
173 WININETAPPINFOW *lpAppInfo;
174 LPWSTR lpszHostName; /* the final destination of the request */
175 LPWSTR lpszServerName; /* the name of the server we directly connect to */
178 INTERNET_PORT nHostPort; /* the final destination port of the request */
179 INTERNET_PORT nServerPort; /* the port of the server we directly connect to */
180 struct sockaddr_in socketAddress;
181 } WININETHTTPSESSIONW, *LPWININETHTTPSESSIONW;
183 #define HDR_ISREQUEST 0x0001
184 #define HDR_COMMADELIMITED 0x0002
185 #define HDR_SEMIDELIMITED 0x0004
193 } HTTPHEADERW, *LPHTTPHEADERW;
200 WININETHANDLEHEADER hdr;
201 WININETHTTPSESSIONW *lpHttpSession;
204 LPWSTR lpszRawHeaders;
205 WININET_NETCONNECTION netConnection;
207 LPWSTR lpszStatusText;
208 DWORD dwContentLength; /* total number of bytes to be read */
209 DWORD dwContentRead; /* bytes of the content read so far */
210 HTTPHEADERW *pCustHeaders;
212 struct HttpAuthInfo *pAuthInfo;
213 struct HttpAuthInfo *pProxyAuthInfo;
214 } WININETHTTPREQW, *LPWININETHTTPREQW;
217 struct _WININETFTPSESSIONW;
221 WININETHANDLEHEADER hdr;
222 struct _WININETFTPSESSIONW *lpFtpSession;
223 BOOL session_deleted;
225 } WININETFTPFILE, *LPWININETFTPFILE;
228 typedef struct _WININETFTPSESSIONW
230 WININETHANDLEHEADER hdr;
231 WININETAPPINFOW *lpAppInfo;
234 int pasvSocket; /* data socket connected by us in case of passive FTP */
235 LPWININETFTPFILE download_in_progress;
236 struct sockaddr_in socketAddress;
237 struct sockaddr_in lstnSocketAddress;
240 } WININETFTPSESSIONW, *LPWININETFTPSESSIONW;
248 struct tm tmLastModified;
249 unsigned short permissions;
250 } FILEPROPERTIESW, *LPFILEPROPERTIESW;
255 WININETHANDLEHEADER hdr;
256 WININETFTPSESSIONW *lpFtpSession;
259 LPFILEPROPERTIESW lpafp;
260 } WININETFTPFINDNEXTW, *LPWININETFTPFINDNEXTW;
262 struct WORKREQ_FTPPUTFILEW
264 LPWSTR lpszLocalFile;
265 LPWSTR lpszNewRemoteFile;
270 struct WORKREQ_FTPSETCURRENTDIRECTORYW
272 LPWSTR lpszDirectory;
275 struct WORKREQ_FTPCREATEDIRECTORYW
277 LPWSTR lpszDirectory;
280 struct WORKREQ_FTPFINDFIRSTFILEW
282 LPWSTR lpszSearchFile;
283 LPWIN32_FIND_DATAW lpFindFileData;
288 struct WORKREQ_FTPGETCURRENTDIRECTORYW
290 LPWSTR lpszDirectory;
291 DWORD *lpdwDirectory;
294 struct WORKREQ_FTPOPENFILEW
302 struct WORKREQ_FTPGETFILEW
304 LPWSTR lpszRemoteFile;
307 DWORD dwLocalFlagsAttribute;
312 struct WORKREQ_FTPDELETEFILEW
317 struct WORKREQ_FTPREMOVEDIRECTORYW
319 LPWSTR lpszDirectory;
322 struct WORKREQ_FTPRENAMEFILEW
328 struct WORKREQ_FTPFINDNEXTW
330 LPWIN32_FIND_DATAW lpFindFileData;
333 struct WORKREQ_HTTPSENDREQUESTW
336 DWORD dwHeaderLength;
338 DWORD dwOptionalLength;
339 DWORD dwContentLength;
343 struct WORKREQ_SENDCALLBACK
346 DWORD dwInternetStatus;
347 LPVOID lpvStatusInfo;
348 DWORD dwStatusInfoLength;
351 struct WORKREQ_INTERNETOPENURLW
356 DWORD dwHeadersLength;
361 struct WORKREQ_INTERNETREADFILEEXA
363 LPINTERNET_BUFFERSA lpBuffersOut;
366 typedef struct WORKREQ
368 void (*asyncproc)(struct WORKREQ*);
369 WININETHANDLEHEADER *hdr;
372 struct WORKREQ_FTPPUTFILEW FtpPutFileW;
373 struct WORKREQ_FTPSETCURRENTDIRECTORYW FtpSetCurrentDirectoryW;
374 struct WORKREQ_FTPCREATEDIRECTORYW FtpCreateDirectoryW;
375 struct WORKREQ_FTPFINDFIRSTFILEW FtpFindFirstFileW;
376 struct WORKREQ_FTPGETCURRENTDIRECTORYW FtpGetCurrentDirectoryW;
377 struct WORKREQ_FTPOPENFILEW FtpOpenFileW;
378 struct WORKREQ_FTPGETFILEW FtpGetFileW;
379 struct WORKREQ_FTPDELETEFILEW FtpDeleteFileW;
380 struct WORKREQ_FTPREMOVEDIRECTORYW FtpRemoveDirectoryW;
381 struct WORKREQ_FTPRENAMEFILEW FtpRenameFileW;
382 struct WORKREQ_FTPFINDNEXTW FtpFindNextW;
383 struct WORKREQ_HTTPSENDREQUESTW HttpSendRequestW;
384 struct WORKREQ_SENDCALLBACK SendCallback;
385 struct WORKREQ_INTERNETOPENURLW InternetOpenUrlW;
386 struct WORKREQ_INTERNETREADFILEEXA InternetReadFileExA;
389 } WORKREQUEST, *LPWORKREQUEST;
391 HINTERNET WININET_AllocHandle( LPWININETHANDLEHEADER info );
392 LPWININETHANDLEHEADER WININET_GetObject( HINTERNET hinternet );
393 LPWININETHANDLEHEADER WININET_AddRef( LPWININETHANDLEHEADER info );
394 BOOL WININET_Release( LPWININETHANDLEHEADER info );
395 BOOL WININET_FreeHandle( HINTERNET hinternet );
397 time_t ConvertTimeString(LPCWSTR asctime);
399 HINTERNET FTP_Connect(LPWININETAPPINFOW hIC, LPCWSTR lpszServerName,
400 INTERNET_PORT nServerPort, LPCWSTR lpszUserName,
401 LPCWSTR lpszPassword, DWORD dwFlags, DWORD_PTR dwContext,
402 DWORD dwInternalFlags);
404 HINTERNET HTTP_Connect(LPWININETAPPINFOW hIC, LPCWSTR lpszServerName,
405 INTERNET_PORT nServerPort, LPCWSTR lpszUserName,
406 LPCWSTR lpszPassword, DWORD dwFlags, DWORD_PTR dwContext,
407 DWORD dwInternalFlags);
409 BOOL GetAddress(LPCWSTR lpszServerName, INTERNET_PORT nServerPort,
410 struct sockaddr_in *psa);
412 void INTERNET_SetLastError(DWORD dwError);
413 DWORD INTERNET_GetLastError(void);
414 BOOL INTERNET_AsyncCall(LPWORKREQUEST lpWorkRequest);
415 LPSTR INTERNET_GetResponseBuffer(void);
416 LPSTR INTERNET_GetNextLine(INT nSocket, LPDWORD dwLen);
417 BOOL INTERNET_ReadFile(LPWININETHANDLEHEADER lpwh, LPVOID lpBuffer,
418 DWORD dwNumOfBytesToRead, LPDWORD pdwNumOfBytesRead,
419 BOOL bWait, BOOL bSendCompletionStatus);
421 BOOLAPI FTP_FtpPutFileW(LPWININETFTPSESSIONW lpwfs, LPCWSTR lpszLocalFile,
422 LPCWSTR lpszNewRemoteFile, DWORD dwFlags, DWORD_PTR dwContext);
423 BOOLAPI FTP_FtpSetCurrentDirectoryW(LPWININETFTPSESSIONW lpwfs, LPCWSTR lpszDirectory);
424 BOOLAPI FTP_FtpCreateDirectoryW(LPWININETFTPSESSIONW lpwfs, LPCWSTR lpszDirectory);
425 INTERNETAPI HINTERNET WINAPI FTP_FtpFindFirstFileW(LPWININETFTPSESSIONW lpwfs,
426 LPCWSTR lpszSearchFile, LPWIN32_FIND_DATAW lpFindFileData, DWORD dwFlags, DWORD_PTR dwContext);
427 BOOL WINAPI FTP_FindNextFileW(LPWININETFTPFINDNEXTW lpwh, LPVOID lpvFindData);
428 BOOLAPI FTP_FtpGetCurrentDirectoryW(LPWININETFTPSESSIONW lpwfs, LPWSTR lpszCurrentDirectory,
429 LPDWORD lpdwCurrentDirectory);
430 BOOL FTP_ConvertFileProp(LPFILEPROPERTIESW lpafp, LPWIN32_FIND_DATAW lpFindFileData);
431 BOOL FTP_FtpRenameFileW(LPWININETFTPSESSIONW lpwfs, LPCWSTR lpszSrc, LPCWSTR lpszDest);
432 BOOL FTP_FtpRemoveDirectoryW(LPWININETFTPSESSIONW lpwfs, LPCWSTR lpszDirectory);
433 BOOL FTP_FtpDeleteFileW(LPWININETFTPSESSIONW lpwfs, LPCWSTR lpszFileName);
434 HINTERNET FTP_FtpOpenFileW(LPWININETFTPSESSIONW lpwfs, LPCWSTR lpszFileName,
435 DWORD fdwAccess, DWORD dwFlags, DWORD_PTR dwContext);
436 BOOLAPI FTP_FtpGetFileW(LPWININETFTPSESSIONW lpwfs, LPCWSTR lpszRemoteFile, LPCWSTR lpszNewFile,
437 BOOL fFailIfExists, DWORD dwLocalFlagsAttribute, DWORD dwInternetFlags,
438 DWORD_PTR dwContext);
440 BOOLAPI HTTP_HttpSendRequestW(LPWININETHTTPREQW lpwhr, LPCWSTR lpszHeaders,
441 DWORD dwHeaderLength, LPVOID lpOptional, DWORD dwOptionalLength,
442 DWORD dwContentLength, BOOL bEndRequest);
443 INTERNETAPI HINTERNET WINAPI HTTP_HttpOpenRequestW(LPWININETHTTPSESSIONW lpwhs,
444 LPCWSTR lpszVerb, LPCWSTR lpszObjectName, LPCWSTR lpszVersion,
445 LPCWSTR lpszReferrer , LPCWSTR *lpszAcceptTypes,
446 DWORD dwFlags, DWORD_PTR dwContext);
447 BOOL HTTP_FinishedReading(LPWININETHTTPREQW lpwhr);
449 VOID SendAsyncCallback(LPWININETHANDLEHEADER hdr, DWORD_PTR dwContext,
450 DWORD dwInternetStatus, LPVOID lpvStatusInfo,
451 DWORD dwStatusInfoLength);
453 VOID INTERNET_SendCallback(LPWININETHANDLEHEADER hdr, DWORD_PTR dwContext,
454 DWORD dwInternetStatus, LPVOID lpvStatusInfo,
455 DWORD dwStatusInfoLength);
457 LPHTTPHEADERW HTTP_GetHeader(LPWININETHTTPREQW lpwhr, LPCWSTR header);
459 BOOL NETCON_connected(WININET_NETCONNECTION *connection);
460 BOOL NETCON_init(WININET_NETCONNECTION *connnection, BOOL useSSL);
461 BOOL NETCON_create(WININET_NETCONNECTION *connection, int domain,
462 int type, int protocol);
463 BOOL NETCON_close(WININET_NETCONNECTION *connection);
464 BOOL NETCON_connect(WININET_NETCONNECTION *connection, const struct sockaddr *serv_addr,
465 unsigned int addrlen);
466 BOOL NETCON_secure_connect(WININET_NETCONNECTION *connection, LPCWSTR hostname);
467 BOOL NETCON_send(WININET_NETCONNECTION *connection, const void *msg, size_t len, int flags,
468 int *sent /* out */);
469 BOOL NETCON_recv(WININET_NETCONNECTION *connection, void *buf, size_t len, int flags,
470 int *recvd /* out */);
471 BOOL NETCON_query_data_available(WININET_NETCONNECTION *connection, DWORD *available);
472 BOOL NETCON_getNextLine(WININET_NETCONNECTION *connection, LPSTR lpszBuffer, LPDWORD dwBuffer);
473 LPCVOID NETCON_GetCert(WININET_NETCONNECTION *connection);
474 BOOL NETCON_set_timeout(WININET_NETCONNECTION *connection, BOOL send, int value);
476 extern void URLCacheContainers_CreateDefaults(void);
477 extern void URLCacheContainers_DeleteAll(void);
479 #define MAX_REPLY_LEN 0x5B4
481 /* Used for debugging - maybe need to be shared in the Wine debugging code ? */
488 #endif /* _WINE_INTERNET_H_ */