From 90e29258a5339d232ea1b22f3f83d61701b52358 Mon Sep 17 00:00:00 2001 From: Christian Grothoff Date: Wed, 6 Jun 2018 00:32:36 +0200 Subject: changes for AGPL handling --- src/util/mq.c | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) (limited to 'src/util/mq.c') diff --git a/src/util/mq.c b/src/util/mq.c index 81a42e0c6..bf8f95790 100644 --- a/src/util/mq.c +++ b/src/util/mq.c @@ -1215,6 +1215,43 @@ GNUNET_MQ_copy_handlers (const struct GNUNET_MQ_MessageHandler *handlers) } +/** + * Copy an array of handlers, appending AGPL handler. + * + * Useful if the array has been delared in local memory and needs to be + * persisted for future use. + * + * @param handlers Array of handlers to be copied. Can be NULL (nothing done). + * @param agpl_handler function to call for AGPL handling + * @param agpl_cls closure for @a agpl_handler + * @return A newly allocated array of handlers. + * Needs to be freed with #GNUNET_free. + */ +struct GNUNET_MQ_MessageHandler * +GNUNET_MQ_copy_handlers2 (const struct GNUNET_MQ_MessageHandler *handlers, + GNUNET_MQ_MessageCallback agpl_handler, + void *agpl_cls) +{ + struct GNUNET_MQ_MessageHandler *copy; + unsigned int count; + + if (NULL == handlers) + return NULL; + count = GNUNET_MQ_count_handlers (handlers); + copy = GNUNET_new_array (count + 2, + struct GNUNET_MQ_MessageHandler); + GNUNET_memcpy (copy, + handlers, + count * sizeof (struct GNUNET_MQ_MessageHandler)); + copy[count].mv = NULL; + copy[count].cb = agpl_handler; + copy[count].cls = agpl_cls; + copy[count].type = GNUNET_MESSAGE_TYPE_REQUEST_AGPL; + copy[count].expected_size = sizeof (struct GNUNET_MessageHeader); + return copy; +} + + /** * Count the handlers in a handler array. * -- cgit v1.2.3