wininet: Moved InternetFindNextFileW implementation to vtbl.
[wine/hacks.git] / dlls / wininet / internet.h
blob6bda9ab3b52e172386a70bcfa080398e3a78f57b
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 typedef struct _WININETHANDLEHEADER WININETHANDLEHEADER, *LPWININETHANDLEHEADER;
138 typedef struct {
139 void (*Destroy)(WININETHANDLEHEADER*);
140 void (*CloseConnection)(WININETHANDLEHEADER*);
141 DWORD (*SetOption)(WININETHANDLEHEADER*,DWORD,void*,DWORD);
142 BOOL (*WriteFile)(WININETHANDLEHEADER*,const void*,DWORD,DWORD*);
143 DWORD (*FindNextFileW)(WININETHANDLEHEADER*,void*);
144 } HANDLEHEADERVtbl;
146 struct _WININETHANDLEHEADER
148 WH_TYPE htype;
149 const HANDLEHEADERVtbl *vtbl;
150 HINTERNET hInternet;
151 DWORD dwFlags;
152 DWORD_PTR dwContext;
153 DWORD dwError;
154 DWORD dwInternalFlags;
155 DWORD dwRefCount;
156 INTERNET_STATUS_CALLBACK lpfnStatusCB;
157 struct list entry;
158 struct list children;
162 typedef struct
164 WININETHANDLEHEADER hdr;
165 LPWSTR lpszAgent;
166 LPWSTR lpszProxy;
167 LPWSTR lpszProxyBypass;
168 LPWSTR lpszProxyUsername;
169 LPWSTR lpszProxyPassword;
170 DWORD dwAccessType;
171 } WININETAPPINFOW, *LPWININETAPPINFOW;
174 typedef struct
176 WININETHANDLEHEADER hdr;
177 WININETAPPINFOW *lpAppInfo;
178 LPWSTR lpszHostName; /* the final destination of the request */
179 LPWSTR lpszServerName; /* the name of the server we directly connect to */
180 LPWSTR lpszUserName;
181 LPWSTR lpszPassword;
182 INTERNET_PORT nHostPort; /* the final destination port of the request */
183 INTERNET_PORT nServerPort; /* the port of the server we directly connect to */
184 struct sockaddr_in socketAddress;
185 } WININETHTTPSESSIONW, *LPWININETHTTPSESSIONW;
187 #define HDR_ISREQUEST 0x0001
188 #define HDR_COMMADELIMITED 0x0002
189 #define HDR_SEMIDELIMITED 0x0004
191 typedef struct
193 LPWSTR lpszField;
194 LPWSTR lpszValue;
195 WORD wFlags;
196 WORD wCount;
197 } HTTPHEADERW, *LPHTTPHEADERW;
200 struct HttpAuthInfo;
202 typedef struct
204 WININETHANDLEHEADER hdr;
205 WININETHTTPSESSIONW *lpHttpSession;
206 LPWSTR lpszPath;
207 LPWSTR lpszVerb;
208 LPWSTR lpszRawHeaders;
209 WININET_NETCONNECTION netConnection;
210 LPWSTR lpszVersion;
211 LPWSTR lpszStatusText;
212 DWORD dwContentLength; /* total number of bytes to be read */
213 DWORD dwContentRead; /* bytes of the content read so far */
214 HTTPHEADERW *pCustHeaders;
215 DWORD nCustHeaders;
216 HANDLE hCacheFile;
217 LPWSTR lpszCacheFile;
218 struct HttpAuthInfo *pAuthInfo;
219 struct HttpAuthInfo *pProxyAuthInfo;
220 } WININETHTTPREQW, *LPWININETHTTPREQW;
223 struct _WININETFTPSESSIONW;
225 typedef struct
227 WININETHANDLEHEADER hdr;
228 struct _WININETFTPSESSIONW *lpFtpSession;
229 BOOL session_deleted;
230 int nDataSocket;
231 } WININETFTPFILE, *LPWININETFTPFILE;
234 typedef struct _WININETFTPSESSIONW
236 WININETHANDLEHEADER hdr;
237 WININETAPPINFOW *lpAppInfo;
238 int sndSocket;
239 int lstnSocket;
240 int pasvSocket; /* data socket connected by us in case of passive FTP */
241 LPWININETFTPFILE download_in_progress;
242 struct sockaddr_in socketAddress;
243 struct sockaddr_in lstnSocketAddress;
244 LPWSTR lpszPassword;
245 LPWSTR lpszUserName;
246 } WININETFTPSESSIONW, *LPWININETFTPSESSIONW;
249 typedef struct
251 BOOL bIsDirectory;
252 LPWSTR lpszName;
253 DWORD nSize;
254 struct tm tmLastModified;
255 unsigned short permissions;
256 } FILEPROPERTIESW, *LPFILEPROPERTIESW;
259 typedef struct
261 WININETHANDLEHEADER hdr;
262 WININETFTPSESSIONW *lpFtpSession;
263 DWORD index;
264 DWORD size;
265 LPFILEPROPERTIESW lpafp;
266 } WININETFTPFINDNEXTW, *LPWININETFTPFINDNEXTW;
268 struct WORKREQ_FTPPUTFILEW
270 LPWSTR lpszLocalFile;
271 LPWSTR lpszNewRemoteFile;
272 DWORD dwFlags;
273 DWORD_PTR dwContext;
276 struct WORKREQ_FTPSETCURRENTDIRECTORYW
278 LPWSTR lpszDirectory;
281 struct WORKREQ_FTPCREATEDIRECTORYW
283 LPWSTR lpszDirectory;
286 struct WORKREQ_FTPFINDFIRSTFILEW
288 LPWSTR lpszSearchFile;
289 LPWIN32_FIND_DATAW lpFindFileData;
290 DWORD dwFlags;
291 DWORD_PTR dwContext;
294 struct WORKREQ_FTPGETCURRENTDIRECTORYW
296 LPWSTR lpszDirectory;
297 DWORD *lpdwDirectory;
300 struct WORKREQ_FTPOPENFILEW
302 LPWSTR lpszFilename;
303 DWORD dwAccess;
304 DWORD dwFlags;
305 DWORD_PTR dwContext;
308 struct WORKREQ_FTPGETFILEW
310 LPWSTR lpszRemoteFile;
311 LPWSTR lpszNewFile;
312 BOOL fFailIfExists;
313 DWORD dwLocalFlagsAttribute;
314 DWORD dwFlags;
315 DWORD_PTR dwContext;
318 struct WORKREQ_FTPDELETEFILEW
320 LPWSTR lpszFilename;
323 struct WORKREQ_FTPREMOVEDIRECTORYW
325 LPWSTR lpszDirectory;
328 struct WORKREQ_FTPRENAMEFILEW
330 LPWSTR lpszSrcFile;
331 LPWSTR lpszDestFile;
334 struct WORKREQ_FTPFINDNEXTW
336 LPWIN32_FIND_DATAW lpFindFileData;
339 struct WORKREQ_HTTPSENDREQUESTW
341 LPWSTR lpszHeader;
342 DWORD dwHeaderLength;
343 LPVOID lpOptional;
344 DWORD dwOptionalLength;
345 DWORD dwContentLength;
346 BOOL bEndRequest;
349 struct WORKREQ_SENDCALLBACK
351 DWORD_PTR dwContext;
352 DWORD dwInternetStatus;
353 LPVOID lpvStatusInfo;
354 DWORD dwStatusInfoLength;
357 struct WORKREQ_INTERNETOPENURLW
359 HINTERNET hInternet;
360 LPWSTR lpszUrl;
361 LPWSTR lpszHeaders;
362 DWORD dwHeadersLength;
363 DWORD dwFlags;
364 DWORD_PTR dwContext;
367 struct WORKREQ_INTERNETREADFILEEXA
369 LPINTERNET_BUFFERSA lpBuffersOut;
372 typedef struct WORKREQ
374 void (*asyncproc)(struct WORKREQ*);
375 WININETHANDLEHEADER *hdr;
377 union {
378 struct WORKREQ_FTPPUTFILEW FtpPutFileW;
379 struct WORKREQ_FTPSETCURRENTDIRECTORYW FtpSetCurrentDirectoryW;
380 struct WORKREQ_FTPCREATEDIRECTORYW FtpCreateDirectoryW;
381 struct WORKREQ_FTPFINDFIRSTFILEW FtpFindFirstFileW;
382 struct WORKREQ_FTPGETCURRENTDIRECTORYW FtpGetCurrentDirectoryW;
383 struct WORKREQ_FTPOPENFILEW FtpOpenFileW;
384 struct WORKREQ_FTPGETFILEW FtpGetFileW;
385 struct WORKREQ_FTPDELETEFILEW FtpDeleteFileW;
386 struct WORKREQ_FTPREMOVEDIRECTORYW FtpRemoveDirectoryW;
387 struct WORKREQ_FTPRENAMEFILEW FtpRenameFileW;
388 struct WORKREQ_FTPFINDNEXTW FtpFindNextW;
389 struct WORKREQ_HTTPSENDREQUESTW HttpSendRequestW;
390 struct WORKREQ_SENDCALLBACK SendCallback;
391 struct WORKREQ_INTERNETOPENURLW InternetOpenUrlW;
392 struct WORKREQ_INTERNETREADFILEEXA InternetReadFileExA;
393 } u;
395 } WORKREQUEST, *LPWORKREQUEST;
397 HINTERNET WININET_AllocHandle( LPWININETHANDLEHEADER info );
398 LPWININETHANDLEHEADER WININET_GetObject( HINTERNET hinternet );
399 LPWININETHANDLEHEADER WININET_AddRef( LPWININETHANDLEHEADER info );
400 BOOL WININET_Release( LPWININETHANDLEHEADER info );
401 BOOL WININET_FreeHandle( HINTERNET hinternet );
403 time_t ConvertTimeString(LPCWSTR asctime);
405 HINTERNET FTP_Connect(LPWININETAPPINFOW hIC, LPCWSTR lpszServerName,
406 INTERNET_PORT nServerPort, LPCWSTR lpszUserName,
407 LPCWSTR lpszPassword, DWORD dwFlags, DWORD_PTR dwContext,
408 DWORD dwInternalFlags);
410 HINTERNET HTTP_Connect(LPWININETAPPINFOW hIC, LPCWSTR lpszServerName,
411 INTERNET_PORT nServerPort, LPCWSTR lpszUserName,
412 LPCWSTR lpszPassword, DWORD dwFlags, DWORD_PTR dwContext,
413 DWORD dwInternalFlags);
415 BOOL GetAddress(LPCWSTR lpszServerName, INTERNET_PORT nServerPort,
416 struct sockaddr_in *psa);
418 void INTERNET_SetLastError(DWORD dwError);
419 DWORD INTERNET_GetLastError(void);
420 BOOL INTERNET_AsyncCall(LPWORKREQUEST lpWorkRequest);
421 LPSTR INTERNET_GetResponseBuffer(void);
422 LPSTR INTERNET_GetNextLine(INT nSocket, LPDWORD dwLen);
423 BOOL INTERNET_ReadFile(LPWININETHANDLEHEADER lpwh, LPVOID lpBuffer,
424 DWORD dwNumOfBytesToRead, LPDWORD pdwNumOfBytesRead,
425 BOOL bWait, BOOL bSendCompletionStatus);
427 BOOLAPI FTP_FtpPutFileW(LPWININETFTPSESSIONW lpwfs, LPCWSTR lpszLocalFile,
428 LPCWSTR lpszNewRemoteFile, DWORD dwFlags, DWORD_PTR dwContext);
429 BOOLAPI FTP_FtpSetCurrentDirectoryW(LPWININETFTPSESSIONW lpwfs, LPCWSTR lpszDirectory);
430 BOOLAPI FTP_FtpCreateDirectoryW(LPWININETFTPSESSIONW lpwfs, LPCWSTR lpszDirectory);
431 INTERNETAPI HINTERNET WINAPI FTP_FtpFindFirstFileW(LPWININETFTPSESSIONW lpwfs,
432 LPCWSTR lpszSearchFile, LPWIN32_FIND_DATAW lpFindFileData, DWORD dwFlags, DWORD_PTR dwContext);
433 BOOLAPI FTP_FtpGetCurrentDirectoryW(LPWININETFTPSESSIONW lpwfs, LPWSTR lpszCurrentDirectory,
434 LPDWORD lpdwCurrentDirectory);
435 BOOL FTP_ConvertFileProp(LPFILEPROPERTIESW lpafp, LPWIN32_FIND_DATAW lpFindFileData);
436 BOOL FTP_FtpRenameFileW(LPWININETFTPSESSIONW lpwfs, LPCWSTR lpszSrc, LPCWSTR lpszDest);
437 BOOL FTP_FtpRemoveDirectoryW(LPWININETFTPSESSIONW lpwfs, LPCWSTR lpszDirectory);
438 BOOL FTP_FtpDeleteFileW(LPWININETFTPSESSIONW lpwfs, LPCWSTR lpszFileName);
439 HINTERNET FTP_FtpOpenFileW(LPWININETFTPSESSIONW lpwfs, LPCWSTR lpszFileName,
440 DWORD fdwAccess, DWORD dwFlags, DWORD_PTR dwContext);
441 BOOLAPI FTP_FtpGetFileW(LPWININETFTPSESSIONW lpwfs, LPCWSTR lpszRemoteFile, LPCWSTR lpszNewFile,
442 BOOL fFailIfExists, DWORD dwLocalFlagsAttribute, DWORD dwInternetFlags,
443 DWORD_PTR dwContext);
445 BOOLAPI HTTP_HttpSendRequestW(LPWININETHTTPREQW lpwhr, LPCWSTR lpszHeaders,
446 DWORD dwHeaderLength, LPVOID lpOptional, DWORD dwOptionalLength,
447 DWORD dwContentLength, BOOL bEndRequest);
448 INTERNETAPI HINTERNET WINAPI HTTP_HttpOpenRequestW(LPWININETHTTPSESSIONW lpwhs,
449 LPCWSTR lpszVerb, LPCWSTR lpszObjectName, LPCWSTR lpszVersion,
450 LPCWSTR lpszReferrer , LPCWSTR *lpszAcceptTypes,
451 DWORD dwFlags, DWORD_PTR dwContext);
452 BOOL HTTP_FinishedReading(LPWININETHTTPREQW lpwhr);
454 VOID SendAsyncCallback(LPWININETHANDLEHEADER hdr, DWORD_PTR dwContext,
455 DWORD dwInternetStatus, LPVOID lpvStatusInfo,
456 DWORD dwStatusInfoLength);
458 VOID INTERNET_SendCallback(LPWININETHANDLEHEADER hdr, DWORD_PTR dwContext,
459 DWORD dwInternetStatus, LPVOID lpvStatusInfo,
460 DWORD dwStatusInfoLength);
462 LPHTTPHEADERW HTTP_GetHeader(LPWININETHTTPREQW lpwhr, LPCWSTR header);
464 BOOL NETCON_connected(WININET_NETCONNECTION *connection);
465 BOOL NETCON_init(WININET_NETCONNECTION *connnection, BOOL useSSL);
466 BOOL NETCON_create(WININET_NETCONNECTION *connection, int domain,
467 int type, int protocol);
468 BOOL NETCON_close(WININET_NETCONNECTION *connection);
469 BOOL NETCON_connect(WININET_NETCONNECTION *connection, const struct sockaddr *serv_addr,
470 unsigned int addrlen);
471 BOOL NETCON_secure_connect(WININET_NETCONNECTION *connection, LPCWSTR hostname);
472 BOOL NETCON_send(WININET_NETCONNECTION *connection, const void *msg, size_t len, int flags,
473 int *sent /* out */);
474 BOOL NETCON_recv(WININET_NETCONNECTION *connection, void *buf, size_t len, int flags,
475 int *recvd /* out */);
476 BOOL NETCON_query_data_available(WININET_NETCONNECTION *connection, DWORD *available);
477 BOOL NETCON_getNextLine(WININET_NETCONNECTION *connection, LPSTR lpszBuffer, LPDWORD dwBuffer);
478 LPCVOID NETCON_GetCert(WININET_NETCONNECTION *connection);
479 DWORD NETCON_set_timeout(WININET_NETCONNECTION *connection, BOOL send, int value);
481 extern void URLCacheContainers_CreateDefaults(void);
482 extern void URLCacheContainers_DeleteAll(void);
484 #define MAX_REPLY_LEN 0x5B4
486 /* Used for debugging - maybe need to be shared in the Wine debugging code ? */
487 typedef struct
489 DWORD val;
490 const char* name;
491 } wininet_flag_info;
493 #endif /* _WINE_INTERNET_H_ */