mshtml: Added nsINetUtil interface to nsIOService.
[wine/winequartzdrv.git] / dlls / wininet / internet.h
blobb80de883b6e7b852b4fbc03fbd36e2cd032dd0b0
1 /*
2 * Wininet
4 * Copyright 1999 Corel Corporation
6 * Ulrich Czekalla
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
28 #endif
30 #include "wine/unicode.h"
31 #include "wine/list.h"
33 #include <time.h>
34 #ifdef HAVE_NETDB_H
35 # include <netdb.h>
36 #endif
37 #ifdef HAVE_NETINET_IN_H
38 # include <sys/types.h>
39 # include <netinet/in.h>
40 #endif
41 #ifdef HAVE_OPENSSL_SSL_H
42 #define DSA __ssl_DSA /* avoid conflict with commctrl.h */
43 #undef FAR
44 /* avoid conflict with wincrypt.h */
45 #undef PKCS7_SIGNER_INFO
46 #undef X509_NAME
47 #undef X509_CERT_PAIR
48 # include <openssl/ssl.h>
49 #undef FAR
50 #define FAR do_not_use_this_in_wine
51 #undef DSA
52 #endif
53 #ifdef HAVE_SYS_SOCKET_H
54 # include <sys/socket.h>
55 #endif
57 #if defined(__MINGW32__) || defined (_MSC_VER)
58 #include "winsock2.h"
59 #ifndef MSG_WAITALL
60 #define MSG_WAITALL 0
61 #endif
62 #else
63 #define closesocket close
64 #endif /* __MINGW32__ */
66 /* used for netconnection.c stuff */
67 typedef struct
69 BOOL useSSL;
70 int socketFD;
71 #ifdef HAVE_OPENSSL_SSL_H
72 SSL *ssl_s;
73 char *peek_msg;
74 char *peek_msg_mem;
75 size_t peek_len;
76 #endif
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 );
83 return ret;
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) );
90 if (ret)
91 MultiByteToWideChar( CP_ACP, 0, str, -1, ret, len);
92 return ret;
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 );
99 if (ret)
100 WideCharToMultiByte( CP_ACP, 0, str, -1, ret, len, NULL, NULL);
101 return ret;
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),
116 NULL, NULL);
117 WideCharToMultiByte(CP_ACP, 0, dataW->cAlternateFileName, -1,
118 dataA->cAlternateFileName, sizeof(dataA->cAlternateFileName),
119 NULL, NULL);
122 typedef enum
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,
131 } WH_TYPE;
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
143 WH_TYPE htype;
144 HINTERNET hInternet;
145 DWORD dwFlags;
146 DWORD_PTR dwContext;
147 DWORD dwError;
148 DWORD dwInternalFlags;
149 DWORD dwRefCount;
150 WININET_object_function close_connection;
151 WININET_object_function destroy;
152 INTERNET_STATUS_CALLBACK lpfnStatusCB;
153 struct list entry;
154 struct list children;
158 typedef struct
160 WININETHANDLEHEADER hdr;
161 LPWSTR lpszAgent;
162 LPWSTR lpszProxy;
163 LPWSTR lpszProxyBypass;
164 LPWSTR lpszProxyUsername;
165 LPWSTR lpszProxyPassword;
166 DWORD dwAccessType;
167 } WININETAPPINFOW, *LPWININETAPPINFOW;
170 typedef struct
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 */
176 LPWSTR lpszUserName;
177 LPWSTR lpszPassword;
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
187 typedef struct
189 LPWSTR lpszField;
190 LPWSTR lpszValue;
191 WORD wFlags;
192 WORD wCount;
193 } HTTPHEADERW, *LPHTTPHEADERW;
196 struct HttpAuthInfo;
198 typedef struct
200 WININETHANDLEHEADER hdr;
201 WININETHTTPSESSIONW *lpHttpSession;
202 LPWSTR lpszPath;
203 LPWSTR lpszVerb;
204 LPWSTR lpszRawHeaders;
205 WININET_NETCONNECTION netConnection;
206 LPWSTR lpszVersion;
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;
211 DWORD nCustHeaders;
212 HANDLE hCacheFile;
213 LPWSTR lpszCacheFile;
214 struct HttpAuthInfo *pAuthInfo;
215 struct HttpAuthInfo *pProxyAuthInfo;
216 } WININETHTTPREQW, *LPWININETHTTPREQW;
219 struct _WININETFTPSESSIONW;
221 typedef struct
223 WININETHANDLEHEADER hdr;
224 struct _WININETFTPSESSIONW *lpFtpSession;
225 BOOL session_deleted;
226 int nDataSocket;
227 } WININETFTPFILE, *LPWININETFTPFILE;
230 typedef struct _WININETFTPSESSIONW
232 WININETHANDLEHEADER hdr;
233 WININETAPPINFOW *lpAppInfo;
234 int sndSocket;
235 int lstnSocket;
236 int pasvSocket; /* data socket connected by us in case of passive FTP */
237 LPWININETFTPFILE download_in_progress;
238 struct sockaddr_in socketAddress;
239 struct sockaddr_in lstnSocketAddress;
240 LPWSTR lpszPassword;
241 LPWSTR lpszUserName;
242 } WININETFTPSESSIONW, *LPWININETFTPSESSIONW;
245 typedef struct
247 BOOL bIsDirectory;
248 LPWSTR lpszName;
249 DWORD nSize;
250 struct tm tmLastModified;
251 unsigned short permissions;
252 } FILEPROPERTIESW, *LPFILEPROPERTIESW;
255 typedef struct
257 WININETHANDLEHEADER hdr;
258 WININETFTPSESSIONW *lpFtpSession;
259 DWORD index;
260 DWORD size;
261 LPFILEPROPERTIESW lpafp;
262 } WININETFTPFINDNEXTW, *LPWININETFTPFINDNEXTW;
264 struct WORKREQ_FTPPUTFILEW
266 LPWSTR lpszLocalFile;
267 LPWSTR lpszNewRemoteFile;
268 DWORD dwFlags;
269 DWORD_PTR dwContext;
272 struct WORKREQ_FTPSETCURRENTDIRECTORYW
274 LPWSTR lpszDirectory;
277 struct WORKREQ_FTPCREATEDIRECTORYW
279 LPWSTR lpszDirectory;
282 struct WORKREQ_FTPFINDFIRSTFILEW
284 LPWSTR lpszSearchFile;
285 LPWIN32_FIND_DATAW lpFindFileData;
286 DWORD dwFlags;
287 DWORD_PTR dwContext;
290 struct WORKREQ_FTPGETCURRENTDIRECTORYW
292 LPWSTR lpszDirectory;
293 DWORD *lpdwDirectory;
296 struct WORKREQ_FTPOPENFILEW
298 LPWSTR lpszFilename;
299 DWORD dwAccess;
300 DWORD dwFlags;
301 DWORD_PTR dwContext;
304 struct WORKREQ_FTPGETFILEW
306 LPWSTR lpszRemoteFile;
307 LPWSTR lpszNewFile;
308 BOOL fFailIfExists;
309 DWORD dwLocalFlagsAttribute;
310 DWORD dwFlags;
311 DWORD_PTR dwContext;
314 struct WORKREQ_FTPDELETEFILEW
316 LPWSTR lpszFilename;
319 struct WORKREQ_FTPREMOVEDIRECTORYW
321 LPWSTR lpszDirectory;
324 struct WORKREQ_FTPRENAMEFILEW
326 LPWSTR lpszSrcFile;
327 LPWSTR lpszDestFile;
330 struct WORKREQ_FTPFINDNEXTW
332 LPWIN32_FIND_DATAW lpFindFileData;
335 struct WORKREQ_HTTPSENDREQUESTW
337 LPWSTR lpszHeader;
338 DWORD dwHeaderLength;
339 LPVOID lpOptional;
340 DWORD dwOptionalLength;
341 DWORD dwContentLength;
342 BOOL bEndRequest;
345 struct WORKREQ_SENDCALLBACK
347 DWORD_PTR dwContext;
348 DWORD dwInternetStatus;
349 LPVOID lpvStatusInfo;
350 DWORD dwStatusInfoLength;
353 struct WORKREQ_INTERNETOPENURLW
355 HINTERNET hInternet;
356 LPWSTR lpszUrl;
357 LPWSTR lpszHeaders;
358 DWORD dwHeadersLength;
359 DWORD dwFlags;
360 DWORD_PTR dwContext;
363 struct WORKREQ_INTERNETREADFILEEXA
365 LPINTERNET_BUFFERSA lpBuffersOut;
368 typedef struct WORKREQ
370 void (*asyncproc)(struct WORKREQ*);
371 WININETHANDLEHEADER *hdr;
373 union {
374 struct WORKREQ_FTPPUTFILEW FtpPutFileW;
375 struct WORKREQ_FTPSETCURRENTDIRECTORYW FtpSetCurrentDirectoryW;
376 struct WORKREQ_FTPCREATEDIRECTORYW FtpCreateDirectoryW;
377 struct WORKREQ_FTPFINDFIRSTFILEW FtpFindFirstFileW;
378 struct WORKREQ_FTPGETCURRENTDIRECTORYW FtpGetCurrentDirectoryW;
379 struct WORKREQ_FTPOPENFILEW FtpOpenFileW;
380 struct WORKREQ_FTPGETFILEW FtpGetFileW;
381 struct WORKREQ_FTPDELETEFILEW FtpDeleteFileW;
382 struct WORKREQ_FTPREMOVEDIRECTORYW FtpRemoveDirectoryW;
383 struct WORKREQ_FTPRENAMEFILEW FtpRenameFileW;
384 struct WORKREQ_FTPFINDNEXTW FtpFindNextW;
385 struct WORKREQ_HTTPSENDREQUESTW HttpSendRequestW;
386 struct WORKREQ_SENDCALLBACK SendCallback;
387 struct WORKREQ_INTERNETOPENURLW InternetOpenUrlW;
388 struct WORKREQ_INTERNETREADFILEEXA InternetReadFileExA;
389 } u;
391 } WORKREQUEST, *LPWORKREQUEST;
393 HINTERNET WININET_AllocHandle( LPWININETHANDLEHEADER info );
394 LPWININETHANDLEHEADER WININET_GetObject( HINTERNET hinternet );
395 LPWININETHANDLEHEADER WININET_AddRef( LPWININETHANDLEHEADER info );
396 BOOL WININET_Release( LPWININETHANDLEHEADER info );
397 BOOL WININET_FreeHandle( HINTERNET hinternet );
399 time_t ConvertTimeString(LPCWSTR asctime);
401 HINTERNET FTP_Connect(LPWININETAPPINFOW hIC, LPCWSTR lpszServerName,
402 INTERNET_PORT nServerPort, LPCWSTR lpszUserName,
403 LPCWSTR lpszPassword, DWORD dwFlags, DWORD_PTR dwContext,
404 DWORD dwInternalFlags);
406 HINTERNET HTTP_Connect(LPWININETAPPINFOW hIC, LPCWSTR lpszServerName,
407 INTERNET_PORT nServerPort, LPCWSTR lpszUserName,
408 LPCWSTR lpszPassword, DWORD dwFlags, DWORD_PTR dwContext,
409 DWORD dwInternalFlags);
411 BOOL GetAddress(LPCWSTR lpszServerName, INTERNET_PORT nServerPort,
412 struct sockaddr_in *psa);
414 void INTERNET_SetLastError(DWORD dwError);
415 DWORD INTERNET_GetLastError(void);
416 BOOL INTERNET_AsyncCall(LPWORKREQUEST lpWorkRequest);
417 LPSTR INTERNET_GetResponseBuffer(void);
418 LPSTR INTERNET_GetNextLine(INT nSocket, LPDWORD dwLen);
419 BOOL INTERNET_ReadFile(LPWININETHANDLEHEADER lpwh, LPVOID lpBuffer,
420 DWORD dwNumOfBytesToRead, LPDWORD pdwNumOfBytesRead,
421 BOOL bWait, BOOL bSendCompletionStatus);
423 BOOLAPI FTP_FtpPutFileW(LPWININETFTPSESSIONW lpwfs, LPCWSTR lpszLocalFile,
424 LPCWSTR lpszNewRemoteFile, DWORD dwFlags, DWORD_PTR dwContext);
425 BOOLAPI FTP_FtpSetCurrentDirectoryW(LPWININETFTPSESSIONW lpwfs, LPCWSTR lpszDirectory);
426 BOOLAPI FTP_FtpCreateDirectoryW(LPWININETFTPSESSIONW lpwfs, LPCWSTR lpszDirectory);
427 INTERNETAPI HINTERNET WINAPI FTP_FtpFindFirstFileW(LPWININETFTPSESSIONW lpwfs,
428 LPCWSTR lpszSearchFile, LPWIN32_FIND_DATAW lpFindFileData, DWORD dwFlags, DWORD_PTR dwContext);
429 BOOL WINAPI FTP_FindNextFileW(LPWININETFTPFINDNEXTW lpwh, LPVOID lpvFindData);
430 BOOLAPI FTP_FtpGetCurrentDirectoryW(LPWININETFTPSESSIONW lpwfs, LPWSTR lpszCurrentDirectory,
431 LPDWORD lpdwCurrentDirectory);
432 BOOL FTP_ConvertFileProp(LPFILEPROPERTIESW lpafp, LPWIN32_FIND_DATAW lpFindFileData);
433 BOOL FTP_FtpRenameFileW(LPWININETFTPSESSIONW lpwfs, LPCWSTR lpszSrc, LPCWSTR lpszDest);
434 BOOL FTP_FtpRemoveDirectoryW(LPWININETFTPSESSIONW lpwfs, LPCWSTR lpszDirectory);
435 BOOL FTP_FtpDeleteFileW(LPWININETFTPSESSIONW lpwfs, LPCWSTR lpszFileName);
436 HINTERNET FTP_FtpOpenFileW(LPWININETFTPSESSIONW lpwfs, LPCWSTR lpszFileName,
437 DWORD fdwAccess, DWORD dwFlags, DWORD_PTR dwContext);
438 BOOLAPI FTP_FtpGetFileW(LPWININETFTPSESSIONW lpwfs, LPCWSTR lpszRemoteFile, LPCWSTR lpszNewFile,
439 BOOL fFailIfExists, DWORD dwLocalFlagsAttribute, DWORD dwInternetFlags,
440 DWORD_PTR dwContext);
442 BOOLAPI HTTP_HttpSendRequestW(LPWININETHTTPREQW lpwhr, LPCWSTR lpszHeaders,
443 DWORD dwHeaderLength, LPVOID lpOptional, DWORD dwOptionalLength,
444 DWORD dwContentLength, BOOL bEndRequest);
445 INTERNETAPI HINTERNET WINAPI HTTP_HttpOpenRequestW(LPWININETHTTPSESSIONW lpwhs,
446 LPCWSTR lpszVerb, LPCWSTR lpszObjectName, LPCWSTR lpszVersion,
447 LPCWSTR lpszReferrer , LPCWSTR *lpszAcceptTypes,
448 DWORD dwFlags, DWORD_PTR dwContext);
449 BOOL HTTP_FinishedReading(LPWININETHTTPREQW lpwhr);
451 VOID SendAsyncCallback(LPWININETHANDLEHEADER hdr, DWORD_PTR dwContext,
452 DWORD dwInternetStatus, LPVOID lpvStatusInfo,
453 DWORD dwStatusInfoLength);
455 VOID INTERNET_SendCallback(LPWININETHANDLEHEADER hdr, DWORD_PTR dwContext,
456 DWORD dwInternetStatus, LPVOID lpvStatusInfo,
457 DWORD dwStatusInfoLength);
459 LPHTTPHEADERW HTTP_GetHeader(LPWININETHTTPREQW lpwhr, LPCWSTR header);
461 BOOL NETCON_connected(WININET_NETCONNECTION *connection);
462 BOOL NETCON_init(WININET_NETCONNECTION *connnection, BOOL useSSL);
463 BOOL NETCON_create(WININET_NETCONNECTION *connection, int domain,
464 int type, int protocol);
465 BOOL NETCON_close(WININET_NETCONNECTION *connection);
466 BOOL NETCON_connect(WININET_NETCONNECTION *connection, const struct sockaddr *serv_addr,
467 unsigned int addrlen);
468 BOOL NETCON_secure_connect(WININET_NETCONNECTION *connection, LPCWSTR hostname);
469 BOOL NETCON_send(WININET_NETCONNECTION *connection, const void *msg, size_t len, int flags,
470 int *sent /* out */);
471 BOOL NETCON_recv(WININET_NETCONNECTION *connection, void *buf, size_t len, int flags,
472 int *recvd /* out */);
473 BOOL NETCON_query_data_available(WININET_NETCONNECTION *connection, DWORD *available);
474 BOOL NETCON_getNextLine(WININET_NETCONNECTION *connection, LPSTR lpszBuffer, LPDWORD dwBuffer);
475 LPCVOID NETCON_GetCert(WININET_NETCONNECTION *connection);
476 BOOL NETCON_set_timeout(WININET_NETCONNECTION *connection, BOOL send, int value);
478 extern void URLCacheContainers_CreateDefaults(void);
479 extern void URLCacheContainers_DeleteAll(void);
481 #define MAX_REPLY_LEN 0x5B4
483 /* Used for debugging - maybe need to be shared in the Wine debugging code ? */
484 typedef struct
486 DWORD val;
487 const char* name;
488 } wininet_flag_info;
490 #endif /* _WINE_INTERNET_H_ */