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>
51 #define closesocket close
52 #endif /* __MINGW32__ */
54 /* used for netconnection.c stuff */
59 #ifdef HAVE_OPENSSL_SSL_H
63 } WININET_NETCONNECTION;
65 inline static LPSTR WININET_strdup( LPCSTR str )
67 LPSTR ret = HeapAlloc( GetProcessHeap(), 0, strlen(str) + 1 );
68 if (ret) strcpy( ret, str );
72 inline static LPWSTR WININET_strdupW( LPCWSTR str )
74 LPWSTR ret = HeapAlloc( GetProcessHeap(), 0, (strlenW(str) + 1)*sizeof(WCHAR) );
75 if (ret) strcpyW( ret, str );
79 inline static LPWSTR WININET_strdup_AtoW( LPCSTR str )
81 int len = MultiByteToWideChar( CP_ACP, 0, str, -1, NULL, 0);
82 LPWSTR ret = HeapAlloc( GetProcessHeap(), 0, len * sizeof(WCHAR) );
84 MultiByteToWideChar( CP_ACP, 0, str, -1, ret, len);
88 inline static LPSTR WININET_strdup_WtoA( LPCWSTR str )
90 int len = WideCharToMultiByte( CP_ACP, 0, str, -1, NULL, 0, NULL, NULL);
91 LPSTR ret = HeapAlloc( GetProcessHeap(), 0, len );
93 WideCharToMultiByte( CP_ACP, 0, str, -1, ret, len, NULL, NULL);
97 inline static void WININET_find_data_WtoA(LPWIN32_FIND_DATAW dataW, LPWIN32_FIND_DATAA dataA)
99 dataA->dwFileAttributes = dataW->dwFileAttributes;
100 dataA->ftCreationTime = dataW->ftCreationTime;
101 dataA->ftLastAccessTime = dataW->ftLastAccessTime;
102 dataA->ftLastWriteTime = dataW->ftLastWriteTime;
103 dataA->nFileSizeHigh = dataW->nFileSizeHigh;
104 dataA->nFileSizeLow = dataW->nFileSizeLow;
105 dataA->dwReserved0 = dataW->dwReserved0;
106 dataA->dwReserved1 = dataW->dwReserved1;
107 WideCharToMultiByte(CP_ACP, 0, dataW->cFileName, -1,
108 dataA->cFileName, sizeof(dataA->cFileName),
110 WideCharToMultiByte(CP_ACP, 0, dataW->cAlternateFileName, -1,
111 dataA->cAlternateFileName, sizeof(dataA->cAlternateFileName),
117 WH_HINIT = INTERNET_HANDLE_TYPE_INTERNET,
118 WH_HFTPSESSION = INTERNET_HANDLE_TYPE_CONNECT_FTP,
119 WH_HGOPHERSESSION = INTERNET_HANDLE_TYPE_CONNECT_GOPHER,
120 WH_HHTTPSESSION = INTERNET_HANDLE_TYPE_CONNECT_HTTP,
121 WH_HFILE = INTERNET_HANDLE_TYPE_FTP_FILE,
122 WH_HFINDNEXT = INTERNET_HANDLE_TYPE_FTP_FIND,
123 WH_HHTTPREQ = INTERNET_HANDLE_TYPE_HTTP_REQUEST,
126 #define INET_OPENURL 0x0001
127 #define INET_CALLBACKW 0x0002
129 struct _WININETHANDLEHEADER;
130 typedef struct _WININETHANDLEHEADER WININETHANDLEHEADER, *LPWININETHANDLEHEADER;
132 typedef void (*WININET_object_destructor)( LPWININETHANDLEHEADER );
134 struct _WININETHANDLEHEADER
140 DWORD dwInternalFlags;
142 WININET_object_destructor destroy;
143 INTERNET_STATUS_CALLBACK lpfnStatusCB;
144 struct _WININETHANDLEHEADER *lpwhparent;
150 WININETHANDLEHEADER hdr;
153 LPWSTR lpszProxyBypass;
154 LPWSTR lpszProxyUsername;
155 LPWSTR lpszProxyPassword;
157 } WININETAPPINFOW, *LPWININETAPPINFOW;
162 WININETHANDLEHEADER hdr;
163 LPWSTR lpszServerName;
165 INTERNET_PORT nServerPort;
166 struct sockaddr_in socketAddress;
167 struct hostent *phostent;
168 } WININETHTTPSESSIONW, *LPWININETHTTPSESSIONW;
170 #define HDR_ISREQUEST 0x0001
171 #define HDR_COMMADELIMITED 0x0002
172 #define HDR_SEMIDELIMITED 0x0004
180 } HTTPHEADERW, *LPHTTPHEADERW;
185 WININETHANDLEHEADER hdr;
188 LPWSTR lpszRawHeaders;
189 WININET_NETCONNECTION netConnection;
190 HTTPHEADERW StdHeaders[HTTP_QUERY_MAX+1];
191 HTTPHEADERW *pCustHeaders;
193 } WININETHTTPREQW, *LPWININETHTTPREQW;
198 WININETHANDLEHEADER hdr;
199 BOOL session_deleted;
201 } WININETFILE, *LPWININETFILE;
206 WININETHANDLEHEADER hdr;
209 int pasvSocket; /* data socket connected by us in case of passive FTP */
210 LPWININETFILE download_in_progress;
211 struct sockaddr_in socketAddress;
212 struct sockaddr_in lstnSocketAddress;
213 struct hostent *phostent;
216 } WININETFTPSESSIONW, *LPWININETFTPSESSIONW;
224 struct tm tmLastModified;
225 unsigned short permissions;
226 } FILEPROPERTIESW, *LPFILEPROPERTIESW;
231 WININETHANDLEHEADER hdr;
234 LPFILEPROPERTIESW lpafp;
235 } WININETFINDNEXTW, *LPWININETFINDNEXTW;
240 FTPSETCURRENTDIRECTORYW,
243 FTPGETCURRENTDIRECTORYW,
256 struct WORKREQ_FTPPUTFILEW
258 LPWSTR lpszLocalFile;
259 LPWSTR lpszNewRemoteFile;
264 struct WORKREQ_FTPSETCURRENTDIRECTORYW
266 LPWSTR lpszDirectory;
269 struct WORKREQ_FTPCREATEDIRECTORYW
271 LPWSTR lpszDirectory;
274 struct WORKREQ_FTPFINDFIRSTFILEW
276 LPWSTR lpszSearchFile;
277 LPWIN32_FIND_DATAW lpFindFileData;
282 struct WORKREQ_FTPGETCURRENTDIRECTORYW
284 LPWSTR lpszDirectory;
285 DWORD *lpdwDirectory;
288 struct WORKREQ_FTPOPENFILEW
296 struct WORKREQ_FTPGETFILEW
298 LPWSTR lpszRemoteFile;
301 DWORD dwLocalFlagsAttribute;
306 struct WORKREQ_FTPDELETEFILEW
311 struct WORKREQ_FTPREMOVEDIRECTORYW
313 LPWSTR lpszDirectory;
316 struct WORKREQ_FTPRENAMEFILEW
322 struct WORKREQ_INTERNETFINDNEXTW
324 LPWIN32_FIND_DATAW lpFindFileData;
327 struct WORKREQ_HTTPOPENREQUESTW
330 LPWSTR lpszObjectName;
333 LPCWSTR *lpszAcceptTypes;
338 struct WORKREQ_HTTPSENDREQUESTW
341 DWORD dwHeaderLength;
343 DWORD dwOptionalLength;
346 struct WORKREQ_SENDCALLBACK
349 DWORD dwInternetStatus;
350 LPVOID lpvStatusInfo;
351 DWORD dwStatusInfoLength;
354 struct WORKREQ_INTERNETOPENURLW
359 DWORD dwHeadersLength;
364 typedef struct WORKREQ
367 WININETHANDLEHEADER *hdr;
370 struct WORKREQ_FTPPUTFILEW FtpPutFileW;
371 struct WORKREQ_FTPSETCURRENTDIRECTORYW FtpSetCurrentDirectoryW;
372 struct WORKREQ_FTPCREATEDIRECTORYW FtpCreateDirectoryW;
373 struct WORKREQ_FTPFINDFIRSTFILEW FtpFindFirstFileW;
374 struct WORKREQ_FTPGETCURRENTDIRECTORYW FtpGetCurrentDirectoryW;
375 struct WORKREQ_FTPOPENFILEW FtpOpenFileW;
376 struct WORKREQ_FTPGETFILEW FtpGetFileW;
377 struct WORKREQ_FTPDELETEFILEW FtpDeleteFileW;
378 struct WORKREQ_FTPREMOVEDIRECTORYW FtpRemoveDirectoryW;
379 struct WORKREQ_FTPRENAMEFILEW FtpRenameFileW;
380 struct WORKREQ_INTERNETFINDNEXTW InternetFindNextW;
381 struct WORKREQ_HTTPOPENREQUESTW HttpOpenRequestW;
382 struct WORKREQ_HTTPSENDREQUESTW HttpSendRequestW;
383 struct WORKREQ_SENDCALLBACK SendCallback;
384 struct WORKREQ_INTERNETOPENURLW InternetOpenUrlW;
387 struct WORKREQ *next;
388 struct WORKREQ *prev;
390 } WORKREQUEST, *LPWORKREQUEST;
392 HINTERNET WININET_AllocHandle( LPWININETHANDLEHEADER info );
393 LPWININETHANDLEHEADER WININET_GetObject( HINTERNET hinternet );
394 LPWININETHANDLEHEADER WININET_AddRef( LPWININETHANDLEHEADER info );
395 BOOL WININET_Release( LPWININETHANDLEHEADER info );
396 BOOL WININET_FreeHandle( HINTERNET hinternet );
397 HINTERNET WININET_FindHandle( LPWININETHANDLEHEADER info );
399 time_t ConvertTimeString(LPCWSTR asctime);
401 HINTERNET FTP_Connect(LPWININETAPPINFOW hIC, LPCWSTR lpszServerName,
402 INTERNET_PORT nServerPort, LPCWSTR lpszUserName,
403 LPCWSTR lpszPassword, DWORD dwFlags, DWORD dwContext,
404 DWORD dwInternalFlags);
406 HINTERNET HTTP_Connect(LPWININETAPPINFOW hIC, LPCWSTR lpszServerName,
407 INTERNET_PORT nServerPort, LPCWSTR lpszUserName,
408 LPCWSTR lpszPassword, DWORD dwFlags, DWORD dwContext,
409 DWORD dwInternalFlags);
411 BOOL GetAddress(LPCWSTR lpszServerName, INTERNET_PORT nServerPort,
412 struct hostent **phe, struct sockaddr_in *psa);
414 void INTERNET_SetLastError(DWORD dwError);
415 DWORD INTERNET_GetLastError();
416 BOOL INTERNET_AsyncCall(LPWORKREQUEST lpWorkRequest);
417 LPSTR INTERNET_GetResponseBuffer();
418 LPSTR INTERNET_GetNextLine(INT nSocket, LPDWORD dwLen);
420 BOOLAPI FTP_FtpPutFileW(LPWININETFTPSESSIONW lpwfs, LPCWSTR lpszLocalFile,
421 LPCWSTR lpszNewRemoteFile, DWORD dwFlags, DWORD dwContext);
422 BOOLAPI FTP_FtpSetCurrentDirectoryW(LPWININETFTPSESSIONW lpwfs, LPCWSTR lpszDirectory);
423 BOOLAPI FTP_FtpCreateDirectoryW(LPWININETFTPSESSIONW lpwfs, LPCWSTR lpszDirectory);
424 INTERNETAPI HINTERNET WINAPI FTP_FtpFindFirstFileW(LPWININETFTPSESSIONW lpwfs,
425 LPCWSTR lpszSearchFile, LPWIN32_FIND_DATAW lpFindFileData, DWORD dwFlags, DWORD dwContext);
426 BOOLAPI FTP_FtpGetCurrentDirectoryW(LPWININETFTPSESSIONW lpwfs, LPWSTR lpszCurrentDirectory,
427 LPDWORD lpdwCurrentDirectory);
428 BOOL FTP_ConvertFileProp(LPFILEPROPERTIESW lpafp, LPWIN32_FIND_DATAW lpFindFileData);
429 BOOL FTP_FtpRenameFileW(LPWININETFTPSESSIONW lpwfs, LPCWSTR lpszSrc, LPCWSTR lpszDest);
430 BOOL FTP_FtpRemoveDirectoryW(LPWININETFTPSESSIONW lpwfs, LPCWSTR lpszDirectory);
431 BOOL FTP_FtpDeleteFileW(LPWININETFTPSESSIONW lpwfs, LPCWSTR lpszFileName);
432 HINTERNET FTP_FtpOpenFileW(LPWININETFTPSESSIONW lpwfs, LPCWSTR lpszFileName,
433 DWORD fdwAccess, DWORD dwFlags, DWORD dwContext);
434 BOOLAPI FTP_FtpGetFileW(LPWININETFTPSESSIONW lpwfs, LPCWSTR lpszRemoteFile, LPCWSTR lpszNewFile,
435 BOOL fFailIfExists, DWORD dwLocalFlagsAttribute, DWORD dwInternetFlags,
438 BOOLAPI HTTP_HttpSendRequestW(LPWININETHTTPREQW lpwhr, LPCWSTR lpszHeaders,
439 DWORD dwHeaderLength, LPVOID lpOptional ,DWORD dwOptionalLength);
440 INTERNETAPI HINTERNET WINAPI HTTP_HttpOpenRequestW(LPWININETHTTPSESSIONW lpwhs,
441 LPCWSTR lpszVerb, LPCWSTR lpszObjectName, LPCWSTR lpszVersion,
442 LPCWSTR lpszReferrer , LPCWSTR *lpszAcceptTypes,
443 DWORD dwFlags, DWORD dwContext);
445 VOID SendAsyncCallback(LPWININETHANDLEHEADER hdr, DWORD dwContext,
446 DWORD dwInternetStatus, LPVOID lpvStatusInfo,
447 DWORD dwStatusInfoLength);
449 VOID SendSyncCallback(LPWININETHANDLEHEADER hdr, DWORD dwContext,
450 DWORD dwInternetStatus, LPVOID lpvStatusInfo,
451 DWORD dwStatusInfoLength);
453 BOOL HTTP_InsertProxyAuthorization( LPWININETHTTPREQW lpwhr,
454 LPCWSTR username, LPCWSTR password );
456 BOOL NETCON_connected(WININET_NETCONNECTION *connection);
457 void NETCON_init(WININET_NETCONNECTION *connnection, BOOL useSSL);
458 BOOL NETCON_create(WININET_NETCONNECTION *connection, int domain,
459 int type, int protocol);
460 BOOL NETCON_close(WININET_NETCONNECTION *connection);
461 BOOL NETCON_connect(WININET_NETCONNECTION *connection, const struct sockaddr *serv_addr,
462 unsigned int addrlen);
463 BOOL NETCON_send(WININET_NETCONNECTION *connection, const void *msg, size_t len, int flags,
464 int *sent /* out */);
465 BOOL NETCON_recv(WININET_NETCONNECTION *connection, void *buf, size_t len, int flags,
466 int *recvd /* out */);
467 BOOL NETCON_getNextLine(WININET_NETCONNECTION *connection, LPSTR lpszBuffer, LPDWORD dwBuffer);
469 #define MAX_REPLY_LEN 0x5B4
471 /* Used for debugging - maybe need to be shared in the Wine debugging code ? */
478 #endif /* _WINE_INTERNET_H_ */