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 */
57 } WININET_NETCONNECTION
;
59 static inline LPWSTR
heap_strdupW(LPCWSTR str
)
66 size
= (strlenW(str
)+1)*sizeof(WCHAR
);
67 ret
= HeapAlloc(GetProcessHeap(), 0, size
);
69 memcpy(ret
, str
, size
);
75 static inline LPWSTR
heap_strndupW(LPCWSTR str
, UINT max_len
)
83 for(len
=0; len
<max_len
; len
++)
87 ret
= HeapAlloc(GetProcessHeap(), 0, sizeof(WCHAR
)*(len
+1));
89 memcpy(ret
, str
, sizeof(WCHAR
)*len
);
96 static inline WCHAR
*heap_strdupAtoW(const char *str
)
103 len
= MultiByteToWideChar(CP_ACP
, 0, str
, -1, NULL
, 0);
104 ret
= HeapAlloc(GetProcessHeap(), 0, len
*sizeof(WCHAR
));
106 MultiByteToWideChar(CP_ACP
, 0, str
, -1, ret
, len
);
112 static inline char *heap_strdupWtoA(LPCWSTR str
)
117 DWORD size
= WideCharToMultiByte(CP_ACP
, 0, str
, -1, NULL
, 0, NULL
, NULL
);
118 ret
= HeapAlloc(GetProcessHeap(), 0, size
);
120 WideCharToMultiByte(CP_ACP
, 0, str
, -1, ret
, size
, NULL
, NULL
);
126 static inline void WININET_find_data_WtoA(LPWIN32_FIND_DATAW dataW
, LPWIN32_FIND_DATAA dataA
)
128 dataA
->dwFileAttributes
= dataW
->dwFileAttributes
;
129 dataA
->ftCreationTime
= dataW
->ftCreationTime
;
130 dataA
->ftLastAccessTime
= dataW
->ftLastAccessTime
;
131 dataA
->ftLastWriteTime
= dataW
->ftLastWriteTime
;
132 dataA
->nFileSizeHigh
= dataW
->nFileSizeHigh
;
133 dataA
->nFileSizeLow
= dataW
->nFileSizeLow
;
134 dataA
->dwReserved0
= dataW
->dwReserved0
;
135 dataA
->dwReserved1
= dataW
->dwReserved1
;
136 WideCharToMultiByte(CP_ACP
, 0, dataW
->cFileName
, -1,
137 dataA
->cFileName
, sizeof(dataA
->cFileName
),
139 WideCharToMultiByte(CP_ACP
, 0, dataW
->cAlternateFileName
, -1,
140 dataA
->cAlternateFileName
, sizeof(dataA
->cAlternateFileName
),
146 WH_HINIT
= INTERNET_HANDLE_TYPE_INTERNET
,
147 WH_HFTPSESSION
= INTERNET_HANDLE_TYPE_CONNECT_FTP
,
148 WH_HGOPHERSESSION
= INTERNET_HANDLE_TYPE_CONNECT_GOPHER
,
149 WH_HHTTPSESSION
= INTERNET_HANDLE_TYPE_CONNECT_HTTP
,
150 WH_HFILE
= INTERNET_HANDLE_TYPE_FTP_FILE
,
151 WH_HFTPFINDNEXT
= INTERNET_HANDLE_TYPE_FTP_FIND
,
152 WH_HHTTPREQ
= INTERNET_HANDLE_TYPE_HTTP_REQUEST
,
155 #define INET_OPENURL 0x0001
156 #define INET_CALLBACKW 0x0002
158 typedef struct _object_header_t object_header_t
;
161 void (*Destroy
)(object_header_t
*);
162 void (*CloseConnection
)(object_header_t
*);
163 DWORD (*QueryOption
)(object_header_t
*,DWORD
,void*,DWORD
*,BOOL
);
164 DWORD (*SetOption
)(object_header_t
*,DWORD
,void*,DWORD
);
165 DWORD (*ReadFile
)(object_header_t
*,void*,DWORD
,DWORD
*);
166 DWORD (*ReadFileExA
)(object_header_t
*,INTERNET_BUFFERSA
*,DWORD
,DWORD_PTR
);
167 DWORD (*ReadFileExW
)(object_header_t
*,INTERNET_BUFFERSW
*,DWORD
,DWORD_PTR
);
168 DWORD (*WriteFile
)(object_header_t
*,const void*,DWORD
,DWORD
*);
169 DWORD (*QueryDataAvailable
)(object_header_t
*,DWORD
*,DWORD
,DWORD_PTR
);
170 DWORD (*FindNextFileW
)(object_header_t
*,void*);
173 #define INTERNET_HANDLE_IN_USE 1
175 struct _object_header_t
178 const object_vtbl_t
*vtbl
;
184 DWORD dwInternalFlags
;
186 INTERNET_STATUS_CALLBACK lpfnStatusCB
;
188 struct list children
;
197 LPWSTR lpszProxyBypass
;
198 LPWSTR lpszProxyUsername
;
199 LPWSTR lpszProxyPassword
;
207 appinfo_t
*lpAppInfo
;
208 LPWSTR lpszHostName
; /* the final destination of the request */
209 LPWSTR lpszServerName
; /* the name of the server we directly connect to */
212 INTERNET_PORT nHostPort
; /* the final destination port of the request */
213 INTERNET_PORT nServerPort
; /* the port of the server we directly connect to */
214 struct sockaddr_storage socketAddress
;
218 #define HDR_ISREQUEST 0x0001
219 #define HDR_COMMADELIMITED 0x0002
220 #define HDR_SEMIDELIMITED 0x0004
228 } HTTPHEADERW
, *LPHTTPHEADERW
;
233 typedef struct gzip_stream_t gzip_stream_t
;
238 http_session_t
*lpHttpSession
;
241 LPWSTR lpszRawHeaders
;
242 WININET_NETCONNECTION netConnection
;
244 LPWSTR lpszStatusText
;
245 DWORD dwBytesToWrite
;
246 DWORD dwBytesWritten
;
247 HTTPHEADERW
*pCustHeaders
;
250 LPWSTR lpszCacheFile
;
251 struct HttpAuthInfo
*pAuthInfo
;
252 struct HttpAuthInfo
*pProxyAuthInfo
;
254 CRITICAL_SECTION read_section
; /* section to protect the following fields */
255 DWORD dwContentLength
; /* total number of bytes to be read */
256 DWORD dwContentRead
; /* bytes of the content read so far */
257 BOOL read_chunked
; /* are we reading in chunked mode? */
258 DWORD read_pos
; /* current read position in read_buf */
259 DWORD read_size
; /* valid data size in read_buf */
260 BYTE read_buf
[4096]; /* buffer for already read but not returned data */
263 gzip_stream_t
*gzip_stream
;
268 struct WORKREQ_FTPPUTFILEW
270 LPWSTR lpszLocalFile
;
271 LPWSTR lpszNewRemoteFile
;
276 struct WORKREQ_FTPSETCURRENTDIRECTORYW
278 LPWSTR lpszDirectory
;
281 struct WORKREQ_FTPCREATEDIRECTORYW
283 LPWSTR lpszDirectory
;
286 struct WORKREQ_FTPFINDFIRSTFILEW
288 LPWSTR lpszSearchFile
;
289 LPWIN32_FIND_DATAW lpFindFileData
;
294 struct WORKREQ_FTPGETCURRENTDIRECTORYW
296 LPWSTR lpszDirectory
;
297 DWORD
*lpdwDirectory
;
300 struct WORKREQ_FTPOPENFILEW
308 struct WORKREQ_FTPGETFILEW
310 LPWSTR lpszRemoteFile
;
313 DWORD dwLocalFlagsAttribute
;
318 struct WORKREQ_FTPDELETEFILEW
323 struct WORKREQ_FTPREMOVEDIRECTORYW
325 LPWSTR lpszDirectory
;
328 struct WORKREQ_FTPRENAMEFILEW
334 struct WORKREQ_FTPFINDNEXTW
336 LPWIN32_FIND_DATAW lpFindFileData
;
339 struct WORKREQ_HTTPSENDREQUESTW
342 DWORD dwHeaderLength
;
344 DWORD dwOptionalLength
;
345 DWORD dwContentLength
;
349 struct WORKREQ_HTTPENDREQUESTW
355 struct WORKREQ_SENDCALLBACK
358 DWORD dwInternetStatus
;
359 LPVOID lpvStatusInfo
;
360 DWORD dwStatusInfoLength
;
363 struct WORKREQ_INTERNETOPENURLW
368 DWORD dwHeadersLength
;
373 struct WORKREQ_INTERNETREADFILEEXA
375 LPINTERNET_BUFFERSA lpBuffersOut
;
378 struct WORKREQ_INTERNETREADFILEEXW
380 LPINTERNET_BUFFERSW lpBuffersOut
;
383 typedef struct WORKREQ
385 void (*asyncproc
)(struct WORKREQ
*);
386 object_header_t
*hdr
;
389 struct WORKREQ_FTPPUTFILEW FtpPutFileW
;
390 struct WORKREQ_FTPSETCURRENTDIRECTORYW FtpSetCurrentDirectoryW
;
391 struct WORKREQ_FTPCREATEDIRECTORYW FtpCreateDirectoryW
;
392 struct WORKREQ_FTPFINDFIRSTFILEW FtpFindFirstFileW
;
393 struct WORKREQ_FTPGETCURRENTDIRECTORYW FtpGetCurrentDirectoryW
;
394 struct WORKREQ_FTPOPENFILEW FtpOpenFileW
;
395 struct WORKREQ_FTPGETFILEW FtpGetFileW
;
396 struct WORKREQ_FTPDELETEFILEW FtpDeleteFileW
;
397 struct WORKREQ_FTPREMOVEDIRECTORYW FtpRemoveDirectoryW
;
398 struct WORKREQ_FTPRENAMEFILEW FtpRenameFileW
;
399 struct WORKREQ_FTPFINDNEXTW FtpFindNextW
;
400 struct WORKREQ_HTTPSENDREQUESTW HttpSendRequestW
;
401 struct WORKREQ_HTTPENDREQUESTW HttpEndRequestW
;
402 struct WORKREQ_SENDCALLBACK SendCallback
;
403 struct WORKREQ_INTERNETOPENURLW InternetOpenUrlW
;
404 struct WORKREQ_INTERNETREADFILEEXA InternetReadFileExA
;
405 struct WORKREQ_INTERNETREADFILEEXW InternetReadFileExW
;
408 } WORKREQUEST
, *LPWORKREQUEST
;
410 HINTERNET
WININET_AllocHandle( object_header_t
*info
);
411 object_header_t
*WININET_GetObject( HINTERNET hinternet
);
412 object_header_t
*WININET_AddRef( object_header_t
*info
);
413 BOOL
WININET_Release( object_header_t
*info
);
414 BOOL
WININET_FreeHandle( HINTERNET hinternet
);
416 DWORD
INET_QueryOption( object_header_t
*, DWORD
, void *, DWORD
*, BOOL
);
418 time_t ConvertTimeString(LPCWSTR asctime
);
420 HINTERNET
FTP_Connect(appinfo_t
*hIC
, LPCWSTR lpszServerName
,
421 INTERNET_PORT nServerPort
, LPCWSTR lpszUserName
,
422 LPCWSTR lpszPassword
, DWORD dwFlags
, DWORD_PTR dwContext
,
423 DWORD dwInternalFlags
);
425 DWORD
HTTP_Connect(appinfo_t
*,LPCWSTR
,
426 INTERNET_PORT nServerPort
, LPCWSTR lpszUserName
,
427 LPCWSTR lpszPassword
, DWORD dwFlags
, DWORD_PTR dwContext
,
428 DWORD dwInternalFlags
, HINTERNET
*);
430 BOOL
GetAddress(LPCWSTR lpszServerName
, INTERNET_PORT nServerPort
,
431 struct sockaddr
*psa
, socklen_t
*sa_len
);
433 void INTERNET_SetLastError(DWORD dwError
);
434 DWORD
INTERNET_GetLastError(void);
435 DWORD
INTERNET_AsyncCall(LPWORKREQUEST lpWorkRequest
);
436 LPSTR
INTERNET_GetResponseBuffer(void);
437 LPSTR
INTERNET_GetNextLine(INT nSocket
, LPDWORD dwLen
);
439 VOID
SendAsyncCallback(object_header_t
*hdr
, DWORD_PTR dwContext
,
440 DWORD dwInternetStatus
, LPVOID lpvStatusInfo
,
441 DWORD dwStatusInfoLength
);
443 VOID
INTERNET_SendCallback(object_header_t
*hdr
, DWORD_PTR dwContext
,
444 DWORD dwInternetStatus
, LPVOID lpvStatusInfo
,
445 DWORD dwStatusInfoLength
);
446 BOOL
INTERNET_FindProxyForProtocol(LPCWSTR szProxy
, LPCWSTR proto
, WCHAR
*foundProxy
, DWORD
*foundProxyLen
);
448 BOOL
NETCON_connected(WININET_NETCONNECTION
*connection
);
449 DWORD
NETCON_init(WININET_NETCONNECTION
*connnection
, BOOL useSSL
);
450 void NETCON_unload(void);
451 DWORD
NETCON_create(WININET_NETCONNECTION
*connection
, int domain
,
452 int type
, int protocol
);
453 DWORD
NETCON_close(WININET_NETCONNECTION
*connection
);
454 DWORD
NETCON_connect(WININET_NETCONNECTION
*connection
, const struct sockaddr
*serv_addr
,
455 unsigned int addrlen
);
456 DWORD
NETCON_secure_connect(WININET_NETCONNECTION
*connection
, LPWSTR hostname
);
457 DWORD
NETCON_send(WININET_NETCONNECTION
*connection
, const void *msg
, size_t len
, int flags
,
458 int *sent
/* out */);
459 DWORD
NETCON_recv(WININET_NETCONNECTION
*connection
, void *buf
, size_t len
, int flags
,
460 int *recvd
/* out */);
461 BOOL
NETCON_query_data_available(WININET_NETCONNECTION
*connection
, DWORD
*available
);
462 LPCVOID
NETCON_GetCert(WININET_NETCONNECTION
*connection
);
463 int NETCON_GetCipherStrength(WININET_NETCONNECTION
*connection
);
464 DWORD
NETCON_set_timeout(WININET_NETCONNECTION
*connection
, BOOL send
, int value
);
465 int sock_get_error(int);
467 extern void URLCacheContainers_CreateDefaults(void);
468 extern void URLCacheContainers_DeleteAll(void);
470 #define MAX_REPLY_LEN 0x5B4
472 /* Used for debugging - maybe need to be shared in the Wine debugging code ? */
479 #endif /* _WINE_INTERNET_H_ */