xcopy: Remove spaces before '\n's in the Korean translation.
[wine/hramrach.git] / dlls / wininet / internet.h
blob40de22f4a209141ca1c42835ec397220bddbef83
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 } WININET_NETCONNECTION;
58 static inline LPWSTR heap_strdupW(LPCWSTR str)
60 LPWSTR ret = NULL;
62 if(str) {
63 DWORD size;
65 size = (strlenW(str)+1)*sizeof(WCHAR);
66 ret = HeapAlloc(GetProcessHeap(), 0, size);
67 if(ret)
68 memcpy(ret, str, size);
71 return ret;
74 static inline LPWSTR heap_strndupW(LPCWSTR str, UINT max_len)
76 LPWSTR ret;
77 UINT len;
79 if(!str)
80 return NULL;
82 for(len=0; len<max_len; len++)
83 if(str[len] == '\0')
84 break;
86 ret = HeapAlloc(GetProcessHeap(), 0, sizeof(WCHAR)*(len+1));
87 if(ret) {
88 memcpy(ret, str, sizeof(WCHAR)*len);
89 ret[len] = '\0';
92 return ret;
95 static inline WCHAR *heap_strdupAtoW(const char *str)
97 LPWSTR ret = NULL;
99 if(str) {
100 DWORD len;
102 len = MultiByteToWideChar(CP_ACP, 0, str, -1, NULL, 0);
103 ret = HeapAlloc(GetProcessHeap(), 0, len*sizeof(WCHAR));
104 if(ret)
105 MultiByteToWideChar(CP_ACP, 0, str, -1, ret, len);
108 return ret;
111 static inline char *heap_strdupWtoA(LPCWSTR str)
113 char *ret = NULL;
115 if(str) {
116 DWORD size = WideCharToMultiByte(CP_ACP, 0, str, -1, NULL, 0, NULL, NULL);
117 ret = HeapAlloc(GetProcessHeap(), 0, size);
118 if(ret)
119 WideCharToMultiByte(CP_ACP, 0, str, -1, ret, size, NULL, NULL);
122 return ret;
125 static inline void WININET_find_data_WtoA(LPWIN32_FIND_DATAW dataW, LPWIN32_FIND_DATAA dataA)
127 dataA->dwFileAttributes = dataW->dwFileAttributes;
128 dataA->ftCreationTime = dataW->ftCreationTime;
129 dataA->ftLastAccessTime = dataW->ftLastAccessTime;
130 dataA->ftLastWriteTime = dataW->ftLastWriteTime;
131 dataA->nFileSizeHigh = dataW->nFileSizeHigh;
132 dataA->nFileSizeLow = dataW->nFileSizeLow;
133 dataA->dwReserved0 = dataW->dwReserved0;
134 dataA->dwReserved1 = dataW->dwReserved1;
135 WideCharToMultiByte(CP_ACP, 0, dataW->cFileName, -1,
136 dataA->cFileName, sizeof(dataA->cFileName),
137 NULL, NULL);
138 WideCharToMultiByte(CP_ACP, 0, dataW->cAlternateFileName, -1,
139 dataA->cAlternateFileName, sizeof(dataA->cAlternateFileName),
140 NULL, NULL);
143 typedef enum
145 WH_HINIT = INTERNET_HANDLE_TYPE_INTERNET,
146 WH_HFTPSESSION = INTERNET_HANDLE_TYPE_CONNECT_FTP,
147 WH_HGOPHERSESSION = INTERNET_HANDLE_TYPE_CONNECT_GOPHER,
148 WH_HHTTPSESSION = INTERNET_HANDLE_TYPE_CONNECT_HTTP,
149 WH_HFILE = INTERNET_HANDLE_TYPE_FTP_FILE,
150 WH_HFTPFINDNEXT = INTERNET_HANDLE_TYPE_FTP_FIND,
151 WH_HHTTPREQ = INTERNET_HANDLE_TYPE_HTTP_REQUEST,
152 } WH_TYPE;
154 #define INET_OPENURL 0x0001
155 #define INET_CALLBACKW 0x0002
157 typedef struct _object_header_t object_header_t;
159 typedef struct {
160 void (*Destroy)(object_header_t*);
161 void (*CloseConnection)(object_header_t*);
162 DWORD (*QueryOption)(object_header_t*,DWORD,void*,DWORD*,BOOL);
163 DWORD (*SetOption)(object_header_t*,DWORD,void*,DWORD);
164 DWORD (*ReadFile)(object_header_t*,void*,DWORD,DWORD*);
165 DWORD (*ReadFileExA)(object_header_t*,INTERNET_BUFFERSA*,DWORD,DWORD_PTR);
166 DWORD (*ReadFileExW)(object_header_t*,INTERNET_BUFFERSW*,DWORD,DWORD_PTR);
167 DWORD (*WriteFile)(object_header_t*,const void*,DWORD,DWORD*);
168 DWORD (*QueryDataAvailable)(object_header_t*,DWORD*,DWORD,DWORD_PTR);
169 DWORD (*FindNextFileW)(object_header_t*,void*);
170 } object_vtbl_t;
172 #define INTERNET_HANDLE_IN_USE 1
174 struct _object_header_t
176 WH_TYPE htype;
177 const object_vtbl_t *vtbl;
178 HINTERNET hInternet;
179 DWORD dwFlags;
180 DWORD_PTR dwContext;
181 DWORD dwError;
182 ULONG ErrorMask;
183 DWORD dwInternalFlags;
184 LONG refs;
185 INTERNET_STATUS_CALLBACK lpfnStatusCB;
186 struct list entry;
187 struct list children;
191 typedef struct
193 object_header_t hdr;
194 LPWSTR lpszAgent;
195 LPWSTR lpszProxy;
196 LPWSTR lpszProxyBypass;
197 LPWSTR lpszProxyUsername;
198 LPWSTR lpszProxyPassword;
199 DWORD dwAccessType;
200 } appinfo_t;
203 typedef struct
205 object_header_t hdr;
206 appinfo_t *lpAppInfo;
207 LPWSTR lpszHostName; /* the final destination of the request */
208 LPWSTR lpszServerName; /* the name of the server we directly connect to */
209 LPWSTR lpszUserName;
210 LPWSTR lpszPassword;
211 INTERNET_PORT nHostPort; /* the final destination port of the request */
212 INTERNET_PORT nServerPort; /* the port of the server we directly connect to */
213 struct sockaddr_storage socketAddress;
214 socklen_t sa_len;
215 } http_session_t;
217 #define HDR_ISREQUEST 0x0001
218 #define HDR_COMMADELIMITED 0x0002
219 #define HDR_SEMIDELIMITED 0x0004
221 typedef struct
223 LPWSTR lpszField;
224 LPWSTR lpszValue;
225 WORD wFlags;
226 WORD wCount;
227 } HTTPHEADERW, *LPHTTPHEADERW;
230 struct HttpAuthInfo;
232 typedef struct gzip_stream_t gzip_stream_t;
234 typedef struct
236 object_header_t hdr;
237 http_session_t *lpHttpSession;
238 LPWSTR lpszPath;
239 LPWSTR lpszVerb;
240 LPWSTR lpszRawHeaders;
241 WININET_NETCONNECTION netConnection;
242 LPWSTR lpszVersion;
243 LPWSTR lpszStatusText;
244 DWORD dwBytesToWrite;
245 DWORD dwBytesWritten;
246 HTTPHEADERW *pCustHeaders;
247 DWORD nCustHeaders;
248 HANDLE hCacheFile;
249 LPWSTR lpszCacheFile;
250 struct HttpAuthInfo *pAuthInfo;
251 struct HttpAuthInfo *pProxyAuthInfo;
253 CRITICAL_SECTION read_section; /* section to protect the following fields */
254 DWORD dwContentLength; /* total number of bytes to be read */
255 DWORD dwContentRead; /* bytes of the content read so far */
256 BOOL read_chunked; /* are we reading in chunked mode? */
257 DWORD read_pos; /* current read position in read_buf */
258 DWORD read_size; /* valid data size in read_buf */
259 BYTE read_buf[4096]; /* buffer for already read but not returned data */
261 BOOL decoding;
262 gzip_stream_t *gzip_stream;
263 } http_request_t;
267 struct WORKREQ_FTPPUTFILEW
269 LPWSTR lpszLocalFile;
270 LPWSTR lpszNewRemoteFile;
271 DWORD dwFlags;
272 DWORD_PTR dwContext;
275 struct WORKREQ_FTPSETCURRENTDIRECTORYW
277 LPWSTR lpszDirectory;
280 struct WORKREQ_FTPCREATEDIRECTORYW
282 LPWSTR lpszDirectory;
285 struct WORKREQ_FTPFINDFIRSTFILEW
287 LPWSTR lpszSearchFile;
288 LPWIN32_FIND_DATAW lpFindFileData;
289 DWORD dwFlags;
290 DWORD_PTR dwContext;
293 struct WORKREQ_FTPGETCURRENTDIRECTORYW
295 LPWSTR lpszDirectory;
296 DWORD *lpdwDirectory;
299 struct WORKREQ_FTPOPENFILEW
301 LPWSTR lpszFilename;
302 DWORD dwAccess;
303 DWORD dwFlags;
304 DWORD_PTR dwContext;
307 struct WORKREQ_FTPGETFILEW
309 LPWSTR lpszRemoteFile;
310 LPWSTR lpszNewFile;
311 BOOL fFailIfExists;
312 DWORD dwLocalFlagsAttribute;
313 DWORD dwFlags;
314 DWORD_PTR dwContext;
317 struct WORKREQ_FTPDELETEFILEW
319 LPWSTR lpszFilename;
322 struct WORKREQ_FTPREMOVEDIRECTORYW
324 LPWSTR lpszDirectory;
327 struct WORKREQ_FTPRENAMEFILEW
329 LPWSTR lpszSrcFile;
330 LPWSTR lpszDestFile;
333 struct WORKREQ_FTPFINDNEXTW
335 LPWIN32_FIND_DATAW lpFindFileData;
338 struct WORKREQ_HTTPSENDREQUESTW
340 LPWSTR lpszHeader;
341 DWORD dwHeaderLength;
342 LPVOID lpOptional;
343 DWORD dwOptionalLength;
344 DWORD dwContentLength;
345 BOOL bEndRequest;
348 struct WORKREQ_HTTPENDREQUESTW
350 DWORD dwFlags;
351 DWORD_PTR dwContext;
354 struct WORKREQ_SENDCALLBACK
356 DWORD_PTR dwContext;
357 DWORD dwInternetStatus;
358 LPVOID lpvStatusInfo;
359 DWORD dwStatusInfoLength;
362 struct WORKREQ_INTERNETOPENURLW
364 HINTERNET hInternet;
365 LPWSTR lpszUrl;
366 LPWSTR lpszHeaders;
367 DWORD dwHeadersLength;
368 DWORD dwFlags;
369 DWORD_PTR dwContext;
372 struct WORKREQ_INTERNETREADFILEEXA
374 LPINTERNET_BUFFERSA lpBuffersOut;
377 struct WORKREQ_INTERNETREADFILEEXW
379 LPINTERNET_BUFFERSW lpBuffersOut;
382 typedef struct WORKREQ
384 void (*asyncproc)(struct WORKREQ*);
385 object_header_t *hdr;
387 union {
388 struct WORKREQ_FTPPUTFILEW FtpPutFileW;
389 struct WORKREQ_FTPSETCURRENTDIRECTORYW FtpSetCurrentDirectoryW;
390 struct WORKREQ_FTPCREATEDIRECTORYW FtpCreateDirectoryW;
391 struct WORKREQ_FTPFINDFIRSTFILEW FtpFindFirstFileW;
392 struct WORKREQ_FTPGETCURRENTDIRECTORYW FtpGetCurrentDirectoryW;
393 struct WORKREQ_FTPOPENFILEW FtpOpenFileW;
394 struct WORKREQ_FTPGETFILEW FtpGetFileW;
395 struct WORKREQ_FTPDELETEFILEW FtpDeleteFileW;
396 struct WORKREQ_FTPREMOVEDIRECTORYW FtpRemoveDirectoryW;
397 struct WORKREQ_FTPRENAMEFILEW FtpRenameFileW;
398 struct WORKREQ_FTPFINDNEXTW FtpFindNextW;
399 struct WORKREQ_HTTPSENDREQUESTW HttpSendRequestW;
400 struct WORKREQ_HTTPENDREQUESTW HttpEndRequestW;
401 struct WORKREQ_SENDCALLBACK SendCallback;
402 struct WORKREQ_INTERNETOPENURLW InternetOpenUrlW;
403 struct WORKREQ_INTERNETREADFILEEXA InternetReadFileExA;
404 struct WORKREQ_INTERNETREADFILEEXW InternetReadFileExW;
405 } u;
407 } WORKREQUEST, *LPWORKREQUEST;
409 HINTERNET WININET_AllocHandle( object_header_t *info );
410 object_header_t *WININET_GetObject( HINTERNET hinternet );
411 object_header_t *WININET_AddRef( object_header_t *info );
412 BOOL WININET_Release( object_header_t *info );
413 BOOL WININET_FreeHandle( HINTERNET hinternet );
415 DWORD INET_QueryOption( object_header_t *, DWORD, void *, DWORD *, BOOL );
417 time_t ConvertTimeString(LPCWSTR asctime);
419 HINTERNET FTP_Connect(appinfo_t *hIC, LPCWSTR lpszServerName,
420 INTERNET_PORT nServerPort, LPCWSTR lpszUserName,
421 LPCWSTR lpszPassword, DWORD dwFlags, DWORD_PTR dwContext,
422 DWORD dwInternalFlags);
424 DWORD HTTP_Connect(appinfo_t*,LPCWSTR,
425 INTERNET_PORT nServerPort, LPCWSTR lpszUserName,
426 LPCWSTR lpszPassword, DWORD dwFlags, DWORD_PTR dwContext,
427 DWORD dwInternalFlags, HINTERNET*);
429 BOOL GetAddress(LPCWSTR lpszServerName, INTERNET_PORT nServerPort,
430 struct sockaddr *psa, socklen_t *sa_len);
432 void INTERNET_SetLastError(DWORD dwError);
433 DWORD INTERNET_GetLastError(void);
434 DWORD INTERNET_AsyncCall(LPWORKREQUEST lpWorkRequest);
435 LPSTR INTERNET_GetResponseBuffer(void);
436 LPSTR INTERNET_GetNextLine(INT nSocket, LPDWORD dwLen);
438 VOID SendAsyncCallback(object_header_t *hdr, DWORD_PTR dwContext,
439 DWORD dwInternetStatus, LPVOID lpvStatusInfo,
440 DWORD dwStatusInfoLength);
442 VOID INTERNET_SendCallback(object_header_t *hdr, DWORD_PTR dwContext,
443 DWORD dwInternetStatus, LPVOID lpvStatusInfo,
444 DWORD dwStatusInfoLength);
445 BOOL INTERNET_FindProxyForProtocol(LPCWSTR szProxy, LPCWSTR proto, WCHAR *foundProxy, DWORD *foundProxyLen);
447 BOOL NETCON_connected(WININET_NETCONNECTION *connection);
448 DWORD NETCON_init(WININET_NETCONNECTION *connnection, BOOL useSSL);
449 void NETCON_unload(void);
450 DWORD NETCON_create(WININET_NETCONNECTION *connection, int domain,
451 int type, int protocol);
452 DWORD NETCON_close(WININET_NETCONNECTION *connection);
453 DWORD NETCON_connect(WININET_NETCONNECTION *connection, const struct sockaddr *serv_addr,
454 unsigned int addrlen);
455 DWORD NETCON_secure_connect(WININET_NETCONNECTION *connection, LPWSTR hostname);
456 DWORD NETCON_send(WININET_NETCONNECTION *connection, const void *msg, size_t len, int flags,
457 int *sent /* out */);
458 DWORD NETCON_recv(WININET_NETCONNECTION *connection, void *buf, size_t len, int flags,
459 int *recvd /* out */);
460 BOOL NETCON_query_data_available(WININET_NETCONNECTION *connection, DWORD *available);
461 LPCVOID NETCON_GetCert(WININET_NETCONNECTION *connection);
462 DWORD NETCON_set_timeout(WININET_NETCONNECTION *connection, BOOL send, int value);
463 int sock_get_error(int);
465 extern void URLCacheContainers_CreateDefaults(void);
466 extern void URLCacheContainers_DeleteAll(void);
468 #define MAX_REPLY_LEN 0x5B4
470 /* Used for debugging - maybe need to be shared in the Wine debugging code ? */
471 typedef struct
473 DWORD val;
474 const char* name;
475 } wininet_flag_info;
477 #endif /* _WINE_INTERNET_H_ */