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., 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"
32 #ifdef HAVE_NETINET_IN_H
33 # include <sys/types.h>
34 # include <netinet/in.h>
36 #ifdef HAVE_OPENSSL_SSL_H
37 #define DSA __ssl_DSA /* avoid conflict with commctrl.h */
39 # include <openssl/ssl.h>
41 #define FAR do_not_use_this_in_wine
44 #ifdef HAVE_SYS_SOCKET_H
45 # include <sys/socket.h>
48 #if defined(__MINGW32__) || defined (_MSC_VER)
54 #define closesocket close
55 #endif /* __MINGW32__ */
57 /* used for netconnection.c stuff */
62 #ifdef HAVE_OPENSSL_SSL_H
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
);
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
);
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
) );
87 MultiByteToWideChar( CP_ACP
, 0, str
, -1, ret
, len
);
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
);
96 WideCharToMultiByte( CP_ACP
, 0, str
, -1, ret
, len
, NULL
, NULL
);
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
),
113 WideCharToMultiByte(CP_ACP
, 0, dataW
->cAlternateFileName
, -1,
114 dataA
->cAlternateFileName
, sizeof(dataA
->cAlternateFileName
),
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
,
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
143 DWORD dwInternalFlags
;
145 WININET_object_destructor destroy
;
146 INTERNET_STATUS_CALLBACK lpfnStatusCB
;
147 struct _WININETHANDLEHEADER
*lpwhparent
;
153 WININETHANDLEHEADER hdr
;
156 LPWSTR lpszProxyBypass
;
157 LPWSTR lpszProxyUsername
;
158 LPWSTR lpszProxyPassword
;
160 } WININETAPPINFOW
, *LPWININETAPPINFOW
;
165 WININETHANDLEHEADER hdr
;
166 LPWSTR lpszServerName
;
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
183 } HTTPHEADERW
, *LPHTTPHEADERW
;
188 WININETHANDLEHEADER hdr
;
191 LPWSTR lpszRawHeaders
;
192 WININET_NETCONNECTION netConnection
;
193 HTTPHEADERW StdHeaders
[HTTP_QUERY_MAX
+1];
194 HTTPHEADERW
*pCustHeaders
;
196 } WININETHTTPREQW
, *LPWININETHTTPREQW
;
201 WININETHANDLEHEADER hdr
;
202 BOOL session_deleted
;
204 } WININETFILE
, *LPWININETFILE
;
209 WININETHANDLEHEADER hdr
;
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
;
219 } WININETFTPSESSIONW
, *LPWININETFTPSESSIONW
;
227 struct tm tmLastModified
;
228 unsigned short permissions
;
229 } FILEPROPERTIESW
, *LPFILEPROPERTIESW
;
234 WININETHANDLEHEADER hdr
;
237 LPFILEPROPERTIESW lpafp
;
238 } WININETFINDNEXTW
, *LPWININETFINDNEXTW
;
243 FTPSETCURRENTDIRECTORYW
,
246 FTPGETCURRENTDIRECTORYW
,
259 struct WORKREQ_FTPPUTFILEW
261 LPWSTR lpszLocalFile
;
262 LPWSTR lpszNewRemoteFile
;
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
;
285 struct WORKREQ_FTPGETCURRENTDIRECTORYW
287 LPWSTR lpszDirectory
;
288 DWORD
*lpdwDirectory
;
291 struct WORKREQ_FTPOPENFILEW
299 struct WORKREQ_FTPGETFILEW
301 LPWSTR lpszRemoteFile
;
304 DWORD dwLocalFlagsAttribute
;
309 struct WORKREQ_FTPDELETEFILEW
314 struct WORKREQ_FTPREMOVEDIRECTORYW
316 LPWSTR lpszDirectory
;
319 struct WORKREQ_FTPRENAMEFILEW
325 struct WORKREQ_INTERNETFINDNEXTW
327 LPWIN32_FIND_DATAW lpFindFileData
;
330 struct WORKREQ_HTTPOPENREQUESTW
333 LPWSTR lpszObjectName
;
336 LPCWSTR
*lpszAcceptTypes
;
341 struct WORKREQ_HTTPSENDREQUESTW
344 DWORD dwHeaderLength
;
346 DWORD dwOptionalLength
;
349 struct WORKREQ_SENDCALLBACK
352 DWORD dwInternetStatus
;
353 LPVOID lpvStatusInfo
;
354 DWORD dwStatusInfoLength
;
357 struct WORKREQ_INTERNETOPENURLW
362 DWORD dwHeadersLength
;
367 typedef struct WORKREQ
370 WININETHANDLEHEADER
*hdr
;
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
;
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
,
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 ? */
481 extern void dump_INTERNET_FLAGS(DWORD dwFlags
) ;
483 #endif /* _WINE_INTERNET_H_ */