3 * Web service library with GLib integration
5 * Copyright (C) 2009-2012 Intel Corporation. All rights reserved.
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License version 2 as
9 * published by the Free Software Foundation.
11 * This program 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
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
38 typedef struct _GWeb GWeb;
39 typedef struct _GWebResult GWebResult;
40 typedef struct _GWebParser GWebParser;
42 typedef bool (*GWebResultFunc)(GWebResult *result, gpointer user_data);
44 typedef bool (*GWebRouteFunc)(const char *addr, int ai_family,
45 int if_index, gpointer user_data);
47 typedef bool (*GWebInputFunc)(const guint8 **data, gsize *length,
50 typedef void (*GWebDebugFunc)(const char *str, gpointer user_data);
52 GWeb *g_web_new(int index);
54 GWeb *g_web_ref(GWeb *web);
55 void g_web_unref(GWeb *web);
57 void g_web_set_debug(GWeb *web, GWebDebugFunc func, gpointer user_data);
59 bool g_web_supports_tls(void);
61 bool g_web_set_proxy(GWeb *web, const char *proxy);
63 bool g_web_set_address_family(GWeb *web, int family);
65 bool g_web_add_nameserver(GWeb *web, const char *address);
67 bool g_web_set_accept(GWeb *web, const char *format, ...)
68 __attribute__((format(printf, 2, 3)));
69 bool g_web_set_user_agent(GWeb *web, const char *format, ...)
70 __attribute__((format(printf, 2, 3)));
71 bool g_web_set_ua_profile(GWeb *web, const char *profile);
73 bool g_web_set_http_version(GWeb *web, const char *version);
75 void g_web_set_close_connection(GWeb *web, bool enabled);
76 bool g_web_get_close_connection(GWeb *web);
78 guint g_web_request_get(GWeb *web, const char *url,
79 GWebResultFunc func, GWebRouteFunc route,
81 guint g_web_request_post(GWeb *web, const char *url,
82 const char *type, GWebInputFunc input,
83 GWebResultFunc func, gpointer user_data);
84 guint g_web_request_post_file(GWeb *web, const char *url,
85 const char *type, const char *file,
86 GWebResultFunc func, gpointer user_data);
88 bool g_web_cancel_request(GWeb *web, guint id);
90 guint16 g_web_result_get_status(GWebResult *result);
92 bool g_web_result_get_header(GWebResult *result,
93 const char *header, const char **value);
94 bool g_web_result_get_chunk(GWebResult *result,
95 const guint8 **chunk, gsize *length);
97 typedef void (*GWebParserFunc)(const char *str, gpointer user_data);
99 GWebParser *g_web_parser_new(const char *begin, const char *end,
100 GWebParserFunc func, gpointer user_data);
102 GWebParser *g_web_parser_ref(GWebParser *parser);
103 void g_web_parser_unref(GWebParser *parser);
105 void g_web_parser_feed_data(GWebParser *parser,
106 const guint8 *data, gsize length);
107 void g_web_parser_end_data(GWebParser *parser);
113 #endif /* __G_WEB_H */