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 #include "wine/unicode.h"
32 #ifdef HAVE_NETINET_IN_H
33 # include <sys/types.h>
34 # include <netinet/in.h>
36 #ifdef HAVE_OPENSSL_SSL_H
37 #define DSA __ssl_DSA /* avoid conflict with commctrl.h */
39 # include <openssl/ssl.h>
41 #define FAR do_not_use_this_in_wine
44 #ifdef HAVE_SYS_SOCKET_H
45 # include <sys/socket.h>
48 #if defined(__MINGW32__) || defined (_MSC_VER)
54 #define closesocket close
55 #endif /* __MINGW32__ */
57 /* used for netconnection.c stuff */
62 #ifdef HAVE_OPENSSL_SSL_H
68 } WININET_NETCONNECTION;
70 inline static LPSTR WININET_strdup( LPCSTR str )
72 LPSTR ret = HeapAlloc( GetProcessHeap(), 0, strlen(str) + 1 );
73 if (ret) strcpy( ret, str );
77 inline static LPWSTR WININET_strdupW( LPCWSTR str )
79 LPWSTR ret = HeapAlloc( GetProcessHeap(), 0, (strlenW(str) + 1)*sizeof(WCHAR) );
80 if (ret) strcpyW( ret, str );
84 inline static LPWSTR WININET_strdup_AtoW( LPCSTR str )
86 int len = MultiByteToWideChar( CP_ACP, 0, str, -1, NULL, 0);
87 LPWSTR ret = HeapAlloc( GetProcessHeap(), 0, len * sizeof(WCHAR) );
89 MultiByteToWideChar( CP_ACP, 0, str, -1, ret, len);
93 inline static LPSTR WININET_strdup_WtoA( LPCWSTR str )
95 int len = WideCharToMultiByte( CP_ACP, 0, str, -1, NULL, 0, NULL, NULL);
96 LPSTR ret = HeapAlloc( GetProcessHeap(), 0, len );
98 WideCharToMultiByte( CP_ACP, 0, str, -1, ret, len, NULL, NULL);
102 inline static void WININET_find_data_WtoA(LPWIN32_FIND_DATAW dataW, LPWIN32_FIND_DATAA dataA)
104 dataA->dwFileAttributes = dataW->dwFileAttributes;
105 dataA->ftCreationTime = dataW->ftCreationTime;
106 dataA->ftLastAccessTime = dataW->ftLastAccessTime;
107 dataA->ftLastWriteTime = dataW->ftLastWriteTime;
108 dataA->nFileSizeHigh = dataW->nFileSizeHigh;
109 dataA->nFileSizeLow = dataW->nFileSizeLow;
110 dataA->dwReserved0 = dataW->dwReserved0;
111 dataA->dwReserved1 = dataW->dwReserved1;
112 WideCharToMultiByte(CP_ACP, 0, dataW->cFileName, -1,
113 dataA->cFileName, sizeof(dataA->cFileName),
115 WideCharToMultiByte(CP_ACP, 0, dataW->cAlternateFileName, -1,
116 dataA->cAlternateFileName, sizeof(dataA->cAlternateFileName),
122 WH_HINIT = INTERNET_HANDLE_TYPE_INTERNET,
123 WH_HFTPSESSION = INTERNET_HANDLE_TYPE_CONNECT_FTP,
124 WH_HGOPHERSESSION = INTERNET_HANDLE_TYPE_CONNECT_GOPHER,
125 WH_HHTTPSESSION = INTERNET_HANDLE_TYPE_CONNECT_HTTP,
126 WH_HFILE = INTERNET_HANDLE_TYPE_FTP_FILE,
127 WH_HFTPFINDNEXT = INTERNET_HANDLE_TYPE_FTP_FIND,
128 WH_HHTTPREQ = INTERNET_HANDLE_TYPE_HTTP_REQUEST,
131 #define INET_OPENURL 0x0001
132 #define INET_CALLBACKW 0x0002
134 struct _WININETHANDLEHEADER;
135 typedef struct _WININETHANDLEHEADER WININETHANDLEHEADER, *LPWININETHANDLEHEADER;
137 typedef void (*WININET_object_destructor)( LPWININETHANDLEHEADER );
139 struct _WININETHANDLEHEADER
146 DWORD dwInternalFlags;
148 WININET_object_destructor destroy;
149 INTERNET_STATUS_CALLBACK lpfnStatusCB;
155 WININETHANDLEHEADER hdr;
158 LPWSTR lpszProxyBypass;
159 LPWSTR lpszProxyUsername;
160 LPWSTR lpszProxyPassword;
162 } WININETAPPINFOW, *LPWININETAPPINFOW;
167 WININETHANDLEHEADER hdr;
168 WININETAPPINFOW *lpAppInfo;
169 LPWSTR lpszHostName; /* the final destination of the request */
170 LPWSTR lpszServerName; /* the name of the server we directly connect to */
172 INTERNET_PORT nHostPort; /* the final destination port of the request */
173 INTERNET_PORT nServerPort; /* the port of the server we directly connect to */
174 struct sockaddr_in socketAddress;
175 } WININETHTTPSESSIONW, *LPWININETHTTPSESSIONW;
177 #define HDR_ISREQUEST 0x0001
178 #define HDR_COMMADELIMITED 0x0002
179 #define HDR_SEMIDELIMITED 0x0004
187 } HTTPHEADERW, *LPHTTPHEADERW;
192 WININETHANDLEHEADER hdr;
193 WININETHTTPSESSIONW *lpHttpSession;
196 LPWSTR lpszRawHeaders;
197 WININET_NETCONNECTION netConnection;
199 LPWSTR lpszStatusText;
200 HTTPHEADERW *pCustHeaders;
202 } WININETHTTPREQW, *LPWININETHTTPREQW;
205 struct _WININETFTPSESSIONW;
209 WININETHANDLEHEADER hdr;
210 struct _WININETFTPSESSIONW *lpFtpSession;
211 BOOL session_deleted;
213 } WININETFTPFILE, *LPWININETFTPFILE;
216 typedef struct _WININETFTPSESSIONW
218 WININETHANDLEHEADER hdr;
219 WININETAPPINFOW *lpAppInfo;
222 int pasvSocket; /* data socket connected by us in case of passive FTP */
223 LPWININETFTPFILE download_in_progress;
224 struct sockaddr_in socketAddress;
225 struct sockaddr_in lstnSocketAddress;
228 } WININETFTPSESSIONW, *LPWININETFTPSESSIONW;
236 struct tm tmLastModified;
237 unsigned short permissions;
238 } FILEPROPERTIESW, *LPFILEPROPERTIESW;
243 WININETHANDLEHEADER hdr;
244 WININETFTPSESSIONW *lpFtpSession;
247 LPFILEPROPERTIESW lpafp;
248 } WININETFTPFINDNEXTW, *LPWININETFTPFINDNEXTW;
250 struct WORKREQ_FTPPUTFILEW
252 LPWSTR lpszLocalFile;
253 LPWSTR lpszNewRemoteFile;
258 struct WORKREQ_FTPSETCURRENTDIRECTORYW
260 LPWSTR lpszDirectory;
263 struct WORKREQ_FTPCREATEDIRECTORYW
265 LPWSTR lpszDirectory;
268 struct WORKREQ_FTPFINDFIRSTFILEW
270 LPWSTR lpszSearchFile;
271 LPWIN32_FIND_DATAW lpFindFileData;
276 struct WORKREQ_FTPGETCURRENTDIRECTORYW
278 LPWSTR lpszDirectory;
279 DWORD *lpdwDirectory;
282 struct WORKREQ_FTPOPENFILEW
290 struct WORKREQ_FTPGETFILEW
292 LPWSTR lpszRemoteFile;
295 DWORD dwLocalFlagsAttribute;
300 struct WORKREQ_FTPDELETEFILEW
305 struct WORKREQ_FTPREMOVEDIRECTORYW
307 LPWSTR lpszDirectory;
310 struct WORKREQ_FTPRENAMEFILEW
316 struct WORKREQ_FTPFINDNEXTW
318 LPWIN32_FIND_DATAW lpFindFileData;
321 struct WORKREQ_HTTPSENDREQUESTW
324 DWORD dwHeaderLength;
326 DWORD dwOptionalLength;
327 DWORD dwContentLength;
331 struct WORKREQ_SENDCALLBACK
334 DWORD dwInternetStatus;
335 LPVOID lpvStatusInfo;
336 DWORD dwStatusInfoLength;
339 struct WORKREQ_INTERNETOPENURLW
344 DWORD dwHeadersLength;
349 struct WORKREQ_INTERNETREADFILEEXA
351 LPINTERNET_BUFFERSA lpBuffersOut;
354 typedef struct WORKREQ
356 void (*asyncproc)(struct WORKREQ*);
357 WININETHANDLEHEADER *hdr;
360 struct WORKREQ_FTPPUTFILEW FtpPutFileW;
361 struct WORKREQ_FTPSETCURRENTDIRECTORYW FtpSetCurrentDirectoryW;
362 struct WORKREQ_FTPCREATEDIRECTORYW FtpCreateDirectoryW;
363 struct WORKREQ_FTPFINDFIRSTFILEW FtpFindFirstFileW;
364 struct WORKREQ_FTPGETCURRENTDIRECTORYW FtpGetCurrentDirectoryW;
365 struct WORKREQ_FTPOPENFILEW FtpOpenFileW;
366 struct WORKREQ_FTPGETFILEW FtpGetFileW;
367 struct WORKREQ_FTPDELETEFILEW FtpDeleteFileW;
368 struct WORKREQ_FTPREMOVEDIRECTORYW FtpRemoveDirectoryW;
369 struct WORKREQ_FTPRENAMEFILEW FtpRenameFileW;
370 struct WORKREQ_FTPFINDNEXTW FtpFindNextW;
371 struct WORKREQ_HTTPSENDREQUESTW HttpSendRequestW;
372 struct WORKREQ_SENDCALLBACK SendCallback;
373 struct WORKREQ_INTERNETOPENURLW InternetOpenUrlW;
374 struct WORKREQ_INTERNETREADFILEEXA InternetReadFileExA;
377 struct WORKREQ *next;
378 struct WORKREQ *prev;
380 } WORKREQUEST, *LPWORKREQUEST;
382 HINTERNET WININET_AllocHandle( LPWININETHANDLEHEADER info );
383 LPWININETHANDLEHEADER WININET_GetObject( HINTERNET hinternet );
384 LPWININETHANDLEHEADER WININET_AddRef( LPWININETHANDLEHEADER info );
385 BOOL WININET_Release( LPWININETHANDLEHEADER info );
386 BOOL WININET_FreeHandle( HINTERNET hinternet );
388 time_t ConvertTimeString(LPCWSTR asctime);
390 HINTERNET FTP_Connect(LPWININETAPPINFOW hIC, LPCWSTR lpszServerName,
391 INTERNET_PORT nServerPort, LPCWSTR lpszUserName,
392 LPCWSTR lpszPassword, DWORD dwFlags, DWORD dwContext,
393 DWORD dwInternalFlags);
395 HINTERNET HTTP_Connect(LPWININETAPPINFOW hIC, LPCWSTR lpszServerName,
396 INTERNET_PORT nServerPort, LPCWSTR lpszUserName,
397 LPCWSTR lpszPassword, DWORD dwFlags, DWORD dwContext,
398 DWORD dwInternalFlags);
400 BOOL GetAddress(LPCWSTR lpszServerName, INTERNET_PORT nServerPort,
401 struct sockaddr_in *psa);
403 void INTERNET_SetLastError(DWORD dwError);
404 DWORD INTERNET_GetLastError(void);
405 BOOL INTERNET_AsyncCall(LPWORKREQUEST lpWorkRequest);
406 LPSTR INTERNET_GetResponseBuffer(void);
407 LPSTR INTERNET_GetNextLine(INT nSocket, LPDWORD dwLen);
409 BOOLAPI FTP_FtpPutFileW(LPWININETFTPSESSIONW lpwfs, LPCWSTR lpszLocalFile,
410 LPCWSTR lpszNewRemoteFile, DWORD dwFlags, DWORD dwContext);
411 BOOLAPI FTP_FtpSetCurrentDirectoryW(LPWININETFTPSESSIONW lpwfs, LPCWSTR lpszDirectory);
412 BOOLAPI FTP_FtpCreateDirectoryW(LPWININETFTPSESSIONW lpwfs, LPCWSTR lpszDirectory);
413 INTERNETAPI HINTERNET WINAPI FTP_FtpFindFirstFileW(LPWININETFTPSESSIONW lpwfs,
414 LPCWSTR lpszSearchFile, LPWIN32_FIND_DATAW lpFindFileData, DWORD dwFlags, DWORD dwContext);
415 BOOL WINAPI FTP_FindNextFileW(LPWININETFTPFINDNEXTW lpwh, LPVOID lpvFindData);
416 BOOLAPI FTP_FtpGetCurrentDirectoryW(LPWININETFTPSESSIONW lpwfs, LPWSTR lpszCurrentDirectory,
417 LPDWORD lpdwCurrentDirectory);
418 BOOL FTP_ConvertFileProp(LPFILEPROPERTIESW lpafp, LPWIN32_FIND_DATAW lpFindFileData);
419 BOOL FTP_FtpRenameFileW(LPWININETFTPSESSIONW lpwfs, LPCWSTR lpszSrc, LPCWSTR lpszDest);
420 BOOL FTP_FtpRemoveDirectoryW(LPWININETFTPSESSIONW lpwfs, LPCWSTR lpszDirectory);
421 BOOL FTP_FtpDeleteFileW(LPWININETFTPSESSIONW lpwfs, LPCWSTR lpszFileName);
422 HINTERNET FTP_FtpOpenFileW(LPWININETFTPSESSIONW lpwfs, LPCWSTR lpszFileName,
423 DWORD fdwAccess, DWORD dwFlags, DWORD dwContext);
424 BOOLAPI FTP_FtpGetFileW(LPWININETFTPSESSIONW lpwfs, LPCWSTR lpszRemoteFile, LPCWSTR lpszNewFile,
425 BOOL fFailIfExists, DWORD dwLocalFlagsAttribute, DWORD dwInternetFlags,
428 BOOLAPI HTTP_HttpSendRequestW(LPWININETHTTPREQW lpwhr, LPCWSTR lpszHeaders,
429 DWORD dwHeaderLength, LPVOID lpOptional, DWORD dwOptionalLength,
430 DWORD dwContentLength, BOOL bEndRequest);
431 INTERNETAPI HINTERNET WINAPI HTTP_HttpOpenRequestW(LPWININETHTTPSESSIONW lpwhs,
432 LPCWSTR lpszVerb, LPCWSTR lpszObjectName, LPCWSTR lpszVersion,
433 LPCWSTR lpszReferrer , LPCWSTR *lpszAcceptTypes,
434 DWORD dwFlags, DWORD dwContext);
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_ */