Implement InternetReadFileExA (based on a patch by Brian Gerst).
[wine/multimedia.git] / dlls / wininet / internet.h
blobaca7c54e76b97d1b4023c6b3a0c79ed342c05fd1
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 char *peek_msg;
66 char *peek_msg_mem;
67 #endif
68 } WININET_NETCONNECTION;
70 inline static LPSTR WININET_strdup( LPCSTR str )
72 LPSTR ret = HeapAlloc( GetProcessHeap(), 0, strlen(str) + 1 );
73 if (ret) strcpy( ret, str );
74 return ret;
77 inline static LPWSTR WININET_strdupW( LPCWSTR str )
79 LPWSTR ret = HeapAlloc( GetProcessHeap(), 0, (strlenW(str) + 1)*sizeof(WCHAR) );
80 if (ret) strcpyW( ret, str );
81 return ret;
84 inline static LPWSTR WININET_strdup_AtoW( LPCSTR str )
86 int len = MultiByteToWideChar( CP_ACP, 0, str, -1, NULL, 0);
87 LPWSTR ret = HeapAlloc( GetProcessHeap(), 0, len * sizeof(WCHAR) );
88 if (ret)
89 MultiByteToWideChar( CP_ACP, 0, str, -1, ret, len);
90 return ret;
93 inline static LPSTR WININET_strdup_WtoA( LPCWSTR str )
95 int len = WideCharToMultiByte( CP_ACP, 0, str, -1, NULL, 0, NULL, NULL);
96 LPSTR ret = HeapAlloc( GetProcessHeap(), 0, len );
97 if (ret)
98 WideCharToMultiByte( CP_ACP, 0, str, -1, ret, len, NULL, NULL);
99 return ret;
102 inline static void WININET_find_data_WtoA(LPWIN32_FIND_DATAW dataW, LPWIN32_FIND_DATAA dataA)
104 dataA->dwFileAttributes = dataW->dwFileAttributes;
105 dataA->ftCreationTime = dataW->ftCreationTime;
106 dataA->ftLastAccessTime = dataW->ftLastAccessTime;
107 dataA->ftLastWriteTime = dataW->ftLastWriteTime;
108 dataA->nFileSizeHigh = dataW->nFileSizeHigh;
109 dataA->nFileSizeLow = dataW->nFileSizeLow;
110 dataA->dwReserved0 = dataW->dwReserved0;
111 dataA->dwReserved1 = dataW->dwReserved1;
112 WideCharToMultiByte(CP_ACP, 0, dataW->cFileName, -1,
113 dataA->cFileName, sizeof(dataA->cFileName),
114 NULL, NULL);
115 WideCharToMultiByte(CP_ACP, 0, dataW->cAlternateFileName, -1,
116 dataA->cAlternateFileName, sizeof(dataA->cAlternateFileName),
117 NULL, NULL);
120 typedef enum
122 WH_HINIT = INTERNET_HANDLE_TYPE_INTERNET,
123 WH_HFTPSESSION = INTERNET_HANDLE_TYPE_CONNECT_FTP,
124 WH_HGOPHERSESSION = INTERNET_HANDLE_TYPE_CONNECT_GOPHER,
125 WH_HHTTPSESSION = INTERNET_HANDLE_TYPE_CONNECT_HTTP,
126 WH_HFILE = INTERNET_HANDLE_TYPE_FTP_FILE,
127 WH_HFINDNEXT = INTERNET_HANDLE_TYPE_FTP_FIND,
128 WH_HHTTPREQ = INTERNET_HANDLE_TYPE_HTTP_REQUEST,
129 } WH_TYPE;
131 #define INET_OPENURL 0x0001
132 #define INET_CALLBACKW 0x0002
134 struct _WININETHANDLEHEADER;
135 typedef struct _WININETHANDLEHEADER WININETHANDLEHEADER, *LPWININETHANDLEHEADER;
137 typedef void (*WININET_object_destructor)( LPWININETHANDLEHEADER );
139 struct _WININETHANDLEHEADER
141 WH_TYPE htype;
142 DWORD dwFlags;
143 DWORD dwContext;
144 DWORD dwError;
145 DWORD dwInternalFlags;
146 DWORD dwRefCount;
147 WININET_object_destructor destroy;
148 INTERNET_STATUS_CALLBACK lpfnStatusCB;
149 struct _WININETHANDLEHEADER *lpwhparent;
153 typedef struct
155 WININETHANDLEHEADER hdr;
156 LPWSTR lpszAgent;
157 LPWSTR lpszProxy;
158 LPWSTR lpszProxyBypass;
159 LPWSTR lpszProxyUsername;
160 LPWSTR lpszProxyPassword;
161 DWORD dwAccessType;
162 } WININETAPPINFOW, *LPWININETAPPINFOW;
165 typedef struct
167 WININETHANDLEHEADER hdr;
168 LPWSTR lpszServerName;
169 LPWSTR lpszUserName;
170 INTERNET_PORT nServerPort;
171 struct sockaddr_in socketAddress;
172 struct hostent *phostent;
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 struct hostent *phostent;
219 LPWSTR lpszPassword;
220 LPWSTR lpszUserName;
221 } WININETFTPSESSIONW, *LPWININETFTPSESSIONW;
224 typedef struct
226 BOOL bIsDirectory;
227 LPWSTR lpszName;
228 DWORD nSize;
229 struct tm tmLastModified;
230 unsigned short permissions;
231 } FILEPROPERTIESW, *LPFILEPROPERTIESW;
234 typedef struct
236 WININETHANDLEHEADER hdr;
237 DWORD index;
238 DWORD size;
239 LPFILEPROPERTIESW lpafp;
240 } WININETFINDNEXTW, *LPWININETFINDNEXTW;
242 typedef enum
244 FTPPUTFILEW,
245 FTPSETCURRENTDIRECTORYW,
246 FTPCREATEDIRECTORYW,
247 FTPFINDFIRSTFILEW,
248 FTPGETCURRENTDIRECTORYW,
249 FTPOPENFILEW,
250 FTPGETFILEW,
251 FTPDELETEFILEW,
252 FTPREMOVEDIRECTORYW,
253 FTPRENAMEFILEW,
254 INTERNETFINDNEXTW,
255 HTTPSENDREQUESTW,
256 HTTPOPENREQUESTW,
257 SENDCALLBACK,
258 INTERNETOPENURLW,
259 INTERNETREADFILEEXA,
260 } ASYNC_FUNC;
262 struct WORKREQ_FTPPUTFILEW
264 LPWSTR lpszLocalFile;
265 LPWSTR lpszNewRemoteFile;
266 DWORD dwFlags;
267 DWORD dwContext;
270 struct WORKREQ_FTPSETCURRENTDIRECTORYW
272 LPWSTR lpszDirectory;
275 struct WORKREQ_FTPCREATEDIRECTORYW
277 LPWSTR lpszDirectory;
280 struct WORKREQ_FTPFINDFIRSTFILEW
282 LPWSTR lpszSearchFile;
283 LPWIN32_FIND_DATAW lpFindFileData;
284 DWORD dwFlags;
285 DWORD dwContext;
288 struct WORKREQ_FTPGETCURRENTDIRECTORYW
290 LPWSTR lpszDirectory;
291 DWORD *lpdwDirectory;
294 struct WORKREQ_FTPOPENFILEW
296 LPWSTR lpszFilename;
297 DWORD dwAccess;
298 DWORD dwFlags;
299 DWORD dwContext;
302 struct WORKREQ_FTPGETFILEW
304 LPWSTR lpszRemoteFile;
305 LPWSTR lpszNewFile;
306 BOOL fFailIfExists;
307 DWORD dwLocalFlagsAttribute;
308 DWORD dwFlags;
309 DWORD dwContext;
312 struct WORKREQ_FTPDELETEFILEW
314 LPWSTR lpszFilename;
317 struct WORKREQ_FTPREMOVEDIRECTORYW
319 LPWSTR lpszDirectory;
322 struct WORKREQ_FTPRENAMEFILEW
324 LPWSTR lpszSrcFile;
325 LPWSTR lpszDestFile;
328 struct WORKREQ_INTERNETFINDNEXTW
330 LPWIN32_FIND_DATAW lpFindFileData;
333 struct WORKREQ_HTTPOPENREQUESTW
335 LPWSTR lpszVerb;
336 LPWSTR lpszObjectName;
337 LPWSTR lpszVersion;
338 LPWSTR lpszReferrer;
339 LPCWSTR *lpszAcceptTypes;
340 DWORD dwFlags;
341 DWORD dwContext;
344 struct WORKREQ_HTTPSENDREQUESTW
346 LPWSTR lpszHeader;
347 DWORD dwHeaderLength;
348 LPVOID lpOptional;
349 DWORD dwOptionalLength;
352 struct WORKREQ_SENDCALLBACK
354 DWORD dwContext;
355 DWORD dwInternetStatus;
356 LPVOID lpvStatusInfo;
357 DWORD dwStatusInfoLength;
360 struct WORKREQ_INTERNETOPENURLW
362 HINTERNET hInternet;
363 LPWSTR lpszUrl;
364 LPWSTR lpszHeaders;
365 DWORD dwHeadersLength;
366 DWORD dwFlags;
367 DWORD dwContext;
370 struct WORKREQ_INTERNETREADFILEEXA
372 LPINTERNET_BUFFERSA lpBuffersOut;
375 typedef struct WORKREQ
377 ASYNC_FUNC asyncall;
378 WININETHANDLEHEADER *hdr;
380 union {
381 struct WORKREQ_FTPPUTFILEW FtpPutFileW;
382 struct WORKREQ_FTPSETCURRENTDIRECTORYW FtpSetCurrentDirectoryW;
383 struct WORKREQ_FTPCREATEDIRECTORYW FtpCreateDirectoryW;
384 struct WORKREQ_FTPFINDFIRSTFILEW FtpFindFirstFileW;
385 struct WORKREQ_FTPGETCURRENTDIRECTORYW FtpGetCurrentDirectoryW;
386 struct WORKREQ_FTPOPENFILEW FtpOpenFileW;
387 struct WORKREQ_FTPGETFILEW FtpGetFileW;
388 struct WORKREQ_FTPDELETEFILEW FtpDeleteFileW;
389 struct WORKREQ_FTPREMOVEDIRECTORYW FtpRemoveDirectoryW;
390 struct WORKREQ_FTPRENAMEFILEW FtpRenameFileW;
391 struct WORKREQ_INTERNETFINDNEXTW InternetFindNextW;
392 struct WORKREQ_HTTPOPENREQUESTW HttpOpenRequestW;
393 struct WORKREQ_HTTPSENDREQUESTW HttpSendRequestW;
394 struct WORKREQ_SENDCALLBACK SendCallback;
395 struct WORKREQ_INTERNETOPENURLW InternetOpenUrlW;
396 struct WORKREQ_INTERNETREADFILEEXA InternetReadFileExA;
397 } u;
399 struct WORKREQ *next;
400 struct WORKREQ *prev;
402 } WORKREQUEST, *LPWORKREQUEST;
404 HINTERNET WININET_AllocHandle( LPWININETHANDLEHEADER info );
405 LPWININETHANDLEHEADER WININET_GetObject( HINTERNET hinternet );
406 LPWININETHANDLEHEADER WININET_AddRef( LPWININETHANDLEHEADER info );
407 BOOL WININET_Release( LPWININETHANDLEHEADER info );
408 BOOL WININET_FreeHandle( HINTERNET hinternet );
409 HINTERNET WININET_FindHandle( LPWININETHANDLEHEADER info );
411 time_t ConvertTimeString(LPCWSTR asctime);
413 HINTERNET FTP_Connect(LPWININETAPPINFOW hIC, LPCWSTR lpszServerName,
414 INTERNET_PORT nServerPort, LPCWSTR lpszUserName,
415 LPCWSTR lpszPassword, DWORD dwFlags, DWORD dwContext,
416 DWORD dwInternalFlags);
418 HINTERNET HTTP_Connect(LPWININETAPPINFOW hIC, LPCWSTR lpszServerName,
419 INTERNET_PORT nServerPort, LPCWSTR lpszUserName,
420 LPCWSTR lpszPassword, DWORD dwFlags, DWORD dwContext,
421 DWORD dwInternalFlags);
423 BOOL GetAddress(LPCWSTR lpszServerName, INTERNET_PORT nServerPort,
424 struct hostent **phe, struct sockaddr_in *psa);
426 void INTERNET_SetLastError(DWORD dwError);
427 DWORD INTERNET_GetLastError(void);
428 BOOL INTERNET_AsyncCall(LPWORKREQUEST lpWorkRequest);
429 LPSTR INTERNET_GetResponseBuffer(void);
430 LPSTR INTERNET_GetNextLine(INT nSocket, LPDWORD dwLen);
432 BOOLAPI FTP_FtpPutFileW(LPWININETFTPSESSIONW lpwfs, LPCWSTR lpszLocalFile,
433 LPCWSTR lpszNewRemoteFile, DWORD dwFlags, DWORD dwContext);
434 BOOLAPI FTP_FtpSetCurrentDirectoryW(LPWININETFTPSESSIONW lpwfs, LPCWSTR lpszDirectory);
435 BOOLAPI FTP_FtpCreateDirectoryW(LPWININETFTPSESSIONW lpwfs, LPCWSTR lpszDirectory);
436 INTERNETAPI HINTERNET WINAPI FTP_FtpFindFirstFileW(LPWININETFTPSESSIONW lpwfs,
437 LPCWSTR lpszSearchFile, LPWIN32_FIND_DATAW lpFindFileData, DWORD dwFlags, DWORD dwContext);
438 BOOLAPI FTP_FtpGetCurrentDirectoryW(LPWININETFTPSESSIONW lpwfs, LPWSTR lpszCurrentDirectory,
439 LPDWORD lpdwCurrentDirectory);
440 BOOL FTP_ConvertFileProp(LPFILEPROPERTIESW lpafp, LPWIN32_FIND_DATAW lpFindFileData);
441 BOOL FTP_FtpRenameFileW(LPWININETFTPSESSIONW lpwfs, LPCWSTR lpszSrc, LPCWSTR lpszDest);
442 BOOL FTP_FtpRemoveDirectoryW(LPWININETFTPSESSIONW lpwfs, LPCWSTR lpszDirectory);
443 BOOL FTP_FtpDeleteFileW(LPWININETFTPSESSIONW lpwfs, LPCWSTR lpszFileName);
444 HINTERNET FTP_FtpOpenFileW(LPWININETFTPSESSIONW lpwfs, LPCWSTR lpszFileName,
445 DWORD fdwAccess, DWORD dwFlags, DWORD dwContext);
446 BOOLAPI FTP_FtpGetFileW(LPWININETFTPSESSIONW lpwfs, LPCWSTR lpszRemoteFile, LPCWSTR lpszNewFile,
447 BOOL fFailIfExists, DWORD dwLocalFlagsAttribute, DWORD dwInternetFlags,
448 DWORD dwContext);
450 BOOLAPI HTTP_HttpSendRequestW(LPWININETHTTPREQW lpwhr, LPCWSTR lpszHeaders,
451 DWORD dwHeaderLength, LPVOID lpOptional ,DWORD dwOptionalLength);
452 INTERNETAPI HINTERNET WINAPI HTTP_HttpOpenRequestW(LPWININETHTTPSESSIONW lpwhs,
453 LPCWSTR lpszVerb, LPCWSTR lpszObjectName, LPCWSTR lpszVersion,
454 LPCWSTR lpszReferrer , LPCWSTR *lpszAcceptTypes,
455 DWORD dwFlags, DWORD dwContext);
457 VOID SendAsyncCallback(LPWININETHANDLEHEADER hdr, DWORD dwContext,
458 DWORD dwInternetStatus, LPVOID lpvStatusInfo,
459 DWORD dwStatusInfoLength);
461 VOID SendSyncCallback(LPWININETHANDLEHEADER hdr, DWORD dwContext,
462 DWORD dwInternetStatus, LPVOID lpvStatusInfo,
463 DWORD dwStatusInfoLength);
465 BOOL NETCON_connected(WININET_NETCONNECTION *connection);
466 void NETCON_init(WININET_NETCONNECTION *connnection, BOOL useSSL);
467 BOOL NETCON_create(WININET_NETCONNECTION *connection, int domain,
468 int type, int protocol);
469 BOOL NETCON_close(WININET_NETCONNECTION *connection);
470 BOOL NETCON_connect(WININET_NETCONNECTION *connection, const struct sockaddr *serv_addr,
471 unsigned int addrlen);
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_getNextLine(WININET_NETCONNECTION *connection, LPSTR lpszBuffer, LPDWORD dwBuffer);
478 extern void URLCacheContainers_CreateDefaults(void);
479 extern void URLCacheContainers_DeleteAll(void);
481 #define MAX_REPLY_LEN 0x5B4
483 /* Used for debugging - maybe need to be shared in the Wine debugging code ? */
484 typedef struct
486 DWORD val;
487 const char* name;
488 } wininet_flag_info;
490 extern void dump_INTERNET_FLAGS(DWORD dwFlags) ;
492 #endif /* _WINE_INTERNET_H_ */