cryptui: Update Japanese translation.
[wine.git] / dlls / wininet / internet.h
blob86b16bda2a6c1f9e377e1606ecf1c29c8334ab1f
1 /*
2 * Wininet
4 * Copyright 1999 Corel Corporation
6 * Ulrich Czekalla
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
28 #endif
30 #include "wine/unicode.h"
31 #include "wine/list.h"
33 #include <time.h>
34 #ifdef HAVE_NETDB_H
35 # include <netdb.h>
36 #endif
37 #ifdef HAVE_NETINET_IN_H
38 # include <sys/types.h>
39 # include <netinet/in.h>
40 #endif
41 #ifdef HAVE_SYS_SOCKET_H
42 # include <sys/socket.h>
43 #endif
45 #if !defined(__MINGW32__) && !defined(_MSC_VER)
46 #define closesocket close
47 #define ioctlsocket ioctl
48 #endif /* __MINGW32__ */
50 /* used for netconnection.c stuff */
51 typedef struct
53 BOOL useSSL;
54 int socketFD;
55 void *ssl_s;
56 DWORD security_flags;
57 } WININET_NETCONNECTION;
59 static inline LPWSTR heap_strdupW(LPCWSTR str)
61 LPWSTR ret = NULL;
63 if(str) {
64 DWORD size;
66 size = (strlenW(str)+1)*sizeof(WCHAR);
67 ret = HeapAlloc(GetProcessHeap(), 0, size);
68 if(ret)
69 memcpy(ret, str, size);
72 return ret;
75 static inline LPWSTR heap_strndupW(LPCWSTR str, UINT max_len)
77 LPWSTR ret;
78 UINT len;
80 if(!str)
81 return NULL;
83 for(len=0; len<max_len; len++)
84 if(str[len] == '\0')
85 break;
87 ret = HeapAlloc(GetProcessHeap(), 0, sizeof(WCHAR)*(len+1));
88 if(ret) {
89 memcpy(ret, str, sizeof(WCHAR)*len);
90 ret[len] = '\0';
93 return ret;
96 static inline WCHAR *heap_strdupAtoW(const char *str)
98 LPWSTR ret = NULL;
100 if(str) {
101 DWORD len;
103 len = MultiByteToWideChar(CP_ACP, 0, str, -1, NULL, 0);
104 ret = HeapAlloc(GetProcessHeap(), 0, len*sizeof(WCHAR));
105 if(ret)
106 MultiByteToWideChar(CP_ACP, 0, str, -1, ret, len);
109 return ret;
112 static inline char *heap_strdupWtoA(LPCWSTR str)
114 char *ret = NULL;
116 if(str) {
117 DWORD size = WideCharToMultiByte(CP_ACP, 0, str, -1, NULL, 0, NULL, NULL);
118 ret = HeapAlloc(GetProcessHeap(), 0, size);
119 if(ret)
120 WideCharToMultiByte(CP_ACP, 0, str, -1, ret, size, NULL, NULL);
123 return ret;
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),
138 NULL, NULL);
139 WideCharToMultiByte(CP_ACP, 0, dataW->cAlternateFileName, -1,
140 dataA->cAlternateFileName, sizeof(dataA->cAlternateFileName),
141 NULL, NULL);
144 typedef enum
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,
153 } WH_TYPE;
155 #define INET_OPENURL 0x0001
156 #define INET_CALLBACKW 0x0002
158 typedef struct _object_header_t object_header_t;
160 typedef struct {
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*);
171 } object_vtbl_t;
173 #define INTERNET_HANDLE_IN_USE 1
175 struct _object_header_t
177 WH_TYPE htype;
178 const object_vtbl_t *vtbl;
179 HINTERNET hInternet;
180 DWORD dwFlags;
181 DWORD_PTR dwContext;
182 DWORD dwError;
183 ULONG ErrorMask;
184 DWORD dwInternalFlags;
185 LONG refs;
186 INTERNET_STATUS_CALLBACK lpfnStatusCB;
187 struct list entry;
188 struct list children;
192 typedef struct
194 object_header_t hdr;
195 LPWSTR lpszAgent;
196 LPWSTR lpszProxy;
197 LPWSTR lpszProxyBypass;
198 LPWSTR lpszProxyUsername;
199 LPWSTR lpszProxyPassword;
200 DWORD dwAccessType;
201 } appinfo_t;
204 typedef struct
206 object_header_t hdr;
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 */
210 LPWSTR lpszUserName;
211 LPWSTR lpszPassword;
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;
215 socklen_t sa_len;
216 } http_session_t;
218 #define HDR_ISREQUEST 0x0001
219 #define HDR_COMMADELIMITED 0x0002
220 #define HDR_SEMIDELIMITED 0x0004
222 typedef struct
224 LPWSTR lpszField;
225 LPWSTR lpszValue;
226 WORD wFlags;
227 WORD wCount;
228 } HTTPHEADERW, *LPHTTPHEADERW;
231 struct HttpAuthInfo;
233 typedef struct gzip_stream_t gzip_stream_t;
235 typedef struct
237 object_header_t hdr;
238 http_session_t *lpHttpSession;
239 LPWSTR lpszPath;
240 LPWSTR lpszVerb;
241 LPWSTR lpszRawHeaders;
242 WININET_NETCONNECTION netConnection;
243 LPWSTR lpszVersion;
244 LPWSTR lpszStatusText;
245 DWORD dwBytesToWrite;
246 DWORD dwBytesWritten;
247 HTTPHEADERW *pCustHeaders;
248 DWORD nCustHeaders;
249 HANDLE hCacheFile;
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 */
262 BOOL decoding;
263 gzip_stream_t *gzip_stream;
264 } http_request_t;
268 struct WORKREQ_FTPPUTFILEW
270 LPWSTR lpszLocalFile;
271 LPWSTR lpszNewRemoteFile;
272 DWORD dwFlags;
273 DWORD_PTR dwContext;
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;
290 DWORD dwFlags;
291 DWORD_PTR dwContext;
294 struct WORKREQ_FTPGETCURRENTDIRECTORYW
296 LPWSTR lpszDirectory;
297 DWORD *lpdwDirectory;
300 struct WORKREQ_FTPOPENFILEW
302 LPWSTR lpszFilename;
303 DWORD dwAccess;
304 DWORD dwFlags;
305 DWORD_PTR dwContext;
308 struct WORKREQ_FTPGETFILEW
310 LPWSTR lpszRemoteFile;
311 LPWSTR lpszNewFile;
312 BOOL fFailIfExists;
313 DWORD dwLocalFlagsAttribute;
314 DWORD dwFlags;
315 DWORD_PTR dwContext;
318 struct WORKREQ_FTPDELETEFILEW
320 LPWSTR lpszFilename;
323 struct WORKREQ_FTPREMOVEDIRECTORYW
325 LPWSTR lpszDirectory;
328 struct WORKREQ_FTPRENAMEFILEW
330 LPWSTR lpszSrcFile;
331 LPWSTR lpszDestFile;
334 struct WORKREQ_FTPFINDNEXTW
336 LPWIN32_FIND_DATAW lpFindFileData;
339 struct WORKREQ_HTTPSENDREQUESTW
341 LPWSTR lpszHeader;
342 DWORD dwHeaderLength;
343 LPVOID lpOptional;
344 DWORD dwOptionalLength;
345 DWORD dwContentLength;
346 BOOL bEndRequest;
349 struct WORKREQ_HTTPENDREQUESTW
351 DWORD dwFlags;
352 DWORD_PTR dwContext;
355 struct WORKREQ_SENDCALLBACK
357 DWORD_PTR dwContext;
358 DWORD dwInternetStatus;
359 LPVOID lpvStatusInfo;
360 DWORD dwStatusInfoLength;
363 struct WORKREQ_INTERNETOPENURLW
365 HINTERNET hInternet;
366 LPWSTR lpszUrl;
367 LPWSTR lpszHeaders;
368 DWORD dwHeadersLength;
369 DWORD dwFlags;
370 DWORD_PTR dwContext;
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;
388 union {
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;
406 } u;
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 ? */
473 typedef struct
475 DWORD val;
476 const char* name;
477 } wininet_flag_info;
479 #endif /* _WINE_INTERNET_H_ */