Add a host port field that preserves the requested port of the
[wine/gsoc_dplay.git] / dlls / wininet / internet.h
blobad3ce72e37955e5cad99c7b27079476f74bd7761
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 #if defined(__MINGW32__) || defined (_MSC_VER)
49 #include "winsock2.h"
50 #ifndef MSG_WAITALL
51 #define MSG_WAITALL 0
52 #endif
53 #else
54 #define closesocket close
55 #endif /* __MINGW32__ */
57 /* used for netconnection.c stuff */
58 typedef struct
60 BOOL useSSL;
61 int socketFD;
62 #ifdef HAVE_OPENSSL_SSL_H
63 SSL *ssl_s;
64 char *peek_msg;
65 char *peek_msg_mem;
66 #endif
67 } WININET_NETCONNECTION;
69 inline static LPSTR WININET_strdup( LPCSTR str )
71 LPSTR ret = HeapAlloc( GetProcessHeap(), 0, strlen(str) + 1 );
72 if (ret) strcpy( ret, str );
73 return ret;
76 inline static LPWSTR WININET_strdupW( LPCWSTR str )
78 LPWSTR ret = HeapAlloc( GetProcessHeap(), 0, (strlenW(str) + 1)*sizeof(WCHAR) );
79 if (ret) strcpyW( ret, str );
80 return ret;
83 inline static LPWSTR WININET_strdup_AtoW( LPCSTR str )
85 int len = MultiByteToWideChar( CP_ACP, 0, str, -1, NULL, 0);
86 LPWSTR ret = HeapAlloc( GetProcessHeap(), 0, len * sizeof(WCHAR) );
87 if (ret)
88 MultiByteToWideChar( CP_ACP, 0, str, -1, ret, len);
89 return ret;
92 inline static LPSTR WININET_strdup_WtoA( LPCWSTR str )
94 int len = WideCharToMultiByte( CP_ACP, 0, str, -1, NULL, 0, NULL, NULL);
95 LPSTR ret = HeapAlloc( GetProcessHeap(), 0, len );
96 if (ret)
97 WideCharToMultiByte( CP_ACP, 0, str, -1, ret, len, NULL, NULL);
98 return ret;
101 inline static void WININET_find_data_WtoA(LPWIN32_FIND_DATAW dataW, LPWIN32_FIND_DATAA dataA)
103 dataA->dwFileAttributes = dataW->dwFileAttributes;
104 dataA->ftCreationTime = dataW->ftCreationTime;
105 dataA->ftLastAccessTime = dataW->ftLastAccessTime;
106 dataA->ftLastWriteTime = dataW->ftLastWriteTime;
107 dataA->nFileSizeHigh = dataW->nFileSizeHigh;
108 dataA->nFileSizeLow = dataW->nFileSizeLow;
109 dataA->dwReserved0 = dataW->dwReserved0;
110 dataA->dwReserved1 = dataW->dwReserved1;
111 WideCharToMultiByte(CP_ACP, 0, dataW->cFileName, -1,
112 dataA->cFileName, sizeof(dataA->cFileName),
113 NULL, NULL);
114 WideCharToMultiByte(CP_ACP, 0, dataW->cAlternateFileName, -1,
115 dataA->cAlternateFileName, sizeof(dataA->cAlternateFileName),
116 NULL, NULL);
119 typedef enum
121 WH_HINIT = INTERNET_HANDLE_TYPE_INTERNET,
122 WH_HFTPSESSION = INTERNET_HANDLE_TYPE_CONNECT_FTP,
123 WH_HGOPHERSESSION = INTERNET_HANDLE_TYPE_CONNECT_GOPHER,
124 WH_HHTTPSESSION = INTERNET_HANDLE_TYPE_CONNECT_HTTP,
125 WH_HFILE = INTERNET_HANDLE_TYPE_FTP_FILE,
126 WH_HFINDNEXT = INTERNET_HANDLE_TYPE_FTP_FIND,
127 WH_HHTTPREQ = INTERNET_HANDLE_TYPE_HTTP_REQUEST,
128 } WH_TYPE;
130 #define INET_OPENURL 0x0001
131 #define INET_CALLBACKW 0x0002
133 struct _WININETHANDLEHEADER;
134 typedef struct _WININETHANDLEHEADER WININETHANDLEHEADER, *LPWININETHANDLEHEADER;
136 typedef void (*WININET_object_destructor)( LPWININETHANDLEHEADER );
138 struct _WININETHANDLEHEADER
140 WH_TYPE htype;
141 DWORD dwFlags;
142 DWORD dwContext;
143 DWORD dwError;
144 DWORD dwInternalFlags;
145 DWORD dwRefCount;
146 WININET_object_destructor destroy;
147 INTERNET_STATUS_CALLBACK lpfnStatusCB;
148 struct _WININETHANDLEHEADER *lpwhparent;
152 typedef struct
154 WININETHANDLEHEADER hdr;
155 LPWSTR lpszAgent;
156 LPWSTR lpszProxy;
157 LPWSTR lpszProxyBypass;
158 LPWSTR lpszProxyUsername;
159 LPWSTR lpszProxyPassword;
160 DWORD dwAccessType;
161 } WININETAPPINFOW, *LPWININETAPPINFOW;
164 typedef struct
166 WININETHANDLEHEADER hdr;
167 LPWSTR lpszHostName; /* the final destination of the request */
168 LPWSTR lpszServerName; /* the name of the server we directly connect to */
169 LPWSTR lpszUserName;
170 INTERNET_PORT nHostPort; /* the final destination port of the request */
171 INTERNET_PORT nServerPort; /* the port of the server we directly connect to */
172 struct sockaddr_in socketAddress;
173 } WININETHTTPSESSIONW, *LPWININETHTTPSESSIONW;
175 #define HDR_ISREQUEST 0x0001
176 #define HDR_COMMADELIMITED 0x0002
177 #define HDR_SEMIDELIMITED 0x0004
179 typedef struct
181 LPWSTR lpszField;
182 LPWSTR lpszValue;
183 WORD wFlags;
184 WORD wCount;
185 } HTTPHEADERW, *LPHTTPHEADERW;
188 typedef struct
190 WININETHANDLEHEADER hdr;
191 LPWSTR lpszPath;
192 LPWSTR lpszVerb;
193 LPWSTR lpszRawHeaders;
194 WININET_NETCONNECTION netConnection;
195 HTTPHEADERW StdHeaders[HTTP_QUERY_MAX+1];
196 HTTPHEADERW *pCustHeaders;
197 DWORD nCustHeaders;
198 } WININETHTTPREQW, *LPWININETHTTPREQW;
201 typedef struct
203 WININETHANDLEHEADER hdr;
204 BOOL session_deleted;
205 int nDataSocket;
206 } WININETFILE, *LPWININETFILE;
209 typedef struct
211 WININETHANDLEHEADER hdr;
212 int sndSocket;
213 int lstnSocket;
214 int pasvSocket; /* data socket connected by us in case of passive FTP */
215 LPWININETFILE download_in_progress;
216 struct sockaddr_in socketAddress;
217 struct sockaddr_in lstnSocketAddress;
218 LPWSTR lpszPassword;
219 LPWSTR lpszUserName;
220 } WININETFTPSESSIONW, *LPWININETFTPSESSIONW;
223 typedef struct
225 BOOL bIsDirectory;
226 LPWSTR lpszName;
227 DWORD nSize;
228 struct tm tmLastModified;
229 unsigned short permissions;
230 } FILEPROPERTIESW, *LPFILEPROPERTIESW;
233 typedef struct
235 WININETHANDLEHEADER hdr;
236 DWORD index;
237 DWORD size;
238 LPFILEPROPERTIESW lpafp;
239 } WININETFINDNEXTW, *LPWININETFINDNEXTW;
241 typedef enum
243 FTPPUTFILEW,
244 FTPSETCURRENTDIRECTORYW,
245 FTPCREATEDIRECTORYW,
246 FTPFINDFIRSTFILEW,
247 FTPGETCURRENTDIRECTORYW,
248 FTPOPENFILEW,
249 FTPGETFILEW,
250 FTPDELETEFILEW,
251 FTPREMOVEDIRECTORYW,
252 FTPRENAMEFILEW,
253 INTERNETFINDNEXTW,
254 HTTPSENDREQUESTW,
255 HTTPOPENREQUESTW,
256 SENDCALLBACK,
257 INTERNETOPENURLW,
258 INTERNETREADFILEEXA,
259 } ASYNC_FUNC;
261 struct WORKREQ_FTPPUTFILEW
263 LPWSTR lpszLocalFile;
264 LPWSTR lpszNewRemoteFile;
265 DWORD dwFlags;
266 DWORD dwContext;
269 struct WORKREQ_FTPSETCURRENTDIRECTORYW
271 LPWSTR lpszDirectory;
274 struct WORKREQ_FTPCREATEDIRECTORYW
276 LPWSTR lpszDirectory;
279 struct WORKREQ_FTPFINDFIRSTFILEW
281 LPWSTR lpszSearchFile;
282 LPWIN32_FIND_DATAW lpFindFileData;
283 DWORD dwFlags;
284 DWORD dwContext;
287 struct WORKREQ_FTPGETCURRENTDIRECTORYW
289 LPWSTR lpszDirectory;
290 DWORD *lpdwDirectory;
293 struct WORKREQ_FTPOPENFILEW
295 LPWSTR lpszFilename;
296 DWORD dwAccess;
297 DWORD dwFlags;
298 DWORD dwContext;
301 struct WORKREQ_FTPGETFILEW
303 LPWSTR lpszRemoteFile;
304 LPWSTR lpszNewFile;
305 BOOL fFailIfExists;
306 DWORD dwLocalFlagsAttribute;
307 DWORD dwFlags;
308 DWORD dwContext;
311 struct WORKREQ_FTPDELETEFILEW
313 LPWSTR lpszFilename;
316 struct WORKREQ_FTPREMOVEDIRECTORYW
318 LPWSTR lpszDirectory;
321 struct WORKREQ_FTPRENAMEFILEW
323 LPWSTR lpszSrcFile;
324 LPWSTR lpszDestFile;
327 struct WORKREQ_INTERNETFINDNEXTW
329 LPWIN32_FIND_DATAW lpFindFileData;
332 struct WORKREQ_HTTPOPENREQUESTW
334 LPWSTR lpszVerb;
335 LPWSTR lpszObjectName;
336 LPWSTR lpszVersion;
337 LPWSTR lpszReferrer;
338 LPCWSTR *lpszAcceptTypes;
339 DWORD dwFlags;
340 DWORD dwContext;
343 struct WORKREQ_HTTPSENDREQUESTW
345 LPWSTR lpszHeader;
346 DWORD dwHeaderLength;
347 LPVOID lpOptional;
348 DWORD dwOptionalLength;
351 struct WORKREQ_SENDCALLBACK
353 DWORD dwContext;
354 DWORD dwInternetStatus;
355 LPVOID lpvStatusInfo;
356 DWORD dwStatusInfoLength;
359 struct WORKREQ_INTERNETOPENURLW
361 HINTERNET hInternet;
362 LPWSTR lpszUrl;
363 LPWSTR lpszHeaders;
364 DWORD dwHeadersLength;
365 DWORD dwFlags;
366 DWORD dwContext;
369 struct WORKREQ_INTERNETREADFILEEXA
371 LPINTERNET_BUFFERSA lpBuffersOut;
374 typedef struct WORKREQ
376 ASYNC_FUNC asyncall;
377 WININETHANDLEHEADER *hdr;
379 union {
380 struct WORKREQ_FTPPUTFILEW FtpPutFileW;
381 struct WORKREQ_FTPSETCURRENTDIRECTORYW FtpSetCurrentDirectoryW;
382 struct WORKREQ_FTPCREATEDIRECTORYW FtpCreateDirectoryW;
383 struct WORKREQ_FTPFINDFIRSTFILEW FtpFindFirstFileW;
384 struct WORKREQ_FTPGETCURRENTDIRECTORYW FtpGetCurrentDirectoryW;
385 struct WORKREQ_FTPOPENFILEW FtpOpenFileW;
386 struct WORKREQ_FTPGETFILEW FtpGetFileW;
387 struct WORKREQ_FTPDELETEFILEW FtpDeleteFileW;
388 struct WORKREQ_FTPREMOVEDIRECTORYW FtpRemoveDirectoryW;
389 struct WORKREQ_FTPRENAMEFILEW FtpRenameFileW;
390 struct WORKREQ_INTERNETFINDNEXTW InternetFindNextW;
391 struct WORKREQ_HTTPOPENREQUESTW HttpOpenRequestW;
392 struct WORKREQ_HTTPSENDREQUESTW HttpSendRequestW;
393 struct WORKREQ_SENDCALLBACK SendCallback;
394 struct WORKREQ_INTERNETOPENURLW InternetOpenUrlW;
395 struct WORKREQ_INTERNETREADFILEEXA InternetReadFileExA;
396 } u;
398 struct WORKREQ *next;
399 struct WORKREQ *prev;
401 } WORKREQUEST, *LPWORKREQUEST;
403 HINTERNET WININET_AllocHandle( LPWININETHANDLEHEADER info );
404 LPWININETHANDLEHEADER WININET_GetObject( HINTERNET hinternet );
405 LPWININETHANDLEHEADER WININET_AddRef( LPWININETHANDLEHEADER info );
406 BOOL WININET_Release( LPWININETHANDLEHEADER info );
407 BOOL WININET_FreeHandle( HINTERNET hinternet );
408 HINTERNET WININET_FindHandle( LPWININETHANDLEHEADER info );
410 time_t ConvertTimeString(LPCWSTR asctime);
412 HINTERNET FTP_Connect(LPWININETAPPINFOW hIC, LPCWSTR lpszServerName,
413 INTERNET_PORT nServerPort, LPCWSTR lpszUserName,
414 LPCWSTR lpszPassword, DWORD dwFlags, DWORD dwContext,
415 DWORD dwInternalFlags);
417 HINTERNET HTTP_Connect(LPWININETAPPINFOW hIC, LPCWSTR lpszServerName,
418 INTERNET_PORT nServerPort, LPCWSTR lpszUserName,
419 LPCWSTR lpszPassword, DWORD dwFlags, DWORD dwContext,
420 DWORD dwInternalFlags);
422 BOOL GetAddress(LPCWSTR lpszServerName, INTERNET_PORT nServerPort,
423 struct sockaddr_in *psa);
425 void INTERNET_SetLastError(DWORD dwError);
426 DWORD INTERNET_GetLastError(void);
427 BOOL INTERNET_AsyncCall(LPWORKREQUEST lpWorkRequest);
428 LPSTR INTERNET_GetResponseBuffer(void);
429 LPSTR INTERNET_GetNextLine(INT nSocket, LPDWORD dwLen);
431 BOOLAPI FTP_FtpPutFileW(LPWININETFTPSESSIONW lpwfs, LPCWSTR lpszLocalFile,
432 LPCWSTR lpszNewRemoteFile, DWORD dwFlags, DWORD dwContext);
433 BOOLAPI FTP_FtpSetCurrentDirectoryW(LPWININETFTPSESSIONW lpwfs, LPCWSTR lpszDirectory);
434 BOOLAPI FTP_FtpCreateDirectoryW(LPWININETFTPSESSIONW lpwfs, LPCWSTR lpszDirectory);
435 INTERNETAPI HINTERNET WINAPI FTP_FtpFindFirstFileW(LPWININETFTPSESSIONW lpwfs,
436 LPCWSTR lpszSearchFile, LPWIN32_FIND_DATAW lpFindFileData, DWORD dwFlags, DWORD dwContext);
437 BOOLAPI FTP_FtpGetCurrentDirectoryW(LPWININETFTPSESSIONW lpwfs, LPWSTR lpszCurrentDirectory,
438 LPDWORD lpdwCurrentDirectory);
439 BOOL FTP_ConvertFileProp(LPFILEPROPERTIESW lpafp, LPWIN32_FIND_DATAW lpFindFileData);
440 BOOL FTP_FtpRenameFileW(LPWININETFTPSESSIONW lpwfs, LPCWSTR lpszSrc, LPCWSTR lpszDest);
441 BOOL FTP_FtpRemoveDirectoryW(LPWININETFTPSESSIONW lpwfs, LPCWSTR lpszDirectory);
442 BOOL FTP_FtpDeleteFileW(LPWININETFTPSESSIONW lpwfs, LPCWSTR lpszFileName);
443 HINTERNET FTP_FtpOpenFileW(LPWININETFTPSESSIONW lpwfs, LPCWSTR lpszFileName,
444 DWORD fdwAccess, DWORD dwFlags, DWORD dwContext);
445 BOOLAPI FTP_FtpGetFileW(LPWININETFTPSESSIONW lpwfs, LPCWSTR lpszRemoteFile, LPCWSTR lpszNewFile,
446 BOOL fFailIfExists, DWORD dwLocalFlagsAttribute, DWORD dwInternetFlags,
447 DWORD dwContext);
449 BOOLAPI HTTP_HttpSendRequestW(LPWININETHTTPREQW lpwhr, LPCWSTR lpszHeaders,
450 DWORD dwHeaderLength, LPVOID lpOptional ,DWORD dwOptionalLength);
451 INTERNETAPI HINTERNET WINAPI HTTP_HttpOpenRequestW(LPWININETHTTPSESSIONW lpwhs,
452 LPCWSTR lpszVerb, LPCWSTR lpszObjectName, LPCWSTR lpszVersion,
453 LPCWSTR lpszReferrer , LPCWSTR *lpszAcceptTypes,
454 DWORD dwFlags, DWORD dwContext);
456 VOID SendAsyncCallback(LPWININETHANDLEHEADER hdr, DWORD dwContext,
457 DWORD dwInternetStatus, LPVOID lpvStatusInfo,
458 DWORD dwStatusInfoLength);
460 VOID INTERNET_SendCallback(LPWININETHANDLEHEADER hdr, DWORD dwContext,
461 DWORD dwInternetStatus, LPVOID lpvStatusInfo,
462 DWORD dwStatusInfoLength);
464 BOOL NETCON_connected(WININET_NETCONNECTION *connection);
465 void 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_send(WININET_NETCONNECTION *connection, const void *msg, size_t len, int flags,
472 int *sent /* out */);
473 BOOL NETCON_recv(WININET_NETCONNECTION *connection, void *buf, size_t len, int flags,
474 int *recvd /* out */);
475 BOOL NETCON_getNextLine(WININET_NETCONNECTION *connection, LPSTR lpszBuffer, LPDWORD dwBuffer);
477 extern void URLCacheContainers_CreateDefaults(void);
478 extern void URLCacheContainers_DeleteAll(void);
480 #define MAX_REPLY_LEN 0x5B4
482 /* Used for debugging - maybe need to be shared in the Wine debugging code ? */
483 typedef struct
485 DWORD val;
486 const char* name;
487 } wininet_flag_info;
489 extern void dump_INTERNET_FLAGS(DWORD dwFlags) ;
491 #endif /* _WINE_INTERNET_H_ */