wined3d: We only care is a sampler is sampled at all in device_map_vsamplers(), not...
[wine] / dlls / wininet / internet.h
1 /*
2  * Wininet
3  *
4  * Copyright 1999 Corel Corporation
5  *
6  * Ulrich Czekalla
7  *
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.
12  *
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.
17  *
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
21  */
22
23 #ifndef _WINE_INTERNET_H_
24 #define _WINE_INTERNET_H_
25
26 #ifndef __WINE_CONFIG_H
27 # error You must include config.h to use this header
28 #endif
29
30 #include "wine/unicode.h"
31 #include "wine/list.h"
32
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
44
45 #if defined(__MINGW32__) || defined (_MSC_VER)
46 #ifndef MSG_WAITALL
47 #define MSG_WAITALL 0
48 #endif
49 #else
50 #define closesocket close
51 #define ioctlsocket ioctl
52 #endif /* __MINGW32__ */
53
54 /* used for netconnection.c stuff */
55 typedef struct
56 {
57     BOOL useSSL;
58     int socketFD;
59     void *ssl_s;
60     char *peek_msg;
61     char *peek_msg_mem;
62     size_t peek_len;
63 } WININET_NETCONNECTION;
64
65 static inline LPWSTR WININET_strdupW( LPCWSTR str )
66 {
67     LPWSTR ret = HeapAlloc( GetProcessHeap(), 0, (strlenW(str) + 1)*sizeof(WCHAR) );
68     if (ret) strcpyW( ret, str );
69     return ret;
70 }
71
72 static inline LPWSTR WININET_strdup_AtoW( LPCSTR str )
73 {
74     int len = MultiByteToWideChar( CP_ACP, 0, str, -1, NULL, 0);
75     LPWSTR ret = HeapAlloc( GetProcessHeap(), 0, len * sizeof(WCHAR) );
76     if (ret)
77         MultiByteToWideChar( CP_ACP, 0, str, -1, ret, len);
78     return ret;
79 }
80
81 static inline LPSTR WININET_strdup_WtoA( LPCWSTR str )
82 {
83     int len = WideCharToMultiByte( CP_ACP, 0, str, -1, NULL, 0, NULL, NULL);
84     LPSTR ret = HeapAlloc( GetProcessHeap(), 0, len );
85     if (ret)
86         WideCharToMultiByte( CP_ACP, 0, str, -1, ret, len, NULL, NULL);
87     return ret;
88 }
89
90 static inline void WININET_find_data_WtoA(LPWIN32_FIND_DATAW dataW, LPWIN32_FIND_DATAA dataA)
91 {
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),
102         NULL, NULL);
103     WideCharToMultiByte(CP_ACP, 0, dataW->cAlternateFileName, -1, 
104         dataA->cAlternateFileName, sizeof(dataA->cAlternateFileName),
105         NULL, NULL);
106 }
107
108 typedef enum
109 {
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,
117 } WH_TYPE;
118
119 #define INET_OPENURL 0x0001
120 #define INET_CALLBACKW 0x0002
121
122 typedef struct _WININETHANDLEHEADER WININETHANDLEHEADER, *LPWININETHANDLEHEADER;
123
124 typedef struct {
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*);
134 } HANDLEHEADERVtbl;
135
136 struct _WININETHANDLEHEADER
137 {
138     WH_TYPE htype;
139     const HANDLEHEADERVtbl *vtbl;
140     HINTERNET hInternet;
141     DWORD  dwFlags;
142     DWORD_PTR dwContext;
143     DWORD  dwError;
144     DWORD  dwInternalFlags;
145     LONG   refs;
146     INTERNET_STATUS_CALLBACK lpfnStatusCB;
147     struct list entry;
148     struct list children;
149 };
150
151
152 typedef struct
153 {
154     WININETHANDLEHEADER hdr;
155     LPWSTR  lpszAgent;
156     LPWSTR  lpszProxy;
157     LPWSTR  lpszProxyBypass;
158     LPWSTR  lpszProxyUsername;
159     LPWSTR  lpszProxyPassword;
160     DWORD   dwAccessType;
161 } WININETAPPINFOW, *LPWININETAPPINFOW;
162
163
164 typedef struct
165 {
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 */
170     LPWSTR  lpszUserName;
171     LPWSTR  lpszPassword;
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;
176
177 #define HDR_ISREQUEST           0x0001
178 #define HDR_COMMADELIMITED      0x0002
179 #define HDR_SEMIDELIMITED       0x0004
180
181 typedef struct
182 {
183     LPWSTR lpszField;
184     LPWSTR lpszValue;
185     WORD wFlags;
186     WORD wCount;
187 } HTTPHEADERW, *LPHTTPHEADERW;
188
189
190 struct HttpAuthInfo;
191
192 typedef struct
193 {
194     WININETHANDLEHEADER hdr;
195     WININETHTTPSESSIONW *lpHttpSession;
196     LPWSTR lpszPath;
197     LPWSTR lpszVerb;
198     LPWSTR lpszRawHeaders;
199     WININET_NETCONNECTION netConnection;
200     LPWSTR lpszVersion;
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;
205     DWORD nCustHeaders;
206     HANDLE hCacheFile;
207     LPWSTR lpszCacheFile;
208     struct HttpAuthInfo *pAuthInfo;
209     struct HttpAuthInfo *pProxyAuthInfo;
210 } WININETHTTPREQW, *LPWININETHTTPREQW;
211
212
213
214 struct WORKREQ_FTPPUTFILEW
215 {
216     LPWSTR lpszLocalFile;
217     LPWSTR lpszNewRemoteFile;
218     DWORD  dwFlags;
219     DWORD_PTR dwContext;
220 };
221
222 struct WORKREQ_FTPSETCURRENTDIRECTORYW
223 {
224     LPWSTR lpszDirectory;
225 };
226
227 struct WORKREQ_FTPCREATEDIRECTORYW
228 {
229     LPWSTR lpszDirectory;
230 };
231
232 struct WORKREQ_FTPFINDFIRSTFILEW
233 {
234     LPWSTR lpszSearchFile;
235     LPWIN32_FIND_DATAW lpFindFileData;
236     DWORD  dwFlags;
237     DWORD_PTR dwContext;
238 };
239
240 struct WORKREQ_FTPGETCURRENTDIRECTORYW
241 {
242     LPWSTR lpszDirectory;
243     DWORD *lpdwDirectory;
244 };
245
246 struct WORKREQ_FTPOPENFILEW
247 {
248     LPWSTR lpszFilename;
249     DWORD  dwAccess;
250     DWORD  dwFlags;
251     DWORD_PTR dwContext;
252 };
253
254 struct WORKREQ_FTPGETFILEW
255 {
256     LPWSTR lpszRemoteFile;
257     LPWSTR lpszNewFile;
258     BOOL   fFailIfExists;
259     DWORD  dwLocalFlagsAttribute;
260     DWORD  dwFlags;
261     DWORD_PTR dwContext;
262 };
263
264 struct WORKREQ_FTPDELETEFILEW
265 {
266     LPWSTR lpszFilename;
267 };
268
269 struct WORKREQ_FTPREMOVEDIRECTORYW
270 {
271     LPWSTR lpszDirectory;
272 };
273
274 struct WORKREQ_FTPRENAMEFILEW
275 {
276     LPWSTR lpszSrcFile;
277     LPWSTR lpszDestFile;
278 };
279
280 struct WORKREQ_FTPFINDNEXTW
281 {
282     LPWIN32_FIND_DATAW lpFindFileData;
283 };
284
285 struct WORKREQ_HTTPSENDREQUESTW
286 {
287     LPWSTR lpszHeader;
288     DWORD  dwHeaderLength;
289     LPVOID lpOptional;
290     DWORD  dwOptionalLength;
291     DWORD  dwContentLength;
292     BOOL   bEndRequest;
293 };
294
295 struct WORKREQ_SENDCALLBACK
296 {
297     DWORD_PTR dwContext;
298     DWORD     dwInternetStatus;
299     LPVOID    lpvStatusInfo;
300     DWORD     dwStatusInfoLength;
301 };
302
303 struct WORKREQ_INTERNETOPENURLW
304 {
305     HINTERNET hInternet;
306     LPWSTR     lpszUrl;
307     LPWSTR     lpszHeaders;
308     DWORD     dwHeadersLength;
309     DWORD     dwFlags;
310     DWORD_PTR dwContext;
311 };
312
313 struct WORKREQ_INTERNETREADFILEEXA
314 {
315     LPINTERNET_BUFFERSA lpBuffersOut;
316 };
317
318 typedef struct WORKREQ
319 {
320     void (*asyncproc)(struct WORKREQ*);
321     WININETHANDLEHEADER *hdr;
322
323     union {
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;
339     } u;
340
341 } WORKREQUEST, *LPWORKREQUEST;
342
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 );
348
349 DWORD INET_QueryOption(DWORD,void*,DWORD*,BOOL);
350
351 time_t ConvertTimeString(LPCWSTR asctime);
352
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);
357
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);
362
363 BOOL GetAddress(LPCWSTR lpszServerName, INTERNET_PORT nServerPort,
364         struct sockaddr_in *psa);
365
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);
371
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);
380
381 VOID SendAsyncCallback(LPWININETHANDLEHEADER hdr, DWORD_PTR dwContext,
382                        DWORD dwInternetStatus, LPVOID lpvStatusInfo,
383                        DWORD dwStatusInfoLength);
384
385 VOID INTERNET_SendCallback(LPWININETHANDLEHEADER hdr, DWORD_PTR dwContext,
386                            DWORD dwInternetStatus, LPVOID lpvStatusInfo,
387                            DWORD dwStatusInfoLength);
388
389 LPHTTPHEADERW HTTP_GetHeader(LPWININETHTTPREQW lpwhr, LPCWSTR header);
390
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);
407
408 extern void URLCacheContainers_CreateDefaults(void);
409 extern void URLCacheContainers_DeleteAll(void);
410
411 #define MAX_REPLY_LEN           0x5B4
412
413 /* Used for debugging - maybe need to be shared in the Wine debugging code ? */
414 typedef struct
415 {
416     DWORD val;
417     const char* name;
418 } wininet_flag_info;
419
420 #endif /* _WINE_INTERNET_H_ */