Properly implement DllCanUnloadNow ref counting.
[wine/multimedia.git] / dlls / wininet / internet.h
blobdda81a4325ef5e3fb77f8f45fec45336cd3d2992
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 int ssl_sock;
65 #endif
66 } WININET_NETCONNECTION;
68 inline static LPSTR WININET_strdup( LPCSTR str )
70 LPSTR ret = HeapAlloc( GetProcessHeap(), 0, strlen(str) + 1 );
71 if (ret) strcpy( ret, str );
72 return ret;
75 inline static LPWSTR WININET_strdupW( LPCWSTR str )
77 LPWSTR ret = HeapAlloc( GetProcessHeap(), 0, (strlenW(str) + 1)*sizeof(WCHAR) );
78 if (ret) strcpyW( ret, str );
79 return ret;
82 inline static LPWSTR WININET_strdup_AtoW( LPCSTR str )
84 int len = MultiByteToWideChar( CP_ACP, 0, str, -1, NULL, 0);
85 LPWSTR ret = HeapAlloc( GetProcessHeap(), 0, len * sizeof(WCHAR) );
86 if (ret)
87 MultiByteToWideChar( CP_ACP, 0, str, -1, ret, len);
88 return ret;
91 inline static LPSTR WININET_strdup_WtoA( LPCWSTR str )
93 int len = WideCharToMultiByte( CP_ACP, 0, str, -1, NULL, 0, NULL, NULL);
94 LPSTR ret = HeapAlloc( GetProcessHeap(), 0, len );
95 if (ret)
96 WideCharToMultiByte( CP_ACP, 0, str, -1, ret, len, NULL, NULL);
97 return ret;
100 inline static void WININET_find_data_WtoA(LPWIN32_FIND_DATAW dataW, LPWIN32_FIND_DATAA dataA)
102 dataA->dwFileAttributes = dataW->dwFileAttributes;
103 dataA->ftCreationTime = dataW->ftCreationTime;
104 dataA->ftLastAccessTime = dataW->ftLastAccessTime;
105 dataA->ftLastWriteTime = dataW->ftLastWriteTime;
106 dataA->nFileSizeHigh = dataW->nFileSizeHigh;
107 dataA->nFileSizeLow = dataW->nFileSizeLow;
108 dataA->dwReserved0 = dataW->dwReserved0;
109 dataA->dwReserved1 = dataW->dwReserved1;
110 WideCharToMultiByte(CP_ACP, 0, dataW->cFileName, -1,
111 dataA->cFileName, sizeof(dataA->cFileName),
112 NULL, NULL);
113 WideCharToMultiByte(CP_ACP, 0, dataW->cAlternateFileName, -1,
114 dataA->cAlternateFileName, sizeof(dataA->cAlternateFileName),
115 NULL, NULL);
118 typedef enum
120 WH_HINIT = INTERNET_HANDLE_TYPE_INTERNET,
121 WH_HFTPSESSION = INTERNET_HANDLE_TYPE_CONNECT_FTP,
122 WH_HGOPHERSESSION = INTERNET_HANDLE_TYPE_CONNECT_GOPHER,
123 WH_HHTTPSESSION = INTERNET_HANDLE_TYPE_CONNECT_HTTP,
124 WH_HFILE = INTERNET_HANDLE_TYPE_FTP_FILE,
125 WH_HFINDNEXT = INTERNET_HANDLE_TYPE_FTP_FIND,
126 WH_HHTTPREQ = INTERNET_HANDLE_TYPE_HTTP_REQUEST,
127 } WH_TYPE;
129 #define INET_OPENURL 0x0001
130 #define INET_CALLBACKW 0x0002
132 struct _WININETHANDLEHEADER;
133 typedef struct _WININETHANDLEHEADER WININETHANDLEHEADER, *LPWININETHANDLEHEADER;
135 typedef void (*WININET_object_destructor)( LPWININETHANDLEHEADER );
137 struct _WININETHANDLEHEADER
139 WH_TYPE htype;
140 DWORD dwFlags;
141 DWORD dwContext;
142 DWORD dwError;
143 DWORD dwInternalFlags;
144 DWORD dwRefCount;
145 WININET_object_destructor destroy;
146 INTERNET_STATUS_CALLBACK lpfnStatusCB;
147 struct _WININETHANDLEHEADER *lpwhparent;
151 typedef struct
153 WININETHANDLEHEADER hdr;
154 LPWSTR lpszAgent;
155 LPWSTR lpszProxy;
156 LPWSTR lpszProxyBypass;
157 LPWSTR lpszProxyUsername;
158 LPWSTR lpszProxyPassword;
159 DWORD dwAccessType;
160 } WININETAPPINFOW, *LPWININETAPPINFOW;
163 typedef struct
165 WININETHANDLEHEADER hdr;
166 LPWSTR lpszServerName;
167 LPWSTR lpszUserName;
168 INTERNET_PORT nServerPort;
169 struct sockaddr_in socketAddress;
170 struct hostent *phostent;
171 } WININETHTTPSESSIONW, *LPWININETHTTPSESSIONW;
173 #define HDR_ISREQUEST 0x0001
174 #define HDR_COMMADELIMITED 0x0002
175 #define HDR_SEMIDELIMITED 0x0004
177 typedef struct
179 LPWSTR lpszField;
180 LPWSTR lpszValue;
181 WORD wFlags;
182 WORD wCount;
183 } HTTPHEADERW, *LPHTTPHEADERW;
186 typedef struct
188 WININETHANDLEHEADER hdr;
189 LPWSTR lpszPath;
190 LPWSTR lpszVerb;
191 LPWSTR lpszRawHeaders;
192 WININET_NETCONNECTION netConnection;
193 HTTPHEADERW StdHeaders[HTTP_QUERY_MAX+1];
194 HTTPHEADERW *pCustHeaders;
195 DWORD nCustHeaders;
196 } WININETHTTPREQW, *LPWININETHTTPREQW;
199 typedef struct
201 WININETHANDLEHEADER hdr;
202 BOOL session_deleted;
203 int nDataSocket;
204 } WININETFILE, *LPWININETFILE;
207 typedef struct
209 WININETHANDLEHEADER hdr;
210 int sndSocket;
211 int lstnSocket;
212 int pasvSocket; /* data socket connected by us in case of passive FTP */
213 LPWININETFILE download_in_progress;
214 struct sockaddr_in socketAddress;
215 struct sockaddr_in lstnSocketAddress;
216 struct hostent *phostent;
217 LPWSTR lpszPassword;
218 LPWSTR lpszUserName;
219 } WININETFTPSESSIONW, *LPWININETFTPSESSIONW;
222 typedef struct
224 BOOL bIsDirectory;
225 LPWSTR lpszName;
226 DWORD nSize;
227 struct tm tmLastModified;
228 unsigned short permissions;
229 } FILEPROPERTIESW, *LPFILEPROPERTIESW;
232 typedef struct
234 WININETHANDLEHEADER hdr;
235 DWORD index;
236 DWORD size;
237 LPFILEPROPERTIESW lpafp;
238 } WININETFINDNEXTW, *LPWININETFINDNEXTW;
240 typedef enum
242 FTPPUTFILEW,
243 FTPSETCURRENTDIRECTORYW,
244 FTPCREATEDIRECTORYW,
245 FTPFINDFIRSTFILEW,
246 FTPGETCURRENTDIRECTORYW,
247 FTPOPENFILEW,
248 FTPGETFILEW,
249 FTPDELETEFILEW,
250 FTPREMOVEDIRECTORYW,
251 FTPRENAMEFILEW,
252 INTERNETFINDNEXTW,
253 HTTPSENDREQUESTW,
254 HTTPOPENREQUESTW,
255 SENDCALLBACK,
256 INTERNETOPENURLW,
257 } ASYNC_FUNC;
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_INTERNETFINDNEXTW
327 LPWIN32_FIND_DATAW lpFindFileData;
330 struct WORKREQ_HTTPOPENREQUESTW
332 LPWSTR lpszVerb;
333 LPWSTR lpszObjectName;
334 LPWSTR lpszVersion;
335 LPWSTR lpszReferrer;
336 LPCWSTR *lpszAcceptTypes;
337 DWORD dwFlags;
338 DWORD dwContext;
341 struct WORKREQ_HTTPSENDREQUESTW
343 LPWSTR lpszHeader;
344 DWORD dwHeaderLength;
345 LPVOID lpOptional;
346 DWORD dwOptionalLength;
349 struct WORKREQ_SENDCALLBACK
351 DWORD 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 dwContext;
367 typedef struct WORKREQ
369 ASYNC_FUNC asyncall;
370 WININETHANDLEHEADER *hdr;
372 union {
373 struct WORKREQ_FTPPUTFILEW FtpPutFileW;
374 struct WORKREQ_FTPSETCURRENTDIRECTORYW FtpSetCurrentDirectoryW;
375 struct WORKREQ_FTPCREATEDIRECTORYW FtpCreateDirectoryW;
376 struct WORKREQ_FTPFINDFIRSTFILEW FtpFindFirstFileW;
377 struct WORKREQ_FTPGETCURRENTDIRECTORYW FtpGetCurrentDirectoryW;
378 struct WORKREQ_FTPOPENFILEW FtpOpenFileW;
379 struct WORKREQ_FTPGETFILEW FtpGetFileW;
380 struct WORKREQ_FTPDELETEFILEW FtpDeleteFileW;
381 struct WORKREQ_FTPREMOVEDIRECTORYW FtpRemoveDirectoryW;
382 struct WORKREQ_FTPRENAMEFILEW FtpRenameFileW;
383 struct WORKREQ_INTERNETFINDNEXTW InternetFindNextW;
384 struct WORKREQ_HTTPOPENREQUESTW HttpOpenRequestW;
385 struct WORKREQ_HTTPSENDREQUESTW HttpSendRequestW;
386 struct WORKREQ_SENDCALLBACK SendCallback;
387 struct WORKREQ_INTERNETOPENURLW InternetOpenUrlW;
388 } u;
390 struct WORKREQ *next;
391 struct WORKREQ *prev;
393 } WORKREQUEST, *LPWORKREQUEST;
395 HINTERNET WININET_AllocHandle( LPWININETHANDLEHEADER info );
396 LPWININETHANDLEHEADER WININET_GetObject( HINTERNET hinternet );
397 LPWININETHANDLEHEADER WININET_AddRef( LPWININETHANDLEHEADER info );
398 BOOL WININET_Release( LPWININETHANDLEHEADER info );
399 BOOL WININET_FreeHandle( HINTERNET hinternet );
400 HINTERNET WININET_FindHandle( LPWININETHANDLEHEADER info );
402 time_t ConvertTimeString(LPCWSTR asctime);
404 HINTERNET FTP_Connect(LPWININETAPPINFOW hIC, LPCWSTR lpszServerName,
405 INTERNET_PORT nServerPort, LPCWSTR lpszUserName,
406 LPCWSTR lpszPassword, DWORD dwFlags, DWORD dwContext,
407 DWORD dwInternalFlags);
409 HINTERNET HTTP_Connect(LPWININETAPPINFOW hIC, LPCWSTR lpszServerName,
410 INTERNET_PORT nServerPort, LPCWSTR lpszUserName,
411 LPCWSTR lpszPassword, DWORD dwFlags, DWORD dwContext,
412 DWORD dwInternalFlags);
414 BOOL GetAddress(LPCWSTR lpszServerName, INTERNET_PORT nServerPort,
415 struct hostent **phe, struct sockaddr_in *psa);
417 void INTERNET_SetLastError(DWORD dwError);
418 DWORD INTERNET_GetLastError(void);
419 BOOL INTERNET_AsyncCall(LPWORKREQUEST lpWorkRequest);
420 LPSTR INTERNET_GetResponseBuffer(void);
421 LPSTR INTERNET_GetNextLine(INT nSocket, LPDWORD dwLen);
423 BOOLAPI FTP_FtpPutFileW(LPWININETFTPSESSIONW lpwfs, LPCWSTR lpszLocalFile,
424 LPCWSTR lpszNewRemoteFile, DWORD dwFlags, DWORD dwContext);
425 BOOLAPI FTP_FtpSetCurrentDirectoryW(LPWININETFTPSESSIONW lpwfs, LPCWSTR lpszDirectory);
426 BOOLAPI FTP_FtpCreateDirectoryW(LPWININETFTPSESSIONW lpwfs, LPCWSTR lpszDirectory);
427 INTERNETAPI HINTERNET WINAPI FTP_FtpFindFirstFileW(LPWININETFTPSESSIONW lpwfs,
428 LPCWSTR lpszSearchFile, LPWIN32_FIND_DATAW lpFindFileData, DWORD dwFlags, DWORD dwContext);
429 BOOLAPI FTP_FtpGetCurrentDirectoryW(LPWININETFTPSESSIONW lpwfs, LPWSTR lpszCurrentDirectory,
430 LPDWORD lpdwCurrentDirectory);
431 BOOL FTP_ConvertFileProp(LPFILEPROPERTIESW lpafp, LPWIN32_FIND_DATAW lpFindFileData);
432 BOOL FTP_FtpRenameFileW(LPWININETFTPSESSIONW lpwfs, LPCWSTR lpszSrc, LPCWSTR lpszDest);
433 BOOL FTP_FtpRemoveDirectoryW(LPWININETFTPSESSIONW lpwfs, LPCWSTR lpszDirectory);
434 BOOL FTP_FtpDeleteFileW(LPWININETFTPSESSIONW lpwfs, LPCWSTR lpszFileName);
435 HINTERNET FTP_FtpOpenFileW(LPWININETFTPSESSIONW lpwfs, LPCWSTR lpszFileName,
436 DWORD fdwAccess, DWORD dwFlags, DWORD dwContext);
437 BOOLAPI FTP_FtpGetFileW(LPWININETFTPSESSIONW lpwfs, LPCWSTR lpszRemoteFile, LPCWSTR lpszNewFile,
438 BOOL fFailIfExists, DWORD dwLocalFlagsAttribute, DWORD dwInternetFlags,
439 DWORD dwContext);
441 BOOLAPI HTTP_HttpSendRequestW(LPWININETHTTPREQW lpwhr, LPCWSTR lpszHeaders,
442 DWORD dwHeaderLength, LPVOID lpOptional ,DWORD dwOptionalLength);
443 INTERNETAPI HINTERNET WINAPI HTTP_HttpOpenRequestW(LPWININETHTTPSESSIONW lpwhs,
444 LPCWSTR lpszVerb, LPCWSTR lpszObjectName, LPCWSTR lpszVersion,
445 LPCWSTR lpszReferrer , LPCWSTR *lpszAcceptTypes,
446 DWORD dwFlags, DWORD dwContext);
448 VOID SendAsyncCallback(LPWININETHANDLEHEADER hdr, DWORD dwContext,
449 DWORD dwInternetStatus, LPVOID lpvStatusInfo,
450 DWORD dwStatusInfoLength);
452 VOID SendSyncCallback(LPWININETHANDLEHEADER hdr, DWORD dwContext,
453 DWORD dwInternetStatus, LPVOID lpvStatusInfo,
454 DWORD dwStatusInfoLength);
456 BOOL HTTP_InsertProxyAuthorization( LPWININETHTTPREQW lpwhr,
457 LPCWSTR username, LPCWSTR password );
459 BOOL NETCON_connected(WININET_NETCONNECTION *connection);
460 void NETCON_init(WININET_NETCONNECTION *connnection, BOOL useSSL);
461 BOOL NETCON_create(WININET_NETCONNECTION *connection, int domain,
462 int type, int protocol);
463 BOOL NETCON_close(WININET_NETCONNECTION *connection);
464 BOOL NETCON_connect(WININET_NETCONNECTION *connection, const struct sockaddr *serv_addr,
465 unsigned int addrlen);
466 BOOL NETCON_send(WININET_NETCONNECTION *connection, const void *msg, size_t len, int flags,
467 int *sent /* out */);
468 BOOL NETCON_recv(WININET_NETCONNECTION *connection, void *buf, size_t len, int flags,
469 int *recvd /* out */);
470 BOOL NETCON_getNextLine(WININET_NETCONNECTION *connection, LPSTR lpszBuffer, LPDWORD dwBuffer);
472 #define MAX_REPLY_LEN 0x5B4
474 /* Used for debugging - maybe need to be shared in the Wine debugging code ? */
475 typedef struct
477 DWORD val;
478 const char* name;
479 } wininet_flag_info;
481 extern void dump_INTERNET_FLAGS(DWORD dwFlags) ;
483 #endif /* _WINE_INTERNET_H_ */