4 * Copyright 1999 Corel Corporation
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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
23 #ifndef _WINE_INTERNET_H_
24 #define _WINE_INTERNET_H_
26 #ifndef __WINE_CONFIG_H
27 # error You must include config.h to use this header
30 #include "wine/unicode.h"
31 #include "wine/list.h"
37 #ifdef HAVE_NETINET_IN_H
38 # include <sys/types.h>
39 # include <netinet/in.h>
41 #ifdef HAVE_SYS_SOCKET_H
42 # include <sys/socket.h>
45 #if !defined(__MINGW32__) && !defined(_MSC_VER)
46 #define closesocket close
47 #define ioctlsocket ioctl
48 #endif /* __MINGW32__ */
50 /* used for netconnection.c stuff */
56 } WININET_NETCONNECTION;
58 static inline LPWSTR WININET_strdupW( LPCWSTR str )
60 LPWSTR ret = HeapAlloc( GetProcessHeap(), 0, (strlenW(str) + 1)*sizeof(WCHAR) );
61 if (ret) strcpyW( ret, str );
65 static inline LPWSTR WININET_strdup_AtoW( LPCSTR str )
67 int len = MultiByteToWideChar( CP_ACP, 0, str, -1, NULL, 0);
68 LPWSTR ret = HeapAlloc( GetProcessHeap(), 0, len * sizeof(WCHAR) );
70 MultiByteToWideChar( CP_ACP, 0, str, -1, ret, len);
74 static inline LPSTR WININET_strdup_WtoA( LPCWSTR str )
76 int len = WideCharToMultiByte( CP_ACP, 0, str, -1, NULL, 0, NULL, NULL);
77 LPSTR ret = HeapAlloc( GetProcessHeap(), 0, len );
79 WideCharToMultiByte( CP_ACP, 0, str, -1, ret, len, NULL, NULL);
83 static inline void WININET_find_data_WtoA(LPWIN32_FIND_DATAW dataW, LPWIN32_FIND_DATAA dataA)
85 dataA->dwFileAttributes = dataW->dwFileAttributes;
86 dataA->ftCreationTime = dataW->ftCreationTime;
87 dataA->ftLastAccessTime = dataW->ftLastAccessTime;
88 dataA->ftLastWriteTime = dataW->ftLastWriteTime;
89 dataA->nFileSizeHigh = dataW->nFileSizeHigh;
90 dataA->nFileSizeLow = dataW->nFileSizeLow;
91 dataA->dwReserved0 = dataW->dwReserved0;
92 dataA->dwReserved1 = dataW->dwReserved1;
93 WideCharToMultiByte(CP_ACP, 0, dataW->cFileName, -1,
94 dataA->cFileName, sizeof(dataA->cFileName),
96 WideCharToMultiByte(CP_ACP, 0, dataW->cAlternateFileName, -1,
97 dataA->cAlternateFileName, sizeof(dataA->cAlternateFileName),
103 WH_HINIT = INTERNET_HANDLE_TYPE_INTERNET,
104 WH_HFTPSESSION = INTERNET_HANDLE_TYPE_CONNECT_FTP,
105 WH_HGOPHERSESSION = INTERNET_HANDLE_TYPE_CONNECT_GOPHER,
106 WH_HHTTPSESSION = INTERNET_HANDLE_TYPE_CONNECT_HTTP,
107 WH_HFILE = INTERNET_HANDLE_TYPE_FTP_FILE,
108 WH_HFTPFINDNEXT = INTERNET_HANDLE_TYPE_FTP_FIND,
109 WH_HHTTPREQ = INTERNET_HANDLE_TYPE_HTTP_REQUEST,
112 #define INET_OPENURL 0x0001
113 #define INET_CALLBACKW 0x0002
115 typedef struct _object_header_t object_header_t;
118 void (*Destroy)(object_header_t*);
119 void (*CloseConnection)(object_header_t*);
120 DWORD (*QueryOption)(object_header_t*,DWORD,void*,DWORD*,BOOL);
121 DWORD (*SetOption)(object_header_t*,DWORD,void*,DWORD);
122 DWORD (*ReadFile)(object_header_t*,void*,DWORD,DWORD*);
123 DWORD (*ReadFileExA)(object_header_t*,INTERNET_BUFFERSA*,DWORD,DWORD_PTR);
124 DWORD (*ReadFileExW)(object_header_t*,INTERNET_BUFFERSW*,DWORD,DWORD_PTR);
125 BOOL (*WriteFile)(object_header_t*,const void*,DWORD,DWORD*);
126 DWORD (*QueryDataAvailable)(object_header_t*,DWORD*,DWORD,DWORD_PTR);
127 DWORD (*FindNextFileW)(object_header_t*,void*);
130 struct _object_header_t
133 const object_vtbl_t *vtbl;
138 DWORD dwInternalFlags;
140 INTERNET_STATUS_CALLBACK lpfnStatusCB;
142 struct list children;
151 LPWSTR lpszProxyBypass;
152 LPWSTR lpszProxyUsername;
153 LPWSTR lpszProxyPassword;
161 appinfo_t *lpAppInfo;
162 LPWSTR lpszHostName; /* the final destination of the request */
163 LPWSTR lpszServerName; /* the name of the server we directly connect to */
166 INTERNET_PORT nHostPort; /* the final destination port of the request */
167 INTERNET_PORT nServerPort; /* the port of the server we directly connect to */
168 struct sockaddr_storage socketAddress;
172 #define HDR_ISREQUEST 0x0001
173 #define HDR_COMMADELIMITED 0x0002
174 #define HDR_SEMIDELIMITED 0x0004
182 } HTTPHEADERW, *LPHTTPHEADERW;
187 typedef struct gzip_stream_t gzip_stream_t;
192 http_session_t *lpHttpSession;
195 LPWSTR lpszRawHeaders;
196 WININET_NETCONNECTION netConnection;
198 LPWSTR lpszStatusText;
199 DWORD dwBytesToWrite;
200 DWORD dwBytesWritten;
201 HTTPHEADERW *pCustHeaders;
204 LPWSTR lpszCacheFile;
205 struct HttpAuthInfo *pAuthInfo;
206 struct HttpAuthInfo *pProxyAuthInfo;
208 CRITICAL_SECTION read_section; /* section to protect the following fields */
209 DWORD dwContentLength; /* total number of bytes to be read */
210 DWORD dwContentRead; /* bytes of the content read so far */
211 BOOL read_chunked; /* are we reading in chunked mode? */
212 DWORD read_pos; /* current read position in read_buf */
213 DWORD read_size; /* valid data size in read_buf */
214 BYTE read_buf[4096]; /* buffer for already read but not returned data */
217 gzip_stream_t *gzip_stream;
222 struct WORKREQ_FTPPUTFILEW
224 LPWSTR lpszLocalFile;
225 LPWSTR lpszNewRemoteFile;
230 struct WORKREQ_FTPSETCURRENTDIRECTORYW
232 LPWSTR lpszDirectory;
235 struct WORKREQ_FTPCREATEDIRECTORYW
237 LPWSTR lpszDirectory;
240 struct WORKREQ_FTPFINDFIRSTFILEW
242 LPWSTR lpszSearchFile;
243 LPWIN32_FIND_DATAW lpFindFileData;
248 struct WORKREQ_FTPGETCURRENTDIRECTORYW
250 LPWSTR lpszDirectory;
251 DWORD *lpdwDirectory;
254 struct WORKREQ_FTPOPENFILEW
262 struct WORKREQ_FTPGETFILEW
264 LPWSTR lpszRemoteFile;
267 DWORD dwLocalFlagsAttribute;
272 struct WORKREQ_FTPDELETEFILEW
277 struct WORKREQ_FTPREMOVEDIRECTORYW
279 LPWSTR lpszDirectory;
282 struct WORKREQ_FTPRENAMEFILEW
288 struct WORKREQ_FTPFINDNEXTW
290 LPWIN32_FIND_DATAW lpFindFileData;
293 struct WORKREQ_HTTPSENDREQUESTW
296 DWORD dwHeaderLength;
298 DWORD dwOptionalLength;
299 DWORD dwContentLength;
303 struct WORKREQ_HTTPENDREQUESTW
309 struct WORKREQ_SENDCALLBACK
312 DWORD dwInternetStatus;
313 LPVOID lpvStatusInfo;
314 DWORD dwStatusInfoLength;
317 struct WORKREQ_INTERNETOPENURLW
322 DWORD dwHeadersLength;
327 struct WORKREQ_INTERNETREADFILEEXA
329 LPINTERNET_BUFFERSA lpBuffersOut;
332 struct WORKREQ_INTERNETREADFILEEXW
334 LPINTERNET_BUFFERSW lpBuffersOut;
337 typedef struct WORKREQ
339 void (*asyncproc)(struct WORKREQ*);
340 object_header_t *hdr;
343 struct WORKREQ_FTPPUTFILEW FtpPutFileW;
344 struct WORKREQ_FTPSETCURRENTDIRECTORYW FtpSetCurrentDirectoryW;
345 struct WORKREQ_FTPCREATEDIRECTORYW FtpCreateDirectoryW;
346 struct WORKREQ_FTPFINDFIRSTFILEW FtpFindFirstFileW;
347 struct WORKREQ_FTPGETCURRENTDIRECTORYW FtpGetCurrentDirectoryW;
348 struct WORKREQ_FTPOPENFILEW FtpOpenFileW;
349 struct WORKREQ_FTPGETFILEW FtpGetFileW;
350 struct WORKREQ_FTPDELETEFILEW FtpDeleteFileW;
351 struct WORKREQ_FTPREMOVEDIRECTORYW FtpRemoveDirectoryW;
352 struct WORKREQ_FTPRENAMEFILEW FtpRenameFileW;
353 struct WORKREQ_FTPFINDNEXTW FtpFindNextW;
354 struct WORKREQ_HTTPSENDREQUESTW HttpSendRequestW;
355 struct WORKREQ_HTTPENDREQUESTW HttpEndRequestW;
356 struct WORKREQ_SENDCALLBACK SendCallback;
357 struct WORKREQ_INTERNETOPENURLW InternetOpenUrlW;
358 struct WORKREQ_INTERNETREADFILEEXA InternetReadFileExA;
359 struct WORKREQ_INTERNETREADFILEEXW InternetReadFileExW;
362 } WORKREQUEST, *LPWORKREQUEST;
364 HINTERNET WININET_AllocHandle( object_header_t *info );
365 object_header_t *WININET_GetObject( HINTERNET hinternet );
366 object_header_t *WININET_AddRef( object_header_t *info );
367 BOOL WININET_Release( object_header_t *info );
368 BOOL WININET_FreeHandle( HINTERNET hinternet );
370 DWORD INET_QueryOption(DWORD,void*,DWORD*,BOOL);
372 time_t ConvertTimeString(LPCWSTR asctime);
374 HINTERNET FTP_Connect(appinfo_t *hIC, LPCWSTR lpszServerName,
375 INTERNET_PORT nServerPort, LPCWSTR lpszUserName,
376 LPCWSTR lpszPassword, DWORD dwFlags, DWORD_PTR dwContext,
377 DWORD dwInternalFlags);
379 HINTERNET HTTP_Connect(appinfo_t *hIC, LPCWSTR lpszServerName,
380 INTERNET_PORT nServerPort, LPCWSTR lpszUserName,
381 LPCWSTR lpszPassword, DWORD dwFlags, DWORD_PTR dwContext,
382 DWORD dwInternalFlags);
384 BOOL GetAddress(LPCWSTR lpszServerName, INTERNET_PORT nServerPort,
385 struct sockaddr *psa, socklen_t *sa_len);
387 void INTERNET_SetLastError(DWORD dwError);
388 DWORD INTERNET_GetLastError(void);
389 BOOL INTERNET_AsyncCall(LPWORKREQUEST lpWorkRequest);
390 LPSTR INTERNET_GetResponseBuffer(void);
391 LPSTR INTERNET_GetNextLine(INT nSocket, LPDWORD dwLen);
393 BOOLAPI HTTP_HttpSendRequestW(http_request_t *req, LPCWSTR lpszHeaders,
394 DWORD dwHeaderLength, LPVOID lpOptional, DWORD dwOptionalLength,
395 DWORD dwContentLength, BOOL bEndRequest);
396 INTERNETAPI HINTERNET WINAPI HTTP_HttpOpenRequestW(http_session_t *session,
397 LPCWSTR lpszVerb, LPCWSTR lpszObjectName, LPCWSTR lpszVersion,
398 LPCWSTR lpszReferrer , LPCWSTR *lpszAcceptTypes,
399 DWORD dwFlags, DWORD_PTR dwContext);
401 VOID SendAsyncCallback(object_header_t *hdr, DWORD_PTR dwContext,
402 DWORD dwInternetStatus, LPVOID lpvStatusInfo,
403 DWORD dwStatusInfoLength);
405 VOID INTERNET_SendCallback(object_header_t *hdr, DWORD_PTR dwContext,
406 DWORD dwInternetStatus, LPVOID lpvStatusInfo,
407 DWORD dwStatusInfoLength);
409 BOOL NETCON_connected(WININET_NETCONNECTION *connection);
410 BOOL NETCON_init(WININET_NETCONNECTION *connnection, BOOL useSSL);
411 BOOL NETCON_create(WININET_NETCONNECTION *connection, int domain,
412 int type, int protocol);
413 BOOL NETCON_close(WININET_NETCONNECTION *connection);
414 BOOL NETCON_connect(WININET_NETCONNECTION *connection, const struct sockaddr *serv_addr,
415 unsigned int addrlen);
416 BOOL NETCON_secure_connect(WININET_NETCONNECTION *connection, LPCWSTR hostname);
417 BOOL NETCON_send(WININET_NETCONNECTION *connection, const void *msg, size_t len, int flags,
418 int *sent /* out */);
419 BOOL NETCON_recv(WININET_NETCONNECTION *connection, void *buf, size_t len, int flags,
420 int *recvd /* out */);
421 BOOL NETCON_query_data_available(WININET_NETCONNECTION *connection, DWORD *available);
422 LPCVOID NETCON_GetCert(WININET_NETCONNECTION *connection);
423 DWORD NETCON_set_timeout(WININET_NETCONNECTION *connection, BOOL send, int value);
425 extern void URLCacheContainers_CreateDefaults(void);
426 extern void URLCacheContainers_DeleteAll(void);
428 #define MAX_REPLY_LEN 0x5B4
430 /* Used for debugging - maybe need to be shared in the Wine debugging code ? */
437 #endif /* _WINE_INTERNET_H_ */