ReactOS 0.4.17-dev-1190-g4c812f4
internet.h File Reference
#include "wine/list.h"
#include <time.h>
#include "winineti.h"
Include dependency graph for internet.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  server_t
 
struct  netconn_t
 
struct  substr_t
 
struct  req_file_t
 
struct  object_vtbl_t
 
struct  _object_header_t
 
struct  appinfo_t
 
struct  http_session_t
 
struct  HTTPHEADERW
 
struct  data_stream_t
 
struct  netconn_stream_t
 
struct  http_request_t
 
struct  task_header_t
 
struct  wininet_flag_info
 

Macros

#define INET_OPENURL   0x0001
 
#define INET_CALLBACKW   0x0002
 
#define INTERNET_HANDLE_IN_USE   1
 
#define HDR_ISREQUEST   0x0001
 
#define HDR_COMMADELIMITED   0x0002
 
#define HDR_SEMIDELIMITED   0x0004
 
#define READ_BUFFER_SIZE   8192
 
#define MAX_REPLY_LEN   0x1000
 
#define _SECURITY_FLAG_CERT_REV_FAILED   0x00800000
 
#define _SECURITY_FLAG_CERT_INVALID_CA   0x01000000
 
#define _SECURITY_FLAG_CERT_INVALID_CN   0x02000000
 
#define _SECURITY_FLAG_CERT_INVALID_DATE   0x04000000
 
#define _SECURITY_ERROR_FLAGS_MASK
 

Typedefs

typedef struct _object_header_t object_header_t
 
typedef struct HTTPHEADERW * LPHTTPHEADERW
 
typedef struct data_stream_vtbl_t data_stream_vtbl_t
 
typedef struct task_header_t task_header_t
 
typedef void(* async_task_proc_t) (task_header_t *)
 

Enumerations

enum  collect_type_t { COLLECT_TIMEOUT , COLLECT_CONNECTIONS , COLLECT_CLEANUP }
 
enum  WH_TYPE {
  WH_HINIT = INTERNET_HANDLE_TYPE_INTERNET , WH_HFTPSESSION = INTERNET_HANDLE_TYPE_CONNECT_FTP , WH_HGOPHERSESSION = INTERNET_HANDLE_TYPE_CONNECT_GOPHER , WH_HHTTPSESSION = INTERNET_HANDLE_TYPE_CONNECT_HTTP ,
  WH_HFILE = INTERNET_HANDLE_TYPE_FTP_FILE , WH_HFTPFINDNEXT = INTERNET_HANDLE_TYPE_FTP_FIND , WH_HHTTPREQ = INTERNET_HANDLE_TYPE_HTTP_REQUEST
}
 

Functions

void server_addref (server_t *)
 
void server_release (server_t *)
 
BOOL collect_connections (collect_type_t)
 
BOOL is_valid_netconn (netconn_t *)
 
void close_netconn (netconn_t *)
 
static WCHAR * strndupW (const WCHAR *str, UINT max_len)
 
static WCHAR * strndupAtoW (const char *str, int len_a, DWORD *len_w)
 
static WCHAR * strdupAtoW (const char *str)
 
static char * strdupWtoA (const WCHAR *str)
 
static substr_t substr (const WCHAR *str, size_t len)
 
static substr_t substrz (const WCHAR *str)
 
static void WININET_find_data_WtoA (LPWIN32_FIND_DATAW dataW, LPWIN32_FIND_DATAA dataA)
 
void * alloc_async_task (object_header_t *, async_task_proc_t, size_t)
 
void * alloc_object (object_header_t *, const object_vtbl_t *, size_t)
 
object_header_t * get_handle_object (HINTERNET hinternet)
 
object_header_t * WININET_AddRef (object_header_t *info)
 
BOOL WININET_Release (object_header_t *info)
 
DWORD INET_QueryOption (object_header_t *, DWORD, void *, DWORD *, BOOL)
 
DWORD INET_SetOption (object_header_t *, DWORD, void *, DWORD)
 
time_t ConvertTimeString (LPCWSTR asctime)
 
HINTERNET FTP_Connect (appinfo_t *hIC, LPCWSTR lpszServerName, INTERNET_PORT nServerPort, LPCWSTR lpszUserName, LPCWSTR lpszPassword, DWORD dwFlags, DWORD_PTR dwContext, DWORD dwInternalFlags)
 
DWORD HTTP_Connect (appinfo_t *, LPCWSTR, INTERNET_PORT nServerPort, LPCWSTR lpszUserName, LPCWSTR lpszPassword, DWORD dwFlags, DWORD_PTR dwContext, DWORD dwInternalFlags, HINTERNET *)
 
BOOL GetAddress (const WCHAR *, INTERNET_PORT, SOCKADDR *, int *, char *)
 
DWORD get_cookie_header (const WCHAR *, const WCHAR *, WCHAR **)
 
DWORD set_cookie (substr_t, substr_t, substr_t, substr_t, DWORD)
 
void INTERNET_SetLastError (DWORD dwError)
 
DWORD INTERNET_GetLastError (void)
 
DWORD INTERNET_AsyncCall (task_header_t *)
 
LPSTR INTERNET_GetResponseBuffer (void)
 
VOID INTERNET_SendCallback (object_header_t *hdr, DWORD_PTR dwContext, DWORD dwInternetStatus, LPVOID lpvStatusInfo, DWORD dwStatusInfoLength)
 
WCHAR * INTERNET_FindProxyForProtocol (LPCWSTR szProxy, LPCWSTR proto)
 
DWORD create_netconn (server_t *, DWORD, BOOL, DWORD, netconn_t **)
 
void free_netconn (netconn_t *)
 
void NETCON_unload (void)
 
DWORD NETCON_secure_connect (netconn_t *, server_t *)
 
DWORD NETCON_send (netconn_t *connection, const void *msg, size_t len, int flags, int *sent)
 
DWORD NETCON_recv (netconn_t *, void *, size_t, BOOL, int *)
 
BOOL NETCON_is_alive (netconn_t *)
 
LPCVOID NETCON_GetCert (netconn_t *connection)
 
int NETCON_GetCipherStrength (netconn_t *)
 
DWORD NETCON_set_timeout (netconn_t *connection, BOOL send, DWORD value)
 
int sock_send (int fd, const void *msg, size_t len, int flags)
 
int sock_recv (int fd, void *msg, size_t len, int flags)
 
server_t * get_server (substr_t, INTERNET_PORT, BOOL, BOOL)
 
DWORD create_req_file (const WCHAR *, req_file_t **)
 
void req_file_release (req_file_t *)
 
static req_file_t * req_file_addref (req_file_t *req_file)
 
BOOL init_urlcache (void)
 
void free_urlcache (void)
 
void free_cookie (void)
 
void free_authorization_cache (void)
 
void init_winsock (void)
 

Variables

HMODULE WININET_hModule
 

Macro Definition Documentation

◆ _SECURITY_ERROR_FLAGS_MASK

#define _SECURITY_ERROR_FLAGS_MASK
Value:
#define _SECURITY_FLAG_CERT_REV_FAILED
Definition: internet.h:440
#define _SECURITY_FLAG_CERT_INVALID_CN
Definition: internet.h:442
#define _SECURITY_FLAG_CERT_INVALID_DATE
Definition: internet.h:443
#define _SECURITY_FLAG_CERT_INVALID_CA
Definition: internet.h:441

Definition at line 445 of file internet.h.

◆ _SECURITY_FLAG_CERT_INVALID_CA

#define _SECURITY_FLAG_CERT_INVALID_CA   0x01000000

Definition at line 441 of file internet.h.

◆ _SECURITY_FLAG_CERT_INVALID_CN

#define _SECURITY_FLAG_CERT_INVALID_CN   0x02000000

Definition at line 442 of file internet.h.

◆ _SECURITY_FLAG_CERT_INVALID_DATE

#define _SECURITY_FLAG_CERT_INVALID_DATE   0x04000000

Definition at line 443 of file internet.h.

◆ _SECURITY_FLAG_CERT_REV_FAILED

#define _SECURITY_FLAG_CERT_REV_FAILED   0x00800000

Definition at line 440 of file internet.h.

◆ HDR_COMMADELIMITED

#define HDR_COMMADELIMITED   0x0002

Definition at line 283 of file internet.h.

◆ HDR_ISREQUEST

#define HDR_ISREQUEST   0x0001

Definition at line 282 of file internet.h.

◆ HDR_SEMIDELIMITED

#define HDR_SEMIDELIMITED   0x0004

Definition at line 284 of file internet.h.

◆ INET_CALLBACKW

#define INET_CALLBACKW   0x0002

Definition at line 210 of file internet.h.

◆ INET_OPENURL

#define INET_OPENURL   0x0001

Definition at line 209 of file internet.h.

◆ INTERNET_HANDLE_IN_USE

#define INTERNET_HANDLE_IN_USE   1

Definition at line 236 of file internet.h.

◆ MAX_REPLY_LEN

#define MAX_REPLY_LEN   0x1000

Definition at line 430 of file internet.h.

◆ READ_BUFFER_SIZE

#define READ_BUFFER_SIZE   8192

Definition at line 309 of file internet.h.

Typedef Documentation

◆ async_task_proc_t

typedef void(* async_task_proc_t) (task_header_t *)

Definition at line 353 of file internet.h.

◆ data_stream_vtbl_t

Definition at line 297 of file internet.h.

◆ LPHTTPHEADERW

◆ object_header_t

Definition at line 221 of file internet.h.

◆ task_header_t

Definition at line 352 of file internet.h.

Enumeration Type Documentation

◆ collect_type_t

Enumerator
COLLECT_TIMEOUT 
COLLECT_CONNECTIONS 
COLLECT_CLEANUP 

Definition at line 58 of file internet.h.

58 {
collect_type_t
Definition: internet.h:58
@ COLLECT_TIMEOUT
Definition: internet.h:59
@ COLLECT_CONNECTIONS
Definition: internet.h:60
@ COLLECT_CLEANUP
Definition: internet.h:61

◆ WH_TYPE

Enumerator
WH_HINIT 
WH_HFTPSESSION 
WH_HGOPHERSESSION 
WH_HHTTPSESSION 
WH_HFILE 
WH_HFTPFINDNEXT 
WH_HHTTPREQ 

Definition at line 198 of file internet.h.

199{
207} WH_TYPE;
WH_TYPE
Definition: internet.h:199
@ WH_HFILE
Definition: internet.h:204
@ WH_HHTTPSESSION
Definition: internet.h:203
@ WH_HGOPHERSESSION
Definition: internet.h:202
@ WH_HFTPFINDNEXT
Definition: internet.h:205
@ WH_HHTTPREQ
Definition: internet.h:206
@ WH_HFTPSESSION
Definition: internet.h:201
@ WH_HINIT
Definition: internet.h:200
#define INTERNET_HANDLE_TYPE_CONNECT_GOPHER
Definition: wininet.h:804
#define INTERNET_HANDLE_TYPE_HTTP_REQUEST
Definition: wininet.h:814
#define INTERNET_HANDLE_TYPE_FTP_FIND
Definition: wininet.h:806
#define INTERNET_HANDLE_TYPE_INTERNET
Definition: wininet.h:802
#define INTERNET_HANDLE_TYPE_CONNECT_HTTP
Definition: wininet.h:805
#define INTERNET_HANDLE_TYPE_CONNECT_FTP
Definition: wininet.h:803
#define INTERNET_HANDLE_TYPE_FTP_FILE
Definition: wininet.h:808

Function Documentation

◆ alloc_async_task()

void * alloc_async_task ( object_header_t *  hdr,
async_task_proc_t  proc,
size_t  size 
)

Definition at line 4513 of file internet.c.

4514{
4516
4517 task = malloc(size);
4518 if(!task)
4519 return NULL;
4520
4521 task->hdr = WININET_AddRef(hdr);
4522 task->proc = proc;
4523 return task;
4524}
#define malloc
Definition: debug_ros.c:4
DWORD task
Definition: delayimp.cpp:484
#define NULL
Definition: types.h:112
object_header_t * WININET_AddRef(object_header_t *info)
Definition: internet.c:202
GLsizeiptr size
Definition: glext.h:5919
char hdr[14]
Definition: iptest.cpp:33
static HANDLE proc()
Definition: pdb.c:32

Referenced by async_read(), FtpCreateDirectoryW(), FtpDeleteFileW(), FTPFILE_QueryDataAvailable(), FtpFindFirstFileW(), FTPFINDNEXT_FindNextFileW(), FtpGetCurrentDirectoryW(), FtpGetFileW(), FtpOpenFileW(), FtpPutFileW(), FtpRemoveDirectoryW(), FtpRenameFileW(), FtpSetCurrentDirectoryW(), HttpEndRequestW(), HttpSendRequestExW(), HttpSendRequestW(), and InternetOpenUrlW().

◆ alloc_object()

void * alloc_object ( object_header_t *  parent,
const object_vtbl_t *  vtbl,
size_t  size 
)

Definition at line 124 of file internet.c.

125{
126 UINT_PTR handle = 0, num;
129 BOOL res = TRUE;
130
131 ret = calloc(1, size);
132 if(!ret)
133 return NULL;
134
135 list_init(&ret->children);
136
138
139 if(!handle_table_size) {
140 num = 16;
141 p = calloc(num, sizeof(handle_table[0]));
142 if(p) {
143 handle_table = p;
145 next_handle = 1;
146 }else {
147 res = FALSE;
148 }
149 }else if(next_handle == handle_table_size) {
151 p = realloc(handle_table, sizeof(handle_table[0]) * num);
152 if(p) {
154 handle_table = p;
156 }else {
157 res = FALSE;
158 }
159 }
160
161 if(res) {
164 ERR("handle isn't free but should be\n");
166 ret->valid_handle = TRUE;
167
169 next_handle++;
170 }
171
173
174 if(!res) {
175 free(ret);
176 return NULL;
177 }
178
179 ret->vtbl = vtbl;
180 ret->refs = 1;
181 ret->hInternet = (HINTERNET)handle;
182
183 if(parent) {
184 ret->lpfnStatusCB = parent->lpfnStatusCB;
185 ret->dwInternalFlags = parent->dwInternalFlags & INET_CALLBACKW;
186 ret->connect_timeout = parent->connect_timeout;
187 ret->send_timeout = parent->send_timeout;
188 ret->receive_timeout = parent->receive_timeout;
189 ret->data_send_timeout = parent->data_send_timeout;
190 ret->data_receive_timeout = parent->data_receive_timeout;
191 } else {
192 ret->connect_timeout = connect_timeout;
193 ret->send_timeout = send_timeout;
194 ret->receive_timeout = receive_timeout;
195 ret->data_send_timeout = data_send_timeout;
196 ret->data_receive_timeout = data_receive_timeout;
197 }
198
199 return ret;
200}
static void list_init(struct list_entry *head)
Definition: list.h:51
#define ERR(fmt,...)
Definition: precomp.h:57
#define realloc
Definition: debug_ros.c:6
#define free
Definition: debug_ros.c:5
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
static ULONG send_timeout
Definition: internet.c:113
static UINT_PTR next_handle
Definition: internet.c:83
static CRITICAL_SECTION WININET_cs
Definition: internet.c:73
static ULONG data_send_timeout
Definition: internet.c:115
static ULONG data_receive_timeout
Definition: internet.c:116
static ULONG connect_timeout
Definition: internet.c:112
static ULONG receive_timeout
Definition: internet.c:114
static UINT_PTR handle_table_size
Definition: internet.c:84
return ret
Definition: mutex.c:147
r parent
Definition: btrfs.c:3010
unsigned int BOOL
Definition: ntddk_ex.h:94
GLuint res
Definition: glext.h:9613
GLfloat GLfloat p
Definition: glext.h:8902
GLuint GLuint num
Definition: glext.h:9618
#define INET_CALLBACKW
Definition: internet.h:210
unsigned __int3264 UINT_PTR
Definition: mstsclib_h.h:274
#define calloc
Definition: rosglue.h:14
#define memset(x, y, z)
Definition: compat.h:39
void WINAPI LeaveCriticalSection(LPCRITICAL_SECTION)
void WINAPI EnterCriticalSection(LPCRITICAL_SECTION)
LPVOID HINTERNET
Definition: winhttp.h:37

Referenced by FTP_Connect(), FTP_FtpOpenFileW(), FTP_ReceiveFileList(), HTTP_Connect(), HTTP_HttpOpenRequestW(), and InternetOpenW().

◆ close_netconn()

void close_netconn ( netconn_t *  netconn)

Definition at line 380 of file netconnection.c.

381{
383 netconn->socket = -1;
384}
#define closesocket
Definition: ncftp.h:477

Referenced by free_netconn(), and http_release_netconn().

◆ collect_connections()

BOOL collect_connections ( collect_type_t  collect_type)

Definition at line 229 of file http.c.

230{
231 netconn_t *netconn, *netconn_safe;
232 server_t *server, *server_safe;
233 BOOL remaining = FALSE;
234 DWORD64 now;
235
237
239 LIST_FOR_EACH_ENTRY_SAFE(netconn, netconn_safe, &server->conn_pool, netconn_t, pool_entry) {
240 if(collect_type > COLLECT_TIMEOUT || netconn->keep_until < now) {
241 TRACE("freeing %p\n", netconn);
242 list_remove(&netconn->pool_entry);
244 }else {
245 remaining = TRUE;
246 }
247 }
248
249 if(collect_type == COLLECT_CLEANUP) {
250 list_remove(&server->entry);
251 list_init(&server->entry);
253 }
254 }
255
256 return remaining;
257}
static void list_remove(struct list_entry *entry)
Definition: list.h:90
ULONGLONG WINAPI DECLSPEC_HOTPATCH GetTickCount64(void)
Definition: sync.c:192
static struct list connection_pool
Definition: http.c:140
void server_release(server_t *server)
Definition: http.c:148
time_t now
Definition: finger.c:65
void free_netconn(netconn_t *)
uint32_t entry
Definition: isohybrid.c:63
#define LIST_FOR_EACH_ENTRY_SAFE(cursor, cursor2, list, type, field)
Definition: list.h:242
#define TRACE(s)
Definition: solgame.cpp:4
ULONGLONG keep_until
uint64_t DWORD64
Definition: typedefs.h:67
static rfbScreenInfoPtr server
Definition: vnc.c:74

Referenced by collect_connections_proc(), DllMain(), and INET_SetOption().

◆ ConvertTimeString()

time_t ConvertTimeString ( LPCWSTR  asctime)

◆ create_netconn()

DWORD create_netconn ( server_t *  server,
DWORD  security_flags,
BOOL  mask_errors,
DWORD  timeout,
netconn_t **  ret 
)

Definition at line 348 of file netconnection.c.

349{
351 int result;
352
353 netconn = calloc(1, sizeof(*netconn));
354 if(!netconn)
355 return ERROR_OUTOFMEMORY;
356
357 netconn->socket = -1;
358 netconn->security_flags = security_flags | server->security_flags;
359 netconn->mask_errors = mask_errors;
360 list_init(&netconn->pool_entry);
362
364 if (result != ERROR_SUCCESS) {
365 free(netconn);
366 return result;
367 }
368
370 netconn->server = server;
371 *ret = netconn;
372 return result;
373}
#define ERROR_OUTOFMEMORY
Definition: deptool.c:13
#define ERROR_SUCCESS
Definition: deptool.c:10
void server_addref(server_t *server)
Definition: http.c:143
GLuint64EXT * result
Definition: glext.h:11304
static DWORD create_netconn_socket(server_t *server, netconn_t *netconn, DWORD timeout)
#define SecInvalidateHandle(x)
Definition: sspi.h:58
CtxtHandle ssl_ctx
Definition: dhcpd.h:248

Referenced by open_http_connection().

◆ create_req_file()

DWORD create_req_file ( const WCHAR *  file_name,
req_file_t **  ret 
)

Definition at line 4607 of file internet.c.

4608{
4609 req_file_t *req_file;
4610
4611 req_file = calloc(1, sizeof(*req_file));
4612 if(!req_file)
4614
4615 req_file->ref = 1;
4616
4617 req_file->file_name = wcsdup(file_name);
4618 if(!req_file->file_name) {
4619 free(req_file);
4621 }
4622
4625 if(req_file->file_handle == INVALID_HANDLE_VALUE) {
4626 req_file_release(req_file);
4627 return GetLastError();
4628 }
4629
4630 *ret = req_file;
4631 return ERROR_SUCCESS;
4632}
#define ERROR_NOT_ENOUGH_MEMORY
Definition: dderror.h:7
#define OPEN_EXISTING
Definition: compat.h:775
#define INVALID_HANDLE_VALUE
Definition: compat.h:731
#define GENERIC_READ
Definition: compat.h:135
#define CreateFileW
Definition: compat.h:741
#define FILE_ATTRIBUTE_NORMAL
Definition: compat.h:137
#define FILE_SHARE_READ
Definition: compat.h:136
static wchar_t * wcsdup(const wchar_t *str)
Definition: string.h:94
void req_file_release(req_file_t *req_file)
Definition: internet.c:4634
static LPCWSTR file_name
Definition: protocol.c:152
#define FILE_SHARE_WRITE
Definition: nt_native.h:681
LONG ref
Definition: internet.h:214
WCHAR * file_name
Definition: internet.h:216
HANDLE file_handle
Definition: internet.h:215
DWORD WINAPI GetLastError(void)
Definition: except.c:1042

Referenced by create_cache_entry().

◆ free_authorization_cache()

void free_authorization_cache ( void  )

Definition at line 926 of file http.c.

927{
928 authorizationData *ad, *sa_safe;
929 basicAuthorizationData *basic, *basic_safe;
930
932
934 {
935 free(basic->host);
936 free(basic->realm);
937 free(basic->authorization);
938
939 list_remove(&basic->entry);
940 free(basic);
941 }
942
944 {
945 free(ad->host);
946 free(ad->scheme);
947 free(ad->user);
948 free(ad->password);
949 free(ad->domain);
950 list_remove(&ad->entry);
951 free(ad);
952 }
953
955}
static struct list authorizationCache
Definition: http.c:109
static struct list basicAuthorizationCache
Definition: http.c:108
static CRITICAL_SECTION authcache_cs
Definition: http.c:111
struct list entry
Definition: http.c:96
LPWSTR password
Definition: http.c:104
LPWSTR domain
Definition: http.c:100
LPWSTR host
Definition: http.c:98
LPWSTR scheme
Definition: http.c:99
LPWSTR user
Definition: http.c:102
struct list entry
Definition: http.c:86

Referenced by InternetSetOptionW().

◆ free_cookie()

void free_cookie ( void  )

Definition at line 1269 of file cookie.c.

1270{
1272
1274
1276}
static struct list domain_list
Definition: cookie.c:100
static CRITICAL_SECTION cookie_cs
Definition: cookie.c:92
static void free_cookie_domain_list(struct list *list)
Definition: cookie.c:689

Referenced by delete_cookie(), DllMain(), InternetSetOptionW(), parse_cookie(), and set_cookies().

◆ free_netconn()

void free_netconn ( netconn_t *  netconn)

Definition at line 386 of file netconnection.c.

387{
388 server_release(netconn->server);
389
390 if (netconn->secure) {
394 netconn->peek_len = 0;
395 free(netconn->ssl_buf);
396 netconn->ssl_buf = NULL;
399 netconn->extra_len = 0;
400 }
403
405 free(netconn);
406}
void close_netconn(netconn_t *netconn)
#define SecIsValidHandle(x)
Definition: sspi.h:63
char * peek_msg
char * extra_buf
char * peek_msg_mem
size_t extra_len
size_t peek_len
SECURITY_STATUS WINAPI DeleteSecurityContext(PCtxtHandle phContext)
Definition: wrapper.c:450

Referenced by collect_connections(), and open_http_connection().

◆ free_urlcache()

void free_urlcache ( void  )

Definition at line 4124 of file urlcache.c.

4125{
4131
4133}
#define CloseHandle
Definition: compat.h:739
static void cache_containers_free(void)
Definition: urlcache.c:820
static HANDLE free_cache_running
Definition: urlcache.c:2234
static HANDLE dll_unload_event
Definition: urlcache.c:2235
#define INFINITE
Definition: serial.h:102
DWORD WINAPI WaitForSingleObject(IN HANDLE hHandle, IN DWORD dwMilliseconds)
Definition: synch.c:82
BOOL WINAPI DECLSPEC_HOTPATCH SetEvent(IN HANDLE hEvent)
Definition: synch.c:669
BOOL WINAPI DECLSPEC_HOTPATCH ReleaseSemaphore(IN HANDLE hSemaphore, IN LONG lReleaseCount, IN LPLONG lpPreviousCount)
Definition: synch.c:491

Referenced by DllMain().

◆ FTP_Connect()

HINTERNET FTP_Connect ( appinfo_t *  hIC,
LPCWSTR  lpszServerName,
INTERNET_PORT  nServerPort,
LPCWSTR  lpszUserName,
LPCWSTR  lpszPassword,
DWORD  dwFlags,
DWORD_PTR  dwContext,
DWORD  dwInternalFlags 
)

Definition at line 2430 of file ftp.c.

2434{
2435 struct sockaddr_in socketAddr;
2436 INT nsocket = -1;
2437 socklen_t sock_namelen;
2438 BOOL bSuccess = FALSE;
2439 ftp_session_t *lpwfs = NULL;
2440 char szaddr[INET6_ADDRSTRLEN];
2441
2442 TRACE("%p Server(%s) Port(%d) User(%s) Paswd(%s)\n",
2443 hIC, debugstr_w(lpszServerName),
2444 nServerPort, debugstr_w(lpszUserName), debugstr_w(lpszPassword));
2445
2446 assert( hIC->hdr.htype == WH_HINIT );
2447
2448 if ((!lpszUserName || !*lpszUserName) && lpszPassword && *lpszPassword)
2449 {
2451 return NULL;
2452 }
2453
2454 lpwfs = alloc_object(&hIC->hdr, &FTPSESSIONVtbl, sizeof(ftp_session_t));
2455 if (NULL == lpwfs)
2456 {
2458 return NULL;
2459 }
2460
2461 if (nServerPort == INTERNET_INVALID_PORT_NUMBER)
2463 else
2464 lpwfs->serverport = nServerPort;
2465
2466 lpwfs->hdr.htype = WH_HFTPSESSION;
2467 lpwfs->hdr.dwFlags = dwFlags;
2468 lpwfs->hdr.dwContext = dwContext;
2469 lpwfs->hdr.dwInternalFlags |= dwInternalFlags;
2470 lpwfs->download_in_progress = NULL;
2471 lpwfs->sndSocket = -1;
2472 lpwfs->lstnSocket = -1;
2473 lpwfs->pasvSocket = -1;
2474
2475 WININET_AddRef( &hIC->hdr );
2476 lpwfs->lpAppInfo = hIC;
2477 list_add_head( &hIC->hdr.children, &lpwfs->hdr.entry );
2478
2479 if(hIC->proxy && hIC->accessType == INTERNET_OPEN_TYPE_PROXY) {
2480 if(wcschr(hIC->proxy, ' '))
2481 FIXME("Several proxies not implemented.\n");
2482 if(hIC->proxyBypass)
2483 FIXME("Proxy bypass is ignored.\n");
2484 }
2485 if (!lpszUserName || !lpszUserName[0]) {
2486 HKEY key;
2487 WCHAR szPassword[MAX_PATH];
2488 DWORD len = sizeof(szPassword);
2489
2490 lpwfs->lpszUserName = wcsdup(L"anonymous");
2491
2492 RegOpenKeyW(HKEY_CURRENT_USER, L"Software\\Microsoft\\Windows\\CurrentVersion\\Internet Settings", &key);
2493 if (RegQueryValueExW(key, L"EmailName", NULL, NULL, (LPBYTE)szPassword, &len)) {
2494 /* Nothing in the registry, get the username and use that as the password */
2495 if (!GetUserNameW(szPassword, &len)) {
2496 /* Should never get here, but use an empty password as failsafe */
2497 lstrcpyW(szPassword, L"");
2498 }
2499 }
2501
2502 TRACE("Password used for anonymous ftp : (%s)\n", debugstr_w(szPassword));
2503 lpwfs->lpszPassword = wcsdup(szPassword);
2504 }
2505 else {
2506 lpwfs->lpszUserName = wcsdup(lpszUserName);
2508 }
2509 lpwfs->servername = wcsdup(lpszServerName);
2510
2511 /* Don't send a handle created callback if this handle was created with InternetOpenUrl */
2512 if (!(lpwfs->hdr.dwInternalFlags & INET_OPENURL))
2513 {
2515
2516 iar.dwResult = (DWORD_PTR)lpwfs->hdr.hInternet;
2517 iar.dwError = ERROR_SUCCESS;
2518
2519 INTERNET_SendCallback(&hIC->hdr, dwContext,
2521 sizeof(INTERNET_ASYNC_RESULT));
2522 }
2523
2525 (LPWSTR) lpszServerName, (lstrlenW(lpszServerName)+1) * sizeof(WCHAR));
2526
2527 sock_namelen = sizeof(socketAddr);
2528 if (!GetAddress(lpszServerName, lpwfs->serverport, (struct sockaddr *)&socketAddr, &sock_namelen, szaddr))
2529 {
2531 goto lerror;
2532 }
2533
2534 if (socketAddr.sin_family != AF_INET)
2535 {
2536 WARN("unsupported address family %d\n", socketAddr.sin_family);
2538 goto lerror;
2539 }
2540
2542 szaddr, strlen(szaddr)+1);
2543
2544 init_winsock();
2545 nsocket = socket(AF_INET,SOCK_STREAM,0);
2546 if (nsocket == -1)
2547 {
2549 goto lerror;
2550 }
2551
2553 szaddr, strlen(szaddr)+1);
2554
2555 if (connect(nsocket, (struct sockaddr *)&socketAddr, sock_namelen) < 0)
2556 {
2557 ERR("Unable to connect (%d)\n", WSAGetLastError());
2559 closesocket(nsocket);
2560 }
2561 else
2562 {
2563 TRACE("Connected to server\n");
2564 lpwfs->sndSocket = nsocket;
2566 szaddr, strlen(szaddr)+1);
2567
2568 sock_namelen = sizeof(lpwfs->socketAddress);
2569 getsockname(nsocket, (struct sockaddr *) &lpwfs->socketAddress, &sock_namelen);
2570
2571 if (FTP_ConnectToHost(lpwfs))
2572 {
2573 TRACE("Successfully logged into server\n");
2574 bSuccess = TRUE;
2575 }
2576 }
2577
2578lerror:
2579 if (!bSuccess)
2580 {
2581 WININET_Release(&lpwfs->hdr);
2582 return NULL;
2583 }
2584
2585 return lpwfs->hdr.hInternet;
2586}
static void list_add_head(struct list_entry *head, struct list_entry *entry)
Definition: list.h:76
#define FIXME(fmt,...)
Definition: precomp.h:53
#define WARN(fmt,...)
Definition: precomp.h:61
#define RegCloseKey(hKey)
Definition: registry.h:49
LONG WINAPI RegOpenKeyW(HKEY hKey, LPCWSTR lpSubKey, PHKEY phkResult)
Definition: reg.c:3268
LONG WINAPI RegQueryValueExW(_In_ HKEY hkeyorg, _In_ LPCWSTR name, _In_ LPDWORD reserved, _In_ LPDWORD type, _In_ LPBYTE data, _In_ LPDWORD count)
Definition: reg.c:4103
BOOL WINAPI GetUserNameW(LPWSTR lpszName, LPDWORD lpSize)
Definition: misc.c:291
#define wcschr
Definition: compat.h:17
#define ERROR_INVALID_PARAMETER
Definition: compat.h:101
#define MAX_PATH
Definition: compat.h:34
#define lstrcpyW
Definition: compat.h:749
#define lstrlenW
Definition: compat.h:750
#define assert(_expr)
Definition: assert.h:32
_ACRTIMP size_t __cdecl strlen(const char *)
Definition: string.c:1597
static const object_vtbl_t FTPSESSIONVtbl
Definition: ftp.c:2397
static BOOL FTP_ConnectToHost(ftp_session_t *)
Definition: ftp.c:2599
BOOL WININET_Release(object_header_t *info)
Definition: internet.c:244
void INTERNET_SetLastError(DWORD dwError)
Definition: internet.c:4456
void * alloc_object(object_header_t *parent, const object_vtbl_t *vtbl, size_t size)
Definition: internet.c:124
void init_winsock(void)
Definition: dpnet_main.c:55
#define L(x)
Definition: resources.c:13
#define SOCK_STREAM
Definition: tcpip.h:118
#define AF_INET
Definition: tcpip.h:117
unsigned long DWORD
Definition: ntddk_ex.h:95
GLenum GLsizei len
Definition: glext.h:6722
VOID INTERNET_SendCallback(object_header_t *hdr, DWORD_PTR dwContext, DWORD dwInternetStatus, LPVOID lpvStatusInfo, DWORD dwStatusInfoLength)
#define INET_OPENURL
Definition: internet.h:209
BOOL GetAddress(const WCHAR *, INTERNET_PORT, SOCKADDR *, int *, char *)
Definition: utility.c:47
#define debugstr_w
Definition: kernel32.h:32
int socklen_t
Definition: tcp.c:35
_In_ LPWSTR _In_ DWORD _In_ DWORD _In_ DWORD dwFlags
Definition: netsh.h:141
short WCHAR
Definition: pedump.c:58
INT WSAAPI getsockname(IN SOCKET s, OUT LPSOCKADDR name, IN OUT INT FAR *namelen)
Definition: sockctrl.c:213
DWORD_PTR dwResult
Definition: wininet.h:155
object_header_t hdr
Definition: ftp.c:75
ftp_file_t * download_in_progress
Definition: ftp.c:80
int lstnSocket
Definition: ftp.c:78
LPWSTR servername
Definition: ftp.c:83
INTERNET_PORT serverport
Definition: ftp.c:84
int pasvSocket
Definition: ftp.c:79
appinfo_t * lpAppInfo
Definition: ftp.c:76
int sndSocket
Definition: ftp.c:77
LPWSTR lpszPassword
Definition: ftp.c:85
struct sockaddr_in socketAddress
Definition: ftp.c:81
LPWSTR lpszUserName
Definition: ftp.c:86
WH_TYPE htype
Definition: internet.h:240
HINTERNET hInternet
Definition: internet.h:242
DWORD dwInternalFlags
Definition: internet.h:253
struct list children
Definition: internet.h:258
struct list entry
Definition: internet.h:257
DWORD_PTR dwContext
Definition: internet.h:250
LPWSTR proxy
Definition: internet.h:265
LPWSTR proxyBypass
Definition: internet.h:266
DWORD accessType
Definition: internet.h:269
object_header_t hdr
Definition: internet.h:263
Definition: copy.c:22
#define DWORD_PTR
Definition: treelist.c:76
unsigned char * LPBYTE
Definition: typedefs.h:53
uint16_t * LPWSTR
Definition: typedefs.h:56
int32_t INT
Definition: typedefs.h:58
_In_opt_ LPSTR _In_opt_ LPSTR lpszPassword
Definition: winbase.h:2442
#define INTERNET_DEFAULT_FTP_PORT
Definition: wininet.h:38
#define INTERNET_STATUS_RESOLVING_NAME
Definition: wininet.h:883
#define INTERNET_STATUS_CONNECTING_TO_SERVER
Definition: wininet.h:885
#define INTERNET_OPEN_TYPE_PROXY
Definition: wininet.h:523
#define INTERNET_INVALID_PORT_NUMBER
Definition: wininet.h:36
#define INTERNET_STATUS_HANDLE_CREATED
Definition: wininet.h:895
#define ERROR_INTERNET_CANNOT_CONNECT
Definition: wininet.h:2018
#define ERROR_INTERNET_NAME_NOT_RESOLVED
Definition: wininet.h:1996
#define INTERNET_STATUS_CONNECTED_TO_SERVER
Definition: wininet.h:886
#define INTERNET_STATUS_NAME_RESOLVED
Definition: wininet.h:884
#define HKEY_CURRENT_USER
Definition: winreg.h:11
int PASCAL FAR WSAGetLastError(void)
Definition: dllmain.c:131
#define INET6_ADDRSTRLEN
Definition: ws2ipdef.h:132

Referenced by INTERNET_InternetOpenUrlW(), and InternetConnectW().

◆ get_cookie_header()

DWORD get_cookie_header ( const WCHAR *  host,
const WCHAR *  path,
WCHAR **  ret 
)

Definition at line 646 of file cookie.c.

647{
648 cookie_set_t cookie_set = {0};
649 DWORD res;
650
651 static const WCHAR cookieW[] = {'C','o','o','k','i','e',':',' '};
652
654
656 if(res != ERROR_SUCCESS) {
658 return res;
659 }
660
661 if(cookie_set.cnt) {
662 WCHAR *header, *ptr;
663
664 ptr = header = malloc(sizeof(cookieW) + (cookie_set.string_len + 3 /* crlf0 */) * sizeof(WCHAR));
665 if(header) {
666 memcpy(ptr, cookieW, sizeof(cookieW));
667 ptr += ARRAY_SIZE(cookieW);
668
669 cookie_set_to_string(&cookie_set, ptr);
670 free(cookie_set.cookies);
671 ptr += cookie_set.string_len;
672
673 *ptr++ = '\r';
674 *ptr++ = '\n';
675 *ptr++ = 0;
676
677 *ret = header;
678 }else {
680 }
681 }else {
682 *ret = NULL;
683 }
684
686 return res;
687}
#define ARRAY_SIZE(A)
Definition: main.h:20
static substr_t substrz(const WCHAR *str)
Definition: internet.h:175
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
static PVOID ptr
Definition: dispmode.c:27
cookie_t ** cookies
Definition: cookie.c:528
unsigned cnt
Definition: cookie.c:529
unsigned string_len
Definition: cookie.c:532
Definition: txthost.c:37
static void cookie_set_to_string(const cookie_set_t *cookie_set, WCHAR *str)
Definition: cookie.c:619
static DWORD get_cookie(substr_t host, substr_t path, DWORD flags, cookie_set_t *res)
Definition: cookie.c:535
#define INTERNET_COOKIE_HTTPONLY
Definition: wininet.h:1828

Referenced by HTTP_InsertCookies().

◆ get_handle_object()

◆ get_server()

server_t * get_server ( substr_t  name,
INTERNET_PORT  port,
BOOL  is_https,
BOOL  do_create 
)

Definition at line 192 of file http.c.

193{
194 server_t *iter, *server = NULL;
195
197
199 if(iter->port == port && name.len == lstrlenW(iter->name) && !wcsnicmp(iter->name, name.str, name.len)
200 && iter->is_https == is_https) {
201 server = iter;
203 break;
204 }
205 }
206
207 if(!server && do_create) {
208 server = calloc(1, sizeof(*server));
209 if(server) {
210 server->ref = 2; /* list reference and return */
211 server->port = port;
212 server->is_https = is_https;
213 list_init(&server->conn_pool);
214 server->name = strndupW(name.str, name.len);
215 if(server->name && process_host_port(server)) {
217 }else {
218 free(server);
219 server = NULL;
220 }
221 }
222 }
223
225
226 return server;
227}
#define wcsnicmp
Definition: compat.h:14
USHORT port
Definition: uri.c:210
static BOOL process_host_port(server_t *server)
Definition: http.c:168
static CRITICAL_SECTION connection_pool_cs
Definition: http.c:131
#define LIST_FOR_EACH_ENTRY(elem, list, type, field)
Definition: list.h:236
Definition: name.c:39
WCHAR * name
Definition: internet.h:35
BOOL is_https
Definition: internet.h:37
INTERNET_PORT port
Definition: internet.h:36
static WCHAR * strndupW(LPCWSTR str, int len)
Definition: urlmon_main.h:236

Referenced by HTTP_DealWithProxy(), HTTP_HandleRedirect(), and HTTP_HttpOpenRequestW().

◆ GetAddress()

BOOL GetAddress ( const WCHAR *  name,
INTERNET_PORT  port,
SOCKADDR *  psa,
int *  sa_len,
char *  addr_str 
)

Definition at line 47 of file utility.c.

48{
50 void *addr = NULL;
51 int ret;
52
53 TRACE("%s\n", debugstr_w(name));
54
55 memset( &hints, 0, sizeof(hints) );
56 /* Prefer IPv4 to IPv6 addresses, since some servers do not listen on
57 * their IPv6 addresses even though they have IPv6 addresses in the DNS.
58 */
59 hints.ai_family = AF_INET;
60
62 if (ret != 0)
63 {
64 TRACE("failed to get IPv4 address of %s, retrying with IPv6\n", debugstr_w(name));
65 hints.ai_family = AF_INET6;
67 }
68 if (ret != 0)
69 {
70 TRACE("failed to get address of %s\n", debugstr_w(name));
71 return FALSE;
72 }
73 if (*sa_len < res->ai_addrlen)
74 {
75 WARN("address too small\n");
77 return FALSE;
78 }
79 *sa_len = res->ai_addrlen;
80 memcpy( psa, res->ai_addr, res->ai_addrlen );
81 /* Copy port */
82 switch (res->ai_family)
83 {
84 case AF_INET:
85 addr = &((struct sockaddr_in *)psa)->sin_addr;
86 ((struct sockaddr_in *)psa)->sin_port = htons(port);
87 break;
88 case AF_INET6:
89 addr = &((struct sockaddr_in6 *)psa)->sin6_addr;
90 ((struct sockaddr_in6 *)psa)->sin6_port = htons(port);
91 break;
92 }
93
94 if(addr_str)
95 inet_ntop(res->ai_family, addr, addr_str, INET6_ADDRSTRLEN);
97 return TRUE;
98}
#define FreeAddrInfoW(a)
Definition: addrinfo.c:21
INT WSAAPI GetAddrInfoW(IN PCWSTR pszNodeName, IN PCWSTR pszServiceName, IN const ADDRINFOW *ptHints, OUT PADDRINFOW *pptResult)
Definition: addrinfo.c:509
GLenum const GLvoid * addr
Definition: glext.h:9621
#define htons(x)
Definition: module.h:215
namespace GUID const ADDRINFOEXW * hints
Definition: sock.c:80
const char *WSAAPI inet_ntop(int af, const void *src, char *dst, size_t cnt)
Definition: unix_func.c:8
#define AF_INET6
Definition: winsock.h:363

Referenced by DECLARE_INTERFACE_(), FTP_Connect(), HTTP_ResolveName(), and InternetCheckConnectionW().

◆ HTTP_Connect()

DWORD HTTP_Connect ( appinfo_t *  hIC,
LPCWSTR  lpszServerName,
INTERNET_PORT  nServerPort,
LPCWSTR  lpszUserName,
LPCWSTR  lpszPassword,
DWORD  dwFlags,
DWORD_PTR  dwContext,
DWORD  dwInternalFlags,
HINTERNET *  ret 
)

Definition at line 5910 of file http.c.

5914{
5916
5917 TRACE("-->\n");
5918
5919 if (!lpszServerName || !lpszServerName[0])
5921
5922 assert( hIC->hdr.htype == WH_HINIT );
5923
5925 if (!session)
5926 return ERROR_OUTOFMEMORY;
5927
5928 /*
5929 * According to my tests. The name is not resolved until a request is sent
5930 */
5931
5932 session->hdr.htype = WH_HHTTPSESSION;
5933 session->hdr.dwFlags = dwFlags;
5934 session->hdr.dwContext = dwContext;
5935 session->hdr.dwInternalFlags |= dwInternalFlags;
5936 session->hdr.decoding = hIC->hdr.decoding;
5937
5938 WININET_AddRef( &hIC->hdr );
5939 session->appInfo = hIC;
5940 list_add_head( &hIC->hdr.children, &session->hdr.entry );
5941
5942 session->hostName = wcsdup(lpszServerName);
5943 if (lpszUserName && lpszUserName[0])
5944 session->userName = wcsdup(lpszUserName);
5945 session->password = wcsdup(lpszPassword);
5946 session->hostPort = serverPort;
5947 session->hdr.connect_timeout = hIC->hdr.connect_timeout;
5948 session->hdr.send_timeout = hIC->hdr.send_timeout;
5949 session->hdr.receive_timeout = hIC->hdr.receive_timeout;
5950
5951 /* Don't send a handle created callback if this handle was created with InternetOpenUrl */
5952 if (!(session->hdr.dwInternalFlags & INET_OPENURL))
5953 {
5954 INTERNET_SendCallback(&hIC->hdr, dwContext,
5956 sizeof(HINTERNET));
5957 }
5958
5959/*
5960 * an INTERNET_STATUS_REQUEST_COMPLETE is NOT sent here as per my tests on
5961 * windows
5962 */
5963
5964 TRACE("%p --> %p\n", hIC, session);
5965
5966 *ret = session->hdr.hInternet;
5967 return ERROR_SUCCESS;
5968}
static const object_vtbl_t HTTPSESSIONVtbl
Definition: http.c:5887
ULONG connect_timeout
Definition: internet.h:243
ULONG receive_timeout
Definition: internet.h:245
ULONG send_timeout
Definition: internet.h:244
struct object_header hdr

Referenced by INTERNET_InternetOpenUrlW(), and InternetConnectW().

◆ INET_QueryOption()

DWORD INET_QueryOption ( object_header_t *  hdr,
DWORD  option,
void *  buffer,
DWORD *  size,
BOOL  unicode 
)

Definition at line 3159 of file internet.c.

3160{
3161 switch(option) {
3163 if (!size)
3165
3166 if (*size < sizeof(DWORD_PTR)) {
3167 *size = sizeof(DWORD_PTR);
3169 }
3170 if (!buffer)
3172
3173 *(DWORD_PTR *)buffer = hdr->dwContext;
3174 *size = sizeof(DWORD_PTR);
3175 return ERROR_SUCCESS;
3176
3178 WARN("INTERNET_OPTION_REQUEST_FLAGS\n");
3179 *size = sizeof(DWORD);
3181
3184 WARN("Called on global option %lu\n", option);
3186
3188 TRACE("INTERNET_OPTION_CONNECT_TIMEOUT\n");
3189
3190 if (*size < sizeof(ULONG))
3192
3193 *(ULONG*)buffer = hdr->connect_timeout;
3194 *size = sizeof(ULONG);
3195
3196 return ERROR_SUCCESS;
3197
3199 TRACE("INTERNET_OPTION_SEND_TIMEOUT\n");
3200
3201 if (*size < sizeof(ULONG))
3203
3204 *size = sizeof(ULONG);
3205 *(ULONG *)buffer = hdr->send_timeout;
3206 return ERROR_SUCCESS;
3207
3209 TRACE("INTERNET_OPTION_RECEIVE_TIMEOUT\n");
3210
3211 if (*size < sizeof(ULONG))
3213
3214 *size = sizeof(ULONG);
3215 *(ULONG *)buffer = hdr->receive_timeout;
3216 return ERROR_SUCCESS;
3217
3219 TRACE("INTERNET_OPTION_DATA_SEND_TIMEOUT\n");
3220
3221 if (*size < sizeof(ULONG))
3223
3224 *size = sizeof(ULONG);
3225 *(ULONG *)buffer = hdr->data_send_timeout;
3226 return ERROR_SUCCESS;
3227
3229 TRACE("INTERNET_OPTION_DATA_RECEIVE_TIMEOUT\n");
3230
3231 if (*size < sizeof(ULONG))
3233
3234 *size = sizeof(ULONG);
3235 *(ULONG *)buffer = hdr->data_receive_timeout;
3236 return ERROR_SUCCESS;
3237 }
3238
3239 /* FIXME: we shouldn't call it here */
3240 return query_global_option(option, buffer, size, unicode);
3241}
#define ERROR_INSUFFICIENT_BUFFER
Definition: dderror.h:10
static DWORD query_global_option(DWORD option, void *buffer, DWORD *size, BOOL unicode)
Definition: internet.c:2925
GLuint buffer
Definition: glext.h:5915
#define DWORD
Definition: nt_native.h:44
Definition: getopt.h:109
uint32_t DWORD_PTR
Definition: typedefs.h:65
uint32_t ULONG
Definition: typedefs.h:59
#define INTERNET_OPTION_DATA_SEND_TIMEOUT
Definition: wininet.h:708
#define INTERNET_OPTION_CONNECT_TIMEOUT
Definition: wininet.h:701
#define INTERNET_OPTION_DATA_RECEIVE_TIMEOUT
Definition: wininet.h:709
#define INTERNET_OPTION_MAX_CONNS_PER_SERVER
Definition: wininet.h:763
#define ERROR_INTERNET_INVALID_OPERATION
Definition: wininet.h:2005
#define INTERNET_OPTION_SEND_TIMEOUT
Definition: wininet.h:704
#define INTERNET_OPTION_RECEIVE_TIMEOUT
Definition: wininet.h:706
#define INTERNET_OPTION_CONTEXT_VALUE
Definition: wininet.h:739
#define ERROR_INTERNET_INCORRECT_HANDLE_TYPE
Definition: wininet.h:2007
#define INTERNET_OPTION_MAX_CONNS_PER_1_0_SERVER
Definition: wininet.h:764
#define INTERNET_OPTION_REQUEST_FLAGS
Definition: wininet.h:718

Referenced by APPINFO_QueryOption(), FTPFILE_QueryOption(), FTPFINDNEXT_QueryOption(), FTPSESSION_QueryOption(), and HTTPSESSION_QueryOption().

◆ INET_SetOption()

DWORD INET_SetOption ( object_header_t *  hdr,
DWORD  option,
void *  buf,
DWORD  size 
)

Definition at line 3309 of file internet.c.

3310{
3311 switch(option) {
3313 FIXME("INTERNETOPTION_SETTINGS_CHANGED semi-stub\n");
3315 return ERROR_SUCCESS;
3317 WARN("Not settable option %lu\n", option);
3321 WARN("Called on global option %lu\n", option);
3326 if (!buf || size != sizeof(ULONG)) return ERROR_INVALID_PARAMETER;
3327 hdr->connect_timeout = *(ULONG *)buf;
3328 return ERROR_SUCCESS;
3330 if (!buf || size != sizeof(ULONG)) return ERROR_INVALID_PARAMETER;
3331 hdr->send_timeout = *(ULONG *)buf;
3332 return ERROR_SUCCESS;
3334 if (!buf || size != sizeof(ULONG)) return ERROR_INVALID_PARAMETER;
3335 hdr->receive_timeout = *(ULONG *)buf;
3336 return ERROR_SUCCESS;
3338 if (!buf || size != sizeof(ULONG)) return ERROR_INVALID_PARAMETER;
3339 hdr->data_send_timeout = *(ULONG *)buf;
3340 return ERROR_SUCCESS;
3342 if (!buf || size != sizeof(ULONG)) return ERROR_INVALID_PARAMETER;
3343 hdr->data_receive_timeout = *(ULONG *)buf;
3344 return ERROR_SUCCESS;
3345 }
3346
3348}
BOOL collect_connections(collect_type_t collect_type)
Definition: http.c:229
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: glext.h:7751
#define ERROR_INTERNET_OPTION_NOT_SETTABLE
Definition: wininet.h:2000
#define ERROR_INTERNET_INVALID_OPTION
Definition: wininet.h:1998
#define INTERNET_OPTION_REFRESH
Definition: wininet.h:731
#define INTERNET_OPTION_SETTINGS_CHANGED
Definition: wininet.h:733
#define INTERNET_OPTION_CALLBACK
Definition: wininet.h:700

Referenced by APPINFO_SetOption(), HTTPREQ_SetOption(), HTTPSESSION_SetOption(), and set_global_option().

◆ init_urlcache()

BOOL init_urlcache ( void  )

Definition at line 4106 of file urlcache.c.

4107{
4109 if(!dll_unload_event)
4110 return FALSE;
4111
4113 if(!free_cache_running) {
4115 return FALSE;
4116 }
4117
4118#ifndef __REACTOS__
4120#endif
4121 return TRUE;
4122}
static void cache_containers_init(void)
Definition: urlcache.c:739
HANDLE WINAPI DECLSPEC_HOTPATCH CreateEventW(IN LPSECURITY_ATTRIBUTES lpEventAttributes OPTIONAL, IN BOOL bManualReset, IN BOOL bInitialState, IN LPCWSTR lpName OPTIONAL)
Definition: synch.c:587
HANDLE WINAPI DECLSPEC_HOTPATCH CreateSemaphoreW(IN LPSECURITY_ATTRIBUTES lpSemaphoreAttributes OPTIONAL, IN LONG lInitialCount, IN LONG lMaximumCount, IN LPCWSTR lpName OPTIONAL)
Definition: synch.c:406

Referenced by DllMain().

◆ init_winsock()

void init_winsock ( void  )

Definition at line 55 of file dpnet_main.c.

56{
59}
BOOL WINAPI InitOnceExecuteOnce(_Inout_ PINIT_ONCE InitOnce, _In_ __callback PINIT_ONCE_FN InitFn, _Inout_opt_ PVOID Parameter, _Outptr_opt_result_maybenull_ LPVOID *Context)
Definition: InitOnce.c:12
static BOOL WINAPI winsock_startup(INIT_ONCE *once, void *param, void **context)
Definition: dpnet_main.c:42
static INIT_ONCE init_once
Definition: vfwcapture.c:981
RTL_RUN_ONCE INIT_ONCE
Definition: winbase.h:3654
#define INIT_ONCE_STATIC_INIT
Definition: winbase.h:591

Referenced by create_netconn_socket(), FTP_Connect(), FTP_InitListenSocket(), IDirectPlay8ClientImpl_Initialize(), IDirectPlay8LobbiedApplicationImpl_Initialize(), IDirectPlay8PeerImpl_Initialize(), IDirectPlay8ServerImpl_Initialize(), InternetCheckConnectionW(), InternetOpenW(), and lobbyclient_Initialize().

◆ INTERNET_AsyncCall()

DWORD INTERNET_AsyncCall ( task_header_t *  task)

Definition at line 4534 of file internet.c.

4535{
4536 BOOL bSuccess;
4537
4538 TRACE("\n");
4539
4541 if (!bSuccess)
4542 {
4543 free(task);
4545 }
4546 return ERROR_SUCCESS;
4547}
BOOL WINAPI QueueUserWorkItem(IN LPTHREAD_START_ROUTINE Function, IN PVOID Context, IN ULONG Flags)
Definition: thread.c:1137
static DWORD CALLBACK INTERNET_WorkerThreadFunc(LPVOID lpvParam)
Definition: internet.c:4495
#define ERROR_INTERNET_ASYNC_THREAD_FAILED
Definition: wininet.h:2035
#define WT_EXECUTELONGFUNCTION
Definition: winnt_old.h:1105

Referenced by async_read(), FtpCreateDirectoryW(), FtpDeleteFileW(), FTPFILE_QueryDataAvailable(), FtpFindFirstFileW(), FTPFINDNEXT_FindNextFileW(), FtpGetCurrentDirectoryW(), FtpGetFileW(), FtpOpenFileW(), FtpPutFileW(), FtpRemoveDirectoryW(), FtpRenameFileW(), FtpSetCurrentDirectoryW(), HttpEndRequestW(), HttpSendRequestExW(), HttpSendRequestW(), and InternetOpenUrlW().

◆ INTERNET_FindProxyForProtocol()

WCHAR * INTERNET_FindProxyForProtocol ( LPCWSTR  szProxy,
LPCWSTR  proto 
)

Definition at line 511 of file internet.c.

512{
513 WCHAR *ret = NULL;
514 const WCHAR *ptr;
515
516 TRACE("(%s, %s)\n", debugstr_w(szProxy), debugstr_w(proto));
517
518 /* First, look for the specified protocol (proto=scheme://host:port) */
519 for (ptr = szProxy; ptr && *ptr; )
520 {
522
523 if (!(end = wcschr(ptr, ' ')))
524 end = ptr + lstrlenW(ptr);
525 if ((equal = wcschr(ptr, '=')) && equal < end &&
526 equal - ptr == lstrlenW(proto) &&
528 {
529 ret = strndupW(equal + 1, end - equal - 1);
530 TRACE("found proxy for %s: %s\n", debugstr_w(proto), debugstr_w(ret));
531 return ret;
532 }
533 if (*end == ' ')
534 ptr = end + 1;
535 else
536 ptr = end;
537 }
538
539 /* It wasn't found: look for no protocol */
540 for (ptr = szProxy; ptr && *ptr; )
541 {
542 LPCWSTR end;
543
544 if (!(end = wcschr(ptr, ' ')))
545 end = ptr + lstrlenW(ptr);
546 if (!wcschr(ptr, '='))
547 {
548 ret = strndupW(ptr, end - ptr);
549 TRACE("found proxy for %s: %s\n", debugstr_w(proto), debugstr_w(ret));
550 return ret;
551 }
552 if (*end == ' ')
553 ptr = end + 1;
554 else
555 ptr = end;
556 }
557
558 return NULL;
559}
GLuint GLuint end
Definition: gl.h:1545
#define equal(x, y)
Definition: reader.cc:56
const uint16_t * LPCWSTR
Definition: typedefs.h:57

Referenced by HTTP_DealWithProxy().

◆ INTERNET_GetLastError()

DWORD INTERNET_GetLastError ( void  )

Definition at line 4477 of file internet.c.

4478{
4480 if (!lpwite) return 0;
4481 /* TlsGetValue clears last error, so set it again here */
4482 SetLastError(lpwite->dwError);
4483 return lpwite->dwError;
4484}
#define SetLastError(x)
Definition: compat.h:752
LPVOID WINAPI TlsGetValue(IN DWORD Index)
Definition: thread.c:1301
static DWORD g_dwTlsErrIndex
Definition: internet.c:70
DWORD dwError
Definition: internet.c:66

Referenced by FTP_FtpCreateDirectoryW(), FTP_FtpDeleteFileW(), FTP_FtpFindFirstFileW(), FTP_FtpGetFileW(), FTP_FtpOpenFileW(), FTP_FtpPutFileW(), FTP_FtpRemoveDirectoryW(), FTP_FtpRenameFileW(), FTP_ReceiveRequestData(), HTTP_HandleRedirect(), and InternetConnectW().

◆ INTERNET_GetResponseBuffer()

LPSTR INTERNET_GetResponseBuffer ( void  )

Definition at line 4556 of file internet.c.

4557{
4559 if (!lpwite)
4560 lpwite = INTERNET_AllocThreadError();
4561 TRACE("\n");
4562 return lpwite->response;
4563}
static LPWITHREADERROR INTERNET_AllocThreadError(void)
Definition: internet.c:4429
CHAR response[MAX_REPLY_LEN]
Definition: internet.c:67

Referenced by FTP_DoPassive(), FTP_FtpGetCurrentDirectoryW(), FTP_GetNextLine(), and FTP_ReceiveResponse().

◆ INTERNET_SendCallback()

◆ INTERNET_SetLastError()

◆ is_valid_netconn()

◆ NETCON_GetCert()

LPCVOID NETCON_GetCert ( netconn_t *  connection)

Definition at line 886 of file netconnection.c.

887{
888 const CERT_CONTEXT *ret;
890
892 return res == SEC_E_OK ? ret : NULL;
893}
HINTERNET connection
Definition: port.c:65
LONG SECURITY_STATUS
Definition: ncrypt.h:31
#define SECPKG_ATTR_REMOTE_CERT_CONTEXT
Definition: schannel.h:69
#define SEC_E_OK
Definition: winerror.h:3450
SECURITY_STATUS WINAPI QueryContextAttributesW(PCtxtHandle phContext, ULONG ulAttribute, void *pBuffer)
Definition: wrapper.c:535

Referenced by get_security_cert_struct().

◆ NETCON_GetCipherStrength()

int NETCON_GetCipherStrength ( netconn_t *  connection)

Definition at line 895 of file netconnection.c.

896{
899
900 if (!connection->secure)
901 return 0;
902
903 res = QueryContextAttributesW(&connection->ssl_ctx, SECPKG_ATTR_CONNECTION_INFO, (void*)&conn_info);
904 if(res != SEC_E_OK)
905 WARN("QueryContextAttributesW failed: %08lx\n", res);
906 return res == SEC_E_OK ? conn_info.dwCipherStrength : 0;
907}
#define SECPKG_ATTR_CONNECTION_INFO
Definition: schannel.h:76

Referenced by get_security_cert_struct(), and netcon_secure_connect_setup().

◆ NETCON_is_alive()

BOOL NETCON_is_alive ( netconn_t *  netconn)

Definition at line 875 of file netconnection.c.

876{
877 int len;
878 char b;
879
882
883 return len == 1 || (len == -1 && WSAGetLastError() == WSAEWOULDBLOCK);
884}
GLboolean GLboolean GLboolean b
Definition: glext.h:6204
#define b
Definition: ke_i.h:79
static void set_socket_blocking(netconn_t *conn, BOOL is_blocking)
int sock_recv(int fd, void *msg, size_t len, int flags)
#define WSAEWOULDBLOCK
Definition: winerror.h:2851
#define MSG_PEEK
Definition: winsock.h:216

Referenced by open_http_connection().

◆ NETCON_recv()

DWORD NETCON_recv ( netconn_t *  connection,
void *  buf,
size_t  len,
BOOL  blocking,
int *  recvd 
)

Definition at line 823 of file netconnection.c.

824{
825 *recvd = 0;
826 if (!len)
827 return ERROR_SUCCESS;
828
829 if (!connection->secure)
830 {
832 *recvd = sock_recv(connection->socket, buf, len, 0);
833 return *recvd == -1 ? WSAGetLastError() : ERROR_SUCCESS;
834 }
835 else
836 {
837 SIZE_T size = 0;
838 BOOL eof;
839 DWORD res;
840
841 if(connection->peek_msg) {
842 size = min(len, connection->peek_len);
843 memcpy(buf, connection->peek_msg, size);
844 connection->peek_len -= size;
845 connection->peek_msg += size;
846
847 if(!connection->peek_len) {
848 free(connection->peek_msg_mem);
849 connection->peek_msg_mem = connection->peek_msg = NULL;
850 }
851
852 *recvd = size;
853 return ERROR_SUCCESS;
854 }
855
856 do {
857 res = read_ssl_chunk(connection, (BYTE*)buf, len, blocking, &size, &eof);
858 if(res != ERROR_SUCCESS) {
859 if(res == WSAEWOULDBLOCK) {
860 if(size)
862 }else {
863 WARN("read_ssl_chunk failed\n");
864 }
865 break;
866 }
867 }while(!size && !eof);
868
869 TRACE("received %Id bytes\n", size);
870 *recvd = size;
871 return res;
872 }
873}
static int eof(int fd)
Definition: io.h:21
#define min(a, b)
Definition: monoChain.cc:55
static BOOL read_ssl_chunk(netconn_t *conn, void *buf, SIZE_T buf_size, BOOL blocking, SIZE_T *ret_size, BOOL *eof)
ULONG_PTR SIZE_T
Definition: typedefs.h:80
unsigned char BYTE
Definition: xxhash.c:193

Referenced by chunked_read(), netconn_drain_content(), netconn_read(), and read_more_data().

◆ NETCON_secure_connect()

DWORD NETCON_secure_connect ( netconn_t *  connection,
server_t *  server 
)

Definition at line 603 of file netconnection.c.

604{
605 DWORD res;
606
607 /* can't connect if we are already connected */
608 if(connection->secure) {
609 ERR("already connected\n");
611 }
612
613 if(server != connection->server) {
614 server_release(connection->server);
616 connection->server = server;
617 }
618
619 /* connect with given TLS options */
621 if (res == ERROR_SUCCESS)
622 return res;
623
624 /* FIXME: when got version alert and FIN from server */
625 /* fallback to connect without TLSv1.1/TLSv1.2 */
627 {
628 closesocket(connection->socket);
630 if (res != ERROR_SUCCESS)
631 return res;
633 }
634 return res;
635}
static BOOL have_compat_cred_handle
static DWORD netcon_secure_connect_setup(netconn_t *connection, BOOL compat_mode)
#define ERROR_INTERNET_SECURITY_CHANNEL_ERROR
Definition: wininet.h:2069

Referenced by HTTP_HttpSendRequestW().

◆ NETCON_send()

DWORD NETCON_send ( netconn_t *  connection,
const void *  msg,
size_t  len,
int  flags,
int *  sent 
)

Definition at line 668 of file netconnection.c.

670{
671 /* send is always blocking. */
673
674 if(!connection->secure)
675 {
676 *sent = sock_send(connection->socket, msg, len, flags);
677 return *sent == -1 ? WSAGetLastError() : ERROR_SUCCESS;
678 }
679 else
680 {
681 const BYTE *ptr = msg;
682 size_t chunk_size;
683
684 *sent = 0;
685
686 while(len) {
687 chunk_size = min(len, connection->ssl_sizes.cbMaximumMessage);
688 if(!send_ssl_chunk(connection, ptr, chunk_size))
690
691 *sent += chunk_size;
692 ptr += chunk_size;
693 len -= chunk_size;
694 }
695
696 return ERROR_SUCCESS;
697 }
698}
@ sent
Definition: SystemMenu.c:27
#define msg(x)
Definition: auth_time.c:54
GLbitfield flags
Definition: glext.h:7161
int sock_send(int fd, const void *msg, size_t len, int flags)
static BOOL send_ssl_chunk(netconn_t *conn, const void *msg, size_t size)

Referenced by HTTP_HttpSendRequestW(), and HTTPREQ_WriteFile().

◆ NETCON_set_timeout()

DWORD NETCON_set_timeout ( netconn_t *  connection,
BOOL  send,
DWORD  value 
)

Definition at line 909 of file netconnection.c.

910{
911 int result;
912
914 send ? SO_SNDTIMEO : SO_RCVTIMEO, (void*)&value,
915 sizeof(value));
916 if (result == -1)
917 {
918 WARN("setsockopt failed\n");
919 return WSAGetLastError();
920 }
921 return ERROR_SUCCESS;
922}
INT WSAAPI send(IN SOCKET s, IN CONST CHAR FAR *buf, IN INT len, IN INT flags)
Definition: send.c:23
INT WSAAPI setsockopt(IN SOCKET s, IN INT level, IN INT optname, IN CONST CHAR FAR *optval, IN INT optlen)
Definition: sockctrl.c:421
Definition: pdh_main.c:64
#define SOL_SOCKET
Definition: winsock.h:392
#define SO_SNDTIMEO
Definition: winsock.h:186
#define SO_RCVTIMEO
Definition: winsock.h:187

Referenced by HTTP_GetResponseHeaders(), and HTTP_HttpSendRequestW().

◆ NETCON_unload()

void NETCON_unload ( void  )

Definition at line 408 of file netconnection.c.

409{
416 WSACleanup();
417}
static SecHandle compat_cred_handle
static CRITICAL_SECTION init_sechandle_cs
static BOOL cred_handle_initialized
static BOOL winsock_loaded
static SecHandle cred_handle
void WINAPI DeleteCriticalSection(PCRITICAL_SECTION)
int PASCAL FAR WSACleanup(void)
Definition: startup.c:60
SECURITY_STATUS WINAPI FreeCredentialsHandle(PCredHandle phCredential)
Definition: wrapper.c:151

Referenced by DllMain().

◆ req_file_addref()

static req_file_t * req_file_addref ( req_file_t *  req_file)
inlinestatic

Definition at line 417 of file internet.h.

418{
419 InterlockedIncrement(&req_file->ref);
420 return req_file;
421}
#define InterlockedIncrement
Definition: armddk.h:53

Referenced by HTTPREQ_LockRequestFile().

◆ req_file_release()

void req_file_release ( req_file_t *  req_file)

Definition at line 4634 of file internet.c.

4635{
4636 if(InterlockedDecrement(&req_file->ref))
4637 return;
4638
4639 if(!req_file->is_committed)
4640 DeleteFileW(req_file->file_name);
4641 if(req_file->file_handle && req_file->file_handle != INVALID_HANDLE_VALUE)
4642 CloseHandle(req_file->file_handle);
4643 free(req_file->file_name);
4644 free(req_file->url);
4645 free(req_file);
4646}
#define InterlockedDecrement
Definition: armddk.h:52
BOOL WINAPI DeleteFileW(IN LPCWSTR lpFileName)
Definition: delete.c:39
WCHAR * url
Definition: internet.h:217
BOOL is_committed
Definition: internet.h:218

Referenced by create_cache_entry(), create_req_file(), HTTPREQ_Destroy(), and InternetUnlockRequestFile().

◆ server_addref()

void server_addref ( server_t *  server)

Definition at line 143 of file http.c.

144{
146}

Referenced by create_netconn(), get_server(), and NETCON_secure_connect().

◆ server_release()

void server_release ( server_t *  server)

Definition at line 148 of file http.c.

149{
151 return;
152
153#ifdef __REACTOS__
155#endif
156 list_remove(&server->entry);
157#ifdef __REACTOS__
159#endif
160
161 if(server->cert_chain)
162 CertFreeCertificateChain(server->cert_chain);
163 free(server->name);
164 free(server->scheme_host_port);
165 free(server);
166}
VOID WINAPI CertFreeCertificateChain(PCCERT_CHAIN_CONTEXT pChainContext)
Definition: chain.c:2956

Referenced by collect_connections(), free_netconn(), HTTP_HandleRedirect(), HTTPREQ_Destroy(), InternetGetSecurityInfoByURLW(), and NETCON_secure_connect().

◆ set_cookie()

DWORD set_cookie ( substr_t  domain,
substr_t  path,
substr_t  name,
substr_t  data,
DWORD  flags 
)

Definition at line 912 of file cookie.c.

913{
915 cookie_t *thisCookie;
917 const WCHAR *end_ptr;
918 FILETIME expiry, create;
919 BOOL expired = FALSE, update_persistent = FALSE;
920 DWORD cookie_flags = 0, len;
921
922 TRACE("%s %s %s=%s %lx\n", debugstr_wn(domain.str, domain.len), debugstr_wn(path.str, path.len),
923 debugstr_wn(name.str, name.len), debugstr_wn(data.str, data.len), flags);
924
925 memset(&expiry,0,sizeof(expiry));
927
928 /* lots of information can be parsed out of the cookie value */
929
930 if(!(end_ptr = wmemchr(data.str, ';', data.len)))
931 end_ptr = data.str + data.len;
932 value = substr(data.str, end_ptr-data.str);
933 data.str += value.len;
934 data.len -= value.len;
935
936 for(;;) {
937 static const WCHAR szDomain[] = {'d','o','m','a','i','n','='};
938 static const WCHAR szPath[] = {'p','a','t','h','='};
939 static const WCHAR szExpires[] = {'e','x','p','i','r','e','s','='};
940 static const WCHAR szSecure[] = {'s','e','c','u','r','e'};
941 static const WCHAR szHttpOnly[] = {'h','t','t','p','o','n','l','y'};
942 static const WCHAR szVersion[] = {'v','e','r','s','i','o','n','='};
943 static const WCHAR max_ageW[] = {'m','a','x','-','a','g','e','='};
944
945 /* Skip ';' */
946 if(data.len)
947 substr_skip(&data, 1);
948
949 while(data.len && *data.str == ' ')
950 substr_skip(&data, 1);
951
952 if(!data.len)
953 break;
954
955 if(!(end_ptr = wmemchr(data.str, ';', data.len)))
956 end_ptr = data.str + data.len;
957
958 if(data.len >= (len = ARRAY_SIZE(szDomain)) && !wcsnicmp(data.str, szDomain, len)) {
960
961 if(data.len && *data.str == '.')
962 substr_skip(&data, 1);
963
964 if(!is_domain_legal_for_cookie(substr(data.str, end_ptr-data.str), domain))
966
967 domain = substr(data.str, end_ptr-data.str);
968 TRACE("Parsing new domain %s\n", debugstr_wn(domain.str, domain.len));
969 }else if(data.len >= (len = ARRAY_SIZE(szPath)) && !wcsnicmp(data.str, szPath, len)) {
971 path = substr(data.str, end_ptr - data.str);
972 TRACE("Parsing new path %s\n", debugstr_wn(path.str, path.len));
973 }else if(data.len >= (len = ARRAY_SIZE(szExpires)) && !wcsnicmp(data.str, szExpires, len)) {
974 SYSTEMTIME st;
975 WCHAR buf[128];
976
978
979 if(end_ptr > data.str && (end_ptr - data.str < ARRAY_SIZE(buf) - 1)) {
980 memcpy(buf, data.str, data.len*sizeof(WCHAR));
981 buf[data.len] = 0;
982
983 if (InternetTimeToSystemTimeW(data.str, &st, 0)) {
984 SystemTimeToFileTime(&st, &expiry);
985
986 if (CompareFileTime(&create,&expiry) > 0) {
987 TRACE("Cookie already expired.\n");
988 expired = TRUE;
989 }
990 }
991 }
992 }else if(data.len >= (len = ARRAY_SIZE(szSecure)) && !wcsnicmp(data.str, szSecure, len)) {
994 FIXME("secure not handled\n");
995 }else if(data.len >= (len = ARRAY_SIZE(szHttpOnly)) && !wcsnicmp(data.str, szHttpOnly, len)) {
997
999 WARN("HTTP only cookie added without INTERNET_COOKIE_HTTPONLY flag\n");
1001 return COOKIE_STATE_REJECT;
1002 }
1003
1004 cookie_flags |= INTERNET_COOKIE_HTTPONLY;
1005 }else if(data.len >= (len = ARRAY_SIZE(szVersion)) && !wcsnicmp(data.str, szVersion, len)) {
1006 substr_skip(&data, len);
1007
1008 FIXME("version not handled (%s)\n",debugstr_wn(data.str, data.len));
1009 }else if(data.len >= (len = ARRAY_SIZE(max_ageW)) && !wcsnicmp(data.str, max_ageW, len)) {
1010 /* Native doesn't support Max-Age attribute. */
1011 WARN("Max-Age ignored\n");
1012 }else if(data.len) {
1013 FIXME("Unknown additional option %s\n", debugstr_wn(data.str, data.len));
1014 }
1015
1016 substr_skip(&data, end_ptr - data.str);
1017 }
1018
1020
1022
1024 if(!container) {
1026 return COOKIE_STATE_ACCEPT;
1027 }
1028
1029 if(!expiry.dwLowDateTime && !expiry.dwHighDateTime)
1030 cookie_flags |= INTERNET_COOKIE_IS_SESSION;
1031 else
1032 update_persistent = TRUE;
1033
1034 if ((thisCookie = find_cookie(container, name))) {
1035 if ((thisCookie->flags & INTERNET_COOKIE_HTTPONLY) && !(flags & INTERNET_COOKIE_HTTPONLY)) {
1036 WARN("An attempt to override httponly cookie\n");
1039 return COOKIE_STATE_REJECT;
1040 }
1041
1042 if (!(thisCookie->flags & INTERNET_COOKIE_IS_SESSION))
1043 update_persistent = TRUE;
1044 delete_cookie(thisCookie);
1045 }
1046
1047 TRACE("setting cookie %s=%s for domain %s path %s\n", debugstr_wn(name.str, name.len),
1048 debugstr_wn(value.str, value.len), debugstr_w(container->domain->domain),
1049 debugstr_wn(container->path.str, container->path.len));
1050
1051 if (!expired) {
1052 cookie_t *new_cookie;
1053
1054 new_cookie = alloc_cookie(name, value, expiry, create, cookie_flags);
1055 if(!new_cookie) {
1057 return COOKIE_STATE_UNKNOWN;
1058 }
1059
1060 add_cookie(container, new_cookie);
1061 }
1062
1063 if (!update_persistent || save_persistent_cookie(container))
1064 {
1066 return COOKIE_STATE_ACCEPT;
1067 }
1069 return COOKIE_STATE_UNKNOWN;
1070}
VOID WINAPI GetSystemTimeAsFileTime(OUT PFILETIME lpFileTime)
Definition: time.c:128
BOOL WINAPI SystemTimeToFileTime(IN CONST SYSTEMTIME *lpSystemTime, OUT LPFILETIME lpFileTime)
Definition: time.c:153
LONG WINAPI CompareFileTime(IN CONST FILETIME *lpFileTime1, IN CONST FILETIME *lpFileTime2)
Definition: time.c:106
static wchar_t * wmemchr(const wchar_t *s, wchar_t c, size_t n)
Definition: wchar.h:48
BOOL WINAPI InternetTimeToSystemTimeW(LPCWSTR string, SYSTEMTIME *time, DWORD reserved)
Definition: internet.c:3979
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
Definition: gl.h:1950
static substr_t substr(const WCHAR *str, size_t len)
Definition: internet.h:169
#define debugstr_wn
Definition: kernel32.h:33
LPCWSTR szPath
Definition: env.c:37
static LPCWSTR szVersion
Definition: asmcache.c:748
static const struct access_res create[16]
Definition: package.c:7546
DWORD dwHighDateTime
Definition: mapidefs.h:66
DWORD dwLowDateTime
Definition: mapidefs.h:65
Definition: cookie.c:42
#define ERROR_INVALID_OPERATION
Definition: winerror.h:1689
static void delete_cookie(struct cookie *cookie)
Definition: cookie.c:98
static struct cookie * find_cookie(struct domain *domain, const WCHAR *path, const WCHAR *name)
Definition: cookie.c:64
static BOOL add_cookie(struct session *session, struct cookie *cookie, WCHAR *domain_name, WCHAR *path)
Definition: cookie.c:132
static BOOL load_persistent_cookie(substr_t domain, substr_t path)
Definition: cookie.c:308
static cookie_container_t * get_cookie_container(substr_t domain, substr_t path, BOOL create)
Definition: cookie.c:192
static BOOL save_persistent_cookie(cookie_container_t *container)
Definition: cookie.c:397
static cookie_t * alloc_cookie(substr_t name, substr_t data, FILETIME expiry, FILETIME create_time, DWORD flags)
Definition: cookie.c:245
static BOOL is_domain_legal_for_cookie(substr_t domain, substr_t full_domain)
Definition: cookie.c:869
static void substr_skip(substr_t *str, size_t len)
Definition: cookie.c:905
#define INTERNET_COOKIE_IS_SESSION
Definition: wininet.h:1819
@ COOKIE_STATE_ACCEPT
Definition: wininet.h:1792
@ COOKIE_STATE_UNKNOWN
Definition: wininet.h:1791
@ COOKIE_STATE_REJECT
Definition: wininet.h:1796

Referenced by HTTP_ProcessCookies(), InternetSetCookieExW(), and record_cookies().

◆ sock_recv()

int sock_recv ( int  fd,
void *  msg,
size_t  len,
int  flags 
)

Definition at line 430 of file netconnection.c.

431{
432 int ret;
433 do
434 {
435 ret = recv(fd, msg, len, flags);
436 }
437 while(ret == -1 && WSAGetLastError() == WSAEINTR);
438 return ret;
439}
INT WSAAPI recv(IN SOCKET s, OUT CHAR FAR *buf, IN INT len, IN INT flags)
Definition: recv.c:23
static int fd
Definition: io.c:51
#define WSAEINTR
Definition: winerror.h:2841

Referenced by NETCON_is_alive(), NETCON_recv(), netcon_secure_connect_setup(), and read_ssl_chunk().

◆ sock_send()

int sock_send ( int  fd,
const void *  msg,
size_t  len,
int  flags 
)

Definition at line 419 of file netconnection.c.

420{
421 int ret;
422 do
423 {
424 ret = send(fd, msg, len, flags);
425 }
426 while(ret == -1 && WSAGetLastError() == WSAEINTR);
427 return ret;
428}

Referenced by netcon_secure_connect_setup(), NETCON_send(), and send_ssl_chunk().

◆ strdupAtoW()

static WCHAR * strdupAtoW ( const char *  str)
inlinestatic

Definition at line 134 of file internet.h.

135{
136 LPWSTR ret = NULL;
137
138 if(str) {
139 DWORD len;
140
141 len = MultiByteToWideChar(CP_ACP, 0, str, -1, NULL, 0);
142 ret = malloc(len * sizeof(WCHAR));
143 if(ret)
145 }
146
147 return ret;
148}
#define CP_ACP
Definition: compat.h:109
#define MultiByteToWideChar
Definition: compat.h:110
const WCHAR * str

◆ strdupWtoA()

static char * strdupWtoA ( const WCHAR *  str)
inlinestatic

Definition at line 150 of file internet.h.

151{
152 char *ret = NULL;
153
154 if(str) {
156 ret = malloc(size);
157 if(ret)
159 }
160
161 return ret;
162}
#define WideCharToMultiByte
Definition: compat.h:111

◆ strndupAtoW()

static WCHAR * strndupAtoW ( const char *  str,
int  len_a,
DWORD *  len_w 
)
inlinestatic

Definition at line 112 of file internet.h.

113{
114 WCHAR *ret = NULL;
115
116 if(str) {
117 size_t len;
118 if(len_a < 0)
119 len_a = strlen(str);
120 else if(len_a > 0)
121 len_a = strnlen(str, len_a);
122 len = MultiByteToWideChar(CP_ACP, 0, str, len_a, NULL, 0);
123 ret = malloc((len + 1) * sizeof(WCHAR));
124 if(ret) {
125 MultiByteToWideChar(CP_ACP, 0, str, len_a, ret, len);
126 ret[len] = 0;
127 *len_w = len;
128 }
129 }
130
131 return ret;
132}
_ACRTIMP size_t __cdecl strnlen(const char *, size_t)
Definition: string.c:1607

Referenced by HttpAddRequestHeadersA(), InternetCrackUrlA(), InternetOpenUrlA(), and retrieve_cached_basic_authorization().

◆ strndupW()

static WCHAR * strndupW ( const WCHAR *  str,
UINT  max_len 
)
inlinestatic

Definition at line 91 of file internet.h.

92{
93 LPWSTR ret;
94 UINT len;
95
96 if(!str)
97 return NULL;
98
99 for(len=0; len<max_len; len++)
100 if(str[len] == '\0')
101 break;
102
103 ret = malloc(sizeof(WCHAR) * (len + 1));
104 if(ret) {
105 memcpy(ret, str, sizeof(WCHAR)*len);
106 ret[len] = '\0';
107 }
108
109 return ret;
110}
unsigned int UINT
Definition: sysinfo.c:13

◆ substr()

◆ substrz()

◆ WININET_AddRef()

object_header_t * WININET_AddRef ( object_header_t *  info)

Definition at line 202 of file internet.c.

203{
205 TRACE("%p -> refcount = %ld\n", info, refs );
206 return info;
207}
LONG refs
Definition: port.c:62

Referenced by alloc_async_task(), FTP_Connect(), FTP_FtpOpenFileW(), FTP_ReceiveFileList(), get_handle_object(), HTTP_Connect(), and HTTP_HttpOpenRequestW().

◆ WININET_find_data_WtoA()

static void WININET_find_data_WtoA ( LPWIN32_FIND_DATAW  dataW,
LPWIN32_FIND_DATAA  dataA 
)
inlinestatic

Definition at line 180 of file internet.h.

181{
182 dataA->dwFileAttributes = dataW->dwFileAttributes;
183 dataA->ftCreationTime = dataW->ftCreationTime;
184 dataA->ftLastAccessTime = dataW->ftLastAccessTime;
185 dataA->ftLastWriteTime = dataW->ftLastWriteTime;
186 dataA->nFileSizeHigh = dataW->nFileSizeHigh;
187 dataA->nFileSizeLow = dataW->nFileSizeLow;
188 dataA->dwReserved0 = dataW->dwReserved0;
189 dataA->dwReserved1 = dataW->dwReserved1;
190 WideCharToMultiByte(CP_ACP, 0, dataW->cFileName, -1,
191 dataA->cFileName, sizeof(dataA->cFileName),
192 NULL, NULL);
194 dataA->cAlternateFileName, sizeof(dataA->cAlternateFileName),
195 NULL, NULL);
196}
_Field_z_ CHAR cFileName[MAX_PATH]
Definition: minwinbase.h:277
_Field_z_ CHAR cAlternateFileName[14]
Definition: minwinbase.h:278
DWORD dwFileAttributes
Definition: minwinbase.h:269
FILETIME ftLastAccessTime
Definition: minwinbase.h:271
FILETIME ftCreationTime
Definition: minwinbase.h:270
FILETIME ftLastWriteTime
Definition: minwinbase.h:272
FILETIME ftLastWriteTime
Definition: minwinbase.h:286
_Field_z_ WCHAR cAlternateFileName[14]
Definition: minwinbase.h:292
_Field_z_ WCHAR cFileName[MAX_PATH]
Definition: minwinbase.h:291
DWORD dwFileAttributes
Definition: minwinbase.h:283
FILETIME ftLastAccessTime
Definition: minwinbase.h:285
FILETIME ftCreationTime
Definition: minwinbase.h:284

Referenced by FtpFindFirstFileA(), and InternetFindNextFileA().

◆ WININET_Release()

BOOL WININET_Release ( object_header_t *  info)

Definition at line 244 of file internet.c.

245{
247 TRACE( "object %p refcount = %ld\n", info, refs );
248 if( !refs )
249 {
251 if ( info->vtbl->CloseConnection )
252 {
253 TRACE( "closing connection %p\n", info);
254 info->vtbl->CloseConnection( info );
255 }
256 /* Don't send a callback if this is a session handle created with InternetOpenUrl */
257 if ((info->htype != WH_HHTTPSESSION && info->htype != WH_HFTPSESSION)
258 || !(info->dwInternalFlags & INET_OPENURL))
259 {
260 INTERNET_SendCallback(info, info->dwContext,
262 sizeof(HINTERNET));
263 }
264 TRACE( "destroying object %p\n", info);
265 if ( info->htype != WH_HINIT )
266 list_remove( &info->entry );
267 info->vtbl->Destroy( info );
268
269 if(info->hInternet) {
270 UINT_PTR handle = (UINT_PTR)info->hInternet;
271
273
275 if(next_handle > handle)
277
279 }
280
281 free(info);
282 }
283 return TRUE;
284}
static void invalidate_handle(object_header_t *info)
Definition: internet.c:226
#define INTERNET_STATUS_HANDLE_CLOSING
Definition: wininet.h:896

Referenced by FTP_Connect(), FtpCommandW(), FtpCreateDirectoryW(), FtpDeleteFileW(), FTPFILE_Destroy(), FtpFindFirstFileW(), FTPFINDNEXT_Destroy(), FtpGetCurrentDirectoryW(), FtpGetFileW(), FtpOpenFileW(), FtpPutFileW(), FtpRemoveDirectoryW(), FtpRenameFileW(), FTPSESSION_Destroy(), FtpSetCurrentDirectoryW(), HTTP_HttpOpenRequestW(), HttpAddRequestHeadersW(), HttpEndRequestW(), HttpOpenRequestW(), HttpQueryInfoW(), HTTPREQ_Destroy(), HttpSendRequestExW(), HttpSendRequestW(), HTTPSESSION_Destroy(), INTERNET_WorkerThreadFunc(), InternetCloseHandle(), InternetConnectW(), InternetErrorDlg(), InternetFindNextFileW(), InternetLockRequestFile(), InternetOpenUrlW(), InternetQueryDataAvailable(), InternetQueryOptionA(), InternetQueryOptionW(), InternetReadFile(), InternetReadFileExA(), InternetReadFileExW(), InternetSetFilePointer(), InternetSetOptionW(), InternetSetStatusCallbackA(), InternetSetStatusCallbackW(), InternetWriteFile(), and invalidate_handle().

Variable Documentation

◆ WININET_hModule