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 /* used for netconnection.c stuff */
53 #ifdef HAVE_OPENSSL_SSL_H
57 } WININET_NETCONNECTION;
59 inline static LPSTR WININET_strdup( LPCSTR str )
61 LPSTR ret = HeapAlloc( GetProcessHeap(), 0, strlen(str) + 1 );
62 if (ret) strcpy( ret, str );
66 inline static LPWSTR WININET_strdupW( LPCWSTR str )
68 LPWSTR ret = HeapAlloc( GetProcessHeap(), 0, (strlenW(str) + 1)*sizeof(WCHAR) );
69 if (ret) strcpyW( ret, str );
73 inline static LPWSTR WININET_strdup_AtoW( LPCSTR str )
75 int len = MultiByteToWideChar( CP_ACP, 0, str, -1, NULL, 0);
76 LPWSTR ret = HeapAlloc( GetProcessHeap(), 0, len * sizeof(WCHAR) );
78 MultiByteToWideChar( CP_ACP, 0, str, -1, ret, len);
82 inline static LPSTR WININET_strdup_WtoA( LPCWSTR str )
84 int len = WideCharToMultiByte( CP_ACP, 0, str, -1, NULL, 0, NULL, NULL);
85 LPSTR ret = HeapAlloc( GetProcessHeap(), 0, len );
87 WideCharToMultiByte( CP_ACP, 0, str, -1, ret, len, NULL, NULL);
91 inline static void WININET_find_data_WtoA(LPWIN32_FIND_DATAW dataW, LPWIN32_FIND_DATAA dataA)
93 dataA->dwFileAttributes = dataW->dwFileAttributes;
94 dataA->ftCreationTime = dataW->ftCreationTime;
95 dataA->ftLastAccessTime = dataW->ftLastAccessTime;
96 dataA->ftLastWriteTime = dataW->ftLastWriteTime;
97 dataA->nFileSizeHigh = dataW->nFileSizeHigh;
98 dataA->nFileSizeLow = dataW->nFileSizeLow;
99 dataA->dwReserved0 = dataW->dwReserved0;
100 dataA->dwReserved1 = dataW->dwReserved1;
101 WideCharToMultiByte(CP_ACP, 0, dataW->cFileName, -1,
102 dataA->cFileName, sizeof(dataA->cFileName),
104 WideCharToMultiByte(CP_ACP, 0, dataW->cAlternateFileName, -1,
105 dataA->cAlternateFileName, sizeof(dataA->cAlternateFileName),
111 WH_HINIT = INTERNET_HANDLE_TYPE_INTERNET,
112 WH_HFTPSESSION = INTERNET_HANDLE_TYPE_CONNECT_FTP,
113 WH_HGOPHERSESSION = INTERNET_HANDLE_TYPE_CONNECT_GOPHER,
114 WH_HHTTPSESSION = INTERNET_HANDLE_TYPE_CONNECT_HTTP,
115 WH_HFILE = INTERNET_HANDLE_TYPE_FTP_FILE,
116 WH_HFINDNEXT = INTERNET_HANDLE_TYPE_FTP_FIND,
117 WH_HHTTPREQ = INTERNET_HANDLE_TYPE_HTTP_REQUEST,
120 #define INET_OPENURL 0x0001
121 #define INET_CALLBACKW 0x0002
123 struct _WININETHANDLEHEADER;
124 typedef struct _WININETHANDLEHEADER WININETHANDLEHEADER, *LPWININETHANDLEHEADER;
126 typedef void (*WININET_object_destructor)( LPWININETHANDLEHEADER );
128 struct _WININETHANDLEHEADER
134 DWORD dwInternalFlags;
136 WININET_object_destructor destroy;
137 struct _WININETHANDLEHEADER *lpwhparent;
143 WININETHANDLEHEADER hdr;
146 LPWSTR lpszProxyBypass;
147 LPWSTR lpszProxyUsername;
148 LPWSTR lpszProxyPassword;
150 INTERNET_STATUS_CALLBACK lpfnStatusCB;
151 } WININETAPPINFOW, *LPWININETAPPINFOW;
156 WININETHANDLEHEADER hdr;
157 LPWSTR lpszServerName;
159 INTERNET_PORT nServerPort;
160 struct sockaddr_in socketAddress;
161 struct hostent *phostent;
162 } WININETHTTPSESSIONW, *LPWININETHTTPSESSIONW;
164 #define HDR_ISREQUEST 0x0001
165 #define HDR_COMMADELIMITED 0x0002
166 #define HDR_SEMIDELIMITED 0x0004
174 } HTTPHEADERW, *LPHTTPHEADERW;
179 WININETHANDLEHEADER hdr;
183 LPWSTR lpszRawHeaders;
184 WININET_NETCONNECTION netConnection;
185 HTTPHEADERW StdHeaders[HTTP_QUERY_MAX+1];
186 HTTPHEADERW *pCustHeaders;
188 } WININETHTTPREQW, *LPWININETHTTPREQW;
193 WININETHANDLEHEADER hdr;
194 BOOL session_deleted;
196 } WININETFILE, *LPWININETFILE;
201 WININETHANDLEHEADER hdr;
204 int pasvSocket; /* data socket connected by us in case of passive FTP */
205 LPWININETFILE download_in_progress;
206 struct sockaddr_in socketAddress;
207 struct sockaddr_in lstnSocketAddress;
208 struct hostent *phostent;
211 } WININETFTPSESSIONW, *LPWININETFTPSESSIONW;
219 struct tm tmLastModified;
220 unsigned short permissions;
221 } FILEPROPERTIESW, *LPFILEPROPERTIESW;
226 WININETHANDLEHEADER hdr;
229 LPFILEPROPERTIESW lpafp;
230 } WININETFINDNEXTW, *LPWININETFINDNEXTW;
235 FTPSETCURRENTDIRECTORYW,
238 FTPGETCURRENTDIRECTORYW,
251 struct WORKREQ_FTPPUTFILEW
253 LPWSTR lpszLocalFile;
254 LPWSTR lpszNewRemoteFile;
259 struct WORKREQ_FTPSETCURRENTDIRECTORYW
261 LPWSTR lpszDirectory;
264 struct WORKREQ_FTPCREATEDIRECTORYW
266 LPWSTR lpszDirectory;
269 struct WORKREQ_FTPFINDFIRSTFILEW
271 LPWSTR lpszSearchFile;
272 LPWIN32_FIND_DATAW lpFindFileData;
277 struct WORKREQ_FTPGETCURRENTDIRECTORYW
279 LPWSTR lpszDirectory;
280 DWORD *lpdwDirectory;
283 struct WORKREQ_FTPOPENFILEW
291 struct WORKREQ_FTPGETFILEW
293 LPWSTR lpszRemoteFile;
296 DWORD dwLocalFlagsAttribute;
301 struct WORKREQ_FTPDELETEFILEW
306 struct WORKREQ_FTPREMOVEDIRECTORYW
308 LPWSTR lpszDirectory;
311 struct WORKREQ_FTPRENAMEFILEW
317 struct WORKREQ_INTERNETFINDNEXTW
319 LPWIN32_FIND_DATAW lpFindFileData;
322 struct WORKREQ_HTTPOPENREQUESTW
325 LPWSTR lpszObjectName;
328 LPCWSTR *lpszAcceptTypes;
333 struct WORKREQ_HTTPSENDREQUESTW
336 DWORD dwHeaderLength;
338 DWORD dwOptionalLength;
341 struct WORKREQ_SENDCALLBACK
343 WININETHANDLEHEADER *hdr;
345 DWORD dwInternetStatus;
346 LPVOID lpvStatusInfo;
347 DWORD dwStatusInfoLength;
350 struct WORKREQ_INTERNETOPENURLW
355 DWORD dwHeadersLength;
360 typedef struct WORKREQ
363 WININETHANDLEHEADER *hdr;
366 struct WORKREQ_FTPPUTFILEW FtpPutFileW;
367 struct WORKREQ_FTPSETCURRENTDIRECTORYW FtpSetCurrentDirectoryW;
368 struct WORKREQ_FTPCREATEDIRECTORYW FtpCreateDirectoryW;
369 struct WORKREQ_FTPFINDFIRSTFILEW FtpFindFirstFileW;
370 struct WORKREQ_FTPGETCURRENTDIRECTORYW FtpGetCurrentDirectoryW;
371 struct WORKREQ_FTPOPENFILEW FtpOpenFileW;
372 struct WORKREQ_FTPGETFILEW FtpGetFileW;
373 struct WORKREQ_FTPDELETEFILEW FtpDeleteFileW;
374 struct WORKREQ_FTPREMOVEDIRECTORYW FtpRemoveDirectoryW;
375 struct WORKREQ_FTPRENAMEFILEW FtpRenameFileW;
376 struct WORKREQ_INTERNETFINDNEXTW InternetFindNextW;
377 struct WORKREQ_HTTPOPENREQUESTW HttpOpenRequestW;
378 struct WORKREQ_HTTPSENDREQUESTW HttpSendRequestW;
379 struct WORKREQ_SENDCALLBACK SendCallback;
380 struct WORKREQ_INTERNETOPENURLW InternetOpenUrlW;
383 struct WORKREQ *next;
384 struct WORKREQ *prev;
386 } WORKREQUEST, *LPWORKREQUEST;
388 HINTERNET WININET_AllocHandle( LPWININETHANDLEHEADER info );
389 LPWININETHANDLEHEADER WININET_GetObject( HINTERNET hinternet );
390 LPWININETHANDLEHEADER WININET_AddRef( LPWININETHANDLEHEADER info );
391 BOOL WININET_Release( LPWININETHANDLEHEADER info );
392 BOOL WININET_FreeHandle( HINTERNET hinternet );
393 HINTERNET WININET_FindHandle( LPWININETHANDLEHEADER info );
395 time_t ConvertTimeString(LPCWSTR asctime);
397 HINTERNET FTP_Connect(LPWININETAPPINFOW hIC, LPCWSTR lpszServerName,
398 INTERNET_PORT nServerPort, LPCWSTR lpszUserName,
399 LPCWSTR lpszPassword, DWORD dwFlags, DWORD dwContext,
400 DWORD dwInternalFlags);
402 HINTERNET HTTP_Connect(LPWININETAPPINFOW hIC, LPCWSTR lpszServerName,
403 INTERNET_PORT nServerPort, LPCWSTR lpszUserName,
404 LPCWSTR lpszPassword, DWORD dwFlags, DWORD dwContext,
405 DWORD dwInternalFlags);
407 BOOL GetAddress(LPCWSTR lpszServerName, INTERNET_PORT nServerPort,
408 struct hostent **phe, struct sockaddr_in *psa);
410 void INTERNET_SetLastError(DWORD dwError);
411 DWORD INTERNET_GetLastError();
412 BOOL INTERNET_AsyncCall(LPWORKREQUEST lpWorkRequest);
413 LPSTR INTERNET_GetResponseBuffer();
414 LPSTR INTERNET_GetNextLine(INT nSocket, LPDWORD dwLen);
416 BOOLAPI FTP_FtpPutFileW(LPWININETFTPSESSIONW lpwfs, LPCWSTR lpszLocalFile,
417 LPCWSTR lpszNewRemoteFile, DWORD dwFlags, DWORD dwContext);
418 BOOLAPI FTP_FtpSetCurrentDirectoryW(LPWININETFTPSESSIONW lpwfs, LPCWSTR lpszDirectory);
419 BOOLAPI FTP_FtpCreateDirectoryW(LPWININETFTPSESSIONW lpwfs, LPCWSTR lpszDirectory);
420 INTERNETAPI HINTERNET WINAPI FTP_FtpFindFirstFileW(LPWININETFTPSESSIONW lpwfs,
421 LPCWSTR lpszSearchFile, LPWIN32_FIND_DATAW lpFindFileData, DWORD dwFlags, DWORD dwContext);
422 BOOLAPI FTP_FtpGetCurrentDirectoryW(LPWININETFTPSESSIONW lpwfs, LPWSTR lpszCurrentDirectory,
423 LPDWORD lpdwCurrentDirectory);
424 BOOL FTP_ConvertFileProp(LPFILEPROPERTIESW lpafp, LPWIN32_FIND_DATAW lpFindFileData);
425 BOOL FTP_FtpRenameFileW(LPWININETFTPSESSIONW lpwfs, LPCWSTR lpszSrc, LPCWSTR lpszDest);
426 BOOL FTP_FtpRemoveDirectoryW(LPWININETFTPSESSIONW lpwfs, LPCWSTR lpszDirectory);
427 BOOL FTP_FtpDeleteFileW(LPWININETFTPSESSIONW lpwfs, LPCWSTR lpszFileName);
428 HINTERNET FTP_FtpOpenFileW(LPWININETFTPSESSIONW lpwfs, LPCWSTR lpszFileName,
429 DWORD fdwAccess, DWORD dwFlags, DWORD dwContext);
430 BOOLAPI FTP_FtpGetFileW(LPWININETFTPSESSIONW lpwfs, LPCWSTR lpszRemoteFile, LPCWSTR lpszNewFile,
431 BOOL fFailIfExists, DWORD dwLocalFlagsAttribute, DWORD dwInternetFlags,
434 BOOLAPI HTTP_HttpSendRequestW(LPWININETHTTPREQW lpwhr, LPCWSTR lpszHeaders,
435 DWORD dwHeaderLength, LPVOID lpOptional ,DWORD dwOptionalLength);
436 INTERNETAPI HINTERNET WINAPI HTTP_HttpOpenRequestW(LPWININETHTTPSESSIONW lpwhs,
437 LPCWSTR lpszVerb, LPCWSTR lpszObjectName, LPCWSTR lpszVersion,
438 LPCWSTR lpszReferrer , LPCWSTR *lpszAcceptTypes,
439 DWORD dwFlags, DWORD dwContext);
441 VOID SendAsyncCallback(LPWININETAPPINFOW hIC, LPWININETHANDLEHEADER hdr,
442 DWORD dwContext, DWORD dwInternetStatus, LPVOID
443 lpvStatusInfo , DWORD dwStatusInfoLength);
445 VOID SendAsyncCallbackInt(LPWININETAPPINFOW hIC, LPWININETHANDLEHEADER hdr,
446 DWORD dwContext, DWORD dwInternetStatus, LPVOID
447 lpvStatusInfo , DWORD dwStatusInfoLength);
449 BOOL HTTP_InsertProxyAuthorization( LPWININETHTTPREQW lpwhr,
450 LPCWSTR username, LPCWSTR password );
452 BOOL NETCON_connected(WININET_NETCONNECTION *connection);
453 void NETCON_init(WININET_NETCONNECTION *connnection, BOOL useSSL);
454 BOOL NETCON_create(WININET_NETCONNECTION *connection, int domain,
455 int type, int protocol);
456 BOOL NETCON_close(WININET_NETCONNECTION *connection);
457 BOOL NETCON_connect(WININET_NETCONNECTION *connection, const struct sockaddr *serv_addr,
459 BOOL NETCON_send(WININET_NETCONNECTION *connection, const void *msg, size_t len, int flags,
460 int *sent /* out */);
461 BOOL NETCON_recv(WININET_NETCONNECTION *connection, void *buf, size_t len, int flags,
462 int *recvd /* out */);
463 BOOL NETCON_getNextLine(WININET_NETCONNECTION *connection, LPSTR lpszBuffer, LPDWORD dwBuffer);
465 #define MAX_REPLY_LEN 0x5B4
467 /* Used for debugging - maybe need to be shared in the Wine debugging code ? */
474 #endif /* _WINE_INTERNET_H_ */