imagehlp: Forward some more 64-bit functions to dbghelp.
[wine] / dlls / wininet / internet.h
1 /*
2  * Wininet
3  *
4  * Copyright 1999 Corel Corporation
5  *
6  * Ulrich Czekalla
7  *
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.
12  *
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.
17  *
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
21  */
22
23 #ifndef _WINE_INTERNET_H_
24 #define _WINE_INTERNET_H_
25
26 #ifndef __WINE_CONFIG_H
27 # error You must include config.h to use this header
28 #endif
29
30 #include "wine/unicode.h"
31 #include "wine/list.h"
32
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_SYS_SOCKET_H
42 # include <sys/socket.h>
43 #endif
44
45 #if !defined(__MINGW32__) && !defined(_MSC_VER)
46 #define closesocket close
47 #define ioctlsocket ioctl
48 #endif /* __MINGW32__ */
49
50 /* used for netconnection.c stuff */
51 typedef struct
52 {
53     BOOL useSSL;
54     int socketFD;
55     void *ssl_s;
56     char *peek_msg;
57     char *peek_msg_mem;
58     size_t peek_len;
59 } WININET_NETCONNECTION;
60
61 static inline LPWSTR WININET_strdupW( LPCWSTR str )
62 {
63     LPWSTR ret = HeapAlloc( GetProcessHeap(), 0, (strlenW(str) + 1)*sizeof(WCHAR) );
64     if (ret) strcpyW( ret, str );
65     return ret;
66 }
67
68 static inline LPWSTR WININET_strdup_AtoW( LPCSTR str )
69 {
70     int len = MultiByteToWideChar( CP_ACP, 0, str, -1, NULL, 0);
71     LPWSTR ret = HeapAlloc( GetProcessHeap(), 0, len * sizeof(WCHAR) );
72     if (ret)
73         MultiByteToWideChar( CP_ACP, 0, str, -1, ret, len);
74     return ret;
75 }
76
77 static inline LPSTR WININET_strdup_WtoA( LPCWSTR str )
78 {
79     int len = WideCharToMultiByte( CP_ACP, 0, str, -1, NULL, 0, NULL, NULL);
80     LPSTR ret = HeapAlloc( GetProcessHeap(), 0, len );
81     if (ret)
82         WideCharToMultiByte( CP_ACP, 0, str, -1, ret, len, NULL, NULL);
83     return ret;
84 }
85
86 static inline void WININET_find_data_WtoA(LPWIN32_FIND_DATAW dataW, LPWIN32_FIND_DATAA dataA)
87 {
88     dataA->dwFileAttributes = dataW->dwFileAttributes;
89     dataA->ftCreationTime   = dataW->ftCreationTime;
90     dataA->ftLastAccessTime = dataW->ftLastAccessTime;
91     dataA->ftLastWriteTime  = dataW->ftLastWriteTime;
92     dataA->nFileSizeHigh    = dataW->nFileSizeHigh;
93     dataA->nFileSizeLow     = dataW->nFileSizeLow;
94     dataA->dwReserved0      = dataW->dwReserved0;
95     dataA->dwReserved1      = dataW->dwReserved1;
96     WideCharToMultiByte(CP_ACP, 0, dataW->cFileName, -1, 
97         dataA->cFileName, sizeof(dataA->cFileName),
98         NULL, NULL);
99     WideCharToMultiByte(CP_ACP, 0, dataW->cAlternateFileName, -1, 
100         dataA->cAlternateFileName, sizeof(dataA->cAlternateFileName),
101         NULL, NULL);
102 }
103
104 typedef enum
105 {
106     WH_HINIT = INTERNET_HANDLE_TYPE_INTERNET,
107     WH_HFTPSESSION = INTERNET_HANDLE_TYPE_CONNECT_FTP,
108     WH_HGOPHERSESSION = INTERNET_HANDLE_TYPE_CONNECT_GOPHER,
109     WH_HHTTPSESSION = INTERNET_HANDLE_TYPE_CONNECT_HTTP,
110     WH_HFILE = INTERNET_HANDLE_TYPE_FTP_FILE,
111     WH_HFTPFINDNEXT = INTERNET_HANDLE_TYPE_FTP_FIND,
112     WH_HHTTPREQ = INTERNET_HANDLE_TYPE_HTTP_REQUEST,
113 } WH_TYPE;
114
115 #define INET_OPENURL 0x0001
116 #define INET_CALLBACKW 0x0002
117
118 typedef struct _WININETHANDLEHEADER WININETHANDLEHEADER, *LPWININETHANDLEHEADER;
119
120 typedef struct {
121     void (*Destroy)(WININETHANDLEHEADER*);
122     void (*CloseConnection)(WININETHANDLEHEADER*);
123     DWORD (*QueryOption)(WININETHANDLEHEADER*,DWORD,void*,DWORD*,BOOL);
124     DWORD (*SetOption)(WININETHANDLEHEADER*,DWORD,void*,DWORD);
125     DWORD (*ReadFile)(WININETHANDLEHEADER*,void*,DWORD,DWORD*);
126     DWORD (*ReadFileExA)(WININETHANDLEHEADER*,INTERNET_BUFFERSA*,DWORD,DWORD_PTR);
127     DWORD (*ReadFileExW)(WININETHANDLEHEADER*,INTERNET_BUFFERSW*,DWORD,DWORD_PTR);
128     BOOL (*WriteFile)(WININETHANDLEHEADER*,const void*,DWORD,DWORD*);
129     DWORD (*QueryDataAvailable)(WININETHANDLEHEADER*,DWORD*,DWORD,DWORD_PTR);
130     DWORD (*FindNextFileW)(WININETHANDLEHEADER*,void*);
131 } HANDLEHEADERVtbl;
132
133 struct _WININETHANDLEHEADER
134 {
135     WH_TYPE htype;
136     const HANDLEHEADERVtbl *vtbl;
137     HINTERNET hInternet;
138     DWORD  dwFlags;
139     DWORD_PTR dwContext;
140     DWORD  dwError;
141     DWORD  dwInternalFlags;
142     LONG   refs;
143     INTERNET_STATUS_CALLBACK lpfnStatusCB;
144     struct list entry;
145     struct list children;
146 };
147
148
149 typedef struct
150 {
151     WININETHANDLEHEADER hdr;
152     LPWSTR  lpszAgent;
153     LPWSTR  lpszProxy;
154     LPWSTR  lpszProxyBypass;
155     LPWSTR  lpszProxyUsername;
156     LPWSTR  lpszProxyPassword;
157     DWORD   dwAccessType;
158 } WININETAPPINFOW, *LPWININETAPPINFOW;
159
160
161 typedef struct
162 {
163     WININETHANDLEHEADER hdr;
164     WININETAPPINFOW *lpAppInfo;
165     LPWSTR  lpszHostName; /* the final destination of the request */
166     LPWSTR  lpszServerName; /* the name of the server we directly connect to */
167     LPWSTR  lpszUserName;
168     LPWSTR  lpszPassword;
169     INTERNET_PORT nHostPort; /* the final destination port of the request */
170     INTERNET_PORT nServerPort; /* the port of the server we directly connect to */
171     struct sockaddr_in socketAddress;
172 } WININETHTTPSESSIONW, *LPWININETHTTPSESSIONW;
173
174 #define HDR_ISREQUEST           0x0001
175 #define HDR_COMMADELIMITED      0x0002
176 #define HDR_SEMIDELIMITED       0x0004
177
178 typedef struct
179 {
180     LPWSTR lpszField;
181     LPWSTR lpszValue;
182     WORD wFlags;
183     WORD wCount;
184 } HTTPHEADERW, *LPHTTPHEADERW;
185
186
187 struct HttpAuthInfo;
188
189 typedef struct
190 {
191     WININETHANDLEHEADER hdr;
192     WININETHTTPSESSIONW *lpHttpSession;
193     LPWSTR lpszPath;
194     LPWSTR lpszVerb;
195     LPWSTR lpszRawHeaders;
196     WININET_NETCONNECTION netConnection;
197     LPWSTR lpszVersion;
198     LPWSTR lpszStatusText;
199     DWORD dwContentLength; /* total number of bytes to be read */
200     DWORD dwContentRead; /* bytes of the content read so far */
201     DWORD dwBytesToWrite;
202     DWORD dwBytesWritten;
203     HTTPHEADERW *pCustHeaders;
204     DWORD nCustHeaders;
205     HANDLE hCacheFile;
206     LPWSTR lpszCacheFile;
207     struct HttpAuthInfo *pAuthInfo;
208     struct HttpAuthInfo *pProxyAuthInfo;
209 } WININETHTTPREQW, *LPWININETHTTPREQW;
210
211
212
213 struct WORKREQ_FTPPUTFILEW
214 {
215     LPWSTR lpszLocalFile;
216     LPWSTR lpszNewRemoteFile;
217     DWORD  dwFlags;
218     DWORD_PTR dwContext;
219 };
220
221 struct WORKREQ_FTPSETCURRENTDIRECTORYW
222 {
223     LPWSTR lpszDirectory;
224 };
225
226 struct WORKREQ_FTPCREATEDIRECTORYW
227 {
228     LPWSTR lpszDirectory;
229 };
230
231 struct WORKREQ_FTPFINDFIRSTFILEW
232 {
233     LPWSTR lpszSearchFile;
234     LPWIN32_FIND_DATAW lpFindFileData;
235     DWORD  dwFlags;
236     DWORD_PTR dwContext;
237 };
238
239 struct WORKREQ_FTPGETCURRENTDIRECTORYW
240 {
241     LPWSTR lpszDirectory;
242     DWORD *lpdwDirectory;
243 };
244
245 struct WORKREQ_FTPOPENFILEW
246 {
247     LPWSTR lpszFilename;
248     DWORD  dwAccess;
249     DWORD  dwFlags;
250     DWORD_PTR dwContext;
251 };
252
253 struct WORKREQ_FTPGETFILEW
254 {
255     LPWSTR lpszRemoteFile;
256     LPWSTR lpszNewFile;
257     BOOL   fFailIfExists;
258     DWORD  dwLocalFlagsAttribute;
259     DWORD  dwFlags;
260     DWORD_PTR dwContext;
261 };
262
263 struct WORKREQ_FTPDELETEFILEW
264 {
265     LPWSTR lpszFilename;
266 };
267
268 struct WORKREQ_FTPREMOVEDIRECTORYW
269 {
270     LPWSTR lpszDirectory;
271 };
272
273 struct WORKREQ_FTPRENAMEFILEW
274 {
275     LPWSTR lpszSrcFile;
276     LPWSTR lpszDestFile;
277 };
278
279 struct WORKREQ_FTPFINDNEXTW
280 {
281     LPWIN32_FIND_DATAW lpFindFileData;
282 };
283
284 struct WORKREQ_HTTPSENDREQUESTW
285 {
286     LPWSTR lpszHeader;
287     DWORD  dwHeaderLength;
288     LPVOID lpOptional;
289     DWORD  dwOptionalLength;
290     DWORD  dwContentLength;
291     BOOL   bEndRequest;
292 };
293
294 struct WORKREQ_HTTPENDREQUESTW
295 {
296     DWORD     dwFlags;
297     DWORD_PTR dwContext;
298 };
299
300 struct WORKREQ_SENDCALLBACK
301 {
302     DWORD_PTR dwContext;
303     DWORD     dwInternetStatus;
304     LPVOID    lpvStatusInfo;
305     DWORD     dwStatusInfoLength;
306 };
307
308 struct WORKREQ_INTERNETOPENURLW
309 {
310     HINTERNET hInternet;
311     LPWSTR     lpszUrl;
312     LPWSTR     lpszHeaders;
313     DWORD     dwHeadersLength;
314     DWORD     dwFlags;
315     DWORD_PTR dwContext;
316 };
317
318 struct WORKREQ_INTERNETREADFILEEXA
319 {
320     LPINTERNET_BUFFERSA lpBuffersOut;
321 };
322
323 struct WORKREQ_INTERNETREADFILEEXW
324 {
325     LPINTERNET_BUFFERSW lpBuffersOut;
326 };
327
328 typedef struct WORKREQ
329 {
330     void (*asyncproc)(struct WORKREQ*);
331     WININETHANDLEHEADER *hdr;
332
333     union {
334         struct WORKREQ_FTPPUTFILEW              FtpPutFileW;
335         struct WORKREQ_FTPSETCURRENTDIRECTORYW  FtpSetCurrentDirectoryW;
336         struct WORKREQ_FTPCREATEDIRECTORYW      FtpCreateDirectoryW;
337         struct WORKREQ_FTPFINDFIRSTFILEW        FtpFindFirstFileW;
338         struct WORKREQ_FTPGETCURRENTDIRECTORYW  FtpGetCurrentDirectoryW;
339         struct WORKREQ_FTPOPENFILEW             FtpOpenFileW;
340         struct WORKREQ_FTPGETFILEW              FtpGetFileW;
341         struct WORKREQ_FTPDELETEFILEW           FtpDeleteFileW;
342         struct WORKREQ_FTPREMOVEDIRECTORYW      FtpRemoveDirectoryW;
343         struct WORKREQ_FTPRENAMEFILEW           FtpRenameFileW;
344         struct WORKREQ_FTPFINDNEXTW             FtpFindNextW;
345         struct WORKREQ_HTTPSENDREQUESTW         HttpSendRequestW;
346         struct WORKREQ_HTTPENDREQUESTW          HttpEndRequestW;
347         struct WORKREQ_SENDCALLBACK             SendCallback;
348         struct WORKREQ_INTERNETOPENURLW         InternetOpenUrlW;
349         struct WORKREQ_INTERNETREADFILEEXA      InternetReadFileExA;
350         struct WORKREQ_INTERNETREADFILEEXW      InternetReadFileExW;
351     } u;
352
353 } WORKREQUEST, *LPWORKREQUEST;
354
355 HINTERNET WININET_AllocHandle( LPWININETHANDLEHEADER info );
356 LPWININETHANDLEHEADER WININET_GetObject( HINTERNET hinternet );
357 LPWININETHANDLEHEADER WININET_AddRef( LPWININETHANDLEHEADER info );
358 BOOL WININET_Release( LPWININETHANDLEHEADER info );
359 BOOL WININET_FreeHandle( HINTERNET hinternet );
360
361 DWORD INET_QueryOption(DWORD,void*,DWORD*,BOOL);
362
363 time_t ConvertTimeString(LPCWSTR asctime);
364
365 HINTERNET FTP_Connect(LPWININETAPPINFOW hIC, LPCWSTR lpszServerName,
366         INTERNET_PORT nServerPort, LPCWSTR lpszUserName,
367         LPCWSTR lpszPassword, DWORD dwFlags, DWORD_PTR dwContext,
368         DWORD dwInternalFlags);
369
370 HINTERNET HTTP_Connect(LPWININETAPPINFOW hIC, LPCWSTR lpszServerName,
371         INTERNET_PORT nServerPort, LPCWSTR lpszUserName,
372         LPCWSTR lpszPassword, DWORD dwFlags, DWORD_PTR dwContext,
373         DWORD dwInternalFlags);
374
375 BOOL GetAddress(LPCWSTR lpszServerName, INTERNET_PORT nServerPort,
376         struct sockaddr_in *psa);
377
378 void INTERNET_SetLastError(DWORD dwError);
379 DWORD INTERNET_GetLastError(void);
380 BOOL INTERNET_AsyncCall(LPWORKREQUEST lpWorkRequest);
381 LPSTR INTERNET_GetResponseBuffer(void);
382 LPSTR INTERNET_GetNextLine(INT nSocket, LPDWORD dwLen);
383
384 BOOLAPI HTTP_HttpSendRequestW(LPWININETHTTPREQW lpwhr, LPCWSTR lpszHeaders,
385         DWORD dwHeaderLength, LPVOID lpOptional, DWORD dwOptionalLength,
386         DWORD dwContentLength, BOOL bEndRequest);
387 INTERNETAPI HINTERNET WINAPI HTTP_HttpOpenRequestW(LPWININETHTTPSESSIONW lpwhs,
388         LPCWSTR lpszVerb, LPCWSTR lpszObjectName, LPCWSTR lpszVersion,
389         LPCWSTR lpszReferrer , LPCWSTR *lpszAcceptTypes,
390         DWORD dwFlags, DWORD_PTR dwContext);
391
392 VOID SendAsyncCallback(LPWININETHANDLEHEADER hdr, DWORD_PTR dwContext,
393                        DWORD dwInternetStatus, LPVOID lpvStatusInfo,
394                        DWORD dwStatusInfoLength);
395
396 VOID INTERNET_SendCallback(LPWININETHANDLEHEADER hdr, DWORD_PTR dwContext,
397                            DWORD dwInternetStatus, LPVOID lpvStatusInfo,
398                            DWORD dwStatusInfoLength);
399
400 BOOL NETCON_connected(WININET_NETCONNECTION *connection);
401 BOOL NETCON_init(WININET_NETCONNECTION *connnection, BOOL useSSL);
402 BOOL NETCON_create(WININET_NETCONNECTION *connection, int domain,
403               int type, int protocol);
404 BOOL NETCON_close(WININET_NETCONNECTION *connection);
405 BOOL NETCON_connect(WININET_NETCONNECTION *connection, const struct sockaddr *serv_addr,
406                     unsigned int addrlen);
407 BOOL NETCON_secure_connect(WININET_NETCONNECTION *connection, LPCWSTR hostname);
408 BOOL NETCON_send(WININET_NETCONNECTION *connection, const void *msg, size_t len, int flags,
409                 int *sent /* out */);
410 BOOL NETCON_recv(WININET_NETCONNECTION *connection, void *buf, size_t len, int flags,
411                 int *recvd /* out */);
412 BOOL NETCON_query_data_available(WININET_NETCONNECTION *connection, DWORD *available);
413 BOOL NETCON_getNextLine(WININET_NETCONNECTION *connection, LPSTR lpszBuffer, LPDWORD dwBuffer);
414 LPCVOID NETCON_GetCert(WININET_NETCONNECTION *connection);
415 DWORD NETCON_set_timeout(WININET_NETCONNECTION *connection, BOOL send, int value);
416
417 extern void URLCacheContainers_CreateDefaults(void);
418 extern void URLCacheContainers_DeleteAll(void);
419
420 #define MAX_REPLY_LEN           0x5B4
421
422 /* Used for debugging - maybe need to be shared in the Wine debugging code ? */
423 typedef struct
424 {
425     DWORD val;
426     const char* name;
427 } wininet_flag_info;
428
429 #endif /* _WINE_INTERNET_H_ */