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)
50 #define closesocket close
51 #define ioctlsocket ioctl
52 #endif /* __MINGW32__ */
54 /* used for netconnection.c stuff */
63 } WININET_NETCONNECTION;
65 static inline LPWSTR WININET_strdupW( LPCWSTR str )
67 LPWSTR ret = HeapAlloc( GetProcessHeap(), 0, (strlenW(str) + 1)*sizeof(WCHAR) );
68 if (ret) strcpyW( ret, str );
72 static inline LPWSTR WININET_strdup_AtoW( LPCSTR str )
74 int len = MultiByteToWideChar( CP_ACP, 0, str, -1, NULL, 0);
75 LPWSTR ret = HeapAlloc( GetProcessHeap(), 0, len * sizeof(WCHAR) );
77 MultiByteToWideChar( CP_ACP, 0, str, -1, ret, len);
81 static inline LPSTR WININET_strdup_WtoA( LPCWSTR str )
83 int len = WideCharToMultiByte( CP_ACP, 0, str, -1, NULL, 0, NULL, NULL);
84 LPSTR ret = HeapAlloc( GetProcessHeap(), 0, len );
86 WideCharToMultiByte( CP_ACP, 0, str, -1, ret, len, NULL, NULL);
90 static inline void WININET_find_data_WtoA(LPWIN32_FIND_DATAW dataW, LPWIN32_FIND_DATAA dataA)
92 dataA->dwFileAttributes = dataW->dwFileAttributes;
93 dataA->ftCreationTime = dataW->ftCreationTime;
94 dataA->ftLastAccessTime = dataW->ftLastAccessTime;
95 dataA->ftLastWriteTime = dataW->ftLastWriteTime;
96 dataA->nFileSizeHigh = dataW->nFileSizeHigh;
97 dataA->nFileSizeLow = dataW->nFileSizeLow;
98 dataA->dwReserved0 = dataW->dwReserved0;
99 dataA->dwReserved1 = dataW->dwReserved1;
100 WideCharToMultiByte(CP_ACP, 0, dataW->cFileName, -1,
101 dataA->cFileName, sizeof(dataA->cFileName),
103 WideCharToMultiByte(CP_ACP, 0, dataW->cAlternateFileName, -1,
104 dataA->cAlternateFileName, sizeof(dataA->cAlternateFileName),
110 WH_HINIT = INTERNET_HANDLE_TYPE_INTERNET,
111 WH_HFTPSESSION = INTERNET_HANDLE_TYPE_CONNECT_FTP,
112 WH_HGOPHERSESSION = INTERNET_HANDLE_TYPE_CONNECT_GOPHER,
113 WH_HHTTPSESSION = INTERNET_HANDLE_TYPE_CONNECT_HTTP,
114 WH_HFILE = INTERNET_HANDLE_TYPE_FTP_FILE,
115 WH_HFTPFINDNEXT = INTERNET_HANDLE_TYPE_FTP_FIND,
116 WH_HHTTPREQ = INTERNET_HANDLE_TYPE_HTTP_REQUEST,
119 #define INET_OPENURL 0x0001
120 #define INET_CALLBACKW 0x0002
122 typedef struct _WININETHANDLEHEADER WININETHANDLEHEADER, *LPWININETHANDLEHEADER;
125 void (*Destroy)(WININETHANDLEHEADER*);
126 void (*CloseConnection)(WININETHANDLEHEADER*);
127 DWORD (*QueryOption)(WININETHANDLEHEADER*,DWORD,void*,DWORD*,BOOL);
128 DWORD (*SetOption)(WININETHANDLEHEADER*,DWORD,void*,DWORD);
129 DWORD (*ReadFile)(WININETHANDLEHEADER*,void*,DWORD,DWORD*);
130 DWORD (*ReadFileExA)(WININETHANDLEHEADER*,INTERNET_BUFFERSA*,DWORD,DWORD_PTR);
131 BOOL (*WriteFile)(WININETHANDLEHEADER*,const void*,DWORD,DWORD*);
132 DWORD (*QueryDataAvailable)(WININETHANDLEHEADER*,DWORD*,DWORD,DWORD_PTR);
133 DWORD (*FindNextFileW)(WININETHANDLEHEADER*,void*);
136 struct _WININETHANDLEHEADER
139 const HANDLEHEADERVtbl *vtbl;
144 DWORD dwInternalFlags;
146 INTERNET_STATUS_CALLBACK lpfnStatusCB;
148 struct list children;
154 WININETHANDLEHEADER hdr;
157 LPWSTR lpszProxyBypass;
158 LPWSTR lpszProxyUsername;
159 LPWSTR lpszProxyPassword;
161 } WININETAPPINFOW, *LPWININETAPPINFOW;
166 WININETHANDLEHEADER hdr;
167 WININETAPPINFOW *lpAppInfo;
168 LPWSTR lpszHostName; /* the final destination of the request */
169 LPWSTR lpszServerName; /* the name of the server we directly connect to */
172 INTERNET_PORT nHostPort; /* the final destination port of the request */
173 INTERNET_PORT nServerPort; /* the port of the server we directly connect to */
174 struct sockaddr_in socketAddress;
175 } WININETHTTPSESSIONW, *LPWININETHTTPSESSIONW;
177 #define HDR_ISREQUEST 0x0001
178 #define HDR_COMMADELIMITED 0x0002
179 #define HDR_SEMIDELIMITED 0x0004
187 } HTTPHEADERW, *LPHTTPHEADERW;
194 WININETHANDLEHEADER hdr;
195 WININETHTTPSESSIONW *lpHttpSession;
198 LPWSTR lpszRawHeaders;
199 WININET_NETCONNECTION netConnection;
201 LPWSTR lpszStatusText;
202 DWORD dwContentLength; /* total number of bytes to be read */
203 DWORD dwContentRead; /* bytes of the content read so far */
204 HTTPHEADERW *pCustHeaders;
207 LPWSTR lpszCacheFile;
208 struct HttpAuthInfo *pAuthInfo;
209 struct HttpAuthInfo *pProxyAuthInfo;
210 } WININETHTTPREQW, *LPWININETHTTPREQW;
214 struct WORKREQ_FTPPUTFILEW
216 LPWSTR lpszLocalFile;
217 LPWSTR lpszNewRemoteFile;
222 struct WORKREQ_FTPSETCURRENTDIRECTORYW
224 LPWSTR lpszDirectory;
227 struct WORKREQ_FTPCREATEDIRECTORYW
229 LPWSTR lpszDirectory;
232 struct WORKREQ_FTPFINDFIRSTFILEW
234 LPWSTR lpszSearchFile;
235 LPWIN32_FIND_DATAW lpFindFileData;
240 struct WORKREQ_FTPGETCURRENTDIRECTORYW
242 LPWSTR lpszDirectory;
243 DWORD *lpdwDirectory;
246 struct WORKREQ_FTPOPENFILEW
254 struct WORKREQ_FTPGETFILEW
256 LPWSTR lpszRemoteFile;
259 DWORD dwLocalFlagsAttribute;
264 struct WORKREQ_FTPDELETEFILEW
269 struct WORKREQ_FTPREMOVEDIRECTORYW
271 LPWSTR lpszDirectory;
274 struct WORKREQ_FTPRENAMEFILEW
280 struct WORKREQ_FTPFINDNEXTW
282 LPWIN32_FIND_DATAW lpFindFileData;
285 struct WORKREQ_HTTPSENDREQUESTW
288 DWORD dwHeaderLength;
290 DWORD dwOptionalLength;
291 DWORD dwContentLength;
295 struct WORKREQ_SENDCALLBACK
298 DWORD dwInternetStatus;
299 LPVOID lpvStatusInfo;
300 DWORD dwStatusInfoLength;
303 struct WORKREQ_INTERNETOPENURLW
308 DWORD dwHeadersLength;
313 struct WORKREQ_INTERNETREADFILEEXA
315 LPINTERNET_BUFFERSA lpBuffersOut;
318 typedef struct WORKREQ
320 void (*asyncproc)(struct WORKREQ*);
321 WININETHANDLEHEADER *hdr;
324 struct WORKREQ_FTPPUTFILEW FtpPutFileW;
325 struct WORKREQ_FTPSETCURRENTDIRECTORYW FtpSetCurrentDirectoryW;
326 struct WORKREQ_FTPCREATEDIRECTORYW FtpCreateDirectoryW;
327 struct WORKREQ_FTPFINDFIRSTFILEW FtpFindFirstFileW;
328 struct WORKREQ_FTPGETCURRENTDIRECTORYW FtpGetCurrentDirectoryW;
329 struct WORKREQ_FTPOPENFILEW FtpOpenFileW;
330 struct WORKREQ_FTPGETFILEW FtpGetFileW;
331 struct WORKREQ_FTPDELETEFILEW FtpDeleteFileW;
332 struct WORKREQ_FTPREMOVEDIRECTORYW FtpRemoveDirectoryW;
333 struct WORKREQ_FTPRENAMEFILEW FtpRenameFileW;
334 struct WORKREQ_FTPFINDNEXTW FtpFindNextW;
335 struct WORKREQ_HTTPSENDREQUESTW HttpSendRequestW;
336 struct WORKREQ_SENDCALLBACK SendCallback;
337 struct WORKREQ_INTERNETOPENURLW InternetOpenUrlW;
338 struct WORKREQ_INTERNETREADFILEEXA InternetReadFileExA;
341 } WORKREQUEST, *LPWORKREQUEST;
343 HINTERNET WININET_AllocHandle( LPWININETHANDLEHEADER info );
344 LPWININETHANDLEHEADER WININET_GetObject( HINTERNET hinternet );
345 LPWININETHANDLEHEADER WININET_AddRef( LPWININETHANDLEHEADER info );
346 BOOL WININET_Release( LPWININETHANDLEHEADER info );
347 BOOL WININET_FreeHandle( HINTERNET hinternet );
349 DWORD INET_QueryOption(DWORD,void*,DWORD*,BOOL);
351 time_t ConvertTimeString(LPCWSTR asctime);
353 HINTERNET FTP_Connect(LPWININETAPPINFOW hIC, LPCWSTR lpszServerName,
354 INTERNET_PORT nServerPort, LPCWSTR lpszUserName,
355 LPCWSTR lpszPassword, DWORD dwFlags, DWORD_PTR dwContext,
356 DWORD dwInternalFlags);
358 HINTERNET HTTP_Connect(LPWININETAPPINFOW hIC, LPCWSTR lpszServerName,
359 INTERNET_PORT nServerPort, LPCWSTR lpszUserName,
360 LPCWSTR lpszPassword, DWORD dwFlags, DWORD_PTR dwContext,
361 DWORD dwInternalFlags);
363 BOOL GetAddress(LPCWSTR lpszServerName, INTERNET_PORT nServerPort,
364 struct sockaddr_in *psa);
366 void INTERNET_SetLastError(DWORD dwError);
367 DWORD INTERNET_GetLastError(void);
368 BOOL INTERNET_AsyncCall(LPWORKREQUEST lpWorkRequest);
369 LPSTR INTERNET_GetResponseBuffer(void);
370 LPSTR INTERNET_GetNextLine(INT nSocket, LPDWORD dwLen);
372 BOOLAPI HTTP_HttpSendRequestW(LPWININETHTTPREQW lpwhr, LPCWSTR lpszHeaders,
373 DWORD dwHeaderLength, LPVOID lpOptional, DWORD dwOptionalLength,
374 DWORD dwContentLength, BOOL bEndRequest);
375 INTERNETAPI HINTERNET WINAPI HTTP_HttpOpenRequestW(LPWININETHTTPSESSIONW lpwhs,
376 LPCWSTR lpszVerb, LPCWSTR lpszObjectName, LPCWSTR lpszVersion,
377 LPCWSTR lpszReferrer , LPCWSTR *lpszAcceptTypes,
378 DWORD dwFlags, DWORD_PTR dwContext);
379 BOOL HTTP_FinishedReading(LPWININETHTTPREQW lpwhr);
381 VOID SendAsyncCallback(LPWININETHANDLEHEADER hdr, DWORD_PTR dwContext,
382 DWORD dwInternetStatus, LPVOID lpvStatusInfo,
383 DWORD dwStatusInfoLength);
385 VOID INTERNET_SendCallback(LPWININETHANDLEHEADER hdr, DWORD_PTR dwContext,
386 DWORD dwInternetStatus, LPVOID lpvStatusInfo,
387 DWORD dwStatusInfoLength);
389 LPHTTPHEADERW HTTP_GetHeader(LPWININETHTTPREQW lpwhr, LPCWSTR header);
391 BOOL NETCON_connected(WININET_NETCONNECTION *connection);
392 BOOL NETCON_init(WININET_NETCONNECTION *connnection, BOOL useSSL);
393 BOOL NETCON_create(WININET_NETCONNECTION *connection, int domain,
394 int type, int protocol);
395 BOOL NETCON_close(WININET_NETCONNECTION *connection);
396 BOOL NETCON_connect(WININET_NETCONNECTION *connection, const struct sockaddr *serv_addr,
397 unsigned int addrlen);
398 BOOL NETCON_secure_connect(WININET_NETCONNECTION *connection, LPCWSTR hostname);
399 BOOL NETCON_send(WININET_NETCONNECTION *connection, const void *msg, size_t len, int flags,
400 int *sent /* out */);
401 BOOL NETCON_recv(WININET_NETCONNECTION *connection, void *buf, size_t len, int flags,
402 int *recvd /* out */);
403 BOOL NETCON_query_data_available(WININET_NETCONNECTION *connection, DWORD *available);
404 BOOL NETCON_getNextLine(WININET_NETCONNECTION *connection, LPSTR lpszBuffer, LPDWORD dwBuffer);
405 LPCVOID NETCON_GetCert(WININET_NETCONNECTION *connection);
406 DWORD NETCON_set_timeout(WININET_NETCONNECTION *connection, BOOL send, int value);
408 extern void URLCacheContainers_CreateDefaults(void);
409 extern void URLCacheContainers_DeleteAll(void);
411 #define MAX_REPLY_LEN 0x5B4
413 /* Used for debugging - maybe need to be shared in the Wine debugging code ? */
420 #endif /* _WINE_INTERNET_H_ */