1 Title: Overview: Network
3 About: Network Interface
5 Allows overriding the default use of <libcurl at http://curl.haxx.se/libcurl/c/>
6 in libquvi. For example, an application could use <libsoup at
7 http://live.gnome.org/LibSoup> instead of libcurl.
11 An application must set the necessary properties in its corresponding
12 callbacks. Besides the <Common properties>, each callback is expected to
13 set any additional properties listed below.
15 About: Common properties
18 quvi_net_setprop(net_handle, QUVI_NET_PROPERTY_RESPONSECODE, resp_code);
21 Common properties that are expected to be set by all callbacks.
23 * <QUVI_NET_PROPERTY_RESPONSECODE>
25 About: quvi_callback_fetch
28 quvi_setopt(session_handle, QUVIOPT_FETCHFUNCTION, &fetch_callback_func);
31 In addition to the <Common properties>, must set
32 * <QUVI_NET_PROPERTY_CONTENT>
35 * Either <QUVI_OK> or <QUVI_CALLBACK> if an error occurred
37 About: quvi_callback_resolve
40 quvi_setopt(session_handle, QUVIOPT_RESOLVEFUNCTION, &resolve_callback_func);
43 In addition to the <Common properties> -- *if* a redirection to another
44 location was found, *then* must set
45 * <QUVI_NET_PROPERTY_REDIRECTURL>
49 This callback should return <QUVI_CALLBACK> *only* if an
50 unrecoverable error occurred, e.g. a network error. Return <QUVI_OK> in
51 all other cases, including those in which a redirection URL was not
55 * Either <QUVI_OK> or <QUVI_CALLBACK> if an (e.g. network) error occurred
56 * Return <QUVI_OK> even if a redirection URL was not found
58 About: quvi_callback_verify
61 quvi_setopt(session_handle, QUVIOPT_VERIFYFUNCTION, &verify_callback_func);
64 In addition to the <Common properties>, must set
65 * <QUVI_NET_PROPERTY_CONTENTTYPE>
66 * <QUVI_NET_PROPERTY_CONTENTLENGTH>
69 * Either <QUVI_OK> or <QUVI_CALLBACK> if an error occurred
73 Basic example. This example assumes that a fictional `do_fetch' function
74 fetches the data over the network. The callback then relays the data
75 and any errors back to libquvi. Some error checks omitted for brewity.
78 static QUVIcode fetch_callback(quvi_net_t net_handle)
80 char *url, *reason, *content;
84 quvi_net_getprop(net_handle, QUVI_NET_PROPERTY_URL, &url);
86 fetch_ok = do_fetch(url, &content, &resp_code, &reason);
88 quvi_net_setprop(net_handle, QUVI_NET_PROPERTY_RESPONSECODE, resp_code);
92 quvi_net_setprop(net_handle, QUVI_NET_PROPERTY_CONTENT, content);
96 quvi_net_seterr(net_handle, "%s (http/%d)", reason, resp_code);
98 return (QUVI_CALLBACK); /* Tell the library an error occurred */
101 int main(int argc, char **argv)
105 quvi_setopt(q, QUVIOPT_FETCHFUNCTION, &fetch_callback);