InternetSetStatusCallback can be used on any handle and callbacks are
[wine/wine-kai.git] / dlls / wininet / internet.h
blobf02c4ae21b9de02222915e1018fd3faabde9e527
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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
23 #ifndef _WINE_INTERNET_H_
24 #define _WINE_INTERNET_H_
26 #include "wine/unicode.h"
28 #include <time.h>
29 #ifdef HAVE_NETDB_H
30 # include <netdb.h>
31 #endif
32 #ifdef HAVE_NETINET_IN_H
33 # include <sys/types.h>
34 # include <netinet/in.h>
35 #endif
36 #ifdef HAVE_OPENSSL_SSL_H
37 #define DSA __ssl_DSA /* avoid conflict with commctrl.h */
38 #undef FAR
39 # include <openssl/ssl.h>
40 #undef FAR
41 #define FAR do_not_use_this_in_wine
42 #undef DSA
43 #endif
44 #ifdef HAVE_SYS_SOCKET_H
45 # include <sys/socket.h>
46 #endif
48 #ifdef __MINGW32__
49 #include "winsock2.h"
50 #else
51 #define closesocket close
52 #endif /* __MINGW32__ */
54 /* used for netconnection.c stuff */
55 typedef struct
57 BOOL useSSL;
58 int socketFD;
59 #ifdef HAVE_OPENSSL_SSL_H
60 SSL *ssl_s;
61 int ssl_sock;
62 #endif
63 } WININET_NETCONNECTION;
65 inline static LPSTR WININET_strdup( LPCSTR str )
67 LPSTR ret = HeapAlloc( GetProcessHeap(), 0, strlen(str) + 1 );
68 if (ret) strcpy( ret, str );
69 return ret;
72 inline static LPWSTR WININET_strdupW( LPCWSTR str )
74 LPWSTR ret = HeapAlloc( GetProcessHeap(), 0, (strlenW(str) + 1)*sizeof(WCHAR) );
75 if (ret) strcpyW( ret, str );
76 return ret;
79 inline static LPWSTR WININET_strdup_AtoW( LPCSTR str )
81 int len = MultiByteToWideChar( CP_ACP, 0, str, -1, NULL, 0);
82 LPWSTR ret = HeapAlloc( GetProcessHeap(), 0, len * sizeof(WCHAR) );
83 if (ret)
84 MultiByteToWideChar( CP_ACP, 0, str, -1, ret, len);
85 return ret;
88 inline static LPSTR WININET_strdup_WtoA( LPCWSTR str )
90 int len = WideCharToMultiByte( CP_ACP, 0, str, -1, NULL, 0, NULL, NULL);
91 LPSTR ret = HeapAlloc( GetProcessHeap(), 0, len );
92 if (ret)
93 WideCharToMultiByte( CP_ACP, 0, str, -1, ret, len, NULL, NULL);
94 return ret;
97 inline static void WININET_find_data_WtoA(LPWIN32_FIND_DATAW dataW, LPWIN32_FIND_DATAA dataA)
99 dataA->dwFileAttributes = dataW->dwFileAttributes;
100 dataA->ftCreationTime = dataW->ftCreationTime;
101 dataA->ftLastAccessTime = dataW->ftLastAccessTime;
102 dataA->ftLastWriteTime = dataW->ftLastWriteTime;
103 dataA->nFileSizeHigh = dataW->nFileSizeHigh;
104 dataA->nFileSizeLow = dataW->nFileSizeLow;
105 dataA->dwReserved0 = dataW->dwReserved0;
106 dataA->dwReserved1 = dataW->dwReserved1;
107 WideCharToMultiByte(CP_ACP, 0, dataW->cFileName, -1,
108 dataA->cFileName, sizeof(dataA->cFileName),
109 NULL, NULL);
110 WideCharToMultiByte(CP_ACP, 0, dataW->cAlternateFileName, -1,
111 dataA->cAlternateFileName, sizeof(dataA->cAlternateFileName),
112 NULL, NULL);
115 typedef enum
117 WH_HINIT = INTERNET_HANDLE_TYPE_INTERNET,
118 WH_HFTPSESSION = INTERNET_HANDLE_TYPE_CONNECT_FTP,
119 WH_HGOPHERSESSION = INTERNET_HANDLE_TYPE_CONNECT_GOPHER,
120 WH_HHTTPSESSION = INTERNET_HANDLE_TYPE_CONNECT_HTTP,
121 WH_HFILE = INTERNET_HANDLE_TYPE_FTP_FILE,
122 WH_HFINDNEXT = INTERNET_HANDLE_TYPE_FTP_FIND,
123 WH_HHTTPREQ = INTERNET_HANDLE_TYPE_HTTP_REQUEST,
124 } WH_TYPE;
126 #define INET_OPENURL 0x0001
127 #define INET_CALLBACKW 0x0002
129 struct _WININETHANDLEHEADER;
130 typedef struct _WININETHANDLEHEADER WININETHANDLEHEADER, *LPWININETHANDLEHEADER;
132 typedef void (*WININET_object_destructor)( LPWININETHANDLEHEADER );
134 struct _WININETHANDLEHEADER
136 WH_TYPE htype;
137 DWORD dwFlags;
138 DWORD dwContext;
139 DWORD dwError;
140 DWORD dwInternalFlags;
141 DWORD dwRefCount;
142 WININET_object_destructor destroy;
143 INTERNET_STATUS_CALLBACK lpfnStatusCB;
144 struct _WININETHANDLEHEADER *lpwhparent;
148 typedef struct
150 WININETHANDLEHEADER hdr;
151 LPWSTR lpszAgent;
152 LPWSTR lpszProxy;
153 LPWSTR lpszProxyBypass;
154 LPWSTR lpszProxyUsername;
155 LPWSTR lpszProxyPassword;
156 DWORD dwAccessType;
157 } WININETAPPINFOW, *LPWININETAPPINFOW;
160 typedef struct
162 WININETHANDLEHEADER hdr;
163 LPWSTR lpszServerName;
164 LPWSTR lpszUserName;
165 INTERNET_PORT nServerPort;
166 struct sockaddr_in socketAddress;
167 struct hostent *phostent;
168 } WININETHTTPSESSIONW, *LPWININETHTTPSESSIONW;
170 #define HDR_ISREQUEST 0x0001
171 #define HDR_COMMADELIMITED 0x0002
172 #define HDR_SEMIDELIMITED 0x0004
174 typedef struct
176 LPWSTR lpszField;
177 LPWSTR lpszValue;
178 WORD wFlags;
179 WORD wCount;
180 } HTTPHEADERW, *LPHTTPHEADERW;
183 typedef struct
185 WININETHANDLEHEADER hdr;
186 LPWSTR lpszPath;
187 LPWSTR lpszVerb;
188 LPWSTR lpszRawHeaders;
189 WININET_NETCONNECTION netConnection;
190 HTTPHEADERW StdHeaders[HTTP_QUERY_MAX+1];
191 HTTPHEADERW *pCustHeaders;
192 DWORD nCustHeaders;
193 } WININETHTTPREQW, *LPWININETHTTPREQW;
196 typedef struct
198 WININETHANDLEHEADER hdr;
199 BOOL session_deleted;
200 int nDataSocket;
201 } WININETFILE, *LPWININETFILE;
204 typedef struct
206 WININETHANDLEHEADER hdr;
207 int sndSocket;
208 int lstnSocket;
209 int pasvSocket; /* data socket connected by us in case of passive FTP */
210 LPWININETFILE download_in_progress;
211 struct sockaddr_in socketAddress;
212 struct sockaddr_in lstnSocketAddress;
213 struct hostent *phostent;
214 LPWSTR lpszPassword;
215 LPWSTR lpszUserName;
216 } WININETFTPSESSIONW, *LPWININETFTPSESSIONW;
219 typedef struct
221 BOOL bIsDirectory;
222 LPWSTR lpszName;
223 DWORD nSize;
224 struct tm tmLastModified;
225 unsigned short permissions;
226 } FILEPROPERTIESW, *LPFILEPROPERTIESW;
229 typedef struct
231 WININETHANDLEHEADER hdr;
232 DWORD index;
233 DWORD size;
234 LPFILEPROPERTIESW lpafp;
235 } WININETFINDNEXTW, *LPWININETFINDNEXTW;
237 typedef enum
239 FTPPUTFILEW,
240 FTPSETCURRENTDIRECTORYW,
241 FTPCREATEDIRECTORYW,
242 FTPFINDFIRSTFILEW,
243 FTPGETCURRENTDIRECTORYW,
244 FTPOPENFILEW,
245 FTPGETFILEW,
246 FTPDELETEFILEW,
247 FTPREMOVEDIRECTORYW,
248 FTPRENAMEFILEW,
249 INTERNETFINDNEXTW,
250 HTTPSENDREQUESTW,
251 HTTPOPENREQUESTW,
252 SENDCALLBACK,
253 INTERNETOPENURLW,
254 } ASYNC_FUNC;
256 struct WORKREQ_FTPPUTFILEW
258 LPWSTR lpszLocalFile;
259 LPWSTR lpszNewRemoteFile;
260 DWORD dwFlags;
261 DWORD dwContext;
264 struct WORKREQ_FTPSETCURRENTDIRECTORYW
266 LPWSTR lpszDirectory;
269 struct WORKREQ_FTPCREATEDIRECTORYW
271 LPWSTR lpszDirectory;
274 struct WORKREQ_FTPFINDFIRSTFILEW
276 LPWSTR lpszSearchFile;
277 LPWIN32_FIND_DATAW lpFindFileData;
278 DWORD dwFlags;
279 DWORD dwContext;
282 struct WORKREQ_FTPGETCURRENTDIRECTORYW
284 LPWSTR lpszDirectory;
285 DWORD *lpdwDirectory;
288 struct WORKREQ_FTPOPENFILEW
290 LPWSTR lpszFilename;
291 DWORD dwAccess;
292 DWORD dwFlags;
293 DWORD dwContext;
296 struct WORKREQ_FTPGETFILEW
298 LPWSTR lpszRemoteFile;
299 LPWSTR lpszNewFile;
300 BOOL fFailIfExists;
301 DWORD dwLocalFlagsAttribute;
302 DWORD dwFlags;
303 DWORD dwContext;
306 struct WORKREQ_FTPDELETEFILEW
308 LPWSTR lpszFilename;
311 struct WORKREQ_FTPREMOVEDIRECTORYW
313 LPWSTR lpszDirectory;
316 struct WORKREQ_FTPRENAMEFILEW
318 LPWSTR lpszSrcFile;
319 LPWSTR lpszDestFile;
322 struct WORKREQ_INTERNETFINDNEXTW
324 LPWIN32_FIND_DATAW lpFindFileData;
327 struct WORKREQ_HTTPOPENREQUESTW
329 LPWSTR lpszVerb;
330 LPWSTR lpszObjectName;
331 LPWSTR lpszVersion;
332 LPWSTR lpszReferrer;
333 LPCWSTR *lpszAcceptTypes;
334 DWORD dwFlags;
335 DWORD dwContext;
338 struct WORKREQ_HTTPSENDREQUESTW
340 LPWSTR lpszHeader;
341 DWORD dwHeaderLength;
342 LPVOID lpOptional;
343 DWORD dwOptionalLength;
346 struct WORKREQ_SENDCALLBACK
348 DWORD dwContext;
349 DWORD dwInternetStatus;
350 LPVOID lpvStatusInfo;
351 DWORD dwStatusInfoLength;
354 struct WORKREQ_INTERNETOPENURLW
356 HINTERNET hInternet;
357 LPWSTR lpszUrl;
358 LPWSTR lpszHeaders;
359 DWORD dwHeadersLength;
360 DWORD dwFlags;
361 DWORD dwContext;
364 typedef struct WORKREQ
366 ASYNC_FUNC asyncall;
367 WININETHANDLEHEADER *hdr;
369 union {
370 struct WORKREQ_FTPPUTFILEW FtpPutFileW;
371 struct WORKREQ_FTPSETCURRENTDIRECTORYW FtpSetCurrentDirectoryW;
372 struct WORKREQ_FTPCREATEDIRECTORYW FtpCreateDirectoryW;
373 struct WORKREQ_FTPFINDFIRSTFILEW FtpFindFirstFileW;
374 struct WORKREQ_FTPGETCURRENTDIRECTORYW FtpGetCurrentDirectoryW;
375 struct WORKREQ_FTPOPENFILEW FtpOpenFileW;
376 struct WORKREQ_FTPGETFILEW FtpGetFileW;
377 struct WORKREQ_FTPDELETEFILEW FtpDeleteFileW;
378 struct WORKREQ_FTPREMOVEDIRECTORYW FtpRemoveDirectoryW;
379 struct WORKREQ_FTPRENAMEFILEW FtpRenameFileW;
380 struct WORKREQ_INTERNETFINDNEXTW InternetFindNextW;
381 struct WORKREQ_HTTPOPENREQUESTW HttpOpenRequestW;
382 struct WORKREQ_HTTPSENDREQUESTW HttpSendRequestW;
383 struct WORKREQ_SENDCALLBACK SendCallback;
384 struct WORKREQ_INTERNETOPENURLW InternetOpenUrlW;
385 } u;
387 struct WORKREQ *next;
388 struct WORKREQ *prev;
390 } WORKREQUEST, *LPWORKREQUEST;
392 HINTERNET WININET_AllocHandle( LPWININETHANDLEHEADER info );
393 LPWININETHANDLEHEADER WININET_GetObject( HINTERNET hinternet );
394 LPWININETHANDLEHEADER WININET_AddRef( LPWININETHANDLEHEADER info );
395 BOOL WININET_Release( LPWININETHANDLEHEADER info );
396 BOOL WININET_FreeHandle( HINTERNET hinternet );
397 HINTERNET WININET_FindHandle( LPWININETHANDLEHEADER info );
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 dwContext,
404 DWORD dwInternalFlags);
406 HINTERNET HTTP_Connect(LPWININETAPPINFOW hIC, LPCWSTR lpszServerName,
407 INTERNET_PORT nServerPort, LPCWSTR lpszUserName,
408 LPCWSTR lpszPassword, DWORD dwFlags, DWORD dwContext,
409 DWORD dwInternalFlags);
411 BOOL GetAddress(LPCWSTR lpszServerName, INTERNET_PORT nServerPort,
412 struct hostent **phe, struct sockaddr_in *psa);
414 void INTERNET_SetLastError(DWORD dwError);
415 DWORD INTERNET_GetLastError();
416 BOOL INTERNET_AsyncCall(LPWORKREQUEST lpWorkRequest);
417 LPSTR INTERNET_GetResponseBuffer();
418 LPSTR INTERNET_GetNextLine(INT nSocket, LPDWORD dwLen);
420 BOOLAPI FTP_FtpPutFileW(LPWININETFTPSESSIONW lpwfs, LPCWSTR lpszLocalFile,
421 LPCWSTR lpszNewRemoteFile, DWORD dwFlags, DWORD dwContext);
422 BOOLAPI FTP_FtpSetCurrentDirectoryW(LPWININETFTPSESSIONW lpwfs, LPCWSTR lpszDirectory);
423 BOOLAPI FTP_FtpCreateDirectoryW(LPWININETFTPSESSIONW lpwfs, LPCWSTR lpszDirectory);
424 INTERNETAPI HINTERNET WINAPI FTP_FtpFindFirstFileW(LPWININETFTPSESSIONW lpwfs,
425 LPCWSTR lpszSearchFile, LPWIN32_FIND_DATAW lpFindFileData, DWORD dwFlags, DWORD dwContext);
426 BOOLAPI FTP_FtpGetCurrentDirectoryW(LPWININETFTPSESSIONW lpwfs, LPWSTR lpszCurrentDirectory,
427 LPDWORD lpdwCurrentDirectory);
428 BOOL FTP_ConvertFileProp(LPFILEPROPERTIESW lpafp, LPWIN32_FIND_DATAW lpFindFileData);
429 BOOL FTP_FtpRenameFileW(LPWININETFTPSESSIONW lpwfs, LPCWSTR lpszSrc, LPCWSTR lpszDest);
430 BOOL FTP_FtpRemoveDirectoryW(LPWININETFTPSESSIONW lpwfs, LPCWSTR lpszDirectory);
431 BOOL FTP_FtpDeleteFileW(LPWININETFTPSESSIONW lpwfs, LPCWSTR lpszFileName);
432 HINTERNET FTP_FtpOpenFileW(LPWININETFTPSESSIONW lpwfs, LPCWSTR lpszFileName,
433 DWORD fdwAccess, DWORD dwFlags, DWORD dwContext);
434 BOOLAPI FTP_FtpGetFileW(LPWININETFTPSESSIONW lpwfs, LPCWSTR lpszRemoteFile, LPCWSTR lpszNewFile,
435 BOOL fFailIfExists, DWORD dwLocalFlagsAttribute, DWORD dwInternetFlags,
436 DWORD dwContext);
438 BOOLAPI HTTP_HttpSendRequestW(LPWININETHTTPREQW lpwhr, LPCWSTR lpszHeaders,
439 DWORD dwHeaderLength, LPVOID lpOptional ,DWORD dwOptionalLength);
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);
445 VOID SendAsyncCallback(LPWININETHANDLEHEADER hdr, DWORD dwContext,
446 DWORD dwInternetStatus, LPVOID lpvStatusInfo,
447 DWORD dwStatusInfoLength);
449 VOID SendSyncCallback(LPWININETHANDLEHEADER hdr, DWORD dwContext,
450 DWORD dwInternetStatus, LPVOID lpvStatusInfo,
451 DWORD dwStatusInfoLength);
453 BOOL HTTP_InsertProxyAuthorization( LPWININETHTTPREQW lpwhr,
454 LPCWSTR username, LPCWSTR password );
456 BOOL NETCON_connected(WININET_NETCONNECTION *connection);
457 void 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_send(WININET_NETCONNECTION *connection, const void *msg, size_t len, int flags,
464 int *sent /* out */);
465 BOOL NETCON_recv(WININET_NETCONNECTION *connection, void *buf, size_t len, int flags,
466 int *recvd /* out */);
467 BOOL NETCON_getNextLine(WININET_NETCONNECTION *connection, LPSTR lpszBuffer, LPDWORD dwBuffer);
469 #define MAX_REPLY_LEN 0x5B4
471 /* Used for debugging - maybe need to be shared in the Wine debugging code ? */
472 typedef struct
474 DWORD val;
475 const char* name;
476 } wininet_flag_info;
478 #endif /* _WINE_INTERNET_H_ */