• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /* GIO - GLib Input, Output and Streaming Library
2  *
3  * Copyright (C) 2006-2007 Red Hat, Inc.
4  * Copyright (C) 2008 Novell, Inc.
5  *
6  * This library is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU Lesser General Public
8  * License as published by the Free Software Foundation; either
9  * version 2.1 of the License, or (at your option) any later version.
10  *
11  * This library is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14  * Lesser General Public License for more details.
15  *
16  * You should have received a copy of the GNU Lesser General
17  * Public License along with this library; if not, see <http://www.gnu.org/licenses/>.
18  *
19  * Author: Alexander Larsson <alexl@redhat.com>
20  * Author: Tor Lillqvist <tml@novell.com>
21  */
22 
23 #ifndef __G_WINHTTP_VFS_H__
24 #define __G_WINHTTP_VFS_H__
25 
26 #include <gio/giotypes.h>
27 #include <gio/gvfs.h>
28 
29 #include <windows.h>
30 
31 #include "winhttp.h"
32 
33 G_BEGIN_DECLS
34 
35 #define G_TYPE_WINHTTP_VFS                      (_g_winhttp_vfs_get_type ())
36 #define G_WINHTTP_VFS(obj)                      (G_TYPE_CHECK_INSTANCE_CAST ((obj), G_TYPE_WINHTTP_VFS, GWinHttpVfs))
37 #define G_WINHTTP_VFS_CLASS(klass)              (G_TYPE_CHECK_CLASS_CAST ((klass), G_TYPE_WINHTTP_VFS, GWinHttpVfsClass))
38 #define G_IS_WINHTTP_VFS(obj)                   (G_TYPE_CHECK_INSTANCE_TYPE ((obj), G_TYPE_WINHTTP_VFS))
39 #define G_IS_WINHTTP_VFS_CLASS(klass)           (G_TYPE_CHECK_CLASS_TYPE ((klass), G_TYPE_WINHTTP_VFS))
40 #define G_WINHTTP_VFS_GET_CLASS(obj)            (G_TYPE_INSTANCE_GET_CLASS ((obj), G_TYPE_WINHTTP_VFS, GWinHttpVfsClass))
41 
42 typedef struct _GWinHttpVfs       GWinHttpVfs;
43 typedef struct _GWinHttpDllFuncs  GWinHttpDllFuncs;
44 typedef struct _GWinHttpVfsClass  GWinHttpVfsClass;
45 
46 struct _GWinHttpVfs
47 {
48   GVfs parent;
49 
50   GVfs *wrapped_vfs;
51   HINTERNET session;
52 };
53 
54 struct _GWinHttpDllFuncs
55 {
56   BOOL (WINAPI *pWinHttpCloseHandle) (HINTERNET);
57   BOOL (WINAPI *pWinHttpCrackUrl) (LPCWSTR,DWORD,DWORD,LPURL_COMPONENTS);
58   HINTERNET (WINAPI *pWinHttpConnect) (HINTERNET,LPCWSTR,INTERNET_PORT,DWORD);
59   BOOL (WINAPI *pWinHttpCreateUrl) (LPURL_COMPONENTS,DWORD,LPWSTR,LPDWORD);
60   HINTERNET (WINAPI *pWinHttpOpen) (LPCWSTR,DWORD,LPCWSTR,LPCWSTR,DWORD);
61   HINTERNET (WINAPI *pWinHttpOpenRequest) (HINTERNET,LPCWSTR,LPCWSTR,LPCWSTR,LPCWSTR,LPCWSTR*,DWORD);
62   BOOL (WINAPI *pWinHttpQueryDataAvailable) (HINTERNET,LPDWORD);
63   BOOL (WINAPI *pWinHttpQueryHeaders) (HINTERNET,DWORD,LPCWSTR,LPVOID,LPDWORD,LPDWORD);
64   BOOL (WINAPI *pWinHttpReadData) (HINTERNET,LPVOID,DWORD,LPDWORD);
65   BOOL (WINAPI *pWinHttpReceiveResponse) (HINTERNET,LPVOID);
66   BOOL (WINAPI *pWinHttpSendRequest) (HINTERNET,LPCWSTR,DWORD,LPVOID,DWORD,DWORD,DWORD_PTR);
67   BOOL (WINAPI *pWinHttpWriteData) (HINTERNET,LPCVOID,DWORD,LPDWORD);
68 };
69 
70 struct _GWinHttpVfsClass
71 {
72   GVfsClass parent_class;
73 
74   /* As there is no import library for winhttp.dll in mingw, and
75    * winhttp.dll isn't present on Windows 2000 anyway, we must look up
76    * the functions we need dynamically. Store the pointers here.
77    */
78   GWinHttpDllFuncs *funcs;
79 };
80 
81 
82 GType   _g_winhttp_vfs_get_type  (void) G_GNUC_CONST;
83 
84 GVfs *_g_winhttp_vfs_new (void);
85 
86 char *_g_winhttp_error_message (DWORD error_code);
87 
88 void _g_winhttp_set_error (GError     **error,
89                            DWORD        error_code,
90                            const char  *what);
91 
92 gboolean _g_winhttp_response (GWinHttpVfs *vfs,
93                               HINTERNET    request,
94                               GError     **error,
95                               const char  *what);
96 
97 gboolean _g_winhttp_query_header (GWinHttpVfs *vfs,
98                                   HINTERNET    request,
99                                   const char  *request_description,
100                                   DWORD        which_header,
101                                   wchar_t    **header,
102                                   GError     **error);
103 
104 G_END_DECLS
105 
106 #endif /* __G_WINHTTP_VFS_H__ */
107