aboutsummaryrefslogtreecommitdiff
path: root/src/include/gnunet_curl_lib.h
diff options
context:
space:
mode:
authorMarcello Stanisci <stanisci.m@gmail.com>2018-10-17 12:33:50 +0200
committerMarcello Stanisci <stanisci.m@gmail.com>2018-10-17 12:33:50 +0200
commit25b9d3dfa6fb538627e6cd8ed4b5741e18b752d9 (patch)
tree6a68f3bbac5ae7b438d6cfd99997e9aa180a408c /src/include/gnunet_curl_lib.h
parent564df39557f1a69280f36ff5173807856ff41067 (diff)
downloadgnunet-25b9d3dfa6fb538627e6cd8ed4b5741e18b752d9.tar.gz
gnunet-25b9d3dfa6fb538627e6cd8ed4b5741e18b752d9.zip
curl: abstracting response's parser & cleaner.
Diffstat (limited to 'src/include/gnunet_curl_lib.h')
-rw-r--r--src/include/gnunet_curl_lib.h59
1 files changed, 59 insertions, 0 deletions
diff --git a/src/include/gnunet_curl_lib.h b/src/include/gnunet_curl_lib.h
index 2b2442a52..9bf798bca 100644
--- a/src/include/gnunet_curl_lib.h
+++ b/src/include/gnunet_curl_lib.h
@@ -49,6 +49,52 @@
49typedef void 49typedef void
50(*GNUNET_CURL_RescheduleCallback)(void *cls); 50(*GNUNET_CURL_RescheduleCallback)(void *cls);
51 51
52/**
53 * @brief Buffer data structure we use to buffer the HTTP download
54 * before giving it to the JSON parser.
55 */
56struct GNUNET_CURL_DownloadBuffer
57{
58
59 /**
60 * Download buffer
61 */
62 void *buf;
63
64 /**
65 * The size of the download buffer
66 */
67 size_t buf_size;
68
69 /**
70 * Error code (based on libc errno) if we failed to download
71 * (i.e. response too large).
72 */
73 int eno;
74
75};
76
77
78/**
79 * Parses the raw response we got from the Web server.
80 *
81 * @param db the raw data
82 * @param eh handle
83 * @param response_code HTTP response code
84 * @return the parsed object
85 */
86typedef void *
87(*GNUNET_CURL_RawParser) (struct GNUNET_CURL_DownloadBuffer *db,
88 CURL *eh,
89 long *response_code);
90
91/**
92 * Deallocate the response.
93 *
94 * @param response object to clean
95 */
96typedef void
97(*GNUNET_CURL_ResponseCleaner) (void *response);
52 98
53/** 99/**
54 * Initialise this library. This function should be called before using any of 100 * Initialise this library. This function should be called before using any of
@@ -119,6 +165,19 @@ GNUNET_CURL_perform (struct GNUNET_CURL_Context *ctx);
119 165
120 166
121/** 167/**
168 * Run the main event loop for the Taler interaction.
169 *
170 * @param ctx the library context
171 * @param rp parses the raw response returned from
172 * the Web server.
173 * @param rc cleans/frees the response
174 */
175void
176GNUNET_CURL_perform2 (struct GNUNET_CURL_Context *ctx,
177 GNUNET_CURL_RawParser rp,
178 GNUNET_CURL_ResponseCleaner rc);
179
180/**
122 * Cleanup library initialisation resources. This function should be called 181 * Cleanup library initialisation resources. This function should be called
123 * after using this library to cleanup the resources occupied during library's 182 * after using this library to cleanup the resources occupied during library's
124 * initialisation. 183 * initialisation.