push d2761731c253bfe9a5961252b22d8cea093833f5
[wine/hacks.git] / dlls / winhttp / winhttp_private.h
blob549d9cd2a049412808c6f220e258bb1ec548bfa4
1 /*
2 * Copyright 2008 Hans Leidekker for CodeWeavers
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
19 #ifndef _WINE_WINHTTP_PRIVATE_H_
20 #define _WINE_WINHTTP_PRIVATE_H_
22 #ifndef __WINE_CONFIG_H
23 # error You must include config.h to use this header
24 #endif
26 #include "wine/list.h"
27 #include "wine/unicode.h"
29 #ifdef HAVE_NETDB_H
30 # include <netdb.h>
31 #endif
33 typedef struct _object_header_t object_header_t;
35 typedef struct
37 void (*destroy)( object_header_t * );
38 BOOL (*query_option)( object_header_t *, DWORD, void *, DWORD *, BOOL );
39 BOOL (*set_option)( object_header_t *, DWORD, void *, DWORD );
40 } object_vtbl_t;
42 struct _object_header_t
44 DWORD type;
45 HINTERNET handle;
46 const object_vtbl_t *vtbl;
47 DWORD flags;
48 DWORD error;
49 DWORD_PTR context;
50 LONG refs;
51 WINHTTP_STATUS_CALLBACK callback;
52 DWORD notify_mask;
53 struct list entry;
54 struct list children;
57 typedef struct
59 object_header_t hdr;
60 LPWSTR agent;
61 DWORD access;
62 LPWSTR proxy_server;
63 LPWSTR proxy_bypass;
64 LPWSTR proxy_username;
65 LPWSTR proxy_password;
66 } session_t;
68 typedef struct
70 object_header_t hdr;
71 session_t *session;
72 LPWSTR hostname; /* final destination of the request */
73 LPWSTR servername; /* name of the server we directly connect to */
74 LPWSTR username;
75 LPWSTR password;
76 INTERNET_PORT hostport;
77 INTERNET_PORT serverport;
78 struct sockaddr_in sockaddr;
79 } connect_t;
81 typedef struct
83 int socket;
84 char *peek_msg;
85 char *peek_msg_mem;
86 size_t peek_len;
87 } netconn_t;
89 typedef struct
91 LPWSTR field;
92 LPWSTR value;
93 BOOL is_request; /* part of request headers? */
94 } header_t;
96 typedef struct
98 object_header_t hdr;
99 connect_t *connect;
100 LPWSTR verb;
101 LPWSTR path;
102 LPWSTR version;
103 LPWSTR raw_headers;
104 netconn_t netconn;
105 LPWSTR status_text;
106 DWORD content_length; /* total number of bytes to be read (per chunk) */
107 DWORD content_read; /* bytes read so far */
108 header_t *headers;
109 DWORD num_headers;
110 } request_t;
112 object_header_t *addref_object( object_header_t * );
113 object_header_t *grab_object( HINTERNET );
114 void release_object( object_header_t * );
115 HINTERNET alloc_handle( object_header_t * );
116 BOOL free_handle( HINTERNET );
118 void set_last_error( DWORD );
119 void send_callback( object_header_t *, DWORD, LPVOID, DWORD );
121 static inline void *heap_alloc( SIZE_T size )
123 return HeapAlloc( GetProcessHeap(), 0, size );
126 static inline void *heap_alloc_zero( SIZE_T size )
128 return HeapAlloc( GetProcessHeap(), HEAP_ZERO_MEMORY, size );
131 static inline void *heap_realloc( LPVOID mem, SIZE_T size )
133 return HeapReAlloc( GetProcessHeap(), 0, mem, size );
136 static inline void *heap_realloc_zero( LPVOID mem, SIZE_T size )
138 return HeapReAlloc( GetProcessHeap(), HEAP_ZERO_MEMORY, mem, size );
141 static inline BOOL heap_free( LPVOID mem )
143 return HeapFree( GetProcessHeap(), 0, mem );
146 static inline WCHAR *strdupW( const WCHAR *src )
148 WCHAR *dst;
150 if (!src) return NULL;
151 dst = heap_alloc( (strlenW( src ) + 1) * sizeof(WCHAR) );
152 if (dst) strcpyW( dst, src );
153 return dst;
156 #endif /* _WINE_WINHTTP_PRIVATE_H_ */