2 This file is part of GNUnet
3 (C) 2012, 2013 Christian Grothoff (and other contributing authors)
5 GNUnet is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published
7 by the Free Software Foundation; either version 3, or (at your
8 option) any later version.
10 GNUnet is distributed in the hope that it will be useful, but
11 WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 General Public License for more details.
15 You should have received a copy of the GNU General Public License
16 along with GNUnet; see the file COPYING. If not, write to the
17 Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18 Boston, MA 02111-1307, USA.
21 * @file include/gnunet_regex_service.h
22 * @brief access regex service to advertise capabilities via regex and discover
23 * respective peers using matching strings
24 * @author Maximilian Szengel
25 * @author Christian Grothoff
27 #ifndef GNUNET_REGEX_SERVICE_H
28 #define GNUNET_REGEX_SERVICE_H
30 #include "gnunet_util_lib.h"
35 #if 0 /* keep Emacsens' auto-indent happy */
42 * Constant for how many bytes the initial string regex should have.
44 #define GNUNET_REGEX_INITIAL_BYTES 24
48 * Handle to store cached data about a regex announce.
50 struct GNUNET_REGEX_Announcement;
53 * Handle to store data about a regex search.
55 struct GNUNET_REGEX_Search;
59 * Announce this peer under the given regular expression. Does
60 * not free resources, must call GNUNET_REGEX_announce_cancel for
63 * @param cfg configuration to use
64 * @param regex Regular expression to announce.
65 * @param refresh_delay after what delay should the announcement be repeated?
66 * @param compression How many characters per edge can we squeeze?
67 * @return Handle to reuse o free cached resources.
68 * Must be freed by calling GNUNET_REGEX_announce_cancel.
70 struct GNUNET_REGEX_Announcement *
71 GNUNET_REGEX_announce (const struct GNUNET_CONFIGURATION_Handle *cfg,
73 struct GNUNET_TIME_Relative refresh_delay,
74 uint16_t compression);
78 * Stop announcing the regex specified by the given handle.
80 * @param a handle returned by a previous GNUNET_REGEX_announce call.
83 GNUNET_REGEX_announce_cancel (struct GNUNET_REGEX_Announcement *a);
87 * Search callback function, invoked for every result that was found.
89 * @param cls Closure provided in GNUNET_REGEX_search.
90 * @param id Peer providing a regex that matches the string.
91 * @param get_path Path of the get request.
92 * @param get_path_length Lenght of get_path.
93 * @param put_path Path of the put request.
94 * @param put_path_length Length of the put_path.
96 typedef void (*GNUNET_REGEX_Found)(void *cls,
97 const struct GNUNET_PeerIdentity *id,
98 const struct GNUNET_PeerIdentity *get_path,
99 unsigned int get_path_length,
100 const struct GNUNET_PeerIdentity *put_path,
101 unsigned int put_path_length);
105 * Search for a peer offering a regex matching certain string in the DHT.
106 * The search runs until GNUNET_REGEX_search_cancel is called, even if results
109 * @param cfg configuration to use
110 * @param string String to match against the regexes in the DHT.
111 * @param callback Callback for found peers.
112 * @param callback_cls Closure for @c callback.
113 * @return Handle to stop search and free resources.
114 * Must be freed by calling GNUNET_REGEX_search_cancel.
116 struct GNUNET_REGEX_Search *
117 GNUNET_REGEX_search (const struct GNUNET_CONFIGURATION_Handle *cfg,
119 GNUNET_REGEX_Found callback,
124 * Stop search and free all data used by a GNUNET_REGEX_search call.
126 * @param s Handle returned by a previous GNUNET_REGEX_search call.
129 GNUNET_REGEX_search_cancel (struct GNUNET_REGEX_Search *s);
132 #if 0 /* keep Emacsens' auto-indent happy */
139 /* end of gnunet_regex_service.h */