aboutsummaryrefslogtreecommitdiff
path: root/src/util/mq.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/util/mq.c')
-rw-r--r--src/util/mq.c55
1 files changed, 45 insertions, 10 deletions
diff --git a/src/util/mq.c b/src/util/mq.c
index 81a42e0c6..eaac85575 100644
--- a/src/util/mq.c
+++ b/src/util/mq.c
@@ -2,20 +2,18 @@
2 This file is part of GNUnet. 2 This file is part of GNUnet.
3 Copyright (C) 2012-2017 GNUnet e.V. 3 Copyright (C) 2012-2017 GNUnet e.V.
4 4
5 GNUnet is free software; you can redistribute it and/or modify 5 GNUnet is free software: you can redistribute it and/or modify it
6 it under the terms of the GNU General Public License as published 6 under the terms of the GNU Affero General Public License as published
7 by the Free Software Foundation; either version 3, or (at your 7 by the Free Software Foundation, either version 3 of the License,
8 option) any later version. 8 or (at your option) any later version.
9 9
10 GNUnet is distributed in the hope that it will be useful, but 10 GNUnet is distributed in the hope that it will be useful, but
11 WITHOUT ANY WARRANTY; without even the implied warranty of 11 WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 General Public License for more details. 13 Affero General Public License for more details.
14 14
15 You should have received a copy of the GNU General Public License 15 You should have received a copy of the GNU Affero General Public License
16 along with GNUnet; see the file COPYING. If not, write to the 16 along with this program. If not, see <http://www.gnu.org/licenses/>.
17 Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
18 Boston, MA 02110-1301, USA.
19*/ 17*/
20 18
21/** 19/**
@@ -1216,6 +1214,43 @@ GNUNET_MQ_copy_handlers (const struct GNUNET_MQ_MessageHandler *handlers)
1216 1214
1217 1215
1218/** 1216/**
1217 * Copy an array of handlers, appending AGPL handler.
1218 *
1219 * Useful if the array has been delared in local memory and needs to be
1220 * persisted for future use.
1221 *
1222 * @param handlers Array of handlers to be copied. Can be NULL (nothing done).
1223 * @param agpl_handler function to call for AGPL handling
1224 * @param agpl_cls closure for @a agpl_handler
1225 * @return A newly allocated array of handlers.
1226 * Needs to be freed with #GNUNET_free.
1227 */
1228struct GNUNET_MQ_MessageHandler *
1229GNUNET_MQ_copy_handlers2 (const struct GNUNET_MQ_MessageHandler *handlers,
1230 GNUNET_MQ_MessageCallback agpl_handler,
1231 void *agpl_cls)
1232{
1233 struct GNUNET_MQ_MessageHandler *copy;
1234 unsigned int count;
1235
1236 if (NULL == handlers)
1237 return NULL;
1238 count = GNUNET_MQ_count_handlers (handlers);
1239 copy = GNUNET_new_array (count + 2,
1240 struct GNUNET_MQ_MessageHandler);
1241 GNUNET_memcpy (copy,
1242 handlers,
1243 count * sizeof (struct GNUNET_MQ_MessageHandler));
1244 copy[count].mv = NULL;
1245 copy[count].cb = agpl_handler;
1246 copy[count].cls = agpl_cls;
1247 copy[count].type = GNUNET_MESSAGE_TYPE_REQUEST_AGPL;
1248 copy[count].expected_size = sizeof (struct GNUNET_MessageHeader);
1249 return copy;
1250}
1251
1252
1253/**
1219 * Count the handlers in a handler array. 1254 * Count the handlers in a handler array.
1220 * 1255 *
1221 * @param handlers Array of handlers to be counted. 1256 * @param handlers Array of handlers to be counted.