ReactOS Fundraising Campaign 2012
 
€ 4,410 / € 30,000

Information | Donate

Home | Info | Community | Development | myReactOS | Contact Us

  1. Home
  2. Community
  3. Development
  4. myReactOS
  5. Fundraiser 2012

  1. Main Page
  2. Alphabetical List
  3. Data Structures
  4. Directories
  5. File List
  6. Data Fields
  7. Globals
  8. Related Pages

ReactOS Development > Doxygen

internet.h
Go to the documentation of this file.
00001 /*
00002  * Wininet
00003  *
00004  * Copyright 1999 Corel Corporation
00005  *
00006  * Ulrich Czekalla
00007  *
00008  * This library is free software; you can redistribute it and/or
00009  * modify it under the terms of the GNU Lesser General Public
00010  * License as published by the Free Software Foundation; either
00011  * version 2.1 of the License, or (at your option) any later version.
00012  *
00013  * This library is distributed in the hope that it will be useful,
00014  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00015  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00016  * Lesser General Public License for more details.
00017  *
00018  * You should have received a copy of the GNU Lesser General Public
00019  * License along with this library; if not, write to the Free Software
00020  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
00021  */
00022 
00023 #ifndef _WINE_INTERNET_H_
00024 #define _WINE_INTERNET_H_
00025 
00026 #ifndef __WINE_CONFIG_H
00027 # error You must include config.h to use this header
00028 #endif
00029 
00030 #include "wine/unicode.h"
00031 #include "wine/list.h"
00032 
00033 #include <time.h>
00034 #ifdef HAVE_NETDB_H
00035 # include <netdb.h>
00036 #endif
00037 #ifdef HAVE_NETINET_IN_H
00038 # include <sys/types.h>
00039 # include <netinet/in.h>
00040 #endif
00041 #ifdef HAVE_SYS_SOCKET_H
00042 # include <sys/socket.h>
00043 #endif
00044 
00045 #if !defined(__MINGW32__) && !defined(_MSC_VER)
00046 #define closesocket close
00047 #define ioctlsocket ioctl
00048 #endif /* __MINGW32__ */
00049 
00050 extern HMODULE WININET_hModule DECLSPEC_HIDDEN;
00051 
00052 #ifndef INET6_ADDRSTRLEN
00053 #define INET6_ADDRSTRLEN 46
00054 #endif
00055 
00056 typedef struct {
00057     WCHAR *name;
00058     INTERNET_PORT port;
00059     struct sockaddr_storage addr;
00060     socklen_t addr_len;
00061     char addr_str[INET6_ADDRSTRLEN];
00062 
00063     LONG ref;
00064     DWORD64 keep_until;
00065 
00066     struct list entry;
00067     struct list conn_pool;
00068 } server_t;
00069 
00070 void server_addref(server_t*) DECLSPEC_HIDDEN;
00071 void server_release(server_t*) DECLSPEC_HIDDEN;
00072 BOOL collect_connections(BOOL) DECLSPEC_HIDDEN;
00073 
00074 /* used for netconnection.c stuff */
00075 typedef struct
00076 {
00077     BOOL useSSL;
00078     int socketFD;
00079     void *ssl_s;
00080     server_t *server;
00081     DWORD security_flags;
00082 
00083     BOOL keep_alive;
00084     DWORD64 keep_until;
00085     struct list pool_entry;
00086 } netconn_t;
00087 
00088 static inline void * __WINE_ALLOC_SIZE(1) heap_alloc(size_t len)
00089 {
00090     return HeapAlloc(GetProcessHeap(), 0, len);
00091 }
00092 
00093 static inline void * __WINE_ALLOC_SIZE(1) heap_alloc_zero(size_t len)
00094 {
00095     return HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, len);
00096 }
00097 
00098 static inline void * __WINE_ALLOC_SIZE(2) heap_realloc(void *mem, size_t len)
00099 {
00100     return HeapReAlloc(GetProcessHeap(), 0, mem, len);
00101 }
00102 
00103 static inline void * __WINE_ALLOC_SIZE(2) heap_realloc_zero(void *mem, size_t len)
00104 {
00105     return HeapReAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, mem, len);
00106 }
00107 
00108 static inline BOOL heap_free(void *mem)
00109 {
00110     return HeapFree(GetProcessHeap(), 0, mem);
00111 }
00112 
00113 static inline LPWSTR heap_strdupW(LPCWSTR str)
00114 {
00115     LPWSTR ret = NULL;
00116 
00117     if(str) {
00118         DWORD size;
00119 
00120         size = (strlenW(str)+1)*sizeof(WCHAR);
00121         ret = heap_alloc(size);
00122         if(ret)
00123             memcpy(ret, str, size);
00124     }
00125 
00126     return ret;
00127 }
00128 
00129 static inline LPWSTR heap_strndupW(LPCWSTR str, UINT max_len)
00130 {
00131     LPWSTR ret;
00132     UINT len;
00133 
00134     if(!str)
00135         return NULL;
00136 
00137     for(len=0; len<max_len; len++)
00138         if(str[len] == '\0')
00139             break;
00140 
00141     ret = heap_alloc(sizeof(WCHAR)*(len+1));
00142     if(ret) {
00143         memcpy(ret, str, sizeof(WCHAR)*len);
00144         ret[len] = '\0';
00145     }
00146 
00147     return ret;
00148 }
00149 
00150 static inline WCHAR *heap_strdupAtoW(const char *str)
00151 {
00152     LPWSTR ret = NULL;
00153 
00154     if(str) {
00155         DWORD len;
00156 
00157         len = MultiByteToWideChar(CP_ACP, 0, str, -1, NULL, 0);
00158         ret = heap_alloc(len*sizeof(WCHAR));
00159         if(ret)
00160             MultiByteToWideChar(CP_ACP, 0, str, -1, ret, len);
00161     }
00162 
00163     return ret;
00164 }
00165 
00166 static inline char *heap_strdupWtoA(LPCWSTR str)
00167 {
00168     char *ret = NULL;
00169 
00170     if(str) {
00171         DWORD size = WideCharToMultiByte(CP_ACP, 0, str, -1, NULL, 0, NULL, NULL);
00172         ret = heap_alloc(size);
00173         if(ret)
00174             WideCharToMultiByte(CP_ACP, 0, str, -1, ret, size, NULL, NULL);
00175     }
00176 
00177     return ret;
00178 }
00179 
00180 static inline void WININET_find_data_WtoA(LPWIN32_FIND_DATAW dataW, LPWIN32_FIND_DATAA dataA)
00181 {
00182     dataA->dwFileAttributes = dataW->dwFileAttributes;
00183     dataA->ftCreationTime   = dataW->ftCreationTime;
00184     dataA->ftLastAccessTime = dataW->ftLastAccessTime;
00185     dataA->ftLastWriteTime  = dataW->ftLastWriteTime;
00186     dataA->nFileSizeHigh    = dataW->nFileSizeHigh;
00187     dataA->nFileSizeLow     = dataW->nFileSizeLow;
00188     dataA->dwReserved0      = dataW->dwReserved0;
00189     dataA->dwReserved1      = dataW->dwReserved1;
00190     WideCharToMultiByte(CP_ACP, 0, dataW->cFileName, -1, 
00191         dataA->cFileName, sizeof(dataA->cFileName),
00192         NULL, NULL);
00193     WideCharToMultiByte(CP_ACP, 0, dataW->cAlternateFileName, -1, 
00194         dataA->cAlternateFileName, sizeof(dataA->cAlternateFileName),
00195         NULL, NULL);
00196 }
00197 
00198 typedef enum
00199 {
00200     WH_HINIT = INTERNET_HANDLE_TYPE_INTERNET,
00201     WH_HFTPSESSION = INTERNET_HANDLE_TYPE_CONNECT_FTP,
00202     WH_HGOPHERSESSION = INTERNET_HANDLE_TYPE_CONNECT_GOPHER,
00203     WH_HHTTPSESSION = INTERNET_HANDLE_TYPE_CONNECT_HTTP,
00204     WH_HFILE = INTERNET_HANDLE_TYPE_FTP_FILE,
00205     WH_HFTPFINDNEXT = INTERNET_HANDLE_TYPE_FTP_FIND,
00206     WH_HHTTPREQ = INTERNET_HANDLE_TYPE_HTTP_REQUEST,
00207 } WH_TYPE;
00208 
00209 #define INET_OPENURL 0x0001
00210 #define INET_CALLBACKW 0x0002
00211 
00212 typedef struct _object_header_t object_header_t;
00213 
00214 typedef struct {
00215     void (*Destroy)(object_header_t*);
00216     void (*CloseConnection)(object_header_t*);
00217     DWORD (*QueryOption)(object_header_t*,DWORD,void*,DWORD*,BOOL);
00218     DWORD (*SetOption)(object_header_t*,DWORD,void*,DWORD);
00219     DWORD (*ReadFile)(object_header_t*,void*,DWORD,DWORD*);
00220     DWORD (*ReadFileExA)(object_header_t*,INTERNET_BUFFERSA*,DWORD,DWORD_PTR);
00221     DWORD (*ReadFileExW)(object_header_t*,INTERNET_BUFFERSW*,DWORD,DWORD_PTR);
00222     DWORD (*WriteFile)(object_header_t*,const void*,DWORD,DWORD*);
00223     DWORD (*QueryDataAvailable)(object_header_t*,DWORD*,DWORD,DWORD_PTR);
00224     DWORD (*FindNextFileW)(object_header_t*,void*);
00225 } object_vtbl_t;
00226 
00227 #define INTERNET_HANDLE_IN_USE 1
00228 
00229 struct _object_header_t
00230 {
00231     WH_TYPE htype;
00232     const object_vtbl_t *vtbl;
00233     HINTERNET hInternet;
00234     BOOL valid_handle;
00235     DWORD  dwFlags;
00236     DWORD_PTR dwContext;
00237     DWORD  dwError;
00238     ULONG  ErrorMask;
00239     DWORD  dwInternalFlags;
00240     LONG   refs;
00241     INTERNET_STATUS_CALLBACK lpfnStatusCB;
00242     struct list entry;
00243     struct list children;
00244 };
00245 
00246 
00247 typedef struct
00248 {
00249     object_header_t hdr;
00250     LPWSTR  agent;
00251     LPWSTR  proxy;
00252     LPWSTR  proxyBypass;
00253     LPWSTR  proxyUsername;
00254     LPWSTR  proxyPassword;
00255     DWORD   accessType;
00256 } appinfo_t;
00257 
00258 typedef struct
00259 {
00260     object_header_t hdr;
00261     appinfo_t *appInfo;
00262     LPWSTR  hostName; /* the final destination of the request */
00263     LPWSTR  serverName; /* the name of the server we directly connect to */
00264     LPWSTR  userName;
00265     LPWSTR  password;
00266     INTERNET_PORT hostPort; /* the final destination port of the request */
00267     INTERNET_PORT serverPort; /* the port of the server we directly connect to */
00268 } http_session_t;
00269 
00270 #define HDR_ISREQUEST       0x0001
00271 #define HDR_COMMADELIMITED  0x0002
00272 #define HDR_SEMIDELIMITED   0x0004
00273 
00274 typedef struct
00275 {
00276     LPWSTR lpszField;
00277     LPWSTR lpszValue;
00278     WORD wFlags;
00279     WORD wCount;
00280 } HTTPHEADERW, *LPHTTPHEADERW;
00281 
00282 
00283 struct HttpAuthInfo;
00284 
00285 typedef struct data_stream_vtbl_t data_stream_vtbl_t;
00286 
00287 typedef struct {
00288     const data_stream_vtbl_t *vtbl;
00289 }  data_stream_t;
00290 
00291 typedef struct {
00292     data_stream_t data_stream;
00293     DWORD content_length;
00294     DWORD content_read;
00295 } netconn_stream_t;
00296 
00297 #define READ_BUFFER_SIZE 8192
00298 
00299 typedef struct
00300 {
00301     object_header_t hdr;
00302     http_session_t *session;
00303     LPWSTR path;
00304     LPWSTR verb;
00305     LPWSTR rawHeaders;
00306     netconn_t *netconn;
00307     DWORD security_flags;
00308     LPWSTR version;
00309     LPWSTR statusText;
00310     DWORD bytesToWrite;
00311     DWORD bytesWritten;
00312     HTTPHEADERW *custHeaders;
00313     DWORD nCustHeaders;
00314     FILETIME last_modified;
00315     HANDLE hCacheFile;
00316     LPWSTR cacheFile;
00317     FILETIME expires;
00318     struct HttpAuthInfo *authInfo;
00319     struct HttpAuthInfo *proxyAuthInfo;
00320 
00321     CRITICAL_SECTION read_section;  /* section to protect the following fields */
00322     DWORD contentLength;  /* total number of bytes to be read */
00323     BOOL  read_chunked;   /* are we reading in chunked mode? */
00324     BOOL  read_gzip;      /* are we reading in gzip mode? */
00325     DWORD read_pos;       /* current read position in read_buf */
00326     DWORD read_size;      /* valid data size in read_buf */
00327     BYTE  read_buf[READ_BUFFER_SIZE]; /* buffer for already read but not returned data */
00328 
00329     BOOL decoding;
00330     data_stream_t *data_stream;
00331     netconn_stream_t netconn_stream;
00332 } http_request_t;
00333 
00334 
00335 
00336 struct WORKREQ_FTPPUTFILEW
00337 {
00338     LPWSTR lpszLocalFile;
00339     LPWSTR lpszNewRemoteFile;
00340     DWORD  dwFlags;
00341     DWORD_PTR dwContext;
00342 };
00343 
00344 struct WORKREQ_FTPSETCURRENTDIRECTORYW
00345 {
00346     LPWSTR lpszDirectory;
00347 };
00348 
00349 struct WORKREQ_FTPCREATEDIRECTORYW
00350 {
00351     LPWSTR lpszDirectory;
00352 };
00353 
00354 struct WORKREQ_FTPFINDFIRSTFILEW
00355 {
00356     LPWSTR lpszSearchFile;
00357     LPWIN32_FIND_DATAW lpFindFileData;
00358     DWORD  dwFlags;
00359     DWORD_PTR dwContext;
00360 };
00361 
00362 struct WORKREQ_FTPGETCURRENTDIRECTORYW
00363 {
00364     LPWSTR lpszDirectory;
00365     DWORD *lpdwDirectory;
00366 };
00367 
00368 struct WORKREQ_FTPOPENFILEW
00369 {
00370     LPWSTR lpszFilename;
00371     DWORD  dwAccess;
00372     DWORD  dwFlags;
00373     DWORD_PTR dwContext;
00374 };
00375 
00376 struct WORKREQ_FTPGETFILEW
00377 {
00378     LPWSTR lpszRemoteFile;
00379     LPWSTR lpszNewFile;
00380     BOOL   fFailIfExists;
00381     DWORD  dwLocalFlagsAttribute;
00382     DWORD  dwFlags;
00383     DWORD_PTR dwContext;
00384 };
00385 
00386 struct WORKREQ_FTPDELETEFILEW
00387 {
00388     LPWSTR lpszFilename;
00389 };
00390 
00391 struct WORKREQ_FTPREMOVEDIRECTORYW
00392 {
00393     LPWSTR lpszDirectory;
00394 };
00395 
00396 struct WORKREQ_FTPRENAMEFILEW
00397 {
00398     LPWSTR lpszSrcFile;
00399     LPWSTR lpszDestFile;
00400 };
00401 
00402 struct WORKREQ_FTPFINDNEXTW
00403 {
00404     LPWIN32_FIND_DATAW lpFindFileData;
00405 };
00406 
00407 struct WORKREQ_HTTPSENDREQUESTW
00408 {
00409     LPWSTR lpszHeader;
00410     DWORD  dwHeaderLength;
00411     LPVOID lpOptional;
00412     DWORD  dwOptionalLength;
00413     DWORD  dwContentLength;
00414     BOOL   bEndRequest;
00415 };
00416 
00417 struct WORKREQ_HTTPENDREQUESTW
00418 {
00419     DWORD     dwFlags;
00420     DWORD_PTR dwContext;
00421 };
00422 
00423 struct WORKREQ_SENDCALLBACK
00424 {
00425     DWORD_PTR dwContext;
00426     DWORD     dwInternetStatus;
00427     LPVOID    lpvStatusInfo;
00428     DWORD     dwStatusInfoLength;
00429 };
00430 
00431 struct WORKREQ_INTERNETOPENURLW
00432 {
00433     HINTERNET hInternet;
00434     LPWSTR     lpszUrl;
00435     LPWSTR     lpszHeaders;
00436     DWORD     dwHeadersLength;
00437     DWORD     dwFlags;
00438     DWORD_PTR dwContext;
00439 };
00440 
00441 struct WORKREQ_INTERNETREADFILEEXA
00442 {
00443     LPINTERNET_BUFFERSA lpBuffersOut;
00444 };
00445 
00446 struct WORKREQ_INTERNETREADFILEEXW
00447 {
00448     LPINTERNET_BUFFERSW lpBuffersOut;
00449 };
00450 
00451 typedef struct WORKREQ
00452 {
00453     void (*asyncproc)(struct WORKREQ*);
00454     object_header_t *hdr;
00455 
00456     union {
00457         struct WORKREQ_FTPPUTFILEW              FtpPutFileW;
00458         struct WORKREQ_FTPSETCURRENTDIRECTORYW  FtpSetCurrentDirectoryW;
00459         struct WORKREQ_FTPCREATEDIRECTORYW      FtpCreateDirectoryW;
00460         struct WORKREQ_FTPFINDFIRSTFILEW        FtpFindFirstFileW;
00461         struct WORKREQ_FTPGETCURRENTDIRECTORYW  FtpGetCurrentDirectoryW;
00462         struct WORKREQ_FTPOPENFILEW             FtpOpenFileW;
00463         struct WORKREQ_FTPGETFILEW              FtpGetFileW;
00464         struct WORKREQ_FTPDELETEFILEW           FtpDeleteFileW;
00465         struct WORKREQ_FTPREMOVEDIRECTORYW      FtpRemoveDirectoryW;
00466         struct WORKREQ_FTPRENAMEFILEW           FtpRenameFileW;
00467         struct WORKREQ_FTPFINDNEXTW             FtpFindNextW;
00468         struct WORKREQ_HTTPSENDREQUESTW         HttpSendRequestW;
00469         struct WORKREQ_HTTPENDREQUESTW          HttpEndRequestW;
00470         struct WORKREQ_SENDCALLBACK             SendCallback;
00471         struct WORKREQ_INTERNETOPENURLW         InternetOpenUrlW;
00472         struct WORKREQ_INTERNETREADFILEEXA      InternetReadFileExA;
00473         struct WORKREQ_INTERNETREADFILEEXW      InternetReadFileExW;
00474     } u;
00475 
00476 } WORKREQUEST, *LPWORKREQUEST;
00477 
00478 void *alloc_object(object_header_t*,const object_vtbl_t*,size_t) DECLSPEC_HIDDEN;
00479 object_header_t *get_handle_object( HINTERNET hinternet ) DECLSPEC_HIDDEN;
00480 object_header_t *WININET_AddRef( object_header_t *info ) DECLSPEC_HIDDEN;
00481 BOOL WININET_Release( object_header_t *info ) DECLSPEC_HIDDEN;
00482 
00483 DWORD INET_QueryOption( object_header_t *, DWORD, void *, DWORD *, BOOL ) DECLSPEC_HIDDEN;
00484 
00485 time_t ConvertTimeString(LPCWSTR asctime) DECLSPEC_HIDDEN;
00486 
00487 HINTERNET FTP_Connect(appinfo_t *hIC, LPCWSTR lpszServerName,
00488     INTERNET_PORT nServerPort, LPCWSTR lpszUserName,
00489     LPCWSTR lpszPassword, DWORD dwFlags, DWORD_PTR dwContext,
00490     DWORD dwInternalFlags) DECLSPEC_HIDDEN;
00491 
00492 DWORD HTTP_Connect(appinfo_t*,LPCWSTR,
00493         INTERNET_PORT nServerPort, LPCWSTR lpszUserName,
00494         LPCWSTR lpszPassword, DWORD dwFlags, DWORD_PTR dwContext,
00495         DWORD dwInternalFlags, HINTERNET*) DECLSPEC_HIDDEN;
00496 
00497 BOOL GetAddress(LPCWSTR lpszServerName, INTERNET_PORT nServerPort,
00498     struct sockaddr *psa, socklen_t *sa_len) DECLSPEC_HIDDEN;
00499 
00500 BOOL get_cookie(const WCHAR*,const WCHAR*,WCHAR*,DWORD*) DECLSPEC_HIDDEN;
00501 BOOL set_cookie(const WCHAR*,const WCHAR*,const WCHAR*,const WCHAR*) DECLSPEC_HIDDEN;
00502 
00503 void INTERNET_SetLastError(DWORD dwError) DECLSPEC_HIDDEN;
00504 DWORD INTERNET_GetLastError(void) DECLSPEC_HIDDEN;
00505 DWORD INTERNET_AsyncCall(LPWORKREQUEST lpWorkRequest) DECLSPEC_HIDDEN;
00506 LPSTR INTERNET_GetResponseBuffer(void) DECLSPEC_HIDDEN;
00507 LPSTR INTERNET_GetNextLine(INT nSocket, LPDWORD dwLen) DECLSPEC_HIDDEN;
00508 
00509 VOID SendAsyncCallback(object_header_t *hdr, DWORD_PTR dwContext,
00510                        DWORD dwInternetStatus, LPVOID lpvStatusInfo,
00511                        DWORD dwStatusInfoLength) DECLSPEC_HIDDEN;
00512 
00513 VOID INTERNET_SendCallback(object_header_t *hdr, DWORD_PTR dwContext,
00514                            DWORD dwInternetStatus, LPVOID lpvStatusInfo,
00515                            DWORD dwStatusInfoLength) DECLSPEC_HIDDEN;
00516 BOOL INTERNET_FindProxyForProtocol(LPCWSTR szProxy, LPCWSTR proto, WCHAR *foundProxy, DWORD *foundProxyLen) DECLSPEC_HIDDEN;
00517 
00518 DWORD create_netconn(BOOL,server_t*,DWORD,netconn_t**) DECLSPEC_HIDDEN;
00519 void free_netconn(netconn_t*) DECLSPEC_HIDDEN;
00520 void NETCON_unload(void) DECLSPEC_HIDDEN;
00521 DWORD NETCON_secure_connect(netconn_t *connection, LPWSTR hostname) DECLSPEC_HIDDEN;
00522 DWORD NETCON_send(netconn_t *connection, const void *msg, size_t len, int flags,
00523         int *sent /* out */) DECLSPEC_HIDDEN;
00524 DWORD NETCON_recv(netconn_t *connection, void *buf, size_t len, int flags,
00525         int *recvd /* out */) DECLSPEC_HIDDEN;
00526 BOOL NETCON_query_data_available(netconn_t *connection, DWORD *available) DECLSPEC_HIDDEN;
00527 BOOL NETCON_is_alive(netconn_t*) DECLSPEC_HIDDEN;
00528 LPCVOID NETCON_GetCert(netconn_t *connection) DECLSPEC_HIDDEN;
00529 int NETCON_GetCipherStrength(netconn_t*) DECLSPEC_HIDDEN;
00530 DWORD NETCON_set_timeout(netconn_t *connection, BOOL send, int value) DECLSPEC_HIDDEN;
00531 #define sock_get_error(x) WSAGetLastError()
00532 
00533 extern void URLCacheContainers_CreateDefaults(void) DECLSPEC_HIDDEN;
00534 extern void URLCacheContainers_DeleteAll(void) DECLSPEC_HIDDEN;
00535 
00536 #define MAX_REPLY_LEN       0x5B4
00537 
00538 /* Used for debugging - maybe need to be shared in the Wine debugging code ? */
00539 typedef struct
00540 {
00541     DWORD val;
00542     const char* name;
00543 } wininet_flag_info;
00544 
00545 #endif /* _WINE_INTERNET_H_ */

Generated on Sat May 26 2012 04:25:26 for ReactOS by doxygen 1.7.6.1

ReactOS is a registered trademark or a trademark of ReactOS Foundation in the United States and other countries.