Assorted spelling fixes.
[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., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
21  */
22
23 #ifndef _WINE_INTERNET_H_
24 #define _WINE_INTERNET_H_
25
26 #include "wine/unicode.h"
27
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
47
48 /* used for netconnection.c stuff */
49 typedef struct
50 {
51     BOOL useSSL;
52     int socketFD;
53 #ifdef HAVE_OPENSSL_SSL_H
54     SSL *ssl_s;
55     int ssl_sock;
56 #endif
57 } WININET_NETCONNECTION;
58
59 inline static LPSTR WININET_strdup( LPCSTR str )
60 {
61     LPSTR ret = HeapAlloc( GetProcessHeap(), 0, strlen(str) + 1 );
62     if (ret) strcpy( ret, str );
63     return ret;
64 }
65
66 inline static LPWSTR WININET_strdupW( LPCWSTR str )
67 {
68     LPWSTR ret = HeapAlloc( GetProcessHeap(), 0, (strlenW(str) + 1)*sizeof(WCHAR) );
69     if (ret) strcpyW( ret, str );
70     return ret;
71 }
72
73 typedef enum
74 {
75     WH_HINIT = INTERNET_HANDLE_TYPE_INTERNET,
76     WH_HFTPSESSION = INTERNET_HANDLE_TYPE_CONNECT_FTP,
77     WH_HGOPHERSESSION = INTERNET_HANDLE_TYPE_CONNECT_GOPHER,
78     WH_HHTTPSESSION = INTERNET_HANDLE_TYPE_CONNECT_HTTP,
79     WH_HFILE = INTERNET_HANDLE_TYPE_FTP_FILE,
80     WH_HFINDNEXT = INTERNET_HANDLE_TYPE_FTP_FIND,
81     WH_HHTTPREQ = INTERNET_HANDLE_TYPE_HTTP_REQUEST,
82 } WH_TYPE;
83
84 typedef struct _WININETHANDLEHEADER
85 {
86     WH_TYPE htype;
87     DWORD  dwFlags;
88     DWORD  dwContext;
89     DWORD  dwError;
90     struct _WININETHANDLEHEADER *lpwhparent;
91 } WININETHANDLEHEADER, *LPWININETHANDLEHEADER;
92
93
94 typedef struct
95 {
96     WININETHANDLEHEADER hdr;
97     LPWSTR  lpszAgent;
98     LPWSTR  lpszProxy;
99     LPWSTR  lpszProxyBypass;
100     LPWSTR  lpszProxyUsername;
101     LPWSTR  lpszProxyPassword;
102     DWORD   dwAccessType;
103     INTERNET_STATUS_CALLBACK lpfnStatusCB;
104 } WININETAPPINFOW, *LPWININETAPPINFOW;
105
106
107 typedef struct
108 {
109     WININETHANDLEHEADER hdr;
110     LPWSTR  lpszServerName;
111     LPWSTR  lpszUserName;
112     INTERNET_PORT nServerPort;
113     struct sockaddr_in socketAddress;
114     struct hostent *phostent;
115 } WININETHTTPSESSIONW, *LPWININETHTTPSESSIONW;
116
117 #define HDR_ISREQUEST           0x0001
118 #define HDR_COMMADELIMITED      0x0002
119 #define HDR_SEMIDELIMITED       0x0004
120
121 typedef struct
122 {
123     LPWSTR lpszField;
124     LPWSTR lpszValue;
125     WORD wFlags;
126     WORD wCount;
127 } HTTPHEADERW, *LPHTTPHEADERW;
128
129
130 typedef struct
131 {
132     WININETHANDLEHEADER hdr;
133     LPWSTR lpszPath;
134     LPWSTR lpszVerb;
135     LPWSTR lpszHostName;
136     WININET_NETCONNECTION netConnection;
137     HTTPHEADERW StdHeaders[HTTP_QUERY_MAX+1];
138     HTTPHEADERW *pCustHeaders;
139     INT nCustHeaders;
140 } WININETHTTPREQW, *LPWININETHTTPREQW;
141
142
143 typedef struct
144 {
145     WININETHANDLEHEADER hdr;
146     BOOL session_deleted;
147     int nDataSocket;
148 } WININETFILE, *LPWININETFILE;
149
150
151 typedef struct
152 {
153     WININETHANDLEHEADER hdr;
154     int sndSocket;
155     int lstnSocket;
156     int pasvSocket; /* data socket connected by us in case of passive FTP */
157     LPWININETFILE download_in_progress;
158     struct sockaddr_in socketAddress;
159     struct sockaddr_in lstnSocketAddress;
160     struct hostent *phostent;
161     LPSTR  lpszPassword;
162     LPSTR  lpszUserName;
163 } WININETFTPSESSIONA, *LPWININETFTPSESSIONA;
164
165
166 typedef struct
167 {
168     BOOL bIsDirectory;
169     LPSTR lpszName;
170     DWORD nSize;
171     struct tm tmLastModified;
172     unsigned short permissions;
173 } FILEPROPERTIESA, *LPFILEPROPERTIESA;
174
175
176 typedef struct
177 {
178     WININETHANDLEHEADER hdr;
179     int index;
180     DWORD size;
181     LPFILEPROPERTIESA lpafp;
182 } WININETFINDNEXTA, *LPWININETFINDNEXTA;
183
184 typedef enum
185 {
186     FTPPUTFILEA,
187     FTPSETCURRENTDIRECTORYA,
188     FTPCREATEDIRECTORYA,
189     FTPFINDFIRSTFILEA,
190     FTPGETCURRENTDIRECTORYA,
191     FTPOPENFILEA,
192     FTPGETFILEA,
193     FTPDELETEFILEA,
194     FTPREMOVEDIRECTORYA,
195     FTPRENAMEFILEA,
196     INTERNETFINDNEXTA,
197     HTTPSENDREQUESTW,
198     HTTPOPENREQUESTW,
199     SENDCALLBACK,
200     INTERNETOPENURLW,
201 } ASYNC_FUNC;
202
203 struct WORKREQ_FTPPUTFILEA
204 {
205     LPSTR lpszLocalFile;
206     LPSTR lpszNewRemoteFile;
207     DWORD  dwFlags;
208     DWORD  dwContext;
209 };
210
211 struct WORKREQ_FTPSETCURRENTDIRECTORYA
212 {
213     LPSTR lpszDirectory;
214 };
215
216 struct WORKREQ_FTPCREATEDIRECTORYA
217 {
218     LPSTR lpszDirectory;
219 };
220
221 struct WORKREQ_FTPFINDFIRSTFILEA
222 {
223     LPSTR lpszSearchFile;
224     LPWIN32_FIND_DATAA lpFindFileData;
225     DWORD  dwFlags;
226     DWORD  dwContext;
227 };
228
229 struct WORKREQ_FTPGETCURRENTDIRECTORYA
230 {
231     LPSTR lpszDirectory;
232     DWORD *lpdwDirectory;
233 };
234
235 struct WORKREQ_FTPOPENFILEA
236 {
237     LPSTR lpszFilename;
238     DWORD  dwAccess;
239     DWORD  dwFlags;
240     DWORD  dwContext;
241 };
242
243 struct WORKREQ_FTPGETFILEA
244 {
245     LPSTR lpszRemoteFile;
246     LPSTR lpszNewFile;
247     BOOL   fFailIfExists;
248     DWORD  dwLocalFlagsAttribute;
249     DWORD  dwFlags;
250     DWORD  dwContext;
251 };
252
253 struct WORKREQ_FTPDELETEFILEA
254 {
255     LPSTR lpszFilename;
256 };
257
258 struct WORKREQ_FTPREMOVEDIRECTORYA
259 {
260     LPSTR lpszDirectory;
261 };
262
263 struct WORKREQ_FTPRENAMEFILEA
264 {
265     LPSTR lpszSrcFile;
266     LPSTR lpszDestFile;
267 };
268
269 struct WORKREQ_INTERNETFINDNEXTA
270 {
271     LPWIN32_FIND_DATAA lpFindFileData;
272 };
273
274 struct WORKREQ_HTTPOPENREQUESTW
275 {
276     LPWSTR lpszVerb;
277     LPWSTR lpszObjectName;
278     LPWSTR lpszVersion;
279     LPWSTR lpszReferrer;
280     LPCWSTR *lpszAcceptTypes;
281     DWORD  dwFlags;
282     DWORD  dwContext;
283 };
284
285 struct WORKREQ_HTTPSENDREQUESTW
286 {
287     LPWSTR lpszHeader;
288     DWORD  dwHeaderLength;
289     LPVOID lpOptional;
290     DWORD  dwOptionalLength;
291 };
292
293 struct WORKREQ_SENDCALLBACK
294 {
295     HINTERNET hHttpSession;
296     DWORD     dwContext;
297     DWORD     dwInternetStatus;
298     LPVOID    lpvStatusInfo;
299     DWORD     dwStatusInfoLength;
300 };
301
302 struct WORKREQ_INTERNETOPENURLW
303 {
304     HINTERNET hInternet;
305     LPWSTR     lpszUrl;
306     LPWSTR     lpszHeaders;
307     DWORD     dwHeadersLength;
308     DWORD     dwFlags;
309     DWORD     dwContext;
310 };
311
312 typedef struct WORKREQ
313 {
314     ASYNC_FUNC asyncall;
315     HINTERNET handle;
316
317     union {
318         struct WORKREQ_FTPPUTFILEA              FtpPutFileA;
319         struct WORKREQ_FTPSETCURRENTDIRECTORYA  FtpSetCurrentDirectoryA;
320         struct WORKREQ_FTPCREATEDIRECTORYA      FtpCreateDirectoryA;
321         struct WORKREQ_FTPFINDFIRSTFILEA        FtpFindFirstFileA;
322         struct WORKREQ_FTPGETCURRENTDIRECTORYA  FtpGetCurrentDirectoryA;
323         struct WORKREQ_FTPOPENFILEA             FtpOpenFileA;
324         struct WORKREQ_FTPGETFILEA              FtpGetFileA;
325         struct WORKREQ_FTPDELETEFILEA           FtpDeleteFileA;
326         struct WORKREQ_FTPREMOVEDIRECTORYA      FtpRemoveDirectoryA;
327         struct WORKREQ_FTPRENAMEFILEA           FtpRenameFileA;
328         struct WORKREQ_INTERNETFINDNEXTA        InternetFindNextA;
329         struct WORKREQ_HTTPOPENREQUESTW         HttpOpenRequestW;
330         struct WORKREQ_HTTPSENDREQUESTW         HttpSendRequestW;
331         struct WORKREQ_SENDCALLBACK             SendCallback;
332         struct WORKREQ_INTERNETOPENURLW         InternetOpenUrlW;
333     } u;
334
335     struct WORKREQ *next;
336     struct WORKREQ *prev;
337
338 } WORKREQUEST, *LPWORKREQUEST;
339
340 HINTERNET WININET_AllocHandle( LPWININETHANDLEHEADER info );
341 LPWININETHANDLEHEADER WININET_GetObject( HINTERNET hinternet );
342 BOOL WININET_FreeHandle( HINTERNET hinternet );
343 HINTERNET WININET_FindHandle( LPWININETHANDLEHEADER info );
344
345 time_t ConvertTimeString(LPCWSTR asctime);
346
347 HINTERNET FTP_Connect(HINTERNET hInterent, LPCWSTR lpszServerName,
348         INTERNET_PORT nServerPort, LPCWSTR lpszUserName,
349         LPCWSTR lpszPassword, DWORD dwFlags, DWORD dwContext);
350
351 HINTERNET HTTP_Connect(HINTERNET hInterent, LPCWSTR lpszServerName,
352         INTERNET_PORT nServerPort, LPCWSTR lpszUserName,
353         LPCWSTR lpszPassword, DWORD dwFlags, DWORD dwContext);
354
355 BOOL GetAddress(LPCWSTR lpszServerName, INTERNET_PORT nServerPort,
356         struct hostent **phe, struct sockaddr_in *psa);
357
358 void INTERNET_SetLastError(DWORD dwError);
359 DWORD INTERNET_GetLastError();
360 BOOL INTERNET_AsyncCall(LPWORKREQUEST lpWorkRequest);
361 LPSTR INTERNET_GetResponseBuffer();
362 LPSTR INTERNET_GetNextLine(INT nSocket, LPSTR lpszBuffer, LPDWORD dwBuffer);
363
364 BOOL FTP_CloseSessionHandle(LPWININETFTPSESSIONA lpwfs);
365 BOOL FTP_CloseFindNextHandle(LPWININETFINDNEXTA lpwfn);
366 BOOL FTP_CloseFileTransferHandle(LPWININETFILE lpwfn);
367 BOOLAPI FTP_FtpPutFileA(HINTERNET hConnect, LPCSTR lpszLocalFile,
368     LPCSTR lpszNewRemoteFile, DWORD dwFlags, DWORD dwContext);
369 BOOLAPI FTP_FtpSetCurrentDirectoryA(HINTERNET hConnect, LPCSTR lpszDirectory);
370 BOOLAPI FTP_FtpCreateDirectoryA(HINTERNET hConnect, LPCSTR lpszDirectory);
371 INTERNETAPI HINTERNET WINAPI FTP_FtpFindFirstFileA(HINTERNET hConnect,
372     LPCSTR lpszSearchFile, LPWIN32_FIND_DATAA lpFindFileData, DWORD dwFlags, DWORD dwContext);
373 BOOLAPI FTP_FtpGetCurrentDirectoryA(HINTERNET hFtpSession, LPSTR lpszCurrentDirectory,
374         LPDWORD lpdwCurrentDirectory);
375 BOOL FTP_ConvertFileProp(LPFILEPROPERTIESA lpafp, LPWIN32_FIND_DATAA lpFindFileData);
376 BOOL FTP_FtpRenameFileA(HINTERNET hFtpSession, LPCSTR lpszSrc, LPCSTR lpszDest);
377 BOOL FTP_FtpRemoveDirectoryA(HINTERNET hFtpSession, LPCSTR lpszDirectory);
378 BOOL FTP_FtpDeleteFileA(HINTERNET hFtpSession, LPCSTR lpszFileName);
379 HINTERNET FTP_FtpOpenFileA(HINTERNET hFtpSession, LPCSTR lpszFileName,
380         DWORD fdwAccess, DWORD dwFlags, DWORD dwContext);
381 BOOLAPI FTP_FtpGetFileA(HINTERNET hInternet, LPCSTR lpszRemoteFile, LPCSTR lpszNewFile,
382         BOOL fFailIfExists, DWORD dwLocalFlagsAttribute, DWORD dwInternetFlags,
383         DWORD dwContext);
384
385 BOOLAPI HTTP_HttpSendRequestW(HINTERNET hHttpRequest, LPCWSTR lpszHeaders,
386         DWORD dwHeaderLength, LPVOID lpOptional ,DWORD dwOptionalLength);
387 INTERNETAPI HINTERNET WINAPI HTTP_HttpOpenRequestW(HINTERNET hHttpSession,
388         LPCWSTR lpszVerb, LPCWSTR lpszObjectName, LPCWSTR lpszVersion,
389         LPCWSTR lpszReferrer , LPCWSTR *lpszAcceptTypes,
390         DWORD dwFlags, DWORD dwContext);
391 void HTTP_CloseHTTPSessionHandle(LPWININETHTTPSESSIONW lpwhs);
392 void HTTP_CloseHTTPRequestHandle(LPWININETHTTPREQW lpwhr);
393
394 VOID SendAsyncCallback(LPWININETAPPINFOW hIC, HINTERNET hHttpSession,
395                              DWORD dwContext, DWORD dwInternetStatus, LPVOID
396                              lpvStatusInfo , DWORD dwStatusInfoLength);
397
398 VOID SendAsyncCallbackInt(LPWININETAPPINFOW hIC, HINTERNET hHttpSession,
399                              DWORD dwContext, DWORD dwInternetStatus, LPVOID
400                              lpvStatusInfo , DWORD dwStatusInfoLength);
401
402 BOOL HTTP_InsertProxyAuthorization( LPWININETHTTPREQW lpwhr,
403                        LPCWSTR username, LPCWSTR password );
404
405 BOOL NETCON_connected(WININET_NETCONNECTION *connection);
406 void NETCON_init(WININET_NETCONNECTION *connnection, BOOL useSSL);
407 BOOL NETCON_create(WININET_NETCONNECTION *connection, int domain,
408               int type, int protocol);
409 BOOL NETCON_close(WININET_NETCONNECTION *connection);
410 BOOL NETCON_connect(WININET_NETCONNECTION *connection, const struct sockaddr *serv_addr,
411                     socklen_t addrlen);
412 BOOL NETCON_send(WININET_NETCONNECTION *connection, const void *msg, size_t len, int flags,
413                 int *sent /* out */);
414 BOOL NETCON_recv(WININET_NETCONNECTION *connection, void *buf, size_t len, int flags,
415                 int *recvd /* out */);
416 BOOL NETCON_getNextLine(WININET_NETCONNECTION *connection, LPSTR lpszBuffer, LPDWORD dwBuffer);
417
418 #define MAX_REPLY_LEN           0x5B4
419
420 /* Used for debugging - maybe need to be shared in the Wine debugging code ? */
421 typedef struct
422 {
423     DWORD val;
424     const char* name;
425 } wininet_flag_info;
426
427 #endif /* _WINE_INTERNET_H_ */