ReactOS  0.4.14-dev-317-g96040ec
winhttp_private.h File Reference
#include "wine/heap.h"
#include "wine/list.h"
#include "wine/unicode.h"
#include <sys/types.h>
#include "ole2.h"
#include "sspi.h"
Include dependency graph for winhttp_private.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  object_vtbl_t
 
struct  _object_header_t
 
struct  domain_t
 
struct  cookie_t
 
struct  hostdata_t
 
struct  session_t
 
struct  connect_t
 
struct  netconn_t
 
struct  header_t
 
struct  authinfo
 
struct  request_t
 
struct  _task_header_t
 
struct  send_request_t
 
struct  receive_response_t
 
struct  query_data_t
 
struct  read_data_t
 
struct  write_data_t
 

Macros

#define closesocket   close
 
#define ioctlsocket   ioctl
 

Typedefs

typedef struct _object_header_t object_header_t
 
typedef struct _task_header_t task_header_t
 

Enumerations

enum  auth_target { TARGET_INVALID = -1, TARGET_SERVER, TARGET_PROXY, TARGET_MAX }
 
enum  auth_scheme {
  SCHEME_INVALID = -1, SCHEME_BASIC, SCHEME_NTLM, SCHEME_PASSPORT,
  SCHEME_DIGEST, SCHEME_NEGOTIATE, SCHEME_MAX
}
 

Functions

object_header_taddref_object (object_header_t *) DECLSPEC_HIDDEN
 
object_header_tgrab_object (HINTERNET) DECLSPEC_HIDDEN
 
void release_object (object_header_t *) DECLSPEC_HIDDEN
 
HINTERNET alloc_handle (object_header_t *) DECLSPEC_HIDDEN
 
BOOL free_handle (HINTERNET) DECLSPEC_HIDDEN
 
void set_last_error (DWORD) DECLSPEC_HIDDEN
 
DWORD get_last_error (void) DECLSPEC_HIDDEN
 
void send_callback (object_header_t *, DWORD, LPVOID, DWORD) DECLSPEC_HIDDEN
 
void close_connection (request_t *) DECLSPEC_HIDDEN
 
BOOL netconn_close (netconn_t *) DECLSPEC_HIDDEN
 
netconn_tnetconn_create (hostdata_t *, const struct sockaddr_storage *, int) DECLSPEC_HIDDEN
 
void netconn_unload (void) DECLSPEC_HIDDEN
 
ULONG netconn_query_data_available (netconn_t *) DECLSPEC_HIDDEN
 
BOOL netconn_recv (netconn_t *, void *, size_t, int, int *) DECLSPEC_HIDDEN
 
BOOL netconn_resolve (WCHAR *, INTERNET_PORT, struct sockaddr_storage *, int) DECLSPEC_HIDDEN
 
BOOL netconn_secure_connect (netconn_t *, WCHAR *, DWORD, CredHandle *) DECLSPEC_HIDDEN
 
BOOL netconn_send (netconn_t *, const void *, size_t, int *) DECLSPEC_HIDDEN
 
DWORD netconn_set_timeout (netconn_t *, BOOL, int) DECLSPEC_HIDDEN
 
BOOL netconn_is_alive (netconn_t *) DECLSPEC_HIDDEN
 
const voidnetconn_get_certificate (netconn_t *) DECLSPEC_HIDDEN
 
int netconn_get_cipher_strength (netconn_t *) DECLSPEC_HIDDEN
 
BOOL set_cookies (request_t *, const WCHAR *) DECLSPEC_HIDDEN
 
BOOL add_cookie_headers (request_t *) DECLSPEC_HIDDEN
 
BOOL add_request_headers (request_t *, LPCWSTR, DWORD, DWORD) DECLSPEC_HIDDEN
 
void delete_domain (domain_t *) DECLSPEC_HIDDEN
 
BOOL set_server_for_hostname (connect_t *, LPCWSTR, INTERNET_PORT) DECLSPEC_HIDDEN
 
void destroy_authinfo (struct authinfo *) DECLSPEC_HIDDEN
 
void release_host (hostdata_t *host) DECLSPEC_HIDDEN
 
BOOL process_header (request_t *request, LPCWSTR field, LPCWSTR value, DWORD flags, BOOL request_only) DECLSPEC_HIDDEN
 
HRESULT WinHttpRequest_create (void **) DECLSPEC_HIDDEN
 
void release_typelib (void) DECLSPEC_HIDDEN
 
static void__WINE_ALLOC_SIZE (2) heap_realloc_zero(LPVOID mem
 
static WCHARstrdupW (const WCHAR *src)
 
static WCHARstrdupAW (const char *src)
 
static charstrdupWA (const WCHAR *src)
 
static charstrdupWA_sized (const WCHAR *src, DWORD size)
 

Variables

static const WCHAR getW [] = {'G','E','T',0}
 
static const WCHAR postW [] = {'P','O','S','T',0}
 
static const WCHAR headW [] = {'H','E','A','D',0}
 
static const WCHAR slashW [] = {'/',0}
 
static const WCHAR http1_0 [] = {'H','T','T','P','/','1','.','0',0}
 
static const WCHAR http1_1 [] = {'H','T','T','P','/','1','.','1',0}
 
static const WCHAR chunkedW [] = {'c','h','u','n','k','e','d',0}
 
static void SIZE_T size
 
HINSTANCE winhttp_instance DECLSPEC_HIDDEN
 

Macro Definition Documentation

◆ closesocket

#define closesocket   close

Definition at line 43 of file winhttp_private.h.

◆ ioctlsocket

#define ioctlsocket   ioctl

Definition at line 44 of file winhttp_private.h.

Typedef Documentation

◆ object_header_t

Definition at line 58 of file winhttp_private.h.

◆ task_header_t

Definition at line 241 of file winhttp_private.h.

Enumeration Type Documentation

◆ auth_scheme

Enumerator
SCHEME_INVALID 
SCHEME_BASIC 
SCHEME_NTLM 
SCHEME_PASSPORT 
SCHEME_DIGEST 
SCHEME_NEGOTIATE 
SCHEME_MAX 

Definition at line 176 of file winhttp_private.h.

◆ auth_target

Enumerator
TARGET_INVALID 
TARGET_SERVER 
TARGET_PROXY 
TARGET_MAX 

Definition at line 168 of file winhttp_private.h.

Function Documentation

◆ __WINE_ALLOC_SIZE()

static void* __WINE_ALLOC_SIZE ( )
inlinestatic

◆ add_cookie_headers()

BOOL add_cookie_headers ( request_t )

Definition at line 293 of file cookie.c.

294 {
295  struct list *domain_cursor;
296  session_t *session = request->connect->session;
297 
298  LIST_FOR_EACH( domain_cursor, &session->cookie_cache )
299  {
300  domain_t *domain = LIST_ENTRY( domain_cursor, domain_t, entry );
301  if (domain_match( request->connect->servername, domain, TRUE ))
302  {
303  struct list *cookie_cursor;
304  TRACE("found domain %s\n", debugstr_w(domain->name));
305 
306  LIST_FOR_EACH( cookie_cursor, &domain->cookies )
307  {
308  cookie_t *cookie = LIST_ENTRY( cookie_cursor, cookie_t, entry );
309 
310  TRACE("comparing path %s with %s\n", debugstr_w(request->path), debugstr_w(cookie->path));
311 
312  if (strstrW( request->path, cookie->path ) == request->path)
313  {
314  const WCHAR cookieW[] = {'C','o','o','k','i','e',':',' '};
315  int len, len_cookie = sizeof(cookieW) / sizeof(cookieW[0]), len_name = strlenW( cookie->name );
316  WCHAR *header;
317 
318  len = len_cookie + len_name;
319  if (cookie->value) len += strlenW( cookie->value ) + 1;
320  if (!(header = heap_alloc( (len + 1) * sizeof(WCHAR) ))) return FALSE;
321 
322  memcpy( header, cookieW, len_cookie * sizeof(WCHAR) );
323  strcpyW( header + len_cookie, cookie->name );
324  if (cookie->value)
325  {
326  header[len_cookie + len_name] = '=';
327  strcpyW( header + len_cookie + len_name + 1, cookie->value );
328  }
329 
330  TRACE("%s\n", debugstr_w(header));
333  heap_free( header );
334  }
335  }
336  }
337  }
338  return TRUE;
339 }
#define TRUE
Definition: types.h:120
WINE_UNICODE_INLINE unsigned int strlenW(const WCHAR *str)
Definition: unicode.h:212
#define WINHTTP_ADDREQ_FLAG_ADD
Definition: winhttp.h:84
static void * heap_alloc(size_t len)
Definition: appwiz.h:65
WCHAR * name
#define debugstr_w
Definition: kernel32.h:32
char path[256]
Definition: tftpd.h:94
#define strstrW(d, s)
Definition: unicode.h:32
#define LIST_FOR_EACH(cursor, list)
Definition: list.h:188
static BOOL domain_match(const WCHAR *name, domain_t *domain, BOOL partial)
Definition: cookie.c:66
struct list cookie_cache
#define WINHTTP_ADDREQ_FLAG_COALESCE_WITH_SEMICOLON
Definition: winhttp.h:86
#define TRACE(s)
Definition: solgame.cpp:4
__wchar_t WCHAR
Definition: xmlstorage.h:180
BOOL add_request_headers(request_t *request, LPCWSTR headers, DWORD len, DWORD flags)
Definition: request.c:474
uint32_t entry
Definition: isohybrid.c:63
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
GLenum GLsizei len
Definition: glext.h:6722
Definition: _list.h:228
WCHAR * name
WINE_UNICODE_INLINE WCHAR * strcpyW(WCHAR *dst, const WCHAR *src)
Definition: unicode.h:219
WCHAR * value
Definition: tftpd.h:85
struct list cookies
#define LIST_ENTRY(type)
Definition: queue.h:175
struct CFHEADER header
Definition: fdi.c:101
WCHAR * path
static BOOL heap_free(void *mem)
Definition: appwiz.h:75

Referenced by send_request().

◆ add_request_headers()

BOOL add_request_headers ( request_t ,
LPCWSTR  ,
DWORD  ,
DWORD   
)

Definition at line 474 of file request.c.

475 {
476  BOOL ret = FALSE;
477  WCHAR *buffer, *p, *q;
478  header_t *header;
479 
480  if (len == ~0u) len = strlenW( headers );
481  if (!len) return TRUE;
482  if (!(buffer = heap_alloc( (len + 1) * sizeof(WCHAR) ))) return FALSE;
483  memcpy( buffer, headers, len * sizeof(WCHAR) );
484  buffer[len] = 0;
485 
486  p = buffer;
487  do
488  {
489  q = p;
490  while (*q)
491  {
492  if (q[0] == '\n' && q[1] == '\r')
493  {
494  q[0] = '\r';
495  q[1] = '\n';
496  }
497  if (q[0] == '\r' && q[1] == '\n') break;
498  q++;
499  }
500  if (!*p) break;
501  if (*q == '\r')
502  {
503  *q = 0;
504  q += 2; /* jump over \r\n */
505  }
506  if ((header = parse_header( p )))
507  {
508  ret = process_header( request, header->field, header->value, flags, TRUE );
509  free_header( header );
510  }
511  p = q;
512  } while (ret);
513 
514  heap_free( buffer );
515  return ret;
516 }
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble * u
Definition: glfuncs.h:240
#define TRUE
Definition: types.h:120
static header_t * parse_header(LPCWSTR string)
Definition: request.c:305
WINE_UNICODE_INLINE unsigned int strlenW(const WCHAR *str)
Definition: unicode.h:212
GLuint buffer
Definition: glext.h:5915
vector< Header * > headers
Definition: sdkparse.cpp:39
static void * heap_alloc(size_t len)
Definition: appwiz.h:65
unsigned int BOOL
Definition: ntddk_ex.h:94
__wchar_t WCHAR
Definition: xmlstorage.h:180
GLdouble GLdouble GLdouble GLdouble q
Definition: gl.h:2063
GLbitfield flags
Definition: glext.h:7161
int ret
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
GLenum GLsizei len
Definition: glext.h:6722
static void free_header(header_t *header)
Definition: request.c:277
BOOL process_header(request_t *request, LPCWSTR field, LPCWSTR value, DWORD flags, BOOL request_only)
Definition: request.c:409
Definition: tftpd.h:85
GLfloat GLfloat p
Definition: glext.h:8902
unsigned int len
Definition: request.c:869
struct CFHEADER header
Definition: fdi.c:101
static BOOL heap_free(void *mem)
Definition: appwiz.h:75

Referenced by add_cookie_headers(), send_request(), and WinHttpAddRequestHeaders().

◆ addref_object()

object_header_t* addref_object ( object_header_t )

Definition at line 50 of file handle.c.

51 {
52  ULONG refs = InterlockedIncrement( &hdr->refs );
53  TRACE("%p -> refcount = %d\n", hdr, refs);
54  return hdr;
55 }
char hdr[14]
Definition: iptest.cpp:33
#define TRACE(s)
Definition: solgame.cpp:4
#define InterlockedIncrement
Definition: armddk.h:53
unsigned int ULONG
Definition: retypes.h:1

Referenced by alloc_handle(), grab_object(), WinHttpConnect(), WinHttpOpenRequest(), WinHttpQueryDataAvailable(), WinHttpReadData(), WinHttpReceiveResponse(), WinHttpSendRequest(), and WinHttpWriteData().

◆ alloc_handle()

HINTERNET alloc_handle ( object_header_t )

Definition at line 89 of file handle.c.

90 {
93 
94  list_init( &hdr->children );
95  hdr->handle = NULL;
96 
98  if (!max_handles)
99  {
101  if (!(p = heap_alloc_zero( sizeof(ULONG_PTR) * num ))) goto end;
102  handles = p;
103  max_handles = num;
104  }
105  if (max_handles == next_handle)
106  {
107  num = max_handles * 2;
108  if (!(p = heap_realloc_zero( handles, sizeof(ULONG_PTR) * num ))) goto end;
109  handles = p;
110  max_handles = num;
111  }
113  if (handles[handle]) ERR("handle isn't free but should be\n");
114 
116  hdr->handle = (HINTERNET)(handle + 1);
118 
119 end:
121  return hdr->handle;
122 }
LPVOID HINTERNET
Definition: winhttp.h:32
namespace GUID const ADDRINFOEXW ADDRINFOEXW struct timeval OVERLAPPED LPLOOKUPSERVICE_COMPLETION_ROUTINE HANDLE * handle
Definition: sock.c:82
char hdr[14]
Definition: iptest.cpp:33
GLuint GLuint end
Definition: gl.h:1545
#define HANDLE_CHUNK_SIZE
Definition: handle.c:35
void WINAPI EnterCriticalSection(LPCRITICAL_SECTION)
uint32_t ULONG_PTR
Definition: typedefs.h:63
smooth NULL
Definition: ftsmooth.c:416
static ULONG_PTR next_handle
Definition: handle.c:47
static object_header_t ** handles
Definition: handle.c:46
GLuint GLuint num
Definition: glext.h:9618
#define ERR(fmt,...)
Definition: debug.h:109
static ULONG_PTR max_handles
Definition: handle.c:48
object_header_t * addref_object(object_header_t *hdr)
Definition: handle.c:50
__WINE_SERVER_LIST_INLINE void list_init(struct list *list)
Definition: list.h:149
void WINAPI LeaveCriticalSection(LPCRITICAL_SECTION)
GLfloat GLfloat p
Definition: glext.h:8902
static CRITICAL_SECTION handle_cs
Definition: handle.c:37

◆ close_connection()

void close_connection ( request_t )

Definition at line 1803 of file request.c.

1804 {
1805  if (!request->netconn) return;
1806 
1808  netconn_close( request->netconn );
1809  request->netconn = NULL;
1811 }
void send_callback(object_header_t *hdr, DWORD status, LPVOID info, DWORD buflen)
Definition: session.c:71
#define WINHTTP_CALLBACK_STATUS_CLOSING_CONNECTION
Definition: winhttp.h:388
smooth NULL
Definition: ftsmooth.c:416
Definition: tftpd.h:85
#define WINHTTP_CALLBACK_STATUS_CONNECTION_CLOSED
Definition: winhttp.h:389
BOOL netconn_close(netconn_t *conn)
Definition: net.c:405

Referenced by finished_reading(), and release_object().

◆ delete_domain()

void delete_domain ( domain_t )

Definition at line 89 of file cookie.c.

90 {
91  cookie_t *cookie;
92  struct list *item, *next;
93 
94  LIST_FOR_EACH_SAFE( item, next, &domain->cookies )
95  {
96  cookie = LIST_ENTRY( item, cookie_t, entry );
97  delete_cookie( cookie );
98  }
99 
100  list_remove( &domain->entry );
101  heap_free( domain->name );
102  heap_free( domain );
103 }
#define LIST_FOR_EACH_SAFE(cursor, cursor2, list)
Definition: list.h:192
__WINE_SERVER_LIST_INLINE void list_remove(struct list *elem)
Definition: list.h:108
uint32_t entry
Definition: isohybrid.c:63
Definition: _list.h:228
static unsigned __int64 next
Definition: rand_nt.c:6
static ATOM item
Definition: dde.c:856
static void delete_cookie(cookie_t *cookie)
Definition: cookie.c:83
#define LIST_ENTRY(type)
Definition: queue.h:175
static BOOL heap_free(void *mem)
Definition: appwiz.h:75

Referenced by session_destroy().

◆ destroy_authinfo()

void destroy_authinfo ( struct authinfo )

Definition at line 1117 of file request.c.

1118 {
1119  if (!authinfo) return;
1120 
1121  if (SecIsValidHandle( &authinfo->ctx ))
1123  if (SecIsValidHandle( &authinfo->cred ))
1125 
1126  heap_free( authinfo->data );
1127  heap_free( authinfo );
1128 }
#define SecIsValidHandle(x)
Definition: sspi.h:63
SECURITY_STATUS WINAPI FreeCredentialsHandle(PCredHandle phCredential)
Definition: wrapper.c:151
CredHandle cred
char * data
SECURITY_STATUS WINAPI DeleteSecurityContext(PCtxtHandle phContext)
Definition: wrapper.c:450
static BOOL heap_free(void *mem)
Definition: appwiz.h:75
CtxtHandle ctx

Referenced by do_authorization().

◆ free_handle()

BOOL free_handle ( HINTERNET  )

Definition at line 124 of file handle.c.

125 {
126  BOOL ret = FALSE;
127  ULONG_PTR handle = (ULONG_PTR)hinternet;
129 
131 
132  if ((handle > 0) && (handle <= max_handles))
133  {
134  handle--;
135  if (handles[handle])
136  {
137  hdr = handles[handle];
138  TRACE("destroying handle 0x%lx for object %p\n", handle + 1, hdr);
139  handles[handle] = NULL;
140  ret = TRUE;
141  }
142  }
143 
145 
146  if (hdr)
147  {
149  {
150  TRACE("freeing child handle %p for parent handle 0x%lx\n", child->handle, handle + 1);
151  free_handle( child->handle );
152  }
153  release_object( hdr );
154  }
155 
159 
160  return ret;
161 }
namespace GUID const ADDRINFOEXW ADDRINFOEXW struct timeval OVERLAPPED LPLOOKUPSERVICE_COMPLETION_ROUTINE HANDLE * handle
Definition: sock.c:82
#define TRUE
Definition: types.h:120
char hdr[14]
Definition: iptest.cpp:33
void WINAPI EnterCriticalSection(LPCRITICAL_SECTION)
static HWND child
Definition: cursoricon.c:298
uint32_t ULONG_PTR
Definition: typedefs.h:63
unsigned int BOOL
Definition: ntddk_ex.h:94
smooth NULL
Definition: ftsmooth.c:416
#define TRACE(s)
Definition: solgame.cpp:4
static ULONG_PTR next_handle
Definition: handle.c:47
static object_header_t ** handles
Definition: handle.c:46
int ret
uint32_t entry
Definition: isohybrid.c:63
BOOL free_handle(HINTERNET hinternet)
Definition: handle.c:124
void release_object(object_header_t *hdr)
Definition: handle.c:73
static unsigned __int64 next
Definition: rand_nt.c:6
#define LIST_FOR_EACH_ENTRY_SAFE(cursor, cursor2, list, type, field)
Definition: list.h:204
static ULONG_PTR max_handles
Definition: handle.c:48
#define ULONG_PTR
Definition: config.h:101
void WINAPI LeaveCriticalSection(LPCRITICAL_SECTION)
static CRITICAL_SECTION handle_cs
Definition: handle.c:37

Referenced by free_handle(), pqInsert(), and WinHttpCloseHandle().

◆ get_last_error()

◆ grab_object()

object_header_t* grab_object ( HINTERNET  )

Definition at line 57 of file handle.c.

58 {
60  ULONG_PTR handle = (ULONG_PTR)hinternet;
61 
63 
64  if ((handle > 0) && (handle <= max_handles) && handles[handle - 1])
65  hdr = addref_object( handles[handle - 1] );
66 
68 
69  TRACE("handle 0x%lx -> %p\n", handle, hdr);
70  return hdr;
71 }
char hdr[14]
Definition: iptest.cpp:33
void WINAPI EnterCriticalSection(LPCRITICAL_SECTION)
uint32_t ULONG_PTR
Definition: typedefs.h:63
smooth NULL
Definition: ftsmooth.c:416
#define TRACE(s)
Definition: solgame.cpp:4
static object_header_t ** handles
Definition: handle.c:46
static ULONG_PTR max_handles
Definition: handle.c:48
object_header_t * addref_object(object_header_t *hdr)
Definition: handle.c:50
#define ULONG_PTR
Definition: config.h:101
void WINAPI LeaveCriticalSection(LPCRITICAL_SECTION)
static CRITICAL_SECTION handle_cs
Definition: handle.c:37

Referenced by WinHttpAddRequestHeaders(), WinHttpCloseHandle(), WinHttpConnect(), WinHttpGetProxyForUrl(), WinHttpOpenRequest(), WinHttpQueryAuthSchemes(), WinHttpQueryDataAvailable(), WinHttpQueryHeaders(), WinHttpQueryOption(), WinHttpReadData(), WinHttpReceiveResponse(), WinHttpSendRequest(), WinHttpSetCredentials(), WinHttpSetOption(), WinHttpSetStatusCallback(), WinHttpSetTimeouts(), and WinHttpWriteData().

◆ netconn_close()

BOOL netconn_close ( netconn_t )

Definition at line 405 of file net.c.

406 {
407  int res;
408 
409  if (conn->secure)
410  {
411  heap_free( conn->peek_msg_mem );
412  heap_free(conn->ssl_buf);
413  heap_free(conn->extra_buf);
414  DeleteSecurityContext(&conn->ssl_ctx);
415  }
416  res = closesocket( conn->socket );
417  release_host( conn->host );
418  heap_free(conn);
419  if (res == -1)
420  {
422  return FALSE;
423  }
424  return TRUE;
425 }
#define TRUE
Definition: types.h:120
#define closesocket
static int sock_get_error(int err)
Definition: net.c:77
int errno
void release_host(hostdata_t *host)
Definition: request.c:1526
GLuint res
Definition: glext.h:9613
void set_last_error(DWORD error)
Definition: session.c:59
SECURITY_STATUS WINAPI DeleteSecurityContext(PCtxtHandle phContext)
Definition: wrapper.c:450
static BOOL heap_free(void *mem)
Definition: appwiz.h:75

Referenced by close_connection(), connection_collector(), handle_redirect(), netconn_create(), and open_connection().

◆ netconn_create()

netconn_t* netconn_create ( hostdata_t ,
const struct sockaddr_storage ,
int   
)

Definition at line 300 of file net.c.

301 {
302  netconn_t *conn;
303  unsigned int addr_len;
304  BOOL ret = FALSE;
305  int res;
306  ULONG state;
307 
308  conn = heap_alloc_zero(sizeof(*conn));
309  if (!conn) return NULL;
310  conn->host = host;
311  conn->sockaddr = *sockaddr;
312  if ((conn->socket = socket( sockaddr->ss_family, SOCK_STREAM, 0 )) == -1)
313  {
314  WARN("unable to create socket (%s)\n", strerror(errno));
316  heap_free(conn);
317  return NULL;
318  }
319 
320  switch (conn->sockaddr.ss_family)
321  {
322  case AF_INET:
323  addr_len = sizeof(struct sockaddr_in);
324  break;
325  case AF_INET6:
326  addr_len = sizeof(struct sockaddr_in6);
327  break;
328  default:
329  assert(0);
330  }
331 
332  if (timeout > 0)
333  {
334  state = 1;
335  ioctlsocket( conn->socket, FIONBIO, &state );
336  }
337 
338  for (;;)
339  {
340  res = 0;
341  if (connect( conn->socket, (const struct sockaddr *)&conn->sockaddr, addr_len ) < 0)
342  {
343  res = sock_get_error( errno );
344  if (res == WSAEWOULDBLOCK || res == WSAEINPROGRESS)
345  {
346 #ifdef __REACTOS__
347  /* ReactOS: use select instead of poll */
348  fd_set outfd;
349  struct timeval tv;
350 
351  FD_ZERO(&outfd);
352  FD_SET(conn->socket, &outfd);
353 
354  tv.tv_sec = 0;
355  tv.tv_usec = timeout * 1000;
356  for (;;)
357  {
358  res = 0;
359 
360  if (select( 0, NULL, &outfd, NULL, &tv ) > 0)
361 #else
362  struct pollfd pfd;
363 
364  pfd.fd = conn->socket;
365  pfd.events = POLLOUT;
366  for (;;)
367  {
368  res = 0;
369  if (poll( &pfd, 1, timeout ) > 0)
370 #endif
371  {
372  ret = TRUE;
373  break;
374  }
375  else
376  {
377  res = sock_get_error( errno );
378  if (res != WSAEINTR) break;
379  }
380  }
381  }
382  if (res != WSAEINTR) break;
383  }
384  else
385  {
386  ret = TRUE;
387  break;
388  }
389  }
390  if (timeout > 0)
391  {
392  state = 0;
393  ioctlsocket( conn->socket, FIONBIO, &state );
394  }
395  if (!ret)
396  {
397  WARN("unable to connect to host (%d)\n", res);
398  set_last_error( res );
399  netconn_close( conn );
400  return NULL;
401  }
402  return conn;
403 }
#define ioctlsocket
Definition: winsock.h:66
#define TRUE
Definition: types.h:120
SOCKET WSAAPI socket(IN INT af, IN INT type, IN INT protocol)
Definition: socklife.c:143
#define WARN(fmt,...)
Definition: debug.h:111
char * host
Definition: whois.c:55
static int sock_get_error(int err)
Definition: net.c:77
#define WSAEWOULDBLOCK
Definition: winerror.h:1948
#define assert(x)
Definition: debug.h:53
Definition: dhcpd.h:245
int errno
#define FD_ZERO(set)
Definition: winsock.h:96
#define FD_SET(fd, set)
Definition: winsock.h:89
const char * strerror(int err)
Definition: compat_str.c:23
INT WSAAPI connect(IN SOCKET s, IN CONST struct sockaddr *name, IN INT namelen)
Definition: sockctrl.c:23
#define WSAEINPROGRESS
Definition: winerror.h:1949
struct sockaddr_storage sockaddr
unsigned int BOOL
Definition: ntddk_ex.h:94
INT WSAAPI select(IN INT s, IN OUT LPFD_SET readfds, IN OUT LPFD_SET writefds, IN OUT LPFD_SET exceptfds, IN CONST struct timeval *timeout)
Definition: select.c:41
smooth NULL
Definition: ftsmooth.c:416
#define AF_INET6
Definition: winsock.h:369
int poll(struct pollfd *ufds, int nfds, int timeout)
Definition: adnstest.c:68
Definition: linux.h:1867
static PIXELFORMATDESCRIPTOR pfd
Definition: ssstars.c:67
int ret
static int state
Definition: maze.c:121
#define FIONBIO
Definition: winsock.h:149
hostdata_t * host
GLuint res
Definition: glext.h:9613
unsigned int ULONG
Definition: retypes.h:1
#define AF_INET
Definition: tcpip.h:117
void set_last_error(DWORD error)
Definition: session.c:59
#define SOCK_STREAM
Definition: tcpip.h:118
#define POLLOUT
Definition: linux.h:1855
BOOL netconn_close(netconn_t *conn)
Definition: net.c:405
#define WSAEINTR
Definition: winerror.h:1942
static BOOL heap_free(void *mem)
Definition: appwiz.h:75

Referenced by open_connection().

◆ netconn_get_certificate()

const void* netconn_get_certificate ( netconn_t )

Definition at line 928 of file net.c.

929 {
930  const CERT_CONTEXT *ret;
932 
933  if (!conn->secure) return NULL;
935  return res == SEC_E_OK ? ret : NULL;
936 }
#define SECPKG_ATTR_REMOTE_CERT_CONTEXT
Definition: schannel.h:69
smooth NULL
Definition: ftsmooth.c:416
LONG SECURITY_STATUS
Definition: sspi.h:34
int ret
#define SEC_E_OK
Definition: winerror.h:2356
SECURITY_STATUS WINAPI QueryContextAttributesW(PCtxtHandle phContext, ULONG ulAttribute, void *pBuffer)
Definition: wrapper.c:535
GLuint res
Definition: glext.h:9613

Referenced by request_query_option().

◆ netconn_get_cipher_strength()

int netconn_get_cipher_strength ( netconn_t )

Definition at line 938 of file net.c.

939 {
942 
943  if (!conn->secure) return 0;
944  res = QueryContextAttributesW(&conn->ssl_ctx, SECPKG_ATTR_CONNECTION_INFO, (void*)&conn_info);
945  if(res != SEC_E_OK)
946  WARN("QueryContextAttributesW failed: %08x\n", res);
947  return res == SEC_E_OK ? conn_info.dwCipherStrength : 0;
948 }
#define WARN(fmt,...)
Definition: debug.h:111
LONG SECURITY_STATUS
Definition: sspi.h:34
#define SECPKG_ATTR_CONNECTION_INFO
Definition: schannel.h:76
#define SEC_E_OK
Definition: winerror.h:2356
SECURITY_STATUS WINAPI QueryContextAttributesW(PCtxtHandle phContext, ULONG ulAttribute, void *pBuffer)
Definition: wrapper.c:535
GLuint res
Definition: glext.h:9613

Referenced by request_query_option().

◆ netconn_is_alive()

BOOL netconn_is_alive ( netconn_t )

Definition at line 784 of file net.c.

785 {
786 #ifdef MSG_DONTWAIT
787  ssize_t len;
788  BYTE b;
789 
790  len = recv( netconn->socket, &b, 1, MSG_PEEK | MSG_DONTWAIT );
791  return len == 1 || (len == -1 && errno == EWOULDBLOCK);
792 #elif defined(__MINGW32__) || defined(_MSC_VER)
793  ULONG mode;
794  int len;
795  char b;
796 
797  mode = 1;
798  if(!ioctlsocket(netconn->socket, FIONBIO, &mode))
799  return FALSE;
800 
801  len = recv(netconn->socket, &b, 1, MSG_PEEK);
802 
803  mode = 0;
804  if(!ioctlsocket(netconn->socket, FIONBIO, &mode))
805  return FALSE;
806 
807  return len == 1 || (len == -1 && WSAGetLastError() == WSAEWOULDBLOCK);
808 #else
809  FIXME("not supported on this platform\n");
810  return TRUE;
811 #endif
812 }
#define ioctlsocket
#define TRUE
Definition: types.h:120
#define WSAEWOULDBLOCK
Definition: winerror.h:1948
int errno
#define EWOULDBLOCK
Definition: errno.h:42
#define FIXME(fmt,...)
Definition: debug.h:110
#define b
Definition: ke_i.h:79
GLboolean GLboolean GLboolean b
Definition: glext.h:6204
INT WSAAPI WSAGetLastError(VOID)
Definition: dllmain.c:112
GLenum GLsizei len
Definition: glext.h:6722
unsigned char BYTE
Definition: mem.h:68
int ssize_t
Definition: rosdhcp.h:48
GLenum mode
Definition: glext.h:6217
#define FIONBIO
Definition: winsock.h:149
unsigned int ULONG
Definition: retypes.h:1
INT WSAAPI recv(IN SOCKET s, OUT CHAR FAR *buf, IN INT len, IN INT flags)
Definition: recv.c:23
#define MSG_PEEK
Definition: winsock.h:222

Referenced by open_connection().

◆ netconn_query_data_available()

ULONG netconn_query_data_available ( netconn_t )

Definition at line 763 of file net.c.

764 {
765  return conn->secure ? conn->peek_len : 0;
766 }

Referenced by query_data_available().

◆ netconn_recv()

BOOL netconn_recv ( netconn_t ,
void ,
size_t  ,
int  ,
int  
)

Definition at line 706 of file net.c.

707 {
708  *recvd = 0;
709  if (!len) return TRUE;
710 
711  if (conn->secure)
712  {
713  SIZE_T size, cread;
714  BOOL res, eof;
715 
716  if (conn->peek_msg)
717  {
718  *recvd = min( len, conn->peek_len );
719  memcpy( buf, conn->peek_msg, *recvd );
720  conn->peek_len -= *recvd;
721  conn->peek_msg += *recvd;
722 
723  if (conn->peek_len == 0)
724  {
725  heap_free( conn->peek_msg_mem );
726  conn->peek_msg_mem = NULL;
727  conn->peek_msg = NULL;
728  }
729  /* check if we have enough data from the peek buffer */
730  if (!(flags & MSG_WAITALL) || *recvd == len) return TRUE;
731  }
732  size = *recvd;
733 
734  do {
735  res = read_ssl_chunk(conn, (BYTE*)buf+size, len-size, &cread, &eof);
736  if(!res) {
737  WARN("read_ssl_chunk failed\n");
738  if(!size)
739  return FALSE;
740  break;
741  }
742 
743  if(eof) {
744  TRACE("EOF\n");
745  break;
746  }
747 
748  size += cread;
749  }while(!size || ((flags & MSG_WAITALL) && size < len));
750 
751  TRACE("received %ld bytes\n", size);
752  *recvd = size;
753  return TRUE;
754  }
755  if ((*recvd = sock_recv( conn->socket, buf, len, flags )) == -1)
756  {
758  return FALSE;
759  }
760  return TRUE;
761 }
#define TRUE
Definition: types.h:120
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: glext.h:7751
#define WARN(fmt,...)
Definition: debug.h:111
static int sock_get_error(int err)
Definition: net.c:77
int errno
unsigned int BOOL
Definition: ntddk_ex.h:94
smooth NULL
Definition: ftsmooth.c:416
#define TRACE(s)
Definition: solgame.cpp:4
GLsizeiptr size
Definition: glext.h:5919
static BOOL read_ssl_chunk(netconn_t *conn, void *buf, SIZE_T buf_size, SIZE_T *ret_size, BOOL *eof)
Definition: net.c:615
GLbitfield flags
Definition: glext.h:7161
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
GLenum GLsizei len
Definition: glext.h:6722
unsigned char BYTE
Definition: mem.h:68
_Check_return_ _CRTIMP int __cdecl __cdecl eof(_In_ int _FileHandle)
ULONG_PTR SIZE_T
Definition: typedefs.h:78
#define min(a, b)
Definition: monoChain.cc:55
GLuint res
Definition: glext.h:9613
void set_last_error(DWORD error)
Definition: session.c:59
static int sock_recv(int fd, void *msg, size_t len, int flags)
Definition: net.c:163
static BOOL heap_free(void *mem)
Definition: appwiz.h:75

Referenced by read_more_data().

◆ netconn_resolve()

BOOL netconn_resolve ( WCHAR ,
INTERNET_PORT  ,
struct sockaddr_storage ,
int   
)

Definition at line 896 of file net.c.

897 {
898  DWORD ret;
899 
900  if (timeout)
901  {
902  DWORD status;
903  HANDLE thread;
904  struct resolve_args ra;
905 
906  ra.hostname = hostname;
907  ra.port = port;
908  ra.sa = sa;
909 
910  thread = CreateThread( NULL, 0, resolve_proc, &ra, 0, NULL );
911  if (!thread) return FALSE;
912 
915  else ret = ERROR_WINHTTP_TIMEOUT;
916  CloseHandle( thread );
917  }
918  else ret = resolve_hostname( hostname, port, sa );
919 
920  if (ret)
921  {
922  set_last_error( ret );
923  return FALSE;
924  }
925  return TRUE;
926 }
#define TRUE
Definition: types.h:120
#define CloseHandle
Definition: compat.h:398
static DWORD resolve_hostname(const WCHAR *hostnameW, INTERNET_PORT port, struct sockaddr_storage *sa)
Definition: net.c:814
#define ERROR_WINHTTP_TIMEOUT
Definition: winhttp.h:189
Definition: dhcpd.h:245
char * hostname
Definition: ftp.c:88
BOOL WINAPI GetExitCodeThread(IN HANDLE hThread, OUT LPDWORD lpExitCode)
Definition: thread.c:540
DWORD WINAPI WaitForSingleObject(IN HANDLE hHandle, IN DWORD dwMilliseconds)
Definition: synch.c:82
HANDLE WINAPI DECLSPEC_HOTPATCH CreateThread(IN LPSECURITY_ATTRIBUTES lpThreadAttributes, IN DWORD dwStackSize, IN LPTHREAD_START_ROUTINE lpStartAddress, IN LPVOID lpParameter, IN DWORD dwCreationFlags, OUT LPDWORD lpThreadId)
Definition: thread.c:136
smooth NULL
Definition: ftsmooth.c:416
#define WAIT_OBJECT_0
Definition: winbase.h:387
unsigned long DWORD
Definition: ntddk_ex.h:95
static HANDLE thread
Definition: service.c:33
int ret
const WCHAR * hostname
Definition: net.c:885
void set_last_error(DWORD error)
Definition: session.c:59
USHORT port
Definition: uri.c:227
static SERVICE_STATUS status
Definition: service.c:31
static struct sockaddr_in sa
Definition: adnsresfilter.c:69
static DWORD CALLBACK resolve_proc(LPVOID arg)
Definition: net.c:890
Definition: ps.c:97

Referenced by open_connection().

◆ netconn_secure_connect()

BOOL netconn_secure_connect ( netconn_t ,
WCHAR ,
DWORD  ,
CredHandle  
)

Definition at line 427 of file net.c.

428 {
429  SecBuffer out_buf = {0, SECBUFFER_TOKEN, NULL}, in_bufs[2] = {{0, SECBUFFER_TOKEN}, {0, SECBUFFER_EMPTY}};
430  SecBufferDesc out_desc = {SECBUFFER_VERSION, 1, &out_buf}, in_desc = {SECBUFFER_VERSION, 2, in_bufs};
431  BYTE *read_buf;
432  SIZE_T read_buf_size = 2048;
433  ULONG attrs = 0;
434  CtxtHandle ctx;
435  SSIZE_T size;
436  const CERT_CONTEXT *cert;
439 
442 
443  read_buf = heap_alloc(read_buf_size);
444  if(!read_buf)
445  return FALSE;
446 
447  status = InitializeSecurityContextW(cred_handle, NULL, hostname, isc_req_flags, 0, 0, NULL, 0,
448  &ctx, &out_desc, &attrs, NULL);
449 
450  assert(status != SEC_E_OK);
451 
453  if(out_buf.cbBuffer) {
455 
456  TRACE("sending %u bytes\n", out_buf.cbBuffer);
457 
458  size = sock_send(conn->socket, out_buf.pvBuffer, out_buf.cbBuffer, 0);
459  if(size != out_buf.cbBuffer) {
460  ERR("send failed\n");
462  break;
463  }
464 
465  FreeContextBuffer(out_buf.pvBuffer);
466  out_buf.pvBuffer = NULL;
467  out_buf.cbBuffer = 0;
468  }
469 
471  assert(in_bufs[1].cbBuffer < read_buf_size);
472 
473  memmove(read_buf, (BYTE*)in_bufs[0].pvBuffer+in_bufs[0].cbBuffer-in_bufs[1].cbBuffer, in_bufs[1].cbBuffer);
474  in_bufs[0].cbBuffer = in_bufs[1].cbBuffer;
475 
476  in_bufs[1].BufferType = SECBUFFER_EMPTY;
477  in_bufs[1].cbBuffer = 0;
478  in_bufs[1].pvBuffer = NULL;
479  }
480 
481  assert(in_bufs[0].BufferType == SECBUFFER_TOKEN);
482  assert(in_bufs[1].BufferType == SECBUFFER_EMPTY);
483 
484  if(in_bufs[0].cbBuffer + 1024 > read_buf_size) {
485  BYTE *new_read_buf;
486 
487  new_read_buf = heap_realloc(read_buf, read_buf_size + 1024);
488  if(!new_read_buf) {
490  break;
491  }
492 
493  in_bufs[0].pvBuffer = read_buf = new_read_buf;
494  read_buf_size += 1024;
495  }
496 
497  size = sock_recv(conn->socket, read_buf+in_bufs[0].cbBuffer, read_buf_size-in_bufs[0].cbBuffer, 0);
498  if(size < 1) {
500  break;
501  }
502 
503  TRACE("recv %lu bytes\n", size);
504 
505  in_bufs[0].cbBuffer += size;
506  in_bufs[0].pvBuffer = read_buf;
507  status = InitializeSecurityContextW(cred_handle, &ctx, hostname, isc_req_flags, 0, 0, &in_desc,
508  0, NULL, &out_desc, &attrs, NULL);
509  TRACE("InitializeSecurityContext ret %08x\n", status);
510 
511  if(status == SEC_E_OK) {
512  if(in_bufs[1].BufferType == SECBUFFER_EXTRA)
513  FIXME("SECBUFFER_EXTRA not supported\n");
514 
515  status = QueryContextAttributesW(&ctx, SECPKG_ATTR_STREAM_SIZES, &conn->ssl_sizes);
516  if(status != SEC_E_OK) {
517  WARN("Could not get sizes\n");
518  break;
519  }
520 
522  if(status == SEC_E_OK) {
523  res = netconn_verify_cert(cert, hostname, security_flags);
525  if(res != ERROR_SUCCESS) {
526  WARN("cert verify failed: %u\n", res);
527  break;
528  }
529  }else {
530  WARN("Could not get cert\n");
531  break;
532  }
533 
534  conn->ssl_buf = heap_alloc(conn->ssl_sizes.cbHeader + conn->ssl_sizes.cbMaximumMessage + conn->ssl_sizes.cbTrailer);
535  if(!conn->ssl_buf) {
536  res = GetLastError();
537  break;
538  }
539  }
540  }
541 
543 
544  if(status != SEC_E_OK || res != ERROR_SUCCESS) {
545  WARN("Failed to initialize security context failed: %08x\n", status);
546  heap_free(conn->ssl_buf);
547  conn->ssl_buf = NULL;
548  DeleteSecurityContext(&ctx);
550  return FALSE;
551  }
552 
553 
554  TRACE("established SSL connection\n");
555  conn->secure = TRUE;
556  conn->ssl_ctx = ctx;
557  return TRUE;
558 }
#define ISC_REQ_SEQUENCE_DETECT
Definition: sspi.h:351
#define memmove(s1, s2, n)
Definition: mkisofs.h:881
#define TRUE
Definition: types.h:120
#define ERROR_SUCCESS
Definition: deptool.c:10
SECURITY_STATUS WINAPI FreeContextBuffer(PVOID pv)
Definition: sspi.c:699
#define ERROR_WINHTTP_SECURE_CHANNEL_ERROR
Definition: winhttp.h:219
BOOL WINAPI CertFreeCertificateContext(PCCERT_CONTEXT pCertContext)
Definition: cert.c:371
#define WARN(fmt,...)
Definition: debug.h:111
#define SECPKG_ATTR_REMOTE_CERT_CONTEXT
Definition: schannel.h:69
static SecHandle cred_handle
#define assert(x)
Definition: debug.h:53
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1059
LONG_PTR SSIZE_T
Definition: basetsd.h:183
static void * heap_realloc(void *mem, size_t len)
Definition: appwiz.h:70
static void * heap_alloc(size_t len)
Definition: appwiz.h:65
#define SECBUFFER_EXTRA
Definition: sspi.h:150
unsigned read_buf(z_streamp strm, Bytef *buf, unsigned size)
Definition: deflate.c:1167
char * hostname
Definition: ftp.c:88
#define ISC_REQ_MANUAL_CRED_VALIDATION
Definition: sspi.h:367
#define E_OUTOFMEMORY
Definition: ddrawi.h:100
#define FIXME(fmt,...)
Definition: debug.h:110
smooth NULL
Definition: ftsmooth.c:416
#define SECBUFFER_EMPTY
Definition: sspi.h:145
#define SEC_I_CONTINUE_NEEDED
Definition: winerror.h:2927
static BYTE cert[]
Definition: msg.c:1437
LONG SECURITY_STATUS
Definition: sspi.h:34
#define TRACE(s)
Definition: solgame.cpp:4
GLsizeiptr size
Definition: glext.h:5919
SECURITY_STATUS WINAPI InitializeSecurityContextW(PCredHandle phCredential, PCtxtHandle phContext, SEC_WCHAR *pszTargetName, ULONG fContextReq, ULONG Reserved1, ULONG TargetDataRep, PSecBufferDesc pInput, ULONG Reserved2, PCtxtHandle phNewContext, PSecBufferDesc pOutput, ULONG *pfContextAttr, PTimeStamp ptsExpiry)
Definition: wrapper.c:301
unsigned long DWORD
Definition: ntddk_ex.h:95
#define ISC_REQ_USE_SESSION_KEY
Definition: sspi.h:353
#define SECPKG_ATTR_STREAM_SIZES
Definition: sspi.h:511
#define ISC_REQ_ALLOCATE_MEMORY
Definition: sspi.h:356
#define SECBUFFER_TOKEN
Definition: sspi.h:147
unsigned char BYTE
Definition: mem.h:68
#define SEC_E_OK
Definition: winerror.h:2356
SECURITY_STATUS WINAPI QueryContextAttributesW(PCtxtHandle phContext, ULONG ulAttribute, void *pBuffer)
Definition: wrapper.c:535
#define ERR(fmt,...)
Definition: debug.h:109
ULONG_PTR SIZE_T
Definition: typedefs.h:78
static int sock_send(int fd, const void *msg, size_t len, int flags)
Definition: net.c:152
#define SECBUFFER_VERSION
Definition: sspi.h:173
ULONG cbBuffer
Definition: sspi.h:139
static DWORD netconn_verify_cert(PCCERT_CONTEXT cert, WCHAR *server, DWORD security_flags)
Definition: net.c:174
GLuint res
Definition: glext.h:9613
unsigned int ULONG
Definition: retypes.h:1
#define ISC_REQ_CONFIDENTIALITY
Definition: sspi.h:352
#define ISC_REQ_REPLAY_DETECT
Definition: sspi.h:350
void set_last_error(DWORD error)
Definition: session.c:59
static int sock_recv(int fd, void *msg, size_t len, int flags)
Definition: net.c:163
static SERVICE_STATUS status
Definition: service.c:31
#define SEC_E_INCOMPLETE_MESSAGE
Definition: winerror.h:2934
SECURITY_STATUS WINAPI DeleteSecurityContext(PCtxtHandle phContext)
Definition: wrapper.c:450
static BOOL heap_free(void *mem)
Definition: appwiz.h:75
Definition: ps.c:97

Referenced by open_connection().

◆ netconn_send()

BOOL netconn_send ( netconn_t ,
const void ,
size_t  ,
int  
)

Definition at line 586 of file net.c.

587 {
588  if (conn->secure)
589  {
590  const BYTE *ptr = msg;
591  size_t chunk_size;
592 
593  *sent = 0;
594 
595  while(len) {
596  chunk_size = min(len, conn->ssl_sizes.cbMaximumMessage);
597  if(!send_ssl_chunk(conn, ptr, chunk_size))
598  return FALSE;
599 
600  *sent += chunk_size;
601  ptr += chunk_size;
602  len -= chunk_size;
603  }
604 
605  return TRUE;
606  }
607  if ((*sent = sock_send( conn->socket, msg, len, 0 )) == -1)
608  {
610  return FALSE;
611  }
612  return TRUE;
613 }
#define TRUE
Definition: types.h:120
static int sock_get_error(int err)
Definition: net.c:77
static BOOL send_ssl_chunk(netconn_t *conn, const void *msg, size_t size)
Definition: net.c:560
int errno
static PVOID ptr
Definition: dispmode.c:27
Definition: msg.h:34
GLenum GLsizei len
Definition: glext.h:6722
unsigned char BYTE
Definition: mem.h:68
static int sock_send(int fd, const void *msg, size_t len, int flags)
Definition: net.c:152
#define min(a, b)
Definition: monoChain.cc:55
#define msg(x)
Definition: auth_time.c:54
void set_last_error(DWORD error)
Definition: session.c:59

Referenced by secure_proxy_connect(), send_request(), and write_data().

◆ netconn_set_timeout()

DWORD netconn_set_timeout ( netconn_t ,
BOOL  ,
int   
)

Definition at line 768 of file net.c.

769 {
770  struct timeval tv;
771 
772  /* value is in milliseconds, convert to struct timeval */
773  tv.tv_sec = value / 1000;
774  tv.tv_usec = (value % 1000) * 1000;
775 
776  if (setsockopt( netconn->socket, SOL_SOCKET, send ? SO_SNDTIMEO : SO_RCVTIMEO, (void*)&tv, sizeof(tv) ) == -1)
777  {
778  WARN("setsockopt failed (%s)\n", strerror( errno ));
779  return sock_get_error( errno );
780  }
781  return ERROR_SUCCESS;
782 }
#define ERROR_SUCCESS
Definition: deptool.c:10
#define WARN(fmt,...)
Definition: debug.h:111
unsigned long tv_sec
Definition: linux.h:1738
static int sock_get_error(int err)
Definition: net.c:77
int errno
#define SOL_SOCKET
Definition: winsock.h:398
const char * strerror(int err)
Definition: compat_str.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
#define SO_RCVTIMEO
Definition: winsock.h:193
INT WSAAPI send(IN SOCKET s, IN CONST CHAR FAR *buf, IN INT len, IN INT flags)
Definition: send.c:23
#define SO_SNDTIMEO
Definition: winsock.h:192

Referenced by open_connection(), and WinHttpSetTimeouts().

◆ netconn_unload()

void netconn_unload ( void  )

Definition at line 289 of file net.c.

290 {
291 #ifndef HAVE_GETADDRINFO
293 #endif
294 #ifdef __REACTOS__
295  if(winsock_initialized)
296  WSACleanup();
297 #endif
298 }
static CRITICAL_SECTION cs_gethostbyname
Definition: net.c:64
INT WSAAPI WSACleanup(VOID)
Definition: startup.c:60
void WINAPI DeleteCriticalSection(PCRITICAL_SECTION)

Referenced by DllMain().

◆ process_header()

BOOL process_header ( request_t request,
LPCWSTR  field,
LPCWSTR  value,
DWORD  flags,
BOOL  request_only 
)

Definition at line 409 of file request.c.

410 {
411  int index;
412  header_t hdr;
413 
414  TRACE("%s: %s 0x%08x\n", debugstr_w(field), debugstr_w(value), flags);
415 
416  if ((index = get_header_index( request, field, 0, request_only )) >= 0)
417  {
419  }
420 
422  {
423  if (index >= 0)
424  {
426  if (!value || !value[0]) return TRUE;
427  }
428  else if (!(flags & WINHTTP_ADDREQ_FLAG_ADD))
429  {
431  return FALSE;
432  }
433 
434  hdr.field = (LPWSTR)field;
435  hdr.value = (LPWSTR)value;
436  hdr.is_request = request_only;
437  return insert_header( request, &hdr );
438  }
439  else if (value)
440  {
441 
443  index >= 0)
444  {
445  WCHAR *tmp;
446  int len, len_orig, len_value;
447  header_t *header = &request->headers[index];
448 
449  len_orig = strlenW( header->value );
450  len_value = strlenW( value );
451 
452  len = len_orig + len_value + 2;
453  if (!(tmp = heap_realloc( header->value, (len + 1) * sizeof(WCHAR) ))) return FALSE;
454  header->value = tmp;
455  header->value[len_orig++] = (flags & WINHTTP_ADDREQ_FLAG_COALESCE_WITH_COMMA) ? ',' : ';';
456  header->value[len_orig++] = ' ';
457 
458  memcpy( &header->value[len_orig], value, len_value * sizeof(WCHAR) );
459  header->value[len] = 0;
460  return TRUE;
461  }
462  else
463  {
464  hdr.field = (LPWSTR)field;
465  hdr.value = (LPWSTR)value;
466  hdr.is_request = request_only;
467  return insert_header( request, &hdr );
468  }
469  }
470 
471  return TRUE;
472 }
#define TRUE
Definition: types.h:120
char hdr[14]
Definition: iptest.cpp:33
WINE_UNICODE_INLINE unsigned int strlenW(const WCHAR *str)
Definition: unicode.h:212
#define WINHTTP_ADDREQ_FLAG_ADD
Definition: winhttp.h:84
#define WINHTTP_ADDREQ_FLAG_REPLACE
Definition: winhttp.h:88
#define WINHTTP_ADDREQ_FLAG_COALESCE_WITH_COMMA
Definition: winhttp.h:85
static void * heap_realloc(void *mem, size_t len)
Definition: appwiz.h:70
static BOOL delete_header(request_t *request, DWORD index)
Definition: request.c:395
#define debugstr_w
Definition: kernel32.h:32
GLuint index
Definition: glext.h:6031
#define WINHTTP_ADDREQ_FLAG_COALESCE_WITH_SEMICOLON
Definition: winhttp.h:86
#define TRACE(s)
Definition: solgame.cpp:4
__wchar_t WCHAR
Definition: xmlstorage.h:180
Definition: parser.c:43
#define WINHTTP_ADDREQ_FLAG_ADD_IF_NEW
Definition: winhttp.h:83
GLbitfield flags
Definition: glext.h:7161
#define index(s, c)
Definition: various.h:29
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
GLenum GLsizei len
Definition: glext.h:6722
static BOOL insert_header(request_t *request, header_t *header)
Definition: request.c:376
Definition: tftpd.h:85
static int get_header_index(request_t *request, LPCWSTR field, int requested_index, BOOL request_only)
Definition: request.c:356
void set_last_error(DWORD error)
Definition: session.c:59
WCHAR * LPWSTR
Definition: xmlstorage.h:184
unsigned int len
Definition: request.c:869
#define ERROR_WINHTTP_HEADER_NOT_FOUND
Definition: winhttp.h:213
struct CFHEADER header
Definition: fdi.c:101

Referenced by add_host_header(), add_request_headers(), do_authorization(), read_reply(), send_request(), and store_accept_types().

◆ release_host()

void release_host ( hostdata_t host)

Definition at line 1526 of file request.c.

1527 {
1528  LONG ref;
1529 
1531  if (!(ref = --host->ref)) list_remove( &host->entry );
1533  if (ref) return;
1534 
1535  assert( list_empty( &host->connections ) );
1536  heap_free( host->hostname );
1537  heap_free( host );
1538 }
char * host
Definition: whois.c:55
#define assert(x)
Definition: debug.h:53
void WINAPI EnterCriticalSection(LPCRITICAL_SECTION)
Definition: send.c:47
static CRITICAL_SECTION connection_pool_cs
Definition: request.c:1515
long LONG
Definition: pedump.c:60
GLenum GLint ref
Definition: glext.h:6028
__WINE_SERVER_LIST_INLINE void list_remove(struct list *elem)
Definition: list.h:108
__WINE_SERVER_LIST_INLINE int list_empty(const struct list *list)
Definition: list.h:143
void WINAPI LeaveCriticalSection(LPCRITICAL_SECTION)
static BOOL heap_free(void *mem)
Definition: appwiz.h:75

Referenced by netconn_close(), and open_connection().

◆ release_object()

void release_object ( object_header_t )

Definition at line 73 of file handle.c.

74 {
75  ULONG refs = InterlockedDecrement( &hdr->refs );
76  TRACE("object %p refcount = %d\n", hdr, refs);
77  if (!refs)
78  {
80 
82 
83  TRACE("destroying object %p\n", hdr);
84  if (hdr->type != WINHTTP_HANDLE_TYPE_SESSION) list_remove( &hdr->entry );
85  hdr->vtbl->destroy( hdr );
86  }
87 }
#define WINHTTP_HANDLE_TYPE_REQUEST
Definition: winhttp.h:432
char hdr[14]
Definition: iptest.cpp:33
void send_callback(object_header_t *hdr, DWORD status, LPVOID info, DWORD buflen)
Definition: session.c:71
#define WINHTTP_HANDLE_TYPE_SESSION
Definition: winhttp.h:430
__WINE_SERVER_LIST_INLINE void list_remove(struct list *elem)
Definition: list.h:108
#define TRACE(s)
Definition: solgame.cpp:4
#define WINHTTP_CALLBACK_STATUS_HANDLE_CLOSING
Definition: winhttp.h:391
#define InterlockedDecrement
Definition: armddk.h:52
void close_connection(request_t *request)
Definition: request.c:1803
unsigned int ULONG
Definition: retypes.h:1

Referenced by connect_destroy(), free_handle(), request_destroy(), task_proc(), WinHttpAddRequestHeaders(), WinHttpCloseHandle(), WinHttpConnect(), WinHttpGetProxyForUrl(), WinHttpOpen(), WinHttpOpenRequest(), WinHttpQueryAuthSchemes(), WinHttpQueryDataAvailable(), WinHttpQueryHeaders(), WinHttpQueryOption(), WinHttpReadData(), WinHttpReceiveResponse(), WinHttpSendRequest(), WinHttpSetCredentials(), WinHttpSetOption(), WinHttpSetStatusCallback(), WinHttpSetTimeouts(), and WinHttpWriteData().

◆ release_typelib()

void release_typelib ( void  )

Definition at line 159 of file apps.c.

160 {
161  unsigned i;
162 
163  for (i = 0; i < ARRAY_SIZE(typeinfo); i++)
164  if (typeinfo[i])
165  ITypeInfo_Release(typeinfo[i]);
166 
167  if (typelib)
168  ITypeLib_Release(typelib);
169 }
static ITypeLib * typelib
Definition: apps.c:108
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
#define ARRAY_SIZE(a)
Definition: main.h:24

Referenced by DllMain(), and process_detach().

◆ send_callback()

void send_callback ( object_header_t ,
DWORD  ,
LPVOID  ,
DWORD   
)

Definition at line 71 of file session.c.

72 {
73  if (hdr->callback && (hdr->notify_mask & status))
74  {
75  TRACE("%p, 0x%08x, %p, %u\n", hdr, status, info, buflen);
76  hdr->callback( hdr->handle, hdr->context, status, info, buflen );
77  TRACE("returning from 0x%08x callback\n", status);
78  }
79 }
char hdr[14]
Definition: iptest.cpp:33
#define TRACE(s)
Definition: solgame.cpp:4
Definition: ps.c:97

Referenced by close_connection(), handle_redirect(), open_connection(), query_data_available(), read_data(), read_more_data(), receive_response(), release_object(), send_request(), WinHttpConnect(), WinHttpOpenRequest(), and write_data().

◆ set_cookies()

BOOL set_cookies ( request_t ,
const WCHAR  
)

Definition at line 232 of file cookie.c.

233 {
234  static const WCHAR pathW[] = {'p','a','t','h',0};
235  static const WCHAR domainW[] = {'d','o','m','a','i','n',0};
236  BOOL ret = FALSE;
237  WCHAR *buffer, *p;
238  WCHAR *cookie_domain = NULL, *cookie_path = NULL;
239  struct attr *attr, *domain = NULL, *path = NULL;
240  session_t *session = request->connect->session;
241  cookie_t *cookie;
242  int len, used;
243 
244  len = strlenW( cookies );
245  if (!(buffer = heap_alloc( (len + 1) * sizeof(WCHAR) ))) return FALSE;
246  strcpyW( buffer, cookies );
247 
248  p = buffer;
249  while (*p && *p != ';') p++;
250  if (*p == ';') *p++ = 0;
251  if (!(cookie = parse_cookie( buffer )))
252  {
253  heap_free( buffer );
254  return FALSE;
255  }
256  len = strlenW( p );
257  while (len && (attr = parse_attr( p, &used )))
258  {
259  if (!strcmpiW( attr->name, domainW ))
260  {
261  domain = attr;
262  cookie_domain = attr->value;
263  }
264  else if (!strcmpiW( attr->name, pathW ))
265  {
266  path = attr;
267  cookie_path = attr->value;
268  }
269  else
270  {
271  FIXME( "unhandled attribute %s\n", debugstr_w(attr->name) );
272  free_attr( attr );
273  }
274  len -= used;
275  p += used;
276  }
277  if (!cookie_domain && !(cookie_domain = strdupW( request->connect->servername ))) goto end;
278  if (!cookie_path && !(cookie_path = strdupW( request->path ))) goto end;
279 
280  if ((p = strrchrW( cookie_path, '/' )) && p != cookie_path) *p = 0;
281  ret = add_cookie( session, cookie, cookie_domain, cookie_path );
282 
283 end:
284  if (!ret) free_cookie( cookie );
285  if (domain) free_attr( domain );
286  else heap_free( cookie_domain );
287  if (path) free_attr( path );
288  else heap_free( cookie_path );
289  heap_free( buffer );
290  return ret;
291 }
WINE_UNICODE_INLINE unsigned int strlenW(const WCHAR *str)
Definition: unicode.h:212
WCHAR * value
Definition: cookie.c:173
static WCHAR * strdupW(const WCHAR *src)
Definition: main.c:92
GLuint buffer
Definition: glext.h:5915
GLuint GLuint end
Definition: gl.h:1545
static void * heap_alloc(size_t len)
Definition: appwiz.h:65
static void free_attr(struct attr *attr)
Definition: cookie.c:176
unsigned int BOOL
Definition: ntddk_ex.h:94
#define debugstr_w
Definition: kernel32.h:32
#define FIXME(fmt,...)
Definition: debug.h:110
char path[256]
Definition: tftpd.h:94
smooth NULL
Definition: ftsmooth.c:416
c used
Definition: write.c:2877
__wchar_t WCHAR
Definition: xmlstorage.h:180
Definition: cookie.c:170
int ret
static CookieInternal * cookies
Definition: msctf.c:65
__u8 attr
Definition: mkdosfs.c:359
GLenum GLsizei len
Definition: glext.h:6722
static struct attr * parse_attr(const WCHAR *str, int *used)
Definition: cookie.c:184
#define strcmpiW(s1, s2)
Definition: unicode.h:39
WINE_UNICODE_INLINE WCHAR * strrchrW(const WCHAR *str, WCHAR ch)
Definition: unicode.h:254
WINE_UNICODE_INLINE WCHAR * strcpyW(WCHAR *dst, const WCHAR *src)
Definition: unicode.h:219
static void free_cookie(cookie_t *cookie)
Definition: cookie.c:75
Definition: services.c:325
static cookie_t * parse_cookie(const WCHAR *string)
Definition: cookie.c:131
Definition: tftpd.h:85
WCHAR * name
Definition: cookie.c:172
GLfloat GLfloat p
Definition: glext.h:8902
static BOOL add_cookie(session_t *session, cookie_t *cookie, WCHAR *domain_name, WCHAR *path)
Definition: cookie.c:105
static BOOL heap_free(void *mem)
Definition: appwiz.h:75

Referenced by record_cookies().

◆ set_last_error()

◆ set_server_for_hostname()

BOOL set_server_for_hostname ( connect_t ,
LPCWSTR  ,
INTERNET_PORT   
)

Definition at line 459 of file session.c.

460 {
461  session_t *session = connect->session;
462  BOOL ret = TRUE;
463 
464  if (session->proxy_server && !should_bypass_proxy(session, server))
465  {
466  LPCWSTR colon;
467 
468  if ((colon = strchrW( session->proxy_server, ':' )))
469  {
470  if (!connect->servername || strncmpiW( connect->servername,
471  session->proxy_server, colon - session->proxy_server - 1 ))
472  {
473  heap_free( connect->servername );
474  connect->resolved = FALSE;
475  if (!(connect->servername = heap_alloc(
476  (colon - session->proxy_server + 1) * sizeof(WCHAR) )))
477  {
478  ret = FALSE;
479  goto end;
480  }
481  memcpy( connect->servername, session->proxy_server,
482  (colon - session->proxy_server) * sizeof(WCHAR) );
483  connect->servername[colon - session->proxy_server] = 0;
484  if (*(colon + 1))
485  connect->serverport = atoiW( colon + 1 );
486  else
487  connect->serverport = INTERNET_DEFAULT_PORT;
488  }
489  }
490  else
491  {
492  if (!connect->servername || strcmpiW( connect->servername,
493  session->proxy_server ))
494  {
495  heap_free( connect->servername );
496  connect->resolved = FALSE;
497  if (!(connect->servername = strdupW( session->proxy_server )))
498  {
499  ret = FALSE;
500  goto end;
501  }
502  connect->serverport = INTERNET_DEFAULT_PORT;
503  }
504  }
505  }
506  else if (server)
507  {
508  heap_free( connect->servername );
509  connect->resolved = FALSE;
510  if (!(connect->servername = strdupW( server )))
511  {
512  ret = FALSE;
513  goto end;
514  }
515  connect->serverport = port;
516  }
517 end:
518  return ret;
519 }
#define TRUE
Definition: types.h:120
static rfbScreenInfoPtr server
Definition: vnc.c:74
const WCHAR * LPCWSTR
Definition: xmlstorage.h:185
static WCHAR * strdupW(const WCHAR *src)
Definition: main.c:92
WINE_UNICODE_INLINE WCHAR * strchrW(const WCHAR *str, WCHAR ch)
Definition: unicode.h:248
GLuint GLuint end
Definition: gl.h:1545
#define strncmpiW(s1, s2, n)
Definition: unicode.h:40
INT WSAAPI connect(IN SOCKET s, IN CONST struct sockaddr *name, IN INT namelen)
Definition: sockctrl.c:23
static void * heap_alloc(size_t len)
Definition: appwiz.h:65
unsigned int BOOL
Definition: ntddk_ex.h:94
LPWSTR proxy_server
__wchar_t WCHAR
Definition: xmlstorage.h:180
int ret
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
#define strcmpiW(s1, s2)
Definition: unicode.h:39
#define INTERNET_DEFAULT_PORT
Definition: winhttp.h:35
USHORT port
Definition: uri.c:227
static BOOL should_bypass_proxy(session_t *session, LPCWSTR server)
Definition: session.c:428
WINE_UNICODE_INLINE int atoiW(const WCHAR *str)
Definition: unicode.h:315
static BOOL heap_free(void *mem)
Definition: appwiz.h:75

Referenced by handle_redirect(), and WinHttpConnect().

◆ strdupAW()

static WCHAR* strdupAW ( const char src)
inlinestatic

Definition at line 341 of file winhttp_private.h.

342 {
343  WCHAR *dst = NULL;
344  if (src)
345  {
346  DWORD len = MultiByteToWideChar( CP_ACP, 0, src, -1, NULL, 0 );
347  if ((dst = heap_alloc( len * sizeof(WCHAR) )))
348  MultiByteToWideChar( CP_ACP, 0, src, -1, dst, len );
349  }
350  return dst;
351 }
#define CP_ACP
Definition: compat.h:99
static void * heap_alloc(size_t len)
Definition: appwiz.h:65
smooth NULL
Definition: ftsmooth.c:416
__wchar_t WCHAR
Definition: xmlstorage.h:180
unsigned long DWORD
Definition: ntddk_ex.h:95
GLenum GLsizei len
Definition: glext.h:6722
GLenum src
Definition: glext.h:6340
GLenum GLenum dst
Definition: glext.h:6340
#define MultiByteToWideChar
Definition: compat.h:100

◆ strdupW()

static WCHAR* strdupW ( const WCHAR src)
inlinestatic

Definition at line 331 of file winhttp_private.h.

332 {
333  WCHAR *dst;
334 
335  if (!src) return NULL;
336  dst = heap_alloc( (strlenW( src ) + 1) * sizeof(WCHAR) );
337  if (dst) strcpyW( dst, src );
338  return dst;
339 }
WINE_UNICODE_INLINE unsigned int strlenW(const WCHAR *str)
Definition: unicode.h:212
static void * heap_alloc(size_t len)
Definition: appwiz.h:65
smooth NULL
Definition: ftsmooth.c:416
__wchar_t WCHAR
Definition: xmlstorage.h:180
GLenum src
Definition: glext.h:6340
WINE_UNICODE_INLINE WCHAR * strcpyW(WCHAR *dst, const WCHAR *src)
Definition: unicode.h:219
GLenum GLenum dst
Definition: glext.h:6340

◆ strdupWA()

static char* strdupWA ( const WCHAR src)
inlinestatic

Definition at line 353 of file winhttp_private.h.

354 {
355  char *dst = NULL;
356  if (src)
357  {
358  int len = WideCharToMultiByte( CP_ACP, 0, src, -1, NULL, 0, NULL, NULL );
359  if ((dst = heap_alloc( len )))
360  WideCharToMultiByte( CP_ACP, 0, src, -1, dst, len, NULL, NULL );
361  }
362  return dst;
363 }
#define WideCharToMultiByte
Definition: compat.h:101
#define CP_ACP
Definition: compat.h:99
static void * heap_alloc(size_t len)
Definition: appwiz.h:65
smooth NULL
Definition: ftsmooth.c:416
GLenum GLsizei len
Definition: glext.h:6722
GLenum src
Definition: glext.h:6340
GLenum GLenum dst
Definition: glext.h:6340

◆ strdupWA_sized()

static char* strdupWA_sized ( const WCHAR src,
DWORD  size 
)
inlinestatic

Definition at line 365 of file winhttp_private.h.

366 {
367  char *dst = NULL;
368  if (src)
369  {
370  int len = WideCharToMultiByte( CP_ACP, 0, src, size, NULL, 0, NULL, NULL ) + 1;
371  if ((dst = heap_alloc( len )))
372  {
374  dst[len - 1] = 0;
375  }
376  }
377  return dst;
378 }
#define WideCharToMultiByte
Definition: compat.h:101
#define CP_ACP
Definition: compat.h:99
static void * heap_alloc(size_t len)
Definition: appwiz.h:65
smooth NULL
Definition: ftsmooth.c:416
GLsizeiptr size
Definition: glext.h:5919
GLenum GLsizei len
Definition: glext.h:6722
GLenum src
Definition: glext.h:6340
GLenum GLenum dst
Definition: glext.h:6340

Referenced by run_script().

◆ WinHttpRequest_create()

HRESULT WinHttpRequest_create ( void **  )

Definition at line 4484 of file request.c.

4485 {
4486  struct winhttp_request *request;
4487 
4488  TRACE("%p\n", obj);
4489 
4490  if (!(request = heap_alloc( sizeof(*request) ))) return E_OUTOFMEMORY;
4491  request->IWinHttpRequest_iface.lpVtbl = &winhttp_request_vtbl;
4492  request->refs = 1;
4494  request->proxy.lpszProxy = NULL;
4495  request->proxy.lpszProxyBypass = NULL;
4496  request->url_codepage = CP_UTF8;
4498  request->cs.DebugInfo->Spare[0] = (DWORD_PTR)(__FILE__ ": winhttp_request.cs");
4499 
4500  *obj = &request->IWinHttpRequest_iface;
4501  TRACE("returning iface %p\n", *obj);
4502  return S_OK;
4503 }
#define DWORD_PTR
Definition: treelist.c:76
static void * heap_alloc(size_t len)
Definition: appwiz.h:65
#define E_OUTOFMEMORY
Definition: ddrawi.h:100
#define CP_UTF8
Definition: nls.h:20
VOID WINAPI InitializeCriticalSection(OUT LPCRITICAL_SECTION lpCriticalSection)
Definition: synch.c:751
smooth NULL
Definition: ftsmooth.c:416
static const struct IWinHttpRequestVtbl winhttp_request_vtbl
Definition: request.c:4454
#define TRACE(s)
Definition: solgame.cpp:4
#define S_OK
Definition: intsafe.h:59
Definition: tftpd.h:85

Variable Documentation

◆ chunkedW

const WCHAR chunkedW[] = {'c','h','u','n','k','e','d',0}
static

Definition at line 56 of file winhttp_private.h.

Referenced by set_content_length().

◆ DECLSPEC_HIDDEN

HINSTANCE winhttp_instance DECLSPEC_HIDDEN

Definition at line 155 of file crypt32_private.h.

◆ getW

const WCHAR getW[] = {'G','E','T',0}
static

Definition at line 50 of file winhttp_private.h.

◆ headW

const WCHAR headW[] = {'H','E','A','D',0}
static

Definition at line 52 of file winhttp_private.h.

◆ http1_0

const WCHAR http1_0[] = {'H','T','T','P','/','1','.','0',0}
static

Definition at line 54 of file winhttp_private.h.

Referenced by finished_reading().

◆ http1_1

const WCHAR http1_1[] = {'H','T','T','P','/','1','.','1',0}
static

Definition at line 55 of file winhttp_private.h.

Referenced by secure_proxy_connect(), and WinHttpOpenRequest().

◆ postW

const WCHAR postW[] = {'P','O','S','T',0}
static

◆ size

Initial value:
{
GLsizeiptr size
Definition: glext.h:5919
#define GetProcessHeap()
Definition: compat.h:395
#define HeapReAlloc
Definition: compat.h:393
#define HEAP_ZERO_MEMORY
Definition: compat.h:123
Definition: mem.c:156

Definition at line 327 of file winhttp_private.h.

◆ slashW

const WCHAR slashW[] = {'/',0}
static

Definition at line 53 of file winhttp_private.h.