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_destructor)( LPWININETHANDLEHEADER );
140 struct _WININETHANDLEHEADER
147 DWORD dwInternalFlags;
149 WININET_object_destructor destroy;
150 INTERNET_STATUS_CALLBACK lpfnStatusCB;
156 WININETHANDLEHEADER hdr;
159 LPWSTR lpszProxyBypass;
160 LPWSTR lpszProxyUsername;
161 LPWSTR lpszProxyPassword;
163 } WININETAPPINFOW, *LPWININETAPPINFOW;
168 WININETHANDLEHEADER hdr;
169 WININETAPPINFOW *lpAppInfo;
170 LPWSTR lpszHostName; /* the final destination of the request */
171 LPWSTR lpszServerName; /* the name of the server we directly connect to */
174 INTERNET_PORT nHostPort; /* the final destination port of the request */
175 INTERNET_PORT nServerPort; /* the port of the server we directly connect to */
176 struct sockaddr_in socketAddress;
177 } WININETHTTPSESSIONW, *LPWININETHTTPSESSIONW;
179 #define HDR_ISREQUEST 0x0001
180 #define HDR_COMMADELIMITED 0x0002
181 #define HDR_SEMIDELIMITED 0x0004
189 } HTTPHEADERW, *LPHTTPHEADERW;
196 WININETHANDLEHEADER hdr;
197 WININETHTTPSESSIONW *lpHttpSession;
200 LPWSTR lpszRawHeaders;
201 WININET_NETCONNECTION netConnection;
203 LPWSTR lpszStatusText;
204 DWORD dwContentLength; /* total number of bytes to be read */
205 DWORD dwContentRead; /* bytes of the content read so far */
206 HTTPHEADERW *pCustHeaders;
208 struct HttpAuthInfo *pAuthInfo;
209 struct HttpAuthInfo *pProxyAuthInfo;
210 } WININETHTTPREQW, *LPWININETHTTPREQW;
213 struct _WININETFTPSESSIONW;
217 WININETHANDLEHEADER hdr;
218 struct _WININETFTPSESSIONW *lpFtpSession;
219 BOOL session_deleted;
221 } WININETFTPFILE, *LPWININETFTPFILE;
224 typedef struct _WININETFTPSESSIONW
226 WININETHANDLEHEADER hdr;
227 WININETAPPINFOW *lpAppInfo;
230 int pasvSocket; /* data socket connected by us in case of passive FTP */
231 LPWININETFTPFILE download_in_progress;
232 struct sockaddr_in socketAddress;
233 struct sockaddr_in lstnSocketAddress;
236 } WININETFTPSESSIONW, *LPWININETFTPSESSIONW;
244 struct tm tmLastModified;
245 unsigned short permissions;
246 } FILEPROPERTIESW, *LPFILEPROPERTIESW;
251 WININETHANDLEHEADER hdr;
252 WININETFTPSESSIONW *lpFtpSession;
255 LPFILEPROPERTIESW lpafp;
256 } WININETFTPFINDNEXTW, *LPWININETFTPFINDNEXTW;
258 struct WORKREQ_FTPPUTFILEW
260 LPWSTR lpszLocalFile;
261 LPWSTR lpszNewRemoteFile;
266 struct WORKREQ_FTPSETCURRENTDIRECTORYW
268 LPWSTR lpszDirectory;
271 struct WORKREQ_FTPCREATEDIRECTORYW
273 LPWSTR lpszDirectory;
276 struct WORKREQ_FTPFINDFIRSTFILEW
278 LPWSTR lpszSearchFile;
279 LPWIN32_FIND_DATAW lpFindFileData;
284 struct WORKREQ_FTPGETCURRENTDIRECTORYW
286 LPWSTR lpszDirectory;
287 DWORD *lpdwDirectory;
290 struct WORKREQ_FTPOPENFILEW
298 struct WORKREQ_FTPGETFILEW
300 LPWSTR lpszRemoteFile;
303 DWORD dwLocalFlagsAttribute;
308 struct WORKREQ_FTPDELETEFILEW
313 struct WORKREQ_FTPREMOVEDIRECTORYW
315 LPWSTR lpszDirectory;
318 struct WORKREQ_FTPRENAMEFILEW
324 struct WORKREQ_FTPFINDNEXTW
326 LPWIN32_FIND_DATAW lpFindFileData;
329 struct WORKREQ_HTTPSENDREQUESTW
332 DWORD dwHeaderLength;
334 DWORD dwOptionalLength;
335 DWORD dwContentLength;
339 struct WORKREQ_SENDCALLBACK
342 DWORD dwInternetStatus;
343 LPVOID lpvStatusInfo;
344 DWORD dwStatusInfoLength;
347 struct WORKREQ_INTERNETOPENURLW
352 DWORD dwHeadersLength;
357 struct WORKREQ_INTERNETREADFILEEXA
359 LPINTERNET_BUFFERSA lpBuffersOut;
362 typedef struct WORKREQ
364 void (*asyncproc)(struct WORKREQ*);
365 WININETHANDLEHEADER *hdr;
368 struct WORKREQ_FTPPUTFILEW FtpPutFileW;
369 struct WORKREQ_FTPSETCURRENTDIRECTORYW FtpSetCurrentDirectoryW;
370 struct WORKREQ_FTPCREATEDIRECTORYW FtpCreateDirectoryW;
371 struct WORKREQ_FTPFINDFIRSTFILEW FtpFindFirstFileW;
372 struct WORKREQ_FTPGETCURRENTDIRECTORYW FtpGetCurrentDirectoryW;
373 struct WORKREQ_FTPOPENFILEW FtpOpenFileW;
374 struct WORKREQ_FTPGETFILEW FtpGetFileW;
375 struct WORKREQ_FTPDELETEFILEW FtpDeleteFileW;
376 struct WORKREQ_FTPREMOVEDIRECTORYW FtpRemoveDirectoryW;
377 struct WORKREQ_FTPRENAMEFILEW FtpRenameFileW;
378 struct WORKREQ_FTPFINDNEXTW FtpFindNextW;
379 struct WORKREQ_HTTPSENDREQUESTW HttpSendRequestW;
380 struct WORKREQ_SENDCALLBACK SendCallback;
381 struct WORKREQ_INTERNETOPENURLW InternetOpenUrlW;
382 struct WORKREQ_INTERNETREADFILEEXA InternetReadFileExA;
385 } WORKREQUEST, *LPWORKREQUEST;
387 HINTERNET WININET_AllocHandle( LPWININETHANDLEHEADER info );
388 LPWININETHANDLEHEADER WININET_GetObject( HINTERNET hinternet );
389 LPWININETHANDLEHEADER WININET_AddRef( LPWININETHANDLEHEADER info );
390 BOOL WININET_Release( LPWININETHANDLEHEADER info );
391 BOOL WININET_FreeHandle( HINTERNET hinternet );
393 time_t ConvertTimeString(LPCWSTR asctime);
395 HINTERNET FTP_Connect(LPWININETAPPINFOW hIC, LPCWSTR lpszServerName,
396 INTERNET_PORT nServerPort, LPCWSTR lpszUserName,
397 LPCWSTR lpszPassword, DWORD dwFlags, DWORD dwContext,
398 DWORD dwInternalFlags);
400 HINTERNET HTTP_Connect(LPWININETAPPINFOW hIC, LPCWSTR lpszServerName,
401 INTERNET_PORT nServerPort, LPCWSTR lpszUserName,
402 LPCWSTR lpszPassword, DWORD dwFlags, DWORD dwContext,
403 DWORD dwInternalFlags);
405 BOOL GetAddress(LPCWSTR lpszServerName, INTERNET_PORT nServerPort,
406 struct sockaddr_in *psa);
408 void INTERNET_SetLastError(DWORD dwError);
409 DWORD INTERNET_GetLastError(void);
410 BOOL INTERNET_AsyncCall(LPWORKREQUEST lpWorkRequest);
411 LPSTR INTERNET_GetResponseBuffer(void);
412 LPSTR INTERNET_GetNextLine(INT nSocket, LPDWORD dwLen);
413 BOOL INTERNET_ReadFile(LPWININETHANDLEHEADER lpwh, LPVOID lpBuffer,
414 DWORD dwNumOfBytesToRead, LPDWORD pdwNumOfBytesRead,
415 BOOL bWait, BOOL bSendCompletionStatus);
417 BOOLAPI FTP_FtpPutFileW(LPWININETFTPSESSIONW lpwfs, LPCWSTR lpszLocalFile,
418 LPCWSTR lpszNewRemoteFile, DWORD dwFlags, DWORD dwContext);
419 BOOLAPI FTP_FtpSetCurrentDirectoryW(LPWININETFTPSESSIONW lpwfs, LPCWSTR lpszDirectory);
420 BOOLAPI FTP_FtpCreateDirectoryW(LPWININETFTPSESSIONW lpwfs, LPCWSTR lpszDirectory);
421 INTERNETAPI HINTERNET WINAPI FTP_FtpFindFirstFileW(LPWININETFTPSESSIONW lpwfs,
422 LPCWSTR lpszSearchFile, LPWIN32_FIND_DATAW lpFindFileData, DWORD dwFlags, DWORD dwContext);
423 BOOL WINAPI FTP_FindNextFileW(LPWININETFTPFINDNEXTW lpwh, LPVOID lpvFindData);
424 BOOLAPI FTP_FtpGetCurrentDirectoryW(LPWININETFTPSESSIONW lpwfs, LPWSTR lpszCurrentDirectory,
425 LPDWORD lpdwCurrentDirectory);
426 BOOL FTP_ConvertFileProp(LPFILEPROPERTIESW lpafp, LPWIN32_FIND_DATAW lpFindFileData);
427 BOOL FTP_FtpRenameFileW(LPWININETFTPSESSIONW lpwfs, LPCWSTR lpszSrc, LPCWSTR lpszDest);
428 BOOL FTP_FtpRemoveDirectoryW(LPWININETFTPSESSIONW lpwfs, LPCWSTR lpszDirectory);
429 BOOL FTP_FtpDeleteFileW(LPWININETFTPSESSIONW lpwfs, LPCWSTR lpszFileName);
430 HINTERNET FTP_FtpOpenFileW(LPWININETFTPSESSIONW lpwfs, LPCWSTR lpszFileName,
431 DWORD fdwAccess, DWORD dwFlags, DWORD dwContext);
432 BOOLAPI FTP_FtpGetFileW(LPWININETFTPSESSIONW lpwfs, LPCWSTR lpszRemoteFile, LPCWSTR lpszNewFile,
433 BOOL fFailIfExists, DWORD dwLocalFlagsAttribute, DWORD dwInternetFlags,
436 BOOLAPI HTTP_HttpSendRequestW(LPWININETHTTPREQW lpwhr, LPCWSTR lpszHeaders,
437 DWORD dwHeaderLength, LPVOID lpOptional, DWORD dwOptionalLength,
438 DWORD dwContentLength, BOOL bEndRequest);
439 INTERNETAPI HINTERNET WINAPI HTTP_HttpOpenRequestW(LPWININETHTTPSESSIONW lpwhs,
440 LPCWSTR lpszVerb, LPCWSTR lpszObjectName, LPCWSTR lpszVersion,
441 LPCWSTR lpszReferrer , LPCWSTR *lpszAcceptTypes,
442 DWORD dwFlags, DWORD dwContext);
443 BOOL HTTP_FinishedReading(LPWININETHTTPREQW lpwhr);
445 VOID SendAsyncCallback(LPWININETHANDLEHEADER hdr, DWORD dwContext,
446 DWORD dwInternetStatus, LPVOID lpvStatusInfo,
447 DWORD dwStatusInfoLength);
449 VOID INTERNET_SendCallback(LPWININETHANDLEHEADER hdr, DWORD dwContext,
450 DWORD dwInternetStatus, LPVOID lpvStatusInfo,
451 DWORD dwStatusInfoLength);
453 LPHTTPHEADERW HTTP_GetHeader(LPWININETHTTPREQW lpwhr, LPCWSTR header);
455 BOOL NETCON_connected(WININET_NETCONNECTION *connection);
456 BOOL NETCON_init(WININET_NETCONNECTION *connnection, BOOL useSSL);
457 BOOL NETCON_create(WININET_NETCONNECTION *connection, int domain,
458 int type, int protocol);
459 BOOL NETCON_close(WININET_NETCONNECTION *connection);
460 BOOL NETCON_connect(WININET_NETCONNECTION *connection, const struct sockaddr *serv_addr,
461 unsigned int addrlen);
462 BOOL NETCON_secure_connect(WININET_NETCONNECTION *connection, LPCWSTR hostname);
463 BOOL NETCON_send(WININET_NETCONNECTION *connection, const void *msg, size_t len, int flags,
464 int *sent /* out */);
465 BOOL NETCON_recv(WININET_NETCONNECTION *connection, void *buf, size_t len, int flags,
466 int *recvd /* out */);
467 BOOL NETCON_query_data_available(WININET_NETCONNECTION *connection, DWORD *available);
468 BOOL NETCON_getNextLine(WININET_NETCONNECTION *connection, LPSTR lpszBuffer, LPDWORD dwBuffer);
469 LPCVOID NETCON_GetCert(WININET_NETCONNECTION *connection);
470 BOOL NETCON_set_timeout(WININET_NETCONNECTION *connection, BOOL send, int value);
472 extern void URLCacheContainers_CreateDefaults(void);
473 extern void URLCacheContainers_DeleteAll(void);
475 #define MAX_REPLY_LEN 0x5B4
477 /* Used for debugging - maybe need to be shared in the Wine debugging code ? */
484 #endif /* _WINE_INTERNET_H_ */