wininet: Use proc instead of enum in FTPDELETEFILEW request.
[wine.git] / dlls / wininet / internet.h
blob1d68a7c522e63bcd8ee2125ae3ca01f5b409b775
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 #include "wine/unicode.h"
28 #include <time.h>
29 #ifdef HAVE_NETDB_H
30 # include <netdb.h>
31 #endif
32 #ifdef HAVE_NETINET_IN_H
33 # include <sys/types.h>
34 # include <netinet/in.h>
35 #endif
36 #ifdef HAVE_OPENSSL_SSL_H
37 #define DSA __ssl_DSA /* avoid conflict with commctrl.h */
38 #undef FAR
39 # include <openssl/ssl.h>
40 #undef FAR
41 #define FAR do_not_use_this_in_wine
42 #undef DSA
43 #endif
44 #ifdef HAVE_SYS_SOCKET_H
45 # include <sys/socket.h>
46 #endif
48 #if defined(__MINGW32__) || defined (_MSC_VER)
49 #include "winsock2.h"
50 #ifndef MSG_WAITALL
51 #define MSG_WAITALL 0
52 #endif
53 #else
54 #define closesocket close
55 #endif /* __MINGW32__ */
57 /* used for netconnection.c stuff */
58 typedef struct
60 BOOL useSSL;
61 int socketFD;
62 #ifdef HAVE_OPENSSL_SSL_H
63 SSL *ssl_s;
64 char *peek_msg;
65 char *peek_msg_mem;
66 size_t peek_len;
67 #endif
68 } WININET_NETCONNECTION;
70 inline static LPSTR WININET_strdup( LPCSTR str )
72 LPSTR ret = HeapAlloc( GetProcessHeap(), 0, strlen(str) + 1 );
73 if (ret) strcpy( ret, str );
74 return ret;
77 inline static LPWSTR WININET_strdupW( LPCWSTR str )
79 LPWSTR ret = HeapAlloc( GetProcessHeap(), 0, (strlenW(str) + 1)*sizeof(WCHAR) );
80 if (ret) strcpyW( ret, str );
81 return ret;
84 inline static LPWSTR WININET_strdup_AtoW( LPCSTR str )
86 int len = MultiByteToWideChar( CP_ACP, 0, str, -1, NULL, 0);
87 LPWSTR ret = HeapAlloc( GetProcessHeap(), 0, len * sizeof(WCHAR) );
88 if (ret)
89 MultiByteToWideChar( CP_ACP, 0, str, -1, ret, len);
90 return ret;
93 inline static LPSTR WININET_strdup_WtoA( LPCWSTR str )
95 int len = WideCharToMultiByte( CP_ACP, 0, str, -1, NULL, 0, NULL, NULL);
96 LPSTR ret = HeapAlloc( GetProcessHeap(), 0, len );
97 if (ret)
98 WideCharToMultiByte( CP_ACP, 0, str, -1, ret, len, NULL, NULL);
99 return ret;
102 inline static void WININET_find_data_WtoA(LPWIN32_FIND_DATAW dataW, LPWIN32_FIND_DATAA dataA)
104 dataA->dwFileAttributes = dataW->dwFileAttributes;
105 dataA->ftCreationTime = dataW->ftCreationTime;
106 dataA->ftLastAccessTime = dataW->ftLastAccessTime;
107 dataA->ftLastWriteTime = dataW->ftLastWriteTime;
108 dataA->nFileSizeHigh = dataW->nFileSizeHigh;
109 dataA->nFileSizeLow = dataW->nFileSizeLow;
110 dataA->dwReserved0 = dataW->dwReserved0;
111 dataA->dwReserved1 = dataW->dwReserved1;
112 WideCharToMultiByte(CP_ACP, 0, dataW->cFileName, -1,
113 dataA->cFileName, sizeof(dataA->cFileName),
114 NULL, NULL);
115 WideCharToMultiByte(CP_ACP, 0, dataW->cAlternateFileName, -1,
116 dataA->cAlternateFileName, sizeof(dataA->cAlternateFileName),
117 NULL, NULL);
120 typedef enum
122 WH_HINIT = INTERNET_HANDLE_TYPE_INTERNET,
123 WH_HFTPSESSION = INTERNET_HANDLE_TYPE_CONNECT_FTP,
124 WH_HGOPHERSESSION = INTERNET_HANDLE_TYPE_CONNECT_GOPHER,
125 WH_HHTTPSESSION = INTERNET_HANDLE_TYPE_CONNECT_HTTP,
126 WH_HFILE = INTERNET_HANDLE_TYPE_FTP_FILE,
127 WH_HFTPFINDNEXT = INTERNET_HANDLE_TYPE_FTP_FIND,
128 WH_HHTTPREQ = INTERNET_HANDLE_TYPE_HTTP_REQUEST,
129 } WH_TYPE;
131 #define INET_OPENURL 0x0001
132 #define INET_CALLBACKW 0x0002
134 struct _WININETHANDLEHEADER;
135 typedef struct _WININETHANDLEHEADER WININETHANDLEHEADER, *LPWININETHANDLEHEADER;
137 typedef void (*WININET_object_destructor)( LPWININETHANDLEHEADER );
139 struct _WININETHANDLEHEADER
141 WH_TYPE htype;
142 HINTERNET hInternet;
143 DWORD dwFlags;
144 DWORD dwContext;
145 DWORD dwError;
146 DWORD dwInternalFlags;
147 DWORD dwRefCount;
148 WININET_object_destructor destroy;
149 INTERNET_STATUS_CALLBACK lpfnStatusCB;
153 typedef struct
155 WININETHANDLEHEADER hdr;
156 LPWSTR lpszAgent;
157 LPWSTR lpszProxy;
158 LPWSTR lpszProxyBypass;
159 LPWSTR lpszProxyUsername;
160 LPWSTR lpszProxyPassword;
161 DWORD dwAccessType;
162 } WININETAPPINFOW, *LPWININETAPPINFOW;
165 typedef struct
167 WININETHANDLEHEADER hdr;
168 WININETAPPINFOW *lpAppInfo;
169 LPWSTR lpszHostName; /* the final destination of the request */
170 LPWSTR lpszServerName; /* the name of the server we directly connect to */
171 LPWSTR lpszUserName;
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
181 typedef struct
183 LPWSTR lpszField;
184 LPWSTR lpszValue;
185 WORD wFlags;
186 WORD wCount;
187 } HTTPHEADERW, *LPHTTPHEADERW;
190 typedef struct
192 WININETHANDLEHEADER hdr;
193 WININETHTTPSESSIONW *lpHttpSession;
194 LPWSTR lpszPath;
195 LPWSTR lpszVerb;
196 LPWSTR lpszRawHeaders;
197 WININET_NETCONNECTION netConnection;
198 LPWSTR lpszVersion;
199 LPWSTR lpszStatusText;
200 HTTPHEADERW *pCustHeaders;
201 DWORD nCustHeaders;
202 } WININETHTTPREQW, *LPWININETHTTPREQW;
205 struct _WININETFTPSESSIONW;
207 typedef struct
209 WININETHANDLEHEADER hdr;
210 struct _WININETFTPSESSIONW *lpFtpSession;
211 BOOL session_deleted;
212 int nDataSocket;
213 } WININETFTPFILE, *LPWININETFTPFILE;
216 typedef struct _WININETFTPSESSIONW
218 WININETHANDLEHEADER hdr;
219 WININETAPPINFOW *lpAppInfo;
220 int sndSocket;
221 int lstnSocket;
222 int pasvSocket; /* data socket connected by us in case of passive FTP */
223 LPWININETFTPFILE download_in_progress;
224 struct sockaddr_in socketAddress;
225 struct sockaddr_in lstnSocketAddress;
226 LPWSTR lpszPassword;
227 LPWSTR lpszUserName;
228 } WININETFTPSESSIONW, *LPWININETFTPSESSIONW;
231 typedef struct
233 BOOL bIsDirectory;
234 LPWSTR lpszName;
235 DWORD nSize;
236 struct tm tmLastModified;
237 unsigned short permissions;
238 } FILEPROPERTIESW, *LPFILEPROPERTIESW;
241 typedef struct
243 WININETHANDLEHEADER hdr;
244 WININETFTPSESSIONW *lpFtpSession;
245 DWORD index;
246 DWORD size;
247 LPFILEPROPERTIESW lpafp;
248 } WININETFTPFINDNEXTW, *LPWININETFTPFINDNEXTW;
250 typedef enum
252 CALLASYNCPROC,
253 FTPREMOVEDIRECTORYW,
254 FTPRENAMEFILEW,
255 FTPFINDNEXTW,
256 } ASYNC_FUNC;
258 struct WORKREQ_FTPPUTFILEW
260 LPWSTR lpszLocalFile;
261 LPWSTR lpszNewRemoteFile;
262 DWORD dwFlags;
263 DWORD dwContext;
266 struct WORKREQ_FTPSETCURRENTDIRECTORYW
268 LPWSTR lpszDirectory;
271 struct WORKREQ_FTPCREATEDIRECTORYW
273 LPWSTR lpszDirectory;
276 struct WORKREQ_FTPFINDFIRSTFILEW
278 LPWSTR lpszSearchFile;
279 LPWIN32_FIND_DATAW lpFindFileData;
280 DWORD dwFlags;
281 DWORD dwContext;
284 struct WORKREQ_FTPGETCURRENTDIRECTORYW
286 LPWSTR lpszDirectory;
287 DWORD *lpdwDirectory;
290 struct WORKREQ_FTPOPENFILEW
292 LPWSTR lpszFilename;
293 DWORD dwAccess;
294 DWORD dwFlags;
295 DWORD dwContext;
298 struct WORKREQ_FTPGETFILEW
300 LPWSTR lpszRemoteFile;
301 LPWSTR lpszNewFile;
302 BOOL fFailIfExists;
303 DWORD dwLocalFlagsAttribute;
304 DWORD dwFlags;
305 DWORD dwContext;
308 struct WORKREQ_FTPDELETEFILEW
310 LPWSTR lpszFilename;
313 struct WORKREQ_FTPREMOVEDIRECTORYW
315 LPWSTR lpszDirectory;
318 struct WORKREQ_FTPRENAMEFILEW
320 LPWSTR lpszSrcFile;
321 LPWSTR lpszDestFile;
324 struct WORKREQ_FTPFINDNEXTW
326 LPWIN32_FIND_DATAW lpFindFileData;
329 struct WORKREQ_HTTPSENDREQUESTW
331 LPWSTR lpszHeader;
332 DWORD dwHeaderLength;
333 LPVOID lpOptional;
334 DWORD dwOptionalLength;
335 DWORD dwContentLength;
336 BOOL bEndRequest;
339 struct WORKREQ_SENDCALLBACK
341 DWORD dwContext;
342 DWORD dwInternetStatus;
343 LPVOID lpvStatusInfo;
344 DWORD dwStatusInfoLength;
347 struct WORKREQ_INTERNETOPENURLW
349 HINTERNET hInternet;
350 LPWSTR lpszUrl;
351 LPWSTR lpszHeaders;
352 DWORD dwHeadersLength;
353 DWORD dwFlags;
354 DWORD dwContext;
357 struct WORKREQ_INTERNETREADFILEEXA
359 LPINTERNET_BUFFERSA lpBuffersOut;
362 typedef struct WORKREQ
364 ASYNC_FUNC asyncall;
365 void (*asyncproc)(struct WORKREQ*);
366 WININETHANDLEHEADER *hdr;
368 union {
369 struct WORKREQ_FTPPUTFILEW FtpPutFileW;
370 struct WORKREQ_FTPSETCURRENTDIRECTORYW FtpSetCurrentDirectoryW;
371 struct WORKREQ_FTPCREATEDIRECTORYW FtpCreateDirectoryW;
372 struct WORKREQ_FTPFINDFIRSTFILEW FtpFindFirstFileW;
373 struct WORKREQ_FTPGETCURRENTDIRECTORYW FtpGetCurrentDirectoryW;
374 struct WORKREQ_FTPOPENFILEW FtpOpenFileW;
375 struct WORKREQ_FTPGETFILEW FtpGetFileW;
376 struct WORKREQ_FTPDELETEFILEW FtpDeleteFileW;
377 struct WORKREQ_FTPREMOVEDIRECTORYW FtpRemoveDirectoryW;
378 struct WORKREQ_FTPRENAMEFILEW FtpRenameFileW;
379 struct WORKREQ_FTPFINDNEXTW FtpFindNextW;
380 struct WORKREQ_HTTPSENDREQUESTW HttpSendRequestW;
381 struct WORKREQ_SENDCALLBACK SendCallback;
382 struct WORKREQ_INTERNETOPENURLW InternetOpenUrlW;
383 struct WORKREQ_INTERNETREADFILEEXA InternetReadFileExA;
384 } u;
386 struct WORKREQ *next;
387 struct WORKREQ *prev;
389 } WORKREQUEST, *LPWORKREQUEST;
391 HINTERNET WININET_AllocHandle( LPWININETHANDLEHEADER info );
392 LPWININETHANDLEHEADER WININET_GetObject( HINTERNET hinternet );
393 LPWININETHANDLEHEADER WININET_AddRef( LPWININETHANDLEHEADER info );
394 BOOL WININET_Release( LPWININETHANDLEHEADER info );
395 BOOL WININET_FreeHandle( HINTERNET hinternet );
397 time_t ConvertTimeString(LPCWSTR asctime);
399 HINTERNET FTP_Connect(LPWININETAPPINFOW hIC, LPCWSTR lpszServerName,
400 INTERNET_PORT nServerPort, LPCWSTR lpszUserName,
401 LPCWSTR lpszPassword, DWORD dwFlags, DWORD dwContext,
402 DWORD dwInternalFlags);
404 HINTERNET HTTP_Connect(LPWININETAPPINFOW hIC, LPCWSTR lpszServerName,
405 INTERNET_PORT nServerPort, LPCWSTR lpszUserName,
406 LPCWSTR lpszPassword, DWORD dwFlags, DWORD dwContext,
407 DWORD dwInternalFlags);
409 BOOL GetAddress(LPCWSTR lpszServerName, INTERNET_PORT nServerPort,
410 struct sockaddr_in *psa);
412 void INTERNET_SetLastError(DWORD dwError);
413 DWORD INTERNET_GetLastError(void);
414 BOOL INTERNET_AsyncCall(LPWORKREQUEST lpWorkRequest);
415 LPSTR INTERNET_GetResponseBuffer(void);
416 LPSTR INTERNET_GetNextLine(INT nSocket, LPDWORD dwLen);
418 BOOLAPI FTP_FtpPutFileW(LPWININETFTPSESSIONW lpwfs, LPCWSTR lpszLocalFile,
419 LPCWSTR lpszNewRemoteFile, DWORD dwFlags, DWORD dwContext);
420 BOOLAPI FTP_FtpSetCurrentDirectoryW(LPWININETFTPSESSIONW lpwfs, LPCWSTR lpszDirectory);
421 BOOLAPI FTP_FtpCreateDirectoryW(LPWININETFTPSESSIONW lpwfs, LPCWSTR lpszDirectory);
422 INTERNETAPI HINTERNET WINAPI FTP_FtpFindFirstFileW(LPWININETFTPSESSIONW lpwfs,
423 LPCWSTR lpszSearchFile, LPWIN32_FIND_DATAW lpFindFileData, DWORD dwFlags, DWORD dwContext);
424 BOOL WINAPI FTP_FindNextFileW(LPWININETFTPFINDNEXTW lpwh, LPVOID lpvFindData);
425 BOOLAPI FTP_FtpGetCurrentDirectoryW(LPWININETFTPSESSIONW lpwfs, LPWSTR lpszCurrentDirectory,
426 LPDWORD lpdwCurrentDirectory);
427 BOOL FTP_ConvertFileProp(LPFILEPROPERTIESW lpafp, LPWIN32_FIND_DATAW lpFindFileData);
428 BOOL FTP_FtpRenameFileW(LPWININETFTPSESSIONW lpwfs, LPCWSTR lpszSrc, LPCWSTR lpszDest);
429 BOOL FTP_FtpRemoveDirectoryW(LPWININETFTPSESSIONW lpwfs, LPCWSTR lpszDirectory);
430 BOOL FTP_FtpDeleteFileW(LPWININETFTPSESSIONW lpwfs, LPCWSTR lpszFileName);
431 HINTERNET FTP_FtpOpenFileW(LPWININETFTPSESSIONW lpwfs, LPCWSTR lpszFileName,
432 DWORD fdwAccess, DWORD dwFlags, DWORD dwContext);
433 BOOLAPI FTP_FtpGetFileW(LPWININETFTPSESSIONW lpwfs, LPCWSTR lpszRemoteFile, LPCWSTR lpszNewFile,
434 BOOL fFailIfExists, DWORD dwLocalFlagsAttribute, DWORD dwInternetFlags,
435 DWORD dwContext);
437 BOOLAPI HTTP_HttpSendRequestW(LPWININETHTTPREQW lpwhr, LPCWSTR lpszHeaders,
438 DWORD dwHeaderLength, LPVOID lpOptional, DWORD dwOptionalLength,
439 DWORD dwContentLength, BOOL bEndRequest);
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 INTERNET_SendCallback(LPWININETHANDLEHEADER hdr, DWORD dwContext,
450 DWORD dwInternetStatus, LPVOID lpvStatusInfo,
451 DWORD dwStatusInfoLength);
453 LPHTTPHEADERW HTTP_GetHeader(LPWININETHTTPREQW lpwhr, LPCWSTR header);
455 BOOL NETCON_connected(WININET_NETCONNECTION *connection);
456 BOOL NETCON_init(WININET_NETCONNECTION *connnection, BOOL useSSL);
457 BOOL NETCON_create(WININET_NETCONNECTION *connection, int domain,
458 int type, int protocol);
459 BOOL NETCON_close(WININET_NETCONNECTION *connection);
460 BOOL NETCON_connect(WININET_NETCONNECTION *connection, const struct sockaddr *serv_addr,
461 unsigned int addrlen);
462 BOOL NETCON_secure_connect(WININET_NETCONNECTION *connection, LPCWSTR hostname);
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);
468 LPCVOID NETCON_GetCert(WININET_NETCONNECTION *connection);
469 BOOL NETCON_set_timeout(WININET_NETCONNECTION *connection, BOOL send, int value);
471 extern void URLCacheContainers_CreateDefaults(void);
472 extern void URLCacheContainers_DeleteAll(void);
474 #define MAX_REPLY_LEN 0x5B4
476 /* Used for debugging - maybe need to be shared in the Wine debugging code ? */
477 typedef struct
479 DWORD val;
480 const char* name;
481 } wininet_flag_info;
483 #endif /* _WINE_INTERNET_H_ */