diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/regex/regex_api.c | 27 |
1 files changed, 18 insertions, 9 deletions
diff --git a/src/regex/regex_api.c b/src/regex/regex_api.c index ebb824f61..09b3fd68d 100644 --- a/src/regex/regex_api.c +++ b/src/regex/regex_api.c | |||
@@ -30,6 +30,8 @@ | |||
30 | #include "gnunet_regex_service.h" | 30 | #include "gnunet_regex_service.h" |
31 | #include "regex_ipc.h" | 31 | #include "regex_ipc.h" |
32 | 32 | ||
33 | #define LOG(kind,...) GNUNET_log_from (kind, "regex-api",__VA_ARGS__) | ||
34 | |||
33 | /** | 35 | /** |
34 | * Handle to store cached data about a regex announce. | 36 | * Handle to store cached data about a regex announce. |
35 | */ | 37 | */ |
@@ -104,16 +106,14 @@ handle_a_reconnect (void *cls, | |||
104 | 106 | ||
105 | 107 | ||
106 | /** | 108 | /** |
107 | * Announce the given peer under the given regular expression. Does | 109 | * Announce the given peer under the given regular expression. |
108 | * not free resources, must call #GNUNET_REGEX_announce_cancel for | ||
109 | * that. | ||
110 | * | 110 | * |
111 | * @param cfg configuration to use | 111 | * @param cfg configuration to use |
112 | * @param regex Regular expression to announce. | 112 | * @param regex Regular expression to announce. |
113 | * @param refresh_delay after what delay should the announcement be repeated? | 113 | * @param refresh_delay after what delay should the announcement be repeated? |
114 | * @param compression How many characters per edge can we squeeze? | 114 | * @param compression How many characters per edge can we squeeze? |
115 | * @return Handle to reuse o free cached resources. | 115 | * @return Handle to reuse o free cached resources. |
116 | * Must be freed by calling #GNUNET_REGEX_announce_cancel. | 116 | * Must be freed by calling #GNUNET_REGEX_announce_cancel(). |
117 | */ | 117 | */ |
118 | struct GNUNET_REGEX_Announcement * | 118 | struct GNUNET_REGEX_Announcement * |
119 | GNUNET_REGEX_announce (const struct GNUNET_CONFIGURATION_Handle *cfg, | 119 | GNUNET_REGEX_announce (const struct GNUNET_CONFIGURATION_Handle *cfg, |
@@ -133,6 +133,9 @@ GNUNET_REGEX_announce (const struct GNUNET_CONFIGURATION_Handle *cfg, | |||
133 | GNUNET_break (0); | 133 | GNUNET_break (0); |
134 | return NULL; | 134 | return NULL; |
135 | } | 135 | } |
136 | LOG (GNUNET_ERROR_TYPE_DEBUG, | ||
137 | "Starting REGEX announcement %s\n", | ||
138 | regex); | ||
136 | a = GNUNET_malloc (sizeof (struct GNUNET_REGEX_Announcement) + slen); | 139 | a = GNUNET_malloc (sizeof (struct GNUNET_REGEX_Announcement) + slen); |
137 | a->cfg = cfg; | 140 | a->cfg = cfg; |
138 | a->client = GNUNET_CLIENT_connect ("regex", cfg); | 141 | a->client = GNUNET_CLIENT_connect ("regex", cfg); |
@@ -233,7 +236,7 @@ retry_search (struct GNUNET_REGEX_Search *s) | |||
233 | * We got a response or disconnect after asking regex | 236 | * We got a response or disconnect after asking regex |
234 | * to do the search. Handle it. | 237 | * to do the search. Handle it. |
235 | * | 238 | * |
236 | * @param cls the 'struct GNUNET_REGEX_Search' to retry | 239 | * @param cls the `struct GNUNET_REGEX_Search` to handle reply for |
237 | * @param msg NULL on disconnect, otherwise presumably a response | 240 | * @param msg NULL on disconnect, otherwise presumably a response |
238 | */ | 241 | */ |
239 | static void | 242 | static void |
@@ -269,6 +272,9 @@ handle_search_response (void *cls, | |||
269 | &handle_search_response, s, | 272 | &handle_search_response, s, |
270 | GNUNET_TIME_UNIT_FOREVER_REL); | 273 | GNUNET_TIME_UNIT_FOREVER_REL); |
271 | pid = &result->id; | 274 | pid = &result->id; |
275 | LOG (GNUNET_ERROR_TYPE_DEBUG, | ||
276 | "Got regex result %s\n", | ||
277 | GNUNET_i2s (pid)); | ||
272 | s->callback (s->callback_cls, | 278 | s->callback (s->callback_cls, |
273 | pid, | 279 | pid, |
274 | &pid[1], gpl, | 280 | &pid[1], gpl, |
@@ -285,7 +291,7 @@ handle_search_response (void *cls, | |||
285 | 291 | ||
286 | /** | 292 | /** |
287 | * Search for a peer offering a regex matching certain string in the DHT. | 293 | * Search for a peer offering a regex matching certain string in the DHT. |
288 | * The search runs until GNUNET_REGEX_search_cancel is called, even if results | 294 | * The search runs until #GNUNET_REGEX_search_cancel() is called, even if results |
289 | * are returned. | 295 | * are returned. |
290 | * | 296 | * |
291 | * @param cfg configuration to use | 297 | * @param cfg configuration to use |
@@ -293,7 +299,7 @@ handle_search_response (void *cls, | |||
293 | * @param callback Callback for found peers. | 299 | * @param callback Callback for found peers. |
294 | * @param callback_cls Closure for @c callback. | 300 | * @param callback_cls Closure for @c callback. |
295 | * @return Handle to stop search and free resources. | 301 | * @return Handle to stop search and free resources. |
296 | * Must be freed by calling GNUNET_REGEX_search_cancel. | 302 | * Must be freed by calling #GNUNET_REGEX_search_cancel(). |
297 | */ | 303 | */ |
298 | struct GNUNET_REGEX_Search * | 304 | struct GNUNET_REGEX_Search * |
299 | GNUNET_REGEX_search (const struct GNUNET_CONFIGURATION_Handle *cfg, | 305 | GNUNET_REGEX_search (const struct GNUNET_CONFIGURATION_Handle *cfg, |
@@ -304,6 +310,9 @@ GNUNET_REGEX_search (const struct GNUNET_CONFIGURATION_Handle *cfg, | |||
304 | struct GNUNET_REGEX_Search *s; | 310 | struct GNUNET_REGEX_Search *s; |
305 | size_t slen; | 311 | size_t slen; |
306 | 312 | ||
313 | LOG (GNUNET_ERROR_TYPE_DEBUG, | ||
314 | "Starting regex search for %s\n", | ||
315 | string); | ||
307 | slen = strlen (string) + 1; | 316 | slen = strlen (string) + 1; |
308 | s = GNUNET_new (struct GNUNET_REGEX_Search); | 317 | s = GNUNET_new (struct GNUNET_REGEX_Search); |
309 | s->cfg = cfg; | 318 | s->cfg = cfg; |
@@ -325,9 +334,9 @@ GNUNET_REGEX_search (const struct GNUNET_CONFIGURATION_Handle *cfg, | |||
325 | 334 | ||
326 | 335 | ||
327 | /** | 336 | /** |
328 | * Stop search and free all data used by a GNUNET_REGEX_search call. | 337 | * Stop search and free all data used by a #GNUNET_REGEX_search() call. |
329 | * | 338 | * |
330 | * @param s Handle returned by a previous GNUNET_REGEX_search call. | 339 | * @param s Handle returned by a previous #GNUNET_REGEX_search() call. |
331 | */ | 340 | */ |
332 | void | 341 | void |
333 | GNUNET_REGEX_search_cancel (struct GNUNET_REGEX_Search *s) | 342 | GNUNET_REGEX_search_cancel (struct GNUNET_REGEX_Search *s) |