push 599a9d3db769aad8dabfd10a59120f719b00f4ee
[wine/hacks.git] / dlls / wininet / internet.h
blob42ade48353f8e09265dc19d8132928ff12fceb29
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"
32 #include <time.h>
33 #ifdef HAVE_NETDB_H
34 # include <netdb.h>
35 #endif
36 #ifdef HAVE_NETINET_IN_H
37 # include <sys/types.h>
38 # include <netinet/in.h>
39 #endif
40 #ifdef HAVE_OPENSSL_SSL_H
41 #define DSA __ssl_DSA /* avoid conflict with commctrl.h */
42 #undef FAR
43 /* avoid conflict with wincrypt.h */
44 #undef PKCS7_SIGNER_INFO
45 #undef X509_NAME
46 #undef X509_CERT_PAIR
47 # include <openssl/ssl.h>
48 #undef FAR
49 #define FAR do_not_use_this_in_wine
50 #undef DSA
51 #endif
52 #ifdef HAVE_SYS_SOCKET_H
53 # include <sys/socket.h>
54 #endif
56 #if defined(__MINGW32__) || defined (_MSC_VER)
57 #include "winsock2.h"
58 #ifndef MSG_WAITALL
59 #define MSG_WAITALL 0
60 #endif
61 #else
62 #define closesocket close
63 #endif /* __MINGW32__ */
65 /* used for netconnection.c stuff */
66 typedef struct
68 BOOL useSSL;
69 int socketFD;
70 #ifdef HAVE_OPENSSL_SSL_H
71 SSL *ssl_s;
72 char *peek_msg;
73 char *peek_msg_mem;
74 size_t peek_len;
75 #endif
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 );
82 return ret;
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) );
89 if (ret)
90 MultiByteToWideChar( CP_ACP, 0, str, -1, ret, len);
91 return ret;
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 );
98 if (ret)
99 WideCharToMultiByte( CP_ACP, 0, str, -1, ret, len, NULL, NULL);
100 return ret;
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),
115 NULL, NULL);
116 WideCharToMultiByte(CP_ACP, 0, dataW->cAlternateFileName, -1,
117 dataA->cAlternateFileName, sizeof(dataA->cAlternateFileName),
118 NULL, NULL);
121 typedef enum
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,
130 } WH_TYPE;
132 #define INET_OPENURL 0x0001
133 #define INET_CALLBACKW 0x0002
135 struct _WININETHANDLEHEADER;
136 typedef struct _WININETHANDLEHEADER WININETHANDLEHEADER, *LPWININETHANDLEHEADER;
138 typedef void (*WININET_object_function)( LPWININETHANDLEHEADER );
140 struct _WININETHANDLEHEADER
142 WH_TYPE htype;
143 HINTERNET hInternet;
144 DWORD dwFlags;
145 DWORD dwContext;
146 DWORD dwError;
147 DWORD dwInternalFlags;
148 DWORD dwRefCount;
149 WININET_object_function close_connection;
150 WININET_object_function destroy;
151 INTERNET_STATUS_CALLBACK lpfnStatusCB;
155 typedef struct
157 WININETHANDLEHEADER hdr;
158 LPWSTR lpszAgent;
159 LPWSTR lpszProxy;
160 LPWSTR lpszProxyBypass;
161 LPWSTR lpszProxyUsername;
162 LPWSTR lpszProxyPassword;
163 DWORD dwAccessType;
164 } WININETAPPINFOW, *LPWININETAPPINFOW;
167 typedef struct
169 WININETHANDLEHEADER hdr;
170 WININETAPPINFOW *lpAppInfo;
171 LPWSTR lpszHostName; /* the final destination of the request */
172 LPWSTR lpszServerName; /* the name of the server we directly connect to */
173 LPWSTR lpszUserName;
174 LPWSTR lpszPassword;
175 INTERNET_PORT nHostPort; /* the final destination port of the request */
176 INTERNET_PORT nServerPort; /* the port of the server we directly connect to */
177 struct sockaddr_in socketAddress;
178 } WININETHTTPSESSIONW, *LPWININETHTTPSESSIONW;
180 #define HDR_ISREQUEST 0x0001
181 #define HDR_COMMADELIMITED 0x0002
182 #define HDR_SEMIDELIMITED 0x0004
184 typedef struct
186 LPWSTR lpszField;
187 LPWSTR lpszValue;
188 WORD wFlags;
189 WORD wCount;
190 } HTTPHEADERW, *LPHTTPHEADERW;
193 struct HttpAuthInfo;
195 typedef struct
197 WININETHANDLEHEADER hdr;
198 WININETHTTPSESSIONW *lpHttpSession;
199 LPWSTR lpszPath;
200 LPWSTR lpszVerb;
201 LPWSTR lpszRawHeaders;
202 WININET_NETCONNECTION netConnection;
203 LPWSTR lpszVersion;
204 LPWSTR lpszStatusText;
205 DWORD dwContentLength; /* total number of bytes to be read */
206 DWORD dwContentRead; /* bytes of the content read so far */
207 HTTPHEADERW *pCustHeaders;
208 DWORD nCustHeaders;
209 struct HttpAuthInfo *pAuthInfo;
210 struct HttpAuthInfo *pProxyAuthInfo;
211 } WININETHTTPREQW, *LPWININETHTTPREQW;
214 struct _WININETFTPSESSIONW;
216 typedef struct
218 WININETHANDLEHEADER hdr;
219 struct _WININETFTPSESSIONW *lpFtpSession;
220 BOOL session_deleted;
221 int nDataSocket;
222 } WININETFTPFILE, *LPWININETFTPFILE;
225 typedef struct _WININETFTPSESSIONW
227 WININETHANDLEHEADER hdr;
228 WININETAPPINFOW *lpAppInfo;
229 int sndSocket;
230 int lstnSocket;
231 int pasvSocket; /* data socket connected by us in case of passive FTP */
232 LPWININETFTPFILE download_in_progress;
233 struct sockaddr_in socketAddress;
234 struct sockaddr_in lstnSocketAddress;
235 LPWSTR lpszPassword;
236 LPWSTR lpszUserName;
237 } WININETFTPSESSIONW, *LPWININETFTPSESSIONW;
240 typedef struct
242 BOOL bIsDirectory;
243 LPWSTR lpszName;
244 DWORD nSize;
245 struct tm tmLastModified;
246 unsigned short permissions;
247 } FILEPROPERTIESW, *LPFILEPROPERTIESW;
250 typedef struct
252 WININETHANDLEHEADER hdr;
253 WININETFTPSESSIONW *lpFtpSession;
254 DWORD index;
255 DWORD size;
256 LPFILEPROPERTIESW lpafp;
257 } WININETFTPFINDNEXTW, *LPWININETFTPFINDNEXTW;
259 struct WORKREQ_FTPPUTFILEW
261 LPWSTR lpszLocalFile;
262 LPWSTR lpszNewRemoteFile;
263 DWORD dwFlags;
264 DWORD dwContext;
267 struct WORKREQ_FTPSETCURRENTDIRECTORYW
269 LPWSTR lpszDirectory;
272 struct WORKREQ_FTPCREATEDIRECTORYW
274 LPWSTR lpszDirectory;
277 struct WORKREQ_FTPFINDFIRSTFILEW
279 LPWSTR lpszSearchFile;
280 LPWIN32_FIND_DATAW lpFindFileData;
281 DWORD dwFlags;
282 DWORD dwContext;
285 struct WORKREQ_FTPGETCURRENTDIRECTORYW
287 LPWSTR lpszDirectory;
288 DWORD *lpdwDirectory;
291 struct WORKREQ_FTPOPENFILEW
293 LPWSTR lpszFilename;
294 DWORD dwAccess;
295 DWORD dwFlags;
296 DWORD dwContext;
299 struct WORKREQ_FTPGETFILEW
301 LPWSTR lpszRemoteFile;
302 LPWSTR lpszNewFile;
303 BOOL fFailIfExists;
304 DWORD dwLocalFlagsAttribute;
305 DWORD dwFlags;
306 DWORD dwContext;
309 struct WORKREQ_FTPDELETEFILEW
311 LPWSTR lpszFilename;
314 struct WORKREQ_FTPREMOVEDIRECTORYW
316 LPWSTR lpszDirectory;
319 struct WORKREQ_FTPRENAMEFILEW
321 LPWSTR lpszSrcFile;
322 LPWSTR lpszDestFile;
325 struct WORKREQ_FTPFINDNEXTW
327 LPWIN32_FIND_DATAW lpFindFileData;
330 struct WORKREQ_HTTPSENDREQUESTW
332 LPWSTR lpszHeader;
333 DWORD dwHeaderLength;
334 LPVOID lpOptional;
335 DWORD dwOptionalLength;
336 DWORD dwContentLength;
337 BOOL bEndRequest;
340 struct WORKREQ_SENDCALLBACK
342 DWORD dwContext;
343 DWORD dwInternetStatus;
344 LPVOID lpvStatusInfo;
345 DWORD dwStatusInfoLength;
348 struct WORKREQ_INTERNETOPENURLW
350 HINTERNET hInternet;
351 LPWSTR lpszUrl;
352 LPWSTR lpszHeaders;
353 DWORD dwHeadersLength;
354 DWORD dwFlags;
355 DWORD dwContext;
358 struct WORKREQ_INTERNETREADFILEEXA
360 LPINTERNET_BUFFERSA lpBuffersOut;
363 typedef struct WORKREQ
365 void (*asyncproc)(struct WORKREQ*);
366 WININETHANDLEHEADER *hdr;
368 union {
369 struct WORKREQ_FTPPUTFILEW FtpPutFileW;
370 struct WORKREQ_FTPSETCURRENTDIRECTORYW FtpSetCurrentDirectoryW;
371 struct WORKREQ_FTPCREATEDIRECTORYW FtpCreateDirectoryW;
372 struct WORKREQ_FTPFINDFIRSTFILEW FtpFindFirstFileW;
373 struct WORKREQ_FTPGETCURRENTDIRECTORYW FtpGetCurrentDirectoryW;
374 struct WORKREQ_FTPOPENFILEW FtpOpenFileW;
375 struct WORKREQ_FTPGETFILEW FtpGetFileW;
376 struct WORKREQ_FTPDELETEFILEW FtpDeleteFileW;
377 struct WORKREQ_FTPREMOVEDIRECTORYW FtpRemoveDirectoryW;
378 struct WORKREQ_FTPRENAMEFILEW FtpRenameFileW;
379 struct WORKREQ_FTPFINDNEXTW FtpFindNextW;
380 struct WORKREQ_HTTPSENDREQUESTW HttpSendRequestW;
381 struct WORKREQ_SENDCALLBACK SendCallback;
382 struct WORKREQ_INTERNETOPENURLW InternetOpenUrlW;
383 struct WORKREQ_INTERNETREADFILEEXA InternetReadFileExA;
384 } u;
386 } WORKREQUEST, *LPWORKREQUEST;
388 HINTERNET WININET_AllocHandle( LPWININETHANDLEHEADER info );
389 LPWININETHANDLEHEADER WININET_GetObject( HINTERNET hinternet );
390 LPWININETHANDLEHEADER WININET_AddRef( LPWININETHANDLEHEADER info );
391 BOOL WININET_Release( LPWININETHANDLEHEADER info );
392 BOOL WININET_FreeHandle( HINTERNET hinternet );
394 time_t ConvertTimeString(LPCWSTR asctime);
396 HINTERNET FTP_Connect(LPWININETAPPINFOW hIC, LPCWSTR lpszServerName,
397 INTERNET_PORT nServerPort, LPCWSTR lpszUserName,
398 LPCWSTR lpszPassword, DWORD dwFlags, DWORD dwContext,
399 DWORD dwInternalFlags);
401 HINTERNET HTTP_Connect(LPWININETAPPINFOW hIC, LPCWSTR lpszServerName,
402 INTERNET_PORT nServerPort, LPCWSTR lpszUserName,
403 LPCWSTR lpszPassword, DWORD dwFlags, DWORD dwContext,
404 DWORD dwInternalFlags);
406 BOOL GetAddress(LPCWSTR lpszServerName, INTERNET_PORT nServerPort,
407 struct sockaddr_in *psa);
409 void INTERNET_SetLastError(DWORD dwError);
410 DWORD INTERNET_GetLastError(void);
411 BOOL INTERNET_AsyncCall(LPWORKREQUEST lpWorkRequest);
412 LPSTR INTERNET_GetResponseBuffer(void);
413 LPSTR INTERNET_GetNextLine(INT nSocket, LPDWORD dwLen);
414 BOOL INTERNET_ReadFile(LPWININETHANDLEHEADER lpwh, LPVOID lpBuffer,
415 DWORD dwNumOfBytesToRead, LPDWORD pdwNumOfBytesRead,
416 BOOL bWait, BOOL bSendCompletionStatus);
418 BOOLAPI FTP_FtpPutFileW(LPWININETFTPSESSIONW lpwfs, LPCWSTR lpszLocalFile,
419 LPCWSTR lpszNewRemoteFile, DWORD dwFlags, DWORD dwContext);
420 BOOLAPI FTP_FtpSetCurrentDirectoryW(LPWININETFTPSESSIONW lpwfs, LPCWSTR lpszDirectory);
421 BOOLAPI FTP_FtpCreateDirectoryW(LPWININETFTPSESSIONW lpwfs, LPCWSTR lpszDirectory);
422 INTERNETAPI HINTERNET WINAPI FTP_FtpFindFirstFileW(LPWININETFTPSESSIONW lpwfs,
423 LPCWSTR lpszSearchFile, LPWIN32_FIND_DATAW lpFindFileData, DWORD dwFlags, DWORD dwContext);
424 BOOL WINAPI FTP_FindNextFileW(LPWININETFTPFINDNEXTW lpwh, LPVOID lpvFindData);
425 BOOLAPI FTP_FtpGetCurrentDirectoryW(LPWININETFTPSESSIONW lpwfs, LPWSTR lpszCurrentDirectory,
426 LPDWORD lpdwCurrentDirectory);
427 BOOL FTP_ConvertFileProp(LPFILEPROPERTIESW lpafp, LPWIN32_FIND_DATAW lpFindFileData);
428 BOOL FTP_FtpRenameFileW(LPWININETFTPSESSIONW lpwfs, LPCWSTR lpszSrc, LPCWSTR lpszDest);
429 BOOL FTP_FtpRemoveDirectoryW(LPWININETFTPSESSIONW lpwfs, LPCWSTR lpszDirectory);
430 BOOL FTP_FtpDeleteFileW(LPWININETFTPSESSIONW lpwfs, LPCWSTR lpszFileName);
431 HINTERNET FTP_FtpOpenFileW(LPWININETFTPSESSIONW lpwfs, LPCWSTR lpszFileName,
432 DWORD fdwAccess, DWORD dwFlags, DWORD dwContext);
433 BOOLAPI FTP_FtpGetFileW(LPWININETFTPSESSIONW lpwfs, LPCWSTR lpszRemoteFile, LPCWSTR lpszNewFile,
434 BOOL fFailIfExists, DWORD dwLocalFlagsAttribute, DWORD dwInternetFlags,
435 DWORD dwContext);
437 BOOLAPI HTTP_HttpSendRequestW(LPWININETHTTPREQW lpwhr, LPCWSTR lpszHeaders,
438 DWORD dwHeaderLength, LPVOID lpOptional, DWORD dwOptionalLength,
439 DWORD dwContentLength, BOOL bEndRequest);
440 INTERNETAPI HINTERNET WINAPI HTTP_HttpOpenRequestW(LPWININETHTTPSESSIONW lpwhs,
441 LPCWSTR lpszVerb, LPCWSTR lpszObjectName, LPCWSTR lpszVersion,
442 LPCWSTR lpszReferrer , LPCWSTR *lpszAcceptTypes,
443 DWORD dwFlags, DWORD dwContext);
444 BOOL HTTP_FinishedReading(LPWININETHTTPREQW lpwhr);
446 VOID SendAsyncCallback(LPWININETHANDLEHEADER hdr, DWORD dwContext,
447 DWORD dwInternetStatus, LPVOID lpvStatusInfo,
448 DWORD dwStatusInfoLength);
450 VOID INTERNET_SendCallback(LPWININETHANDLEHEADER hdr, DWORD dwContext,
451 DWORD dwInternetStatus, LPVOID lpvStatusInfo,
452 DWORD dwStatusInfoLength);
454 LPHTTPHEADERW HTTP_GetHeader(LPWININETHTTPREQW lpwhr, LPCWSTR header);
456 BOOL NETCON_connected(WININET_NETCONNECTION *connection);
457 BOOL NETCON_init(WININET_NETCONNECTION *connnection, BOOL useSSL);
458 BOOL NETCON_create(WININET_NETCONNECTION *connection, int domain,
459 int type, int protocol);
460 BOOL NETCON_close(WININET_NETCONNECTION *connection);
461 BOOL NETCON_connect(WININET_NETCONNECTION *connection, const struct sockaddr *serv_addr,
462 unsigned int addrlen);
463 BOOL NETCON_secure_connect(WININET_NETCONNECTION *connection, LPCWSTR hostname);
464 BOOL NETCON_send(WININET_NETCONNECTION *connection, const void *msg, size_t len, int flags,
465 int *sent /* out */);
466 BOOL NETCON_recv(WININET_NETCONNECTION *connection, void *buf, size_t len, int flags,
467 int *recvd /* out */);
468 BOOL NETCON_query_data_available(WININET_NETCONNECTION *connection, DWORD *available);
469 BOOL NETCON_getNextLine(WININET_NETCONNECTION *connection, LPSTR lpszBuffer, LPDWORD dwBuffer);
470 LPCVOID NETCON_GetCert(WININET_NETCONNECTION *connection);
471 BOOL NETCON_set_timeout(WININET_NETCONNECTION *connection, BOOL send, int value);
473 extern void URLCacheContainers_CreateDefaults(void);
474 extern void URLCacheContainers_DeleteAll(void);
476 #define MAX_REPLY_LEN 0x5B4
478 /* Used for debugging - maybe need to be shared in the Wine debugging code ? */
479 typedef struct
481 DWORD val;
482 const char* name;
483 } wininet_flag_info;
485 #endif /* _WINE_INTERNET_H_ */